OpenFusion/src/NPCManager.hpp

58 lines
2.0 KiB
C++
Raw Normal View History

#pragma once
2020-08-19 22:21:35 +00:00
#include "CNProtocol.hpp"
2020-08-20 21:43:48 +00:00
#include "PlayerManager.hpp"
#include "NPC.hpp"
2020-08-19 22:21:35 +00:00
#include "contrib/JSON.hpp"
2020-08-19 22:21:35 +00:00
#include <map>
#include <vector>
2020-08-19 22:21:35 +00:00
#define RESURRECT_HEIGHT 400
// 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::map<int32_t, BaseNPC*> NPCs;
extern std::map<int32_t, WarpLocation> Warps;
extern std::vector<WarpLocation> RespawnPoints;
extern std::map<std::pair<int32_t, int32_t>, time_t> EggBuffs;
extern nlohmann::json NPCData;
extern int32_t nextId;
2020-08-19 22:21:35 +00:00
void init();
2020-09-25 01:58:20 +00:00
void addNPC(std::vector<Chunk*> viewableChunks, int32_t id);
void removeNPC(std::vector<Chunk*> viewableChunks, int32_t id);
void destroyNPC(int32_t);
void updateNPCPosition(int32_t, int X, int Y, int Z, int angle);
void updateNPCPosition(int32_t, int X, int Y, int Z);
2020-10-12 16:55:41 +00:00
void updateNPCInstance(int32_t, uint64_t instanceID);
2020-09-17 22:45:43 +00:00
void sendToViewable(BaseNPC* npc, void* buf, uint32_t type, size_t size);
void npcBarkHandler(CNSocket* sock, CNPacketData* data);
void npcSummonHandler(CNSocket* sock, CNPacketData* data);
2020-09-18 21:24:15 +00:00
void npcUnsummonHandler(CNSocket* sock, CNPacketData* data);
void npcWarpHandler(CNSocket* sock, CNPacketData* data);
void npcWarpTimeMachine(CNSocket* sock, CNPacketData* data);
void npcVendorStart(CNSocket* sock, CNPacketData* data);
void npcVendorTable(CNSocket* sock, CNPacketData* data);
void npcVendorBuy(CNSocket* sock, CNPacketData* data);
2020-09-12 02:04:23 +00:00
void npcVendorSell(CNSocket* sock, CNPacketData* data);
void npcVendorBuyback(CNSocket* sock, CNPacketData* data);
void npcVendorBuyBattery(CNSocket* sock, CNPacketData* data);
2020-09-16 00:30:01 +00:00
void npcCombineItems(CNSocket* sock, CNPacketData* data);
void handleWarp(CNSocket* sock, int32_t warpId);
BaseNPC* getNearestNPC(std::vector<Chunk*> chunks, int X, int Y, int Z);
/// returns -1 on fail
int eggBuffPlayer(CNSocket* sock, int skillId, int duration);
2020-08-19 22:21:35 +00:00
}