mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
Add some Follow stuff to lua
You can also disallow following code from allowing the NPC to run if they're far enough away
This commit is contained in:
parent
5e03d977d6
commit
dbb368865c
@ -333,6 +333,21 @@ void Lua_NPC::AI_SetRoambox(float dist, float max_x, float min_x, float max_y, f
|
|||||||
self->AI_SetRoambox(dist, max_x, min_x, max_y, min_y, delay, mindelay);
|
self->AI_SetRoambox(dist, max_x, min_x, max_y, min_y, delay, mindelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lua_NPC::SetFollowID(int id) {
|
||||||
|
Lua_Safe_Call_Void();
|
||||||
|
self->SetFollowID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_NPC::SetFollowDistance(int dist) {
|
||||||
|
Lua_Safe_Call_Void();
|
||||||
|
self->SetFollowDistance(dist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_NPC::SetFollowCanRun(bool v) {
|
||||||
|
Lua_Safe_Call_Void();
|
||||||
|
self->SetFollowCanRun(v);
|
||||||
|
}
|
||||||
|
|
||||||
int Lua_NPC::GetNPCSpellsID() {
|
int Lua_NPC::GetNPCSpellsID() {
|
||||||
Lua_Safe_Call_Int();
|
Lua_Safe_Call_Int();
|
||||||
return self->GetNPCSpellsID();
|
return self->GetNPCSpellsID();
|
||||||
@ -572,6 +587,9 @@ luabind::scope lua_register_npc() {
|
|||||||
.def("IsGuarding", (bool(Lua_NPC::*)(void))&Lua_NPC::IsGuarding)
|
.def("IsGuarding", (bool(Lua_NPC::*)(void))&Lua_NPC::IsGuarding)
|
||||||
.def("AI_SetRoambox", (void(Lua_NPC::*)(float,float,float,float,float))&Lua_NPC::AI_SetRoambox)
|
.def("AI_SetRoambox", (void(Lua_NPC::*)(float,float,float,float,float))&Lua_NPC::AI_SetRoambox)
|
||||||
.def("AI_SetRoambox", (void(Lua_NPC::*)(float,float,float,float,float,uint32,uint32))&Lua_NPC::AI_SetRoambox)
|
.def("AI_SetRoambox", (void(Lua_NPC::*)(float,float,float,float,float,uint32,uint32))&Lua_NPC::AI_SetRoambox)
|
||||||
|
.def("SetFollowID", (void(Lua_NPC::*)(int))&Lua_NPC::SetFollowID)
|
||||||
|
.def("SetFollowDistance", (void(Lua_NPC::*)(int))&Lua_NPC::SetFollowDistance)
|
||||||
|
.def("SetFollowCanRun", (void(Lua_NPC::*)(bool))&Lua_NPC::SetFollowCanRun)
|
||||||
.def("GetNPCSpellsID", (int(Lua_NPC::*)(void))&Lua_NPC::GetNPCSpellsID)
|
.def("GetNPCSpellsID", (int(Lua_NPC::*)(void))&Lua_NPC::GetNPCSpellsID)
|
||||||
.def("GetSpawnPointID", (int(Lua_NPC::*)(void))&Lua_NPC::GetSpawnPointID)
|
.def("GetSpawnPointID", (int(Lua_NPC::*)(void))&Lua_NPC::GetSpawnPointID)
|
||||||
.def("GetSpawnPointX", (float(Lua_NPC::*)(void))&Lua_NPC::GetSpawnPointX)
|
.def("GetSpawnPointX", (float(Lua_NPC::*)(void))&Lua_NPC::GetSpawnPointX)
|
||||||
|
|||||||
@ -92,6 +92,9 @@ public:
|
|||||||
bool IsGuarding();
|
bool IsGuarding();
|
||||||
void AI_SetRoambox(float dist, float max_x, float min_x, float max_y, float min_y);
|
void AI_SetRoambox(float dist, float max_x, float min_x, float max_y, float min_y);
|
||||||
void AI_SetRoambox(float dist, float max_x, float min_x, float max_y, float min_y, uint32 delay, uint32 mindelay);
|
void AI_SetRoambox(float dist, float max_x, float min_x, float max_y, float min_y, uint32 delay, uint32 mindelay);
|
||||||
|
void SetFollowID(int id);
|
||||||
|
void SetFollowDistance(int dist);
|
||||||
|
void SetFollowCanRun(bool v);
|
||||||
int GetNPCSpellsID();
|
int GetNPCSpellsID();
|
||||||
int GetSpawnPointID();
|
int GetSpawnPointID();
|
||||||
float GetSpawnPointX();
|
float GetSpawnPointX();
|
||||||
|
|||||||
@ -383,8 +383,9 @@ Mob::Mob(const char* in_name,
|
|||||||
m_CurrentWayPoint = glm::vec4();
|
m_CurrentWayPoint = glm::vec4();
|
||||||
cur_wp_pause = 0;
|
cur_wp_pause = 0;
|
||||||
patrol = 0;
|
patrol = 0;
|
||||||
follow = 0;
|
follow_id = 0;
|
||||||
follow_dist = 100; // Default Distance for Follow
|
follow_dist = 100; // Default Distance for Follow
|
||||||
|
follow_run = true; // We can run if distance great enough
|
||||||
no_target_hotkey = false;
|
no_target_hotkey = false;
|
||||||
flee_mode = false;
|
flee_mode = false;
|
||||||
currently_fleeing = false;
|
currently_fleeing = false;
|
||||||
|
|||||||
@ -695,10 +695,12 @@ public:
|
|||||||
virtual bool IsAttackAllowed(Mob *target, bool isSpellAttack = false);
|
virtual bool IsAttackAllowed(Mob *target, bool isSpellAttack = false);
|
||||||
bool IsTargeted() const { return (targeted > 0); }
|
bool IsTargeted() const { return (targeted > 0); }
|
||||||
inline void IsTargeted(int in_tar) { targeted += in_tar; if(targeted < 0) targeted = 0;}
|
inline void IsTargeted(int in_tar) { targeted += in_tar; if(targeted < 0) targeted = 0;}
|
||||||
void SetFollowID(uint32 id) { follow = id; }
|
void SetFollowID(uint32 id) { follow_id = id; }
|
||||||
void SetFollowDistance(uint32 dist) { follow_dist = dist; }
|
void SetFollowDistance(uint32 dist) { follow_dist = dist; }
|
||||||
uint32 GetFollowID() const { return follow; }
|
void SetFollowCanRun(bool v) { follow_run = v; }
|
||||||
|
uint32 GetFollowID() const { return follow_id; }
|
||||||
uint32 GetFollowDistance() const { return follow_dist; }
|
uint32 GetFollowDistance() const { return follow_dist; }
|
||||||
|
bool GetFollowCanRun() const { return follow_run; }
|
||||||
inline bool IsRareSpawn() const { return rare_spawn; }
|
inline bool IsRareSpawn() const { return rare_spawn; }
|
||||||
inline void SetRareSpawn(bool in) { rare_spawn = in; }
|
inline void SetRareSpawn(bool in) { rare_spawn = in; }
|
||||||
|
|
||||||
@ -1235,8 +1237,9 @@ protected:
|
|||||||
uint16 ownerid;
|
uint16 ownerid;
|
||||||
PetType typeofpet;
|
PetType typeofpet;
|
||||||
int16 petpower;
|
int16 petpower;
|
||||||
uint32 follow;
|
uint32 follow_id;
|
||||||
uint32 follow_dist;
|
uint32 follow_dist;
|
||||||
|
bool follow_run;
|
||||||
bool no_target_hotkey;
|
bool no_target_hotkey;
|
||||||
bool rare_spawn;
|
bool rare_spawn;
|
||||||
|
|
||||||
|
|||||||
@ -1647,7 +1647,8 @@ void Mob::AI_Process() {
|
|||||||
if (distance >= follow_distance) {
|
if (distance >= follow_distance) {
|
||||||
int speed = GetWalkspeed();
|
int speed = GetWalkspeed();
|
||||||
|
|
||||||
if (distance >= follow_distance + 150) {
|
// maybe we want the NPC to only walk doing follow logic
|
||||||
|
if (GetFollowCanRun() && distance >= follow_distance + 150) {
|
||||||
speed = GetRunspeed();
|
speed = GetRunspeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user