mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Quest API] Expand SaveGuardSpot (#2258)
* Expand SaveGuardSpot - Adds -- mob:saveguardspot() -- mob:saveguardspot(true) * Perl Support Thanks to KinglyKrab for the perl implementation.
This commit is contained in:
parent
83e066bffc
commit
e75f87a535
@ -318,6 +318,16 @@ void Lua_NPC::NextGuardPosition() {
|
|||||||
self->NextGuardPosition();
|
self->NextGuardPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lua_NPC::SaveGuardSpot() {
|
||||||
|
Lua_Safe_Call_Void();
|
||||||
|
self->SaveGuardSpot();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_NPC::SaveGuardSpot(bool clear) {
|
||||||
|
Lua_Safe_Call_Void();
|
||||||
|
self->SaveGuardSpot(clear);
|
||||||
|
}
|
||||||
|
|
||||||
void Lua_NPC::SaveGuardSpot(float x, float y, float z, float heading) {
|
void Lua_NPC::SaveGuardSpot(float x, float y, float z, float heading) {
|
||||||
Lua_Safe_Call_Void();
|
Lua_Safe_Call_Void();
|
||||||
self->SaveGuardSpot(glm::vec4(x, y, z, heading));
|
self->SaveGuardSpot(glm::vec4(x, y, z, heading));
|
||||||
@ -759,6 +769,8 @@ luabind::scope lua_register_npc() {
|
|||||||
.def("RemoveItem", (void(Lua_NPC::*)(int,int))&Lua_NPC::RemoveItem)
|
.def("RemoveItem", (void(Lua_NPC::*)(int,int))&Lua_NPC::RemoveItem)
|
||||||
.def("RemoveItem", (void(Lua_NPC::*)(int,int,int))&Lua_NPC::RemoveItem)
|
.def("RemoveItem", (void(Lua_NPC::*)(int,int,int))&Lua_NPC::RemoveItem)
|
||||||
.def("ResumeWandering", (void(Lua_NPC::*)(void))&Lua_NPC::ResumeWandering)
|
.def("ResumeWandering", (void(Lua_NPC::*)(void))&Lua_NPC::ResumeWandering)
|
||||||
|
.def("SaveGuardSpot", (void(Lua_NPC::*)(void))&Lua_NPC::SaveGuardSpot)
|
||||||
|
.def("SaveGuardSpot", (void(Lua_NPC::*)(bool))&Lua_NPC::SaveGuardSpot)
|
||||||
.def("SaveGuardSpot", (void(Lua_NPC::*)(float,float,float,float))&Lua_NPC::SaveGuardSpot)
|
.def("SaveGuardSpot", (void(Lua_NPC::*)(float,float,float,float))&Lua_NPC::SaveGuardSpot)
|
||||||
.def("ScaleNPC", (void(Lua_NPC::*)(uint8))&Lua_NPC::ScaleNPC)
|
.def("ScaleNPC", (void(Lua_NPC::*)(uint8))&Lua_NPC::ScaleNPC)
|
||||||
.def("SetCopper", (void(Lua_NPC::*)(uint32))&Lua_NPC::SetCopper)
|
.def("SetCopper", (void(Lua_NPC::*)(uint32))&Lua_NPC::SetCopper)
|
||||||
|
|||||||
@ -90,6 +90,8 @@ public:
|
|||||||
void PauseWandering(int pause_time);
|
void PauseWandering(int pause_time);
|
||||||
void MoveTo(float x, float y, float z, float h, bool save);
|
void MoveTo(float x, float y, float z, float h, bool save);
|
||||||
void NextGuardPosition();
|
void NextGuardPosition();
|
||||||
|
void SaveGuardSpot();
|
||||||
|
void SaveGuardSpot(bool clear);
|
||||||
void SaveGuardSpot(float x, float y, float z, float heading);
|
void SaveGuardSpot(float x, float y, float z, float heading);
|
||||||
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);
|
||||||
|
|||||||
@ -348,6 +348,7 @@ public:
|
|||||||
int32 GetEquipmentMaterial(uint8 material_slot) const;
|
int32 GetEquipmentMaterial(uint8 material_slot) const;
|
||||||
|
|
||||||
void NextGuardPosition();
|
void NextGuardPosition();
|
||||||
|
void SaveGuardSpot(bool ClearGuardSpot = false);
|
||||||
void SaveGuardSpot(const glm::vec4 &pos);
|
void SaveGuardSpot(const glm::vec4 &pos);
|
||||||
inline bool IsGuarding() const { return(m_GuardPoint.w != 0); }
|
inline bool IsGuarding() const { return(m_GuardPoint.w != 0); }
|
||||||
void SaveGuardSpotCharm();
|
void SaveGuardSpotCharm();
|
||||||
|
|||||||
@ -929,16 +929,27 @@ XS(XS_NPC_NextGuardPosition) {
|
|||||||
XS(XS_NPC_SaveGuardSpot); /* prototype to pass -Wmissing-prototypes */
|
XS(XS_NPC_SaveGuardSpot); /* prototype to pass -Wmissing-prototypes */
|
||||||
XS(XS_NPC_SaveGuardSpot) {
|
XS(XS_NPC_SaveGuardSpot) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
if (items != 5)
|
if (items != 1 && items != 2 && items != 5)
|
||||||
Perl_croak(aTHX_ "Usage: NPC::SaveGuardSpot(THIS, x, y, z, heading)"); // @categories Script Utility
|
Perl_croak(aTHX_ "Usage: NPC::SaveGuardSpot(THIS, x, y, z, heading)"); // @categories Script Utility
|
||||||
{
|
{
|
||||||
NPC *THIS;
|
NPC *THIS;
|
||||||
float x = (float)SvNV(ST(1));
|
if (items == 1 || items == 2) {
|
||||||
float y = (float)SvNV(ST(2));
|
bool clear_guard_spot = false;
|
||||||
float z = (float)SvNV(ST(3));
|
|
||||||
float heading = (float)SvNV(ST(4));
|
if (items > 1) {
|
||||||
VALIDATE_THIS_IS_NPC;
|
clear_guard_spot = (bool) SvTRUE(ST(1));
|
||||||
THIS->SaveGuardSpot(glm::vec4(x, y, z, heading));
|
}
|
||||||
|
|
||||||
|
VALIDATE_THIS_IS_NPC;
|
||||||
|
THIS->SaveGuardSpot(clear_guard_spot);
|
||||||
|
} else if (items == 5) {
|
||||||
|
float x = (float)SvNV(ST(1));
|
||||||
|
float y = (float)SvNV(ST(2));
|
||||||
|
float z = (float)SvNV(ST(3));
|
||||||
|
float heading = (float)SvNV(ST(4));
|
||||||
|
VALIDATE_THIS_IS_NPC;
|
||||||
|
THIS->SaveGuardSpot(glm::vec4(x, y, z, heading));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
XSRETURN_EMPTY;
|
XSRETURN_EMPTY;
|
||||||
}
|
}
|
||||||
@ -2017,7 +2028,7 @@ XS(boot_NPC) {
|
|||||||
newXSproto(strcpy(buf, "RemoveMeleeProc"), XS_NPC_RemoveMeleeProc, file, "$$");
|
newXSproto(strcpy(buf, "RemoveMeleeProc"), XS_NPC_RemoveMeleeProc, file, "$$");
|
||||||
newXSproto(strcpy(buf, "RemoveRangedProc"), XS_NPC_RemoveRangedProc, file, "$$");
|
newXSproto(strcpy(buf, "RemoveRangedProc"), XS_NPC_RemoveRangedProc, file, "$$");
|
||||||
newXSproto(strcpy(buf, "ResumeWandering"), XS_NPC_ResumeWandering, file, "$");
|
newXSproto(strcpy(buf, "ResumeWandering"), XS_NPC_ResumeWandering, file, "$");
|
||||||
newXSproto(strcpy(buf, "SaveGuardSpot"), XS_NPC_SaveGuardSpot, file, "$$$$$");
|
newXSproto(strcpy(buf, "SaveGuardSpot"), XS_NPC_SaveGuardSpot, file, "$;$$$$");
|
||||||
newXSproto(strcpy(buf, "ScaleNPC"), XS_NPC_ScaleNPC, file, "$$");
|
newXSproto(strcpy(buf, "ScaleNPC"), XS_NPC_ScaleNPC, file, "$$");
|
||||||
newXSproto(strcpy(buf, "SetCopper"), XS_NPC_SetCopper, file, "$$");
|
newXSproto(strcpy(buf, "SetCopper"), XS_NPC_SetCopper, file, "$$");
|
||||||
newXSproto(strcpy(buf, "SetGold"), XS_NPC_SetGold, file, "$$");
|
newXSproto(strcpy(buf, "SetGold"), XS_NPC_SetGold, file, "$$");
|
||||||
|
|||||||
@ -557,6 +557,20 @@ void NPC::SetWaypointPause()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NPC::SaveGuardSpot(bool ClearGuardSpot) {
|
||||||
|
if (ClearGuardSpot) {
|
||||||
|
LogAI("Clearing guard order.");
|
||||||
|
m_GuardPoint = glm::vec4();
|
||||||
|
} else {
|
||||||
|
m_GuardPoint = m_Position;
|
||||||
|
|
||||||
|
if (m_GuardPoint.w == 0) {
|
||||||
|
m_GuardPoint.w = 0.0001; //hack to make IsGuarding simpler
|
||||||
|
}
|
||||||
|
LogAI("Setting guard position to {0}", to_string(static_cast<glm::vec3>(m_GuardPoint)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NPC::SaveGuardSpot(const glm::vec4 &pos)
|
void NPC::SaveGuardSpot(const glm::vec4 &pos)
|
||||||
{
|
{
|
||||||
m_GuardPoint = pos;
|
m_GuardPoint = pos;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user