From 03049799efdc103fdd74e77161ed6a907acb7dde Mon Sep 17 00:00:00 2001 From: gumi Date: Wed, 11 Oct 2017 18:43:29 -0400 Subject: fix npc talk lock mechanism it was setting a var in the function rather than in the NPC --- npc/functions/main.txt | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'npc') 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; -- cgit v1.2.3-70-g09d2