Jump to content

r17280: Slight Script Engine Update


Euphy

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

nice. :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

Great update!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  177
  • Topics Per Day:  0.04
  • Content Count:  909
  • Reputation:   247
  • Joined:  11/08/11
  • Last Seen:  

i quite like, good job

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  118
  • Topics Per Day:  0.03
  • Content Count:  1942
  • Reputation:   197
  • Joined:  01/08/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  118
  • Topics Per Day:  0.03
  • Content Count:  1942
  • Reputation:   197
  • Joined:  01/08/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  118
  • Topics Per Day:  0.03
  • Content Count:  1942
  • Reputation:   197
  • Joined:  01/08/12
  • Last Seen:  

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 ^_^

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...