summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-10-11 18:43:29 -0400
committergumi <mekolat@users.noreply.github.com>2017-10-11 18:44:17 -0400
commit03049799efdc103fdd74e77161ed6a907acb7dde (patch)
treef8499e41d1118650255cde17e5093e84c5eef592 /npc
parent9df794b30d8372da248c0c78151dec5cad1743a6 (diff)
downloadserverdata-03049799efdc103fdd74e77161ed6a907acb7dde.tar.gz
serverdata-03049799efdc103fdd74e77161ed6a907acb7dde.tar.bz2
serverdata-03049799efdc103fdd74e77161ed6a907acb7dde.tar.xz
serverdata-03049799efdc103fdd74e77161ed6a907acb7dde.zip
fix npc talk lock mechanism
it was setting a var in the function rather than in the NPC
Diffstat (limited to 'npc')
-rw-r--r--npc/functions/main.txt34
1 files changed, 14 insertions, 20 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt
index b2827a52..5f8c7aea 100644
--- a/npc/functions/main.txt
+++ b/npc/functions/main.txt
@@ -169,32 +169,26 @@ function script compareandsetq {
// 1 = npctalk
// 2 = message
function script npctalkonce {
- if (getarg(2, 0) == 0)
+ // lock mechanism
+ switch (getarg(2, 0))
{
+ case 1:
+ if (gettimetick(2) <= getvariableofnpc(.talk_lock, strnpcinfo(NPC_NAME_UNIQUE)))
+ return false;
+ set(getvariableofnpc(.talk_lock, strnpcinfo(NPC_NAME_UNIQUE)), gettimetick(2) + getarg(1, 1));
+ break;
+ default:
if (gettimetick(2) <= @NPC_TALK_LOCK[getnpcid(0)])
- {
return false;
- }
@NPC_TALK_LOCK[getnpcid(0)] = gettimetick(2) + getarg(1, 1);
- npctalk3(getarg(0));
- }
- else if (getarg(2, 0) == 1)
- {
- if (gettimetick(2) <= .talk_lock)
- {
- return false;
- }
- .talk_lock = gettimetick(2) + getarg(1, 1);
- npctalk(getarg(0));
}
- else if (getarg(2, 0) == 2)
+
+ // talk mechanism
+ switch (getarg(2, 0))
{
- if (gettimetick(2) <= @NPC_TALK_LOCK[getnpcid(0)])
- {
- return false;
- }
- @NPC_TALK_LOCK[getnpcid(0)] = gettimetick(2) + getarg(1, 1);
- message(strcharinfo(0), getarg(0));
+ case 0: npctalk3(getarg(0)); break;
+ case 1: npctalk(getarg(0)); break;
+ case 2: message(strcharinfo(0), getarg(0));
}
return true;