Slight Script Engine Update
r17280 applies a handful of changes that are just barely worth mentioning.
'close' vs. 'end'
Prior to this update, the 'close' command could be used to used to end scripts without having a dialogue window open. This is bad practice, since 'end' is the proper command; now the map-server will output a reminder to edit those scripts:
[Warning]: Incorrect use of 'close' command! (source:Example NPC / path:npc/custom/Example.txt)Some of you may have also noticed that, before this change, only 'close' could end a script with a menu open ('select', 'prompt', 'menu'). This has been corrected; now 'end' is able to terminate these scripts.// Before:
select("Choice 1:Choice 2");
close;
// After:
select("Choice 1:Choice 2");
end;
NPC TimeoutThe more noticeable change is the completion of the "Secure NPC Timeout" feature, turned on by default (as it is on official servers). With this change, NPCs will automatically terminate if the attached player is idle for a given period of time:
/**
* Optional NPC Dialog Timer
* When enabled all npcs dialog will 'timeout' if user is on idle for longer than the amount of seconds allowed
* - On 'timeout' the npc dialog window changes its next/menu to a 'close' button
* Comment to disable the timer.
**/
#define SECURE_NPCTIMEOUT
/**
+ * Number of seconds after an 'input' field is displayed before invoking an idle timeout.
+ * Default: 180
**/
#define NPC_SECURE_TIMEOUT_INPUT 180
/**
+ * Number of seconds after a 'menu' is displayed before invoking an idle timeout.
+ * Default: 60
**/
#define NPC_SECURE_TIMEOUT_MENU 60
/**
+ * Number of seconds after a 'next' button is displayed before invoking an idle timeout.
+ * Default: 60
**/
#define NPC_SECURE_TIMEOUT_NEXT 60
For instance, a "next" button will automatically turn into "close" after 60 seconds have passed.So what?
if (QuestVariable == 4) {
/* Section 1 */
mes "You've completed the quest.";
set QuestVariable,5;
next;
/* --------- */
mes "Here's your reward!";
getitem 512,1;
close;
} else if (QuestVariable == 5) {
mes "You've already claimed a prize!";
close;
}
In the snippet above, idling in the first section (marked off by *) will end the script before the player can receive a reward. While this may be a stretch, less-obvious cases certainly do exist.The point: Make sure to check that these changes do not cause any errors or exploits in your custom scripts. They shouldn't, for the most part, but they will break poorly-written NPCs.
Thanks for reading!~ :>