Skip to content

Instantly share code, notes, and snippets.

@vankk
Created September 10, 2019 16:36
Show Gist options
  • Save vankk/32d731a6d58d985e20a5330f048aa8f2 to your computer and use it in GitHub Desktop.
Save vankk/32d731a6d58d985e20a5330f048aa8f2 to your computer and use it in GitHub Desktop.
Author: vankk
Date: Tue Sep 10 13:34:04 2019 -0300
NPC Idle Fix
diff --git a/sources/src/npc.cpp b/sources/src/npc.cpp
index 60e225d..83fee35 100644
--- a/sources/src/npc.cpp
+++ b/sources/src/npc.cpp
@@ -58,7 +58,8 @@ Npc::Npc(const std::string& name) :
filename("data/npc/" + name + ".xml"),
npcEventHandler(nullptr),
masterRadius(-1),
- loaded(false)
+ loaded(false),
+ isIdle(true)
{
reset();
}
@@ -102,6 +103,7 @@ void Npc::reset()
floorChange = false;
attackable = false;
ignoreHeight = true;
+ isIdle = true;
focusCreature = 0;
speechBubble = SPEECHBUBBLE_NONE;
@@ -122,7 +124,7 @@ void Npc::reload()
npcEventHandler->onCreatureAppear(this);
}
- if (walkTicks > 0) {
+ if (!isIdle && walkTicks > 0) {
addEventWalk();
}
}
@@ -244,7 +246,7 @@ void Npc::onCreatureAppear(Creature* creature, bool isLogin)
Creature::onCreatureAppear(creature, isLogin);
if (creature == this) {
- if (walkTicks > 0) {
+ if (!isIdle && walkTicks > 0) {
addEventWalk();
}
@@ -331,7 +333,7 @@ void Npc::onThink(uint32_t interval)
{
Creature::onThink(interval);
- if (npcEventHandler) {
+ if (!isIdle && npcEventHandler) {
npcEventHandler->onThink();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment