Euphy

r17280: Slight Script Engine Update

Recommended Posts

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 Timeout

The 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!~ :>

  • Upvote 5

Share this post


Link to post
Share on other sites

nice. :D

Share this post


Link to post
Share on other sites

Thanks for the news, now I have to re-examine my scripts to make sure that those 'auto-close' command won't make my quests halt in the middle :P

Share this post


Link to post
Share on other sites

Great update!

Share this post


Link to post
Share on other sites

i quite like, good job

Share this post


Link to post
Share on other sites

advantage of this.

when menu open ('select', 'prompt', 'menu') 'end' is able to terminate these scripts.

so it means it has no dialog window to make it work right?

disadvantage of this.

when menu open ('select', 'prompt', 'menu')

press esc the game setting window will appear. press esc again. the game setting windows and the menu open will disappear.

you can't move and you can't use skill, etc.

 

to fix that problem the npc should have dialog box to avoid appearing game setting windows by pressing esc.

but you must also change the end function to close function to close the dialog window.

 

so i'm confuse now if there is a real advantage for this.

Share this post


Link to post
Share on other sites

Brynner please stop spreading that false rumor, I told you 3 time already on each bugreport you bring this issue that it wasn't related to this.

You don't believe me ?

fine you can go to "src/config/secure.h" comment out //SECURE_NPCTIMEOUT recompile and try by yourself. The issue still here.

or you could "svn up -r 17279 && ./configure && make clean sql", that was before any change on this. SECURE_NPCTIMEOUT was disable by default and close; end; was acting as before

 

Your bug is really independant of this, and yes a dialogue, (a mes in script) will prevent the client to hide the menu from "select","menu","prompt" and then prevent the issue. (cause right now the client just hide that menu but we still believe we talking to the npc so we're getting stuck)

but will continue that debug conversation in the specified bugreport you did.

  • Upvote 1

Share this post


Link to post
Share on other sites

Brynner please stop spreading that false rumor, I told you 3 time already on each bugreport you bring this issue that it wasn't related to this.

You don't believe me ?

fine you can go to "src/config/secure.h" comment out //SECURE_NPCTIMEOUT recompile and try by yourself. The issue still here.

or you could "svn up -r 17279 && ./configure && make clean sql", that was before any change on this. SECURE_NPCTIMEOUT was disable by default and close; end; was acting as before

 

Your bug is really independant of this, and yes a dialogue, (a mes in script) will prevent the client to hide the menu from "select","menu","prompt" and then prevent the issue. (cause right now the client just hide that menu but we still believe we talking to the npc so we're getting stuck)

but will continue that debug conversation in the specified bugreport you did.

it's not the secure npc that i'm talking about sir. the implementation for close to end.

Share this post


Link to post
Share on other sites

still not related, try revert to r17179 the implementation of close and end ain't there and your bug still present

Share this post


Link to post
Share on other sites

no need to revert it back. i'm just waiting for the official update or fixes for those issue to avoid conflict on the source for future updates ^_^

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.