2020-08-27 20:16:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-03-17 19:07:40 +00:00
|
|
|
#include "core/Core.hpp"
|
2021-03-13 22:55:16 +00:00
|
|
|
#include "NPCManager.hpp"
|
2020-09-16 23:43:48 +00:00
|
|
|
|
|
|
|
enum class MobState {
|
|
|
|
INACTIVE,
|
|
|
|
ROAMING,
|
|
|
|
COMBAT,
|
|
|
|
RETREAT,
|
|
|
|
DEAD
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Mob : public BaseNPC {
|
2020-09-24 01:18:41 +00:00
|
|
|
// general
|
2020-09-16 23:43:48 +00:00
|
|
|
MobState state;
|
2020-09-24 22:36:25 +00:00
|
|
|
int maxHealth;
|
2020-09-22 18:33:10 +00:00
|
|
|
int spawnX;
|
|
|
|
int spawnY;
|
|
|
|
int spawnZ;
|
functional crates (no more plungers) (#133)
* FM, Taros and Boosts awards from killing mobs should be pretty
accurate now. A temporary formula for adjusting player/mob level gap is
implemented, but it will probably need to be adjusted in the future
* Mobs now drop correct crates
* Crates can be opened and give you correct items This includes
regular mob crates, world boss crates, mission crates, IZ race crates,
E.G.G.E.R.s, golden Eggs, and Event Crates. Keep in mind that neither
IZ races or golden Eggs are implemented, but if you spawn such a crate
it can be opened.
* All data is read from a json file, for which I'm going to release a
tool soon so it's easily adjustable
* There is a new setting for enabling events, which enables dropping
extra event crates These are Knishmas, Halloween and Easter
2020-10-10 17:18:47 +00:00
|
|
|
int level;
|
2020-09-22 18:33:10 +00:00
|
|
|
|
2020-10-17 17:26:09 +00:00
|
|
|
std::unordered_map<int32_t,time_t> unbuffTimes;
|
|
|
|
|
2020-09-24 01:18:41 +00:00
|
|
|
// dead
|
|
|
|
time_t killedTime = 0;
|
2020-09-24 20:55:33 +00:00
|
|
|
time_t regenTime;
|
2020-09-24 22:36:25 +00:00
|
|
|
bool summoned = false;
|
2020-09-24 01:18:41 +00:00
|
|
|
bool despawned = false; // for the sake of death animations
|
|
|
|
|
|
|
|
// roaming
|
|
|
|
int idleRange;
|
2020-10-20 22:55:58 +00:00
|
|
|
const int sightRange;
|
2020-09-22 18:33:10 +00:00
|
|
|
time_t nextMovement = 0;
|
2020-10-12 19:03:18 +00:00
|
|
|
bool staticPath = false;
|
2020-10-17 17:26:09 +00:00
|
|
|
int roamX, roamY, roamZ;
|
2020-09-22 18:33:10 +00:00
|
|
|
|
2020-09-24 01:18:41 +00:00
|
|
|
// combat
|
|
|
|
CNSocket *target = nullptr;
|
|
|
|
time_t nextAttack = 0;
|
2020-10-28 21:05:01 +00:00
|
|
|
time_t lastDrainTime = 0;
|
2020-11-25 08:10:05 +00:00
|
|
|
int skillStyle = -1; // -1 for nothing, 0-2 for corruption, -2 for eruption
|
2020-11-25 02:51:17 +00:00
|
|
|
int hitX, hitY, hitZ; // for use in ability targeting
|
2020-09-24 01:18:41 +00:00
|
|
|
|
2020-10-17 23:19:05 +00:00
|
|
|
// drop
|
functional crates (no more plungers) (#133)
* FM, Taros and Boosts awards from killing mobs should be pretty
accurate now. A temporary formula for adjusting player/mob level gap is
implemented, but it will probably need to be adjusted in the future
* Mobs now drop correct crates
* Crates can be opened and give you correct items This includes
regular mob crates, world boss crates, mission crates, IZ race crates,
E.G.G.E.R.s, golden Eggs, and Event Crates. Keep in mind that neither
IZ races or golden Eggs are implemented, but if you spawn such a crate
it can be opened.
* All data is read from a json file, for which I'm going to release a
tool soon so it's easily adjustable
* There is a new setting for enabling events, which enables dropping
extra event crates These are Knishmas, Halloween and Easter
2020-10-10 17:18:47 +00:00
|
|
|
int dropType;
|
|
|
|
|
2020-11-15 07:06:29 +00:00
|
|
|
// group
|
|
|
|
int groupLeader = 0;
|
|
|
|
int offsetX, offsetY;
|
|
|
|
int groupMember[4] = {0, 0, 0, 0};
|
|
|
|
|
2020-09-22 18:33:10 +00:00
|
|
|
// temporary; until we're sure what's what
|
|
|
|
nlohmann::json data;
|
|
|
|
|
2021-03-21 02:54:24 +00:00
|
|
|
Mob(int x, int y, int z, int angle, uint64_t iID, int t, nlohmann::json d, int32_t id)
|
|
|
|
: BaseNPC(x, y, z, angle, iID, t, id),
|
2020-12-14 05:26:17 +00:00
|
|
|
maxHealth(d["m_iHP"]),
|
2020-10-20 22:55:58 +00:00
|
|
|
sightRange(d["m_iSightRange"]) {
|
2020-09-16 23:43:48 +00:00
|
|
|
state = MobState::ROAMING;
|
|
|
|
|
2020-09-24 01:18:41 +00:00
|
|
|
data = d;
|
|
|
|
|
|
|
|
regenTime = data["m_iRegenTime"];
|
2020-12-17 00:59:55 +00:00
|
|
|
idleRange = (int)data["m_iIdleRange"];
|
functional crates (no more plungers) (#133)
* FM, Taros and Boosts awards from killing mobs should be pretty
accurate now. A temporary formula for adjusting player/mob level gap is
implemented, but it will probably need to be adjusted in the future
* Mobs now drop correct crates
* Crates can be opened and give you correct items This includes
regular mob crates, world boss crates, mission crates, IZ race crates,
E.G.G.E.R.s, golden Eggs, and Event Crates. Keep in mind that neither
IZ races or golden Eggs are implemented, but if you spawn such a crate
it can be opened.
* All data is read from a json file, for which I'm going to release a
tool soon so it's easily adjustable
* There is a new setting for enabling events, which enables dropping
extra event crates These are Knishmas, Halloween and Easter
2020-10-10 17:18:47 +00:00
|
|
|
dropType = data["m_iDropType"];
|
|
|
|
level = data["m_iNpcLevel"];
|
2020-09-24 01:18:41 +00:00
|
|
|
|
2020-10-13 19:44:43 +00:00
|
|
|
roamX = spawnX = appearanceData.iX;
|
|
|
|
roamY = spawnY = appearanceData.iY;
|
|
|
|
roamZ = spawnZ = appearanceData.iZ;
|
2020-09-22 18:33:10 +00:00
|
|
|
|
2020-11-23 00:14:22 +00:00
|
|
|
offsetX = 0;
|
|
|
|
offsetY = 0;
|
|
|
|
|
2020-09-22 20:22:10 +00:00
|
|
|
appearanceData.iConditionBitFlag = 0;
|
|
|
|
|
2020-09-16 23:43:48 +00:00
|
|
|
// NOTE: there appear to be discrepancies in the dump
|
|
|
|
appearanceData.iHP = maxHealth;
|
2020-09-24 22:36:25 +00:00
|
|
|
|
2021-03-21 02:54:24 +00:00
|
|
|
type = EntityType::MOB;
|
2020-09-24 22:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// constructor for /summon
|
2021-03-21 02:54:24 +00:00
|
|
|
Mob(int x, int y, int z, uint64_t iID, int t, nlohmann::json d, int32_t id)
|
|
|
|
: Mob(x, y, z, 0, iID, t, d, id) {
|
2020-09-24 22:36:25 +00:00
|
|
|
summoned = true; // will be despawned and deallocated when killed
|
2020-09-16 23:43:48 +00:00
|
|
|
}
|
2020-09-24 22:36:25 +00:00
|
|
|
|
2020-09-18 21:24:15 +00:00
|
|
|
~Mob() {}
|
2020-09-22 18:33:10 +00:00
|
|
|
|
|
|
|
auto operator[](std::string s) {
|
|
|
|
return data[s];
|
|
|
|
}
|
2020-09-16 23:43:48 +00:00
|
|
|
};
|
2020-08-27 20:16:52 +00:00
|
|
|
|
2021-03-13 22:55:16 +00:00
|
|
|
namespace MobAI {
|
2020-10-07 18:38:32 +00:00
|
|
|
extern bool simulateMobs;
|
2021-03-13 22:55:16 +00:00
|
|
|
extern std::map<int32_t, Mob*> Mobs;
|
2020-09-16 23:43:48 +00:00
|
|
|
|
2020-08-27 20:16:52 +00:00
|
|
|
void init();
|
2021-03-13 22:55:16 +00:00
|
|
|
|
|
|
|
// TODO: make this internal later
|
2020-10-12 19:03:18 +00:00
|
|
|
void incNextMovement(Mob *mob, time_t currTime=0);
|
2020-10-04 23:54:08 +00:00
|
|
|
bool aggroCheck(Mob *mob, time_t currTime);
|
2020-10-28 21:05:01 +00:00
|
|
|
void clearDebuff(Mob *mob);
|
2020-11-16 03:13:40 +00:00
|
|
|
void followToCombat(Mob *mob);
|
2020-12-30 22:07:10 +00:00
|
|
|
void groupRetreat(Mob *mob);
|
2021-01-09 13:16:29 +00:00
|
|
|
void enterCombat(CNSocket *sock, Mob *mob);
|
2020-08-27 20:16:52 +00:00
|
|
|
}
|