viewing paste script commands | Text

Posted on the
  1. //===== Athena Doc ===========================================
  2. //= rAthena Script Commands
  3. //===== By: ==================================================
  4. //= rAthena Dev Team
  5. //===== Current Version: =====================================
  6. //= $Revision: 15819 $
  7. //===== Last Updated: ========================================
  8. //= $LastChangedDate: 2012-04-01 00:52:58 +0200 (So, 01 Apr 2012) $
  9. //===== Description: =========================================
  10. //= A reference manual for the rAthena scripting language.
  11. //= Commands are sorted depending on their functionality.
  12. //============================================================
  13.  
  14. This document is a reference manual for all the scripting commands and functions 
  15. available in current rAthena SVN. It is not a simple tutorial. When people tell 
  16. you to "Read The F***ing Manual", they mean this.
  17.  
  18. The information was mostly acquired through looking up how things actually work 
  19. in the source code of the server, which was written by many people over time, 
  20. and lots of them don't speak English and never left any notes - or are otherwise 
  21. not available for comments. As such, anything written in here might not be 
  22. correct, it is only correct to the best of our knowledge, which is limited.
  23.  
  24. This is not a place to teach you basic programming. This document will not teach 
  25. you basic programming by itself. It's more of a reference for those who have at 
  26. least a vague idea of what they want to do and want to know what tools they have 
  27. available to do it. We've tried to keep it as simple as feasible, but if you 
  28. don't understand it, getting a clear book on programming in general will help 
  29. better than yelling around the forum for help.
  30.  
  31. A little learning never caused anyone's head to explode.
  32.  
  33. Structure
  34. ---------
  35.  
  36. The commands and functions are listed in no particular order:
  37.  
  38. *Name of the command and how to call it.
  39.  
  40. Descriptive text
  41.  
  42.     Small example if possible. Will usually be incomplete, it's there just to 
  43.     give you an idea of how it works in practice.
  44.  
  45. To find a specific command, use Ctrl+F, (or whatever keys call up a search 
  46. function in whatever you're reading this with) put an * followed by the command 
  47. name, and it should find the command description for you.
  48.  
  49. If you find anything omitted, please respond. :)
  50.  
  51. Syntax
  52. ------
  53.  
  54. Throughout this document, wherever a command wants an argument, it is given in 
  55. <angle brackets>. This doesn't mean you should type the angle brackets. :) If an 
  56. argument of a command is optional, it is given in {curly brackets}. You've 
  57. doubtlessly seen this convention somewhere, if you didn't, get used to it, 
  58. that's how big boys do it. If a command can optionally take an unspecified 
  59. number of arguments, you'll see a list like this:
  60.  
  61. command <argument>{,<argument>...<argument>}
  62.  
  63. This still means they will want to be separated by commas.
  64.  
  65. Where a command wants a string, it will be given in "quotes", if it's a number, 
  66. it will be given without them. Normally, you can put an expression, like a bunch 
  67. of functions or operators returning a value, in (round brackets) instead of most 
  68. numbers. Round brackets will not always be required, but they're often a good 
  69. idea.
  70.  
  71. Wherever you refer to a map name, it's always 'mapname' or 'mapname.gat'
  72. (Please, don't use .gat suffix anymore. It's useless.) 
  73.  
  74.  
  75. Script loading structure
  76. ------------------------
  77.  
  78. Scripts are loaded by the map server as referenced in the 'conf/map_athena.conf' 
  79. configuration file, but in the default configuration, it doesn't load any script 
  80. files itself. Instead, it loads the file 'npc/scripts_main.conf' which itself 
  81. contains references to other files. The actual scripts are loaded from txt 
  82. files, which are linked up like this:
  83.  
  84. npc: <path to a filename>
  85.  
  86. Any line like this, invoked, ultimately, by 'map_athena.conf' will load up the 
  87. script contained in this file, which will make the script available. No file 
  88. will get loaded twice, to prevent possible errors.
  89.  
  90. Another configuration file option of relevance is:
  91.  
  92. delnpc: <path to a filename>
  93.  
  94. This will unload a specified script filename from memory, which, while 
  95. seemingly useless, may sometimes be required.
  96.  
  97. Whenever '//' is encountered in a line upon reading, everything beyond this on 
  98. that line is considered to be a comment and is ignored. This works wherever you 
  99. place it.
  100.  
  101. // This line will be ignored when processing the script.
  102.  
  103. Block comments can also be used, where you can place /* and */ between any text you 
  104. wish rAthena to ignore.
  105.  
  106. Example:
  107. /* This text,
  108.  * no matter which new line you start
  109.  * is ignored, until the following 
  110.  * symbol is encountered: */
  111.  
  112. The asterisks (*) in front of each line is a personal preference, and is not required.
  113.  
  114. Upon loading all the files, the server will execute all the top-level commands 
  115. in them. No variables exist yet at this point, no commands can be called other 
  116. than those given in this section. These commands set up the basic server script 
  117. structure - create NPC objects, spawn monster objects, set map flags, etc. No 
  118. code is actually executed at this point except them. The top-level commands the 
  119. scripting are pretty confusing, since they aren't structured like you would 
  120. expect commands, command name first, but rather, normally start with a map name.
  121.  
  122. What's more confusing about the top-level commands is that most of them use a 
  123. tab symbol to divide their arguments.
  124.  
  125. To prevent problems and confusion, the tab symbols are written as '%TAB%' 
  126. throughout this document, even though this makes the text a bit less readable. 
  127. Using an invisible symbol to denote arguments is one of the bad things about 
  128. this language, but we're stuck with it for now. :)
  129.  
  130. Here is a list of valid top-level commands:
  131.  
  132. ** Set a map flag:
  133.  
  134. <map name>%TAB%mapflag%TAB%<flag>
  135.  
  136. This will, upon loading, set a specified map flag on a map you like. These are 
  137. normally in files inside 'conf/mapflag' and are loaded first, so by the time the 
  138. server's up, all the maps have the flags they should have. Map flags determine 
  139. the behavior of the map regarding various common problems, for a better 
  140. explanation, see 'setmapflag'.
  141.  
  142. ** Create a permanent monster spawn:
  143.  
  144. <map name>,<x>,<y>,<xs>,<ys>%TAB%monster%TAB%<monster name>%TAB%<mob id>,<amount>,<delay1>,<delay2>,<event>
  145.  
  146. Map name is the name of the map the monsters will spawn on. x,y are the
  147. coordinates where the mob should spawn. If xs and ys are non-zero, they
  148. specify the 'radius' of a spawn-rectangle area centered at x,y.
  149. Putting zeros instead of these coordinates will spawn the monsters randomly.
  150. Note this is only the initial spawn zone, as mobs random-walk, they are free
  151. to move away from their specified spawn region.
  152.  
  153. Monster name is the name the monsters will have on screen, and has no relation 
  154. whatsoever to their names anywhere else. It's the mob id that counts, which 
  155. identifies monster record in 'mob_db.txt' database of monsters. If the mob name 
  156. is given as "--ja--", the 'japanese name' field from the monster database is 
  157. used, (which, in rAthena, actually contains an english name) if it's "--en--", 
  158. it's the 'english name' from the monster database (which contains an uppercase 
  159. name used to summon the monster with a GM command).
  160.  
  161. If you add 20000 to the monster ID, the monster will be spawned in a 'big 
  162. version', (monster size class will increase) and if you add 10000, the 'tiny 
  163. version' of the monster will be created. However, this method is deprecated
  164. and not recommended, as the values to add can change at a later time (20000
  165. and 10000 actually stand for 2*MAX_MOB_DB and MAX_MOB_DB respectively, which
  166. is defined on mob.h, and can change in the future as more mobs are created).
  167. The recommended way to change a mob's size is to use the event-field (see
  168. below).
  169.  
  170. Amount is the amount of monsters that will be spawned when this command is 
  171. executed, it is affected by spawn rates in 'battle_athena.conf'.
  172.  
  173. Delay1 and delay2 control monster respawn delays - the first one is the fixed
  174. base respawn time, and the second is random variance on top of the base time.
  175. Both values are given in miliseconds (1000 = 1 second).
  176. Note that the server also enforces a minimum respawn delay of 5 seconds.
  177.  
  178. You can specify a custom level to use for the mob different from the one of
  179. the database by adjoining the level after the name with a comma. eg:
  180. "Poring,50" for a name will spawn a monster with name Poring and level 50.
  181.  
  182. Event is a script event to be executed when the mob is killed. The event must
  183. be in the form "NPCName::OnEventName" to execute, and the event name label
  184. should start with "On". As with all events, if the NPC is an on-touch NPC, the
  185. player who triggers the script must be within 'trigger' range for the event to
  186. work.
  187.  
  188. The Event field can be used alternatively to specify other mob properties. Use
  189. 2 to specify that the mob should be small, 4 for big monsters, and 8 for
  190. special ai mobs (which by default attack other monsters instead of players).
  191. You can add these, so using 10 will spawn small monsters that attack other
  192. mobs (if you specify both 2 and 4, the small version takes priority).
  193.  
  194. ** NPC names
  195.  
  196. /!\ WARNING: this applies to warps, NPCs, duplicates and shops /!\
  197.  
  198. NPC names are kinda special and are formatted this way:
  199.  
  200. <Display name>{::<Unique name>}
  201.  
  202. All NPCs need to have a unique name that is used for identification purposes.
  203. When you have to identify a NPC by it's name, you should use <Unique name>.
  204. If <Unique name> is not provided, use <Display name> instead.
  205.  
  206. The client has a special feature when displaying names:
  207. if the display name contains a '#' character, it hides that part of the name.
  208. ex: if your NPC is named 'Hunter#hunter1', it will be displayed as 'Hunter'
  209.  
  210. <Display name> must be at most 24 characters in length.
  211. <Unique name> must be at most 24 characters in length.
  212.  
  213. ** Define a warp point
  214.  
  215. <from map name>,<fromX>,<fromY>,<facing>%TAB%warp%TAB%<warp name>%TAB%<spanx>,<spany>,<to map name>,<toX>,<toY>
  216.  
  217. This will define a warp NPC that will warp a player between maps, and while most 
  218. arguments of that are obvious, some deserve special mention.
  219.  
  220. SpanX and SpanY will make the warp sensitive to a character who didn't step 
  221. directly on it, but walked into a zone which is centered on the warp from 
  222. coordinates and is SpanX in each direction across the X axis and SpanY in each 
  223. direction across the Y axis.
  224.  
  225. Warp NPC objects also have a name, because you can use it to refer to them later 
  226. with 'enablenpc'/'disablenpc' 
  227.  
  228. Facing of a warp object is irrelevant, it is not used in the code and all 
  229. current scripts have a zero in there.
  230.  
  231. ** Define an NPC object.
  232.  
  233. <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,{<code>}
  234. <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>}
  235.  
  236. This will place an NPC object on a specified map at the specified location, and 
  237. is a top-level command you will use the most in your custom scripting. The NPCs 
  238. are triggered by clicking on them, and/or by walking in their trigger area, if 
  239. defined, see that below.
  240.  
  241. Facing is a direction the NPC sprite will face in. Not all NPC sprites have 
  242. different images depending on the direction you look from, so for some facing 
  243. will be meaningless. Facings are counted counterclockwise in increments of 45 
  244. degrees, where 0 means facing towards the top of the map. (So to turn the sprite 
  245. towards the bottom of the map, you use facing 4, and to make it look southeast 
  246. it's facing 5.)
  247.  
  248. Sprite id is the sprite number used to display this particular NPC. For a full 
  249. list of sprite id numbers see http://kalen.s79.xrea.com/npc/npce.shtml You may 
  250. also use a monster's ID number instead to display a monster sprite for this NPC. 
  251. It is possible to use a job sprite as well, but you must first define it as a 
  252. monster sprite in 'mob_avail.txt', a full description on how to do this is not 
  253. in the scope of this manual.
  254. A '-1' sprite id will make the NPC invisible (and unclickable). 
  255. A '111' sprite id will make an NPC which does not have a sprite, but is still 
  256. clickable, which is useful if you want to make a clickable object of the 3D 
  257. terrain.
  258.  
  259. TriggerX and triggerY, if given, will define an area, centered on NPC and 
  260. spanning triggerX cells in every direction across X and triggerY in every 
  261. direction across Y. Walking into that area will trigger the NPC. If no 
  262. 'OnTouch:' special label is present in the NPC code, the execution will start 
  263. from the beginning of the script, otherwise, it will start from the 'OnTouch:' 
  264. label. Monsters can also trigger the NPC, though the label 'OnTouchNPC:' is 
  265. used in this case.
  266.  
  267. The code part is the script code that will execute whenever the NPC is 
  268. triggered. It may contain commands and function calls, descriptions of which 
  269. compose most of this document. It has to be in curly brackets, unlike elsewhere 
  270. where we use curly brackets, these do NOT signify an optional parameter.
  271.  
  272. ** Define a 'floating' NPC object.
  273.  
  274. -%TAB%script%TAB%<NPC Name>%TAB%-1,{<code>}
  275.  
  276. This will define an NPC object not triggerable by normal means. This would 
  277. normally mean it's pointless since it can't do anything, but there are 
  278. exceptions, mostly related to running scripts at specified time, which is what 
  279. these floating NPC objects are for. More on that below.
  280.  
  281. ** Define a shop/cashshop NPC.
  282.  
  283. -%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
  284. <map name>,<x>,<y>,<facing>%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
  285.  
  286. This will define a shop NPC, which, when triggered (which can only be done by 
  287. clicking) will cause a shop window to come up. No code whatsoever runs in shop 
  288. NPCs and you can't change the prices otherwise than by editing the script 
  289. itself. (No variables even exist at this point of scripting, so don't even 
  290. bother trying to use them.)
  291.  
  292. The item id is the number of item in the 'item_db.txt' database. If Price is set 
  293. to -1, the 'buy price' given in the item database will be used. Otherwise, the 
  294. price you gave will be used for this item, which is how you create differing 
  295. prices for items in different shops.
  296.  
  297. Since trunk r12264 you can alternatively use "cashshop" in place of "shop"
  298. to use the Cash Shop interface, allowing you to buy items with special points
  299. (Currently stored as account vars in global_reg #CASHPOINTS and #KAFRAPOINTS.)
  300. This type of shop will not allow you to sell items at it, you may only
  301. purchase items here. The layout used to define sale items still count, and
  302. "<price>" refers to how many points will be spent purchasing the them.
  303.  
  304. ** Define an warp/shop/cashshop/NPC duplicate.
  305.  
  306. warp: <map name>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<spanx>,<spany>
  307. shop/cashshop/npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>
  308. shop/cashshop/npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>
  309. npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>
  310. npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>
  311.  
  312. This will duplicate an warp/shop/cashshop/NPC referred to by 'label'.
  313. Warp duplicates inherit the target location.
  314. Shop/cashshop duplicates inherit the item list.
  315. NPC duplicates inherit the script code.
  316. The rest (name, location, facing, sprite ID, span/trigger area)
  317. is obtained from the definition of the duplicate (not inherited).
  318.  
  319. ** Define a function object
  320.  
  321. function%TAB%script%TAB%<function name>%TAB%{<code>}
  322.  
  323. This will define a function object, callable with the 'callfunc' command (see 
  324. below). This object will load on every map server separately, so you can get at 
  325. it from anywhere. It's not possible to call the code in this object by 
  326. anything other than the 'callfunc' script command.
  327.  
  328. The code part is the script code that will execute whenever the function is 
  329. called with 'callfunc'. It has to be in curly brackets, unlike elsewhere where 
  330. we use curly brackets, these do NOT signify an optional parameter.
  331.  
  332.  
  333. Once an object is defined which has a 'code' field to it's definition, it 
  334. contains script commands which can actually be triggered and executed. 
  335.  
  336. ~ RID? GID? ~
  337.  
  338. What a RID is and why do you need to know
  339. -----------------------------------------
  340.  
  341. Most scripting commands and functions will want to request data about a 
  342. character, store variables referenced to that character, send stuff to the 
  343. client connected to that specific character. Whenever a script is invoked by a 
  344. character, it is passed a so-called RID - this is the account ID number of a 
  345. character that caused the code to execute by clicking on it, walking into it's 
  346. OnTouch zone, or otherwise.
  347.  
  348. If you are only writing common NPCs, you don't need to bother with it. However, 
  349. if you use functions, if you use timers, if you use clock-based script 
  350. activation, you need to be aware of all cases when a script execution can be 
  351. triggered without a RID attached. This will make a lot of commands and functions 
  352. unusable, since they want data from a specific character, want to send stuff to 
  353. a specific client, want to store variables specific to that character, and they 
  354. would not know what character to work on if there's no RID.
  355.  
  356. Unless you use 'attachrid' to explicitly attach a character to the script first.
  357.  
  358. Whenever we say 'invoking character', we mean 'the character who's RID is 
  359. attached to the running script. The script function "playerattached" can be
  360. used to check which is the currently attached player to the script (it will
  361. return 0 if the there is no player attached or the attached player no longer
  362. is logged on to the map-server).
  363.  
  364. But what about GID?
  365. --- ---- ----- ----
  366.  
  367. GID stands for the Game ID of something, this can either be the GID obtained
  368. through mobspawn (mob control commands) or the account ID of a character.
  369. Another way would be to right click on a mob, 
  370. NPC or char as GM sprited char to view the GID.
  371.  
  372. This is mostly used for the new version of skill and the mob control commmands
  373. implemented (but NEVER documented by Lance. Shame on you...).
  374.  
  375. Item and pet scripts
  376. --------------------
  377.  
  378. Each item in the item database has three special fields - Script , OnEquip_Script
  379. and OnUnequip_Script. The first is script code run every time a character equips the item, 
  380. with the RID of the equipping character. Every time they unequip an item, all 
  381. temporary bonuses given by the script commands are cleared, and all the scripts 
  382. are executed once again to rebuild them. This also happens in several other 
  383. situations (like upon login) but the full list is currently unknown.
  384.  
  385. OnEquip_Script is a piece of script code run whenever the item is used by a character 
  386. by doubleclicking on it. OnUnequip_Script runs whenever the
  387. equipment is unequip by a character
  388.  
  389. Not all script commands work properly in the item scripts. Where commands and 
  390. functions are known to be meant specifically for use in item scripts, they are 
  391. described as such.
  392.  
  393. Every pet in the pet database has a PetScript field, which determines pet 
  394. behavior. It is invoked wherever a pet of the specified type is spawned. 
  395. (hatched from an egg, or loaded from the char server when a character who had 
  396. that pet following them connects) This may occur in some other situations as 
  397. well. Don't expect anything other than commands definitely marked as usable in 
  398. pet scripts to work in there reliably.
  399.  
  400. Numbers
  401. -------
  402.  
  403. Beside the common decimal numbers, which are nothing special whatsoever (though 
  404. do not expect to use fractions, since ALL numbers are integer in this language), 
  405. the script engine also handles hexadecimal numbers, which are otherwise 
  406. identical. Writing a number like '0x<hex digits>' will make it recognized as a 
  407. hexadecimal value. Notice that 0x10 is equal to 16. Also notice that if you try 
  408. to 'mes 0x10' it will print '16'.
  409.  
  410. This is not used much, but it pays to know about it.
  411.  
  412. Variables
  413. ---------
  414.  
  415. The meat of every programming language is variables - places where you store 
  416. data.
  417.  
  418. In the rAthena scripting language, variable names are not case sensitive.
  419.  
  420. Variables are divided into and uniquely identified by the combination of:
  421. prefix  - determines the scope and extent (or lifetime) of the variable
  422. name    - an identifier consisting of '_' and alphanumeric characters
  423. postfix - determines the type of the variable: integer or string
  424.  
  425. Scope can be:
  426. global    - global to all servers
  427. local     - local to the server
  428. account   - attached to the account of the character identified by RID
  429. character - attached to the character identified by RID
  430. npc       - attached to the NPC
  431. scope     - attached to the scope of the instance
  432.  
  433. Extent can be:
  434. permanent - They still exist when the server resets.
  435. temporary - They cease to exist when the server resets.
  436.  
  437. Prefix: scope and extent
  438. nothing  - A permanent variable attached to the character, the default variable
  439.            type. They are stored with all the account data in "save\athena.txt"
  440.            in TXT versions and in the SQL versions in the `global_reg_value`
  441.            table using type 3.
  442. "@"      - A temporary variable attached to the character.
  443.            SVN versions before 2094 revision and RC5 version will also treat
  444.            'l' as a temporary variable prefix, so beware of having variable
  445.            names starting with 'l' if you want full backward compatibility.
  446. "$"      - A global permanent variable.
  447.            They are stored in "save\mapreg.txt" or database table `mapreg`,
  448.            depending on server type.
  449. "$@"     - A global temporary variable.
  450.            This is important for scripts which are called with no RID
  451.            attached, that is, not triggered by a specific character object.
  452. "."      - A NPC variable.
  453.            They exist in the NPC and disappear when the server restarts or the 
  454.            NPC is reloaded. Can be accessed from inside the NPC or by calling 
  455.            'getvariableofnpc'. Function objects can also have .variables which 
  456.            are accessible from inside the function, however 'getvariableofnpc' 
  457.            does NOT work on function objects.
  458. ".@"     - A scope variable.
  459.            They are unique to the instance and scope. Each instance has it's 
  460.            own scope that ends when the script ends. Calling a function with 
  461.            callsub/callfunc starts a new scope, returning from the function 
  462.            ends it. When a scope ends, it's variables are converted to values 
  463.            ('return .@var;' returns a value, not a reference).
  464. "'"      - An instance variable
  465.            These are used with the instancing system, and are unique to each 
  466.            party's instance.
  467. "#"      - A permanent local account variable.
  468.            They are stored with all the account data in "save\accreg.txt" in
  469.            TXT versions and in the SQL versions in the 'global_reg_value'
  470.            table using type 2.
  471. "##"     - A permanent global account variable stored by the login server.
  472.            They are stored in "save\account.txt" and in the SQL versions in the
  473.            'global_reg_value' table, using type 1. The only difference you will
  474.            note from normal # variables is when you have multiple char-servers
  475.            connected to the same login server. The # variables are unique to
  476.            each char-server, while the ## variables are shared by all these
  477.            char-servers.
  478.  
  479. Postfix: integer or string
  480. nothing - integer variable, can store positive and negative numbers, but only 
  481.           whole numbers (so don't expect to do any fractional math)
  482. '$'     - string variable, can store text
  483.  
  484. Examples:
  485.   name  - permanent character integer variable
  486.   name$ - permanent character string variable
  487.  @name  - temporary character integer variable
  488.  @name$ - temporary character string variable
  489.  $name  - permanent global integer variable
  490.  $name$ - permanent global string variable
  491. $@name  - temporary global integer variable
  492. $@name$ - temporary global string variable
  493.  .name  - NPC integer variable
  494.  .name$ - NPC string variable
  495. .@name  - scope integer variable
  496. .@name$ - scope string variable
  497.  #name  - permanent local account integer variable
  498.  #name$ - permanent local account string variable
  499. ##name  - permanent global account integer variable
  500. ##name$ - permanent global account string variable
  501.  
  502. If a variable was never set, it is considered to equal zero for integer 
  503. variables or an empty string ("", nothing between the quotes) for string 
  504. variables. Once you set it to that, the variable is as good as forgotten 
  505. forever, and no trace remains of it even if it was stored with character or 
  506. account data.
  507.  
  508. Some variables are special, that is, they are already defined for you by the 
  509. scripting engine. You can see the full list somewhere in 'db/const.txt', which 
  510. is a file you should read, since it also allows you to replace lots of numbered 
  511. arguments for many commands with easier to read text. The special variables most 
  512. commonly used are all permanent character-based variables:
  513.  
  514. StatusPoint - Amount of status points remaining.
  515. BaseLevel   - Current base level
  516. SkillPoint  - Amount of skill points remaining
  517. Class       - Current job
  518. Upper       - 1 if the character is an advanced job class.
  519. Zeny        - Current amount of Zeny
  520. Sex         - Character's gender, 0 if female, 1 if male.
  521. Weight      - The weight the character currently carries.
  522. MaxWeight   - The maximum weight the character can carry.
  523. JobLevel    - Character's job level
  524. BaseExp     - The amount of base experience points the character has.
  525.               Notice that it's zero (or close) if the character just got a level.
  526. JobExp      - Same for job levels
  527. NextBaseExp - Amount of experience points needed to reach the next base level.
  528. NextJobExp  - Same for job levels.
  529. Hp          - Current amount of hit points.
  530. MaxHp       - Maximum amount of hit points.
  531. Sp          - Current spell points.
  532. MaxSp       - Maximum amount of spell points.
  533. BaseJob     - This is sneaky, apparently meant for baby class support.
  534.               This will supposedly equal Job_Acolyte regardless of whether the 
  535.               character is an acolyte or a baby acolyte, for example.
  536. Karma       - The character's karma. Karma system is not fully functional, but 
  537.               this doesn't mean this doesn't work at all. Not tested.
  538. Manner      - The character's manner rating. Becomes negative if the player 
  539.               utters words forbidden through the use of 'manner.txt' client-side 
  540.               file.
  541.  
  542. While these behave as variables, do not always expect to just set them - it is 
  543. not certain whether this will work for all of them. Whenever there is a command 
  544. or a function to set something, it's usually preferable to use that instead. The 
  545. notable exception is Zeny, which you can and often will address directly -
  546. setting it will make the character own this number of Zeny.
  547. If you try to set Zeny to a negative number, the script will be terminated with an error.
  548.  
  549. Strings
  550. -------
  551.  
  552. To include symbol '"' in a string you should use prefix '\"'
  553.  
  554.  
  555. Arrays
  556. ------
  557.  
  558. Arrays (in rAthena at least) are essentially a set of variables going under the 
  559. same name. You can tell between the specific variables of an array with an 
  560. 'array index', a number of a variable in that array:
  561.  
  562. <variable name>[<array index>]
  563.  
  564. Variables stored in this way, inside an array, are also called 'array elements'. 
  565. Arrays are specifically useful for storing a set of similar data (like several 
  566. item IDs for example) and then looping through it. You can address any array 
  567. variable as if it was a normal variable:
  568.  
  569.     set @arrayofnumbers[0],1;
  570.  
  571. You can also do sneaky things like using a variable (or an expression, or even a 
  572. value from an another array) to get at an array value:
  573.  
  574.     set @x,100;
  575.     set @arrayofnumbers[@x],10;
  576.  
  577. This will make @arrayofnumbers[100] equal to 10.
  578.  
  579. Notice that index numbering always starts with 0. Arrays cannot hold more than 
  580. 128 variables. (So the last one can't have a number higher than 127)
  581.  
  582. And array indexes probably can't be negative. Nobody tested what happens when 
  583. you try to get a negatively numbered variable from an array, but it's not going 
  584. to be pretty. :)
  585.  
  586. Arrays can naturally store strings:
  587.  
  588. @menulines$[0] is the 0th element of the @menulines$ array of strings. Notice 
  589. the '$', normally denoting a string variable, before the square brackets that 
  590. denotes an array index.
  591.  
  592. Resume of the allowed variable and array scopes
  593. ------ -- --- ------- -------- --- ----- ------
  594.  
  595. +==========+======+=======+
  596. |VarType   | Norm | Array |
  597. +==========+======+=======+
  598. |$Str$     | OK!  | OK!   |
  599. +----------+------+-------+
  600. |$@Str$    | OK!  | OK!   |
  601. +----------+------+-------+
  602. |@Str$     | OK!  | OK!   |
  603. +----------+------+-------+
  604. |#Str$     | OK!  | FAIL! |
  605. +----------+------+-------+
  606. |Str$      | OK!  | FAIL! |
  607. +----------+------+-------+
  608. |$Int      | OK!  | OK!   |
  609. +----------+------+-------+
  610. |$@Int     | OK!  | OK!   |
  611. +----------+------+-------+
  612. |@Int      | OK!  | OK!   |
  613. +----------+------+-------+
  614. |#Int      | OK!  | FAIL! |
  615. +----------+------+-------+
  616. |Int       | OK!  | FAIL! |
  617. +----------+------+-------+
  618. |.Str$     | OK!  | OK!   |
  619. +----------+------+-------+
  620. |.Int      | OK!  | OK!   |
  621. +----------+------+-------+
  622. |.@Str$    | OK!  | OK!   |
  623. +----------+------+-------+
  624. |.@Int     | OK!  | OK!   |
  625. +----------+------+-------+
  626.  
  627. Variable References
  628. -------------------
  629.  
  630. //##TODO
  631.  
  632.  
  633.  
  634. Operators
  635. ---------
  636.  
  637. Operators are things you can do to variables and numbers. They are either the 
  638. common mathematical operations or conditional operators
  639.  
  640. + - will add two numbers. If you try to add two strings, the result will be a 
  641.     string glued together at the +. You can add a number to a string, and the
  642.     result will be a string. No other math operators work with strings.
  643. - - will subtract two numbers. 
  644. * - will multiply two numbers.
  645. / - will divide two numbers. Note that this is an integer division, i.e.
  646.     7/2 is not equal 3.5, it's equal 3.
  647. % - will give you the remainder of the division. 7%2 is equal to 1.
  648.  
  649. There are also conditional operators. This has to do with the conditional 
  650. command 'if' and they are meant to return either 1 if the condition is satisfied 
  651. and 0 if it isn't. (That's what they call 'boolean' variables. 0 means 'False'. 
  652. Anything except the zero is 'True' Odd as it is, -1 and -5 and anything below 
  653. zero will also be True.)
  654.  
  655. You can compare numbers to each other and you compare strings to each other, but 
  656. you can not compare numbers to strings.
  657.  
  658.  ==  - Is true if both sides are equal. For strings, it means they are the same.
  659.  >=  - True if the first value is equal to, or greater than, the second value.
  660.  <=  - True if the first value is equal to, or less than, the second value
  661.  >   - True if the first value greater than the second value
  662.  <   - True if the first value is less than the second value
  663.  !=  - True if the first value IS NOT equal to the second one
  664.  
  665. Examples:
  666.  
  667.  1==1 is True.
  668.  1<2 is True while 1>2 is False.
  669.  @x>2 is True if @x is equal to 3. But it isn't true if @x is 2.
  670.  
  671. Only '==' and '!=' have been tested for comparing strings. Since there's no way 
  672. to code a seriously complex data structure in this language, trying to sort 
  673. strings by alphabet would be pointless anyway.
  674.  
  675. Comparisons can be stacked in the same condition:
  676.  
  677.  && - Is True if and only if BOTH sides are true.
  678.       ('1==1 && 2==2' is true. '2==1 && 1==1' is false.)
  679.  || - Is True if either side of this expression is True.
  680.  
  681.  1==1 && 2==2 is True.
  682.  1==1 && 2==1 is False.
  683.  1==1 || 2==1 is True.
  684.  
  685. Logical bitwise operators work only on numbers, and they are the following:
  686.  
  687.  << - Left shift.
  688.  >> - Right shift.
  689. 	Left shift moves the binary 1(s) of a number n positions to the left,
  690. 	which is the same as multiplying by 2, n times.
  691. 	In the other hand, Right shift moves the binary 1(s) of a number n positions
  692. 	to the right, which is the same as dividing by 2, n times.
  693. 		Example:
  694. 		set b,2;
  695. 		set a, b << 3;
  696. 		mes a;
  697. 		set a, a >> 2;
  698. 		mes a;
  699. 	The first mes command would display 16, which is the same as 2 x (2 x 2 x 2) = 16.
  700. 	The second mes command would display 4, which is the same as 16 / 2 = 8. 8 / 2 = 4.
  701.  &  - And.
  702.  |  - Or.
  703. 	The bitwise operator AND (&) is used to test two values against each other, 
  704. 	and results in setting bits which are active in both arguments. This can
  705. 	be used for a few things, but in rAthena this operator is usually used to
  706. 	create bit-masks in scripts. 
  707.  
  708. 	The bitwise operator OR (|)sets to 1 a binary position if the binary position
  709. 	of one of the numbers is 1. This way a variable can hold several values we can check,
  710. 	known as bit-mask. A variable currently can hold up to 32 bit-masks (from position 0
  711. 	to position 1). This is a cheap(skate) and easy way to avoid using arrays to store several checks
  712. 	that a player can have.
  713.  
  714. 	A bit-mask basically is (ab)using the variables bits to set various options in 
  715. 	one variable. With the current limit if variables it is possible to store 32 
  716. 	different options in one variable (by using the bits on position 0 to 31).
  717.  
  718. 	Example(s):
  719. 	- Basic example of the & operator, bit example:
  720. 		10 & 2 = 2
  721. 	Why? :
  722. 		10 = 2^1 + 2^3 (2 + 8), so in bits, it would be 1010
  723. 		2 = 2^1 (2), so in bits (same size) it would be 0010
  724. 		The & (AND) operator sets bits which are active (1) in both arguments, so in the
  725. 		example 1010 & 0010, only the 2^1 bit is active (1) in both. Resulting in the bit
  726. 		0010, which is 2.
  727. 	- Basic example of creating and using a bit-mask:
  728. 		set @options,2|4|16; //(note: this is the same as 2+4+16, or 22)
  729. 		if (@options & 1)	mes "Option 1 is activated";
  730. 		if (@options & 2) mes "Option 2 is activated";
  731. 		if (@options & 4) mes "Option 3 is activated";
  732. 		if (@options & 8) mes "Option 4 is activated";
  733. 		if (@options & 16) mes "Options 5 is activated";
  734. 	This would return the messages about option 2, 3 and 5 being shown (since we've set
  735. 	the 2,4 and 16 bit to 1).
  736.  ^  - Xor.
  737. 	The bitwise operator XOR (eXclusive OR) sets a binary position to 0 if both 
  738. 	numbers have the same value in the said position. On the other hand, it 
  739. 	sets to 1 if they have different values in the said binary position.
  740. 	This is another way of setting and unsetting bits in bit-masks.
  741.  
  742. 	Example:
  743. 	- First let's set the quests that are currently in progress:
  744. 		set inProgress,1|8|16; // quest 1,8 and 16 are in progress
  745. 	- After playing for a bit, the player starts another quest:
  746. 		if( inProgress&2 == 0 ){
  747. 			// this will set the bit for quest 2 (inProgress has that bit set to 0)
  748. 			set inProgress,inProgress^2;
  749. 			mes "Quest 2: find a newbie and be helpful to him for an hour.";
  750. 			close;
  751. 		}
  752. 	- After spending some time reading info on Xor's, the player finally completes quest 1:
  753. 		if( inProgress&1 && isComplete ){
  754. 			// this will unset the bit for quest 1 (inProgress has that bit set to 1)
  755. 			set inProgress,inProgress^1;
  756. 			mes "Quest 1 complete!! You unlocked the secrets of the Xor dynasty, use them wisely.";
  757. 			close;
  758. 		}
  759.  
  760. Unary operators with only with a single number, which follows the operator, and
  761. are following:
  762.  
  763.  -  - Negation.
  764. 	The sign of the number will be reversed. If the number was positive, it will
  765. 	become negative and vice versa.
  766.  
  767. 	Example:
  768. 		set .@myvar,10;
  769. 		mes "Negative 10 is "+(-.@myvar);
  770.  
  771.  !  - Logical Not.
  772. 	Reverses the boolean result of an expression. True will become false and
  773. 	false will become true.
  774.  
  775. 	Example:
  776. 		if(!callfunc("F_dosomething"))
  777. 		{
  778. 			mes "Doing something failed.";
  779. 			close;
  780. 		}
  781.  
  782.  ~  - Bitwise Not.
  783. 	Reverses each bit in a number, also known as one's complement. Cleared bits
  784. 	are set, and set bits are cleared.
  785.  
  786. 	Example:
  787. 	- Ensure, that quest 2 is disabled, while keeping all other active, if they are.
  788. 		set inProgress,inProgress&(~2);  // same as set inProgress,inProgress&0xfffffffd
  789.  
  790. Ternary operators take three expressions (numbers, strings or boolean), and are
  791. following:
  792.  
  793.  ?: - Conditional operator
  794. 	Very useful e.g. to replace
  795.  
  796. 		if(Sex) mes "..."; else mes "...";
  797.  
  798. 	clauses with simple
  799.  
  800. 		mes "Welcome, " + (Sex?"Mr.":"Mrs.") + " " + strcharinfo(0);
  801.  
  802. 	or to replace any other simple if-else clauses. It might be worth
  803. 	mentioning that ?: has low priority and has to be enclosed with
  804. 	parenthesis in most (if not all) cases.
  805.  
  806. Labels
  807. ------
  808.  
  809. Within executable script code, some lines can be labels:
  810.  
  811. <label name>:
  812.  
  813. Labels are points of reference in your script, which can be used to route 
  814. execution with 'goto', 'menu' and 'jump_zero' commands, invoked with 'doevent' 
  815. and 'donpcevent' commands and are otherwise essential. A label's name may not be 
  816. longer than 22 characters. (23rd is the ':'.) There is some confusion in the 
  817. source about whether it's 22, 23 or 24 all over the place, so keeping labels 
  818. under 22 characters could be wise. In addition to labels you name yourself, 
  819. there are also some special labels which the script engine will start execution 
  820. from if a special event happens:
  821.  
  822. OnClock<hour><minute>:
  823. OnMinute<minute>:
  824. OnHour<hour>:
  825. On<weekday><hour><minute>:
  826. OnDay<month><day>:
  827.  
  828. This will execute when the server clock hits the specified date or time. Hours 
  829. and minutes are given in military time. ('0105' will mean 01:05 AM). Weekdays 
  830. are Sun,Mon,Tue,Wed,Thu,Fri,Sat. Months are 01 to 12, days are 01 to 31. 
  831. Remember the zero. :)
  832.  
  833. OnInit:
  834. OnInterIfInit:
  835. OnInterIfInitOnce:
  836.  
  837. OnInit will execute every time the scripts loading is complete, including when 
  838. they are reloaded with @reloadscript command. OnInterIfInit will execute when 
  839. the map server connects to a char server, OnInterIfInitOnce will only execute 
  840. once and will not execute if the map server reconnects to the char server later.
  841.  
  842. OnAgitStart:
  843. OnAgitEnd:
  844. OnAgitInit:
  845. OnAgitStart2:
  846. OnAgitEnd2:
  847. OnAgitInit2:
  848.  
  849. OnAgitStart will run whenever the server shifts into WoE mode, whether it is 
  850. done with @agitstart GM command or with 'AgitStart' script command. OnAgitEnd 
  851. will do likewise for the end of WoE.
  852.  
  853. OnAgitInit will run when data for all castles and all guilds that hold a castle 
  854. is received by map-server from the char-server after initial connect.
  855.  
  856. No RID will be attached while any of the above mentioned labels are triggered, so 
  857. no character or account-based variables will be accessible, until you attach a 
  858. RID with 'attachrid' (see below).
  859.  
  860. The above also applies to, the last three labels, the only difference is that
  861. these labels are used exclusively for WoE SE, and are called independently.
  862.  
  863. OnTouch:
  864.  
  865. This label will be executed if a trigger area is defined for the NPC object it's 
  866. in. If it isn't present, the execution will start from the beginning of the NPC 
  867. code. The RID of the triggering character object will be attached.
  868.  
  869. OnPCLoginEvent:
  870. OnPCLogoutEvent:
  871. OnPCBaseLvUpEvent:
  872. OnPCJobLvUpEvent:
  873.  
  874. It's pretty obvious when these four special labels will be invoked. For more
  875. information, see 'doc/sample/PCLoginEvent.txt'
  876.  
  877. OnPCDieEvent:
  878.  
  879. This special label triggers when a player dies. The variable 'killerrid' is
  880. set to the ID of the killer.
  881.  
  882. OnPCKillEvent:
  883.  
  884. This special label triggers when a player kills another player. The variable
  885. 'killedrid' is set to the ID of the player killed.
  886.  
  887. OnNPCKillEvent:
  888.  
  889. This special label triggers when a player kills a monster. The variable
  890. 'killedrid' is set to the Class of the monster killed.
  891.  
  892. OnPCLoadMapEvent:
  893.  
  894. This special label will trigger once a player steps in a map marked with the 
  895. 'loadevent' mapflag and attach its RID. The fact that this label requires a 
  896. mapflag for it to work is because, otherwise, it'd be server-wide and trigger
  897. every time a player would change maps. Imagine the server load with 1,000 players
  898. (oh the pain...)
  899.  
  900. Only the special labels which are not associated with any script command are 
  901. listed here. There are other kinds of labels which may be triggered in a similar 
  902. manner, but they are described with their associated commands.
  903.  
  904. On<label name>:
  905.  
  906. These special labels are used with Mob scripts mostly, and script commands
  907. that requires you to point/link a command to a mob or another NPC, giving a label
  908. name to start from. The label name can be any of your liking, but must be
  909.  
  910. Example:
  911.  
  912. monster "prontera",123,42,"Poringz0rd",2341,23,"Master::OnThisMobDeath";
  913.  
  914. amatsu,13,152,4	script	Master	767,{
  915. 	mes "Hi there";
  916. 	close;
  917.  
  918. OnThisMobDeath:
  919. 	announce "Hey, "+strcharinfo(0)+" just killed a Poringz0rd!",bc_blue|bc_all;
  920. 	end;
  921. }
  922.  
  923. Each time you kill one, that announce will appear in blue to everyone.
  924.  
  925. "Global" labels
  926.  
  927. There's a catch with labels and doevent. If you call a label (using doevent)
  928. and called label is in NPC that has trigger area, that label must end with
  929. "Global" to work globally (i.e. if RID is outside of the trigger area, which
  930. usually happens since otherwise there would be no point calling the label with
  931. doevent, because OnTouch would do the job). For further reference look for
  932. npc_event in npc.c.
  933.  
  934. Scripting commands and functions
  935. --------------------------------
  936.  
  937. The commands and functions are listed here in no particular order. There's a 
  938. difference between commands and functions - commands leave no 'return value' 
  939. which might be used in a conditional statement, as a command argument, or stored 
  940. in a variable. Calling commands as if they were functions will sometimes work, 
  941. but is not advised, as this can lead to some hard to track errors. Calling 
  942. functions as if they were commands will mess up the stack, so 'return' command 
  943. will not return correctly after this happens in a particular script.
  944.  
  945. All commands must end with a ';'. Actually, you may expect to have multiple 
  946. commands on one line if you properly terminate them with a ';', but it's better 
  947. if you don't, since it is not certain just whether the scripting engine will 
  948. behave nicely if you do.
  949.  
  950. -------------------------
  951.  
  952.  
  953. From here on, we will have the commands sorted as follow:
  954.  
  955. 1.- Basic commands.
  956. 2.- Information-retrieving commands.
  957. 3.- Checking commands.
  958. 4.- Player-related commands.
  959. 5.- Mob / NPC -related commands.
  960. 6.- Other commands.
  961. 7.- Instance commands.
  962. 8.- Quest Log commands.
  963. 9.- Battleground commands.
  964. 10.- Mercenary commands.
  965.  
  966. =====================
  967. |1.- Basic commands.|
  968. =====================
  969. ---------------------------------------
  970.  
  971. *mes "<string>";
  972.  
  973. This command will displays a box on the screen for the invoking character, if no 
  974. such box is displayed already, and will print the string specified into that 
  975. box. There is normally no 'close' or 'next' button on this box, unless you 
  976. create one with 'close' or 'next', and while it's open the player can't do much 
  977. else, so it's important to create a button later. If the string is empty, it 
  978. will show up as an empty line.
  979.  
  980.     mes "Text that will appear in the box";
  981.  
  982. Inside the string you may put color codes, which will alter the color of the 
  983. text printed after them. The color codes are all '^<R><G><B>' and contain three 
  984. hexadecimal numbers representing colors as if they were HTML colors - ^FF0000 is 
  985. bright red, ^00FF00 is bright green, ^0000FF is bright blue, ^000000 is black. 
  986. ^FF00FF is a pure magenta, but it's also a color that is considered transparent 
  987. whenever the client is drawing windows on screen, so printing text in that color 
  988. will have kind of a weird effect. Once you've set a text's color to something, 
  989. you have to set it back to black unless you want all the rest of the text be in 
  990. that color:
  991.  
  992.     mes "This is ^FF0000 red ^000000 and this is ^00FF00 green, ^000000 so.";
  993.  
  994. Notice that the text coloring is handled purely by the client. If you use non-
  995. english characters, the color codes might get screwed if they stick to letters 
  996. with no intervening space. Separating them with spaces from the letters on 
  997. either side solves the problem.
  998.  
  999. To display multiple lines of message while only using a single mes; command,
  1000. use the script command in the following format:
  1001.  
  1002.     mes "Line 1", "Line 2", "Line 3";
  1003.  
  1004. This will display 3 different lines while only consuming a single line in
  1005. the relevant script file.
  1006.  
  1007. ---------------------------------------
  1008.  
  1009. *next;
  1010.  
  1011. This command will display a 'next' button in the message window for the
  1012. invoking character. Clicking on it will cause the window to clear and display
  1013. a new one. Used to segment NPC-talking, next is often used in combination with
  1014. 'mes' and 'close'.
  1015.  
  1016. If no window is currently on screen, one will be created, but once the invoking
  1017. character clicks on it, a warning is thrown on the server console and the script
  1018. will terminate.
  1019.  
  1020.     mes "[Woman]";
  1021.     mes "This would appear on the page";
  1022.     next;
  1023.     // This is needed cause it is a new page and the top will now be blank
  1024.     mes "[Woman]";
  1025.     mes "This would appear on the 2nd page";
  1026.  
  1027. ---------------------------------------
  1028.  
  1029. *close;
  1030.  
  1031. This command will create a 'close' button in the message window for the invoking 
  1032. character. If no window is currently on screen, the script execution will end. This is one 
  1033. of the ways to end a speech from an NPC. Once the button is clicked, the NPC 
  1034. script execution will end, and the message box will disappear.
  1035.  
  1036.     mes "[Woman]";
  1037.     mes "I am finished talking to you, click the close button";
  1038.     close;
  1039.     mes "This command will not run at all, cause the script has ended.";
  1040.  
  1041. ---------------------------------------
  1042.  
  1043. *close2;
  1044.  
  1045. This command will create a 'close' button in the message window for the invoking 
  1046. character. WARNING: If no window is currently on screen, the script execution will halt 
  1047. indefinitely! See 'close'. There is one important difference, though - even though 
  1048. the message box will have closed, the script execution will not stop, and commands after 
  1049. 'close2' will still run, meaning an 'end' has to be used to stop the script, unless you 
  1050. make it stop in some other manner.
  1051.  
  1052.     mes "[Woman]";
  1053.     mes "I will warp you now";
  1054.     close2;
  1055.     warp "place",50,50;
  1056.     end;
  1057.  
  1058. Don't expect things to run smoothly if you don't make your scripts 'end'.
  1059.  
  1060. ---------------------------------------
  1061.  
  1062. *end;
  1063.  
  1064. This command will stop the execution for this particular script. The two 
  1065. versions are perfectly equivalent. It is the normal way to end a script which 
  1066. does not use 'mes'.
  1067.  
  1068.         if (BaseLevel<=10) goto L_Lvl10;
  1069.         if (BaseLevel<=20) goto L_Lvl20;
  1070.         if (BaseLevel<=30) goto L_Lvl30;
  1071.         if (BaseLevel<=40) goto L_Lvl40;
  1072.         if (BaseLevel<=50) goto L_Lvl50;
  1073.         if (BaseLevel<=60) goto L_Lvl60;
  1074.         if (BaseLevel<=70) goto L_Lvl70;
  1075.     L_Lvl10:
  1076.         npctalk "Look at that you are still a n00b";
  1077.         end;
  1078.     L_Lvl20:
  1079.         npctalk "Look at that you are getting better, but still a n00b";
  1080.         end;
  1081.     L_Lvl30:
  1082.         npctalk "Look at that you are getting there, you are almost 2nd profession now right???";
  1083.         end;
  1084.     L_Lvl40:
  1085.         npctalk "Look at that you are almost 2nd profession";
  1086.         end;
  1087.  
  1088. Without the use if 'end' it would travel through the labels until the end of the 
  1089. script. If you were lvl 10 or less, you would see all the speech lines, the use 
  1090. of 'end' stops this, and ends the script.
  1091.  
  1092. ---------------------------------------
  1093.  
  1094. *set <variable>,<expression>;
  1095. *set(<variable>,<expression>)
  1096.  
  1097. This command will set a variable to the value that the expression results in. 
  1098. This is the only way to set a variable directly.
  1099.  
  1100. This is the most basic script command and is used a lot whenever you try to do 
  1101. anything more advanced than just printing text into a message box.
  1102.  
  1103.     set @x,100;
  1104.  
  1105. will make @x equal 100.
  1106.  
  1107.     set @x,1+5/8+9;
  1108.  
  1109. will compute 1+5/8+9 (which is, surprisingly, 10 - remember, all numbers are 
  1110. integer in this language) and make @x equal it.
  1111.  
  1112. Returns the variable reference (since trunk r12870).
  1113.  
  1114. ---------------------------------------
  1115.  
  1116. *setd "<variable name>",<value>;
  1117.  
  1118. Works almost identical as set, just that the variable name is identified as a string, 
  1119. thus can be constructed dynamically.
  1120. This command is equivalent to:
  1121. set getd("variable name"),<value>;
  1122.  
  1123. Example:
  1124. set $var$, "Poring";
  1125.  
  1126. setd "$var$", "Poporing";
  1127. mes $var$; // Will return Poporing
  1128.  
  1129. setd "$" + $var$ + "123$", "Poporing is cool";
  1130. mes $Poporing123$; // Will return Poporing is cool.
  1131.  
  1132. ---------------------------------------
  1133.  
  1134. *getd("<variable name>")
  1135.  
  1136. Returns a reference to a variable, the name can be constructed dynamically.
  1137. Refer to setd for usage.
  1138.  
  1139. Example:
  1140. set getd("$varRefence"), 1;
  1141. set @i, getd("$pikachu");
  1142.  
  1143. ---------------------------------------
  1144.  
  1145. *getvariableofnpc(<variable>,"<npc name>")
  1146.  
  1147. Returns a reference to a NPC variable (. prefix) from the target NPC.
  1148. This can only be used to get . variables.
  1149. Example(s):
  1150.  
  1151. //This will return the value of .var, note that this can't be used, since the value isn't caught.
  1152. 	getvariableofnpc(.var,"TargetNPC");
  1153.  
  1154. //This will set the .v variable to the value of the TargetNPC's .var variable.
  1155. 	set .v,getvariableofnpc(.var,"TargetNPC");
  1156.  
  1157. //This will set the .var variable of TargetNPC to 1.
  1158. 	set getvariableofnpc(.var,"TargetNPC"),1;
  1159.  
  1160. Note: even though function objects can have .variables, 
  1161. getvariableofnpc will not work on them.
  1162.  
  1163. ---------------------------------------
  1164.  
  1165. *goto <label>;
  1166.  
  1167. This command will make the script jump to a label, usually used in conjunction 
  1168. with other command, such as "if", but often used on it's own.
  1169.  
  1170. 	...
  1171. 	goto Label;
  1172. 	mes "This will not be seen";
  1173. Label:
  1174. 	mes "This will be seen";
  1175.  
  1176. Note by FlavioJS: goto's are "evil" and should be avoided if possible (�_�)
  1177.  
  1178. ---------------------------------------
  1179.  
  1180. *menu "<option_text>",<target_label>{,"<option_text>",<target_label>,...};
  1181.  
  1182. This command will create a selectable menu for the invoking character. Only one 
  1183. menu can be on screen at the same time.
  1184.  
  1185. Depending on what the player picks from the menu, the script execution will 
  1186. continue from the corresponding label. (it's string-label pairs, not label-
  1187. string)
  1188.  
  1189. Options can be grouped together, separated by the character ':'.
  1190.  
  1191. 	menu "A:B",L_Wrong,"C",L_Right;
  1192.  
  1193. It also sets a special temporary character variable @menu, which contains the 
  1194. number of option the player picked. (Numbering of options starts at 1.)
  1195. This number is consistent with empty options and grouped options.
  1196.  
  1197.        menu "A::B",L_Wrong,"",L_Impossible,"C",L_Right;
  1198.     L_Wrong:
  1199.        // If they click "A" or "B" they will end up here
  1200. 	   // @menu == 1 if "A"
  1201. 	   // @menu == 2 will never happen because the option is empty
  1202. 	   // @menu == 3 if "B"
  1203. 	L_Impossible:
  1204. 	   // Empty options are not displayed and therefore can't be selected
  1205. 	   // this label will never be reached from the menu command
  1206.     L_Right:
  1207.        // If they click "C" they will end up here
  1208. 	   // @menu == 5
  1209.  
  1210. If a label is '-', the script execution will continue right after the menu 
  1211. command if that option is selected, this can be used to save you time, and 
  1212. optimize big scripts.
  1213.  
  1214.         menu "A::B:",-,"C",L_Right;
  1215.         // If they click "A" or "B" they will end up here
  1216. 		// @menu == 1 if "A"
  1217. 		// @menu == 3 if "B"
  1218.     L_Right:
  1219.         // If they click "C" they will end up here
  1220. 		// @menu == 5
  1221.  
  1222. Both these examples will perform the exact same task.
  1223.  
  1224. If you give an empty string as a menu item, the item will not display. This
  1225. can effectively be used to script dynamic menus by using empty string for
  1226. entries that should be unavailable at that time.
  1227.  
  1228. You can do it by using arrays, but watch carefully - this trick isn't high 
  1229. wizardry, but minor magic at least. You can't expect to easily duplicate it 
  1230. until you understand how it works.
  1231.  
  1232. Create a temporary array of strings to contain your menu items, and populate it 
  1233. with the strings that should go into the menu at this execution, making sure not 
  1234. to leave any gaps. Normally, you do it with a loop and an extra counter, like 
  1235. this:
  1236.  
  1237. 	setarray @possiblemenuitems$[0],<list of potential menu items>;
  1238. 	set @j,0; // That's the menu lines counter.
  1239.  
  1240. 	// We loop through the list of possible menu items.
  1241. 	// @i is our loop counter.
  1242. 	for( set @i,0; @i<getarraysize(@possiblemenuitems$) ; set @i,@i+1 )
  1243. 	{
  1244. 		// That 'condition' is whatever condition that determines whether 
  1245. 		// a menu item number @i actually goes into the menu or not.
  1246.  
  1247. 		if (<condition>)
  1248. 		{
  1249. 			// We record the option into the list of options actually available.
  1250.  
  1251. 			set @menulist$[@j],@possiblemenuitems$[@i];
  1252.  
  1253. 			// We just copied the string, we do need it's number for later 
  1254. 			// though, so we record it as well.
  1255.  
  1256. 			set @menureference[@j],@i;
  1257.  
  1258. 			// Since we've just added a menu item into the list, we increment 
  1259. 			// the menu lines counter.
  1260.  
  1261. 			set @j,@j+1;
  1262. 		}
  1263.  
  1264. 		// We go on to the next possible menu item.
  1265. 	}
  1266.  
  1267. This will create you an array @menulist$ which contains the text of all items 
  1268. that should actually go into the menu based on your condition, and an array 
  1269. @menureference, which contains their numbers in the list of possible menu items. 
  1270. (Remember, arrays start with 0.) There's less of them than the possible menu 
  1271. items you've defined, but the menu command can handle the empty lines - only if 
  1272. they are last in the list, and if it's made this way, they are. Now comes a 
  1273. dirty trick:
  1274.  
  1275. 	// X is whatever the most menu items you expect to handle.
  1276. 	menu @menulist$[0],-,@menulist$[1],-,....@menulist$[<X>],-;
  1277.  
  1278. This calls up a menu of all your items. Since you didn't copy some of the 
  1279. possible menu items into the list, it's end is empty and so no menu items will 
  1280. show up past the end. But this menu call doesn't jump anywhere, it just 
  1281. continues execution right after the menu command. (And it's a good thing it 
  1282. doesn't, cause you can only explicitly define labels to jump to, and how do you 
  1283. know which ones to define if you don't know beforehand which options will end up 
  1284. where in your menu?)
  1285. But how do you figure out which option the user picked? Enter the @menu.
  1286.  
  1287. @menu contains the number of option that the user selected from the list, 
  1288. starting with 1 for the first option. You know now which option the user picked 
  1289. and which number in your real list of possible menu items it translated to:
  1290.  
  1291.     mes "You selected "+@possiblemenuitems$[@menureference[@menu-1]]+"!";
  1292.  
  1293. @menu is the number of option the user picked.
  1294. @menu-1 is the array index for the list of actually used menu items that we 
  1295. made.
  1296. @menureference[@menu-1] is the number of the item in the array of possible menu 
  1297. items that we've saved just for this purpose.
  1298.  
  1299. And @possiblemenuitems$[@menureference[@menu-1]] is the string that we used to 
  1300. display the menu line the user picked. (Yes, it's a handful, but it works.)
  1301.  
  1302. You can set up a bunch of 'if (@menureference[@menu-1]==X) goto Y' statements to 
  1303. route your execution based on the line selected and still generate a different 
  1304. menu every time, which is handy when you want to, for example, make users select 
  1305. items in any specific order before proceeding, or make a randomly shuffled menu.
  1306.  
  1307. Kafra code bundled with the standard distribution uses a similar array-based 
  1308. menu technique for teleport lists, but it's much simpler and doesn't use @menu, 
  1309. probably since that wasn't documented anywhere.
  1310.  
  1311. See also 'select', which is probably better in this particular case. Instead of 
  1312. menu, you could use 'select' like this:
  1313.  
  1314.     set @dummy,select(@menulist$[0],@menulist$[1],....@menulist$[<X>]);
  1315.  
  1316. For the purposes of the technique described above these two statements are 
  1317. perfectly equivalent.
  1318.  
  1319. ---------------------------------------
  1320.  
  1321. *select("<option>"{,"<option>",...})
  1322. *prompt("<option>"{,"<option>",...})
  1323.  
  1324. This function is a handy replacement for 'menu' for some specific cases where 
  1325. you don't want a complex label structure - like, for example, asking simple yes-
  1326. no questions. It will return the number of menu option picked, starting with 1. 
  1327. Like 'menu', it will also set the variable @menu to contain the option the user 
  1328. picked.
  1329.  
  1330.     if (select("Yes:No")==1) mes "You said yes, I know.";
  1331.  
  1332. And like 'menu', the selected option is consistent with grouped options 
  1333. and empty options.
  1334.  
  1335. prompt works almost the same as select, except that when a character clicks
  1336. the Cancel button, this function will return 255 instead.
  1337.  
  1338. ---------------------------------------
  1339.  
  1340. *input(<variable>{,<min>{,<max>}})
  1341.  
  1342. This command will make an input box pop up on the client connected to the 
  1343. invoking character, to allow entering of a number or a string. This has many 
  1344. uses, one example would be a guessing game, also making use of the 'rand' 
  1345. function:
  1346.  
  1347. 	mes "[Woman]";
  1348. 	mes "Try and guess the number I am thinking of.";
  1349. 	mes "The number will be between 1 and 10.";
  1350. 	next;
  1351. 	set @number, rand(1,10);
  1352. 	input @guess;
  1353. 	if(@guess==@number)
  1354. 	{
  1355. 		mes "[Woman]";
  1356. 		mes "Well done that was the number I was thinking of";
  1357. 		close;
  1358. 	}
  1359. 	else
  1360. 	{
  1361. 		mes "[Woman]";
  1362. 		mes "Sorry, that wasn't the number I was thinking of.";
  1363. 		close;
  1364. 	}
  1365.  
  1366. If you give the input command a string variable to put the input in, it will 
  1367. allow the player to enter text. Otherwise, only numbers will be allowed.
  1368.  
  1369. 	mes "[Woman]";
  1370. 	mes "Please say HELLO";
  1371. 	next;
  1372. 	input @var$;
  1373. 	if(@var$=="HELLO")
  1374. 	{
  1375. 		mes "[Woman]";
  1376. 		mes "Well done you typed it correctly";
  1377. 		close;
  1378. 	}
  1379. 	else
  1380. 	{
  1381. 		mes "[Woman]";
  1382. 		mes "Sorry you got it wrong";
  1383. 		close;
  1384. 	}
  1385.  
  1386. Normally you may not input a negative number with this command.
  1387. This is done to prevent exploits in badly written scripts, which would 
  1388. let people, for example, put negative amounts of Zeny into a bank script and 
  1389. receive free Zeny as a result.
  1390.  
  1391. Since trunk r12192 the command has two optional arguments and a return value.
  1392. The default value of 'min' and 'max' can be set with 'input_min_value' and 
  1393. 'input_max_value' in script_athena.conf.
  1394. For numeric inputs the value is capped to the range [min,max]. Returns 1 if 
  1395. the value was higher than 'max', -1 if lower than 'min' and 0 otherwise.
  1396. For string inputs it returns 1 if the string was longer than 'max', -1 is 
  1397. shorter than 'min' and 0 otherwise.
  1398.  
  1399. ---------------------------------------
  1400.  
  1401. *callfunc "<function>"{,<argument>,...<argument>};
  1402. *callfunc("<function>"{,<argument>,...<argument>})
  1403.  
  1404. This command lets you call up a function NPC. A function NPC can be called from 
  1405. any script on any map server. Using the 'return' command it will come back to 
  1406. the place that called it.
  1407.  
  1408. 	place,50,50,6%TAB%script%TAB%Woman%TAB%115,{
  1409. 		mes "[Woman]"
  1410. 		mes "Lets see if you win";
  1411. 		callfunc "funcNPC";
  1412. 		mes "Well done you have won";
  1413. 		close;
  1414. 	}
  1415. 	function%TAB%script%TAB%funcNPC%TAB%{
  1416. 		set @win, rand(2);
  1417. 		if(@win==0) return;
  1418. 		mes "Sorry you lost";
  1419. 		end;
  1420. 	}
  1421.  
  1422. You can pass arguments to your function - values telling it what exactly to do -
  1423. which will be available there with getarg() (see 'getarg')
  1424. Notice that returning is not mandatory, you can end execution right there.
  1425.  
  1426. If you want to return a real value from inside your function NPC, it is better 
  1427. to write it in the function form, which will also work and will make the script 
  1428. generally cleaner:
  1429.  
  1430. 	place,50,50,6%TAB%script%TAB%Man%TAB%115,{
  1431. 		mes "[Man]"
  1432. 		mes "Gimme a number!";
  1433. 		next;
  1434. 		input @number;
  1435. 		if (callfunc("OddFunc",@number)) mes "It's Odd!";
  1436. 		close;
  1437. 	}
  1438. 	function%TAB%script%TAB%OddFunc%TAB%{
  1439. 		if (getarg(0)%2==0) return 0;// it's even
  1440. 		return 1;// it's odd
  1441. 	}
  1442.  
  1443. ---------------------------------------
  1444.  
  1445. *callsub <label>{,<argument>,...<argument>};
  1446. *callsub(<label>{,<argument>,...<argument>})
  1447.  
  1448. This command will go to a specified label within the current script (do NOT use 
  1449. quotes around it) coming in as if it were a 'callfunc' call, and pass it 
  1450. arguments given, if any, which can be recovered there with 'getarg'. When done 
  1451. there, you should use the 'return' command to go back to the point from where 
  1452. this label was called. This is used when there is a specific thing the script 
  1453. will do over and over, this lets you use the same bit of code as many times as 
  1454. you like, to save space and time, without creating extra NPC objects which are 
  1455. needed with 'callfunc'. A label is not callable in this manner from another 
  1456. script.
  1457.  
  1458. Example 1: callsub for checking (if checks pass, return to script)
  1459. 	callsub S_CheckFull, "guild_vs2",50;
  1460. 	switch( rand(4) ) {
  1461. 		case 0:	warp "guild_vs2",9,50;	end;
  1462. 		case 1:	warp "guild_vs2",49,90;	end;
  1463. 		case 2:	warp "guild_vs2",90,50;	end;
  1464. 		case 3:	warp "guild_vs2",49,9;	end;
  1465. 	}
  1466.  
  1467. ...
  1468.  
  1469. S_CheckFull:
  1470. 	if (getmapusers(getarg(0)) >= getarg(1)) {
  1471. 		mes "I'm sorry, this arena is full.  Please try again later.";
  1472. 		close;
  1473. 	}
  1474. 	return;
  1475.  
  1476. Example 2: callsub used repeatedly, with different arguments
  1477. // notice how the Zeny check/delete is reused, instead of copy-pasting for every warp
  1478. 	switch(select("Abyss Lake:Amatsu Dungeon:Anthell:Ayothaya Dungeon:Beacon Island, Pharos") {
  1479. 		case 1:	callsub S_DunWarp,"hu_fild05",192,207;
  1480. 		case 2:	callsub S_DunWarp,"ama_in02",119,181;
  1481. 		case 3:	callsub S_DunWarp,"moc_fild20",164,145;
  1482. 		case 4:	callsub S_DunWarp,"ayo_fild02",279,150;
  1483. 		case 5:	callsub S_DunWarp,"cmd_fild07",132,125;
  1484. 		// etc
  1485. 	}
  1486.  
  1487. ...
  1488.  
  1489. S_DunWarp:
  1490. // getarg(0) = "mapname"
  1491. // getarg(1) = x
  1492. // getarg(2) = y
  1493. 	if (Zeny >= 100) {
  1494. 		set Zeny, Zeny-100;
  1495. 		warp getarg(0),getarg(1),getarg(2);
  1496. 	} else {
  1497. 		mes "Dungeon warp costs 100 Zeny.";
  1498. 	}
  1499. 	close;
  1500.  
  1501. ---------------------------------------
  1502.  
  1503. *getarg(<index>{,<default_value>})
  1504.  
  1505. This function is used when you use the 'callsub' or 'callfunc' commands. In the 
  1506. call you can specify variables that will make that call different from another 
  1507. one. This function will return an argument the function or subroutine was 
  1508. called with, and is the normal way to get them. 
  1509. This is another thing that can let you use the same code more than once. 
  1510.  
  1511. Argument numbering starts with 0, i.e. the first argument you gave is number 0. 
  1512. If no such argument was given, a zero is returned.
  1513.  
  1514. 	place,50,50,6%TAB%script%TAB%Woman1%TAB%115,{
  1515. 		mes "[Woman]";
  1516. 		mes "Lets see if you win";
  1517. 		callfunc "funcNPC",2;
  1518. 		mes "Well done you have won";
  1519.  
  1520. 	...
  1521.  
  1522. 	place,52,50,6%TAB%script%TAB%Woman2%TAB%115,{
  1523. 		mes "[Woman]";
  1524. 		mes "Lets see if you win";
  1525. 		callfunc "funcNPC",5;
  1526. 		mes "Well done you have won";
  1527.  
  1528. 	...
  1529.  
  1530. 	function%TAB%script%TAB%funcNPC%TAB%{
  1531. 		set @win, rand(getarg(0));
  1532. 		if(@win==0) return;
  1533. 		mes "Sorry you lost";
  1534.  
  1535. "woman1" NPC object calls the funcNPC. The argument it gives in this call is 
  1536. stated as 2, so when the random number is generated by the 'rand' function, it 
  1537. can only be 0 or 1. Whereas "woman2" gives 5 as the argument number 0 when 
  1538. calling the function, so the random number could be 0, 1, 2, 3 or 4, this makes 
  1539. "woman2" less likely to say the player won. 
  1540.  
  1541. You can pass multiple arguments in a function call:
  1542.  
  1543. 	callfunc "funcNPC",5,4,3;
  1544.  
  1545. getarg(0) would be 5, getarg(1) would be 4 and getarg(2) would be 3.
  1546.  
  1547. Getarg has an optional argument since trunk r10773 and stable r10958.
  1548. If the target argument exists, it is returned.
  1549. Otherwise, if <default_value> is present it is returned instead, 
  1550. if not the script terminates immediately.
  1551.  
  1552. in the previous example getarg(2,-1) would be 3 and getarg(3,-1) would be -1
  1553.  
  1554. ---------------------------------------
  1555.  
  1556. *return {<value>};
  1557.  
  1558. This command causes the script execution to leave previously called function
  1559. with callfunc or script with callsub and return to the location, where the call
  1560. originated from. Optionally a return value can be supplied, when the call was
  1561. done using the function form. 
  1562.  
  1563. Using this command outside of functions or scripts referenced by callsub will
  1564. result in error and termination of the script.
  1565.  
  1566. 	callfunc "<your function>";// when nothing is returned
  1567. 	set <variable>,callfunc("<your function>");// when a value is being returned
  1568.  
  1569. ---------------------------------------
  1570.  
  1571. *function <function name>;
  1572. *<function name>;
  1573. *function <function name> {
  1574. <code>
  1575. }
  1576.  
  1577. (Skotlex stop being so selfish and give us all the commands T~T! J/k lol :P)
  1578.  
  1579. This works like callfunc. It's used for cleaner and fast scripting. Also they
  1580. must be inside a script. They're not separated scripts and they work more like
  1581. labels with arguments.
  1582.  
  1583. Note it looks like the normal declaration
  1584.  
  1585. Usage:
  1586.  
  1587. You first Declare the function with function <function name>;.
  1588.  
  1589. Put the rest of your code. You can use then <function name>; to call the
  1590. function. It can also return a value when used with parentheses.
  1591.  
  1592. And at last, but inside the script itself, put the function <function name> {<code>}.
  1593.  
  1594. Example:
  1595.  
  1596. prontera,154,189,4	script	Item seller	767,{
  1597.  
  1598. function SF_Selling;
  1599.  
  1600. mes "I'll open this now if you have more than 50z and you are level 50 or bigger";
  1601. next;
  1602.  
  1603. if (Zeny > 50) && (BaseLevel > 50) {
  1604. 	mes "Welcome";
  1605. 	next;
  1606. 	SF_Selling;
  1607. 	close;
  1608. } else
  1609.  
  1610. set @needed,50-BaseLevel;
  1611. mes "You either are Level "+BaseLevel+", thus you need "+@needed+" more levels";
  1612. mes "to be able to use this NPC; or you don't have enough Zeny, so get some please";
  1613. close;
  1614.  
  1615. function SF_Selling {
  1616.  
  1617. 	mes "Would you like to buy a phracon for 50z?";
  1618. 	switch(select("Yes","No, thanks")) {
  1619.  
  1620. 	case 1:
  1621. 		mes "Ok, how many?";
  1622. 		input @quantity;
  1623. 		set @check,Zeny/50;
  1624. 		if (@quantity > @check) {
  1625. 			mes "Sorry but you can only have "+@check+" Phracons with "+Zeny;
  1626. 			close;
  1627. 		} else
  1628. 		next;
  1629. 		mes "here you have";
  1630. 		set Zeny,Zeny-@quantity*50;
  1631. 		getitem 1010,@quantity;
  1632. 		close;
  1633. 	case 2:
  1634. 		mes "Good bye then";
  1635. 		close;
  1636. 		}
  1637. 	}
  1638. 	return;
  1639. }
  1640.  
  1641. Example with parameters and return value:
  1642.  
  1643. prontera,150,150,0	script	TestNPC	123,{
  1644. 	function MyAdd;
  1645.  
  1646. 	mes "Enter two numbers.";
  1647. 	next;
  1648. 	input .@a;
  1649. 	input .@b;
  1650. 	mes .@a+" + "+.@b+" = "+MyAdd(.@a,.@b);
  1651. 	close;
  1652.  
  1653. 	function MyAdd
  1654. 	{
  1655. 		return getarg(0)+getarg(1);
  1656. 	}
  1657. }
  1658.  
  1659.  
  1660. ---------------------------------------
  1661.  
  1662. *if (<condition>) <statement>;
  1663.  
  1664. This is the basic conditional statement command, and just about the only one 
  1665. available in this scripting language. 
  1666.  
  1667. The condition can be any expression. All expressions resulting in a non-zero 
  1668. value will be considered True, including negative values. All expressions 
  1669. resulting in a zero are false.
  1670.  
  1671. If the expression results in True, the statement will be executed. If it isn't 
  1672. true, nothing happens and we move on to the next line of the script.
  1673.  
  1674.     if (1)  mes "This will always print.";
  1675.     if (0)  mes "And this will never print.";
  1676.     if (5)  mes "This will also always print.";
  1677.     if (-1) mes "Funny as it is, this will also print just fine.";
  1678.  
  1679. For more information on conditional operators see the operators section above.
  1680. Anything that is returned by a function can be used in a condition check without 
  1681. bothering to store it in a specific variable:
  1682.  
  1683.     if (strcharinfo(0)=="Daniel Jackson") mes "It is true, you are Daniel!";
  1684.  
  1685. More examples of using the 'if' command in the real world:
  1686.  
  1687. Example 1:
  1688.  
  1689.         set @var1,1;
  1690.         input @var2;
  1691.         if(@var1==@var2) goto L_Same;
  1692.         mes "Sorry that is wrong";
  1693.         close;
  1694.     L_Same:
  1695.         close;
  1696.  
  1697. Example 2:
  1698.  
  1699.     set @var1,1;
  1700.     input @var2;
  1701.     if(@var1!=@var2) mes "Sorry that is wrong";
  1702.     close;
  1703.  
  1704. (Notice examples 1 and 2 have the same effect.)
  1705.  
  1706. Example 3:
  1707.  
  1708.     set @var1,@var1+1;
  1709.     mes "[Forgetfull Man]";
  1710.     if (@var==1) mes "This is the first time you have talked to me";
  1711.     if (@var==2) mes "This is the second time you have talked to me";
  1712.     if (@var==3) mes "This is the third time you have talked to me";
  1713.     if (@var==4) mes "This is the forth time you have talked to me, but I think I am getting amnesia, I have forgotten about you";
  1714.     if (@var==4) set @var,0;
  1715.     close;
  1716.  
  1717. Example 4:
  1718.  
  1719.         mes "[Quest Person]";
  1720.         if(countitem(512)>=1) goto L_GiveApple;
  1721.         // The number 512 was found from item_db, it is the item number for the Apple.
  1722.         mes "Can you please bring me an apple?";
  1723.         close;
  1724.     L_GiveApple:
  1725.         mes "Oh an apple, I didn't want it, I just wanted to see one";
  1726.         close;
  1727.  
  1728. Example 5:
  1729.  
  1730.         mes "[Person Checker]";
  1731.         if($name$!=null) goto L_Check;
  1732.         mes "Please tell me someones name";
  1733.         next;
  1734.         input $name$;
  1735.         set $name2$,strcharinfo(0);
  1736.         mes "[Person Checker]";
  1737.         mes "Thank you";
  1738.     L_Check:
  1739.         if($name$==strcharinfo(0) ) goto L_SameName;
  1740.         mes "[Person Checker]";
  1741.         mes "You are not the person that " +$name2$+ " mentioned";
  1742.     L_End:
  1743.         set $name$,null;
  1744.         set $name2$,null;
  1745.         close;
  1746.     L_SameName:
  1747.         mes "[Person Checker]";
  1748.         mes "You are the person that " +$name2$+ " just mentioned";
  1749.         mes "nice to meet you";
  1750.         goto L_End;
  1751.  
  1752. See 'strcharinfo' for explanation of what this function does.
  1753.  
  1754. Example 6: Using complex conditions.
  1755.  
  1756.         mes "[Multi Checker]";
  1757.         if( (@queststarted==1) && (countitem(512)>=5) ) goto L_MultiCheck;
  1758.         // Only if the quest has been started AND You have 5 apples will it goto "L_MultiCheck"
  1759.         mes "Please get me 5 apples";
  1760.         set @queststarted,1;
  1761.         close;
  1762.     L_MultiCheck:
  1763.         mes "[Multi Checker]";
  1764.         mes "Well done you have started the quest of got me 5 apples";
  1765.         mes "Thank you";
  1766.         set @queststarted,0;
  1767.         delitem 512,5;
  1768.         close;
  1769.  
  1770. With the Advanced scripting engine, we got nested if's. That is:
  1771.  
  1772. if (<condition>)
  1773. 	dothis;
  1774. else
  1775. 	dothat;
  1776.  
  1777. If the condition doesn't meet, it'll do the action following the else.
  1778. We can also group several actions depending on a condition, the following way:
  1779.  
  1780. if (<condition)
  1781. {
  1782. 	dothis1;
  1783. 	dothis2;
  1784. 	dothis3;
  1785. } else {
  1786. 	dothat1;
  1787. 	dothat2;
  1788. 	dothat3;
  1789. 	dothat4;
  1790. }
  1791.  
  1792. Remember that if you plan to do several actions upon the condition being false, and 
  1793. you forget to use the curly braces (the { } ), the second action will be executed regardless
  1794. the output of the condition, unless of course, you stop the execution of the script if the
  1795. condition is true (that is, in the first grouping using a return; , and end; or a close; )
  1796.  
  1797. Also, you can have multiple conditions nested or chained, and don't worry about limits as to
  1798. how many nested if you can have, there is no spoon ;)
  1799.  
  1800. ...
  1801. if (<condition 1>)
  1802. 	dothis;
  1803. else if (<condition 2>)
  1804. {
  1805. 	dotheother;
  1806. 	do that;
  1807. 	end;
  1808. } else
  1809. 	do this;
  1810. ...
  1811.  
  1812. ---------------------------------------
  1813.  
  1814. *jump_zero (<condition>),<label>;
  1815.  
  1816. This command works kinda like an 'if'+'goto' combination in one go. (See 'if'). 
  1817. If the condition is false (equal to zero) this command will immediately jump to 
  1818. the specified label like in 'goto'. While 'if' is more generally useful, for
  1819. some cases this could be an optimization.
  1820.  
  1821. The main reason for this command is that other control statements, like
  1822. 'switch', 'for' or 'while', are disassembled into simple expressions together
  1823. with this command when a script is parsed.
  1824.  
  1825. ---------------------------------------
  1826.  
  1827. *while (<condition>) <statement>;
  1828.  
  1829. This is probably the simplest and most frequently used loop structure. The 'while' 
  1830. statement can be interpreted as "while <condition> is true, perform <statement>". 
  1831. It is a pretest loop, meaning the conditional expression is tested before any of the 
  1832. statements in the body of the loop are performed. If the condition evaluates to 
  1833. false, the statement(s) in the body of the loop is/are never executed. If the 
  1834. condition evaluates to true, the statement(s) are executed, then control transfers 
  1835. back to the conditional expression, which is reevaluated and the cycle continues. 
  1836.  
  1837. Multiple statements can be grouped with { }, curly braces, just like with the 'if' statement.
  1838.  
  1839. Example 1:
  1840. 	while (switch(select("Yes:No") == 2 ))
  1841. 		mes "You picked no.";
  1842.  
  1843. Example 2: multiple statements
  1844. 	while (switch(select("Yes:No") == 2 )) {
  1845. 		mes "Why did you pick no?";
  1846. 		mes "You should pick yes instead!";
  1847. 	}
  1848.  
  1849. Example 3: counter-controlled loop
  1850. 	set .@i, 1;
  1851. 	while (.@i <= 5) {
  1852. 		mes "This line will print 5 times.";
  1853. 		set .@i, .@i +1;
  1854. 	}
  1855.  
  1856. Example 4: sentinel-controlled loop
  1857. 	mes "Input 0 to stop";
  1858. 	input .@num;
  1859. 	while (.@num != 0) {
  1860. 		mes "You entered " + .@num;
  1861. 		input .@num;
  1862. 	}
  1863. 	close;
  1864.  
  1865. ---------------------------------------
  1866.  
  1867. *for (<variable initialization>; <condition>; <variable update>) <statement>;
  1868.  
  1869. Another pretest looping structure is the 'for' statement. It is considered a 
  1870. specialized form of the 'while' statement, and is usually associated with counter-
  1871. controlled loops. Here are the steps of the 'for' statement: the initialize 
  1872. statement is executed first and only once. The condition test is performed. 
  1873. When the condition evaluates to false, the rest of the for statement is skipped. 
  1874. When the condition evaluates to true, the body of the loop is executed, then the 
  1875. update statement is executed (this usually involves incrementing a variable). 
  1876. Then the condition is reevaluated and the cycle continues. 
  1877.  
  1878. Example 1:
  1879. 	for( set .@i, 1; .@i <= 5; set .@i, .@i +1 )
  1880. 		mes "This line will print 5 times.";
  1881.  
  1882. Example 2:
  1883. 	mes "This will print the numbers 1 - 5.";
  1884. 	for( set .@i, 1; .@i <= 5; set .@i, .@i +1 )
  1885. 		mes .@i;
  1886.  
  1887. ---------------------------------------
  1888.  
  1889. *do { <statement>; } while (<condition>);
  1890.  
  1891. The 'do...while' is the only post-test loop structure available in this script 
  1892. language. With a post-test, the statements are executed once before the condition 
  1893. is tested. When the condition is true, the statement(s) are repeated. When the 
  1894. condition is false, control is transferred to the statement following the 
  1895. 'do...while' loop expression.
  1896.  
  1897. Example 1: sentinel-controlled loop
  1898. 	mes "This menu will keep appearing until you pick Cancel";
  1899. 	do {
  1900. 		set .@menu, select("One:Two:Three:Cancel");
  1901. 	} while (.@menu != 4);
  1902.  
  1903. Example 2: counter-controlled loop
  1904. 	mes "This will countdown from 10 to 1.";
  1905. 	set .@i, 10;
  1906. 	do {
  1907. 		mes .@i;
  1908. 		set .@i, .@i - 1;
  1909. 	} while (.@i > 0);
  1910.  
  1911. ---------------------------------------
  1912.  
  1913. *setarray <array name>[<first value>],<value>{,<value>...<value>};
  1914.  
  1915. This command will allow you to quickly fill up an array in one go. Check the 
  1916. Kafra scripts in the distribution to see this used a lot.
  1917.  
  1918.     setarray @array[0], 100, 200, 300, 400, 500, 600;
  1919.  
  1920. First value is the index of the first element of the array to alter. For 
  1921. example:
  1922.  
  1923.     setarray @array[0],200,200,200;
  1924.     setarray @array[1],300,150;
  1925.  
  1926. will produce:
  1927.  
  1928.  @array[0]=200
  1929.  @array[1]=300
  1930.  @array[2]=150
  1931.  
  1932. ---------------------------------------
  1933.  
  1934. *cleararray <array name>[<first value to alter>],<value>,<number of values to set>;
  1935.  
  1936. This command will change many array values at the same time to the same value.
  1937.  
  1938.     setarray @array[0], 100, 200, 300, 400, 500, 600;
  1939.     // This will make all 6 values 0
  1940.     cleararray @array[0],0,6;
  1941.     // This will make array element 0 change to 245
  1942.     cleararray @array[0],245,1;
  1943.     // This will make elements 1 and 2 change to 345
  1944.     cleararray @array[1],345,2;
  1945.  
  1946. See 'setarray'.
  1947.  
  1948. ---------------------------------------
  1949.  
  1950. *copyarray <destination array>[<first value>],<source array>[<first value>],<amount of data to copy>;
  1951.  
  1952. This command lets you quickly shuffle a lot of data between arrays, which is in 
  1953. some cases invaluable.
  1954.  
  1955.     setarray @array[0], 100, 200, 300, 400, 500, 600;
  1956.     // So we have made @array[]
  1957.     copyarray @array2[0],@array[2],2;
  1958.  
  1959.     // Now, @array2[0] will be equal to @array[2] (300) and 
  1960.     // @array2[1] will be equal to @array[3].
  1961.  
  1962. So using the examples above:
  1963.  @array[0]  = 100
  1964.  @array[1]  = 200
  1965.  @array[2]  = 300
  1966.  @array[3]  = 400
  1967.  @array[4]  = 500
  1968.  @array[5]  = 600
  1969.  
  1970. New Array:
  1971.  @array2[0] = 300
  1972.  @array2[1] = 400
  1973.  @array2[2] = 0
  1974.  @array2[3] = 0
  1975.  
  1976. Notice that @array[4] and @array[5] won't be copied to the second array, and it will return a 
  1977. 0.
  1978.  
  1979. ---------------------------------------
  1980.  
  1981. *deletearray <array name>[<first value>],<how much to delete>;
  1982.  
  1983. This command will delete a specified number of array elements totally from an 
  1984. array, shifting all the elements beyond this towards the beginning.
  1985.  
  1986.     // This will delete array element 0, and move all the other array elements 
  1987.     // up one place.
  1988.     deletearray @array[0],1
  1989.  
  1990. // This would delete array elements numbered 1, 2 and 3, leave element 0 in its 
  1991. // place, and move the other elements ups, so there are no gaps.
  1992.  
  1993.     deletearray @array[1],3
  1994.  
  1995. ---------------------------------------
  1996.  
  1997. ======================================
  1998. |2.- Information-retrieving commands.|
  1999. ======================================
  2000. ---------------------------------------
  2001.  
  2002. *strcharinfo(<type>)
  2003.  
  2004. This function will return either the name, party name or guild name for the 
  2005. invoking character. Whatever it returns is determined by type.
  2006.  
  2007.  0 - Character's name.
  2008.  1 - The name of the party they're in if any.
  2009.  2 - The name of the guild they're in if any.
  2010.  3 - The name of the map the character is in.
  2011.  
  2012. If a character is not a member of any party or guild, an empty string will be 
  2013. returned when requesting that information.
  2014.  
  2015. ---------------------------------------
  2016.  
  2017. *strnpcinfo(<type>)
  2018.  
  2019. This function will return the various parts of the name of the calling NPC.
  2020. Whatever it returns is determined by type.
  2021.  
  2022.  0 - The NPC's display name (visible#hidden)
  2023.  1 - The visible part of the NPC's display name
  2024.  2 - The hidden part of the NPC's display name
  2025.  3 - The NPC's unique name (::name)
  2026.  4 - The name of the map the NPC is in.
  2027.  
  2028. ---------------------------------------
  2029.  
  2030. *getarraysize(<array name>)
  2031.  
  2032. This function returns the number of values that are contained inside the 
  2033. specified array. Notice that zeros and empty strings at the end of this array 
  2034. are not counted towards this number.
  2035.  
  2036. For example:
  2037.  
  2038.     setarray @array[0], 100, 200, 300, 400, 500, 600;
  2039.     set @arraysize,getarraysize(@array);
  2040.  
  2041. This will make @arraysize == 6. But if you try this:
  2042.  
  2043.     setarray @array[0], 100, 200, 300, 400, 500, 600, 0;
  2044.     set @arraysize,getarraysize(@array);
  2045.  
  2046. @arraysize will still equal 6, even though you've set 7 values.    
  2047.  
  2048. ---------------------------------------
  2049.  
  2050. *getelementofarray(<array name>,<index>)
  2051.  
  2052. This command retrieves the value of the element of given array at given index.
  2053. This is equivalent to using:
  2054.  
  2055.     <array name>[<index>]
  2056.  
  2057. The reason for this is, that this short form is internally converted into a call
  2058. to getelementofarray, when the script is loaded.
  2059.  
  2060. Also useful when passing arrays to functions or accessing another npc's arrays: 
  2061.     getelementofarray(getarg(0),<index>)
  2062.     getelementofarray(getvariableofnpc(.var, "testNPC"),<index>)
  2063.  
  2064. ---------------------------------------
  2065.  
  2066. *readparam(<parameter number>)
  2067.  
  2068. This function will return the basic stats of an invoking character, referred to 
  2069. by the parameter number. Instead of a number, you can use a parameter name if it 
  2070. is defined in "db/const.txt".
  2071.  
  2072. For reference, in there these things are defined:
  2073.  
  2074. StatusPoint, BaseLevel, SkillPoint, Class, Upper, Zeny, Sex, Weight, MaxWeight,
  2075. JobLevel, BaseExp, JobExp, NextBaseExp, NextJobExp, Hp, MaxHp, Sp, MaxSp,
  2076. BaseJob, Karma, Manner, bVit, bDex, bAgi, bStr, bInt, bLuk
  2077.  
  2078. All of these also behave as variables, but don't expect to be able to just 'set' 
  2079. all of them - some will not work for various internal reasons.
  2080.  
  2081.     // This would return how many status points you haven't spent yet
  2082.     readparam(9)
  2083.  
  2084. Using this particular information as a function call is not required. Just 
  2085. putting
  2086.  
  2087.     StatusPoint 
  2088.  
  2089. will give you the same result, and some of these parameters work just like 
  2090. variables (i.e. you can 'set Zeny,100' to make the character have 100 Zeny, 
  2091. destroying whatever Zeny they had before, or 'set Zeny,Zeny+100' to give them 
  2092. 100 Zeny)
  2093.  
  2094. You can also use this command to get stat values:
  2095.  
  2096.     readparam(bVit)
  2097.     if(readparam(bVit)<=77) goto L_End;
  2098.     mes "Only people with over 77 Vit are reading this";
  2099. L_End:
  2100.     close;
  2101.  
  2102. ---------------------------------------
  2103.  
  2104. *getcharid(<type>{,"<character name>"})
  2105.  
  2106. This function will return a unique ID number of the invoking character, or, if a 
  2107. character name is specified, of that character.
  2108.  
  2109. Type is the kind of associated ID number required:
  2110.  
  2111.  0 - Character ID number.
  2112.  1 - Party ID number.
  2113.  2 - Guild ID number.
  2114.  3 - Account ID number.
  2115.  4 - Battle ground ID
  2116.  
  2117. For most purposes other than printing it, a number is better to have than a name 
  2118. (people do horrifying things to their character names).
  2119.  
  2120. If the character is not in a party or not in a guild, the function will return 0 
  2121. if guild or party number is requested. If a name is specified and the character 
  2122. is not found, 0 is returned.
  2123.  
  2124. If getcharid(0) returns a zero, the script got called not by a character and 
  2125. doesn't have an attached RID. Note that this will cause the map server to
  2126. print "player not attached!" error messages, so it is preferred to use
  2127. "playerattached" to check for the character attached to the script.
  2128.  
  2129. if( getcharid(2) == 0 ) mes "Only members of a guild are allowed here!";
  2130.  
  2131. ---------------------------------------
  2132.  
  2133. *getnpcid(<type>{,"<npc name>"});
  2134.  
  2135. Retrieves IDs of the currently invoked NPC. If a unique npc name is
  2136. given, IDs of that NPC are retrieved instead. Type specifies what ID
  2137. to retrieve and can be one of the following:
  2138.  
  2139.     0 - Unit ID (GID)
  2140.  
  2141. If an invalid type is given or the NPC does not exist, return value
  2142. is 0.
  2143.  
  2144. ---------------------------------------
  2145.  
  2146. *getchildid()
  2147. *getmotherid()
  2148. *getfatherid()
  2149.  
  2150. These functions return the characters (child/mother/father) ID
  2151.  
  2152.     if (getmotherid()) mes "Oh... I know your mother's ID:"+getmotherid();
  2153.  
  2154. ---------------------------------------
  2155.  
  2156. *ispartneron()
  2157.  
  2158. This function returns 1 if the invoking character's marriage partner is 
  2159. currently online and 0 if they are not or if the character has no partner.
  2160.  
  2161. ---------------------------------------
  2162.  
  2163. *getpartnerid()
  2164.  
  2165. This function returns the character ID of the invoking character's marriage 
  2166. partner, if any. If the invoking character is not married, it will return 0, 
  2167. which is a quick way to see if they are married:
  2168.  
  2169.     if (getpartnerid()) mes "I'm not going to be your girlfriend!";
  2170.     if (getpartnerid()) mes "You're married already!";
  2171.  
  2172. ---------------------------------------
  2173.  
  2174. *getpartyname(<party id>)
  2175.  
  2176. This function will return the name of a party that has the specified ID number. 
  2177. If there is no such party ID, "null" will be returned.
  2178.  
  2179. Lets say the ID of a party was saved as a global variable:
  2180.  
  2181.     // This would return the name of the party from the ID stored in a variable
  2182.     mes "You're in the '"+getpartyname($@var)+"' party, I know!";
  2183.  
  2184. ---------------------------------------
  2185.  
  2186. *getpartymember <party id>{,<type>};
  2187.  
  2188. Thank you to HappyDenn for all this information.
  2189.  
  2190. This command will find all members of a specified party and returns their names 
  2191. (or character id or account id depending on the value of "type") into an array
  2192. of temporary global variables. There's actually quite a few commands like this
  2193. which will fill a special variable with data upon execution and not do anything
  2194. else.
  2195.  
  2196. Upon executing this,
  2197.  
  2198. $@partymembername$[] is a global temporary string array which contains all the 
  2199.                      names of these party members
  2200.                      (only set when type is 0 or not specified)
  2201.  
  2202. $@partymembercid[]   is a global temporary number array which contains the 
  2203.                      character id of these party members.
  2204.                      (only set when type is 1)
  2205.  
  2206. $@partymemberaid[]   is a global temporary number array which contains the 
  2207.                      account id of these party members.
  2208.                      (only set when type is 2)
  2209.  
  2210. $@partymembercount   is the number of party members that were found.
  2211.  
  2212. The party members will (apparently) be found regardless of whether they are 
  2213. online or offline. Note that the names come in no particular order.
  2214.  
  2215. Be sure to use $@partymembercount to go through this array, and not 
  2216. 'getarraysize', because it is not cleared between runs of 'getpartymember'. If 
  2217. someone with 7 party members invokes this script, the array would have 7 
  2218. elements. But if another person calls up the NPC, and he has a party of 5, the 
  2219. server will not clear the array for you, overwriting the values instead. So in 
  2220. addition to returning the 5 member names, the 6th and 7th elements from the last 
  2221. call remain, and you will get 5+2 members, of which the last 2 don't belong to 
  2222. the new guy's party. $@partymembercount will always contain the correct number, 
  2223. (5) unlike 'getarraysize()' which will return 7 in this case.
  2224.  
  2225. Example:
  2226.  
  2227.    // get the character's party ID
  2228.        getpartymember(getcharid(1));
  2229.  
  2230.    // immediately copy $@partymembercount value to a new variable, since
  2231.    // you don't know when 'getpartymember' will get called again for someone 
  2232.    // else's party, overwriting your global array.
  2233.        set @partymembercount,$@partymembercount;
  2234.  
  2235.    // copy $@partymembername array to a new array
  2236.        copyarray @partymembername$[0],$@partymembername$[0],@partymembercount;
  2237.  
  2238.    //list the party members in NPC dialog
  2239.        set @count,0;
  2240.    L_DisplayMember:
  2241.        if(@count == @partymembercount) goto L_DisplayMemberEnd;
  2242.        mes (@count + 1) + ". ^0000FF" + @partymembername$[@count] + "^000000";
  2243.        set @count,@count+1;
  2244.        goto L_DisplayMember;
  2245.    L_DisplayMemberEnd:
  2246.        close;
  2247.  
  2248. ---------------------------------------
  2249.  
  2250. *getpartyleader(<party id>{,<type>})
  2251.  
  2252. This function returns some information about the given party-id's leader.
  2253. When type is omitted, the default information retrieved is the leader's name.
  2254. Possible types are:
  2255.  
  2256. 	1: Leader account id
  2257. 	2: Leader character id
  2258. 	3: Leader's class
  2259. 	4: Leader's current map name
  2260. 	5: Leader's current level as stored on the party structure (may not be
  2261. 	   current level if leader leveled up recently).
  2262.  
  2263. If retrieval fails (leader not found or party does not exist), this function
  2264. returns "null" instead of the character name, and -1 for the other types.
  2265.  
  2266. ---------------------------------------
  2267.  
  2268. *getlook(<type>)
  2269.  
  2270. This function will return the number for the current character look value 
  2271. specified by type. See 'setlook' for valid look types.
  2272.  
  2273. This can be used to make a certain script behave differently for characters 
  2274. dressed in black. :)
  2275.  
  2276. ---------------------------------------
  2277.  
  2278. *getsavepoint(<information type>)
  2279.  
  2280. This function will return information about the invoking character's save point. 
  2281. You can use it to let a character swap between several recorded save points. 
  2282. Available information types are:
  2283.  
  2284.  0 - Map name (a string)
  2285.  1 - X coordinate
  2286.  2 - Y coordinate
  2287.  
  2288. ---------------------------------------
  2289. \\
  2290. 2,2 Item-related commands
  2291. \\
  2292. ---------------------------------------
  2293.  
  2294. *getequipid(<equipment slot>)
  2295.  
  2296. This function returns the item ID of the item equipped in the equipment slot 
  2297. specified on the invoking character. If nothing is equipped there, it returns -1. 
  2298. Valid equipment slots are:
  2299.  
  2300. EQI_HEAD_TOP (1)  - Upper head gear
  2301. EQI_ARMOR (2)     - Armor (Where you keep your Jackets and Robes)
  2302. EQI_HAND_L (3)    - What is in your Left hand.
  2303. EQI_HAND_R (4)    - What is in your Right hand.
  2304. EQI_GARMENT (5)   - The garment slot (Mufflers, Hoods, Manteaus)
  2305. EQI_SHOES (6)     - What foot gear the player has on.
  2306. EQI_ACC_L (7)     - Accessory 1.
  2307. EQI_ACC_R (8)     - Accessory 2.
  2308. EQI_HEAD_MID (9)  - Middle Headgear (masks and glasses)
  2309. EQI_HEAD_LOW (10) - Lower Headgear (beards, some masks)
  2310.  
  2311. Notice that a few items occupy several equipment slots, and if the character is 
  2312. wearing such an item, 'getequipid' will return it's ID number for either slot.
  2313.  
  2314. Can be used to check if you have something equipped, or if you haven't got 
  2315. something equipped:
  2316.  
  2317.         if(getequipid(EQI_HEAD_TOP)==2234) goto L_WearingTiara;
  2318.         mes "Come back when you have a Tiara on";
  2319.         close;
  2320.     L_WearingTiara:
  2321.         mes "What a lovely Tiara you have on";
  2322.         close;
  2323.  
  2324. You can also use it to make sure people don't pass a point before removing an 
  2325. item totally from them. Let's say you don't want people to wear Legion Plate 
  2326. armor, but also don't want them to equip if after the check, you would do this:
  2327.  
  2328.         if ((getequipid(EQI_ARMOR) == 2341) || (getequipid(EQI_ARMOR) == 2342) goto L_EquipedLegionPlate;
  2329.     // the || is used as an or argument, there is 2341 and 2342 cause there are 
  2330.     // two different legion plate armors, one with a slot one without.
  2331.         if ((countitem(2341) > 0) || (countitem(2432) > 0) goto L_InventoryLegionPlate;
  2332.         mes "I will lets you pass";
  2333.         close2;
  2334.         warp "place",50,50;
  2335.         end;
  2336.     L_EquipedLegionPlate:
  2337.         mes "You are wearing some Legion Plate Armor, please drop that in your stash before continuing";
  2338.         close;
  2339.     L_InventoryLegionPlate:
  2340.         mes "You have some Legion Plate Armor in your inventory, please drop that in your stash before continuing";
  2341.         close;
  2342.  
  2343. ---------------------------------------
  2344.  
  2345. *getequipname(<equpment slot>)
  2346.  
  2347. Returns the jname of the item equipped in the specified equipment slot on the
  2348. invoking character, or an empty string if nothing is equipped in that position.
  2349. Does the same thing as getitemname(getequipid()). Useful for an NPC to state
  2350. what your are wearing, or maybe saving as a string variable.
  2351. See 'getequipid' for a full list of valid equipment slots.
  2352.  
  2353.         if( getequipname(EQI_HEAD_TOP) != "" )
  2354. 	        mes "So you are wearing a "+getequipname(EQI_HEAD_TOP)+" on your head";
  2355. 	else
  2356. 	        mes "You are not wearing any head gear";
  2357.  
  2358. ---------------------------------------
  2359.  
  2360. *getitemname(<item id>)
  2361.  
  2362. Given the database ID number of an item, this function will return the text 
  2363. stored in the 'japanese name' field (which, in rAthena, stores an english name 
  2364. the players would normally see on screen.)
  2365.  
  2366. ---------------------------------------
  2367.  
  2368. *getbrokenid(<number>)
  2369.  
  2370. This function will search the invoking character's inventory for any broken 
  2371. items, and will return their item ID numbers. Since the character may have 
  2372. several broken items, 1 given as an argument will return the first one found, 2 
  2373. will return the second one, etc. Will return 0 if no such item is found.
  2374.  
  2375.     // Let's see if they have anything broken:
  2376.         if (getbrokenid(1)==0) goto Skip;
  2377.     // They do, so let's print the name of the first broken item:
  2378.         mes "Oh, I see you have a broken "+getitemname(getbrokenid(1))+" here!";
  2379.     Skip:
  2380.         mes "You don't have anything broken, quit bothering me.";
  2381.  
  2382. ---------------------------------------
  2383.  
  2384. *getequipisequiped(<equipment slot>)
  2385.  
  2386. This functions will return 1 if there is an equipment placed on the specified
  2387. equipment slot and 0 otherwise. For a list of equipment slots 
  2388. see 'getequipid'. Function originally used by the refining NPCs:
  2389.  
  2390.     if (getequipisequiped(EQI_HEAD_TOP)) goto L_equipped;
  2391.         mes "[Refiner]";
  2392.         mes "Do you want me to refine your dumb head?";
  2393.         close;
  2394.     L_equipped:
  2395.         mes "[Refiner]";
  2396.         mes "That's a fine hat you are wearing there...";
  2397.         close;
  2398.  
  2399.  
  2400. ---------------------------------------
  2401.  
  2402. *getequipisenableref(<equipment slot>)
  2403.  
  2404. Will return 1 if the item equipped on the invoking character in the specified 
  2405. equipment slot is refinable, and 0 if it isn't. For a list of equipment slots 
  2406. see 'getequipid'.
  2407.  
  2408.         if (getequipisenableref(EQI_HEAD_TOP)) goto L_Refine;
  2409.         mes "[Refiner]";
  2410.         mes "I can't refine this hat!...";
  2411.         close;
  2412.     L_Refine:
  2413.         mes "[Refiner]";
  2414.         mes "Ok I can refine this";
  2415.         close;
  2416.  
  2417. ---------------------------------------
  2418.  
  2419. *getequiprefinerycnt(<equipment slot>)
  2420.  
  2421. Returns the current number of pluses for the item in the specified equipment 
  2422. slot. For a list of equipment slots see 'getequipid'.
  2423.  
  2424. Can be used to check if you have reached a maximum refine value, default for 
  2425. this is +10:
  2426.  
  2427.         if(getequiprefinerycnt(EQI_HEAD_TOP) < 10) goto L_Refine_HeadGear;
  2428.         mes "Sorry, it's not possible to refine hats better than +10";
  2429.         close;
  2430.     L_Refine_HeadGear:
  2431.         mes "I will now upgrade your "+getequipname(EQI_HEAD_TOP);
  2432.  
  2433. ---------------------------------------
  2434.  
  2435. *getequipweaponlv(<equipment slot>)
  2436.  
  2437. This function returns the weapon level for the weapon equipped in the specified 
  2438. equipment slot on the invoking character. For a list of equipment slots see 
  2439. 'getequipid'.
  2440.  
  2441. Only EQI_HAND_L and EQI_HAND_R normally make sense, since only weapons 
  2442. have a weapon level. You can, however, probably, use this field for other 
  2443. equippable custom items as a flag or something. 
  2444. If no item is equipped in this slot, or if it doesn't have a weapon level 
  2445. according to the database, 0 will be returned.
  2446.  
  2447.     switch (getequipweaponlv(EQI_HAND_R)) {
  2448.       case 1: mes "You are holding a lvl 1 weapon"; break;
  2449. 		case 2: mes "You are holding a lvl 2 weapon"; break;
  2450. 		case 3: mes "You are holding a lvl 3 weapon"; break;
  2451.       case 4: mes "You are holding a lvl 4 weapon"; break;
  2452. 		case 5: mes "You are holding a lvl 5 weapon, hm, must be a custom design"; break;
  2453. 		default: mes "Seems you don't have a weapon on"; break;
  2454. 	 }
  2455.  
  2456. Or for the left hand, cause it can hold a weapon or a shield:
  2457.  
  2458.         if(getequipid(EQI_HAND_R)==0) goto L_NothingEquiped;
  2459.         switch (getequipweaponlv(EQI_HAND_L)) {
  2460.           case 0: mes "You are holding a shield, so it doesnt have a level"; break;
  2461.           case 1: mes "You are holding a lvl 1 weapon"; break;
  2462.           case 2: mes "You are holding a lvl 2 weapon"; break;
  2463.           case 3: mes "You are holding a lvl 3 weapon"; break;
  2464.           case 4: mes "You are holding a lvl 4 weapon"; break;
  2465.           case 5: mes "You are holding a lvl 5 weapon, hm, must be a custom design"; break;
  2466. 		  }
  2467.         close;
  2468.     L_NothingEquiped:
  2469.         mes "Seems you have nothing equipped";
  2470.         close;
  2471.  
  2472. ---------------------------------------
  2473.  
  2474. *getequippercentrefinery(<equipment slot>)
  2475.  
  2476. This function calculates and returns the percent value chance to successfully 
  2477. refine the item found in the specified equipment slot of the invoking character 
  2478. by +1. There is no actual formula, the success rate for a given weapon level of
  2479. a certain refine level is found in the db/refine_db.txt file. For a list of
  2480. equipment slots see 'getequipid'.
  2481.  
  2482. These values can be displayed for the player to see, or used to calculate the 
  2483. random change of a refine succeeding or failing and then going through with it 
  2484. (which is what the official NPC refinery scripts use it for)
  2485.  
  2486. // This will find a random number from 0 - 99 and if that is equal to or more 
  2487. // than the value recoverd by this command it will go to L_Fail
  2488.     if (getequippercentrefinery(EQI_HAND_L)<=rand(100)) goto L_Fail;
  2489.  
  2490. ---------------------------------------
  2491.  
  2492. *getareadropitem("<map name>",<x1>,<y1>,<x2>,<y2>,<item>)
  2493.  
  2494. This function will count all the items with the specified ID number lying on the 
  2495. ground on the specified map within the x1/y1-x2/y2 square on it and return that 
  2496. number.
  2497.  
  2498. This is the only function around where a parameter may be either a string or a 
  2499. number! If it's a number, it means that only the items with that item ID number 
  2500. will be counted. If it is a string, it is assumed to mean the 'english name' 
  2501. field from the item database. If you give it an empty string, or something that 
  2502. isn't found from the item database, it will count items number '512' (apples).
  2503.  
  2504. ---------------------------------------
  2505.  
  2506. *getequipcardcnt(<equipment slot>)
  2507.  
  2508. This function will return the number of cards that have been compounded onto a 
  2509. specific equipped item for the invoking character. See 'getequipid' for a list 
  2510. of possible equipment slots.
  2511.  
  2512. ---------------------------------------
  2513.  
  2514. *getinventorylist;
  2515.  
  2516. This command sets a bunch of arrays with a complete list of whatever the 
  2517. invoking character has in their inventory, including all the data needed to 
  2518. recreate these items perfectly if they are destroyed. Here's what you get:
  2519.  
  2520. @inventorylist_id[]        - array of item ids.
  2521. @inventorylist_amount[]    - their corresponding item amounts.
  2522. @inventorylist_equip[]     - whether the item is equipped or not.
  2523. @inventorylist_refine[]    - for how much it is refined.
  2524. @inventorylist_identify[]  - whether it is identified.
  2525. @inventorylist_attribute[] - whether it is broken.
  2526. @inventorylist_card1[]     - These four arrays contain card data for the items.
  2527. @inventorylist_card2[]       These data slots are also used to store names
  2528. @inventorylist_card3[]       inscribed on the items, so you can explicitly check
  2529. @inventorylist_card4[]       if the character owns an item made by a specific 
  2530.                              craftsman.
  2531. @inventorylist_expire[]    - expire time (Unix time stamp). 0 means never expires.
  2532. @inventorylist_count       - the number of items in these lists.
  2533.  
  2534. This could be handy to save/restore a character's inventory, since no other 
  2535. command returns such a complete set of data, and could also be the only way to 
  2536. correctly handle an NPC trader for carded and named items who could resell them 
  2537. - since NPC objects cannot own items, so they have to store item data in 
  2538. variables and recreate the items.
  2539.  
  2540. Notice that the variables this command generates are all temporary, attached to 
  2541. the character, and integer.
  2542.  
  2543. Be sure to use @inventorylist_count to go through these arrays, and not 
  2544. 'getarraysize', because the arrays are not automatically cleared between runs 
  2545. of 'getinventorylist'.
  2546.  
  2547. ---------------------------------------
  2548.  
  2549. *cardscnt()
  2550.  
  2551. This function will return the number of cards inserted into the weapon currently 
  2552. equipped on the invoking character.
  2553. While this function was meant for item scripts, it will work outside them:
  2554.  
  2555.     if (cardscnt()==4) mes "So you've stuck four cards into that weapon, think you're cool now?";
  2556.  
  2557. ---------------------------------------
  2558.  
  2559. *getrefine()
  2560.  
  2561. This function will return the number of pluses the weapon currently equipped on 
  2562. the invoking character has been refined for.
  2563. While this function was meant for item scripts, it will work outside them:
  2564.  
  2565.     if (getrefine()==10) mes "Wow. That's a murder weapon.";
  2566.  
  2567. ---------------------------------------
  2568.  
  2569. *getnameditem(<item id>,"<name to inscribe>");
  2570. *getnameditem("<item name>","<name to inscribe>");
  2571.  
  2572. This function is equivalent to using 'getitem', however, it will not just give 
  2573. the character an item object, but will also inscribe it with a specified 
  2574. character's name. You may not inscribe items with arbitrary strings, only with 
  2575. names of characters that actually exist. While this isn't said anywhere 
  2576. specifically, apparently, named items may not have cards in them, slots or no -
  2577. these data slots are taken by the character ID who's name is inscribed. Only one 
  2578. remains free and it's not quite clear if a card may be there.
  2579.  
  2580. This function will return 1 if an item was successfully created and 0 if it
  2581. wasn't for whatever reason. Like 'getitem', this function will also accept an
  2582. 'english name' from the item database as an item name and will return 0 if no
  2583. such item exists.
  2584.  
  2585. ---------------------------------------
  2586.  
  2587. *getitemslots(<item ID>)
  2588.  
  2589. This function will look up the item with the specified ID number in the database 
  2590. and return the number of slots this kind of items has - 0 if they are not 
  2591. slotted. It will also be 0 for all non-equippable items, naturally, unless 
  2592. someone messed up the item database. It will return -1 if there is no such item.
  2593.  
  2594. Example(s):
  2595.  
  2596. //@slots now has the amount of slots of the item with ID 1205.
  2597. 	set @slots, getItemSlots(1205);
  2598.  
  2599. ---------------------------------------
  2600.  
  2601. *getiteminfo(<item ID>,<type>)
  2602.  
  2603. This function will look up the item with the specified ID number in the database 
  2604. and return the info set by TYPE argument.
  2605. It will return -1 if there is no such item.
  2606.  
  2607. Valid types are:
  2608. 	0 - Buy Price; 1 - Sell Price; 2 - Item Type;
  2609. 	3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..
  2610. 		if = 0, then monsters don't drop it at all (rare or a quest item)
  2611. 		if = 10000, then this item is sold in NPC shops only
  2612. 	4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;
  2613. 	10 - slot; 11 - look; 12 - elv; 13 - wlv; 14 - view id
  2614.  
  2615. Check sample in doc/sample/getiteminfo.txt
  2616.  
  2617. ---------------------------------------
  2618.  
  2619. *getequipcardid(<equipment slot>,<card slot>)
  2620.  
  2621. Returns value from equipped item slot in the indicated slot:
  2622.  
  2623. getequipcardid(num,slot)
  2624.  
  2625. where:
  2626. 	num = equip position slot
  2627. 	slot = 0,1,2,3 (Card Slot N)
  2628.  
  2629. This func returns CARD ID, 255,254,-255 (for card 0, if the item is produced) it's useful 
  2630. when you want to check item cards or if it's signed. Useful for such quests as 
  2631. "Sign this refined item with players name" etc;
  2632. 	Hat[0] +4 -> Player's Hat[0] +4
  2633.  
  2634. ---------------------------------------
  2635. //
  2636. 2,1.- End of item-related commands.
  2637. //
  2638. ---------------------------------------
  2639.  
  2640. *getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"})
  2641.  
  2642. This function will locate a character object, NPC object or pet's coordinates 
  2643. and place their coordinates into the variables specified when calling it. It 
  2644. will return 0 if the search was successful, and -1 if the parameters given were 
  2645. not variables or the search was not successful.
  2646.  
  2647. Type is the type of object to search for:
  2648.  
  2649.   0 - Character object
  2650.   1 - NPC object
  2651.   2 - Pet object
  2652.   3 - Monster object.
  2653.  
  2654. While 3 is meant to look for a monster object, no searching will be done if you 
  2655. specify type 3, and the function will always return -1.
  2656.  
  2657. The search string is optional. If it is not specified, the location of the 
  2658. invoking character will always be returned for types 0 and 2, the location of 
  2659. the NPC running this function for type 1.
  2660. If a search string is specified, for types 0 and 1, the character or NPC with 
  2661. the specified name will be located. If type is 3, the search will locate the 
  2662. current pet of the character who's name is given in the search string, it will 
  2663. NOT locate a pet by name.
  2664.  
  2665. What a mess. Example, a working and tested one now:
  2666.  
  2667.     prontera,164,301,3%TAB%script%TAB%Meh%TAB%730,{
  2668.         mes "My name is Meh. I'm here so that Nyah can find me.";
  2669.         close;
  2670.     }
  2671.  
  2672.     prontera,164,299,3%TAB%script%TAB%Nyah%TAB%730,{
  2673.         mes "My name is Nyah.";
  2674.         mes "I will now search for Meh all across the world!";
  2675.         if (getmapxy(@mapname$,@mapx,@mapy,1,"Meh")!=0) goto Notfound;
  2676.         mes "And I found him on map "+@mapname$+" at X:"+@mapx+" Y:"+@mapy+" !";
  2677.         close;
  2678.     Notfound:
  2679.         mes "I can't seem to find Meh anywhere!";
  2680.         close;
  2681.    }
  2682.  
  2683. Notice that NPC objects disabled with 'disablenpc' will still be located.
  2684.  
  2685. ---------------------------------------
  2686.  
  2687. *getgmlevel()
  2688.  
  2689. This function will return the (GM) level of player group the account to which the 
  2690. invoking character belongs. If this is somehow executed from a console command,
  2691. 99 will be returned, and 0 will be returned if the account has no GM level.
  2692.  
  2693. This allows you to make NPC's only accessible for certain GM levels, or behave 
  2694. specially when talked to by GMs.
  2695.  
  2696.    if (getgmlevel()) mes "What is your command, your godhood?";
  2697.    if (getgmlevel()) goto Wherever;
  2698.  
  2699. ---------------------------------------
  2700.  
  2701. *getgroupid()
  2702.  
  2703. This function will return the id of player group the account to which the 
  2704. invoking player belongs.
  2705.  
  2706. ---------------------------------------
  2707.  
  2708. *gettimetick(<tick type>)
  2709.  
  2710. This function will return the system time in UNIX epoch time (if tick type is 2) 
  2711. or the time since the start of the current day in seconds if tick type is 1.
  2712. Passing 0 will make it return the server's tick, which is a measurement in
  2713. milliseconds used by the server's timer system. The server's tick is an
  2714. unsigned int which loops every ~50 days.
  2715.  
  2716. Just in case you don't know, UNIX epoch time is the number of seconds elapsed 
  2717. since 1st of January 1970, and is useful to see, for example, for how long the 
  2718. character has been online with OnPCLoginEvent and OnPCLogoutEvent, which could allow 
  2719. you to make an 'online time counted for conviction only' jail script.
  2720.  
  2721. ---------------------------------------
  2722.  
  2723. *gettime(<type>)
  2724.  
  2725. This function will return specified information about the current system time.
  2726.  
  2727. 1 - Seconds (of a minute)
  2728. 2 - Minutes (of an hour)
  2729. 3 - Hour (of a day)
  2730. 4 - Week day (0 for Sunday, 6 is Saturday)
  2731. 5 - Day of the month.
  2732. 6 - Number of the month.
  2733. 7 - Year.
  2734. 8 - Day of the year.
  2735.  
  2736. It will only return numbers.
  2737.  
  2738.     if (gettime(4)==6) mes "It's a Saturday. I don't work on Saturdays.";
  2739.  
  2740. ---------------------------------------
  2741.  
  2742. *gettimestr(<format string>,<max length>)
  2743.  
  2744. This function will return a string containing time data as specified by the 
  2745. format string.
  2746.  
  2747. This uses the C function 'strfmtime', which obeys special format characters. For 
  2748. a full description see, for example, the description of 'strfmtime' at 
  2749. http://www.delorie.com/gnu/docs/glibc/libc_437.html
  2750. All the format characters given in there should properly work.
  2751. Max length is the maximum length of a time string to generate.
  2752.  
  2753. The example given in rAthena sample scripts works like this:
  2754.  
  2755.   mes gettimestr("%Y-%m/%d %H:%M:%S",21);
  2756.  
  2757. This will print a full date and time like 'YYYY-MM/DD HH:MM:SS'.
  2758.  
  2759. ---------------------------------------
  2760.  
  2761. *getusers(<type>)
  2762.  
  2763. This function will return a number of users on a map or the whole server. What 
  2764. it returns is specified by Type.
  2765.  
  2766. Type can be one of the following values, which control what will be returned:
  2767.  
  2768.     0 - Count of all characters on the map of the invoking character.
  2769.     1 - Count of all characters in the entire server.
  2770.     8 - Count of all characters on the map of the NPC the script is
  2771.         running in.
  2772.  
  2773. ---------------------------------------
  2774.  
  2775. *getmapusers("<map name>")
  2776.  
  2777. This function will return the number of users currently located on the specified 
  2778. map.
  2779.  
  2780. Currently being used in the PVP scripts to check if a PVP room is full of not, 
  2781. if the number returned it equal to the maximum allowed it will not let you 
  2782. enter.
  2783.  
  2784. ---------------------------------------
  2785.  
  2786. *getareausers("<map name>",<x1>,<y1>,<x2>,<y2>)
  2787.  
  2788. This function will return the count of connected characters which are located 
  2789. within the specified area - an x1/y1-x2/y2 square on the specified map.
  2790.  
  2791. This is useful for maps that are split into many buildings, such as all the 
  2792. "*_in" maps, due to all the shops and houses.
  2793.  
  2794. ---------------------------------------
  2795.  
  2796. *getusersname;
  2797.  
  2798. This command will give the invoking character a list of names of the connected 
  2799. characters (including themselves) into an NPC script message window (see 'mes') 
  2800. paging it by 10 names as if with the 'next' command.
  2801.  
  2802. You need to put a 'close' after that yourself.
  2803.  
  2804. ---------------------------------------
  2805. \\
  2806. 2,2.- Guild-related commands
  2807. \\
  2808. ---------------------------------------
  2809. *getguildname(<guild id>)
  2810.  
  2811. This function returns a guild's name given an ID number. If there is no such 
  2812. guild, "null" will be returned;
  2813.  
  2814.    // Would print what ever guild 10007 is, in my case this would return "AlcoROhics"
  2815.    mes "The guild "+GetGuildName(10007)+" are all nice people.";
  2816.  
  2817.    // This will do the same as above:
  2818.    set @var,10007;
  2819.    mes "We have some friends in "+GetGuildName(@var)+", you know.";
  2820.  
  2821. This is used all over the WoE controlling scripts. You could also use it for a 
  2822. guild-based event.
  2823.  
  2824. ---------------------------------------
  2825.  
  2826. *getguildmaster(<guild id>)
  2827.  
  2828. This function return the name of the master of the guild which has the specified 
  2829. ID number. If there is no such guild, "null" will be returned.
  2830.  
  2831. // Would return the guild master of guild 10007, whatever that might be.
  2832. // In this example it would return "MissDjax" cause she owns "AlcoROhics" (10007)
  2833.     mes getguildmaster(10007)+" runs "+getguildname(10007);
  2834.  
  2835. Can be used to check if the character is the guild master of the specified guild.
  2836.  
  2837. Maybe you want to make a room only guild masters can enter:
  2838.  
  2839.         set @GID,getcharid(2);
  2840.         if(@GID==0) goto L_NoGuild;
  2841.         if(strcharinfo(0)==getguildmaster(@GID)) goto L_GuildMaster;
  2842.         mes "Sorry you don't own the guild you are in";
  2843.         close;
  2844.     L_NoGuild:
  2845.         mes "Sorry you are not in a guild";
  2846.         close;
  2847.     L_GuildMaster:
  2848.         mes "Welcome guild master of "+GetGuildName(@GID);
  2849.         close;
  2850.  
  2851.  
  2852. ---------------------------------------
  2853.  
  2854. *getguildmasterid(<guild id>)
  2855.  
  2856. This function will return the character ID number of the guild master of the 
  2857. guild specified by the ID. 0 if the character is not a guild master of any guild.
  2858.  
  2859. ---------------------------------------
  2860.  
  2861. *getcastlename("<map name>")
  2862.  
  2863. This function returns the name of the castle when given the map name for that 
  2864. castle. The data is read from 'db/castle_db.txt'.
  2865.  
  2866. ---------------------------------------
  2867.  
  2868. *getcastledata("<map name>",<type of data>)
  2869. *setcastledata "<map name>",<type of data>,<value>;
  2870.  
  2871. This function returns the castle ownership information for the castle referred 
  2872. to by its map name. Castle information is stored in `guild_castle` SQL table.
  2873.  
  2874. Types of data correspond to `guild_castle` table columns:
  2875.  
  2876.  1 - `guild_id`   - Guild ID.
  2877.  2 - `economy`    - Castle Economy score.
  2878.  3 - `defense`    - Castle Defense score.
  2879.  4 - `triggerE`   - Number of times the economy was invested in today.
  2880.  5 - `triggerD`   - Number of times the defense was invested in today.
  2881.  6 - `nextTime`   - unused
  2882.  7 - `payTime`    - unused
  2883.  8 - `createTime` - unused
  2884.  9 - `visibleC`   - Is 1 if a Kafra was hired for this castle, 0 otherwise.
  2885. 10 - `visibleG0`  - Is 1 if the 1st guardian is present (Soldier Guardian)
  2886. 11 - `visibleG1`  - Is 1 if the 2nd guardian is present (Soldier Guardian)
  2887. 12 - `visibleG2`  - Is 1 if the 3rd guardian is present (Soldier Guardian)
  2888. 13 - `visibleG3`  - Is 1 if the 4th guardian is present (Archer Guardian)
  2889. 14 - `visibleG4`  - Is 1 if the 5th guardian is present (Archer Guardian)
  2890. 15 - `visibleG5`  - Is 1 if the 6th guardian is present (Knight Guardian)
  2891. 16 - `visibleG6`  - Is 1 if the 7th guardian is present (Knight Guardian)
  2892. 17 - `visibleG7`  - Is 1 if the 8th guardian is present (Knight Guardian)
  2893.  
  2894. All types of data have their meaning determined by War of Emperium scripts, 
  2895. with exception of:
  2896.  - `guild_id` that is always considered ID of the guild that owns the castle,
  2897.  - `defense` that is used in Guardians & Emperium HP calculations,
  2898.  - `visibleG` that is always considered to hold guardian presence bits.
  2899.  
  2900. The 'setcastledata' command will behave identically, but instead of returning 
  2901. values for the specified types of accessible data, it will alter them and cause 
  2902. them to be sent to the char-server for storage.
  2903.  
  2904. Changing Guild ID or Castle Defense will trigger additional actions, like 
  2905. recalculating guardians' HP.
  2906.  
  2907. ---------------------------------------
  2908.  
  2909. *getgdskilllv(<guild id>,<skill id>)
  2910. *getgdskilllv(<guild id>,"<skill name>")
  2911.  
  2912. This function returns the level of the skill <skill id> of the guild <guild id>.
  2913. If the guild does not have that skill, 0 is returned.
  2914. If the guild does not exist, -1 is returned.
  2915. Refer to 'db/skill_db.txt' for the full list of skills. (GD_* are guild skills)
  2916.  
  2917. ---------------------------------------
  2918.  
  2919. *requestguildinfo <guild id>{,"<event label>"};
  2920.  
  2921. This command requests the guild data from the char server and merrily continues 
  2922. with the execution. Whenever the guild information becomes available (which 
  2923. happens instantly if the guild information is already in memory, or later, if it 
  2924. isn't and the map server has to wait for the char server to reply) it will run 
  2925. the specified event as in a 'doevent' call.
  2926.  
  2927. ---------------------------------------
  2928.  
  2929. *getmapguildusers(<mapname>,<guild id>)
  2930.  
  2931. Returns the amount of persons from the given guild that are on the given map.
  2932. Example(s):
  2933.  
  2934. //Will set the @persons variable to the amount of persons from the guild
  2935. //which ID's = 10 and are at prontera.
  2936.  
  2937. 	set @persons,getMapGuildUsers("prontera",10);
  2938.  
  2939. ---------------------------------------
  2940. //
  2941. 2,2.- End of guild-related commands
  2942. //
  2943. ---------------------------------------
  2944.  
  2945. *getskilllv(<skill id>)
  2946. *getskilllv("<skill name>")
  2947.  
  2948. This function returns the level of the specified skill that the invoking 
  2949. character has. If they don't have the skill, 0 will be returned. The full list 
  2950. of character skills is available in 'db/skill_db.txt'.
  2951.  
  2952. There are two main uses for this function, it can check whether the character 
  2953. has a skill or not, and it can tell you if the level is high enough.
  2954.  
  2955. Example 1:
  2956.  
  2957.         if (getskilllv(152)) goto L_HasSkillThrowStone;
  2958.         mes "You don't have Throw Stone";
  2959.         close;
  2960.     L_HasSkillThrowStone:
  2961.         mes "You have got the skill Throw Stone";
  2962.         close;
  2963.  
  2964. Example 2:
  2965.  
  2966.         if (getskilllv(28) >= 5) goto L_HasSkillHeallvl5orMore;
  2967.         if (getskilllv(28) == 10) goto L_HasSkillHealMaxed;
  2968.         mes "You heal skill is below lvl 5";
  2969.         close;
  2970.     L_HasSkillHeallvl6orMore:
  2971.         mes "Your heal lvl is 5 or more";
  2972.         close;
  2973.     L_HasSkillHealMaxed:
  2974.         mes "Your heal lvl has been maxed";
  2975.         close;
  2976.  
  2977. ---------------------------------------
  2978.  
  2979. *getskilllist;
  2980.  
  2981. This command sets a bunch of arrays with a complete list of skills the 
  2982. invoking character has. Here's what you get:
  2983.  
  2984. @skilllist_id[]   - skill ids.
  2985. @skilllist_lv[]   - skill levels.
  2986. @skilllist_flag[] - see 'skill' for the meaning of skill flags.
  2987. @skilllist_count  - number of skills in the above arrays.
  2988.  
  2989. While 'getskillv' is probably more useful for most situations, this is the 
  2990. easiest way to store all the skills and make the character something else for a 
  2991. while. Advanced job for a day? :) This could also be useful to see how many 
  2992. skills a character has.
  2993.  
  2994. ---------------------------------------
  2995.  
  2996. *getpetinfo(<type>)
  2997.  
  2998. This function will return pet information for the pet the invoking character 
  2999. currently has active. Valid types are:
  3000.  
  3001.  0 - Unique pet ID number as stored by the char server and distinguishing it 
  3002.      from all other pets the characters actually have. This value is currently 
  3003.      useless, at most you can use it to tell pets apart reliably.
  3004.  1 - Pet class number as per 'db/pet_db.txt' - will tell you what kind of a pet it 
  3005.      is.
  3006.  2 - Pet name. Will return "null" if there's no pet. 
  3007.  3 - Pet friendly level (intimacy score). 1000 is full loyalty.
  3008.  4 - Pet hungry level. 100 is completely full.
  3009.  5 - Pet rename flag. 0 means this pet has not been named yet.
  3010.  
  3011. ---------------------------------------
  3012.  
  3013. *gethominfo(<type>)
  3014.  
  3015. This function works as a direct counterpart of 'getpetinfo':
  3016.  0 - Homunculus unique ID
  3017.  1 - Homunculus Class
  3018.  2 - Name
  3019.  3 - Friendly level (intimacy score). 100000 is full loyalty.
  3020.  4 - Hungry level. 100 is completely full.
  3021.  5 - Rename flag. 0 means this homunculus has not been named yet.
  3022.  6 - Homunculus level
  3023.  
  3024. ---------------------------------------
  3025.  
  3026.  
  3027. *petstat(<flag>)
  3028.  
  3029. Returns current pet status, all are integers except name.
  3030. Returns 0 or "" if the player doesn't have pets.
  3031.  
  3032. Flags usable >>
  3033. PET_CLASS
  3034. PET_NAME
  3035. PET_LEVEL
  3036. PET_HUNGRY
  3037. PET_INTIMATE
  3038.  
  3039. Example:
  3040. set @i, petstat(PET_CLASS);
  3041.  
  3042.  
  3043. ---------------------------------------
  3044.  
  3045. *getmonsterinfo(<mob ID>,<type>)
  3046.  
  3047. This function will look up the monster with the specified ID number in the
  3048. mob database and return the info set by TYPE argument.
  3049. It will return -1 if there is no such monster (or the type value is invalid),
  3050. or "null" if you requested the monster's name.
  3051.  
  3052. Valid types are listed in const.txt:
  3053. 	MOB_NAME	0		MOB_LV	1
  3054. 	MOB_MAXHP	2		MOB_BASEEXP	3
  3055. 	MOB_JOBEXP	4		MOB_ATK1	5
  3056. 	MOB_ATK2	6		MOB_DEF	7
  3057. 	MOB_MDEF	8		MOB_STR	9
  3058. 	MOB_AGI		10		MOB_VIT		11
  3059. 	MOB_INT		12		JOB_DEX		13
  3060. 	MOB_LUK		14		MOB_RANGE	15
  3061. 	MOB_RANGE2	16		MOB_RANGE3	17
  3062. 	MOB_SIZE	18		MOB_RACE	19
  3063. 	MOB_ELEMENT	20		MOB_MODE	21
  3064.  
  3065. Check sample in doc/sample/getmonsterinfo.txt
  3066.  
  3067. ---------------------------------------
  3068.  
  3069. *getmobdrops(<mob id>)
  3070.  
  3071. This command will find all drops of the specified mob and return the item IDs 
  3072. and drop percentages into arrays of temporary global variables. 
  3073. 'getmobdrops' returns 1 if successful and 0 if the mob ID doesn't exist.
  3074.  
  3075. Upon executing this,
  3076.  
  3077. $@MobDrop_item[] is a global temporary number array which contains the 
  3078.                  item IDs of the monster's drops.
  3079.  
  3080. $@MobDrop_rate[] is a global temporary number array which contains the 
  3081.                  drop percentages of each item. (1 = .01%)
  3082.  
  3083. $@MobDrop_count  is the number of item drops found.
  3084.  
  3085. Be sure to use $@MobDrop_count to go through the arrays, and not 
  3086. 'getarraysize', because the temporary global arrays are not cleared between 
  3087. runs of 'getmobdrops'. If a mob with 7 item drops is looked up, the arrays would 
  3088. have 7 elements. But if another mob is looked up and it only has 5 item drops, 
  3089. the server will not clear the arrays for you, overwriting the values instead. So 
  3090. in addition to returning the 5 item drops, the 6th and 7th elements from the 
  3091. last call remain, and you will get 5+2 item drops, of which the last 2 don't 
  3092. belong to the new mob. $@MobDrop_count will always contain the correct number 
  3093. (5), unlike 'getarraysize()' which would return 7 in this case.
  3094.  
  3095. Example:
  3096.  
  3097. 	// get a Mob ID from the user
  3098. 	input .@mob_id;
  3099.  
  3100. 	if (getmobdrops(.@mob_id)) {	// 'getmobdrops' returns 1 on success
  3101. 		// immediately copy global temporary variables into scope variables, 
  3102. 		// since we don't know when 'getmobdrops' will get called again for 
  3103. 		// another mob, overwriting your global temporary variables
  3104. 		set .@count, $@MobDrop_count;
  3105. 		copyarray .@item[0],$@MobDrop_item[0],.@count;
  3106. 		copyarray .@rate[0],$@MobDrop_rate[0],.@count;
  3107.  
  3108. 		mes getmonsterinfo(.@mob_id,MOB_NAME) + " - " + .@count + " drops found:";
  3109. 		for( set .@i,0; .@i < .@count; set .@i,.@i +1 ) {
  3110. 			mes .@item[.@i] + " (" + getitemname(.@item[.@i]) + ") " + .@rate[.@i]/100 + ((.@rate[.@i]%100 < 10) ? ".0":".") + .@rate[.@i]%100 + "%";
  3111. 		}
  3112. 	} else {
  3113. 		mes "Unknown monster ID.";
  3114. 	}
  3115. 	close;
  3116.  
  3117. ---------------------------------------
  3118.  
  3119. *skillpointcount()
  3120.  
  3121. Returns the total amount of skill points a character possesses (SkillPoint+SP's used in skills)
  3122. This command can be used to check the currently attached characters total amount of skill points.
  3123. This means the skill points used in skill are counted, and added to SkillPoints (number of skill points not used).
  3124.  
  3125. Example:
  3126.  
  3127. //This will set the temp character variable @skillPoints to the amount of skill points,
  3128. //and then tell the player the value.
  3129. 	set @skillPoints, skillPointCount();
  3130. 	mes "You have "+@skillPoints+" skill points in total!";
  3131.  
  3132. //Self-explanatory... :P
  3133. 	if (skillPointCount() > 20)
  3134. 		mes "Wow, you have more then 20 Skill Points in total!";
  3135.  
  3136. ---------------------------------------
  3137.  
  3138. *getscrate(<effect type>,<base rate>{,<GID>})
  3139.  
  3140. This function will return the chance of a status effect affecting the invoking 
  3141. character, in percent, modified by the their current defense against said 
  3142. status. The 'base rate' is the base chance of the status effect being inflicted, 
  3143. in percent.
  3144.  
  3145.     if (rand(100) > getscrate(Eff_Blind, 50)) goto BlindHimNow;
  3146.  
  3147. You can see the full list of available effect types you can possibly inflict in 
  3148. 'db/const.txt' under 'Eff_'.
  3149.  
  3150. ---------------------------------------
  3151.  
  3152. ========================
  3153. |3.- Checking commands.|
  3154. ========================
  3155. -------------------------
  3156.  
  3157. *playerattached()
  3158.  
  3159. Returns the ID of the player currently attached to the script. It will return
  3160. 0 if no one is attached, or if the attached player no longer exists on the map
  3161. server. It is wise to check for the attached player in script functions that
  3162. deal with timers as there's no guarantee the player will still be logged on
  3163. when the timer triggers. Note that the ID of a player is actually their
  3164. account ID.
  3165.  
  3166. ---------------------------------------
  3167.  
  3168. *isloggedin(<account id>{,<char id>})
  3169.  
  3170. This function returns 1 if the specified account is logged in and 0 if they 
  3171. aren't. You can also pass the char_id to check for both account and char id.
  3172.  
  3173. ---------------------------------------
  3174.  
  3175. *checkweight(<item id>,<amount>)
  3176. *checkweight("<item name>",<amount>)
  3177.  
  3178. This function will compute and return 1 if the total weight of a specified 
  3179. number of specific items does not exceed the invoking character's carrying 
  3180. capacity, and 0 otherwise. It is important to see if a player can carry the 
  3181. items you expect to give them, failing to do that may open your script up to 
  3182. abuse or create some very unfair errors.
  3183.  
  3184. This function, in addition to checking to see if the player is capable of
  3185. holding a set amount of items, also ensures the player has room in their
  3186. inventory for the item(s) they will be receiving.
  3187.  
  3188. Like 'getitem', this function will also accept an 'english name' from the 
  3189. database as an argument.
  3190.  
  3191.     checkweight(502,10) // 10 apples
  3192.  
  3193.         if (checkweight(502,10) == 0 ) goto L_OverWeight;
  3194.         getitem 502,10;
  3195.         close;
  3196.     L_OverWeight:
  3197.         mes "Sorry you cannot hold this amount of apples";
  3198.         close;
  3199.  
  3200. Or to put this another way:
  3201.  
  3202.         if (checkweight("APPLE",10)) goto L_Getapples;
  3203.         mes "Sorry you cannot hold this amount of apples";
  3204.         close;
  3205.     L_Getapples:
  3206.         getitem 502,10;
  3207.         close;
  3208.  
  3209. Both these examples have the same effect.
  3210.  
  3211. ---------------------------------------
  3212.  
  3213. *basicskillcheck()
  3214.  
  3215. This function will return the state of the configuration option 
  3216. 'basic_skill_check' in 'battle_athena.conf'. It returns 1 if the option is 
  3217. enabled and 0 if it isn't. If the 'basic_skill_check' option is enabled, which 
  3218. it is by default, characters must have a certain number of basic skill levels to 
  3219. sit, request a trade, use emotions, etc. Making your script behave differently 
  3220. depending on whether the characters must actually have the skill to do all these 
  3221. things might in some cases be required.
  3222.  
  3223. ---------------------------------------
  3224.  
  3225. *checkoption(<option number>)
  3226. *checkoption1(<option number>)
  3227. *checkoption2(<option number>)
  3228. *setoption <option number>{,<flag>};
  3229.  
  3230. The 'setoption' series of functions check for a so-called option that is set on 
  3231. the invoking character. 'Options' are used to store status conditions and a lot 
  3232. of other non-permanent character data of the yes-no kind. For most common cases, 
  3233. it is better to use 'checkcart','checkfalcon','checkpeco' and other similar 
  3234. functions, but there are some options which you cannot get at this way. They 
  3235. return 1 if the option is set and 0 if the option is not set.
  3236.  
  3237. Option numbers valid for the first (option) version of this command are:
  3238.  
  3239. 0x1     - Sight in effect.
  3240. 0x2     - Hide in effect.
  3241. 0x4     - Cloaking in effect.
  3242. 0x8     - Cart number 1 present.
  3243. 0x10    - Falcon present.
  3244. 0x20    - Peco Peco present.
  3245. 0x40    - GM Perfect Hide in effect.
  3246. 0x80    - Cart number 2 present.
  3247. 0x100   - Cart number 3 present.
  3248. 0x200   - Cart number 4 present.
  3249. 0x400   - Cart number 5 present.
  3250. 0x800   - Orc head present.
  3251. 0x1000  - The character is wearing a wedding sprite.
  3252. 0x2000  - Ruwach is in effect.
  3253. 0x4000  - Chasewalk in effect.
  3254. 0x8000  - Flying or Xmas suit.
  3255. 0x10000 - Sighttrasher.
  3256.  
  3257. Option numbers valid for the second version (opt1) of this command are:
  3258.  
  3259. 1 - Petrified.
  3260. 2 - Frozen.
  3261. 3 - Stunned.
  3262. 4 - Sleeping.
  3263. 6 - Petrifying (the state where you can still walk)
  3264.  
  3265. Option numbers valid for the third version (opt2) of this command are:
  3266.  
  3267. 0x1  - Poisoned.
  3268. 0x2  - Cursed.
  3269. 0x4  - Silenced.
  3270. 0x8  - Signum Crucis (plays a howl-like sound effect, but otherwise no visible effects are displayed)
  3271. 0x10 - Blinded.
  3272. 0x80 - Deadly poisoned.
  3273.  
  3274. Option numbers (except for opt1) are bit-masks - you can add them up to check
  3275.  for several states, but the functions will return true if at least one of them
  3276.  is in effect.
  3277.  
  3278. 'setoption' will set options on the invoking character. There are no second and 
  3279. third versions of this command, so you can only change the values in the first 
  3280. list (cloak, cart, ruwach, etc). if flag is 1 (default when omitted),
  3281. the option will be added to what the character currently has; if 0, the option is removed. 
  3282.  
  3283. This is definitely not a complete list of available option flag numbers. Ask a 
  3284. core developer (or read the source: src/map/status.h) for the full list.
  3285.  
  3286. ---------------------------------------
  3287.  
  3288. *setcart {<type>};
  3289. *checkcart()
  3290.  
  3291. If <type> is 0 this command will remove the cart from the character.
  3292. Otherwise it gives the invoking character a cart. The cart given will be 
  3293. cart number <type> and will work regardless of whether the character is a 
  3294. merchant class or not.
  3295. Note: the character needs to have the skill MC_PUSHCART to gain a cart
  3296.  
  3297. The accompanying function will return 1 if the invoking character has a cart 
  3298. (any kind of cart) and 0 if they don't.
  3299.  
  3300.     if (checkcart()) mes "But you already have a cart!";
  3301.  
  3302. ---------------------------------------
  3303.  
  3304. *setfalcon {<flag>};
  3305. *checkfalcon()
  3306.  
  3307. If <flag> is 0 this command will remove the falcon from the character.
  3308. Otherwise it gives the invoking character a falcon. The falcon will be there 
  3309. regardless of whether the character is a hunter or not. It will (probably) not 
  3310. have any useful effects for non-hunters though.
  3311. Note: the character needs to have the skill HT_FALCON to gain a falcon
  3312.  
  3313. The accompanying function will return 1 if the invoking character has a falcon 
  3314. and 0 if they don't.
  3315.  
  3316.     if (checkfalcon()) mes "But you already have a falcon!";
  3317.  
  3318. ---------------------------------------
  3319.  
  3320. *setriding {<flag>};
  3321. *checkriding()
  3322.  
  3323. If <flag> is 0 this command will remove the mount from the character.
  3324. Otherwise it give the invoking character a PecoPeco (if they are a Knight 
  3325. series class) or a GrandPeco (if they are a Crusader series class). Unlike 
  3326. 'setfalcon' and 'setcart' this will not work at all if they aren't of a class 
  3327. which can ride.
  3328. Note: the character needs to have the skill KN_RIDING to gain a mount
  3329.  
  3330. The accompanying function will return 1 if the invoking character is riding a 
  3331. bird and 0 if they don't.
  3332.  
  3333.     if (checkriding()) mes "PLEASE leave your bird outside! No riding birds on the floor here!";
  3334.  
  3335. ---------------------------------------
  3336.  
  3337. *checkvending ({"<player name>"})
  3338. *checkchatting ({"<Player Name>"})
  3339.  
  3340. If the player's name is given, this command checks for that player
  3341. to be online and whether he/she is chatting or vending.
  3342. When no name is given, the attached player is used for checking.
  3343. Returns true or false (1 or 0) when the player is chatting/vending or not.
  3344.  
  3345. Example(s):
  3346. if (checkVending("Aaron")) mes "Aaron is currently vending!";
  3347. 	//This will check if Aaron is vending, and if so, put a message in front
  3348. 	//of the attached player saying Aaron is vending.
  3349.  
  3350. if (checkChatting()) mes "You are currently chatting!";
  3351. 	//This will check if you're in a chat room or not
  3352.  
  3353. ---------------------------------------
  3354.  
  3355. *agitcheck()
  3356. *agitcheck2()
  3357.  
  3358. These function will let you check whether the server is currently in WoE mode
  3359. (or WoE SE mode if the second function is called) and will return 1 if War of
  3360. Emperium is on and 0 if it isn't. 
  3361.  
  3362. ---------------------------------------
  3363.  
  3364. *isnight()
  3365. *isday()
  3366.  
  3367. These functions will return 1 or 0 depending on whether the server is in night 
  3368. mode or day mode. 'isnight' returns 1 if it's night and 0 if it isn't, 'isday' 
  3369. the other way around. They can be used interchangeably, pick the one you like 
  3370. more:
  3371.  
  3372.     // These two are equivalent:
  3373.     if (isday()) mes "I only prowl in the night.";
  3374.     if (isnight()!=1) mes "I only prowl in the night.";
  3375.  
  3376. ---------------------------------------
  3377. \\
  3378. 3,1.- Item-related commands
  3379. \\
  3380. ---------------------------------------
  3381. *isequipped(<id>{,<id>{,<id>{,<id>}}})
  3382.  
  3383. This function will return 1 if the invoking character has all of the item 
  3384. IDs given equipped (if card IDs are passed, then it checks if the cards are
  3385. inserted into slots in the equipment they are currently wearing). Theoretically
  3386. there is no limit to the number of items that may be tested for at the same time. 
  3387. If even one of the items given is not equipped, 0 will be returned.
  3388.  
  3389.     // (Poring,Santa Poring,Poporing,Marin)
  3390.     if (isequipped(4001,4005,4033,4196)) mes "Wow! You're wearing a full complement of possible poring cards!";
  3391.     // (Poring)
  3392.     if (isequipped(4001)) mes "A poring card is useful, don't you think?";
  3393.  
  3394. The function was meant for item scripts to support the cards released by Gravity 
  3395. in February 2005, but it will work just fine in normal NPC scripts.
  3396.  
  3397. ---------------------------------------
  3398.  
  3399. *isequippedcnt(<card id>{,<card id>{,<card id>{,<card id>}}})
  3400.  
  3401. This function is similar to 'isequipped', but instead of 1 or 0, it will return 
  3402. the number of cards in the list given that were found on the invoking character.
  3403.  
  3404.     if (isequippedcnt(4001,4005,4033,4196)=4) mes "Finally got all four poring cards?";
  3405.  
  3406. ---------------------------------------
  3407.  
  3408. *checkequipedcard(<card id>)
  3409.  
  3410. This function will return 1 if the card specified by it's item ID number is 
  3411. inserted into any equipment they have in their inventory, currently equipped or 
  3412. not.
  3413.  
  3414. ---------------------------------------
  3415.  
  3416. *getequipisidentify(<equipment slot>)
  3417.  
  3418. This function will return 1 if an item in the specified equipment slot is 
  3419. identified and 0 if it isn't. Since you can't even equip unidentified equipment, 
  3420. there's a question of whether it can actually end up there, and it will normally 
  3421. return 1 all the time if there is an item in this equipment slot.
  3422. Which is kinda pointless.
  3423. For a list of equipment slots see 'getequipid'.
  3424.  
  3425. ---------------------------------------
  3426. //
  3427. 3,1.- End of item-related commands
  3428. //
  3429. ---------------------------------------
  3430.  
  3431. ==============================
  3432. |4.- Player-related commands.|
  3433. ==============================
  3434. -------------------------
  3435.  
  3436. *attachrid(<account ID>)
  3437. *detachrid;
  3438.  
  3439. These commands allow the manipulation of the script's currently attached player.
  3440. While attachrid allows attaching of a different player by using it's account id
  3441. for the parameter rid, detachrid makes the following commands run, as if the
  3442. script was never invoked by a player. 
  3443.  
  3444. In case, that the player cannot be attached, such as, when the player went
  3445. offline in the mean time, attachrid returns 0, otherwise 1.
  3446.  
  3447. ---------------------------------------
  3448.  
  3449. *rid2name(<rid>)
  3450.  
  3451. Converts rid to name. Note: The player/monster/NPC must be online/enabled.
  3452. Good for PCKillEvent where you can convert 'killedrid' to the name of the player.
  3453.  
  3454. Note: rid2name may not produce correct character names since rid = account id.
  3455.       It will return the current online character of the account only.
  3456.  
  3457. ---------------------------------------
  3458.  
  3459. *message "<character name>","<message>";
  3460.  
  3461. That command will send a message to the chat window of the character specified 
  3462. by name. The text will also appear above the head of that character. It will not 
  3463. be seen by anyone else.
  3464.  
  3465. ---------------------------------------
  3466.  
  3467. *dispbottom "<message>";
  3468.  
  3469. This command will send the given message into the invoking character's chat 
  3470. window.
  3471.  
  3472. ---------------------------------------
  3473.  
  3474. *warp "<map name>",<x>,<y>;
  3475.  
  3476. This command will take the invoking character to the specified map, and if 
  3477. wanted, specified coordinates too, but these can be random.
  3478.  
  3479.     warp "place",50,55;
  3480.  
  3481. This would take them to X 50 Y 55 on the map called "place". If your X and Y 
  3482. coordinates land on an unwalkable map square, it will send the warped character 
  3483. to a random place. Same will happen if they are both zero:
  3484.  
  3485.     warp "place",0,0;
  3486.  
  3487. Notice that while warping people to coordinates 0,0 will normally get them into 
  3488. a random place, it's not certain to always be so. Darned if I know where this is 
  3489. actually coded, it might be that this happens because square 0,0 is unwalkable 
  3490. on all official maps. If you're using custom maps, beware.
  3491.  
  3492. There are also three special 'map names' you can use.
  3493.  
  3494. "Random" will warp the player randomly on the current map.
  3495. "Save" and "SavePoint" will warp the player back to their save point.
  3496.  
  3497. ---------------------------------------
  3498.  
  3499. *areawarp "<from map name>",<x1>,<y1>,<x2>,<y2>,"<to map name>",<x3>,<y3>;
  3500.  
  3501. This command is similar to 'warp', however, it will not refer to the invoking 
  3502. character, but instead, all characters within a specified area, defined by the 
  3503. x1/y1-x2/y2 square, will be warped. Nobody outside the area will be affected, 
  3504. including the activating character, if they are outside the area.
  3505.  
  3506.     areawarp "place",10,10,120,120,"place2",150,150;
  3507.  
  3508. Everyone that is in the area between X 10 Y 10 and X 120 Y 120, in a square 
  3509. shape, on the map called "place", will be affected, and warped to "place2" X 150 
  3510. Y 150
  3511.  
  3512.     areawarp "place",10,10,120,120,"place2",0,0;
  3513.  
  3514. By using ,0,0; as the destination coordinates it will take all the characters in 
  3515. the affected area to a random set of co-ordinates on "place2".
  3516.  
  3517. Like 'warp', areawarp will also explicitly warp characters randomly into the 
  3518. current map if you give the 'to map name' as "Random".
  3519.  
  3520. See also 'warp'.
  3521.  
  3522. ---------------------------------------
  3523.  
  3524. *warpparty "<to_mapname>",<x>,<y>,<party_id>,{"<from_mapname>"};
  3525.  
  3526. Warps a party to specified map and coordinate given the party ID, which you can get with
  3527. getcharid(1). You can also request another party id given a member's name with getcharid(1,<player_name>).
  3528.  
  3529. You can use the following "map names" for special warping behavior:
  3530. Random:       All party members are randomly warped in their current map (as if they
  3531.               all used a fly wing)
  3532. SavePointAll: All party members are warped to their respective save point.
  3533. SavePoint:    All party members are warped to the save point of the currently
  3534.               attached player (will fail if there's no player attached).
  3535. Leader:       All party members are warped to the leader's position. The leader must
  3536.               be online and in the current map-server for this to work.
  3537.  
  3538. If you specify a from_mapname, warpparty will only affect those on that map.
  3539.  
  3540. Example:
  3541. mes "[Party Warper]";
  3542. mes "Here you go!";
  3543. close2;
  3544. set @id,getcharid(1);
  3545. warpparty "prontera",150,100,@id;
  3546. close;
  3547.  
  3548. ---------------------------------------
  3549.  
  3550. *warpchar "<mapname>",<x>,<y>,<char_id>;
  3551.  
  3552. Warps another player to specified map and coordinate given the char id, which you can get with
  3553. getcharid(0,<player_name>). Obviously this is useless if you want to warp the same player that
  3554. is executing this script, unless it's some kind of "chosen" script. 
  3555.  
  3556. Example:
  3557.  
  3558. warpchar "prontera",150,100,150001;
  3559.  
  3560. ---------------------------------------
  3561.  
  3562. *warpguild "<mapname>",<x>,<y>,<guild_id>;
  3563.  
  3564. Warps a guild to specified map and coordinate given the guild id, which you can get with 
  3565. getcharid(2). You can also request another guild id given the member's name with getcharid(2,<player_name>).
  3566.  
  3567. You can use the following "map names" for special warping behavior:
  3568. Random:       All party members are randomly warped in their current map (as if they
  3569.               all used a fly wing)
  3570. SavePointAll: All party members are warped to their respective save point.
  3571. SavePoint:    All party members are warped to the save point of the currently
  3572.               attached player (will fail if there's no player attached).
  3573.  
  3574. Example:
  3575.  
  3576. warpguild "prontera",x,y,Guild_ID;
  3577.  
  3578. ---------------------------------------
  3579.  
  3580. *warppartner("<map name>",<x>,<y>);
  3581.  
  3582. This function will find the invoking character's marriage partner, if any, and 
  3583. warp them to the map and coordinates given. Go kidnap that spouse. :) It will 
  3584. return 1 upon success and 0 if the partner is not online, the character is not 
  3585. married, or if there's no invoking character (no RID). 0,0 will, as usual, 
  3586. normally translate to random coordinates.
  3587.  
  3588. ---------------------------------------
  3589.  
  3590. *savepoint "<map name>",<x>,<y>;
  3591. *save "<map name>",<x>,<y>;
  3592.  
  3593. This command saves where the invoking character will return to upon 
  3594. 'return to save point', if dead or in some other cases. The two versions are 
  3595. equivalent. Map name, X coordinate and Y coordinate should be perfectly obvious. 
  3596. This ignores any and all map flags, and can make a character respawn where no 
  3597. teleportation is otherwise possible.
  3598.  
  3599.     savepoint "place",350,75;
  3600.  
  3601. ---------------------------------------
  3602.  
  3603. *heal <hp>,<sp>;
  3604.  
  3605. This command will heal a set amount of HP and/or SP on the invoking character.
  3606.  
  3607.     heal 30000,0; // This will heal 30,000 HP
  3608.     heal 0,30000; // This will heal 30,000 SP
  3609.     heal 300,300; // This will heal 300 HP and 300 SP
  3610.  
  3611. This command just alters the hit points and spell points of the invoking 
  3612. character and produces no other output whatsoever.
  3613.  
  3614. ---------------------------------------
  3615.  
  3616. *itemheal <hp>,<sp>;
  3617.  
  3618. This command heals given absolute amounts of HP and/or SP on the invoking
  3619. character. Unlike heal, this command is intended for use in item scripts. It
  3620. applies potion-related bonuses, such as alchemist ranking, cards and status
  3621. changes. When used inside an NPC script, certain bonuses are omitted.
  3622.  
  3623. There is also a nice example on using this with the 'rand' function, to give you 
  3624. a random amount of healing.
  3625.  
  3626.     // This will heal anything thing from 100 to 150 HP and no SP
  3627.     itemheal rand(100,150),0;
  3628.  
  3629. ---------------------------------------
  3630.  
  3631. *percentheal <hp>,<sp>;
  3632.  
  3633. This command will heal the invoking character. It heals the character, but not 
  3634. by a set value - it adds percent of their maximum HP/SP.
  3635.  
  3636.     percentheal 100,0; // This will heal 100% HP
  3637.     percentheal 0,100; // This will heal 100% SP
  3638.     percentheal 50,50; // This will heal 50% HP and 50% SP
  3639.  
  3640. So the amount that this will heal will depend on the total amount of HP or SP 
  3641. you have maximum. Like 'heal', this will not call up any animations or effects.
  3642.  
  3643. ---------------------------------------
  3644.  
  3645. *recovery;
  3646.  
  3647. This command will revive and restore full HP and SP to all characters currently 
  3648. connected to the server.
  3649.  
  3650. ---------------------------------------
  3651.  
  3652. *jobchange <job number>{,<upper flag>};
  3653.  
  3654. This command will change the job class of the invoking character.
  3655.  
  3656.     jobchange 1; // This would change your player into a Swordman
  3657.     jobchange 4002; // This would change your player into a Swordman High
  3658.  
  3659. This command does work with numbers, but you can also use job names. The full 
  3660. list of job names and the numbers they correspond to can be found in 
  3661. 'db/const.txt'.
  3662.  
  3663.     // This would change your player into a Swordman
  3664.     jobchange Job_Swordman;
  3665.     // This would change your player into a Swordman High
  3666.     jobchange Job_Swordman_High;
  3667.  
  3668. 'upper flag' can alternatively be used to specify the type of job one changes
  3669. to. For example, jobchange Job_Swordman,1; will change the character to a high
  3670. swordsman. The upper values are:
  3671. -1 (or when omitted): preserves the current job type.
  3672. 0: Normal/standard classes
  3673. 1: High/Advanced classes
  3674. 2: Baby classes
  3675.  
  3676. This command will also set a permanent character-based variable 
  3677. 'jobchange_level' which will contain the job level at the time right before 
  3678. changing jobs, which can be checked for later in scripts.
  3679.  
  3680. ---------------------------------------
  3681.  
  3682. *jobname (<job number>)
  3683.  
  3684. This command retrieves the name of the given job using the msg_athena entries 550->650.
  3685.  
  3686. 		mes "[Kid]";
  3687. 		mes "I never thought I'd met a "+jobname(Class)+" here of all places.";
  3688. 		close;
  3689.  
  3690. ---------------------------------------
  3691.  
  3692. *eaclass ({<job number>})
  3693.  
  3694. This commands returns the "eA job-number" corresponding to the given class (if none is given, it returns uses
  3695. the invoking player's class as argument). The eA job-number is also a class number system, but it's one that
  3696. comes with constants which make it easy to convert among classes. The command will return -1 if you pass it a
  3697. job number which doesn't has a eA Job value equivalent.
  3698.  
  3699. 	set @eac, eaclass();
  3700. 	if ((@eac&EAJ_BASEMASK) == EAJ_SWORDMAN)
  3701. 		mes "You must be a swordman, knight, crusader, paladin, high swordman, lord knight, baby swordman,";
  3702. 		mes "baby knight or baby crusader.";
  3703. 	if (@eac&EAJL_UPPER)
  3704. 		mes "You are a rebirth job.";
  3705. 	if ((@eac&EAJ_UPPERMASK) == EAJ_SWORDMAN)
  3706. 		mes "You must be a Swordman, Baby Swordman or High Swordman.";
  3707.  
  3708. For more information on the eA Job System, see the docs/ea_job_system.txt file.
  3709.  
  3710. ---------------------------------------
  3711. *roclass <job number> {,<gender>}
  3712.  
  3713. Does the opposite of eaclass. That is, given a eA Job class, it returns which is the corresponding RO class number. 
  3714. A gender is required because both Bard and Dancers share the same eA Job value (EAJ_BARDDANCER), if it isn't given, the
  3715. gender of the executing player is taken (if there's no player running the script, male will be used by default).
  3716. The command returns -1 when there isn't a valid class to represent the required job (for example, if you try to get the
  3717. baby version of a Taekwon class).
  3718.  
  3719. 	set @eac, eaclass();
  3720. 	//Check if class is already rebirth
  3721. 	if (@eac&EAJL_UPPER) {
  3722. 		mes "You look strong.";
  3723. 		close;
  3724. 	}
  3725. 	set @eac, roclass(@eac|EAJL_UPPER);
  3726. 	//Check if class has a rebirth version
  3727. 	if (@eac != -1) {
  3728. 		mes "Bet you can't wait to become a "+jobname(@eac)+"!";
  3729. 		close;
  3730. 	}
  3731.  
  3732. ---------------------------------------
  3733.  
  3734. *changebase <job ID number>;
  3735.  
  3736. This will change the appearance of the invoking character to that of a specified 
  3737. job class. Nothing but appearance will change. This command is used in item 
  3738. scripts for "Wedding Dress" and "Tuxedo" so the character like job 22, which is 
  3739. the job number of the wedding sprites.
  3740.  
  3741. It would be entered in the equip bonus section of an item
  3742.  
  3743. 2338,Wedding_Dress,Wedding Dress,5,43000,,500,,0,,0,119529470,7,0,16,,0,1,0,{ bonus bMdef,15; changebase 22; }
  3744.  
  3745. ---------------------------------------
  3746.  
  3747. *classchange <view id>,<type>;
  3748.  
  3749. This command is very ancient, it's origins are clouded in mystery. 
  3750. It will send a 'display id change' packet to everyone in the immediate area of 
  3751. the NPC object, which will supposedly make the NPC look like a different sprite, 
  3752. an NPC sprite ID, or a monster ID. This effect is not stored anywhere and will 
  3753. not persist (Which is odd, cause it would be relatively easy to make it do so) 
  3754. and most importantly, will not work at all since this command was broken with 
  3755. the introduction of advanced classes. The code is written with the assumption 
  3756. that the lowest sprite IDs are the job sprites and the anything beyond them is 
  3757. monster and NPC sprites, but since the advanced classes rolled in, they got the 
  3758. ID numbers on the other end of the number pool where monster sprites float.
  3759.  
  3760. As a result it is currently impossible to call this command with a valid view 
  3761. id. It will do nothing whatsoever if the view ID is below 4047. Getting it to 
  3762. run will actually just crash the client.
  3763.  
  3764. It could be a real gem if it can be gotten to actually do what it's supposed to 
  3765. do, but this will only happen in a later SVN revision.
  3766.  
  3767. ---------------------------------------
  3768.  
  3769. *changesex;
  3770.  
  3771. This command will change the gender for the attached character's account. If it 
  3772. was male, it will become female, if it was female, it will become male. The 
  3773. change will be written to the character server, the player will receive the 
  3774. message: "Need disconnection to perform change-sex request..." and the player 
  3775. will be immediately kicked to the login screen. When they log back in, they will 
  3776. be the opposite sex.
  3777.  
  3778. If there are any Dancer/Gypsy or Bard/Clown characters on the account, 
  3779. they will also have their skills reset upon 'changesex'.
  3780.  
  3781. ---------------------------------------
  3782.  
  3783. *getexp <base xp>,<job xp>;
  3784.  
  3785. This command will give the invoking character a specified number of base and job 
  3786. experience points. Can be used as a quest reward. Negative values won't work.
  3787.  
  3788.     getexp 10000,5000;
  3789.  
  3790. You can also use the "set" command with the constants defined in 'db/const.txt':
  3791.  
  3792.     // These 2 combined has the same effect as the above command
  3793.     set BaseExp,BaseExp+10000;
  3794.     set JobExp,JobExp+5000;
  3795.  
  3796. You can also reduce the amount of experience points:
  3797.  
  3798.     set BaseExp,BaseExp-10000;
  3799.  
  3800. Note that 'getexp' is now subject to the 'quest_exp_rate' config option, which
  3801. adjusts the gained value. If you want to bypass this, use the 'set' method.
  3802.  
  3803. ---------------------------------------
  3804.  
  3805. *setlook <look type>,<look value>;
  3806. *changelook <look type>,<look value>;
  3807.  
  3808. 'setlook' will alter the look data for the invoking character. It is used 
  3809. mainly for changing the palette used on hair and clothes: you specify which look 
  3810. type you want to change, then the palette you want to use. Make sure you specify 
  3811. a palette number that exists/is usable by the client you use.
  3812. 'changelook' works the same, but is only client side (it doesn't save the look value).
  3813.  
  3814.     // This will change your hair(6), so that it uses palette 8, what ever your 
  3815.     // palette 8 is, your hair will use that color
  3816.  
  3817.     setlook 6,8;
  3818.  
  3819.     // This will change your clothes(7), so they are using palette 1, whatever 
  3820.     // your palette 1 is, your clothes will then use that set of colors.
  3821.  
  3822.     setlook 7,1;
  3823.  
  3824. Here are the possible look types:
  3825.  
  3826.  0 - Base sprite
  3827.  1 - Hairstyle
  3828.  2 - Weapon
  3829.  3 - Head bottom
  3830.  4 - Head top
  3831.  5 - Head mid
  3832.  6 - Hair color
  3833.  7 - Clothes color
  3834.  8 - Shield
  3835.  9 - Shoes
  3836.  
  3837. Whatever 'shoes' means is anyone's guess, ask Gravity - the client does nothing 
  3838. with this value. It still wants it from the server though, so it is kept, but 
  3839. normally doesn't do a thing.
  3840.  
  3841. Only the look data for hairstyle, hair color and clothes color are saved to the 
  3842. char server's database and will persist. The rest freely change as the character 
  3843. puts on and removes equipment, changes maps, logs in and out and otherwise you 
  3844. should not expect to set them. In fact, messing with them is generally 
  3845. hazardous, do it at your own risk, it is not tested what will this actually do -
  3846. it won't cause database corruption and probably won't cause a server crash, but 
  3847. it's easy to crash the client with just about anything unusual.
  3848.  
  3849. However, it might be an easy way to quickly check for empty view IDs for 
  3850. sprites, which is essential for making custom headgear. 
  3851.  
  3852. Since a lot of people have different palettes for hair and clothes, it's 
  3853. impossible to tell you what all the color numbers are. If you want a serious 
  3854. example, there is a Stylist script inside the default rAthena installation that 
  3855. you can look at, this may help you create a Stylist of your own: 
  3856. 'custom\dye.txt'
  3857.  
  3858. ---------------------------------------
  3859.  
  3860. *pushpc <direction>,<cells>;
  3861.  
  3862. This command will push the currently attached player to given direction by given
  3863. amount of square cells. Direction is the same as used when declaring NPCs, and
  3864. can be specified by using one of the DIR_* constants (db/const.txt).
  3865.  
  3866. The knock-back is not restricted by items or map flags, only obstacles are taken
  3867. into account. If there is not enough space to perform the push (e.g. due to a
  3868. wall), the character is pushed only up to the obstacle.
  3869.  
  3870.     // pushes the character 5 cells in 3 o'clock direction from it's
  3871.     // current position.
  3872.     pushpc DIR_EAST, 5;
  3873.  
  3874. ---------------------------------------
  3875. \\
  3876. 4,1.- Item-related commands
  3877. \\
  3878. ---------------------------------------
  3879.  
  3880. *getitem <item id>,<amount>{,<account ID>};
  3881. *getitem "<item name>",<amount>{,<account ID>};
  3882.  
  3883. This command will give a specific amount of specified items to the target 
  3884. character. If the character is not online, nothing will happen.
  3885. If <account ID> is not specified, items will be created in the invoking 
  3886. character inventory instead.
  3887.  
  3888. In the first and most commonly used version of this command, items are 
  3889. referred to by their database ID number found inside 'db/item_db.txt'.
  3890.  
  3891.     getitem 502,10 // The person will receive 10 apples
  3892.     getitem 617,1  // The person will receive 1 Old Violet Box
  3893.  
  3894. Giving an item ID of -1 will give a specified number of random items from the 
  3895. list of those that fall out of Old Blue Box. Unlike in all other cases, these 
  3896. will be unidentified, if they turn out to be equipment. This is exactly what's 
  3897. written in the Old Blue Box's item script.
  3898.  
  3899. Other negative IDs also correspond to other random item generating item tables:
  3900.  
  3901. Giving an item ID of -2 will produce the effects of Old Violet Box.
  3902. Giving an item ID of -3 will produce the effects of Old Card Album.
  3903. Giving an item ID of -4 will produce the effects of Gift Box.
  3904. Giving an item ID of -5 will produce the effects of Worn Out Scroll, which, in 
  3905. current SVN, drops only Jellopies anyway.
  3906.  
  3907. This transaction is logged if the log script generated transactions option is 
  3908. enabled.
  3909.  
  3910. You may also create an item by it's name in the 'english name' field in the 
  3911. item database:
  3912.  
  3913.     getitem "RED_POTION",10;
  3914.  
  3915. Which will do what you'd expect. If it can't find that name in the database, 
  3916. apples will be created anyway. It is often a VERY GOOD IDEA to use it like this.
  3917.  
  3918. This is used in pretty much all NPC scripts that have to do with items and 
  3919. quite a few item scripts. For more examples check just about any official script.
  3920.  
  3921. ---------------------------------------
  3922.  
  3923. *getitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
  3924. *getitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
  3925.  
  3926. This command will give an amount of specified items to the invoking character. 
  3927. If an optional account ID is specified, and the target character is currently 
  3928. online, items will be created in their inventory instead. If they are not 
  3929. online, nothing will happen. It works essentially the same as 'getitem' (it even 
  3930. works for negative ID numbers the same way, which is kinda silly) but is a lot 
  3931. more flexible, since it allows you to give the player an item altered with it's 
  3932. specific properties. 
  3933.  
  3934. Those parameters that are different from 'getitem' are:
  3935.  
  3936. identify    - Whether you want the item to be identified or not, 0 unidentified, 
  3937.               1 identified.
  3938. refine      - For how many pluses will it be refined.
  3939.               It will not let you refine an item higher than +10, if you 
  3940.               specify more it'll still be 10.
  3941. attribute   - Whether the item is broken (1) or not (0) and NOT an elemental 
  3942.               attribute. 
  3943. card1,2,3,4 - If you want a card compound to it, place the card ID number into 
  3944.               the specific card slot. Card ID numbers also found in 
  3945.               'db/item_db.txt'
  3946.  
  3947. Card1-card4 values are also used to store name information for named items, as 
  3948. well as the elemental property of weapons and armor. You can create a named item 
  3949. in this manner, however, if you just need a named piece of standard equipment, 
  3950. it is much easier to the 'getnameditem' function instead.
  3951.  
  3952. You will need to keep these values if you want to destroy and then perfectly 
  3953. recreate a named item, for this see 'getinventorylist'.
  3954.  
  3955. If you still want to try creating a named item with this command because 
  3956. 'getnameditem' won't do it for you cause it's too limited, you can do it like 
  3957. this. Careful, minor magic ahead.
  3958.  
  3959.     // First, let's get an ID of a character who's name will be on the item.
  3960.     // Only an existing character's name may be there.
  3961.     // Let's assume our character is 'Adam' and find his ID.
  3962.  
  3963.     set @charid,getcharid(0,"Adam");
  3964.  
  3965.     // Now we split the character ID number into two portions with a binary
  3966.     // shift operation. If you don't understand what this does, just copy it.
  3967.  
  3968.     set @card3, @charid & 65535;
  3969.     set @card4, @charid >> 16;
  3970.  
  3971.     // If you're inscribing non-equipment, @card1 must be 254.
  3972.     // Arrows are also not equipment. :)
  3973.     set @card1,254;
  3974.  
  3975.     // For named equipment, card2 means the Star Crumbs and elemental 
  3976.     // crystals used to make this equipment. For everything else, it's 0.
  3977.  
  3978.     set @card2,0;
  3979.  
  3980.     // Now, let's give the character who invoked the script some 
  3981.     // Adam's Apples:
  3982.  
  3983.     getitem2 512,1,1,0,0,@card1,@card2,@card3,@card4;
  3984.  
  3985. This wasn't tested with all possible items, so I can't give any promises, 
  3986. experiment first before relying on it.
  3987.  
  3988. To create equipment, continue this example it like this:
  3989.  
  3990.     // We've already have card3 and card4 loaded with correct
  3991.     // values so we'll just set up card1 and card2 with data
  3992.     // for an Ice Stiletto.
  3993.  
  3994.     // If you're inscribing equipment, @card1 must be 255.
  3995.     set @card1,255;
  3996.  
  3997.     // That's the number of star crumbs in a weapon.
  3998.     set @sc,2;
  3999.  
  4000.     // That's the number of elemental property of the weapon.
  4001.     set @ele,1;
  4002.  
  4003.     // And that's the wacky formula that makes them into
  4004.     // a single number.    
  4005.     set @card2,@ele+((@sc*5)<<8);
  4006.  
  4007.     // That will make us an Adam's +2 VVS Ice Stiletto:
  4008.  
  4009.     getitem2 1216,1,1,2,0,@card1,@card2,@card3,@card4;
  4010.  
  4011. Experiment with the number of star crumbs - I'm not certain just how much will 
  4012. work most and what it depends on. The valid element numbers are:
  4013.  
  4014.  1 - Ice, 2 - Earth 3 - Fire 4 - Wind.
  4015.  
  4016. You can, apparently, even create duplicates of the same pet egg with this 
  4017. command, creating a pet which is the same, but simultaneously exists in two 
  4018. eggs, and may hatch from either, although, I'm not sure what kind of a mess will 
  4019. this really cause.
  4020.  
  4021. ---------------------------------------
  4022.  
  4023. *getnameditem <item name|item id>,<Character name|character ID>;
  4024.  
  4025. -Note: there's a total of 4 possible combinations of this command.
  4026. E.g: item name and character name, or with character id, etc...
  4027.  
  4028. Create a item signed with the given character's name. 
  4029. This is the same as using the hard(ly) explained way with getitem2.
  4030.  
  4031. The command returns 1 when the item is created successfully, or 0 when failed.
  4032. Failure occurs when there is:
  4033. - no player attached
  4034. - Item name or ID is not valid
  4035. - The given character ID/name is offline.
  4036.  
  4037. Example:
  4038.  
  4039. //This will give the currently attached player a Aaron's Apple (if Aaron is online).
  4040. 	getnameditem "Apple","Aaron";
  4041.  
  4042. //Self-explanatory (I hope).
  4043. 	if (getnameitem("Apple","Aaron")) {
  4044. 		mes "You now have a Aaron's Apple!";
  4045. 	}
  4046.  
  4047. ---------------------------------------
  4048.  
  4049. *rentitem <item id>,<time>;
  4050. *rentitem "<item name>",<time>;
  4051.  
  4052. Creates a rental item in the attached character's inventory. The item will expire 
  4053. in <time> seconds and be automatically deleted. When receiving a rental item, 
  4054. the character will receive a message in their chat window. The character will 
  4055. also receive warning messages in their chat window before the item disappears.
  4056.  
  4057. This command can not be used to rent stackable items. Rental items cannot be 
  4058. dropped, traded, sold to NPCs, or placed in guild storage. (i.e. trade mask 75)
  4059. Note: 'delitem' in an NPC script can still remove rental items.
  4060.  
  4061. ---------------------------------------
  4062.  
  4063. *makeitem <item id>,<amount>,"<map name>",<X>,<Y>;
  4064. *makeitem "<item name>",<amount>,"<map name>",<X>,<Y>;
  4065.  
  4066. This command will create an item lying around on a specified map in the 
  4067. specified location.
  4068.  
  4069.  itemid   - Found in 'db/item_db.txt'
  4070.  amount   - Amount you want produced
  4071.  map name - The map name
  4072.  X        - The X coordinate
  4073.  Y        - The Y coordinate.
  4074.  
  4075. This item will still disappear just like any other dropped item. Like 'getitem', 
  4076. it also accepts an 'english name' field from the database and creates apples if 
  4077. the name isn't found.
  4078. If the map name is given as "this", the map the invoking character is on will be used.
  4079.  
  4080. ---------------------------------------
  4081.  
  4082. *searchitem <array name>,"<item name>";
  4083.  
  4084. This command will fill the given array with the ID of items whose name matches the given one. It returns the number of items found. For performance reasons, the results array is limited to 10 items.
  4085.  
  4086. 	mes "What item are you looking for?";
  4087. 	input @name$;
  4088. 	set @qty, searchitem(@matches[0],@name$);
  4089. 	mes "I found "+@qty+" items:";
  4090. 	for (set @i, 0; @i < @qty; set @i, @i+1)
  4091. 		//Display name (eg: "Apple[0]")
  4092. 		mes getitemname(@matches[@i])+"["+getitemslots(@matches[@i])+"]";
  4093.  
  4094. ---------------------------------------
  4095.  
  4096. *delitem <item id>,<amount>{,<account ID>};
  4097. *delitem "<item name>",<amount>{,<account ID>};
  4098.  
  4099. This command will take a specified amount of items from the invoking/target character. 
  4100. As all the item commands, this one uses the ID of the item found inside 
  4101. 'db/item_db.txt'. The items are destroyed - there is no way an NPC can simply 
  4102. own items and have an inventory of them, other as by destroying and recreating 
  4103. them when needed.
  4104.  
  4105.     delitem 502,10 // The person will lose 10 apples
  4106.     delitem 617,1  // The person will lose 1 Old Violet Box
  4107.  
  4108. It is always a good idea to check if the player actually has the items before you delete them.
  4109. If you try to delete more items that the player has, the player will lose the ones he/she has 
  4110. and the script will be terminated with an error.
  4111.  
  4112. Like 'getitem' this command will also accept an 'english name' field from the 
  4113. database. If the name is not found, nothing will be deleted.
  4114.  
  4115. ---------------------------------------
  4116.  
  4117. *delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
  4118. *delitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
  4119.  
  4120. This command will take a specified amount of items from the invoking/target character. 
  4121. Check 'getitem2' to understand its expanded parameters.
  4122.  
  4123. ---------------------------------------
  4124.  
  4125. *countitem(<item id>)
  4126. *countitem("<item name>")
  4127.  
  4128. This function will return the number of items for the specified item ID that the 
  4129. invoking character has in the inventory.
  4130.  
  4131.     mes "[Item Checker]";
  4132.     mes "Hmmm, it seems you have "+countitem(502)+" apples";
  4133.     close;
  4134.  
  4135. Like 'getitem', this function will also accept an 'english name' from the 
  4136. database as an argument.
  4137.  
  4138. If you want to state the number at the end of a sentence, you can do it by 
  4139. adding up strings:
  4140.  
  4141.     mes "[Item Checker]";
  4142.     mes "Hmmm, the total number of apples you are holding is "+countitem("APPLE");
  4143.     close;
  4144.  
  4145. ---------------------------------------
  4146.  
  4147. *countitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
  4148. *countitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
  4149.  
  4150. Expanded version of 'countitem' function, used for created/carded/forged items.
  4151.  
  4152. This function will return the number of items for the specified item ID and
  4153. other parameters that the invoking character has in the inventory.
  4154. Check 'getitem2' to understand the arguments of the function.
  4155.  
  4156. ---------------------------------------
  4157.  
  4158. *groupranditem <group id>;
  4159.  
  4160. Returns the item_id of a random item picked from the group specified. The
  4161. different groups and their group number are specified in db/item_group_db.txt
  4162.  
  4163. When used in conjunction with other functions, you can get a random item. For
  4164. example, for a random pet lure:
  4165.  
  4166. getitem groupranditem(15),1;
  4167.  
  4168. ---------------------------------------
  4169.  
  4170. *enable_items;
  4171. *disable_items;
  4172.  
  4173. These commands enable item usage while an NPC is running. When enable_items is
  4174. run, items can be used during scripts until disable_items is called. 
  4175. To avoid possible exploits, when enable_items is invoked, it will only enable
  4176. item usage while running that script in particular. Note that if a different
  4177. script also calls enable_items, it will override the last call (so you may
  4178. want to call this command at the start of your script without assuming the
  4179. effect is still in effect).
  4180.  
  4181. ---------------------------------------
  4182.  
  4183. *itemskill <skill id>,<skill level>;
  4184. *itemskill "<skill name>",<skill level>;
  4185.  
  4186. This command meant for item scripts to replicate single-use skills in usable
  4187. items. It will not work properly, if there is a visible dialog window or menu.
  4188. If the skill is self or auto-targeting, it will be used immediately otherwise a
  4189. target cursor is shown.
  4190.  
  4191. // When Anodyne is used, it will cast Endure (8), Level 1, as if the actual
  4192. // skill has been used from skill tree.
  4193. 605,Anodyne,Anodyne,11,2000,0,100,,,,,10477567,2,,,,,{ itemskill 8,1; },{}
  4194.  
  4195.  
  4196. ---------------------------------------
  4197.  
  4198. *produce <item level>;
  4199.  
  4200. This command will open a crafting window on the client connected to the invoking 
  4201. character. The 'item level' is a number which determines what kind of a crafting 
  4202. window will pop-up. You can see the full list of such item levels in 
  4203. 'db/produce_db.txt' which determines what can actually be produced.
  4204. The window will not be empty only if the invoking character can actually produce 
  4205. the items of that type and has the appropriate raw materials in their inventory.
  4206.  
  4207. Valid item levels are:
  4208.  
  4209.  1   - Level 1 Weapons
  4210.  2   - Level 2 Weapons
  4211.  3   - Level 3 Weapons
  4212.  21  - Blacksmith's Stones and Metals
  4213.  22  - Alchemist's Potions, Holy Water, Assassin Cross's Deadly Poison
  4214.  23  - Elemental Converters
  4215.  
  4216. ---------------------------------------
  4217.  
  4218. *cooking <dish level>;
  4219.  
  4220. This command will open a produce window on the client connected to the invoking 
  4221. character. The 'dish level' is the number which determines what kind of dish
  4222. level you can produce. You can see the full list of dishes that can be produced in 
  4223. 'db/produce_db.txt'.
  4224.  
  4225. The window will be shown empty if the invoking character does not have enough of
  4226. the required incredients to cook a dish.
  4227.  
  4228. Valid dish levels are:
  4229.  
  4230. 11 - Level 1 Dish
  4231. 12 - Level 2 Dish
  4232. 13 - Level 3 Dish
  4233. 14 - Level 4 Dish
  4234. 15 - Level 5 Dish
  4235. 16 - Level 6 Dish
  4236. 17 - Level 7 Dish
  4237. 18 - Level 8 Dish
  4238. 19 - Level 9 Dish
  4239. 20 - Level 10 Dish
  4240.  
  4241. Altough it's required to set a dish level, it doesn't matter if you set it to 1
  4242. and you want to cook a level 10 dish, as long as you got the required incredients
  4243. to cook the dish the command works.
  4244.  
  4245. ---------------------------------------
  4246.  
  4247. *successremovecards <equipment slot>;
  4248.  
  4249. This command will remove all cards from the item found in the specified 
  4250. equipment slot of the invoking character, create new card items and give them to 
  4251. the character. If any cards were removed in this manner, it will also show a 
  4252. success effect.
  4253.  
  4254. ---------------------------------------
  4255.  
  4256. *failedremovecards <equipment slot>,<type>;
  4257.  
  4258. This command will remove all cards from the item found in the specified 
  4259. equipment slot of the invoking character. 'type' determines what happens to the 
  4260. item and the cards:
  4261.  
  4262.  0 - will destroy both the item and the cards.
  4263.  1 - will keep the item, but destroy the cards.
  4264.  2 - will keep the cards, but destroy the item.
  4265.  
  4266. Whatever the type is, it will also show a failure effect on screen.
  4267.  
  4268. ---------------------------------------
  4269.  
  4270. *repair <broken item number>;
  4271.  
  4272. This command repairs a broken piece of equipment, using the same list of broken 
  4273. items as available through 'getbrokenid'.
  4274.  
  4275. The official scripts seem to use the repair command as a function instead: 
  4276. 'repair(<number>)' but it returns nothing on the stack. Probably only Valaris, 
  4277. who made it, can answer why is it so.
  4278.  
  4279. ---------------------------------------
  4280.  
  4281. *successrefitem <equipment slot>;
  4282.  
  4283. This command will refine an item in the specified equipment slot of the invoking 
  4284. character by +1. For a list of equipment slots see 'getequipid'. This command 
  4285. will not only add the +1, but also display a 'refine success' effect on the 
  4286. character and put appropriate messages into their chat window. It will also give 
  4287. the character fame points if a weapon reached +10 this way, even though these 
  4288. will only take effect for blacksmith who will later forge a weapon.
  4289.  
  4290. The official scripts seem to use the 'successrefitem' command as a function 
  4291. instead: 'successrefitem(<number>)' but it returns nothing on the stack. 
  4292. This is since jAthena, so probably nobody knows for sure why is it so.
  4293.  
  4294. ---------------------------------------
  4295.  
  4296. *failedrefitem <equipment slot>;
  4297.  
  4298. This command will fail to refine an item in the specified equipment slot of the 
  4299. invoking character. The item will be destroyed. This will also display a 'refine 
  4300. failure' effect on the character and put appropriate messages into their chat 
  4301. window.
  4302.  
  4303. The official scripts seem to use the 'failedrefitem' command as a function 
  4304. instead: 'failedrefitem(<number>)' but it returns nothing on the stack. This is 
  4305. since jAthena, so probably nobody knows for sure why is it so.
  4306.  
  4307.  
  4308. ---------------------------------------
  4309.  
  4310. *unequip <equipment slot>;
  4311.  
  4312. This command will unequip whatever is currently equipped in the invoking 
  4313. character's specified equipment slot. For a full list of possible equipment 
  4314. slots see 'getequipid'.
  4315.  
  4316. If an item occupies several equipment slots, it will get unequipped from all of 
  4317. them. (Which is a good thing.)
  4318.  
  4319. ---------------------------------------
  4320.  
  4321. *clearitem;
  4322.  
  4323. This command will destroy all items the invoking character has in their 
  4324. inventory. (that includes equipped items) It will not affect anything else, like 
  4325. storage or cart.
  4326.  
  4327. ---------------------------------------
  4328.  
  4329. *equip <item id>;
  4330. *autoEquip <item id>,<option>;
  4331.  
  4332. These commands are to equip a equipment on the attached character. 
  4333. The equip function will equip the item ID given when the player has
  4334. this item in his/her inventory, while the autoequip function will 
  4335. equip the given item ID when this is looted. The option parameter of
  4336. the autoequip is 1 or 0, 1 to turn it on, and 0 to turn it off.
  4337.  
  4338. Example(s):
  4339.  
  4340. //This will equip a 1104 (falchion) on the character if this is in the inventory.
  4341. 	equip 1104;
  4342.  
  4343. //The invoked character will now automatically equip a falchion when it's looted.
  4344. 	autoequip 1104,1;
  4345.  
  4346. //The invoked character will no longer automatically equip a falchion.
  4347. 	autoequip 1104,0;
  4348.  
  4349. ---------------------------------------
  4350.  
  4351. *buyingstore <slots>;
  4352.  
  4353. Invokes buying store preparation window like the skill 'Open Buying Store',
  4354. without the item requirement. Amount of slots is limited by the server to
  4355. a maximum of 5 slots by default.
  4356.  
  4357. Example:
  4358.  
  4359. 	// Gives the player oppurtunity to buy 4 different kinds of items.
  4360. 	buyingstore 4;
  4361.  
  4362. ---------------------------------------
  4363.  
  4364. *searchstores <uses>,<effect>;
  4365.  
  4366. Invokes the store search window, which allows to search for both vending
  4367. and buying stores. Parameter uses indicates, how many searches can be
  4368. started, before the window has to be reopened. Effect value affects,
  4369. what happens, when a result item is double-clicked and can be one of the
  4370. following:
  4371.  
  4372. 	0 = Shows the store's position on the mini-map and highlights the
  4373. 		shop sign with yellow color, when the store is on same map
  4374. 		as the invoking player.
  4375. 	1 = Directly opens the shop, regardless of distance.
  4376.  
  4377. Example:
  4378.  
  4379. 	// Item Universal_Catalog_Gold (10 uses, effect: open shop)
  4380. 	searchstores 10,1;
  4381.  
  4382. ---------------------------------------
  4383. //
  4384. 4,1.- End of item-related commands
  4385. //
  4386. ---------------------------------------
  4387.  
  4388. *openstorage;
  4389.  
  4390. This will open character's Kafra storage window on the client connected to the
  4391. invoking character. It can be used from any kind of NPC or item script, not just
  4392. limited to Kafra Staff.
  4393.  
  4394. The storage window opens regardless of whether there are open NPC dialogs or
  4395. not, but it is preferred to close the dialog before displaying the storage
  4396. window, to avoid any disruption when both windows overlap.
  4397.  
  4398.     mes "I will now open your stash for you";
  4399.     close2;
  4400.     openstorage;
  4401.     end;
  4402.  
  4403. ---------------------------------------
  4404.  
  4405. *openmail;
  4406.  
  4407. This will open a character's Mail window on the client connected to the 
  4408. invoking character.
  4409.  
  4410.     mes "Close this window to open your mail inbox.";
  4411.     close2;
  4412.     openmail;
  4413.     end;
  4414.  
  4415. ---------------------------------------
  4416.  
  4417. *openauction;
  4418.  
  4419. This will open the Auction window on the client connected to the invoking character.
  4420.  
  4421.     mes "Close this window to open the Auction window.";
  4422.     close2;
  4423.     openauction;
  4424.     end;
  4425.  
  4426. ---------------------------------------
  4427. \\
  4428. 4,2.- Guild-related commands
  4429. \\
  4430. ---------------------------------------
  4431.  
  4432. *guildopenstorage()
  4433.  
  4434. This function works the same as 'openstorage' but will open a guild storage 
  4435. window instead for the guild storage of the guild the invoking character belongs 
  4436. to. This is a function because it returns a value - 0 if the guild storage was 
  4437. opened successfully and 1 if it wasn't. (Notice, it's a ZERO upon success.) 
  4438. Since guild storage is only accessible to one character at one time, it may fail 
  4439. if another character is accessing the guild storage at the same time.
  4440.  
  4441. This will also fail and return 2 if the character does not belong to any guild.
  4442.  
  4443. ---------------------------------------
  4444.  
  4445. *guildchangegm(<guild id>,<new master's name>)
  4446.  
  4447. This function will change the Guild Master of a guild. The ID is the guild's
  4448. id, and the new guild master's name must be passed.
  4449.  
  4450. Returns 1 on success, 0 otherwise.
  4451.  
  4452. ---------------------------------------
  4453.  
  4454. *guildgetexp <amount>;
  4455.  
  4456. This will give the specified amount of guild experience points to the guild the 
  4457. invoking character belongs to. It will silently fail if they do not belong to 
  4458. any guild.
  4459.  
  4460. ---------------------------------------
  4461.  
  4462. *guildskill <skill id>,<level>
  4463. *guildskill "<skill name>",<level>
  4464.  
  4465. This command will bump up the specified guild skill by the specified number of 
  4466. levels. This refers to the invoking character and will only work if the invoking 
  4467. character is a member of a guild AND it's guild master, otherwise no failure 
  4468. message will be given and no error will occur, but nothing will happen - same 
  4469. about the guild skill trying to exceed the possible maximum. The full list of 
  4470. guild skills is available in 'db/skill_db.txt', these are all the GD_ skills at 
  4471. the end.
  4472.  
  4473. The flag parameter is currently not functional and it's a mystery of what it 
  4474. would actually do. (Though probably, like for character skills, it would allow 
  4475. temporary bumping.) Using this command will bump the guild skill up permanently.
  4476.  
  4477. // This would give your character's guild one level of Approval (GD_APPROVAL ID 
  4478. // 10000). Notice that if you try to add two levels of Approval, or add
  4479. // Approval when the guild already has it, it will only have one level of 
  4480. // Approval afterwards.
  4481.     guildskill 10000,1,0;
  4482.  
  4483. You might want to make a quest for getting a certain guild skill, make it hard 
  4484. enough that all the guild needs to help or something. Doing this for the Glory 
  4485. of the Guild skill, which allows your guild to use an emblem, is a good idea for 
  4486. a fun quest. (Wasting a level point on that is really annoying :D)
  4487.  
  4488. ---------------------------------------
  4489. //
  4490. 4,2 End of guild-related commands.
  4491. //
  4492. ---------------------------------------
  4493.  
  4494. *resetlvl <action type>;
  4495.  
  4496. This is a character reset command, meant mostly for rebirth script supporting 
  4497. Advanced jobs, which will reset the invoking character's stats and level 
  4498. depending on the action type given. Valid action types are:
  4499.  
  4500.  1 - Base level 1, Job level 1, 0 skill points, 0 base exp, 0 job exp, wipes the 
  4501.      status effects (only the ones settable by 'setoption'), sets all stats to 1. 
  4502.      If the new job is 'Novice High', give 100 status points, give First Aid and 
  4503.      Play Dead skills.
  4504.  2 - Base level 1, Job level 1, 0 skill points, 0 base exp, 0 job exp. 
  4505.      Skills and attribute values are not altered.
  4506.  3 - Base level 1, base exp 0. Nothing else is changed.
  4507.  4 - Job level 1, job exp 0. Nothing else is changed.
  4508.  
  4509. In all cases everything the character has on will be unequipped.
  4510.  
  4511. Even though it doesn't return a value, it is used as a function in the official 
  4512. rebirth scripts. Ask AppleGirl why.
  4513.  
  4514. ---------------------------------------
  4515.  
  4516. *resetstatus;
  4517.  
  4518. This is a character reset command, which will reset the stats on the invoking 
  4519. character and give back all the stat points used to raise them previously. 
  4520. Nothing will happen to any other numbers about the character.
  4521.  
  4522. Used in reset NPC's (duh!)
  4523.  
  4524. ---------------------------------------
  4525.  
  4526. *resetskill;
  4527.  
  4528. This command takes off all the skill points on the invoking character, so they 
  4529. only have Basic Skill blanked out (lvl 0) left, and returns the points for them 
  4530. to spend again. Nothing else will change but the skills. Quest skills will also 
  4531. reset if 'quest_skill_reset' option is set to Yes in 'battle_athena.conf'. If 
  4532. the 'quest_skill_learn' option is set in there, the points in the quest skills 
  4533. will also count towards the total.
  4534.  
  4535. Used in reset NPC's (duh!)
  4536.  
  4537. ---------------------------------------
  4538.  
  4539. *sc_start 	<effect type>,<ticks>,<extra argument>{,<GID>};
  4540. *sc_start2 	<effect type>,<ticks>,<extra argument>,<percent chance>{,<GID>};
  4541. *sc_start4	<effect type>,<ticks>,<value 1>,<value 2>,<value 3>,<value 4>{,<GID>};
  4542. *sc_end 	<effect type>{,<GID>};
  4543.  
  4544. These command bestow a status effect on the invoking character. This command is 
  4545. used a lot in the item scripts.
  4546.  
  4547.     // This would poison them for 10 min
  4548.     sc_start SC_Poison,600000,0;
  4549.  
  4550. Effect type is a number of effect, 'db/const.txt' lists the common (mostly 
  4551. negative) status effect types as constants, starting with 'SC_'. You can also 
  4552. use this to give someone an effect of a player-cast spell:
  4553.  
  4554.     // This will bless someone as if with Bless 10:
  4555.     sc_start 10,240000,10;
  4556.  
  4557. Extra argument's meaning differs depending on the effect type, for most effects 
  4558. caused by a player skill the extra argument means the level of the skill that 
  4559. would have been used to create that effect, for others it might have no meaning 
  4560. whatsoever. You can actually bless someone with a 0 bless spell level this way, 
  4561. which is fun, but weird.
  4562.  
  4563. The GID, if given, will cause the status effect to appear on a 
  4564. specified character, instead of the one attached to the running script. This has 
  4565. not been properly tested.
  4566.  
  4567. 'sc_start2' is perfectly equivalent, but unlike 'sc_start', a status change 
  4568. effect will only occur with a specified percentage chance. 10000 given as the 
  4569. chance is equivalent to a 100% chance, 0 is a zero.
  4570.  
  4571. 'sc_start4' is just like sc_start, however it takes four parameters for the
  4572. status change instead of one. What these values are depends on the status
  4573. change in question. For example, elemental armor defense takes the following
  4574. four values:
  4575. - val1 is the first element, val2 is the resistance to the element val1.
  4576. - val3 is the second element, val4 is the resistance to said element.
  4577. eg: sc_start4 SC_DefEle,60000,Ele_Fire,20,Ele_Water,-15;
  4578.  
  4579. 'sc_end' will remove a specified status effect. If SC_All is used (-1), it will
  4580. do a complete removal of all statuses (although permanent ones will re-apply).
  4581.  
  4582. You can see the full list of status effects caused by skills in 
  4583. 'src/map/status.h' - they are currently not fully documented, but most of that 
  4584. should be rather obvious.
  4585.  
  4586. ---------------------------------------
  4587.  
  4588. *getstatus <effect type>{,<type>};
  4589.  
  4590. Retrieve information about a specific status effect when called. Depending on <type>
  4591. specified the function will return different information.
  4592.  
  4593. Possible <type> values:
  4594. 	- 0 or undefined: whether the status is active
  4595. 	- 1: the val1 of the status
  4596. 	- 2: the val2 of the status
  4597. 	- 3: the val3 of the status
  4598. 	- 4: the val4 of the status
  4599. 	- 5: the amount of time in milliseconds that the status has remaining
  4600.  
  4601. If <type> is not defined or is set to 0, then the script function will either
  4602. return 1 if the status is active, or 0 if the status is not active. If the status
  4603. is not active when any of the <type> fields are provided, this script function
  4604. will always return 0.
  4605.  
  4606. ---------------------------------------
  4607.  
  4608. *skilleffect <skill id>,<number>;
  4609. *skilleffect "<skill name>",<number>;
  4610.  
  4611. This command displays visual and aural effects of given skill on currently
  4612. attached character. The number parameter is for skill whose visual effect
  4613. involves displaying of a number (healing or damaging). Note, that this command
  4614. will not actually use the skill, it is intended for scripts, which simulate
  4615. skill usage by the NPC, such as buffs, by setting appropriate status and
  4616. displaying the skill's effect.
  4617.  
  4618.     mes "Be blessed!";
  4619.     // Heal of 2000 HP
  4620.     heal 2000,0;
  4621.     skilleffect 28,2000;
  4622.     // Blessing Level 10
  4623.     sc_start 10,240000,10;
  4624.     skilleffect 34,0;
  4625.     // Increase AGI Level 5
  4626.     sc_start 12,140000,5;
  4627.     skilleffect 29,0;
  4628.  
  4629. This will heal the character with 2000 HP, buff it with Blessing Lv 10 and
  4630. Increase AGI Lv 5, and display appropriate effects.
  4631.  
  4632. ---------------------------------------
  4633.  
  4634. *npcskilleffect <skill id>,<number>,<x>,<y>;
  4635. *npcskilleffect "<skill name>",<number>,<x>,<y>;
  4636.  
  4637. This command behaves identically to 'skilleffect', however, the effect will not 
  4638. be centered on the invoking character's sprite, nor on the NPC sprite, if any, 
  4639. but will be centered at map coordinates given on the same map as the invoking 
  4640. character.
  4641.  
  4642. ---------------------------------------
  4643.  
  4644. *specialeffect <effect number>{,<send_target>{,"<NPC Name>"}};
  4645.  
  4646. This command will display special effect with the given number, centered on the 
  4647. specified NPCs coordinates, if any. For a full list of special effect numbers 
  4648. known see 'doc/effect_list.txt'. Some effect numbers are known not to work in 
  4649. some client releases. (Notably, rain is absent from any client executables 
  4650. released after April 2005.)
  4651.  
  4652. <NPC name> parameter will display <effect number> on another NPC. If the NPC
  4653. specified does not exist, the command will do nothing. When specifying an NPC,
  4654. <send_target> must be specified when specifying an <NPC Name>, specifying AREA 
  4655. will retain the default behavior of the command.
  4656.  
  4657. 	// this will make the NPC "John Doe#1"
  4658. 	// show the effect "EF_HIT1" specified by
  4659. 	// Jane Doe. I wonder what John did...
  4660. 	mes "[Jane Doe]";
  4661. 	mes "Well, I never!";
  4662. 	specialeffect EF_HIT1,AREA,"John Doe#1";
  4663. 	close;
  4664.  
  4665. ---------------------------------------
  4666.  
  4667. *specialeffect2 <effect number>{,<send_target>{,"<Player Name>"}};
  4668.  
  4669. This command behaves identically to the 'specialeffect', but the effect will be 
  4670. centered on the invoking character's sprite.
  4671.  
  4672. <Player name> parameter will display <effect number> on another Player than the
  4673. one currently attached to the script. Like with specialeffect, when specifying
  4674. a player, <send_target> must be supplied, specifying AREA will retain the default 
  4675. behavior of the command.
  4676.  
  4677. ---------------------------------------
  4678.  
  4679. *statusup <stat>;
  4680.  
  4681. This command will bump a specified stat of the invoking character up by one 
  4682. permanently. Stats are to be given as number, but you can use these constants to 
  4683. replace them:
  4684.  
  4685. bStr -  Strength
  4686. bVit -  Vitality
  4687. bInt -  Intelligence
  4688. bAgi -  Agility
  4689. bDex -  Dexterity
  4690. bLuk -  Luck
  4691.  
  4692. ---------------------------------------
  4693.  
  4694. *statusup2 <stat>,<amount>;
  4695.  
  4696. This command will bump a specified stat of the invoking character up by the 
  4697. specified amount permanently. The amount can be negative. See 'statusup'.
  4698.  
  4699.     // This will decrease a character's Vit forever.
  4700.     statusup bVit,-1;
  4701.  
  4702. ---------------------------------------
  4703.  
  4704. *bonus <bonus type>,<val1>;
  4705. *bonus2 <bonus type>,<val1>,<val2>;
  4706. *bonus3 <bonus type>,<val1>,<val2>,<val3>;
  4707. *bonus4 <bonus type>,<val1>,<val2>,<val3>,<val4>;
  4708. *bonus5 <bonus type>,<val1>,<val2>,<val3>,<val4>,<val5>;
  4709.  
  4710. These commands are meant to be used in item scripts. They will probably work 
  4711. outside item scripts, but the bonus will not persist for long. They, as 
  4712. expected, refer only to an invoking character.
  4713.  
  4714. You can find the full list of possible bonuses and which command to use for each 
  4715. kind in 'doc/item_bonus.txt'.
  4716.  
  4717. ---------------------------------------
  4718.  
  4719. *autobonus <bonus script>,<rate>,<duration>{,<flag>,{<other script>}};
  4720. *autobonus2 <bonus script>,<rate>,<duration>{,<flag>,{<other script>}};
  4721. *autobonus3 <bonus script>,<rate>,<duration>,<skill id>,{<other script>};
  4722. *autobonus3 <bonus script>,<rate>,<duration>,"<skill name>",{<other script>};
  4723.  
  4724. These commands are meant to be used in item scripts. They will probably work 
  4725. outside item scripts, but the bonus will not persist for long. They, as 
  4726. expected, refer only to an invoking character.
  4727.  
  4728. What these commands do is 'attach' a script to the player which will get
  4729. executed on attack (or when attacked in the case of autobonus2).
  4730.  
  4731. Rate is the trigger rate of the script (1000 = 100%). 
  4732.  
  4733. Duration is the time that the bonus will last for since the script has triggered.
  4734.  
  4735. The optional argument 'flag' is used to classify the type of attack where the script
  4736. can trigger (it shares the same flags as the bAutoSpell bonus script):
  4737.  
  4738. Range criteria:
  4739. 	BF_SHORT:  Trigger on melee attack
  4740. 	BF_LONG:   Trigger on ranged attack
  4741. 	Default:   BF_SHORT+BF_LONG
  4742. Attack type criteria:
  4743. 	BF_WEAPON: Trigger on weapon skills 
  4744. 	BF_MAGIC:  Trigger on magic skills 
  4745. 	BF_MISC:   Trigger on misc skills
  4746. 	Default:   BF_WEAPON
  4747. Skill criteria:
  4748. 	BF_NORMAL: Trigger on normal attacks
  4749. 	BF_SKILL:  Trigger on skills
  4750. 	default:   If the attack type is BF_WEAPON (only) BF_NORMAL is used,
  4751. 		   otherwise BF_SKILL+BF_NORMAL is used.
  4752.  
  4753. The difference between the optional argument 'other script' and the 'bonus script' is that,
  4754. the former one triggers only when attacking(or attacked) and the latter one runs on 
  4755. status calculation as well, which makes sure, within the duration, the "bonus" that get
  4756. lost on status calculation is restored. So, 'bonus script' is technically supposed to accept
  4757. "bonus" command only. And we usually use 'other script' to show visual effects.
  4758.  
  4759. In all cases, when the script triggers, the attached player will be the one
  4760. who holds the bonus. There is currently no way of knowing within this script  
  4761. who was the other character (the attacker in autobonus2, or the target in
  4762. autobonus and autobonus3).
  4763.  
  4764. //Grants a 1% chance of starting the state "all stats +10" for 10 seconds when
  4765. //using weapon or misc attacks (both melee and ranged skills) and shows a special 
  4766. //effect when the bonus is active.
  4767. 	autobonus "{ bonus bAllStats,10; }",10,10000,BF_WEAPON|BF_MISC,"{ specialeffect2 EF_FIRESPLASHHIT; }";
  4768.  
  4769. ---------------------------------------
  4770.  
  4771. *skill <skill id>,<level>{,<flag>};
  4772. *skill "<skill name>",<level>{,<flag>};
  4773. *addtoskill <skill id>,<level>{,<flag>};
  4774. *addtoskill "<skill name>",<level>{,<flag>};
  4775.  
  4776. These commands will give the invoking character a specified skill. This is also 
  4777. used for item scripts.
  4778.  
  4779. Level is obvious. Skill id is the ID number of the skill in question as per 
  4780. 'db/skill_db.txt'. It is not known for certain whether this can be used to give 
  4781. a character a monster's skill, but you're welcome to try with the numbers given 
  4782. in 'db/mob_skill_db.txt'.
  4783.  
  4784. Flag is 0 if the skill is given permanently (will get written with the character 
  4785. data) or 1 if it is temporary (will be lost eventually, this is meant for card 
  4786. item scripts usage.).  The flag parameter is optional, and defaults to 1 in 
  4787. 'skill' and to 2 in 'addtoskill'.
  4788.  
  4789. Flag 2 means that the level parameter is to be interpreted as a stackable 
  4790. additional bonus to the skill level. If the character did not have that skill 
  4791. previously, they will now at 0+the level given.
  4792.  
  4793. // This will permanently give the character Stone Throw (TF_THROWSTONE,152), at 
  4794. // level 1.
  4795.     skill 152,1,0;
  4796.  
  4797. ---------------------------------------
  4798.  
  4799. *nude;
  4800.  
  4801. This command will unequip anything equipped on the invoking character.
  4802.  
  4803. It is not required to do this when changing jobs since 'jobchange' will unequip 
  4804. everything not equippable by the new job class anyway.
  4805.  
  4806. ---------------------------------------
  4807.  
  4808. *disguise <Monster ID>;
  4809. *undisguise;
  4810.  
  4811. This command disguises the current player with a monster sprite.
  4812. The disguise lasts until 'undisguise' is issued or the player logs out.
  4813.  
  4814. Example:
  4815.  
  4816. disguise 1002; //Yay! You're a Poring!!!
  4817. next;
  4818. undisguise; //Yay!!!! You're a human again!!
  4819.  
  4820. ---------------------------------------
  4821. \\
  4822. 4,3 Marriage-related commands
  4823. \\
  4824. ---------------------------------------
  4825. *marriage("<spouse name>");
  4826.  
  4827. This function will marry two characters, the invoking character and the one 
  4828. referred to by name given, together, setting them up as each other's marriage 
  4829. partner. No second function call has to be issued (in current SVN at least) to 
  4830. make sure the marriage works both ways. The function returns 1 upon success, or 
  4831. 0 if the marriage could not be completed, either because the other character 
  4832. wasn't found or because one of the two characters is already married.
  4833.  
  4834. This will do nothing else for the marriage except setting up the spouse ID for 
  4835. both of these characters. No rings will be given and no effects will be shown.
  4836.  
  4837. ---------------------------------------
  4838.  
  4839. *wedding;
  4840.  
  4841. This command will call up wedding effects - the music and confetti - centered on 
  4842. the invoking character. Example can be found in the wedding script.
  4843.  
  4844. ---------------------------------------
  4845.  
  4846. *divorce()
  4847.  
  4848. This function will "un-marry" the invoking character from whoever they were 
  4849. married to. Both will no longer be each other's marriage partner, (at least in 
  4850. current SVN, which prevents the cases of multi-spouse problems). It will return 
  4851. 1 upon success or 0 if the character was not married at all.
  4852.  
  4853. This function will also destroy both wedding rings and send a message to both 
  4854. players, telling them they are now divorced.
  4855.  
  4856. ---------------------------------------
  4857. //
  4858. 4,3.- End of marriage-related commands
  4859. //
  4860. ---------------------------------------
  4861.  
  4862. *pcfollow <id>,<target id>;
  4863. *pcstopfollow <id>;
  4864.  
  4865. Makes a character follow or stop following someone. This command does the same as the @follow command.
  4866. The main difference is that @follow can use character names, and this commands needs the Account ID for the target.
  4867.  
  4868. Example(s):
  4869.  
  4870. //This will make Aaron follow Bullah, when both of these characters are online.
  4871. 	PCFollow getCharID(3,"Aaron"),getCharID(3,"Bullah");
  4872.  
  4873. //Makes Aaron stop following whoever he is following.
  4874. 	PCStopFollow getCharID(3,"Aaron");
  4875.  
  4876. ---------------------------------------
  4877.  
  4878. *pcblockmove <id>,<option>;
  4879.  
  4880. Prevents the given ID from moving when the option != 0, 0 enables the ID to move again.
  4881. ID should be able to be GID of a monster/NPC or AID from a character.
  4882.  
  4883. Example(s):
  4884.  
  4885. //prevents the current char from moving away;
  4886. 	pcblockmove getcharid(3),1;
  4887.  
  4888. //enables the current char to move again.
  4889. 	pcblockmove getcharid(3),0;
  4890.  
  4891. --------------------------------------- 
  4892.  
  4893. ==================================
  4894. |5.- Mob / NPC -related commands.|
  4895. ==================================
  4896. ---------------------------------------
  4897.  
  4898. *monster     "<map name>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>"};
  4899. *areamonster "<map name>",<x1>,<y1>,<x2>,<y2>,"<name to show>",<mob id>,<amount>{,"<event label>"};
  4900.  
  4901. This command will spawn a monster on the specified coordinates on the specified 
  4902. map. If the script is invoked by a character, a special map name, "this", will 
  4903. be recognized to mean the name of the map the invoking character is located at. 
  4904. This command works fine in the item scripts.
  4905.  
  4906. The same command arguments mean the same things as described above in the 
  4907. beginning of this document when talking about permanent monster spawns. Monsters 
  4908. spawned in this manner will not respawn upon being killed.
  4909.  
  4910. Unlike the permanent monster spawns, if the mob id is -1, a random monster will 
  4911. be picked from the entire database according to the rules configured in the 
  4912. server for dead branches. This will work for all other kinds of non-permanent 
  4913. monster spawns.
  4914.  
  4915. The only very special thing about this command is an event label, which is an 
  4916. optional parameter. This label is written like '<NPC object name>::<label name>' 
  4917. and upon the monster being killed, it will execute the script inside of the 
  4918. specified NPC object starting from the label given. The RID of the player 
  4919. attached at this execution will be the RID of the killing character.
  4920.  
  4921. The Event field can be used alternatively to specify other mob properties. Use
  4922. 2 to specify that the mob should be small, 4 for big monsters, and 8 for
  4923. special ai mobs (which by default attack other monsters instead of players).
  4924. You can add these, so using 10 will spawn small monsters that attack other
  4925. mobs (if you specify both 2 and 4, the small version takes priority).
  4926.  
  4927.     monster "place",60,100,"Poring",1002,1,"NPCNAME::OnLabel";
  4928.  
  4929. The coordinates of 0,0 will spawn the monster on a random place on the map.
  4930.  
  4931. The 'areamonster' command works much like the 'monster' command and is not 
  4932. significantly different, but spawns the monsters within a square defined by 
  4933. x1/y1-x2/y2.
  4934.  
  4935. Simple monster killing script:
  4936.  
  4937.         <Normal NPC object definition. Let's assume you called him NPCNAME.>
  4938.         mes "[Summon Man]";
  4939.         mes "Want to start the kill?";
  4940.         next;
  4941.         menu "Yes",L_Yes,"No",-;
  4942.         mes "[Summon Man]";
  4943.         mes "Come back later";
  4944.         close;
  4945.     L_Yes:
  4946.         monster "prontera",0,0,"Quest Poring",1002,10,"NPCNAME::OnPoringKilled";
  4947.         // By using 0,0 it will spawn them in a random place.
  4948.         mes "[Summon Man]";
  4949.         mes "Now go and kill all the Poring I summoned";
  4950.         // He summoned ten.
  4951.         close;
  4952.     OnPoringKilled:
  4953.         set $PoringKilled,$PoringKilled+1;
  4954.         if ($PoringKilled==10) goto L_AllDead;
  4955.         end;
  4956.     L_AllDead:
  4957.         announce "Summon Man: Well done all the poring are dead",3;
  4958.         set $PoringKilled,0;
  4959.         end;
  4960.  
  4961. For more good examples see just about any official 2-1 or 2-2 job quest script.
  4962.  
  4963. ---------------------------------------
  4964.  
  4965. *areamobuseskill "<map name>",<x>,<y>,<range>,<mob id>,<skill id>,<skill level>,<cast time>,<cancelable>,<emotion>,<target type>;
  4966. *areamobuseskill "<map name>",<x>,<y>,<range>,<mob id>,"<skill name>",<skill level>,<cast time>,<cancelable>,<emotion>,<target type>;
  4967.  
  4968. This command will make all monsters of the specified mob ID in the specified 
  4969. area use the specified skill. Map name, x, and y define the center of the area, 
  4970. which extending <range> cells in each direction (ex: a range of 3 would create 
  4971. a 7x7 square). The skill can be specified by skill ID or name. <cast time> is in 
  4972. milliseconds (1000 = 1 second), and the rest should be self-explanatory. 
  4973.  
  4974. <target type> can be: 
  4975. 	0 = self
  4976. 	1 = the mob's current target
  4977. 	2 = the mob's master
  4978. 	3 = random target
  4979.  
  4980. Example:
  4981.  
  4982. 	// spawn 1 Shining Plant in the 5x5 area centered on (155,188)
  4983. 	areamonster "prontera",153,186,157,190,"Shining Plant",1083,1;
  4984. 	// make the plant cast level 10 Cold Bolt on a random target
  4985. 	areamobuseskill "prontera",155,188,2,1083,"MG_COLDBOLT",10,3000,1,e_gg,3;
  4986.  
  4987. ---------------------------------------
  4988.  
  4989. *killmonster "<map name>","<event label>"{,<type>};
  4990.  
  4991. This command will kill all monsters that were spawned with 'monster' or 
  4992. 'addmonster' and have a specified event label attached to them. Commonly used to 
  4993. get rid of remaining quest monsters once the quest is complete.
  4994.  
  4995. If the label is given as "All", all monsters which have their respawn times set 
  4996. to -1 (like all the monsters summoned with 'monster' or 'areamonster' script 
  4997. command, and all monsters summoned with GM commands, but no other ones - that 
  4998. is, all non-permanent monsters) on the specified map will be killed regardless 
  4999. of the event label value.
  5000.  
  5001. As of r12876 killmonster now supports an optional argument type. Using 1 for type
  5002. will make the command fire "OnMyMobDead" events from any monsters that do die
  5003. as a result of this command.
  5004.  
  5005. ---------------------------------------
  5006.  
  5007. *killmonsterall "<map name>"{,<type>};
  5008.  
  5009. This command will kill all monsters on a specified map name, regardless of how 
  5010. they were spawned or what they are. As of r12873, The behavior has changed slightly.
  5011. In light of a label behavior fix for mob spawning commands that will now allow the label to 
  5012. trigger when there is no player, killmonsterall has also been modified to support this.
  5013.  
  5014. Using this the normal/old way means labels don't trigger when a player didn't
  5015. attack/kill a monster. This is because it breaks compatibility with older scripts if
  5016. forced to use the new method. However, if you wish to use the new label type with this
  5017. command, simply use 1 for type. Any other number won't be recognized.
  5018.  
  5019. ---------------------------------------
  5020.  
  5021. *strmobinfo(<type>,<monster id>);
  5022.  
  5023. This function will return information about a monster record in the database, as 
  5024. per 'db/mob_db.txt'. Type is the kind of information returned. Valid types are:
  5025.  
  5026.  1 - 'english name' field in the database, a string.
  5027.  2 - 'japanese name' field in the database, a string.
  5028.      All other returned values are numbers:
  5029.  3 - Level.
  5030.  4 - Maximum HP.
  5031.  5 - Maximum SP.
  5032.  6 - Experience reward.
  5033.  7 - Job experience reward.
  5034.  
  5035. ---------------------------------------
  5036.  
  5037. *mobcount("<map name>","<event label>")
  5038.  
  5039. This function will count all the monsters on the specified map that have a given 
  5040. event label and return the number or 0 if it can't find any. Naturally, only 
  5041. monsters spawned with 'monster' and 'areamonster' script commands can have non-empty 
  5042. event label.
  5043. If you pass this function an empty string for the event label, it will return 
  5044. the total count of monster without event label, including permanently spawning monsters.
  5045. With the dynamic mobs system enabled, where mobs are not kept 
  5046. in memory for maps with no actual people playing on them, this will return a 0 
  5047. for any such map.
  5048. If the event label is given as "all", all monsters will be counted, regardless of
  5049. having any event label attached.
  5050.  
  5051. If the map name is given as "this", the map the invoking character is on will 
  5052. be used. If the map is not found, or the invoker is not a character while the map 
  5053. is "this", it will return -1.
  5054.  
  5055. ---------------------------------------
  5056.  
  5057. *clone "<map name>",<x>,<y>,"<event>",<char id>{,<master_id>{,<mode>{,<flag>,<duration>}}}
  5058.  
  5059. This command creates a monster which is a copy of another player. The first
  5060. four arguments serve the same purpose as in the monster script command, The
  5061. <char id> is the character id of the player to clone (player must be online).
  5062. If <master id> is given, the clone will be a 'slave/minion' of it. Master_id
  5063. must be a character id of another online player.
  5064.  
  5065. The mode can be specified to determine the behavior of the clone, it's
  5066. values are the same as the ones used for the mode field in the mob_db. The
  5067. default mode is aggressive, assists, can move, can attack.
  5068.  
  5069. Flag can be either zero or one currently. If zero, the clone is a normal
  5070. monster that'll target players, if one, it is considered a summoned monster,
  5071. and as such, it'll target other monsters. Defaults to zero.
  5072.  
  5073. The duration specifies how long the clone will live before it is auto-removed.
  5074. Specified in seconds, defaults to no limit (zero).
  5075.  
  5076. Returned value is the monster ID of the spawned clone. If command fails,
  5077. returned value is zero.
  5078.  
  5079. ---------------------------------------
  5080.  
  5081. *summon "Monster name",<monster id>{,<Time Out>{,"event label"}};
  5082.  
  5083. This command will summon a monster. (see also 'monster') Unlike monsters spawned
  5084. with other commands, this one will set up the monster to fight to protect the
  5085. invoking character. Monster name and mob id obey the same rules as the one given
  5086. at the beginning of this document for permanent monster spawns with the
  5087. exceptions mentioned when describing 'monster' command.
  5088.  
  5089. The effect for the skill 'Call Homonuculus' will be displayed centered on the
  5090. invoking character.
  5091.  
  5092. Timeout is the time in milliseconds the summon lives, and is set default 
  5093. to 60000 (1 minute). Note that also the value 0 will set the timer to default,
  5094. and it is not possible to create a spawn that lasts forever.
  5095. If an event label is given, upon the monster being killed, the event label will
  5096. run as if by 'donpcevent'.
  5097.  
  5098. // Will summon a dead branch-style monster to fight for the character.
  5099. summon "--ja--",-1;
  5100.  
  5101. ---------------------------------------
  5102.  
  5103. *homevolution;
  5104.  
  5105. This command will try to evolve the current player's homunculus.
  5106. If it doesn't work, the /swt emotion is shown.
  5107.  
  5108. To evolve a homunculus, the invoking player must have a homunculus,
  5109. the homunculus must not be the last evolution and
  5110. the homunculus must have above 91000 intimacy with it's owner.
  5111.  
  5112. ---------------------------------------
  5113.  
  5114. *unitwalk <GID>,<x>,<y>;
  5115. *unitwalk <GID>,<mapid>;
  5116.  
  5117. This is one command, but can be used in two ways. If only the first argument is given,
  5118. the unit whose GID is given will start walking towards the map with the given mapid 
  5119. (we believe these are the map-indexes found in db/map_index.txt).
  5120.  
  5121. When 2 arguments are passed, the given unit will walk to the given x,y coordinates on 
  5122. the map where the unit currently is.
  5123.  
  5124. Example(s):
  5125.  
  5126. //Will move/walk the poring we made to the coordinates 150,150
  5127. 	unitwalk .GID,150,150;
  5128.  
  5129. //Will move the poring towards alberta (if my assumed map-indexes are correct).
  5130. 	unitwalk .GID,3;
  5131.  
  5132. ---------------------------------------
  5133.  
  5134. *unitkill <GID>;
  5135. *unitwarp <GID>,<Mapname>,<x>,<y>;
  5136. *unitattack <GID>,<Target ID>;
  5137. *unitstop <GID>;
  5138. *unittalk <GID>,<Text>;
  5139. *unitemote <GID>,<Emote>;
  5140.  
  5141. Okay, these commands should be fairly self explaining.
  5142. For the emotions, you can look in db/const.txt for prefixes with e_
  5143. PS: unitwarp supports a <GID> of zero, which causes the executor of the script to be affected. This can be used with OnTouchNPC to warp monsters:
  5144.  
  5145. OnTouchNPC:
  5146. 	unitwarp 0,"this",-1,-1;
  5147.  
  5148. ---------------------------------------
  5149.  
  5150. *disablenpc "<NPC object name>";
  5151. *enablenpc "<NPC object name>";
  5152.  
  5153. These two commands will disable and enable, respectively, an NPC object 
  5154. specified by name. The disabled NPC will disappear from sight and will no longer 
  5155. be triggerable in the normal way. It is not clear whether it will still be 
  5156. accessible through 'donpcevent' and other triggering commands, but it probably 
  5157. will be. You can disable even warp NPCs if you know their object names, which is 
  5158. an easy way to make a map only accessible through walking half the time. Then 
  5159. you 'enablenpc' them back.
  5160.  
  5161. You can also use these commands to create the illusion of an NPC switching 
  5162. between several locations, which is often better than actually moving the NPC -
  5163. create one NPC object with a visible and a hidden part to their name, make a few 
  5164. copies, and then disable all except one.
  5165.  
  5166. ---------------------------------------
  5167.  
  5168. *hideonnpc "<NPC object name>";
  5169. *hideoffnpc "<NPC object name>";
  5170.  
  5171. These commands will make the NPC object specified display as hidden/visible, 
  5172. even though not actually disabled per se. Hidden as in thief Hide skill, but 
  5173. unfortunately, not detectable by Ruwach or Sight.
  5174.  
  5175. As they are now, these commands are pointless, it is suggested to use 
  5176. 'disablenpc'/'enablenpc', because these two commands actually unload the NPC 
  5177. sprite location and other accompanying data from memory when it is not used.
  5178. However, you can use these for some quest ideas (such as cloaking NPCs talking 
  5179. while hidden then revealing.... you can wonder around =P
  5180.  
  5181. ---------------------------------------
  5182.  
  5183. *doevent "<NPC object name>::<event label>";
  5184.  
  5185. This command will start a new execution thread in a specified NPC object at the 
  5186. specified label. The execution of the script running this command will not stop. 
  5187. No parameters may be passed with a doevent call.
  5188.  
  5189. The script of the NPC object invoked in this manner will run as if it's been 
  5190. invoked by the RID that was active in the script that issued a 'doevent'.
  5191.  
  5192.     place,100,100,1%TAB%script%TAB%NPC%TAB%53,{
  5193.         mes "This is what you will see when you click me";
  5194.         close;
  5195.     OnLabel:
  5196.         mes "This is what you will see if the doevent is activated";
  5197.         close;
  5198.     }
  5199.  
  5200.     ....
  5201.  
  5202.     doevent "NPC::OnLabel";
  5203.  
  5204. ---------------------------------------
  5205.  
  5206. *donpcevent "{NPC NAME}::<event label>";
  5207.  
  5208. This command invokes the event label code within an another NPC or NPCs. If
  5209. event label has the form "NpcName::OnLabel", then only given NPC's event label
  5210. will be invoked (much like 'goto' into another NPC). If the form is "::OnLabel"
  5211. (NpcName omitted), the event code of all NPCs with given label will be invoked,
  5212. one after another. In both cases the invoked script will run without an attached
  5213. RID, whether or not the invoking script was attached to a player. The event
  5214. label name is required to start with On.
  5215.  
  5216. This command can be used to make other NPCs act, as if they were responding to
  5217. the invoking NPC's actions, such as using an emotion or talking.
  5218.  
  5219.     place,100,100,1%TAB%script%TAB%NPC%TAB%53,{
  5220.         mes "Hey NPC2 copy what I do";
  5221.         close2;
  5222.         set .@emote, rand(1,30);
  5223.         donpcevent "NPC2::OnEmote";
  5224.     OnEmote:
  5225.         emotion .@emote;
  5226.         end;
  5227.     }
  5228.  
  5229.     place,102,100,1%TAB%script%TAB%NPC2%TAB%53,{
  5230.         mes "Hey NPC copy what I do";
  5231.         close2;
  5232.         set .@emote, rand(1,30);
  5233.         donpcevent "NPC::OnEmote";
  5234.     OnEmote:
  5235.         emotion .@emote;
  5236.         end;
  5237.     }
  5238.  
  5239. Whichever of the both NPCs is talked to, both will show a random emotion at the
  5240. same time. 
  5241.  
  5242. ---------------------------------------
  5243.  
  5244. *cmdothernpc "<npc name>","<command>";
  5245.  
  5246. This is simply "donpcevent <npc name>::OnCommand<command>".
  5247. It is an approximation of official server script language's 'cmdothernpc'.
  5248.  
  5249. ---------------------------------------
  5250.  
  5251. *npctalk "<message>";
  5252.  
  5253. This command will display a message to the surrounding area as if the NPC object 
  5254. running it was a player talking - that is, above their head and in the chat 
  5255. window. The display name of the NPC will get appended in front of the message to 
  5256. complete the effect.
  5257.  
  5258.     // This will make everyone in the area see the NPC greet the character
  5259.     // who just invoked it.
  5260.     npctalk "Hello "+strcharinfo(0)+" how are you";
  5261.  
  5262. ---------------------------------------
  5263.  
  5264. *setnpcdisplay("<npc name>", "<display name>", <class id>, <size>)
  5265. *setnpcdisplay("<npc name>", "<display name>", <class id>)
  5266. *setnpcdisplay("<npc name>", "<display name>")
  5267. *setnpcdisplay("<npc name>", <class id>)
  5268.  
  5269. Changes the display name and/or display class of the target NPC.
  5270. Returns 0 is successful, 1 if the NPC does not exist.
  5271. Size is 0 = normal 1 = small 2 = big.
  5272.  
  5273. Since trunk r11779
  5274.  
  5275. ---------------------------------------
  5276. \\
  5277. 5,1.- Time-related commands
  5278. \\
  5279. ---------------------------------------
  5280. *addtimer <ticks>,"NPC::OnLabel";
  5281. *deltimer "NPC::OnLabel";
  5282. *addtimercount <ticks>,"NPC::OnLabel";
  5283.  
  5284. These commands will create, destroy, and delay a countdown timer - 'addtimer' to
  5285. create, 'deltimer' to destroy and 'addtimercount' to delay it by the specified
  5286. number of ticks. For all three cases, the event label given is the identifier of
  5287. that timer. The timer runs on the character object that is attached to the script,
  5288. and can have multiple instances. When the label is run, it is run as if the player that
  5289. the timer runs on has clicked the NPC.
  5290.  
  5291. When this timer runs out, a new execution thread will start in the specified NPC
  5292. object at the specified label.
  5293.  
  5294. The ticks are given in 1/1000ths of a second.
  5295.  
  5296. One more thing. These timers are stored as part of player data. If the player
  5297. logs out, all of these get immediately deleted, without executing the script.
  5298. If this behavior is undesirable, use some other timer mechanism (like 'sleep').
  5299.  
  5300. Example 1:
  5301. <NPC Header> {
  5302. 	dispbottom "Starting a 5 second timer...";
  5303. 	addtimer 5000, strnpcinfo(3)+"::On5secs";
  5304. 	end;
  5305. On5secs:
  5306. 	dispbottom "5 seconds have passed!";
  5307. 	end;
  5308. }
  5309.  
  5310. ---------------------------------------
  5311.  
  5312. *initnpctimer{ "<NPC name>" {, <Attach Flag>} } |
  5313.              { "<NPC name>" | <Attach Flag> };
  5314. *stopnpctimer{ "<NPC name>" {, <Detach Flag>}  } |
  5315.              { "<NPC name>" | <Detach Flag> };
  5316. *startnpctimer{ "<NPC name>" {, <Attach Flag>} } |
  5317.               { "<NPC name>" | <Attach Flag> };
  5318. *setnpctimer <tick>{,"<NPC name>"};
  5319. *getnpctimer(<type of information>{,"<NPC name>"})
  5320. *attachnpctimer {"<character name>"};
  5321. *detachnpctimer {"<NPC name>"};
  5322.  
  5323. This set of commands and functions will create and manage an NPC-based timer.
  5324. The NPC name may be omitted, in which case the calling NPC is used as target.
  5325.  
  5326. Contrary to addtimer/deltimer commands which let you have many different timers
  5327. referencing different labels in the same NPC, each with their own countdown,
  5328. 'initnpctimer' can only have one per NPC object. But it can trigger many labels
  5329. and let you know how many were triggered already and how many still remain.
  5330.  
  5331. This timer is counting up from 0 in ticks of 1/1000ths of a second each. Upon 
  5332. creating this timer, the execution will not stop, but will happily continue 
  5333. onward. The timer will then invoke new execution threads at labels 
  5334. "OnTimer<time>:" in the NPC object it is attached to. 
  5335.  
  5336. To create the timer, use the 'initnpctimer', which will start it running. 
  5337. 'stopnpctimer' will pause the timer, without clearing the current tick, while 
  5338. 'startnpctimer' will let the paused timer continue.
  5339.  
  5340. By default timers do not have a RID attached, which lets them continue even
  5341. if the player that started them logs off. To attach a RID to a timer, you can
  5342. either use the optional "attach flag" when using 'initnpctimer/startnpctimer', 
  5343. or do it manually by using 'attachnpctimer'. Likewise, the optional flag of
  5344. stopnpctimer lets you detach any RID after stopping the timer, and by using
  5345. 'detachnpctimer' you can detach a RID at any time.
  5346.  
  5347. Normally there is only a single timer per NPC, but as an exception, as long as
  5348. you attach a player to the timer, you can have multiple timers running at once,
  5349. because these will get stored on the players instead of the NPC.
  5350. NOTE: You need to attach the RID before the timer _before_ you start it to
  5351. get a player-attached timer. Otherwise it'll stay a NPC timer (no effect).
  5352.  
  5353. If the player that is attached to the npctimer logs out, the "OnTimerQuit:"
  5354. event label of that NPC will be triggered, so you can do the appropriate
  5355. cleanup (the player is still attached when this event is triggered).
  5356.  
  5357. The 'setnpctimer' command will explicitly set the timer to a given tick.
  5358. 'getnpctimer' provides timer information. Its parameter defines what type:
  5359.  
  5360.  0 - Will return the current tick count of the timer.
  5361.  1 - Will return 1 if there are remaining "OnTimer<ticks>:" labels in the 
  5362.      specified NPC waiting for execution.
  5363.  2 - Will return the number of times the timer has triggered and will trigger
  5364.      an "OnTimer<tick>:"  label in the specified NPC.
  5365.  
  5366. Example 1:
  5367.  
  5368.     <NPC Header> {
  5369.         // We need to use attachnpctimer because the mes command below needs RID attach
  5370.         attachnpctimer;
  5371.         initnpctimer;
  5372.         npctalk "I cant talk right now, give me 10 seconds";
  5373.         end;
  5374.     OnTimer5000:
  5375.         npctalk "Ok 5 seconds more";
  5376.         end;
  5377.     OnTimer6000:
  5378.         npctalk "4";
  5379.         end;
  5380.     OnTimer7000:
  5381.         npctalk "3";
  5382.         end;
  5383.     OnTimer8000:
  5384.         npctalk "2";
  5385.         end;
  5386.     OnTimer9000:
  5387.         npctalk "1";
  5388.         end;
  5389.     OnTimer10000:
  5390.         stopnpctimer;
  5391.         mes "[Man]";
  5392.         mes "Ok we can talk now";
  5393.         detachnpctimer;
  5394.         // and remember attachnpctimer and detachnpctimer can only use while the NPC timer is not running !
  5395.     }
  5396.  
  5397. Example 2:
  5398.  
  5399.     OnTimer15000:
  5400. 				npctalk "Another 15 seconds have passed.";
  5401.         initnpctimer; // You have to use 'initnpctimer' instead of 'setnpctimer 0'.
  5402.         							// This is equal to 'setnpctimer 0' + 'startnpctimer'.
  5403.         							// Alternatively, you can also insert another 'OnTimer15001' label so that the timer won't stop.
  5404.         end;
  5405.  
  5406.     // This OnInit label will run when the script is loaded, so that the timer 
  5407.     // is initialized immediately as the server starts. It is dropped back to 0 
  5408.     // every time the NPC says something, so it will cycle continuously.
  5409.     OnInit:
  5410.         initnpctimer;
  5411.         end;
  5412.  
  5413. Example 3:
  5414.  
  5415.     mes "[Man]";
  5416.     mes "I have been waiting "+(getnpctimer(0)/1000)+" seconds for you";
  5417.     // we divide the timer returned by 1000 cause it will be displayed in 
  5418.     // milliseconds otherwise
  5419.     close;
  5420.  
  5421. Example 4:
  5422.  
  5423.     mes "[Man]";
  5424.     mes "Ok I will let you have 30 sec more";
  5425.     close2;
  5426.     setnpctimer (getnpctimer(0)-30000);
  5427.     // Notice the 'close2'. If there were a 'next' there the timer would be 
  5428.     // changed only after the player pressed the 'next' button.
  5429.     end;
  5430.  
  5431. ---------------------------------------
  5432.  
  5433. *sleep {<milliseconds>};
  5434. *sleep2 {<milliseconds>};
  5435. *awake "<NPC name>";
  5436.  
  5437. These commands are used to control the pause of a NPC.
  5438. sleep and sleep2 will pause the script for the given amount of milliseconds.
  5439. Awake is used to cancel a sleep. When awake is called on a NPC it will run as
  5440. if the sleep timer ran out, and thus making the script continue. Sleep and sleep2
  5441. basically do the same, but the main difference is that sleep will not keep the rid,
  5442. while sleep2 does.
  5443.  
  5444. Examples:
  5445. 	sleep 10000; //pause the script for 10 seconds and ditch the RID (so no player is attached anymore)
  5446. 	sleep2 5000; //pause the script for 5 seconds, and continue with the RID attached.
  5447. 	awake "NPC"; //Cancels any running sleep timers on the NPC 'NPC'.
  5448.  
  5449. ---------------------------------------
  5450.  
  5451. *progressbar "<color>",<seconds>;
  5452.  
  5453. This command works almost like sleep2, but displays a progress bar
  5454. above the head of the currently attached character (like cast bar).
  5455. Once the given amount of seconds passes, the script resumes. If the
  5456. character moves while the progress bar progresses, it is aborted and
  5457. the script ends. The color format is in RGB (0xRRGGBB). The color is
  5458. currently ignored by the client and appears always green.
  5459.  
  5460. ---------------------------------------
  5461. //
  5462. 5,1.- End of time-related commands
  5463. //
  5464.  
  5465. *announce "<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
  5466.  
  5467. This command will broadcast a message to all or most players, similar to 
  5468. @kami/@kamib GM commands.
  5469.  
  5470.     announce "This will be shown to everyone at all in yellow.",0;
  5471.  
  5472. The region the broadcast is heard in (target), source of the broadcast
  5473. and the color the message will come up as is determined by the flags.
  5474.  
  5475. The flag values are coded as constants in db/const.txt to make them easier to use.
  5476.  
  5477. Target flags:
  5478. - bc_all: Broadcast message is sent server-wide (default).
  5479. - bc_map: Message is sent to everyone in the same map as the source of the broadcast (see below).
  5480. - bc_area: Message is sent to players in the vicinity of the source.
  5481. - bc_self: Message is sent only to current player.
  5482. You cannot use more than one target flag.
  5483.  
  5484. Source flags:
  5485. - bc_pc: Broadcast source is the attached player (default).
  5486. - bc_npc: Broadcast source is the NPC, not the player attached to the script
  5487.   (useful when a player is not attached or the message should be sent to those
  5488.   nearby the NPC).
  5489. You cannot use more than one source flag.
  5490.  
  5491. Special flags:
  5492. - bc_yellow: Broadcast will be displayed in yellow color (default).
  5493. - bc_blue: Broadcast will be displayed in blue color.
  5494. - bc_woe: Indicates that this broadcast is 'WoE Information' that can be disabled client-side.
  5495. Due to the way client handles broadcasts, it is impossible to set both bc_blue and bc_woe.
  5496.  
  5497. The optional parameters allow usage of broadcasts in custom colors, font-weights, sizes etc.
  5498. If any of the optional parameters is used, special flag is ignored.
  5499. Optional parameters may not work well (or at all) depending on a game client used.
  5500.  
  5501. The color parameter is a single number which can be in hexadecimal notation.
  5502. For example:
  5503.     announce "This will be shown to everyone at all in green.",bc_all,0x00FF00;
  5504. Will display a global announce in green. The color format is in RGB (0xRRGGBB).
  5505.  
  5506. In official scripts only two font-weights (types) are used:
  5507.  - normal (FW_NORMAL = 400, default),
  5508.  - bold (FW_BOLD = 700).
  5509.  
  5510. Default font size is 12.
  5511.  
  5512. Using this for private messages to players is probably not that good an idea,
  5513. but it can be used instead in NPCs to "preview" an announce.
  5514.  
  5515.     // This will be a private message to the player using the NPC that made the 
  5516.     // announcement
  5517.     announce "This is my message just for you",bc_blue|bc_self;
  5518.  
  5519.     // This will be shown on everyones screen that is in sight of the NPC.
  5520.     announce "This is my message just for you people here",bc_npc|bc_area;
  5521.  
  5522. ---------------------------------------
  5523.  
  5524. *mapannounce "<map name>","<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}}};
  5525.  
  5526. This command will work like 'announce' but will only broadcast to characters 
  5527. currently residing on the specified map. The flag and optional parameters
  5528. parameters are the same as in 'announce', but target and source flags are ignored.
  5529.  
  5530. ---------------------------------------
  5531.  
  5532. *areaannounce "<map name>",<x1>,<y1>,<x2>,<y2>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}}};
  5533.  
  5534. This command works like 'announce' but will only broadcast to characters 
  5535. residing in the specified x1/y1-x2/y2 rectangle on the map given. The flags and
  5536. optional parameters are the same as in 'announce', but target and source flags are ignored.
  5537.  
  5538.     areaannounce "prt_church",0,0,350,350,"God's in his heaven, all right with the world",0;
  5539.  
  5540. ---------------------------------------
  5541.  
  5542. *callshop "<name>",<option>;
  5543.  
  5544. These are a series of commands used to create dynamic shops. 
  5545. The callshop function calls a invisible shop (view -1) as if the player clicked on it.
  5546.  
  5547. For the options on callShop:
  5548. 	0 = The normal window (buy, sell and cancel)
  5549. 	1 = The buy window
  5550. 	2 = The sell window
  5551.  
  5552. Example(s):
  5553.  
  5554. callshop "DaShop",1;	//Will call the shop named DaShop and opens the buy menu.
  5555.  
  5556. The shop which is called by callshop (as long as an npcshop* command is executed
  5557. from that NPC (see note 1)) will trigger the labels OnBuyItem and OnSellitem. These
  5558. labels can take over handling for relatively the buying of items from the shop 
  5559. and selling the items to a shop. Via these labels you can customize the way an item
  5560. is bought or sold by a player. 
  5561.  
  5562. In the OnBuyItem, two arrays are set (@bought_nameid and @bought_quantity), which
  5563. hold information about the name id (item id) sold and the amount sold of it. Same 
  5564. goes for the OnSellItem label, only the variables are named different 
  5565. (@sold_nameid, @sold_quantity, @sold_refine, @sold_attribute, @sold_identify,
  5566. @sold_card1, @sold_card2, @sold_card3, @sold_card4). An example on a shop comes
  5567. with rAthena, and can be found in the doc/sample/npc_dynamic_shop.txt file.
  5568.  
  5569. This example shows how to use the labels and their set variables to create a dynamic shop.
  5570.  
  5571. Note 1: These labels will only be triggered if a npcshop* command is executed, this is
  5572. because these commands set a special data on the shop NPC,named master_nd in the source. 
  5573. The OnSellItem and OnBuyItem are triggered in the NPC whose master_nd is given in the shop.
  5574. This was found out thanks to 'Hondacrx', noticing the OnBuyItem wasn't triggered unless
  5575. npcshopitem was used. After rechecking the source, I found what caused this.
  5576.  
  5577. ---------------------------------------
  5578.  
  5579. *npcshopitem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}}
  5580.  
  5581. This command lets you override the contents of an existing NPC shop or cashshop. The
  5582. current sell list will be wiped, and only the items specified with the price
  5583. specified will be for sale.
  5584.  
  5585. The function returns 1 if shop was updated successfully, or 0 if not found.
  5586.  
  5587. Note that you cannot use -1 to specify default selling price!
  5588.  
  5589. ---------------------------------------
  5590.  
  5591. *npcshopadditem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}}
  5592.  
  5593. This command will add more items at the end of the selling list for the
  5594. specified NPC shop or cashshop. If you specify an item already for sell, that item will
  5595. appear twice on the sell list.
  5596.  
  5597. The function returns 1 if shop was updated successfully, or 0 if not found.
  5598.  
  5599. Note that you cannot use -1 to specify default selling price!
  5600.  
  5601. ---------------------------------------
  5602.  
  5603. *npcshopdelitem "<name>",<item id>{,<item id>{,<item id>{,...}}}
  5604.  
  5605. This command will remove items from the specified NPC shop or cashshop.
  5606. If the item to remove exists more than once on the shop, all instances will be
  5607. removed.
  5608.  
  5609. Note that the function returns 1 even if no items were removed. The return
  5610. value is only to confirm that the shop was indeed found.
  5611.  
  5612. ---------------------------------------
  5613.  
  5614. *npcshopattach "<name>"{,<flag>}
  5615.  
  5616. This command will attach the current script to the given NPC shop.
  5617. When a script is attached to a shop, the events "OnBuyItem" and "OnSellItem"
  5618. of your script will be executed whenever a player buys/sells from the shop.
  5619. Additionally, the arrays @bought_nameid[], @bought_quantity[] or @sold_nameid[]
  5620. and @sold_quantity[] will be filled up with the items and quantities
  5621. bought/sold.
  5622.  
  5623. The optional parameter specifies whether to attach ("1") or detach ("0") from
  5624. the shop (the default is to attach). Note that detaching will detach any NPC
  5625. attached to the shop, even if it's from another script, while attaching will
  5626. override any other script that may be already attached.
  5627.  
  5628. The function returns 0 if the shop was not found, 1 otherwise.
  5629.  
  5630. ---------------------------------------
  5631.  
  5632. *waitingroom "<chatroom name>",<limit>{,<event label>,<trigger>,<required zeny>,<min lvl>,<max lvl>};
  5633.  
  5634. This command will create a chat room, owned by the NPC object running this 
  5635. script and displayed above the NPC sprite.
  5636. The maximum length of a chat room name is 60 letters.
  5637.  
  5638. The limit is the maximum number of people allowed to enter the chat room. If the 
  5639. optional event and trigger parameters are given, the event label 
  5640. ("<NPC object name>::<label name>") will be invoked as if with a 'doevent' upon 
  5641. the number of people in the chat room reaching the given triggering amount.
  5642.  
  5643. // The NPC will just show a box above its head that says "Hello World", clicking 
  5644. // it will do nothing, since the limit is zero.
  5645.     waitingroom "Hello World",0;
  5646.  
  5647. // The NPC will have a box above its head, it will say "Disco - Waiting Room" 
  5648. // and will have 8 waiting slots. Clicking this will enter the chat room, where 
  5649. // the player will be able to wait until 8 people accumulate. Once this happens, 
  5650. // it will cause the NPC "Bouncer" run the label "OnStart"
  5651.  
  5652.     waitingroom "Disco - Waiting Room",8,"Bouncer::OnStart",8;
  5653.  
  5654. // The NPC will have a box above its head, it will say "Party - Waiting Room" 
  5655. // and will have 8 waiting slots. Clicking this will allow a player who has
  5656. // 5000 zeny and lvl 50~99 to enter the chat room, where the player will be
  5657. // able to wait until 8 people accumulate. Once this happens, it will cause
  5658. // the NPC "Bouncer" run the label "OnStart"
  5659.  
  5660.     waitingroom "Party - Waiting Room",5,"Bouncer::OnStart",8,5000,50,99;
  5661.  
  5662. Creating a waiting room does not stop the execution of the script and it will 
  5663. continue to the next line.
  5664.  
  5665. For more examples see the 2-1 and 2-2 job quest scripts which make extensive use 
  5666. of waiting rooms.
  5667.  
  5668. ---------------------------------------
  5669.  
  5670. *delwaitingroom {"<NPC object name"};
  5671.  
  5672. This command will delete a waiting room. If no parameter is given, it will 
  5673. delete a waiting room attached to the NPC object running this command, if it is, 
  5674. it will delete a waiting room owned by another NPC object. This is the only way 
  5675. to get rid of a waiting room, nothing else will cause it to disappear.
  5676.  
  5677. It's not clear what happens to a waiting room if the NPC is disabled with 
  5678. 'disablenpc', by the way.
  5679.  
  5680. ---------------------------------------
  5681.  
  5682. *enablewaitingroomevent {"<NPC object name>"};
  5683. *disablewaitingroomevent {"<NPC object name>"};
  5684. *enablearena;
  5685. *disablearena;
  5686.  
  5687. This will enable and disable triggering the waiting room event (see 
  5688. 'waitingroom') respectively. Optionally giving an NPC object name will do that 
  5689. for a specified NPC object. The chat room will not disappear when triggering is 
  5690. disabled and enabled in this manner and players will not be kicked out of it.
  5691. Enabling a chat room event will also cause it to immediately check whether the 
  5692. number of users in it exceeded the trigger amount and trigger the event 
  5693. accordingly.
  5694.  
  5695. Normally, whenever a waiting room was created to make sure that only one 
  5696. character is, for example, trying to pass a job quest trial, and no other 
  5697. characters are present in the room to mess up the script.
  5698.  
  5699. The 'enablearena'/'disablearena' commands are just aliases with no parameter.
  5700. These are supposedly left here for compatibility with official server scripts,
  5701. but no rAthena script uses these at the moment.
  5702.  
  5703. ---------------------------------------
  5704.  
  5705. *getwaitingroomstate(<information type>{,"<NPC object name>"})
  5706.  
  5707. This function will return information about the waiting room state for the 
  5708. attached waiting room or for a waiting room attached to the specified NPC if 
  5709. any.
  5710.  
  5711. The valid information types are:
  5712.  
  5713.  0  - Number of users currently chatting.
  5714.  1  - Maximum number of users allowed.
  5715.  2  - Will return 1 if the waiting room has a trigger set.
  5716.       0 otherwise.
  5717.  3  - Will return 1 if the waiting room is currently disabled.
  5718.       0 otherwise.
  5719.  4  - The Title of the waiting room (string)
  5720.  5  - Password of the waiting room, if any. Pointless, since there is no way to 
  5721.       set a password on a waiting room right now.
  5722.  16 - Event name of the waiting room (string)
  5723.  32 - Whether or not the waiting room is full.
  5724.  33 - Whether the amount of users in the waiting room is higher than the trigger 
  5725.       number.
  5726.  
  5727. ---------------------------------------
  5728.  
  5729. *warpwaitingpc "<map name>",<x>,<y>{,<number of people>};
  5730.  
  5731. This command will warp the amount of characters equal to the trigger number of 
  5732. the waiting room chat attached to the NPC object running this command to the 
  5733. specified map and coordinates, kicking them out of the chat. Those waiting the 
  5734. longest will get warped first. It can also do a random warp on the same map 
  5735. ("Random" instead of map name) and warp to the save point ("SavePoint").
  5736.  
  5737. The list of characters to warp is taken from the list of the chat room members. 
  5738. Those not in the chat room will not be considered even if they are talking to 
  5739. the NPC in question. If the number of people is given, exactly this much people 
  5740. will be warped.
  5741.  
  5742. This command can also keep track of who just got warped. It does this by setting 
  5743. special variables:
  5744.  
  5745. $@warpwaitingpc[] is an array containing the account_id numbers of the 
  5746.                   characters who were just warped.
  5747. $@warpwaitingpcnum contains the number of the character it just warped.
  5748.  
  5749. See also 'getpartymember' for advice on what to do with those variables.
  5750.  
  5751. The obvious way of using this effectively would be to set up a waiting room for 
  5752. two characters to be warped onto a random PVP map for a one-on-one duel, for 
  5753. example.
  5754.  
  5755. ---------------------------------------
  5756.  
  5757. *kickwaitingroomall {"<NPC object name>"};
  5758.  
  5759. This command kicks everybody out of a specified waiting room chat.
  5760.  
  5761. ---------------------------------------
  5762.  
  5763. *setmapflagnosave "<map name>","<alternate map name>",<x>,<y>;
  5764.  
  5765. This command sets the 'nosave' flag for the specified map and also gives an 
  5766. alternate respawn-upon-relogin point.
  5767.  
  5768. It does not make a map impossible to make a save point on as you would normally 
  5769. think, 'savepoint' will still work. It will, however, make the specified map 
  5770. kick the reconnecting players off to the alternate map given to the coordinates 
  5771.  specified.
  5772.  
  5773. ---------------------------------------
  5774.  
  5775. *setmapflag "<map name>",<flag>{,<zone>};
  5776.  
  5777. This command marks a specified map with a map flag given. Map flags alter the 
  5778. behavior of the map, you can see the list of the available ones in 
  5779. 'db/const.txt' under 'mf_'.
  5780.  
  5781. The map flags alter the behavior of the map regarding teleporting (mf_nomemo, 
  5782. mf_noteleport, mf_nowarp, mf_nogo), storing location when disconnected 
  5783. (mf_nosave), dead branch usage (mf_nobranch), penalties upon death 
  5784. (mf_nopenalty, mf_nozenypenalty), PVP behavior (mf_pvp, mf_pvp_noparty, 
  5785. mf_pvp_noguild), WoE behavior (mf_gvg,mf_gvg_noparty), ability to use 
  5786. skills or open up trade deals (mf_notrade, mf_novending, mf_noskill, mf_noicewall),
  5787. current weather effects (mf_snow, mf_fog, mf_sakura, mf_leaves, mf_rain, mf_clouds, 
  5788. mf_fireworks) and whether night will be in effect on this map (mf_nightenabled).
  5789.  
  5790. The zone optional parameter is used to set the zone for restricted mapflags.
  5791.  
  5792. ---------------------------------------
  5793.  
  5794. *removemapflag "<map name>",<flag>{,<zone>};
  5795.  
  5796. This command removes a mapflag from a specified map. 
  5797. See 'setmapflag' for a list of mapflags.
  5798.  
  5799. The zone optional parameter is used to remove the zone from restricted mapflags.
  5800.  
  5801. ---------------------------------------
  5802.  
  5803. *getmapflag("<map name>",<flag>)
  5804.  
  5805. This command checks the status of a given mapflag and returns the mapflag's state. 
  5806. 0 means OFF, and 1 means ON. See 'setmapflag' for a list of mapflags.
  5807.  
  5808. ---------------------------------------
  5809.  
  5810. *setbattleflag "<battle flag>",<value>;
  5811. *getbattleflag("<battle flag>")
  5812.  
  5813. Sets or gets the value of the given battle flag.
  5814. Battle flags are the flags found in the battle/*.conf files and is also used in Lupus' variable rates script.
  5815.  
  5816. Example(s):
  5817.  
  5818. //will set the base experience rate to 20x (2000%)
  5819. 	setBattleFlag "base_exp_rate",2000;
  5820.  
  5821. //will return the value of the base experience rate (when used after the above example, it would print 2000).
  5822. 	mes getBattleFlag("base_exp_rate");
  5823.  
  5824. ---------------------------------------
  5825.  
  5826. *warpportal <x>,<y>,"<mapname>",<x>,<y>;
  5827.  
  5828. Creates a warp Portal as if a acolyte class character did it.
  5829. The first x and y is the place of the warp portal on the map where the NPC is on
  5830. The mapname and second x and y is the target area of the warp portal.
  5831.  
  5832. Example(s):
  5833.  
  5834. //Will create a warp portal on the NPC's map at 150,150 leading to prontera, coords 150,180.
  5835. 	warpPortal 150,150,"prontera",150,180;
  5836.  
  5837. ---------------------------------------
  5838.  
  5839. *mapwarp "<from map>","<to map>",<x>,<y>;
  5840.  
  5841. This command will collect all characters located on the From map and warp them 
  5842. wholesale to the same point on the To map, or randomly distribute them there if 
  5843. the coordinates are zero. "Random" is understood as a special To map name and 
  5844. will mean randomly shuffling everyone on the same map.
  5845.  
  5846. ---------------------------------------
  5847. \\
  5848. 5,2.- Guild-related Commands
  5849. \\
  5850. ---------------------------------------
  5851.  
  5852. *maprespawnguildid "<map name>",<guild id>,<flag>;
  5853.  
  5854. This command goes through the specified map and for each player and monster 
  5855. found there does stuff.
  5856.  
  5857. Flag is a bit-mask (add up numbers to get effects you want)
  5858.  1 - warp all guild members to their save points.
  5859.  2 - warp all non-guild members to their save points.
  5860.  4 - remove all monsters which are not guardian or Emperium.
  5861.  
  5862. Flag 7 will, therefore, mean 'wipe all mobs but guardians and the Emperium and 
  5863. kick all characters out', which is what the official scripts do upon castle 
  5864. surrender. Upon start of WoE, the scripts do 2 (warp all intruders out).
  5865.  
  5866. Characters not belonging to any guild will warp out regardless of the flag setting.
  5867.  
  5868. For examples, check the WoE scripts in the distribution.
  5869.  
  5870. ---------------------------------------
  5871.  
  5872. *agitstart;
  5873. *agitend;
  5874. *agitstart2;
  5875. *agitend2;
  5876.  
  5877. These four commands will start and end War of Emperium or War of Emperium SE.
  5878.  
  5879. This is a bit more complex than it sounds, since the commands themselves won't 
  5880. actually do anything interesting, except causing all 'OnAgitStart:' and 
  5881. 'OnAgitEnd:', or 'OnAgitStart2:' and 'OnAgitEnd2:' in the case of latter two
  5882. commands, events to run everywhere, respectively. They are used as  simple 
  5883. triggers to run a lot of complex scripts all across the server, and they, 
  5884. in turn, are triggered by clock with an 'OnClock<time>:' time-triggering label.
  5885.  
  5886. ---------------------------------------
  5887.  
  5888. *gvgon "<map name>";
  5889. *gvgoff "<map name>";
  5890.  
  5891. These commands will turn GVG mode for the specified maps on and off, setting up 
  5892. appropriate map flags. In GVG mode, maps behave as if during the time of WoE, 
  5893. even though WoE itself may or may not actually be in effect. 
  5894.  
  5895. ---------------------------------------
  5896.  
  5897. *flagemblem <guild id>;
  5898.  
  5899. This command only works when run by the NPC objects which have sprite id 722, 
  5900. which is a 3D guild flag sprite. If it isn't, the data will change, but nothing 
  5901. will be seen by anyone. If it is invoked in that manner, the emblem of the 
  5902. specified guild will appear on the flag, though, if any players are watching it 
  5903. at this moment, they will not see the emblem change until they move out of sight 
  5904. of the flag and return.
  5905.  
  5906. This is commonly used in official guildwar scripts with a function call which 
  5907. returns a guild id:
  5908.  
  5909. // This will change the emblem on the flag to that of the guild that owns
  5910. // "guildcastle"
  5911.  
  5912.     flagemblem GetCastleData("guildcastle",1);
  5913.  
  5914. ---------------------------------------
  5915.  
  5916. *guardian "<map name>",<x>,<y>,"<name to show>",<mob id>{,"<event label>"{,<guardian index>}};
  5917.  
  5918. This command is roughly equivalent to 'monster', but is meant to be used with 
  5919. castle guardian monsters and will only work with them. It will set the guardian 
  5920. characteristics up according to the castle's investment values and otherwise 
  5921. set the things up that only castle guardians need.
  5922.  
  5923. Since trunk r12524:
  5924. Returns the id of the mob or 0 if an error occurred.
  5925. When 'guardian index' isn't supplied it produces a temporary guardian.
  5926. Temporary guardians are not saved with the castle and can't be accessed by guardianinfo.
  5927.  
  5928. ---------------------------------------
  5929.  
  5930. *guardianinfo("<map name>", <guardian number>, <type>);
  5931.  
  5932. This function will return various info about the specified guardian, or -1
  5933. if it fails for some reason. It is primarily used in the castle manager NPC.
  5934.  
  5935. Map name and guardian number (value between 0 and 7) define the target.
  5936. Type indicates what information to return:
  5937.  0 - visibility (whether the guardian is installed or not)
  5938.  1 - max. hp
  5939.  2 - current hp
  5940.  
  5941. ---------------------------------------
  5942. //
  5943. 5,2.- End of guild-related commands
  5944. //
  5945. ---------------------------------------
  5946.  
  5947. *npcspeed <speed value>;
  5948. *npcwalkto <x>,<y>;
  5949. *npcstop;
  5950.  
  5951. These commands will make the NPC object in question move around the map. As they 
  5952. currently are, they are a bit buggy and are not useful for much more than making 
  5953. an NPC move randomly around the map. (see 'npc/custom/devnpc.txt' for an example 
  5954. of such usage)
  5955.  
  5956. 'npcspeed' will set the NPCs walking speed to a specified value. As in the 
  5957. @speed GM command, 200 is the slowest possible speed while 0 is the fastest 
  5958. possible (instant motion). 100 is the default character walking speed.
  5959. 'npcwalkto' will start the NPC sprite moving towards the specified coordinates 
  5960. on the same map as it is currently on.
  5961. 'npcstop' will stop the motion.
  5962.  
  5963. While in transit, the NPC will be clickable, but invoking it will cause it to 
  5964. stop motion, which will make it's coordinates different from what the client 
  5965. computed based on the speed and motion coordinates. The effect is rather 
  5966. unnerving.
  5967.  
  5968. Only a few NPC sprites have walking animations, and those that do, do not get 
  5969. the animation invoked when moving the NPC, due to the problem in the NPC walking 
  5970. code, which looks a bit silly. You might have better success by defining a job-
  5971. sprite based sprite id in 'db/mob-avail.txt' with this.
  5972.  
  5973. ---------------------------------------
  5974.  
  5975. *movenpc "<NPC name>",<x>,<y>{,<dir>};
  5976.  
  5977. This command looks like the NPCWalkToxy function,but is a little different.
  5978.  
  5979. While NPCWalkToXY just makes the NPC 'walk' to the coordinates given (which 
  5980. sometimes gives problems if the path isn't a straight line without objects), 
  5981. this command just moves the NPC. It basically warps out and in on the current 
  5982. and given spot. Direction can be used to change the NPC's facing direction.
  5983.  
  5984. Example(s):
  5985.  
  5986. // This will move Bugga from it's current position to the coordinates 100,20 
  5987. // (if those coordinates are walkable (legit)).
  5988. 	moveNPC "Bugga",100,20;
  5989.  
  5990. ---------------------------------------
  5991.  
  5992. =====================
  5993. |6.- Other commands.|
  5994. =====================
  5995. ---------------------------------------
  5996.  
  5997. *debugmes "<message>";
  5998.  
  5999. This command will send the message to the server console (map-server window). It 
  6000. will not be displayed anywhere else.
  6001.  
  6002.     debugmes strcharinfo(0)+" has just done this that and the other";
  6003.     // You would see in the map-server window "NAME has just done this that and 
  6004.     // the other"
  6005.  
  6006. ---------------------------------------
  6007.  
  6008. *logmes "<message>";
  6009.  
  6010. This command will write the message given to the map server NPC log file, as 
  6011. specified in 'conf/log_athena.conf'. In the TXT version of the server, the log 
  6012. file is 'log/npclog.log' by default. In the SQL version, if SQL logging is 
  6013. enabled, the message will go to the 'npclog' table, otherwise, it will go to the 
  6014. same log file.
  6015.  
  6016. If logs are not enabled, nothing will happen.
  6017.  
  6018. ---------------------------------------
  6019.  
  6020. *globalmes "<message>"{,"<NPC name>"};
  6021.  
  6022. This command will send a message to the chat window of all currently connected 
  6023. characters.
  6024.  
  6025. If NPC name is specified, the message will be sent as if the sender would be
  6026. the NPC with the said name.
  6027.  
  6028. ---------------------------------------
  6029.  
  6030. *rand(<number>{,<number>});
  6031.  
  6032. This function returns a number ...
  6033. (if you specify one) ... randomly positioned between 0 and the number you specify -1.
  6034. (if you specify two) ... randomly positioned between the two numbers you specify.
  6035.  
  6036. rand(10)  would result in 0,1,2,3,4,5,6,7,8 or 9
  6037. rand(0,9) would result in 0,1,2,3,4,5,6,7,8 or 9
  6038.  
  6039. rand(2,5) would result in 2,3,4 or 5
  6040.  
  6041. ---------------------------------------
  6042.  
  6043. *viewpoint <action>,<x>,<y>,<point number>,<color>;
  6044.  
  6045. This command will mark places on the mini map in the client connected to the 
  6046. invoking character. It uses the normal X and Y coordinates from the main map. 
  6047. The colors of the marks are defined using a hexadecimal number, same as the ones 
  6048. used to color text in 'mes' output, but are written as hexadecimal numbers in C. 
  6049. (They look like 0x<six numbers>.)
  6050.  
  6051. Action is what you want to do with a point, 1 will set it, while 2 will clear 
  6052. it. 0 will also set it, but automatically removes the point after 15 seconds.
  6053. Point number is the number of the point - you can have several. If more than 
  6054. one point is drawn at the same coordinates, they will cycle, which can be used 
  6055. to create flashing marks.
  6056.  
  6057.     // This command will show a mark at coordinates X 30 Y 40, is mark number 1, 
  6058.     // and will be red.
  6059.  
  6060.     viewpoint 1,30,40,1,0xFF0000;
  6061.  
  6062. This will create three points:
  6063.  
  6064.     viewpoint 1,30,40,1,0xFF0000;
  6065.     viewpoint 1,35,45,2,0xFF0000;
  6066.     viewpoint 1,40,50,3,0xFF0000;
  6067.  
  6068. And this is how you remove them:
  6069.  
  6070.     viewpoint 2,30,40,1,0xFF0000;
  6071.     viewpoint 2,35,45,2,0xFF0000;
  6072.     viewpoint 2,40,50,3,0xFF0000;
  6073.  
  6074. The client determines what it does with the points entirely, the server keeps no 
  6075. memory of where the points are set whatsoever.
  6076.  
  6077. ---------------------------------------
  6078.  
  6079. *cutin "<filename>",<position>;
  6080.  
  6081. This command will display a picture, usually an NPC illustration, also called
  6082. cutin, for the currently attached client. The position parameter determines the
  6083. placement of the illustration and takes following values:
  6084.  
  6085.     0 - bottom left corner 
  6086.     1 - bottom middle 
  6087.     2 - bottom right corner 
  6088.     3 - middle of screen in a movable window with an empty title bar 
  6089.     4 - middle of screen without the window header, but still movable 
  6090.  
  6091.  
  6092. The picture is read from data\texture\???????\illust, from both the GRF archive
  6093. and data folder, and is required to be a bitmap. The file extension .bmp can be
  6094. omitted. Magenta color (#ff00ff) is considered transparent. There is no limit
  6095. placed on the size of the illustrations by the client, although loading of large
  6096. pictures (about 700x700 and larger) causes the client to freeze shortly (lag).
  6097. Typically the size is about 320x480. New illustrations can be added by just
  6098. putting the new file into the location above.
  6099.  
  6100. The client is able to display only one cutin at the same time and each new one
  6101. will cause the old one to disappear. To delete the currently displayed
  6102. illustration without displaying a new one, an empty file name and position 255
  6103. must be used.
  6104.  
  6105.     // Displays the Comodo Kafra illustration in lower right corner.
  6106.     cutin "kafra_07",2;
  6107.  
  6108.     // Typical way to end a script, which displayed an illustration during a
  6109.     // dialog with a player.
  6110.     mes "See you.";
  6111.     close2;
  6112.     cutin "",255;
  6113.     end;
  6114.  
  6115. ---------------------------------------
  6116.  
  6117. *pet <pet id>;
  6118.  
  6119. This command is used in all the item scripts for taming items. Running this 
  6120. command will make the pet catching cursor appear on the client connected to the 
  6121. invoking character, usable on the monsters with the specified pet ID number. It 
  6122. will still work outside an item script.
  6123.  
  6124. A full list of pet IDs can be found inside 'db/pet_db.txt'
  6125.  
  6126. ---------------------------------------
  6127.  
  6128. *emotion <emotion number>{,<target>{,"<target name>"}};
  6129.  
  6130. This command makes an object display an emotion sprite above their own as 
  6131. if they were doing that emotion. For a full list of emotion numbers, 
  6132. see 'db/const.txt' under 'e_'. The not so obvious ones are 'e_what' (a question mark) 
  6133. and 'e_gasp' (the exclamation mark).
  6134.  
  6135. The optional target parameter specifies who will get the emotion on top of
  6136. their head. If 0 (the default if omitted), the NPC in current use will show
  6137. the emotion, if 1, the player that is running the script will display it.
  6138.  
  6139. Target name parameter allows to display emotion on top of other NPC/PC without
  6140. event labels. If specified name is not found, command does nothing.
  6141.  
  6142. ---------------------------------------
  6143.  
  6144. *misceffect <effect number>;
  6145.  
  6146. This command, if run from an NPC object that has a sprite, will call up a 
  6147. specified effect number, centered on the NPC sprite. If the running code does 
  6148. not have an object ID (a 'floating' NPC) or is not running from an NPC object at 
  6149. all (an item script) the effect will be centered on the character who's RID got 
  6150. attached to the script, if any. For usable item scripts, this command will 
  6151. create an effect centered on the player using the item.
  6152.  
  6153. A full list of known effects is found in 'doc/effect_list.txt'. The list of 
  6154. those that actually work may differ greatly between client versions.
  6155.  
  6156. ---------------------------------------
  6157.  
  6158. *soundeffect "<effect filename>",<type>;
  6159. *soundeffectall "<effect filename>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>};
  6160.  
  6161. These two commands will play a sound effect to either the invoking character 
  6162. only ('soundeffect') or multiple characters ('soundeffectall'). If the running 
  6163. code does not have an object ID (a 'floating' NPC) or is not running from an NPC 
  6164. object at all (an item script) the sound will be centered on the character who's 
  6165. RID got attached to the script, if any. If it does, it will be centered on that 
  6166. object. (an NPC sprite)
  6167.  
  6168. Effect filename is the filename in a GRF. It must have the .wav extension.
  6169.  
  6170. It's not quite certain what the 'type' actually does, it is sent to the client 
  6171. directly. It probably determines which directory to play the effect from.
  6172. It's certain that giving 0 for the number will play sound files from '\data\wav\',
  6173. but where the other numbers will read from is unclear.
  6174.  
  6175. You can add your own effects this way, naturally.
  6176.  
  6177. ---------------------------------------
  6178.  
  6179. *playBGM "<BGM filename>";
  6180. *playBGMall "<BGM filename>"{,"<map name>"{,<x0>,<y0>,<x1>,<y1>}};
  6181.  
  6182. These two commands will play a Background Music to either the invoking character 
  6183. only ('playBGM') or multiple characters ('playBGMall').
  6184.  
  6185. BGM filename is the filename in /BGM/ folder. It has to be in .mp3 extension.
  6186.  
  6187. It's not required to specify the extension inside the script.
  6188. If coordinates are omitted, BGM will be broadcasted on the entire map. If the map name
  6189. is omitted as well the BGM will be played for the entire server.
  6190.  
  6191. You can add your own BGMs this way, naturally.
  6192.  
  6193. ---------------------------------------
  6194.  
  6195. *pvpon "<map name>";
  6196. *pvpoff "<map name>";
  6197.  
  6198. These commands will turn PVP mode for the specified maps on and off. Beside 
  6199. setting the flags referred to in 'setmapflag', 'pvpon' will also create a PVP 
  6200. timer and ranking as will @pvpon GM command do.
  6201.  
  6202. ---------------------------------------
  6203.  
  6204. *atcommand "<command line>";
  6205.  
  6206. This command will run the given command line exactly as if it was typed in from 
  6207. the keyboard by the player connected to the invoking character, and that 
  6208. character belonged to an account which had GM level 99.
  6209.  
  6210.     // This will ask the invoker for a character name and then use the '@nuke'
  6211.     // GM command on them, killing them mercilessly.
  6212.     input @player$;
  6213.     atcommand "@nuke "+@player$;
  6214.  
  6215. This command has a lot of good uses, I am sure you can have some fun with this 
  6216. one.
  6217.  
  6218. ---------------------------------------
  6219.  
  6220. *charcommand <command>;
  6221.  
  6222. This command will run the given command line exactly as if it was typed in from 
  6223. the keyboard from a character that belonged to an account which had GM level 99.
  6224.  
  6225. The commands can also run without an attached rid.
  6226.  
  6227. Example(s):
  6228.  
  6229. //this would do the same as above, but now doesn't need a player attached by default.
  6230. 	charCommand "#option 0 0 0 Roy";
  6231.  
  6232. ---------------------------------------
  6233.  
  6234. *unitskilluseid <GID>,<skill id>,<skill lvl>{,<target id>};
  6235. *unitskilluseid <GID>,"<skill name>",<skill lvl>{,<target id>};
  6236. *unitskillusepos <GID>,<skill id>,<skill lvl>,<x>,<y>;
  6237. *unitskillusepos <GID>,"<skill name>",<skill lvl>,<x>,<y>;
  6238.  
  6239. This is the replacement of the older commands, these use the same values for
  6240. GID as the other unit* commands (See 'GID').
  6241.  
  6242. Skill ID is the ID of the skill, skill level is the level of the skill.
  6243. For the position, the x and y are given in the unitSkillUsePos.
  6244.  
  6245. ---------------------------------------
  6246.  
  6247. *day;
  6248. *night;
  6249.  
  6250. These two commands will switch the entire server between day and night mode
  6251. respectively. If your server is set to cycle between day and night by
  6252. configuration, it will eventually return to that cycle.
  6253.  
  6254. -%TAB%script%TAB%DayNight%TAB%-1,{
  6255. 	end;
  6256. OnClock0600:
  6257. 	day;
  6258. 	end;
  6259. OnInit:
  6260. 	// setting correct mode upon server start-up
  6261. 	if(gettime(3)>=6 && gettime(3)<18)
  6262. 	{
  6263. 		end;
  6264. 	}
  6265. OnClock1800:
  6266. 	night;
  6267. 	end;
  6268. }
  6269.  
  6270. This script allows to emulate the day/night cycle as the server does, but also
  6271. allows triggering additional effects upon change, like announces, gifts, etc.
  6272. The day/night cycle set by configuration should be disabled, when this script is
  6273. used.
  6274.  
  6275. ---------------------------------------
  6276.  
  6277. *defpattern <set number>,"<regular expression pattern>","<event label>";
  6278. *activatepset <set number>;
  6279. *deactivatepset <set number>;
  6280. *deletepset <set number>;
  6281.  
  6282. This set of commands is only available if the server is compiled with regular 
  6283. expressions library enabled. Default compilation and most binary distributions 
  6284. aren't, which is probably bad, since these, while complex to use, are quite 
  6285. fascinating.
  6286.  
  6287. They will make the NPC object listen for text spoken publicly by players and 
  6288. match it against regular expression patterns, then trigger labels associated 
  6289. with these regular expression patterns.
  6290.  
  6291. Patterns are organized into sets, which are referred to by a set number. You can 
  6292. have multiple sets patterns, and multiple patterns may be active at once. 
  6293. Numbers for pattern sets start at 1.
  6294.  
  6295. 'defpattern' will associate a given regular expression pattern with an event 
  6296. label. This event will be triggered whenever something a player says is matched 
  6297. by this regular expression pattern, if the pattern is currently active.
  6298.  
  6299. 'activatepset' will make the pattern set specified active. An active pattern 
  6300. will enable triggering labels defined with 'defpattern', which will not happen 
  6301. by default.
  6302. 'deactivatepset' will deactivate a specified pattern set. Giving -1 as a pattern 
  6303. set number in this case will deactivate all pattern sets defined.
  6304.  
  6305. 'deletepset' will delete a pattern set from memory, so you can create a new 
  6306. pattern set in it's place.
  6307.  
  6308. Using regular expressions is high wizardry. But with this high wizardry comes 
  6309. unparalleled power of text manipulation. For an explanation of what a regular 
  6310. expression pattern is, see a few web pages:
  6311.  
  6312. http://www.regular-expressions.info/
  6313. http://www.weitz.de/regex-coach/
  6314.  
  6315. For an example of this in use, see doc/sample/npc_pcre.txt
  6316.  
  6317. With this you could, for example, automatically punish players for asking for 
  6318. Zeny in public places, or alternatively, automatically give them Zeny instead if 
  6319. they want it so much.
  6320.  
  6321. ---------------------------------------
  6322.  
  6323. *pow(<number>,<power>)
  6324.  
  6325. Returns the result of the calculation.
  6326.  
  6327. Example:
  6328. set @i, pow(2,3); // @i will be 8
  6329.  
  6330. ---------------------------------------
  6331.  
  6332. *sqrt(<number>)
  6333.  
  6334. Returns square-root of number.
  6335.  
  6336. Example:
  6337. set @i, sqrt(25); // @i will be 5
  6338.  
  6339. ---------------------------------------
  6340.  
  6341. *distance(<x0>,<y0>,<x1>,<y1>)
  6342.  
  6343. Returns distance between 2 points.
  6344.  
  6345. Example:
  6346. set @i, distance(100,200,101,202);
  6347.  
  6348. ---------------------------------------
  6349.  
  6350. *md5("<string>")
  6351.  
  6352. Returns the md5 checksum of a number or string.
  6353.  
  6354. Example:
  6355. 	mes md5(12345);
  6356. 	mes md5("12345"); 	// Will both display 827ccb0eea8a706c4c34a16891f84e7b
  6357. 	mes md5("qwerty"); 	// Will display d8578edf8458ce06fbc5bb76a58c5ca4
  6358.  
  6359. ---------------------------------------
  6360.  
  6361. *query_sql "your MySQL query", <array variable> {,<array variable>, ...};
  6362. *query_logsql "your MySQL query", <array variable> {,<array variable>, ...};
  6363.  
  6364. Puts up to 128 rows of values into the arrays and returns the number of rows.
  6365.  
  6366. Example:
  6367. set @nb, query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", @name$, @fame);
  6368. mes "Hall Of Fame: TOP5";
  6369. mes "1."+@name$[0]+"("+@fame[0]+")"; // Will return a person with the biggest fame value.
  6370. mes "2."+@name$[1]+"("+@fame[1]+")";
  6371. mes "3."+@name$[2]+"("+@fame[2]+")";
  6372. mes "4."+@name$[3]+"("+@fame[3]+")";
  6373. mes "5."+@name$[4]+"("+@fame[4]+")";
  6374.  
  6375. Note: In the TXT version it doesn't fill the array and always return -1.
  6376. Note: Use $ as suffix in the array to receive all data as text.
  6377. Note: The difference between query_sql and query_logsql is that the latter
  6378. uses the sql connection to the log database, and should be used when you want
  6379. to query the server log tables.
  6380.  
  6381. ---------------------------------------
  6382.  
  6383. *escape_sql("<string>")
  6384.  
  6385. Escapes special characters in the string, so that it is safe to use in query_sql(), 
  6386. and returns the escaped form of the given string.
  6387.  
  6388. Example 1:
  6389. 	set .@str$, "John's Laptop";
  6390. 	set .@esc_str$, escape_sql(.@name$);	// Escaped string: John\'s Laptop
  6391.  
  6392. ---------------------------------------
  6393.  
  6394. *setiteminfo(<item id>,<type>,<value>)
  6395.  
  6396. This function will set some value of an item.
  6397. Returns the new value on success, or -1 on fail (item_id not found or invalid type).
  6398.  
  6399. Valid types are:
  6400. 	0 - Buy Price; 1 - Sell Price; 2 - Item Type;
  6401. 	3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..
  6402. 		if = 0, then monsters don't drop it at all (rare or a quest item)
  6403. 		if = 10000, then this item is sold in NPC shops only
  6404. 	4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;
  6405. 	10 - slot; 11 - look; 12 - elv; 13 - wlv; 14 - view id
  6406.  
  6407. Example:
  6408.  
  6409. setiteminfo 7049,6,999; // Stone now weighs 999
  6410.  
  6411. ---------------------------------------
  6412.  
  6413. *setitemscript(<item id>,<"{ new item script }">{,<type>});
  6414.  
  6415. Set a new script bonus to the Item. Very useful for game events.
  6416. You can remove an item's itemscript by leaving the itemscript argument empty.
  6417. Returns 1 on success, or 0 on fail (item_id not found or new item script is invalid).
  6418. Type can optionally be used indicates which script to set (default is 0):
  6419.  0 - Script
  6420.  1 - OnEquip_Script
  6421.  2 - OnUnequip_Script
  6422.  
  6423. Example:
  6424.  
  6425. setitemscript 2637,"{ if(isequipped(2236)==0)end; if(getskilllv(26)){skill 40,1;}else{skill 26,1+isequipped(2636);} }";
  6426. setitemscript 2637,"";
  6427.  
  6428. ---------------------------------------
  6429.  
  6430. *atoi ("<string>")
  6431. *axtoi ("<string>")
  6432.  
  6433. These commands are used to convert strings to numbers. 'atoi' will interpret
  6434. given string as a decimal number (base 10), while 'axtoi' interprets strings as
  6435. hexadecimal numbers (base 16).
  6436.  
  6437. Example:
  6438.  
  6439. 	mes atoi("11"); 		// Will display 11 (can also be used to set a @var to 11)
  6440. 	set @var, axtoi("FF"); 	// Will set the @var to 255
  6441. 	mes axtoi("11"); 		// Will display 17 (1 = 1, 10 = 16, 
  6442. 							// hexadecimal number set: {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F})
  6443.  
  6444. ---------------------------------------
  6445.  
  6446. *compare(<string>,<substring>)
  6447.  
  6448. This command returns 1 or 0 when the substring is in the main string (1) or not (0).
  6449. This command is not case sensitive.
  6450.  
  6451. Example(s):
  6452.  
  6453. //dothis; will be executed ('Bloody Murderer' contains 'Blood').
  6454. 	if (compare("Bloody Murderer","Blood"))
  6455. 		dothis;
  6456. //dothat; will not be executed ('Blood butterfly' does not contain 'Bloody').
  6457. 	if (compare("Blood Butterfly","Bloody"))
  6458. 		dothat;
  6459.  
  6460. ---------------------------------------
  6461.  
  6462. *getstrlen("<string>")
  6463.  
  6464. This function will return the length of the string given as an argument. It is 
  6465. useful to check if anything input by the player exceeds name length limits and 
  6466. other length limits and asking them to try to input something else.
  6467.  
  6468. ---------------------------------------
  6469.  
  6470. *charisalpha("<string>",<position>)
  6471.  
  6472. This function will return 1 if the character number Position in the given string 
  6473. is a letter, 0 if it isn't a letter but a digit or a space.
  6474. The first letter is position 0.
  6475.  
  6476. ---------------------------------------
  6477.  
  6478. *charat(<string>,<index>)
  6479.  
  6480. 	Returns char at specified index. If index is out of range, 
  6481. 	returns empty string.
  6482.  
  6483. 	Example:
  6484.  
  6485. 	charat("This is a string", 10); //returns "s"
  6486.  
  6487. ---------------------------------------
  6488.  
  6489. *setchar(<string>,<char>,<index>)
  6490.  
  6491. 	Returns the original string with the char at the specified
  6492. 	index set to the specified char. If index out of range, the
  6493. 	original string will be returned.
  6494. 	Only the 1st char in the <char> parameter will be used.
  6495.  
  6496. 	Example:
  6497.  
  6498. 	setchar("Cat", "B", 0); //returns "Bat"
  6499.  
  6500. ---------------------------------------
  6501.  
  6502. *insertchar(<string>,<char>,<index>)
  6503.  
  6504. 	Returns the original string with the specified char inserted
  6505. 	at the specified index. If index is out of range, the char 
  6506. 	will be inserted on the end	of the string that it is closest.
  6507. 	Only the 1st char in the <char> parameter will be used.
  6508.  
  6509. 	Example:
  6510.  
  6511. 	setchar("laughter", "s", 0); //returns "slaughter"
  6512.  
  6513. ---------------------------------------
  6514.  
  6515. *delchar(<string>,<index>)
  6516.  
  6517. 	Returns the original string with the char at the specified index
  6518. 	removed. If index is out of range, original string will be returned.
  6519.  
  6520. 	Example:
  6521.  
  6522. 	delchar("Diet", 3); //returns "Die"
  6523.  
  6524. ---------------------------------------
  6525.  
  6526. *strtoupper(<string>)
  6527. *strtolower(<string>)
  6528.  
  6529. 	Returns the specified string in it's uppercase/lowercase form.
  6530. 	All non-alpha characters will be preserved
  6531.  
  6532. 	Example:
  6533.  
  6534. 	strtoupper("The duck is blue!!"); //returns "THE DUCK IS BLUE!!"
  6535.  
  6536. ---------------------------------------
  6537.  
  6538. *charisupper(<string>,<index>)
  6539. *charislower(<string>,<index>)
  6540.  
  6541. 	Returns 1 if character at specified index of specified string is
  6542. 	uppercase/lowercase. Otherwise, 0. Characters not of the alphabelt
  6543. 	will return 0.
  6544.  
  6545. 	Example:
  6546.  
  6547. 	charisupper("rAthena", 1); //returns 1
  6548.  
  6549. ---------------------------------------
  6550.  
  6551. *substr(<string>,<start_index>,<end_index>)
  6552.  
  6553. 	Returns the sub-string of the specified string inclusively between
  6554. 	the set indexes.
  6555. 	If indexes are out of range, or the start index is after the end
  6556. 	index, an empty string will be returned.
  6557.  
  6558. 	Example:
  6559.  
  6560. 	substr("foobar", 3, 5); //returns "bar"
  6561.  
  6562. ---------------------------------------
  6563.  
  6564. *explode(<dest_array>,<string>,<delimiter>)
  6565.  
  6566. 	Breaks a string up into substrings based on the specified delimiter.
  6567. 	Substrings will be stored within the specified string array.
  6568. 	Only the 1st char of the delimiter parameter will be used.
  6569. 	If an empty string is passed as a delimiter, the string will be placed
  6570. 	in the array in it's original form.
  6571.  
  6572. 	Example:
  6573.  
  6574. 	explode(.@my_array$, "Explode:Test:1965:red:PIE", ":");
  6575. 	//.@my_array$ contents will be...
  6576. 	//.@my_array$[0]: "Explode"
  6577. 	//.@my_array$[1]: "Test"
  6578. 	//.@my_array$[2]: "1965"
  6579. 	//.@my_array$[3]: "red"
  6580. 	//.@my_array$[4]: "PIE"
  6581.  
  6582.  
  6583. ---------------------------------------
  6584.  
  6585. *implode(<string_array>{,<glue>})
  6586.  
  6587. 	Combines all substrings within the specified string array into a single string.
  6588. 	If the glue parameter is specified, it will be inserted inbetween each substring.
  6589.  
  6590. 	Example:
  6591. 	setarray .@my_array$[0], "This", "is", "a", "test";
  6592. 	implode(.@my_array$, " "); //returns "This is a test"
  6593.  
  6594. ---------------------------------------
  6595.  
  6596. *sprintf(<format>[,param[,param[,...]]]) [Mirei]
  6597.  
  6598. 	C style sprintf. The resulting string is returned same as in PHP. All C format 
  6599. 	specifiers are supported except %n. More info: sprintf @ www.cplusplus.com. 
  6600. 	The number of params is only limited by eA's script engine.
  6601.  
  6602. 	See thread: http://www.eathena.ws/board/index.php?showtopic=190410
  6603.  
  6604. 	Example:
  6605. 	.@format$ = 'The %s contains %d monkeys';
  6606. 	dispbottom(sprintf(.@format$, "zoo", 5));        //prints "The zoo contains 5 monkeys"
  6607. 	dispbottom(sprintf(.@format$, "barrel", 82));    //prints "The barrel contains 82 monkeys"
  6608.  
  6609. ---------------------------------------
  6610.  
  6611. *sscanf(<string>,<format>[,param[,param[,...]]]) [Mirei]
  6612.  
  6613. 	C style sscanf. All C format specifiers are supported. 
  6614. 	More info: sscanf @ www.cplusplus.com. The number of params is only limited 
  6615. 	by eA's script engine.
  6616.  
  6617. 	See thread: http://www.eathena.ws/board/index.php?showtopic=191157
  6618.  
  6619. 	Example:
  6620. 	sscanf("This is a test: 42 foobar", "This is a test: %d %s", .@num, .@str$);
  6621. 	dispbottom(.@num + " " + .@str$); //prints "42 foobar"
  6622.  
  6623. ---------------------------------------
  6624.  
  6625. *strpos(<haystack>,<needle>{,<offset>})
  6626.  
  6627. 	PHP style strpos. Finds a substring (needle) within a string (haystack).
  6628. 	The offset parameter indicates the index of the string to start searching.
  6629. 	Returns index of substring on successful search, else -1.
  6630. 	Comparison is case sensitive.
  6631.  
  6632. 	Example:
  6633. 	strpos("foobar", "bar", 0); //returns 3
  6634. 	strpos("foobarfoo", "foo", 0); //returns 0
  6635. 	strpos("foobarfoo", "foo", 1); //returns 6
  6636.  
  6637. ---------------------------------------
  6638.  
  6639. *replacestr(<input>, <search>, <replace>{, <usecase>{, <count>}})
  6640.  
  6641. 	Replaces all instances of a search string in the input with the specified
  6642. 	replacement string. By default is case sensitive unless <usecase> is set
  6643. 	to 0. If specified it will only replace as many instances as specified
  6644. 	in the count parameter.
  6645.  
  6646. 	Example:
  6647. 	replacestr("testing tester", "test", "dash"); //returns "dashing dasher"
  6648. 	replacestr("Donkey", "don", "mon", 0);	//returns "monkey"
  6649. 	replacestr("test test test test test", "yay", 0, 3); //returns "yay yay yay test test"
  6650.  
  6651. ---------------------------------------
  6652.  
  6653. *countstr(<input>, <search>{, <usecase>})
  6654.  
  6655. 	Counts all instances of a search string in the input. By default is case
  6656. 	sensitive unless <usecase> is set to 0.
  6657.  
  6658. 	Example:
  6659. 	countstr("test test test Test", "test"); //returns 3
  6660. 	countstr("cake Cake", "Cake", 0); //returns 2
  6661.  
  6662.  
  6663. ---------------------------------------
  6664.  
  6665. *setfont <font>
  6666.  
  6667. This command sets the current RO client interface font to one of the
  6668. fonts stored in data\*.eot by using an ID of the font. When the ID
  6669. of the currently used font is used, default interface font is used
  6670. again.
  6671.  
  6672.     0 - Default
  6673.     1 - RixLoveangel
  6674.     2 - RixSquirrel
  6675.     3 - NHCgogo
  6676.     4 - RixDiary
  6677.     5 - RixMiniHeart
  6678.     6 - RixFreshman
  6679.     7 - RixKid
  6680.     8 - RixMagic
  6681.     9 - RixJJangu
  6682.  
  6683. ---------------------------------------
  6684.  
  6685. *showdigit <value>{,<type>};
  6686.  
  6687. Displays given numeric 'value' in large digital clock font on top of
  6688. the screen. The optional parameter 'type' specifies visual aspects
  6689. of the "clock" and can be one of the following values:
  6690.  
  6691.     0 - Displays the value for 5 seconds (default).
  6692.     1 - Incremental counter (1 tick/second).
  6693.     2 - Decremental counter (1 tick/second). Does not stop at zero,
  6694.         but overflows.
  6695.     3 - Decremental counter (1 tick/second). Two digits only, stops
  6696.         at zero.
  6697.  
  6698. For type 1 and 2 the start value is set by using negative number of
  6699. the one intended to set (ex. -10 starts the counter at 10 seconds).
  6700. Except for type 3 the value is interpreted as seconds and formatted
  6701. as time in days, hours, minutes and seconds. Note, that the official
  6702. script command does not have the optional parameter.
  6703.  
  6704.     // displays 23:59:59 for 5 seconds
  6705.     showdigit 86399;
  6706.  
  6707.     // counter that starts at 60 and runs for 60 seconds
  6708.     showdigit 60,3;
  6709.  
  6710. ---------------------------------------
  6711.  
  6712. * The Pet AI commands
  6713.  
  6714. These commands will only work if the invoking character has a pet, and are meant 
  6715. to be executed from pet scripts. They will modify the pet AI decision-making for 
  6716. the current pet of the invoking character, and will NOT have any independent 
  6717. effect by themselves, which is why only one of them each may be in effect at any 
  6718. time for a specific pet. A pet may have 'petloot', 'petskillbonus', 
  6719. 'petskillattack' OR 'petpetskillattack2' and 'petskillsupport' OR 'petheal' at 
  6720. the same time. 'petheal' is deprecated and is no longer used in the default pet 
  6721. scripts. 
  6722.  
  6723. *petskillbonus <bonus type>,<value>,<duration>,<delay>;
  6724.  
  6725. This command will make the pet give a bonus to the owner's stat (bonus type -
  6726. bInt,bVit,bDex,bAgi,bLuk,bStr,bSpeedRate - for a full list, see the values 
  6727. starting with 'b' in 'db/const.txt')
  6728.  
  6729. *petrecovery <status type>,<delay>;
  6730.  
  6731. This command will make the pet cure a specified status condition. The curing 
  6732. actions will occur once every Delay seconds. For a full list of status 
  6733. conditions that can be cured, see the list of 'SC_' status condition constants 
  6734. in 'db/const.txt'
  6735.  
  6736. *petloot <max items>;
  6737.  
  6738. This command will turn on pet looting, with a maximum number of items to loot 
  6739. specified. Pet will store items and return them when the maximum is reached or 
  6740. when pet performance is activated.
  6741.  
  6742. *petskillsupport <skill id>,<skill level>,<delay>,<percent hp>,<percent sp>;
  6743. *petskillsupport "<skill name>",<skill level>,<delay>,<percent hp>,<percent sp>;
  6744. *petheal <level>,<delay>,<percent hp>,<percent sp>;
  6745.  
  6746. This will make the pet use a specified support skill on the owner whenever the 
  6747. HP and SP are below the given percent values, with a specified delay time 
  6748. between activations. The skill numbers are as per 'db/skill_db.txt'.
  6749. 'petheal' works the same as 'petskillsupport' but has the skill ID hard-coded to 
  6750. 28 (Heal). This command is deprecated.
  6751. It's not quite certain who's stats will be used for the skills cast, the 
  6752. character's or the pets. Probably, Skotlex can answer that question.
  6753.  
  6754. *petskillattack <skill id>,<skill level>,<rate>,<bonusrate>;
  6755. *petskillattack "<skill name>",<skill level>,<rate>,<bonusrate>;
  6756. *petskillattack2 <skill id>,<damage>,<number of attacks>,<rate>,<bonusrate>;
  6757. *petskillattack2 "<skill name>",<damage>,<number of attacks>,<rate>,<bonusrate>;
  6758.  
  6759. These two commands will make the pet cast an attack skill on the enemy the pet's 
  6760. owner is currently fighting. Skill IDs and levels are as per 'petskillsupport'. 
  6761. 'petskillattack2' will make the pet cast the skill with a fixed amount of damage 
  6762. inflicted and the specified number of attacks.
  6763.  
  6764. All commands with delays and durations will only make the behavior active for 
  6765. the specified duration of seconds, with a delay of the specified number of 
  6766. seconds between activations. Rates are a chance of the effect occurring and are 
  6767. given in percent. 'bonusrate' is added to the normal rate if the pet intimacy is 
  6768. at the maximum possible.
  6769.  
  6770. The behavior modified with the above mentioned commands will only be exhibited if 
  6771. the pet is loyal and appropriate configuration options are set in 
  6772. 'battle_athena.conf'.
  6773.  
  6774. Pet scripts in the database normally run whenever a pet of that type hatches 
  6775. from the egg. Other commands usable in item scripts (see 'bonus') will also 
  6776. happily run from pet scripts. Apparently, the pet-specific commands will also 
  6777. work in NPC scripts and modify the behavior of the current pet up until the pet 
  6778. is hatched again. (Which will also occur when the character is logged in again 
  6779. with the pet still out of the egg.) It is not certain for how long the effect of 
  6780. such command running from an NPC script will eventually persist, but apparently, 
  6781. it is possible to usefully employ them in usable item scripts to create pet 
  6782. buffing items.
  6783.  
  6784. Nobody tried this before, so you're essentially on your own here.
  6785.  
  6786. ---------------------------------------
  6787.  
  6788. *bpet;
  6789.  
  6790. This command opens up a pet hatching window on the client connected to the 
  6791. invoking character. It is used in item script for the pet incubators and will 
  6792. let the player hatch an owned egg. If the character has no eggs, it will just 
  6793. open up an empty incubator window.
  6794. This is still usable outside item scripts.
  6795.  
  6796. ---------------------------------------
  6797.  
  6798. *makepet <pet id>;
  6799.  
  6800. This command will create a pet egg and put it in the invoking character's 
  6801. inventory. The kind of pet is specified by pet ID numbers listed in 
  6802. 'db/pet_db.txt'. The egg is created exactly as if the character just successfully 
  6803. caught a pet in the normal way.
  6804.  
  6805.     // This will make you a poring:
  6806.     makepet 1002;
  6807.  
  6808. Notice that you absolutely have to create pet eggs with this command. If you try 
  6809. to give a pet egg with 'getitem', pet data will not be created by the char 
  6810. server and the egg will disappear when anyone tries to hatch it.
  6811.  
  6812. ---------------------------------------
  6813.  
  6814. *homshuffle;
  6815.  
  6816. This will recalculate the homunculus stats according to its level, of the 
  6817. current invoking character.
  6818.  
  6819. ---------------------------------------
  6820.  
  6821. *setcell "<map name>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>;
  6822.  
  6823. Each map cell has several 'flags' that specify the properties of that cell.
  6824. These include terrain properties (walkability, shootability, presence of water),
  6825. skills (basilica, land protector, ...) and other (NPC nearby, no vending, ...).
  6826. Each of these can be 'on' or 'off'. Together they define a cell's behavior.
  6827.  
  6828. This command lets you alter these flags for all map cells in the specified
  6829. (x1,y1)-(x2,y2) rectangle. The 'flag' can be 0 or 1 (0:clear flag, 1:set flag).
  6830. The 'type' defines which flag to modify. Possible options include cell_walkable,
  6831. cell_shootable, cell_basilica. For a full list, see const.txt.
  6832.  
  6833. Example:
  6834.  
  6835. 	setcell "arena",0,0,300,300,cell_basilica,1;
  6836. 	setcell "arena",140,140,160,160,cell_basilica,0;
  6837. 	setcell "arena",135,135,165,165,cell_walkable,0;
  6838. 	setcell "arena",140,140,160,160,cell_walkable,1;
  6839.  
  6840. This will add a makeshift ring into the center of the map. The ring will be
  6841. surrounded by a 5-cell wide 'gap' to prevent interference from outside, and
  6842. the rest of the map will be marked as 'basilica', preventing observers from
  6843. casting any offensive skills or fighting among themselves. Note that the wall
  6844. will not be shown nor known client-side, which may cause movement problems.
  6845.  
  6846. Another example:
  6847.  
  6848. OnBarricadeDeploy:
  6849. 	setcell "schg_cas05",114,51,125,51,cell_walkable,0;
  6850. 	end;
  6851. OnBarricadeBreak:
  6852. 	setcell "schg_cas05",114,51,125,51,cell_walkable,1;
  6853. 	end;
  6854.  
  6855. This could be a part of the WoE:SE script, where attackers are not allowed
  6856. to proceed until all barricades are destroyed. This script would place and
  6857. remove a nonwalkable row of cells after the barricade mobs.
  6858.  
  6859. ---------------------------------------
  6860.  
  6861. *checkcell ("<map name>",<x>,<y>,<type>);
  6862.  
  6863. This command will return 1 or 0, depending on whether the specified cell has
  6864. the 'type' flag set or not. There are various types to check, all mimicking
  6865. the server's cell_chk enumeration. The types can be found in db/const.txt.
  6866.  
  6867. The meaning of the individual types can be confusing, so here's an overview:
  6868.   - cell_chkwall/water/cliff
  6869.     these check directly for the 'terrain component' of the specified cell
  6870.   - cell_chkpass/reach/nopass/noreach
  6871.     passable = not wall & not cliff, reachable = passable wrt. no-stacking mod
  6872.   - cell_chknpc/basilica/landprotector/novending/nochat
  6873.     these check for specific dynamic flags (their name indicates what they do)
  6874.  
  6875. Example:
  6876.  
  6877. 	mes "Pick a destination map.";
  6878. 	input .@map$;
  6879. 	mes "Alright, now give me the coordinates.";
  6880. 	input .@x;
  6881. 	input .@y;
  6882. 	if( !checkcell(.@map$,.@x,.@y,cell_chkpass) )
  6883. 	{
  6884. 		mes "Can't warp you there, sorry!";
  6885. 		close;
  6886. 	}
  6887. 	else
  6888. 	{
  6889. 		mes "Ok, get ready...";
  6890. 		close2;
  6891. 		warp .@map$, .@x, .@y;
  6892. 		end;
  6893. 	}
  6894.  
  6895. ---------------------------------------
  6896.  
  6897. *setwall "<map name>",<x>,<y>,<size>,<dir>,<shootable>,"<name>";
  6898. *delwall "<name>";
  6899.  
  6900. Creates an invisible wall, an array of "setcell" starting from x,y and doing a
  6901. line of the given size in the given direction. The difference with setcell is
  6902. this one update client part too to avoid the glitch problem. Directions are the 
  6903. same as NPC sprite facing directions: 0=north, 1=northwest, 2=west, etc.
  6904.  
  6905. ---------------------------------------
  6906.  
  6907. *readbook <book id>,<page>;
  6908.  
  6909. This will open a book item at the specified page
  6910.  
  6911. ---------------------------------------
  6912.  
  6913. ========================
  6914. |7.- Instance commands.|
  6915. ========================
  6916. ---------------------------------------
  6917.  
  6918. *instance_create("<instance name>",<party id>);
  6919.  
  6920. Create an instance using the name "<instance name>" for the Party of <party id>.
  6921. Most instance_* commands are used in conjunction with this command and depend
  6922. on the ID this command returns.
  6923.  
  6924. Example: 
  6925. 	// Store the Party ID of the invoking character.
  6926. 	set .@party_id, getcharid(1);
  6927. 	// Attempt to create an instance using that party ID.
  6928. 	set .@id, instance_create("Endless Tower", .@party_id);
  6929. 	if (.@id == -1) { // Invalid type - not used anymore
  6930. 		...
  6931. 	}
  6932. 	else if (.@id == -2) { // Invalid Party ID
  6933. 		...
  6934. 	}
  6935. 	else if (.@id == -3) { // No free instances (MAX_INSTANCE exceeded)
  6936. 		...
  6937. 	}
  6938. 	else if (.@id == -4) { // Already exists
  6939. 		...
  6940. 	}
  6941. 	else (.@id < 0) { // Unspecified error while queuing instance.
  6942. 		...
  6943. 	}
  6944. ---------------------------------------
  6945.  
  6946. *instance_destroy {<instance id>};
  6947.  
  6948. Destroys instance with the ID <instance id>. If no ID is specified, the instance,
  6949. the script is attached to, is used. If the script is not attached to an instance,
  6950. the instance of the currently attached player's party is used. If no player is
  6951. currently attached, the command fails and causes the script to halt.
  6952.  
  6953. ---------------------------------------
  6954.  
  6955. *instance_attachmap("<map name>",<instance id>{,<use base name>});
  6956.  
  6957. Attaches the map "<map name>" to the instance specified with <instance id>. The
  6958. optional parameter specifies, whether a map requires emulation for instancing (1)
  6959. or not (0 = default).
  6960.  
  6961. Returns the resulting map name on success or an empty string on failure.
  6962.  
  6963. ---------------------------------------
  6964.  
  6965. *instance_detachmap "<map name>"{,<instance id>};
  6966.  
  6967. Detach the map "<map name>" to the instance with the <instance id>. If no ID is
  6968. specified, the instance, the script is attached to, is used. If the script is not
  6969. attached to an instance, the instance of the currently attached player's party is
  6970. used. If no player is currently attached, the command fails and causes the script
  6971. to halt.
  6972.  
  6973. ---------------------------------------
  6974.  
  6975. *instance_init <instance id>;
  6976.  
  6977. Initializes the instance given by <instance id>. This copies all NPCs from the
  6978. source maps to the instanced maps.
  6979.  
  6980. ---------------------------------------
  6981.  
  6982. *instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
  6983.  
  6984. Works like announce, but has the <instance id> parameter. If instance id is 0, the
  6985. instance, the script is attached to, is used. If the script is not attached to an
  6986. instance, the instance of the currently attached player's party is used. If no
  6987. player is currently attached, the command fails and causes the script to halt.
  6988.  
  6989. ---------------------------------------
  6990.  
  6991. *instance_attach <instance id>;
  6992.  
  6993. Attaches the current script to the instance given by <instance id>.
  6994.  
  6995. ---------------------------------------
  6996.  
  6997. *instance_npcname("<npc name>"{,<instance id>});
  6998.  
  6999. Retrieves the unique name given to a copy of an NPC given by "<npc name>" in an
  7000. instance specified <instance id>. If no ID is specified, the instance, the script
  7001. is attached to, is used. If the script is not attached to an instance, the
  7002. instance of the currently attached player's party is used. If no player is
  7003. currently attached, the command fails and causes the script to halt.
  7004.  
  7005. ---------------------------------------
  7006.  
  7007. *has_instance("<map name>"{,<instance id>});
  7008.  
  7009. Checks whether or not the given map belongs to specified instance. If no ID is
  7010. specified, the instance, the script is attached to, is used. If the script is not
  7011. attached to an instance, the instance of the currently attached player's party
  7012. is used. If no player is currently attached, the command fails and causes the
  7013. script to halt.
  7014.  
  7015. Returns the name of the instanced map on success, otherwise an empty string.
  7016.  
  7017. ---------------------------------------
  7018.  
  7019. *instance_id({<type>});
  7020.  
  7021. Retrieves the instance id, depending on <type>. If type is not given, it defaults
  7022. to 0.
  7023.  
  7024. Type:
  7025.     0 - Instance ID the script is attached to.
  7026.     1 - Instance ID of the currently attached player's party.
  7027.  
  7028. ---------------------------------------
  7029.  
  7030. *instance_warpall "<map name>",<x>,<y>{,<instance id>};
  7031.  
  7032. Warps all players in the instance <instance id> to <map name> at given
  7033. coordinates. If no ID is specified, the instance, the script is attached to,
  7034. is used. If the script is not attached to an instance, the instance of the
  7035. currently attached player's party is used. If no player is currently attached,
  7036. the command fails and causes the script to halt.
  7037.  
  7038. ---------------------------------------
  7039.  
  7040. *instance_set_timeout <alive timeout>,<idle timeout>{,<instance id>};
  7041.  
  7042. Sets the timeout values for an instance given by <instance id>. If no ID is
  7043. specified, the instance, the script is attached to, is used. If the script is
  7044. not attached to an instance, the instance of the currently attached player's
  7045. party is used. If no player is currently attached, the command fails and causes
  7046. the script to halt.
  7047.  
  7048. Parameter <alive timeout> specifies the total amount of time the instance will
  7049. exist. Parameter <idle timeout> specifies how long players have, when they are
  7050. outside of the instance, until it is destroyed.
  7051.  
  7052. Both timeout values are in seconds.
  7053.  
  7054. ---------------------------------------
  7055.  
  7056. =========================
  7057. |8.- Quest Log commands.|
  7058. =========================
  7059. ---------------------------------------
  7060.  
  7061. *setquest <ID>;
  7062.  
  7063. Place quest of <ID> in the users quest log, the state of which is "active".
  7064.  
  7065. ---------------------------------------
  7066.  
  7067. *completequest <ID>;
  7068.  
  7069. Change the state for the given quest <ID> to "complete" and remove from the users quest log.
  7070.  
  7071. ---------------------------------------
  7072.  
  7073. *erasequest <ID>;
  7074.  
  7075. Remove the quest of the given <ID> from the user's quest log.
  7076.  
  7077. ---------------------------------------
  7078.  
  7079. *changequest <ID>,<ID2>;
  7080.  
  7081. Remove quest of the given <ID> from the user's quest log.
  7082. Add quest of the <ID2> to the the quest log, and the state is "active".
  7083.  
  7084. ---------------------------------------
  7085.  
  7086. *checkquest(<ID>{,PLAYTIME|HUNTING})
  7087.  
  7088. If no additional argument supplied, return the state of the quest: 
  7089. 	-1 = Quest not started (not in quest log)
  7090. 	0  = Quest has been given, but the state is "inactive"
  7091. 	1  = Quest has been given, and the state is "active"
  7092. 	2  = Quest completed
  7093.  
  7094. If parameter "PLAYTIME" is supplied:
  7095. 	-1 = Quest not started (not in quest log)
  7096. 	0  = the time limit has not yet been reached
  7097. 	1  = the time limit has not been reached but the quest is marked as complete
  7098. 	2  = the time limit has been reached
  7099.  
  7100. If parameter "HUNTING" is supplied:
  7101. 	-1 = Quest not started (not in quest log)
  7102. 	0  = you haven't killed all of the target monsters and the time limit has not been reached.
  7103. 	1  = you haven't killed all of the target monsters but the time limit has been reached.
  7104. 	2  = you've killed all of the target monsters
  7105.  
  7106. ---------------------------------------
  7107. *showevent <state>, <color>;
  7108.  
  7109. Show a colored mark in the mini-map like "viewpoint" and an emotion on top of a NPC.
  7110. This is used to indicate that a NPC has a quest or an event to certain player/s.
  7111.  
  7112. state can be:
  7113. 	0 = disable ( Used to disable and remove the mark and the emotion from the NPC. )
  7114. 	1 = exclamation emotion ( Used to show an important quest event to certain player. )
  7115. 	2 = interrogation emotion ( Used to show an non-important quest event to certain player. )
  7116. 	Other value may cause client crashes.
  7117.  
  7118. color can be:
  7119. 	0 = yellow "Quest"
  7120. 	1 = orange "Job"
  7121. 	2 = green "Event"
  7122. 	3 = an MVP flag
  7123. 	other values show a transparent mark in the mini-map.
  7124.  
  7125. ----------------------------------------
  7126.  
  7127. ============================
  7128. |9.- Battleground commands.|
  7129. ============================
  7130. ---------------------------------------
  7131.  
  7132. *waitingroom2bg_single(<battle group>,"<mapname>",<x>,<y>,"<npc name>");
  7133.  
  7134. Adds the first waiting player from the chat room of given NPC to an
  7135. existing battleground group and warps it to specified coordinates on
  7136. given map.
  7137.  
  7138. ---------------------------------------
  7139.  
  7140. *waitingroom2bg("<mapname>",<x>,<y>,"<On Quit Event>","<On Death Event>"{,"<npc name>"});
  7141.  
  7142. <Mapname> and X Y coordinates refer to where the "respawn" base is, where the player group will respawn when they die.
  7143. <On Quit Event> refers to an NPC label that attaches to the character and is run when they relog.
  7144. <On Death Event> refers to an NPC label that attaches to the character and is run when they die. Can be "" for empty.
  7145.  
  7146. Unlike the prior command, the latter will attach a GROUP in a waiting room to the battleground, and 
  7147. sets the array $@arenamembers[0] where 0 holds the IDs of the first group, and 1 holds the IDs of the second.
  7148.  
  7149. If the option parameter is left out, the waiting room of the current NPC is used.
  7150.  
  7151. Example:
  7152. 	// Battle Group will be referred to as $@KvM01BG_id1, and when they die, respawn at bat_c01,52,129.
  7153. 	set $@KvM01BG_id1, waitingroom2bg("bat_c01",52,129,"KvM01_BG::OnGuillaumeQuit","KvM01_BG::OnGuillaumeDie");
  7154. 	end;
  7155.  
  7156. ----------------------------------------
  7157.  
  7158. *bg_team_setxy <Battle Group ID>,<x>,<y>;
  7159.  
  7160. Update the respawn point of the given battle group to x, y on the same map. The <Battle Group ID> can be retrieved using getcharid(4)
  7161.  
  7162. Example:
  7163. 	bg_team_setxy getcharid(4),56,212;
  7164. 	mapannounce "bat_a01", "Group [1] has taken the work shop, and will now respawn there.",bc_map,"0xFFCE00";
  7165. 	end;
  7166.  
  7167. ----------------------------------------
  7168.  
  7169. *bg_warp <Battle Group>,"<Mapname>",<x>,<y>;
  7170.  
  7171. Similar to warp command.
  7172. Place all members of <Battle Group> at <mapname> at x y.
  7173.  
  7174. Example:
  7175. 	//place the battle group one for Tierra Gorge at starting position.
  7176. 	bg_warp $@TierraBG1_id1,"bat_a01",352,342;
  7177. 	end;
  7178.  
  7179. ----------------------------------------
  7180.  
  7181. *bg_monster <Battle Group>,"<map name>",<x>,<y>,"<name to show>",<mob id>,"<event label>";
  7182. *bg_monster(<Battle Group>,"<map name>",<x>,<y>,"<name to show>",<mob id>,"<event label>");
  7183.  
  7184. Similar to monster script command.
  7185. Spawn a monster with allegiance to the given battle group.
  7186. Does not allow for the summoning of multiple monsters.
  7187. Monsters are similar to that in War of Emperium, in that the specified Battle group is considered friendly.
  7188.  
  7189. Example:
  7190. 	// It can be used in two different ways.
  7191. 	bg_monster $@TierraBG1_id2,"bat_a01",167,50,"Food Depot",1910,"Feed Depot#1::OnMyMobDead";
  7192. 	end;
  7193.  
  7194. 	// Alternatively, you can set an ID for the monster using "set".
  7195. 	// This becomes useful when used with the command below.
  7196. 	set $@Guardian_3, bg_monster($@TierraBG1_id2,"bat_a01",268,204,"Guardian",1949,"NPCNAME::OnMyMobDead");
  7197. 	end;
  7198.  
  7199. ----------------------------------------
  7200.  
  7201. *bg_monster_set_team <GID>,<Battle Group>;
  7202.  
  7203. This command will change the allegiance if a monster in a battle ground.
  7204. GID can be set when spawning the monster via the bg_monster command.
  7205.  
  7206. Example:
  7207.  
  7208. 	end;
  7209.  
  7210. OnEnable:
  7211. 	mapannounce "A guardian has been summoned for Battle Group 2!",bc_map,"0xFFCE00";
  7212. 	set $@Guardian, bg_monster($@BG_2,"bat_a01",268,204,"Guardian",1949,"NPCNAME::OnMyMobDead");
  7213. 	initnpctimer;
  7214. 	end;
  7215.  
  7216. OnTimer1000:
  7217. 	stopnpctimer;
  7218. 	mapannounce "Erm, sorry about that! This monster was meant for Battle Group 1.",bc_map,"0xFFCE00";
  7219. 	bg_monster_set_team $@Guardian, $@BG_1;
  7220. 	end;
  7221.  
  7222. ----------------------------------------
  7223.  
  7224. *bg_leave;
  7225.  
  7226. Removes attached player from their Battle Group.
  7227.  
  7228. ----------------------------------------
  7229.  
  7230. *bg_destroy <Batte Group>;
  7231.  
  7232. As the name says, destroys the battle group created for that battle ground.
  7233.  
  7234. ----------------------------------------
  7235.  
  7236. *areapercentheal "<mapname>",<x1>,<y1>,<x2>,<y2>,<hp>,<sp>;
  7237.  
  7238. Not exactly limited to battleground use, this will restore HP/SP in a defined area at a percentage.
  7239.  
  7240. Example:
  7241. 	areapercentheal "bat_a01",52,208,61,217,100,100;
  7242. 	end;
  7243.  
  7244. ----------------------------------------
  7245.  
  7246. *bg_get_data(<Battle Group>,<type>);
  7247.  
  7248. Retrieves data related to given battle group. Type can be one of the following:
  7249.  
  7250.     0 - Amount of players currently belonging to the group.
  7251.  
  7252. ----------------------------------------
  7253.  
  7254. *bg_getareausers(<battle group>,<map name>,<x0>,<y0>,<x1>,<y1>);
  7255.  
  7256. Retrieves amount of players belonging to given battle group on given
  7257. map within an specified rectangular area.
  7258.  
  7259. ----------------------------------------
  7260.  
  7261. *bg_updatescore "<mapname>",<Guillaume Score>,<Croix Score>;
  7262.  
  7263. Only usable when the map is defined as type:
  7264. mapflag	<mapname>	battleground	2
  7265. This command will force the update of the displayed scoreboard.
  7266.  
  7267. ----------------------------------------
  7268.  
  7269. ==========================
  7270. |10.- Mercenary commands.|
  7271. ==========================
  7272. ---------------------------------------
  7273.  
  7274. *mercenary_create <class>,<contract time>;
  7275.  
  7276. This command summons a mercenary of given class, for given amount of
  7277. time in milliseconds. Typically used in item scripts of mercenary
  7278. scrolls.
  7279.  
  7280. ----------------------------------------
  7281.  
  7282. *mercenary_heal <hp>,<sp>;
  7283.  
  7284. This command works like 'heal', but affects the mercenary of the
  7285. currently attached character.
  7286.  
  7287. ----------------------------------------
  7288.  
  7289. *mercenary_sc_start <type>,<tick>,<val1>;
  7290.  
  7291. This command works like 'sc_start', but affects the mercenary of the
  7292. currently attached character.
  7293.  
  7294. ----------------------------------------
  7295.  
  7296. *mercenary_get_calls(<guild>);
  7297. *mercenary_set_calls <guild>,<value>;
  7298.  
  7299. Sets or gets the mercenary calls value for given guild for currently
  7300. attached character. Guild can be one or the following constants:
  7301.  
  7302.     ARCH_MERC_GUILD
  7303.     SPEAR_MERC_GUILD
  7304.     SWORD_MERC_GUILD
  7305.  
  7306. ----------------------------------------
  7307.  
  7308. *mercenary_get_faith(<guild>);
  7309. *mercenary_set_faith <guild>,<value>;
  7310.  
  7311. Sets or gets the mercenary faith value for given guild for currently
  7312. attached character. Guild can be one or the following constants:
  7313.  
  7314.     ARCH_MERC_GUILD
  7315.     SPEAR_MERC_GUILD
  7316.     SWORD_MERC_GUILD
  7317.  
  7318. ---------------------------------------
  7319.  
  7320. *getmercinfo(<type>{,<char id>});
  7321.  
  7322. Retrieves information about mercenary of the currently attached
  7323. character. If char id is given, the information of that character is
  7324. retrieved instead. Type specifies what information to retrieve and
  7325. can be one of the following:
  7326.  
  7327.     0 - Database ID
  7328.     1 - Class
  7329.     2 - Name
  7330.     3 - Faith value for this mercenary's guild, if any
  7331.     4 - Calls value for this mercenary's guild, if any
  7332.     5 - Kill count
  7333.     6 - Remaining life time in msec
  7334.     7 - Level
  7335.  
  7336. If the character does not have a mercenary, the command returns ""
  7337. for name and 0 for all other types.
  7338.  
  7339. ----------------------------------------
  7340.  
  7341. Whew.
  7342. That's about all of them.
Viewed 3025 times, submitted by Guest.