mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-01-24 07:20:49 +00:00
Implemented mob roaming.
Will likely need further tuning. Mobs in vacant chunks are skipped.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "NPC.hpp"
|
||||
|
||||
#include "contrib/JSON.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
enum class MobState {
|
||||
@@ -22,14 +24,32 @@ struct Mob : public BaseNPC {
|
||||
const int regenTime;
|
||||
bool despawned = false; // for the sake of death animations
|
||||
|
||||
Mob(int x, int y, int z, int type, int hp, int angle, int rt)
|
||||
: BaseNPC(x, y, z, type), maxHealth(hp), regenTime(rt) {
|
||||
int spawnX;
|
||||
int spawnY;
|
||||
int spawnZ;
|
||||
|
||||
const int idleRange;
|
||||
time_t nextMovement = 0;
|
||||
|
||||
// temporary; until we're sure what's what
|
||||
nlohmann::json data;
|
||||
|
||||
Mob(int x, int y, int z, int type, int hp, int angle, nlohmann::json d)
|
||||
: BaseNPC(x, y, z, type), maxHealth(hp), regenTime(d["m_iRegenTime"]), idleRange(d["m_iIdleRange"]), data(d) {
|
||||
state = MobState::ROAMING;
|
||||
|
||||
spawnX = appearanceData.iX;
|
||||
spawnY = appearanceData.iY;
|
||||
spawnZ = appearanceData.iZ;
|
||||
|
||||
// NOTE: there appear to be discrepancies in the dump
|
||||
appearanceData.iHP = maxHealth;
|
||||
}
|
||||
~Mob() {}
|
||||
|
||||
auto operator[](std::string s) {
|
||||
return data[s];
|
||||
}
|
||||
};
|
||||
|
||||
namespace MobManager {
|
||||
@@ -39,6 +59,7 @@ namespace MobManager {
|
||||
void step(time_t);
|
||||
|
||||
void deadStep(Mob*, time_t);
|
||||
void roamingStep(Mob*, time_t);
|
||||
|
||||
void pcAttackNpcs(CNSocket *sock, CNPacketData *data);
|
||||
void combatBegin(CNSocket *sock, CNPacketData *data);
|
||||
|
||||
Reference in New Issue
Block a user