OSDN Git Service

First version
[st-ro/stro.git] / doc / script_commands.txt
1 //===== rAthena Documentation================================
2 //= rAthena Script Commands
3 //===== By:==================================================
4 //= rAthena Dev Team
5 //===== Last Updated:========================================
6 //= 20161206
7 //===== Description:=========================================
8 //= A reference manual for the rAthena scripting language.
9 //= Commands are sorted depending on their functionality.
10 //===========================================================
11
12 This document is a reference manual for all the scripting commands and functions
13 available in rAthena. It is not a simple tutorial. When people tell you to
14 "Read The F***ing Manual", they mean this.
15
16 This is not a place to teach you basic programming. This document will not teach
17 you basic programming by itself. It's more of a reference for those who have at
18 least a vague idea of what they want to do and want to know what tools they have
19 available to do it. We've tried to keep it as simple as possible, but if you
20 don't understand it, getting a clear book on programming in general will help
21 better than yelling around the forum for help.
22
23 A little learning never caused anyone's head to explode.
24
25 Structure
26 ---------
27
28 The script commands are listed in no particular order, but are grouped by
29 relative function.
30
31 *Name of the command and parameters (if any).
32
33 Descriptive text
34
35         Small example if possible. Will usually be incomplete, it's there just to
36         give you an idea of how it works in practice.
37
38 To find a specific command, use Ctrl+F, (or whatever keys call up a search
39 function in whatever you're reading this with) put an asterisk (*) followed by the command
40 name, and it should find the command description for you.
41
42 If you find anything missing, please let us know!
43
44 Syntax
45 ------
46
47 Throughout this document, wherever a command wants an argument, it is given in
48 <angle brackets>. This doesn't mean you should type the angle brackets. If an
49 argument of a command is optional, it is given in {curly brackets}. You've
50 doubtlessly seen this convention somewhere. If a command can optionally take
51 an unspecified number of arguments, you'll see a list like this:
52
53 command <argument>{,<argument>...<argument>}
54
55 This still means they will want to be separated by commas.
56
57 Where a command wants a string, it will be given in "quotes", if it's a number,
58 it will be given without them. Normally, you can put an expression, like a bunch
59 of functions or operators returning a value, in (round brackets) instead of most
60 numbers. Round brackets will not always be required, but they're often a good
61 idea.
62
63 Wherever you refer to a map name, it's always 'map name' (.gat suffix is deprecated).
64
65
66 Script loading structure
67 ------------------------
68
69 Scripts are loaded by the map server as referenced in the 'conf/map_athena.conf'
70 configuration file, but in the default configuration, it doesn't load any script
71 files itself. Instead, it loads the file 'npc/(pre-)re/scripts_main.conf' which itself
72 contains references to other files. The actual scripts are loaded from txt
73 files, which are linked up like this:
74
75 npc: <path to a filename>
76
77 Any line like this, invoked, ultimately, by 'map_athena.conf' will load up the
78 script contained in this file, which will make the script available. No file
79 will get loaded twice to prevent possible errors.
80
81 Another configuration file option of relevance is:
82
83 delnpc: <path to a filename>
84
85 This will unload a specified script filename from memory, which, while
86 seemingly useless, may sometimes be required.
87
88 Whenever '//' is encountered in a line upon reading, everything beyond this on
89 that line is considered to be a comment and is ignored. This works wherever you
90 place it.
91
92 // This line will be ignored when processing the script.
93
94 Block comments can also be used, where you can place /* and */ between any text you
95 wish rAthena to ignore.
96
97 Example:
98 /* This text,
99  * no matter which new line you start
100  * is ignored, until the following
101  * symbol is encountered: */
102
103 The asterisks (*) in front of each line is a personal preference and is not required.
104
105 Upon loading all the files, the server will execute all the top-level commands
106 in them. No variables exist yet at this point, no commands can be called other
107 than those given in this section. These commands set up the basic structure - create
108 NPC objects, spawn monster objects, set map flags, etc. No code is actually
109 executed at this point. The top-level commands are pretty confusing, since
110 they aren't structured like you would expect (command name first), but rather,
111 normally start with a map name.
112
113 What's more confusing about the top-level commands is that most of them use a
114 tab symbol to divide their arguments.
115
116 To prevent problems and confusion, the tab symbols are written as '%TAB%'
117 throughout this document, even though this makes the text a bit less readable.
118 Using an invisible symbol to denote arguments is one of the bad things about
119 this language.
120
121 Here is a list of valid top-level commands:
122
123 ** Set a map flag:
124
125 <map name>%TAB%mapflag%TAB%<flag>
126
127 This will, upon loading, set a specified map flag on a map you like. These are
128 normally in files inside 'npc/mapflag' and are loaded first, so by the time the
129 server's up, all the maps have the flags they should have. Map flags determine
130 the behavior of the map in various situations. For more details, see 'setmapflag'
131 and 'doc/mapflags.txt'.
132
133 ** Create a permanent monster spawn:
134
135 <map name>,<x>,<y>{,<xs>{,<ys>}}%TAB%monster%TAB%<monster name>{,<monster level>}%TAB%<mob id>,<amount>{,<delay1>{,<delay2>{,<event>{,<mob size>{,<mob ai>}}}}}
136
137 Map name is the name of the map the monsters will spawn on. x,y are the
138 coordinates where the mob should spawn. If xs and ys are non-zero, they
139 specify the 'radius' of a spawn-rectangle area centered at x,y.
140 Putting zeros instead of these coordinates will spawn the monsters randomly.
141 Note this is only the initial spawn zone, as mobs random-walk, they are free
142 to move away from their specified spawn region.
143
144 Monster name is the name the monsters will have on screen, and has no relation
145 whatsoever to their names anywhere else. It's the mob id that counts, which
146 identifies monster record in 'mob_db.txt' database of monsters. If the mob name
147 is given as "--ja--", the 'japanese name' field from the monster database is
148 used, (which, in rAthena, actually contains an English name) if it's "--en--",
149 it's the 'english name' from the monster database (which contains an uppercase
150 name used to summon the monster with a GM command).
151
152 You can specify a custom level to use for the mob different from the one of
153 the database by adjoining the level after the name with a comma. eg:
154 "Poring,50" for a name will spawn a monster with name Poring and level 50.
155
156 Amount is the amount of monsters that will be spawned when this command is
157 executed, it is affected by spawn rates in 'battle_athena.conf'.
158
159 Delay1 and delay2 control monster respawn delays - the first one is the fixed
160 base respawn time, and the second is random variance on top of the base time.
161 Both values are given in milliseconds (1000 = 1 second).
162 Note that the server also enforces a minimum respawn delay of 5 seconds.
163
164 Event is a script event to be executed when the mob is killed. The event must
165 be in the form "NPCName::OnEventName" to execute, and the event name label
166 should start with "On". As with all events, if the NPC is an on-touch NPC, the
167 player who triggers the script must be within 'trigger' range for the event to
168 work.
169
170 There are two optional fields for monster size and AI.
171
172 <mob size> can be:
173         Size_Small      (0)
174         Size_Medium     (1)
175         Size_Large      (2)
176
177 <mob ai> can be:
178         AI_NONE         (0)             (default)
179         AI_ATTACK       (1)             (attack/friendly)
180         AI_SPHERE       (2)             (Alchemist skill)
181         AI_FLORA        (3)             (Alchemist skill)
182         AI_ZANZOU       (4)             (Kagerou/Oboro skill)
183         AI_LEGION       (5)             (Sera skill)
184         AI_FAW          (6)             (Mechanic skill)
185
186 Alternately, a monster spawned using 'boss_monster' instead of 'monster' is able
187 to be detected on the map with the SC_BOSSMAPINFO status (used by Convex Mirror).
188
189 ** NPC names
190
191 /!\ WARNING: this applies to warps, NPCs, duplicates and shops /!\
192
193 NPC names are kinda special and are formatted this way:
194
195 <Display name>{::<Unique name>}
196
197 All NPCs need to have a unique name that is used for identification purposes.
198 When you have to identify a NPC by its name, you should use <Unique name>.
199 If <Unique name> is not provided, use <Display name> instead.
200
201 The client has a special feature when displaying names:
202 if the display name contains a '#' character, it hides that part of the name.
203 ex: if your NPC is named 'Hunter#hunter1', it will be displayed as 'Hunter'
204
205 <Display name> must be at most 24 characters in length.
206 <Unique name> must be at most 24 characters in length.
207
208 ** Define a warp point
209
210 <from mapname>,<fromX>,<fromY>,<facing>%TAB%warp%TAB%<warp name>%TAB%<spanx>,<spany>,<to mapname>,<toX>,<toY>
211 <from mapname>,<fromX>,<fromY>,<facing>%TAB%warp2%TAB%<warp name>%TAB%<spanx>,<spany>,<to mapname>,<toX>,<toY>
212
213 This will define a warp NPC that will warp a player between maps, and while most
214 arguments of that are obvious, some deserve special mention.
215
216 SpanX and SpanY will make the warp sensitive to a character who didn't step
217 directly on it, but walked into a zone which is centered on the warp from
218 coordinates and is SpanX in each direction across the X axis and SpanY in each
219 direction across the Y axis.
220
221 Warp NPC objects also have a name, because you can use it to refer to them later
222 with 'enablenpc'/'disablenpc'
223
224 Facing of a warp object is irrelevant, it is not used in the code and all
225 current scripts have a zero in there.
226
227 Unlike 'warp', 'warp2' will also be triggered by hidden player.
228
229 ** Define an NPC object.
230
231 <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,{<code>}
232 <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>}
233
234 This will place an NPC object on a specified map at the specified location, and
235 is a top-level command you will use the most in your custom scripting. The NPCs
236 are triggered by clicking on them, and/or by walking in their trigger area, if
237 defined, see that below.
238
239 Facing is a direction the NPC sprite will face in. Not all NPC sprites have
240 different images depending on the direction you look from, so for some facing
241 will be meaningless. Facings are counted counterclockwise in increments of 45
242 degrees, where 0 means facing towards the top of the map. (So to turn the sprite
243 towards the bottom of the map, you use facing 4, and to make it look southeast
244 it's facing 5.)
245
246 Sprite ID is the sprite number or constant used to display this particular NPC.
247 You may also use a monster's ID instead to display a monster sprite for this NPC.
248 It is possible to use a job sprite as well, but you must first define it as a
249 monster sprite in 'mob_avail.txt', a full description on how to do this is not
250 in the scope of this manual.
251 A '-1' Sprite ID will make the NPC invisible (and unclickable).
252 A '111' Sprite ID will make an NPC which does not have a sprite, but is still
253 clickable, which is useful if you want to make a clickable object of the 3D
254 terrain.
255
256 TriggerX and triggerY, if given, will define an area, centered on NPC and
257 spanning triggerX cells in every direction across X and triggerY in every
258 direction across Y. Walking into that area will trigger the NPC. If no
259 'OnTouch:' special label is present in the NPC code, the execution will start
260 from the beginning of the script, otherwise, it will start from the 'OnTouch:'
261 label. Monsters can also trigger the NPC, though the label 'OnTouchNPC:' is
262 used in this case.
263
264 The code part is the script code that will execute whenever the NPC is
265 triggered. It may contain commands and function calls, descriptions of which
266 compose most of this document. It has to be in curly brackets, unlike elsewhere
267 where we use curly brackets, these do NOT signify an optional parameter.
268
269 ** Define a 'floating' NPC object.
270
271 -%TAB%script%TAB%<NPC Name>%TAB%-1,{<code>}
272
273 This will define an NPC object not triggerable by normal means. This would
274 normally mean it's pointless since it can't do anything, but there are
275 exceptions, mostly related to running scripts at specified time, which is what
276 these floating NPC objects are for. More on that below.
277
278 ** Define a shop/cashshop/itemshop/pointshop NPC.
279
280 -%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
281 <map name>,<x>,<y>,<facing>%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
282
283 -%TAB%cashshop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
284 <map name>,<x>,<y>,<facing>%TAB%cashshop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
285
286 -%TAB%itemshop%TAB%<NPC Name>%TAB%<sprite id>,<costitemid>{:<discount>},<itemid>:<price>{,<itemid>:<price>...}
287 <map name>,<x>,<y>,<facing>%TAB%itemshop%TAB%<NPC Name>%TAB%<sprite id>,<costitemid>{:<discount>},<itemid>:<price>{,<itemid>:<price>...}
288
289 -%TAB%pointshop%TAB%<NPC Name>%TAB%<sprite id>,<costvariable>{:<discount>},<itemid>:<price>{,<itemid>:<price>...}
290 <map name>,<x>,<y>,<facing>%TAB%pointshop%TAB%<NPC Name>%TAB%<sprite id>,<costvariable>{:<discount>},<itemid>:<price>{,<itemid>:<price>...}
291
292 <map name>,<x>,<y>,<facing>%TAB%marketshop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>:<quantity>{,<itemid>:<price>:<quantity>...}
293
294 This will define a shop NPC, which, when triggered (which can only be done by
295 clicking) will cause a shop window to come up. No code whatsoever runs in shop
296 NPCs and you can't change the prices otherwise than by editing the script
297 itself.
298
299 The Item ID is the number of item in the 'item_db.txt' database. If Price is set
300 to -1, the 'buy price' given in the item database will be used. Otherwise, the
301 price you gave will be used for this item, which is how you create differing
302 prices for items in different shops.
303
304 There are other types of shops available:
305 cashshop - use "cashshop" in place of "shop" to use the Cash Shop interface, allowing
306 you to buy items with special points that are stored as account variables
307 called  #CASHPOINTS and #KAFRAPOINTS. This type of shop will not allow you to sell
308 items at it, only make purchases. The layout used to define sale items still count, and
309 "<price>" refers to how many points will be spent purchasing the them.
310
311 "itemshop" and "pointshop" use the Shop interface, allowing you to buy items with a specific
312 item or special points from a variable. 'pointshop' only supports permanent character variables,
313 temporary character variables, permanent local account variables or permanent global account
314 variables. These variables must be of integer type, not string. 'discount' flag is an
315 optional value which makes the price at that shop become affected by discount skill.
316
317 ** Define an warp/shop/cashshop/itemshop/pointshop/NPC duplicate.
318
319 warp/warp2: <map name>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<spanx>,<spany>
320 shop/cashshop/itemshop/pointshop/npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>
321 shop/cashshop/itemshop/pointshop/npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>
322 npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>
323 npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>
324
325 This will duplicate an warp/shop/cashshop/itemshop/pointshop/NPC referred to by 'label'.
326 Warp duplicates inherit the target location.
327 Shop/cashshop/itemshop/pointshop duplicates inherit the item list.
328 NPC duplicates inherit the script code.
329 The rest (name, location, facing, sprite ID, span/trigger area)
330 is obtained from the definition of the duplicate (not inherited).
331
332 ** Define a function object
333
334 function%TAB%script%TAB%<function name>%TAB%{<code>}
335
336 This will define a function object, callable with the 'callfunc' command (see
337 below). This object will load on every map server separately, so you can get at
338 it from anywhere. It's not possible to call the code in this object by
339 anything other than the 'callfunc' script command.
340
341 The code part is the script code that will execute whenever the function is
342 called with 'callfunc'. It has to be in curly brackets, unlike elsewhere where
343 we use curly brackets, these do NOT signify an optional parameter.
344
345 Once an object is defined which has a 'code' field to its definition, it
346 contains script commands which can actually be triggered and executed.
347
348 ~ RID? GID? ~
349
350 What a RID is and why do you need to know
351 -----------------------------------------
352
353 Most scripting commands and functions will want to request data about a
354 character, store variables referenced to that character, send stuff to the
355 client connected to that specific character. Whenever a script is invoked by a
356 character, it is passed a so-called RID - this is the account ID number of a
357 character that caused the code to execute by clicking on it, walking into its
358 OnTouch zone, or otherwise.
359
360 If you are only writing common NPCs, you don't need to bother with it. However,
361 if you use functions, if you use timers, if you use clock-based script
362 activation, you need to be aware of all cases when a script execution can be
363 triggered without a RID attached. This will make a lot of commands and functions
364 unusable, since they want data from a specific character, want to send stuff to
365 a specific client, want to store variables specific to that character, and they
366 would not know what character to work on if there's no RID.
367
368 Unless you use 'attachrid' to explicitly attach a character to the script first.
369
370 Whenever we say 'invoking character', we mean 'the character who's RID is
371 attached to the running script. The script function "playerattached" can be
372 used to check which is the currently attached player to the script (it will
373 return 0 if the there is no player attached or the attached player no longer
374 is logged on to the map-server).
375
376 But what about GID?
377 -------------------
378
379 GID stands for the Game ID of something, this can either be the GID obtained
380 through mobspawn (mob control commands) or the account ID of a character.
381 Another way would be to right click on a mob, NPC or char as GM sprited char
382 to view the GID.
383
384 See also 'getpetinfo', 'getmercinfo', 'gethominfo', and 'geteleminfo'.
385
386 This is mostly used for the new version of skill and the mob control commands
387 implemented.
388
389 Item and pet scripts
390 --------------------
391
392 Each item in the item database has three special fields - Script , OnEquip_Script
393 and OnUnequip_Script. The first is script code run every time a character equips the item,
394 with the RID of the equipping character. Every time they unequip an item, all
395 temporary bonuses given by the script commands are cleared, and all the scripts
396 are executed once again to rebuild them. This also happens in several other
397 situations (like upon login) but the full list is currently unknown.
398
399 OnEquip_Script is a piece of script code run whenever the item is used by a character
400 by double-clicking on it. OnUnequip_Script runs whenever the
401 equipment is unequip by a character
402
403 Not all script commands work properly in the item scripts. Where commands and
404 functions are known to be meant specifically for use in item scripts, they are
405 described as such.
406
407 Every pet in the pet database has a PetScript field, which determines pet
408 behavior. It is invoked wherever a pet of the specified type is spawned.
409 (hatched from an egg, or loaded from the char server when a character who had
410 that pet following them connects) This may occur in some other situations as
411 well. Don't expect anything other than commands definitely marked as usable in
412 pet scripts to work in there reliably.
413
414 Numbers
415 -------
416
417 Beside the common decimal numbers, which are nothing special whatsoever (though
418 do not expect to use fractions, since ALL numbers are integer in this language),
419 the script engine also handles hexadecimal numbers, which are otherwise
420 identical. Writing a number like '0x<hex digits>' will make it recognized as a
421 hexadecimal value. Notice that 0x10 is equal to 16. Also notice that if you try
422 to 'mes 0x10' it will print '16'.
423
424 Number values can't exceed the limits of an integer variable: Any number
425 greater than INT_MAX (2147483647) or smaller than INT_MIN (-2147483648) will
426 be capped to those values and will cause a warning to be reported.
427
428 Variables
429 ---------
430
431 The meat of every programming language is variables - places where you store
432 data.
433
434 In the rAthena scripting language, variable names are not case sensitive.
435
436 Variables are divided into and uniquely identified by the combination of:
437 prefix  - determines the scope and extent (or lifetime) of the variable
438 name    - an identifier consisting of '_' and alphanumeric characters
439 postfix - determines the type of the variable: integer or string
440
441 Scope can be:
442 global    - global to all servers
443 local     - local to the server
444 account   - attached to the account of the character identified by RID
445 character - attached to the character identified by RID
446 npc       - attached to the NPC
447 scope     - attached to the scope of the instance
448
449 Extent can be:
450 permanent - They still exist when the server resets.
451 temporary - They cease to exist when the server resets.
452
453 Prefix: scope and extent
454 nothing  - A permanent variable attached to the character, the default variable
455            type. They are stored by char-server in the `char_reg_num` and
456            `char_reg_str`.
457 "@"      - A temporary variable attached to the character.
458            SVN versions before 2094 revision and RC5 version will also treat
459            'l' as a temporary variable prefix, so beware of having variable
460            names starting with 'l' if you want full backward compatibility.
461 "$"      - A global permanent variable.
462            They are stored by map-server in database table `mapreg`.
463 "$@"     - A global temporary variable.
464            This is important for scripts which are called with no RID
465            attached, that is, not triggered by a specific character object.
466 "."      - A NPC variable.
467            They exist in the NPC and disappear when the server restarts or the
468            NPC is reloaded. Can be accessed from inside the NPC or by calling
469            'getvariableofnpc'. Function objects can also have .variables which
470            are accessible from inside the function, however 'getvariableofnpc'
471            does NOT work on function objects.
472 ".@"     - A scope variable.
473            They are unique to the instance and scope. Each instance has its
474            own scope that ends when the script ends. Calling a function with
475            callsub/callfunc starts a new scope, returning from the function
476            ends it. When a scope ends, its variables are converted to values
477            ('return .@var;' returns a value, not a reference).
478 "'"      - An instance variable.
479            These are used with the instancing system and are unique to each
480            instance type.
481 "#"      - A permanent local account variable.
482            They are stored by char-server in the `acc_reg_num` table and
483            `acc_reg_str`.
484 "##"     - A permanent global account variable stored by the login server.
485            They are stored in the `global_acc_reg_num` table and
486                    `global_acc_reg_str`.
487            The only difference you will note from normal # variables is when
488            you have multiple char-servers connected to the same login server.
489            The # variables are unique to each char-server, while the ## variables
490            are shared by all these char-servers.
491
492 Postfix: integer or string
493 nothing - integer variable, can store positive and negative numbers, but only
494           whole numbers (so don't expect to do any fractional math)
495 '$'     - string variable, can store text
496
497 Examples:
498   name  - permanent character integer variable
499   name$ - permanent character string variable
500  @name  - temporary character integer variable
501  @name$ - temporary character string variable
502  $name  - permanent global integer variable
503  $name$ - permanent global string variable
504 $@name  - temporary global integer variable
505 $@name$ - temporary global string variable
506  .name  - NPC integer variable
507  .name$ - NPC string variable
508 .@name  - scope integer variable
509 .@name$ - scope string variable
510  'name  - instance integer variable
511  'name$ - instance string variable
512  #name  - permanent local account integer variable
513  #name$ - permanent local account string variable
514 ##name  - permanent global account integer variable
515 ##name$ - permanent global account string variable
516
517 If a variable was never set, it is considered to equal zero for integer
518 variables or an empty string ("", nothing between the quotes) for string
519 variables. Once you set it to that, the variable is as good as forgotten
520 forever, and no trace remains of it even if it was stored with character or
521 account data.
522
523 Some variables are special, that is, they are already defined for you by the
524 scripting engine. You can see the full list in 'src/map/script_constants.h', which
525 is a file you should read, since it also allows you to replace lots of numbered
526 arguments for many commands with easier to read text. The special variables most
527 commonly used are all permanent character-based variables:
528
529 Zeny        - Amount of Zeny.
530 Hp          - Current amount of hit points.
531 MaxHp       - Maximum amount of hit points.
532 Sp          - Current spell points.
533 MaxSp       - Maximum amount of spell points.
534 StatusPoint - Amount of status points remaining.
535 SkillPoint  - Amount of skill points remaining.
536 BaseLevel   - Character's base level.
537 JobLevel    - Character's job level.
538 BaseExp     - Amount of base experience points.
539 JobExp      - Amount of job experience points.
540 NextBaseExp - Amount of base experience points needed to reach the next level.
541 NextJobExp  - Amount of job experience points needed to reach the next level.
542 Weight      - Amount of weight the character currently carries.
543 MaxWeight   - Maximum weight the character can carry.
544 Sex         - 0 if female, 1 if male.
545 Class       - Character's job.
546 Upper       - 0 if the character is a normal class, 1 if advanced, 2 if baby.
547 BaseClass   - The character's 1-1 'normal' job, regardless of Upper value.
548               For example, this will return Job_Acolyte for Acolyte, Priest/Monk,
549               High Priest/Champion, and Arch Bishop/Sura. If the character has not
550               reached a 1-1 class, it will return Job_Novice.
551 BaseJob     - The character's 'normal' job, regardless of Upper value.
552               For example, this will return Job_Acolyte for Acolyte,
553               Baby Acolyte, and High Acolyte.
554 Karma       - The character's karma. Karma system is not fully functional, but
555               this doesn't mean this doesn't work at all. Not tested.
556 Manner      - The character's manner rating. Becomes negative if the player
557               utters words forbidden through the use of 'manner.txt' client-side
558               file.
559
560 While these behave as variables, do not always expect to just set them - it is
561 not certain whether this will work for all of them. Whenever there is a command
562 or a function to set something, it's usually preferable to use that instead. The
563 notable exception is Zeny, which you can and often will address directly -
564 setting it will make the character own this number of Zeny.
565 If you try to set Zeny to a negative number, the script will be terminated with an error.
566
567 Some source-end constants can also be accessed in scripts. This list is located in
568 'src/map/script_constants.h', which contains constants such as server defines and status options:
569
570         PACKETVER, MAX_LEVEL, MAX_STORAGE, MAX_INVENTORY, MAX_CART, MAX_ZENY, MAX_PARTY,
571         MAX_GUILD, MAX_GUILDLEVEL, MAX_GUILD_STORAGE, MAX_BG_MEMBERS, MAX_CHAT_USERS,
572         VIP_SCRIPT, MIN_STORAGE
573
574         Option_Nothing, Option_Sight, Option_Hide, Option_Cloak, Option_Falcon, Option_Riding,
575         Option_Invisible, Option_Orcish, Option_Wedding, Option_Chasewalk, Option_Flying,
576         Option_Xmas, Option_Transform, Option_Summer, Option_Dragon1, Option_Wug,
577         Option_Wugrider, Option_Madogear, Option_Dragon2, Option_Dragon3, Option_Dragon4,
578         Option_Dragon5, Option_Hanbok, Option_Oktoberfest, Option_Dragon, Option_Costume
579
580 Assigning variables
581 --------- ---------
582
583 Variables can be accessed and modified much like in other programming languages.
584
585         @x = 100;
586         @x = @y = 100;
587
588 Support for modifying variable values using 'set' is still supported (and required
589 to exist for this new method to work) so previous scripts will continue to work.
590
591 When assigning values, all operator methods are supported which exist in the below
592 'Operators' section. For instance:
593
594         @x += 100;
595         @x -= 100;
596         @x *= 2;
597         @x /= 2;
598         @x %= 5;
599         @x >>= 2;
600         @x <<= 2;
601
602 Will all work. For more information on available operators, see the Operators section
603 described below. All operators listed there may be placed in-front of the '=' sign
604 when modifying variables to perform the action as required.
605
606 Note:
607
608  !! Currently the scripting engine does not support directly copying array variables.
609  !! In order to copy arrays between variables the use of 'copyarray' function is still
610  !! required.
611
612 Strings
613 -------
614
615 To include symbol '"' in a string you should use prefix '\"'
616
617
618 Arrays
619 ------
620
621 Arrays (in rAthena at least) are essentially a set of variables going under the
622 same name. You can tell between the specific variables of an array with an
623 'array index', a number of a variable in that array:
624
625 <variable name>[<array index>]
626
627 All variable types can be used as arrays.
628
629 Variables stored in this way, inside an array, are also called 'array elements'.
630 Arrays are specifically useful for storing a set of similar data (like several
631 item IDs for example) and then looping through it. You can address any array
632 variable as if it was a normal variable:
633
634         set @arrayofnumbers[0],1;
635
636 You can also do things like using a variable (or an expression, or even a
637 value from another array) to get at an array value:
638
639         set @x,100;
640         set @arrayofnumbers[@x],10;
641
642 This will make @arrayofnumbers[100] equal to 10.
643
644 Index numbering always starts with 0 and arrays can hold over 2 billion
645 variables. As such, the (guaranteed) allowed values for indices are in the
646 range 0 ~ 2147483647.
647
648 And array indexes probably can't be negative. Nobody tested what happens when
649 you try to get a negatively numbered variable from an array, but it's not going
650 to be pretty.
651
652 Arrays can naturally store strings:
653
654 @menulines$[0] is the 0th element of the @menulines$ array of strings. Notice
655 the '$', normally denoting a string variable, before the square brackets that
656 denotes an array index.
657
658 Variable References
659 -------------------
660
661 //##TODO
662
663
664
665 Operators
666 ---------
667
668 Operators are things you can do to variables and numbers. They are either the
669 common mathematical operations or conditional operators
670
671 + - will add two numbers. If you try to add two strings, the result will be a
672     string glued together at the +. You can add a number to a string, and the
673     result will be a string. No other math operators work with strings.
674 - - will subtract two numbers.
675 * - will multiply two numbers.
676 / - will divide two numbers. Note that this is an integer division, i.e.
677     7/2 is not equal 3.5, it's equal 3.
678 % - will give you the remainder of the division. 7%2 is equal to 1.
679
680 There are also conditional operators. This has to do with the conditional
681 command 'if' and they are meant to return either 1 if the condition is satisfied
682 and 0 if it isn't. (That's what they call 'boolean' variables. 0 means 'False'.
683 Anything except the zero is 'True' Odd as it is, -1 and -5 and anything below
684 zero will also be True.)
685
686 You can compare numbers to each other and you compare strings to each other, but
687 you can not compare numbers to strings.
688
689  == - Is true if both sides are equal. For strings, it means they are the same.
690  >=  - True if the first value is equal to, or greater than, the second value.
691  <=  - True if the first value is equal to, or less than, the second value
692  >   - True if the first value greater than the second value
693  <   - True if the first value is less than the second value
694  !=  - True if the first value IS NOT equal to the second one
695
696 Examples:
697
698  1 == 1 is True.
699  1<2 is True while 1>2 is False.
700  @x>2 is True if @x is equal to 3. But it isn't true if @x is 2.
701
702 Only ' == ' and '!=' have been tested for comparing strings. Since there's no way
703 to code a seriously complex data structure in this language, trying to sort
704 strings by alphabet would be pointless anyway.
705
706 Comparisons can be stacked in the same condition:
707
708  && - Is True if and only if BOTH sides are true.
709       ('1 == 1 && 2 == 2' is true. '2 == 1 && 1 == 1' is false.)
710  || - Is True if either side of this expression is True.
711
712  1 == 1 && 2 == 2 is True.
713  1 == 1 && 2 == 1 is False.
714  1 == 1 || 2 == 1 is True.
715
716 Logical bitwise operators work only on numbers, and they are the following:
717
718  << - Left shift.
719  >> - Right shift.
720         Left shift moves the binary 1(s) of a number n positions to the left,
721         which is the same as multiplying by 2, n times.
722         In the other hand, Right shift moves the binary 1(s) of a number n positions
723         to the right, which is the same as dividing by 2, n times.
724                 Example:
725                 set b,2;
726                 set a, b << 3;
727                 mes a;
728                 set a, a >> 2;
729                 mes a;
730         The first mes command would display 16, which is the same as 2 x (2 x 2 x 2) = 16.
731         The second mes command would display 4, which is the same as 16 / 2 = 8. 8 / 2 = 4.
732  &  - And.
733  |  - Or.
734         The bitwise operator AND (&) is used to test two values against each other,
735         and results in setting bits which are active in both arguments. This can
736         be used for a few things, but in rAthena this operator is usually used to
737         create bit-masks in scripts.
738
739         The bitwise operator OR (|)sets to 1 a binary position if the binary position
740         of one of the numbers is 1. This way a variable can hold several values we can check,
741         known as bit-mask. A variable currently can hold up to 32 bit-masks (from position 0
742         to position 1). This is a cheap(skate) and easy way to avoid using arrays to store several checks
743         that a player can have.
744
745         A bit-mask basically is (ab)using the variables bits to set various options in
746         one variable. With the current limit if variables it is possible to store 32
747         different options in one variable (by using the bits on position 0 to 31).
748
749         Example(s):
750         - Basic example of the & operator, bit example:
751                 10 & 2 = 2
752         Why? :
753                 10 = 2^1 + 2^3 (2 + 8), so in bits, it would be 1010
754                 2 = 2^1 (2), so in bits (same size) it would be 0010
755                 The & (AND) operator sets bits which are active (1) in both arguments, so in the
756                 example 1010 & 0010, only the 2^1 bit is active (1) in both. Resulting in the bit
757                 0010, which is 2.
758         - Basic example of creating and using a bit-mask:
759                 set @options,2|4|16; //(note: this is the same as 2+4+16, or 22)
760                 if (@options & 1)       mes "Option 1 is activated";
761                 if (@options & 2) mes "Option 2 is activated";
762                 if (@options & 4) mes "Option 3 is activated";
763                 if (@options & 8) mes "Option 4 is activated";
764                 if (@options & 16) mes "Options 5 is activated";
765         This would return the messages about option 2, 3 and 5 being shown (since we've set
766         the 2,4 and 16 bit to 1).
767  ^  - Xor.
768         The bitwise operator XOR (eXclusive OR) sets a binary position to 0 if both
769         numbers have the same value in the said position. On the other hand, it
770         sets to 1 if they have different values in the said binary position.
771         This is another way of setting and unsetting bits in bit-masks.
772
773         Example:
774         - First let's set the quests that are currently in progress:
775                 set inProgress,1|8|16; // quest 1,8 and 16 are in progress
776         - After playing for a bit, the player starts another quest:
777                 if (inProgress&2 == 0) {
778                         // this will set the bit for quest 2 (inProgress has that bit set to 0)
779                         set inProgress,inProgress^2;
780                         mes "Quest 2: find a newbie and be helpful to him for an hour.";
781                         close;
782                 }
783         - After spending some time reading info on Xor's, the player finally completes quest 1:
784                 if (inProgress&1 && isComplete) {
785                         // this will unset the bit for quest 1 (inProgress has that bit set to 1)
786                         set inProgress,inProgress^1;
787                         mes "Quest 1 complete!! You unlocked the secrets of the Xor dynasty, use them wisely.";
788                         close;
789                 }
790
791 Unary operators with only with a single number, which follows the operator, and
792 are following:
793
794  -  - Negation.
795         The sign of the number will be reversed. If the number was positive, it will
796         become negative and vice versa.
797
798         Example:
799                 set .@myvar,10;
800                 mes "Negative 10 is " + (-.@myvar);
801
802  !  - Logical Not.
803         Reverses the boolean result of an expression. True will become false and
804         false will become true.
805
806         Example:
807                 if (!callfunc("F_dosomething"))
808                 {
809                         mes "Doing something failed.";
810                         close;
811                 }
812
813  ~  - Bitwise Not.
814         Reverses each bit in a number, also known as one's complement. Cleared bits
815         are set, and set bits are cleared.
816
817         Example:
818         - Ensure, that quest 2 is disabled, while keeping all other active, if they are.
819                 set inProgress,inProgress&(~2);  // same as set inProgress,inProgress&0xfffffffd
820
821 Ternary operators take three expressions (numbers, strings or boolean), and are
822 following:
823
824  ?: - Conditional operator
825         Very useful e.g. to replace
826
827                 if (Sex) mes "..."; else mes "...";
828
829         clauses with simple
830
831                 mes "Welcome, " + (Sex?"Mr.":"Mrs.") + " " + strcharinfo(0);
832
833         or to replace any other simple if-else clauses. It might be worth
834         mentioning that ?: has low priority and has to be enclosed with
835         parenthesis in most (if not all) cases.
836
837 Labels
838 ------
839
840 Within executable script code, some lines can be labels:
841
842 <label name>:
843
844 Labels are points of reference in your script, which can be used to route
845 execution with 'goto', 'menu' and 'jump_zero' commands, invoked with 'doevent'
846 and 'donpcevent' commands and are otherwise essential. A label's name may not be
847 longer than 22 characters. (23rd is the ':'.) There is some confusion in the
848 source about whether it's 22, 23 or 24 all over the place, so keeping labels
849 under 22 characters could be wise. It may only contain alphanumeric characters
850 and underscore. In addition to labels you name yourself, there are also some
851 special labels which the script engine will start execution from if a special
852 event happens:
853
854 OnClock<hour><minute>:
855 OnMinute<minute>:
856 OnHour<hour>:
857 On<weekday><hour><minute>:
858 OnDay<month><day>:
859
860 This will execute when the server clock hits the specified date or time. Hours
861 and minutes are given in military time. ('0105' will mean 01:05 AM). Weekdays
862 are Sun,Mon,Tue,Wed,Thu,Fri,Sat. Months are 01 to 12, days are 01 to 31.
863 Remember the zero.
864
865 OnInit:
866 OnInterIfInit:
867 OnInterIfInitOnce:
868
869 OnInit will execute every time the scripts loading is complete, including when
870 they are reloaded with @reloadscript command. OnInterIfInit will execute when
871 the map server connects to a char server, OnInterIfInitOnce will only execute
872 once and will not execute if the map server reconnects to the char server later.
873
874 OnAgitStart:
875 OnAgitEnd:
876 OnAgitInit:
877 OnAgitStart2:
878 OnAgitEnd2:
879 OnAgitInit2:
880 OnAgitStart3:
881 OnAgitEnd3:
882 OnAgitInit3:
883
884 OnAgitStart will run whenever the server shifts into WoE mode, whether it is
885 done with @agitstart GM command or with 'AgitStart' script command. OnAgitEnd
886 will do likewise for the end of WoE.
887
888 OnAgitInit will run when data for all castles and all guilds that hold a castle
889 is received by map-server from the char-server after initial connect.
890
891 No RID will be attached while any of the above mentioned labels are triggered, so
892 no character or account-based variables will be accessible, until you attach a
893 RID with 'attachrid' (see below).
894
895 The above also applies to, the last three labels, the only difference is that
896 these labels are used exclusively for WoE SE, and are called independently.
897
898 OnInstanceInit:
899
900 This label will be executed when an instance is created and initialized through
901 the 'instance_create' command. It will run again if @reloadscript is used while
902 an instance is in progress.
903
904 OnInstanceDestroy:
905
906 This label will be executed when an instance is destroyed by a timeout, exceeding
907 the keepalive time or through the 'instance_destroy' command. It will be called
908 exactly before the instance will be destroyed and all other NPCs of the instance
909 will still be available at this point of time.
910
911 OnTouch:
912
913 This label will be executed if a trigger area is defined for the NPC object it's
914 in. If it isn't present, the execution will start from the beginning of the NPC
915 code. The RID of the triggering character object will be attached.
916
917 OnTouch_:
918
919 Similar to OnTouch, but will only run one instance. Another character is
920 chosen once the triggering character leaves the area.
921
922 OnTouchNPC:
923
924 Similar to OnTouch, but will only trigger for monsters. For this case, by using
925 'getattachedrid' will returns GID (ID that returned when use 'monster').
926
927 OnPCLoginEvent:
928 OnPCLogoutEvent:
929 OnPCBaseLvUpEvent:
930 OnPCJobLvUpEvent:
931
932 It's pretty obvious when these four special labels will be invoked.
933
934 OnPCDieEvent:
935
936 This special label triggers when a player dies. The variable 'killerrid' is
937 set to the ID of the killer.
938
939 OnPCKillEvent:
940
941 This special label triggers when a player kills another player. The variable
942 'killedrid' is set to the ID of the player killed.
943
944 OnNPCKillEvent:
945
946 This special label triggers when a player kills a monster without label. The variable
947 'killedrid' is set to the Class (mob ID) of the monster killed.
948
949 OnPCLoadMapEvent:
950
951 This special label triggers when a player steps in a map marked with the
952 'loadevent' mapflag and attaches its RID. The fact that this label requires a
953 mapflag for it to work is because, otherwise, it'd be server-wide and trigger
954 every time a player would change maps. Imagine the server load with 1,000 players
955 (oh the pain...)
956
957 OnPCStatCalcEvent:
958
959 This special label triggers when a player's stats are recalculated, such as when
960 changing stats, equipment, or maps, as well as when logging in, leveling up, and
961 mounting a job mount. This can be used to grant additional item bonuses to certain
962 player groups, for instance.
963
964 OnWhisperGlobal:
965
966 This special label triggers when a player whispers the NPC, and will run with the
967 player's RID attached. It can accept up to ten parameters, which will be stored
968 into separate temporary character string variables @whispervar0$ to @whispervar9$.
969 See 'doc/whisper_sys.txt' for further documentation.
970
971 Only the special labels which are not associated with any script command are
972 listed here. There are other kinds of labels which may be triggered in a similar
973 manner, but they are described with their associated commands.
974
975 On<label name>:
976
977 These special labels are used with Mob scripts mostly, and script commands
978 that requires you to point/link a command to a mob or another NPC, giving a label
979 name to start from. The label name can be any of your liking, but must be
980 started with "On".
981
982 Example:
983
984 monster "prontera",123,42,"Poringz0rd",2341,23,"Master::OnThisMobDeath";
985
986 amatsu,13,152,4 script  Master  767,{
987         mes "Hi there";
988         close;
989
990 OnThisMobDeath:
991         announce "Hey, " + strcharinfo(0) + " just killed a Poringz0rd!",bc_blue|bc_all;
992         end;
993 }
994
995 Each time you kill one, that announce will appear in blue to everyone.
996
997 "Global" labels
998
999 There's a catch with labels and doevent. If you call a label (using doevent)
1000 and called label is in NPC that has trigger area, that label must end with
1001 "Global" to work globally (i.e. if RID is outside of the trigger area, which
1002 usually happens since otherwise there would be no point calling the label with
1003 doevent, because OnTouch would do the job). For further reference look for
1004 npc_event in npc.c.
1005
1006 Scripting commands and functions
1007 --------------------------------
1008
1009 The commands and functions are listed here in no particular order. There's a
1010 difference between commands and functions - commands leave no 'return value'
1011 which might be used in a conditional statement, as a command argument, or stored
1012 in a variable. Calling commands as if they were functions will sometimes work,
1013 but is not advised, as this can lead to some hard to track errors. Calling
1014 functions as if they were commands will mess up the stack, so 'return' command
1015 will not return correctly after this happens in a particular script.
1016
1017 All commands must end with a ';'.
1018
1019 -------------------------
1020
1021
1022 From here on, we will have the commands sorted as follow:
1023
1024 1.- Basic commands.
1025 2.- Information-retrieving commands.
1026 3.- Checking commands.
1027 4.- Player-related commands.
1028 5.- Mob / NPC -related commands.
1029 6.- Other commands.
1030 7.- Instance commands.
1031 8.- Quest Log commands.
1032 9.- Battleground commands.
1033 10.- Pet commands.
1034 10.1.- The Pet AI commands.
1035 11.- Homunculus commands.
1036 12.- Mercenary commands.
1037 13.- Party commands.
1038 14.- Channel commands.
1039 15.- Achievement commands.
1040
1041 =====================
1042 |1.- Basic commands.|
1043 =====================
1044 ---------------------------------------
1045
1046 *mes "<string>"{,"<string>"{,...}};
1047
1048 This command will display a box on the screen for the invoking character, if no
1049 such box is displayed already, and will print the string specified into that
1050 box. There is normally no 'close' or 'next' button on this box, unless you
1051 create one with 'close' or 'next', and while it's open the player can't do much
1052 else, so it's important to create a button later. If the string is empty, it
1053 will show up as an empty line.
1054
1055         mes "Text that will appear in the box";
1056
1057 Colors
1058 ------
1059 Inside the string you may put color codes, which will alter the color of the
1060 text printed after them. The color codes are all '^<R><G><B>' and contain three
1061 hexadecimal numbers representing colors as if they were HTML colors - ^FF0000 is
1062 bright red, ^00FF00 is bright green, ^0000FF is bright blue, ^000000 is black.
1063 ^FF00FF is a pure magenta, but it's also a color that is considered transparent
1064 whenever the client is drawing windows on screen, so printing text in that color
1065 will have kind of a weird effect. Once you've set a text's color to something,
1066 you have to set it back to black unless you want all the rest of the text be in
1067 that color:
1068
1069         mes "This is ^FF0000 red ^000000 and this is ^00FF00 green, ^000000 so.";
1070
1071 Notice that the text coloring is handled purely by the client. If you use non-
1072 English characters, the color codes might get screwed if they stick to letters
1073 with no intervening space. Separating them with spaces from the letters on
1074 either side solves the problem.
1075
1076 Multiple Lines
1077 --------------
1078 To display multiple lines of message while only using a single 'mes' command,
1079 use the script command in the following format:
1080
1081         mes "Line 1", "Line 2", "Line 3";
1082
1083 This will display 3 different lines while only consuming a single line in
1084 the relevant script file.
1085
1086 Navigation
1087 ----------
1088 For clients dated 2011-10-10aRagexe onwards, you can generate navigation links
1089 using HTML-like labels:
1090
1091         <NAVI>Display Name<INFO>mapname,x,y,0,000,flag</INFO></NAVI>
1092
1093 The "flag" parameter can be:
1094  0: Do not open Navigation Window (default).
1095  1: Open Navigation Window.
1096
1097 The example below will make the [Tool Shop] text clickable and begin navigation
1098 to alberta (98,154) when clicked.
1099
1100         mes "Have you checked out the <NAVI>[Tool Shop]<INFO>alberta,98,154,0,000,0</INFO></NAVI>?";
1101
1102 See also 'navigateto', which can be used for certain NPC events.
1103
1104 Items
1105 -----
1106 You can refer to items by using HTML-like links to certain items:
1107
1108         <ITEMLINK>Display Name<INFO>Item ID</INFO></ITEMLINK>
1109
1110 Where <Display Name> is the name that will be displayed for your link and
1111 <Item ID> being the ID of the item you want to link to when clicked.
1112
1113 In 2015 the tag name was changed to <ITEM> resulting in the following syntax:
1114
1115         <ITEM>Display Name<INFO>Item ID</INFO></ITEM>
1116
1117 The following sample will open a preview window for Red Potion:
1118
1119         mes "Did you ever consume a <ITEMLINK>Red Potion<INFO>501</INFO></ITEMLINK>?";
1120         // Or in 2015:
1121         mes "Did you ever consume a <ITEM>Red Potion<INFO>501</INFO></ITEM>?";
1122
1123 NOTE: Be aware that item links are rendered incorrectly in 2015+ clients at the moment.
1124
1125 URLs
1126 ----
1127 Similarly, you can create links to websites that launch in a new window:
1128
1129         <URL>Display Name<INFO>http://www.example.com/</INFO></URL>";
1130
1131 ---------------------------------------
1132
1133 *next;
1134
1135 This command will display a 'next' button in the message window for the
1136 invoking character. Clicking on it will cause the window to clear and display
1137 a new one. Used to segment NPC-talking, next is often used in combination with
1138 'mes' and 'close'.
1139
1140 If no window is currently on screen, one will be created, but once the invoking
1141 character clicks on it, a warning is thrown on the server console and the script
1142 will terminate.
1143
1144         mes "[Woman]";
1145         mes "This would appear on the page";
1146         next;
1147         // This is needed since it is a new page and the top will now be blank
1148         mes "[Woman]";
1149         mes "This would appear on the 2nd page";
1150
1151 ---------------------------------------
1152
1153 *close;
1154
1155 This command will create a 'close' button in the message window for the invoking
1156 character. If no window is currently on screen, the script execution will end. This is one
1157 of the ways to end a speech from an NPC. Once the button is clicked, the NPC
1158 script execution will end, and the message box will disappear.
1159
1160         mes "[Woman]";
1161         mes "I am finished talking to you. Click the close button.";
1162         close;
1163         mes "This command will not run at all, since the script has ended.";
1164
1165 ---------------------------------------
1166
1167 *close2;
1168
1169 This command will create a 'close' button in the message window for the invoking
1170 character. WARNING: If no window is currently on screen, the script execution will halt
1171 indefinitely! See 'close'. There is one important difference, though - even though
1172 the message box will have closed, the script execution will not stop, and commands after
1173 'close2' will still run, meaning an 'end' has to be used to stop the script, unless you
1174 make it stop in some other manner.
1175
1176         mes "[Woman]";
1177         mes "I will warp you now.";
1178         close2;
1179         warp "place",50,50;
1180         end;
1181
1182 Don't expect things to run smoothly if you don't make your scripts 'end'.
1183
1184 ---------------------------------------
1185
1186 *end;
1187
1188 This command will stop the execution for this particular script. The two
1189 versions are perfectly equivalent. It is the normal way to end a script which
1190 does not use 'mes'.
1191
1192         if (BaseLevel <= 10)
1193                 npctalk "Look at that you are still a n00b";
1194         else if (BaseLevel <= 20)
1195                 npctalk "Look at that you are getting better, but still a n00b";
1196         else if (BaseLevel <= 30)
1197                 npctalk "Look at that you are getting there, you are almost 2nd profession now right???";
1198         else if (BaseLevel <= 40)
1199                 npctalk "Look at that you are almost 2nd profession";
1200         end;
1201
1202 Without the use of 'end' it would travel through the labels until the end of the
1203 script. If you were lvl 10 or less, you would see all the speech lines, the use
1204 of 'end' stops this, and ends the script.
1205
1206 ---------------------------------------
1207
1208 *set <variable>,<expression>{,<char_id>};
1209 *set(<variable>,<expression>{,<char id>})
1210
1211 This command will set a variable to the value that the expression results in.
1212 Variables may either be set through this command or directly, much like any
1213 other programming language (refer to the "Assigning variables" section).
1214
1215 This is the most basic script command and is used a lot whenever you try to do
1216 anything more advanced than just printing text into a message box.
1217
1218         set @x,100;
1219
1220 will make @x equal 100.
1221
1222         set @x,1+5/8+9;
1223
1224 will compute 1+5/8+9 (which is, surprisingly, 10 - remember, all numbers are
1225 integer in this language) and make @x equal it.
1226
1227 Returns the variable reference (since trunk r12870).
1228
1229 ---------------------------------------
1230
1231 *setd "<variable name>",<value>{,<char_id>};
1232
1233 Works almost identically as set, except the variable name is identified as a string
1234 and can thus be constructed dynamically.
1235
1236 This command is equivalent to:
1237         set getd("variable name"),<value>;
1238
1239 Examples:
1240
1241         setd ".@var$", "Poporing";
1242         mes .@var$; // Displays "Poporing".
1243
1244         setd ".@" + .@var$ + "123$", "Poporing is cool";
1245         mes .@Poporing123$; // Displays "Poporing is cool".
1246
1247 NOTE:
1248         'char_id' only works for non-server variables.
1249         Player with Character ID 'char_id' must be online.
1250
1251 ---------------------------------------
1252
1253 *getd("<variable name>")
1254
1255 Returns a reference to a variable, the name can be constructed dynamically.
1256 Refer to 'setd' for usage.
1257
1258 This can also be used to set an array dynamically:
1259         setarray getd(".array[0]"), 1, 2, 3, 4, 5;
1260
1261 Examples:
1262
1263         set getd("$varRefence"), 1;
1264         set @i, getd("$" + "pikachu");
1265
1266 ---------------------------------------
1267
1268 *getvariableofnpc(<variable>,"<npc name>")
1269
1270 Returns a reference to a NPC variable (. prefix) from the target NPC.
1271 This can only be used to get . variables.
1272
1273 Examples:
1274
1275 //This will return the value of .var, note that this can't be used, since the value isn't caught.
1276         getvariableofnpc(.var,"TargetNPC");
1277
1278 //This will set the .v variable to the value of the TargetNPC's .var variable.
1279         set .v, getvariableofnpc(.var,"TargetNPC");
1280
1281 //This will set the .var variable of TargetNPC to 1.
1282         set getvariableofnpc(.var,"TargetNPC"), 1;
1283
1284 Note: even though function objects can have .variables,
1285 getvariableofnpc will not work on them.
1286
1287 ---------------------------------------
1288
1289 *getvar <variable>,<char_id>;
1290
1291 Get variable value from the specified player. Only player/account variables
1292 are allowed to be used (temporary character variable "@", permanent
1293 character "", permanent local account "#", and permanent global account "##").
1294
1295 ---------------------------------------
1296
1297 *goto <label>;
1298
1299 This command will make the script jump to a label, usually used in conjunction
1300 with other command, such as "if", but often used on its own.
1301
1302         ...
1303         goto Label;
1304
1305         mes "This will not be seen";
1306         end;
1307 Label:
1308         mes "This will be seen";
1309         end;
1310
1311 This command should be avoided and only used if there is no other option.
1312
1313 ---------------------------------------
1314
1315 *menu "<option_text>",<target_label>{,"<option_text>",<target_label>,...};
1316
1317 This command will create a selectable menu for the invoking character. Only one
1318 menu can be on screen at the same time.
1319
1320 Depending on what the player picks from the menu, the script execution will
1321 continue from the corresponding label. (it's string-label pairs, not label-
1322 string)
1323
1324 Options can be grouped together, separated by the character ':'.
1325
1326         menu "A:B",L_Wrong,"C",L_Right;
1327
1328 It also sets a special temporary character variable @menu, which contains the
1329 number of option the player picked. (Numbering of options starts at 1.)
1330 This number is consistent with empty options and grouped options.
1331
1332         menu "A::B",L_Wrong,"",L_Impossible,"C",L_Right;
1333
1334         L_Wrong:
1335                 // If they click "A" or "B" they will end up here
1336                 // @menu == 1 if "A"
1337                 // @menu == 2 will never happen because the option is empty
1338                 // @menu == 3 if "B"
1339         L_Impossible:
1340                 // Empty options are not displayed and therefore can't be selected
1341                 // this label will never be reached from the menu command
1342         L_Right:
1343                 // If they click "C" they will end up here
1344                 // @menu == 5
1345
1346 If a label is '-', the script execution will continue right after the menu
1347 command if that option is selected, this can be used to save you time, and
1348 optimize big scripts.
1349
1350         menu "A::B:",-,"C",L_Right;
1351                 // If they click "A" or "B" they will end up here
1352                 // @menu == 1 if "A"
1353                 // @menu == 3 if "B"
1354         L_Right:
1355                 // If they click "C" they will end up here
1356                 // @menu == 5
1357
1358 Both these examples will perform the exact same task.
1359
1360 If you give an empty string as a menu item, the item will not display. This
1361 can effectively be used to script dynamic menus by using empty string for
1362 entries that should be unavailable at that time.
1363
1364 You can do it by using arrays, but watch carefully - this trick isn't high
1365 wizardry, but minor magic at least. You can't expect to easily duplicate it
1366 until you understand how it works.
1367
1368 Create a temporary array of strings to contain your menu items, and populate it
1369 with the strings that should go into the menu at this execution, making sure not
1370 to leave any gaps. Normally, you do it with a loop and an extra counter, like
1371 this:
1372
1373         setarray @possiblemenuitems$[0],<list of potential menu items>;
1374         @j = 0; // That's the menu lines counter.
1375
1376         // We loop through the list of possible menu items.
1377         // @i is our loop counter.
1378         for( @i = 0; @i < getarraysize(@possiblemenuitems$); @i++ )
1379         {
1380                 // That 'condition' is whatever condition that determines whether
1381                 // a menu item number @i actually goes into the menu or not.
1382
1383                 if (<condition>)
1384                 {
1385                         // We record the option into the list of options actually available.
1386
1387                         @menulist$[@j] = @possiblemenuitems$[@i];
1388
1389                         // We just copied the string, we do need its number for later
1390                         // though, so we record it as well.
1391
1392                         @menureference[@j] = @i;
1393
1394                         // Since we've just added a menu item into the list, we increment
1395                         // the menu lines counter.
1396
1397                         @j++;
1398                 }
1399
1400                 // We go on to the next possible menu item.
1401         }
1402
1403 This will create you an array @menulist$ which contains the text of all items
1404 that should actually go into the menu based on your condition, and an array
1405 @menureference, which contains their numbers in the list of possible menu items.
1406 (Remember, arrays start with 0.) There's less of them than the possible menu
1407 items you've defined, but the menu command can handle the empty lines - only if
1408 they are last in the list, and if it's made this way, they are. Now comes a
1409 dirty trick:
1410
1411         // X is whatever the most menu items you expect to handle.
1412         menu @menulist$[0],-,@menulist$[1],-,....@menulist$[<X>],-;
1413
1414 This calls up a menu of all your items. Since you didn't copy some of the
1415 possible menu items into the list, its end is empty and so no menu items will
1416 show up past the end. But this menu call doesn't jump anywhere, it just
1417 continues execution right after the menu command. (And it's a good thing it
1418 doesn't, cause you can only explicitly define labels to jump to, and how do you
1419 know which ones to define if you don't know beforehand which options will end up
1420 where in your menu?)
1421 But how do you figure out which option the user picked? Enter the @menu.
1422
1423 @menu contains the number of option that the user selected from the list,
1424 starting with 1 for the first option. You know now which option the user picked
1425 and which number in your real list of possible menu items it translated to:
1426
1427     mes "You selected " + @possiblemenuitems$[@menureference[@menu-1]] + "!";
1428
1429 @menu is the number of option the user picked.
1430 @menu-1 is the array index for the list of actually used menu items that we
1431 made.
1432 @menureference[@menu-1] is the number of the item in the array of possible menu
1433 items that we've saved just for this purpose.
1434
1435 And @possiblemenuitems$[@menureference[@menu-1]] is the string that we used to
1436 display the menu line the user picked. (Yes, it's a handful, but it works.)
1437
1438 You can set up a bunch of 'if (@menureference[@menu-1] == X) goto Y' statements to
1439 route your execution based on the line selected and still generate a different
1440 menu every time, which is handy when you want to, for example, make users select
1441 items in any specific order before proceeding, or make a randomly shuffled menu.
1442
1443 Kafra code bundled with the standard distribution uses a similar array-based
1444 menu technique for teleport lists, but it's much simpler and doesn't use @menu,
1445 probably since that wasn't documented anywhere.
1446
1447 See also 'select', which is probably better in this particular case. Instead of
1448 menu, you could use 'select' like this:
1449
1450     @dummy = select(@menulist$[0],@menulist$[1],....@menulist$[<X>]);
1451
1452 For the purposes of the technique described above these two statements are
1453 perfectly equivalent.
1454
1455 ---------------------------------------
1456
1457 *select("<option>"{,"<option>",...})
1458 *prompt("<option>"{,"<option>",...})
1459
1460 This function is a handy replacement for 'menu' for some specific cases where
1461 you don't want a complex label structure - like, for example, asking simple yes-
1462 no questions. It will return the number of menu option picked, starting with 1.
1463 Like 'menu', it will also set the variable @menu to contain the option the user
1464 picked.
1465
1466     if (select("Yes:No" ) == 1)
1467                 mes "You said yes, I know.";
1468
1469 And like 'menu', the selected option is consistent with grouped options
1470 and empty options.
1471
1472 'prompt' works almost the same as select, except that when a character clicks
1473 the Cancel button, this function will return 255 instead.
1474
1475 ---------------------------------------
1476
1477 *input(<variable>{,<min>{,<max>}})
1478
1479 This command will make an input box pop up on the client connected to the
1480 invoking character, to allow entering of a number or a string. This has many
1481 uses, one example would be a guessing game, also making use of the 'rand'
1482 function:
1483
1484         mes "[Woman]";
1485         mes "Try and guess the number I am thinking of.";
1486         mes "The number will be between 1 and 10.";
1487         next;
1488         .@number = rand(1,10);
1489         input .@guess;
1490         if (.@guess == .@number) {
1491                 mes "[Woman]";
1492                 mes "Well done, that was the number I was thinking of!";
1493                 close;
1494         } else {
1495                 mes "[Woman]";
1496                 mes "Sorry, that wasn't the number I was thinking of.";
1497                 close;
1498         }
1499
1500 If you give the input command a string variable to put the input in, it will
1501 allow the player to enter text. Otherwise, only numbers will be allowed.
1502
1503         mes "[Woman]";
1504         mes "Please say HELLO";
1505         next;
1506         input .@var$;
1507         if (.@var$ == "HELLO") {
1508                 mes "[Woman]";
1509                 mes "Well done, you typed it correctly.";
1510                 close;
1511         } else {
1512                 mes "[Woman]";
1513                 mes "Sorry, you got it wrong.";
1514                 close;
1515         }
1516
1517 Normally you may not input a negative number with this command.
1518 This is done to prevent exploits in badly written scripts, which would
1519 let people, for example, put negative amounts of Zeny into a bank script and
1520 receive free Zeny as a result.
1521
1522 Since trunk r12192 the command has two optional arguments and a return value.
1523 The default value of 'min' and 'max' can be set with 'input_min_value' and
1524 'input_max_value' in script_athena.conf.
1525 For numeric inputs the value is capped to the range [min,max]. Returns 1 if
1526 the value was higher than 'max', -1 if lower than 'min' and 0 otherwise.
1527 For string inputs it returns 1 if the string was longer than 'max', -1 is
1528 shorter than 'min' and 0 otherwise.
1529
1530 ---------------------------------------
1531
1532 *callfunc "<function>"{,<argument>,...<argument>};
1533 *callfunc("<function>"{,<argument>,...<argument>})
1534
1535 This command lets you call up a function NPC. A function NPC can be called from
1536 any script on any map server. Using the 'return' command it will come back to
1537 the place that called it.
1538
1539         place,50,50,6%TAB%script%TAB%Woman%TAB%115,{
1540                 mes "[Woman]"
1541                 mes "Let's see if you win...";
1542                 callfunc "funcNPC";
1543                 mes "Well done, you have won!";
1544                 close;
1545         }
1546         function%TAB%script%TAB%funcNPC%TAB%{
1547                 .@win = rand(2);
1548                 if (.@win == 0)
1549                         return;
1550                 mes "Sorry, you lost.";
1551                 close;
1552         }
1553
1554 You can pass arguments to your function - values telling it what exactly to do -
1555 which will be available there with getarg() (see 'getarg')
1556 Notice that returning is not mandatory, you can end execution right there.
1557
1558 If you want to return a real value from inside your function NPC, it is better
1559 to write it in the function form, which will also work and will make the script
1560 generally cleaner:
1561
1562         place,50,50,6%TAB%script%TAB%Man%TAB%115,{
1563                 mes "[Man]"
1564                 mes "Gimme a number!";
1565                 next;
1566                 input @number;
1567                 if (callfunc("OddFunc",@number)) mes "It's Odd!";
1568                 close;
1569         }
1570         function%TAB%script%TAB%OddFunc%TAB%{
1571                 if (getarg(0)%2 == 0)
1572                         return 0;// it's even
1573                 return 1;// it's odd
1574         }
1575
1576 Alternately, as of rAthena revision 15979 and 15981, user-defined functions
1577 may be called directly without the use of the 'callfunc' script command.
1578
1579         function<tab>script<tab>SayHello<tab>{
1580                 mes "Hello " + getarg(0);
1581                 return 0;
1582         }
1583
1584         place,50,50,6<tab>script<tab>Man<tab>115,{
1585                 mes "[Man]";
1586                 SayHello strcharinfo(0);
1587                 close;
1588         }
1589
1590 Note:
1591
1592  !! A user-defined function must be declared /before/ a script attempts to
1593  !! call it. That is to say, any functions should be placed above scripts or NPCs
1594  !! (or loaded in a separate file first) before attempting to call them directly.
1595
1596 ---------------------------------------
1597
1598 *callsub <label>{,<argument>,...<argument>};
1599 *callsub(<label>{,<argument>,...<argument>})
1600
1601 This command will go to a specified label within the current script (do NOT use
1602 quotes around it) coming in as if it were a 'callfunc' call, and pass it
1603 arguments given, if any, which can be recovered there with 'getarg'. When done
1604 there, you should use the 'return' command to go back to the point from where
1605 this label was called. This is used when there is a specific thing the script
1606 will do over and over, this lets you use the same bit of code as many times as
1607 you like, to save space and time, without creating extra NPC objects which are
1608 needed with 'callfunc'. A label is not callable in this manner from another
1609 script.
1610
1611 Example 1: callsub for checking (if checks pass, return to script)
1612         callsub S_CheckFull, "guild_vs2",50;
1613         switch( rand(4) ) {
1614                 case 0: warp "guild_vs2",9,50;  end;
1615                 case 1: warp "guild_vs2",49,90; end;
1616                 case 2: warp "guild_vs2",90,50; end;
1617                 case 3: warp "guild_vs2",49,9;  end;
1618         }
1619
1620 ...
1621
1622 S_CheckFull:
1623         if (getmapusers(getarg(0)) >= getarg(1)) {
1624                 mes "I'm sorry, this arena is full.  Please try again later.";
1625                 close;
1626         }
1627         return;
1628
1629 Example 2: callsub used repeatedly, with different arguments
1630 // notice how the Zeny check/delete is reused, instead of copy-pasting for every warp
1631         switch(select("Abyss Lake:Amatsu Dungeon:Anthell:Ayothaya Dungeon:Beacon Island, Pharos") {
1632                 case 1: callsub S_DunWarp,"hu_fild05",192,207;
1633                 case 2: callsub S_DunWarp,"ama_in02",119,181;
1634                 case 3: callsub S_DunWarp,"moc_fild20",164,145;
1635                 case 4: callsub S_DunWarp,"ayo_fild02",279,150;
1636                 case 5: callsub S_DunWarp,"cmd_fild07",132,125;
1637                 // etc
1638         }
1639
1640 ...
1641
1642 S_DunWarp:
1643 // getarg(0) = "map name"
1644 // getarg(1) = x
1645 // getarg(2) = y
1646         if (Zeny >= 100) {
1647                 Zeny -= 100;
1648                 warp getarg(0),getarg(1),getarg(2);
1649         } else {
1650                 mes "Dungeon warp costs 100 Zeny.";
1651         }
1652         close;
1653
1654 ---------------------------------------
1655
1656 *getarg(<index>{,<default_value>})
1657
1658 This function is used when you use the 'callsub' or 'callfunc' commands. In the
1659 call you can specify variables that will make that call different from another
1660 one. This function will return an argument the function or subroutine was
1661 called with, and is the normal way to get them.
1662 This is another thing that can let you use the same code more than once.
1663
1664 Argument numbering starts with 0, i.e. the first argument you gave is number 0.
1665 If no such argument was given, a zero is returned.
1666
1667         place,50,50,6%TAB%script%TAB%Woman1%TAB%115,{
1668                 mes "[Woman]";
1669                 mes "Let's see if you win...";
1670                 callfunc "funcNPC",2;
1671                 mes "Well done, you have won!";
1672                 close;
1673         }
1674
1675         place,52,50,6%TAB%script%TAB%Woman2%TAB%115,{
1676                 mes "[Woman]";
1677                 mes "Let's see if you win...";
1678                 callfunc "funcNPC",5;
1679                 mes "Well done, you have won!";
1680                 close;
1681         }
1682
1683         function%TAB%script%TAB%funcNPC%TAB%{
1684                 .@win = rand(getarg(0));
1685                 if (.@win == 0) return;
1686                 mes "Sorry, you lost.";
1687                 close;
1688         |
1689
1690 "woman1" NPC object calls the funcNPC. The argument it gives in this call is
1691 stated as 2, so when the random number is generated by the 'rand' function, it
1692 can only be 0 or 1. Whereas "woman2" gives 5 as the argument number 0 when
1693 calling the function, so the random number could be 0, 1, 2, 3 or 4, this makes
1694 "woman2" less likely to say the player won.
1695
1696 You can pass multiple arguments in a function call:
1697
1698         callfunc "funcNPC",5,4,3;
1699
1700 getarg(0) would be 5, getarg(1) would be 4 and getarg(2) would be 3.
1701
1702 'getarg' has an optional argument since trunk r10773 and stable r10958.
1703 If the target argument exists, it is returned.
1704 Otherwise, if <default_value> is present it is returned instead,
1705 if not the script terminates immediately.
1706
1707 In the previous example getarg(2,-1) would be 3 and getarg(3,-1) would be -1.
1708
1709 ---------------------------------------
1710
1711 *getargcount()
1712
1713 This function is used when you use the 'callsub' or 'callfunc' commands. In the
1714 call you can specify arguments. This function will return the number of arguments
1715 provided.
1716
1717 Example:
1718         callfunc "funcNPC",5,4,3;
1719         ...
1720         function%TAB%script%TAB%funcNPC%TAB%{
1721                 .@count = getargcount(); // 3
1722                 ...
1723         }
1724
1725 ---------------------------------------
1726
1727 *return {<value>};
1728
1729 This command causes the script execution to leave previously called function
1730 with callfunc or script with callsub and return to the location, where the call
1731 originated from. Optionally a return value can be supplied, when the call was
1732 done using the function form.
1733
1734 Using this command outside of functions or scripts referenced by callsub will
1735 result in error and termination of the script.
1736
1737         callfunc "<your function>";// when nothing is returned
1738         set <variable>,callfunc("<your function>");// when a value is being returned
1739
1740 ---------------------------------------
1741
1742 *function <function name>;
1743 *<function name>{(<argument>,...<argument>)};
1744 *function <function name> {
1745 <code>
1746 }
1747
1748 This works like callfunc, and is used for cleaner and faster scripting. The function
1749 must be defined and used within a script, and works like a label with arguments.
1750 Note that the name may only contain alphanumeric characters and underscore.
1751
1752 Usage:
1753
1754     1. Declare the function.
1755         function <function name>;
1756     2. Call the function anywhere within the script.
1757        It can also return a value when used with parentheses.
1758         <function name>;
1759     3. Define the function within the script.
1760         <function name> {<code>}
1761
1762 Example:
1763
1764 prontera,154,189,4      script  Item Seller     767,{
1765         /* Function declaration */
1766         function SF_Selling;
1767
1768         if (Zeny > 50) {
1769                 mes "Welcome!";
1770                 /* Function call */
1771                 SF_Selling;
1772         }
1773         else mes "You need 50z, sorry!";
1774         close;
1775
1776         /* Function definition */
1777         function SF_Selling {
1778                 mes "Would you like to buy a phracon for 50z?";
1779                 next;
1780                 if (select("Yes","No, thanks") == 1) {
1781                         Zeny -= Zeny;
1782                         getitem 1010,1;
1783                         mes "Thank you!";
1784                 }
1785                 return;
1786         }
1787 }
1788
1789 Example with parameters and return value:
1790
1791 prontera,150,150,0      script  TestNPC 123,{
1792         /* Function declaration */
1793         function MyAdd;
1794
1795         mes "Enter two numbers.";
1796         next;
1797         input .@a;
1798         input .@b;
1799         /* Function call */
1800         mes .@a + " + " + .@b + " = " + MyAdd(.@a,.@b);
1801         close;
1802
1803         /* Function definition */
1804         function MyAdd {
1805                 return getarg(0)+getarg(1);
1806         }
1807 }
1808
1809
1810 ---------------------------------------
1811
1812 *is_function("<function name>")
1813
1814 This command checks whether a function exists.
1815 It returns 1 if function is found, or 0 if it isn't.
1816
1817 Example:
1818
1819         function        script  try     {
1820                 dothat;
1821         }
1822
1823         -       script  test    -1,{
1824                 .@try = is_function("try"); // 1
1825                 .@not = is_function("not"); // 0
1826         }
1827
1828 ---------------------------------------
1829
1830 *if (<condition>) <statement>;
1831
1832 This is the basic conditional statement command, and just about the only one
1833 available in this scripting language.
1834
1835 The condition can be any expression. All expressions resulting in a non-zero
1836 value will be considered True, including negative values. All expressions
1837 resulting in a zero are false.
1838
1839 If the expression results in True, the statement will be executed. If it isn't
1840 true, nothing happens and we move on to the next line of the script.
1841
1842     if (1)  mes "This will always print.";
1843     if (0)  mes "And this will never print.";
1844     if (5)  mes "This will also always print.";
1845     if (-1) mes "Funny as it is, this will also print just fine.";
1846
1847 For more information on conditional operators see the operators section above.
1848 Anything that is returned by a function can be used in a condition check without
1849 bothering to store it in a specific variable:
1850
1851     if (strcharinfo(0) == "Daniel Jackson") mes "It is true, you are Daniel!";
1852
1853 More examples of using the 'if' command in the real world:
1854
1855 Example 1:
1856
1857         .@answer = 1;
1858         input .@input;
1859         if (.@input == .@answer)
1860                 close;
1861         mes "Sorry, your answer is incorrect.";
1862         close;
1863
1864 Example 2:
1865
1866         .@answer = 1;
1867         input .@input;
1868         if (.@input != .@answer)
1869                 mes "Sorry, your answer is incorrect.";
1870         close;
1871
1872 Notice that examples 1 and 2 have the same effect.
1873
1874 Example 3:
1875
1876         @count++;
1877         mes "[Forgetful Man]";
1878         if (@count == 1) mes "This is the first time you have talked to me.";
1879         if (@count == 2) mes "This is the second time you have talked to me.";
1880         if (@count == 3) mes "This is the third time you have talked to me.";
1881         if (@count == 4) {
1882                 mes "This is the fourth time you have talked to me.";
1883                 mes "I think I am getting amnesia, I have forgotten about you...";
1884                 @count = 0;
1885         }
1886         close;
1887
1888 Example 4:
1889
1890         mes "[Quest Person]";
1891         if (countitem(512) < 1) {  // 512 is the item ID for Apple, found in item_db
1892                 mes "Can you please bring me an apple?";
1893                 close;
1894         }
1895         mes "Oh, you brought an Apple!";
1896         mes "I didn't want it, I just wanted to see one.";
1897         close;
1898
1899 Example 5:
1900
1901         mes "[Person Checker]";
1902         if ($@name$ == "") {  // global variable not yet set
1903                 mes "Please tell me someones name";
1904                 next;
1905                 input $@name$;
1906                 $@name2$ = strcharinfo(0);
1907                 mes "[Person Checker]";
1908                 mes "Thank you.";
1909                 close;
1910         }
1911         if ($@name$ == strcharinfo(0)) {  // player name matches $@name$
1912                 mes "You are the person that " + $@name2$ + " just mentioned.";
1913                 mes "Nice to meet you!";
1914
1915                 // reset the global variables
1916                 $@name$ = "";
1917                 $@name2$ = "";
1918
1919                 close;
1920         }
1921         mes "You are not the person that " + $name2$ + " mentioned.";
1922         close;
1923
1924 See 'strcharinfo' for an explanation of what this function does.
1925
1926 Example 6: Using complex conditions.
1927
1928         mes "[Multiple Checks]";
1929         if (@queststarted == 1 && countitem(512) >= 5) {
1930                 mes "Well done, you have started the quest and brought me 5 Apples.";
1931                 @queststarted = 0;
1932                 delitem 512,5;
1933                 close;
1934         }
1935         mes "Please bring me 5 apples.";
1936         @queststarted = 1;
1937         close;
1938
1939 The script engine also supports nested 'if' statements:
1940
1941         if (<condition>)
1942                 dothis;
1943         else
1944                 dothat;
1945
1946 If the condition isn't met, it'll do the action following the 'else'.
1947 We can also group several actions depending on a condition:
1948
1949         if (<condition>) {
1950                 dothis1;
1951                 dothis2;
1952         } else {
1953                 dothat1;
1954                 dothat2;
1955                 dothat3;
1956         }
1957
1958 Remember that if you plan to do several actions upon the condition being false, and
1959 you forget to use the curly braces (the { } ), the second action will be executed regardless
1960 the output of the condition, unless of course, you stop the execution of the script if the
1961 condition is true (that is, in the first grouping using a return; , and end; or a close; )
1962
1963 Also, you can have multiple conditions nested or chained.
1964
1965         if (<condition 1>)
1966                 dothis;
1967         else if (<condition 2>) {
1968                 dothat;
1969                 end;
1970         } else
1971                 dothis;
1972
1973 ---------------------------------------
1974
1975 *jump_zero (<condition>),<label>;
1976
1977 This command works kinda like an 'if'+'goto' combination in one go. (See 'if').
1978 If the condition is false (equal to zero) this command will immediately jump to
1979 the specified label like in 'goto'. While 'if' is more generally useful, for
1980 some cases this could be an optimization.
1981
1982 The main reason for this command is that other control statements, like
1983 'switch', 'for' or 'while', are disassembled into simple expressions together
1984 with this command when a script is parsed.
1985
1986 ---------------------------------------
1987
1988 *switch (expression);
1989
1990 The switch statement is similar to a series of if statements on the same expression.
1991 In many occasions, you may want to compare the same variable (or expression)
1992 with many different values, and execute a different piece of code depending
1993 on which value it equals to. This is exactly what the switch statement is for.
1994
1995 It is important to understand how the switch statement is executed in order
1996 to avoid mistakes. The switch statement executes line by line (actually, statement by statement).
1997 In the beginning, no code is executed. Only when a case statement is found
1998 with a value that matches the value of the switch expression the case statement(s)
1999 will to executed. The parser continues to execute the statements until the end
2000 of the switch block, or the first time it sees a break statement. If you don't
2001 write a break statement at the end of a case's statement list, the parser will
2002 go on executing the statements of the following case (fall-through).
2003
2004 Example 1:
2005
2006         switch(select("Yes:No")) {
2007                 case 1:
2008                         mes "You said yes!";
2009                         break;
2010                 case 2:
2011                         mes "Aww, why?";
2012                         break;
2013         }
2014         close;
2015
2016 The example above would work like a menu and would go to the first case if
2017 the user selects option, otherwise, would go to the second one.
2018
2019 Example 2:
2020
2021         switch(getgroupid()) {
2022                 case 1:
2023                         mes "Wow, you're super!";
2024                         break;
2025                 case 2:
2026                         mes "A helping hand!";
2027                         break;
2028                 case 3:
2029                         mes "10001010010011";
2030                         break;
2031                 case 4:
2032                         mes "Yes, milord?";
2033                         break;
2034                 default:
2035                         mes "Hello there!";
2036                         break;
2037         }
2038
2039 The example above would print a message depending on the player's groupid.
2040 If there is no statement declared for the corresponding groupid, the script
2041 would use the 'default' statement that applies to rest of possible values,
2042 similar to 'else' in the if-else statement.
2043
2044 ---------------------------------------
2045
2046 *while (<condition>) <statement>;
2047
2048 This is probably the simplest and most frequently used loop structure. The 'while'
2049 statement can be interpreted as "while <condition> is true, perform <statement>".
2050 It is a pretest loop, meaning the conditional expression is tested before any of the
2051 statements in the body of the loop are performed. If the condition evaluates to
2052 false, the statement(s) in the body of the loop is/are never executed. If the
2053 condition evaluates to true, the statement(s) are executed, then control transfers
2054 back to the conditional expression, which is reevaluated and the cycle continues.
2055
2056 Multiple statements can be grouped with { }, curly braces, just like with the 'if' statement.
2057
2058 Example 1:
2059         while (switch(select("Yes:No") == 2 ))
2060                 mes "You picked no.";
2061         close;
2062
2063 Example 2: multiple statements
2064         while (switch(select("Yes:No") == 2 )) {
2065                 mes "Why did you pick no?";
2066                 mes "You should pick yes instead!";
2067         }
2068         close;
2069
2070 Example 3: counter-controlled loop
2071         .@i = 1;
2072         while (.@i <= 5) {
2073                 mes "This line will print 5 times.";
2074                 .@i += 1;
2075         }
2076         close;
2077
2078 Example 4: sentinel-controlled loop
2079         mes "Input 0 to stop";
2080         input .@num;
2081         while (.@num != 0) {
2082                 mes "You entered " + .@num;
2083                 input .@num;
2084         }
2085         close;
2086
2087 ---------------------------------------
2088
2089 *for (<variable initialization>; <condition>; <variable update>) <statement>;
2090
2091 Another pretest looping structure is the 'for' statement. It is considered a
2092 specialized form of the 'while' statement, and is usually associated with counter-
2093 controlled loops. Here are the steps of the 'for' statement: the initialize
2094 statement is executed first and only once. The condition test is performed.
2095 When the condition evaluates to false, the rest of the for statement is skipped.
2096 When the condition evaluates to true, the body of the loop is executed, then the
2097 update statement is executed (this usually involves incrementing a variable).
2098 Then the condition is reevaluated and the cycle continues.
2099
2100 Example 1:
2101         for( .@i = 1; .@i <= 5; .@i++ )
2102                 mes "This line will print 5 times.";
2103
2104 Example 2:
2105         mes "This will print the numbers 1 - 5.";
2106         for( .@i = 1; .@i <= 5; .@i++ )
2107                 mes "Number: " + .@i;
2108
2109 ---------------------------------------
2110
2111 *do { <statement>; } while (<condition>);
2112
2113 The 'do...while' is the only post-test loop structure available in this script
2114 language. With a post-test, the statements are executed once before the condition
2115 is tested. When the condition is true, the statement(s) are repeated. When the
2116 condition is false, control is transferred to the statement following the
2117 'do...while' loop expression.
2118
2119 Example 1: sentinel-controlled loop
2120         mes "This menu will keep appearing until you pick Cancel";
2121         do {
2122                 .@menu = select("One:Two:Three:Cancel");
2123         } while (.@menu != 4);
2124
2125 Example 2: counter-controlled loop
2126         mes "This will countdown from 10 to 1.";
2127         .@i = 10;
2128         do {
2129                 mes .@i;
2130                 .@i -= 1;
2131         } while (.@i > 0);
2132
2133 ---------------------------------------
2134
2135 *freeloop({<toggle>})
2136
2137 Toggling this to enabled (1) allows the script instance to bypass the infinite loop
2138 protection, allowing your script to loop as much as it may need. Disabling (0) will
2139 warn you if an infinite loop is detected.
2140
2141 The command will return the state of freeloop for the attached script, even if no
2142 argument is provided.
2143
2144 Example:
2145         freeloop(1); // enable script to loop freely
2146
2147         // be careful with what you do here
2148         for ( .@i = 0; .@i < .@bigloop; .@i++ ) {
2149                 dothis;
2150                 // will sleep the script for 1ms when detect an infinity loop to
2151                 // let rAthena do what it needs to do (socket, timer, process, etc.)
2152         }
2153
2154         freeloop(0); // disable freeloop
2155
2156         for ( .@i = 0; .@i < .@bigloop; .@i++ ) {
2157                 dothis;
2158                 // throw an infinity loop error
2159         }
2160
2161 ---------------------------------------
2162
2163 *setarray <array name>[<first value>],<value>{,<value>...<value>};
2164
2165 This command will allow you to quickly fill up an array in one go. Check the
2166 Kafra scripts in the distribution to see this used a lot.
2167
2168     setarray @array[0], 100, 200, 300, 400, 500, 600;
2169
2170 First value is the index of the first element of the array to alter. For
2171 example:
2172
2173     setarray @array[0],200,200,200;
2174     setarray @array[1],300,150;
2175
2176 will produce:
2177
2178  @array[0]=200
2179  @array[1]=300
2180  @array[2]=150
2181
2182 ---------------------------------------
2183
2184 *cleararray <array name>[<first value to alter>],<value>,<number of values to set>;
2185
2186 This command will change many array values at the same time to the same value.
2187
2188     setarray @array[0], 100, 200, 300, 400, 500, 600;
2189     // This will make all 6 values 0
2190     cleararray @array[0],0,6;
2191     // This will make array element 0 change to 245
2192     cleararray @array[0],245,1;
2193     // This will make elements 1 and 2 change to 345
2194     cleararray @array[1],345,2;
2195
2196 See 'setarray'.
2197
2198 ---------------------------------------
2199
2200 *copyarray <destination array>[<first value>],<source array>[<first value>],<amount of data to copy>;
2201
2202 This command lets you quickly shuffle a lot of data between arrays, which is in
2203 some cases invaluable.
2204
2205     setarray @array[0], 100, 200, 300, 400, 500, 600;
2206     // So we have made @array[]
2207     copyarray @array2[0],@array[2],2;
2208
2209     // Now, @array2[0] will be equal to @array[2] (300) and
2210     // @array2[1] will be equal to @array[3].
2211
2212 So using the examples above:
2213  @array[0] = 100
2214  @array[1] = 200
2215  @array[2] = 300
2216  @array[3] = 400
2217  @array[4] = 500
2218  @array[5] = 600
2219
2220 New Array:
2221  @array2[0] = 300
2222  @array2[1] = 400
2223  @array2[2] = 0
2224  @array2[3] = 0
2225
2226 Notice that @array[4] and @array[5] won't be copied to the second array, and it will return a
2227 0.
2228
2229 ---------------------------------------
2230
2231 *deletearray <array name>[<first value>],<how much to delete>;
2232
2233 This command will delete a specified number of array elements totally from an
2234 array, shifting all the elements beyond this towards the beginning.
2235
2236     // This will delete array element 0, and move all the other array elements
2237     // up one place.
2238     deletearray @array[0],1
2239
2240 // This would delete array elements numbered 1, 2 and 3, leave element 0 in its
2241 // place, and move the other elements ups, so there are no gaps.
2242
2243     deletearray @array[1],3
2244
2245 ---------------------------------------
2246
2247 ======================================
2248 |2.- Information-retrieving commands.|
2249 ======================================
2250 ---------------------------------------
2251
2252 *strcharinfo(<type>{,<char_id>})
2253
2254 This function will return either the name, party name or guild name for the
2255 invoking character. Whatever it returns is determined by type.
2256
2257  0 - Character's name.
2258  1 - The name of the party they're in if any.
2259  2 - The name of the guild they're in if any.
2260  3 - The name of the map the character is in.
2261
2262 If a character is not a member of any party or guild, an empty string will be
2263 returned when requesting that information.
2264
2265 ---------------------------------------
2266
2267 *strnpcinfo(<type>)
2268
2269 This function will return the various parts of the name of the calling NPC.
2270 Whatever it returns is determined by type.
2271
2272  0 - The NPC's display name (visible#hidden)
2273  1 - The visible part of the NPC's display name
2274  2 - The hidden part of the NPC's display name
2275  3 - The NPC's unique name (::name)
2276  4 - The name of the map the NPC is in.
2277
2278 ---------------------------------------
2279
2280 *getarraysize(<array name>)
2281
2282 This function returns highest index of the array that is filled.
2283 Notice that zeros and empty strings at the end of this array are not
2284 counted towards this number.
2285
2286 For example:
2287
2288     setarray @array[0], 100, 200, 300, 400, 500, 600;
2289     set @arraysize,getarraysize(@array);
2290
2291 This will make @arraysize == 6. But if you try this:
2292
2293     setarray @array[0], 100, 200, 300, 400, 500, 600, 0;
2294     set @arraysize,getarraysize(@array);
2295
2296 @arraysize will still equal 6, even though you've set 7 values.
2297
2298 ---------------------------------------
2299
2300 *getelementofarray(<array name>,<index>)
2301
2302 This command retrieves the value of the element of given array at given index.
2303 This is equivalent to using:
2304
2305     <array name>[<index>]
2306
2307 The reason for this is, that this short form is internally converted into a call
2308 to getelementofarray, when the script is loaded.
2309
2310 Also useful when passing arrays to functions or accessing another npc's arrays:
2311     getelementofarray(getarg(0),<index>)
2312     getelementofarray(getvariableofnpc(.var, "testNPC"),<index>)
2313
2314 ---------------------------------------
2315
2316 *readparam(<parameter number>{,"<character name>"})
2317 *readparam(<parameter number>{,<char_id>})
2318
2319 This function will return the specified stat of the invoking character, or, if a
2320 character name or character id is specified, of that player. The stat can either
2321 be a number or parameter name, defined in 'src/map/script_constants.h'.
2322
2323 Some example parameters:
2324
2325 StatusPoint, BaseLevel, SkillPoint, Class, Upper, Zeny, Sex, Weight, MaxWeight,
2326 JobLevel, BaseExp, JobExp, NextBaseExp, NextJobExp, Hp, MaxHp, Sp, MaxSp,
2327 BaseJob, Karma, Manner, bVit, bDex, bAgi, bStr, bInt, bLuk
2328
2329 All of these also behave as variables, but don't expect to be able to just 'set'
2330 them - some will not work for various internal reasons.
2331
2332 Example 1:
2333
2334     // Returns how many status points you haven't spent yet.
2335     mes "Unused status points: " + readparam(9);
2336
2337 Using this particular information as a function call is not required. Typing this
2338 will return the same result:
2339
2340     mes "Unused status points: " + StatusPoint;
2341
2342 Example 2:
2343
2344 You can also use this command to get stat values.
2345
2346     if (readparam(bVit) > 77)
2347         mes "Only people with over 77 Vit are reading this!";
2348
2349 ---------------------------------------
2350
2351 *getcharid(<type>{,"<character name>"})
2352
2353 This function will return a unique ID number of the invoking character, or, if a
2354 character name is specified, of that player.
2355
2356 Type is the kind of associated ID number required:
2357
2358  0 - Character ID
2359  1 - Party ID
2360  2 - Guild ID
2361  3 - Account ID
2362  4 - Battle Ground ID
2363  5 - Clan ID
2364
2365 For most purposes other than printing it, a number is better to have than a name
2366 (people do horrifying things to their character names).
2367
2368 If the character is not in a party or not in a guild, the function will return 0
2369 if guild or party number is requested. If a name is specified and the character
2370 is not found, 0 is returned.
2371
2372 If getcharid(0) returns a zero, the script got called not by a character and
2373 doesn't have an attached RID. Note that this will cause the map server to
2374 print "player not attached!" error messages, so it is preferred to use
2375 "playerattached" to check for the character attached to the script.
2376
2377 if (getcharid(2) == 0)
2378         mes "Only members of a guild are allowed here!";
2379
2380 ---------------------------------------
2381
2382 *getnpcid(<type>{,"<npc name>"});
2383
2384 Retrieves IDs of the currently invoked NPC. If a unique npc name is
2385 given, IDs of that NPC are retrieved instead. Type specifies what ID
2386 to retrieve and can be one of the following:
2387
2388     0 - NPC Game ID
2389
2390 If an invalid type is given or the NPC does not exist, 0 is returned.
2391
2392 ---------------------------------------
2393
2394 *getchildid({<char_id>})
2395 *getmotherid({<char_id>})
2396 *getfatherid({<char_id>})
2397
2398 These functions return the character ID of the attached player's child,
2399 mother, mother, or father, respectively. It returns 0 if no ID is found.
2400
2401     if (getmotherid()) mes "Your mother's ID is: " + getmotherid();
2402
2403 ---------------------------------------
2404
2405 *ispartneron({<char_id>})
2406
2407 This function returns 1 if the invoking character's marriage partner is
2408 currently online and 0 if they are not or if the character has no partner.
2409
2410 ---------------------------------------
2411
2412 *getpartnerid({<char_id>})
2413
2414 This function returns the character ID of the invoking character's marriage
2415 partner, if any. If the invoking character is not married, it will return 0,
2416 which is a quick way to see if they are married:
2417
2418     if (getpartnerid()) mes "I'm not going to be your girlfriend!";
2419     if (getpartnerid()) mes "You're married already!";
2420
2421 ---------------------------------------
2422
2423 *getlook(<type>{,<char_id>})
2424
2425 This function will return the number for the current character look value
2426 specified by type. See 'setlook' for valid look types.
2427
2428 This can be used to make a certain script behave differently for characters
2429 dressed in black.
2430
2431 ---------------------------------------
2432
2433 *getsavepoint(<information type>{,<char_id>})
2434
2435 This function will return information about the invoking character's save point.
2436 You can use it to let a character swap between several recorded save points.
2437 Available information types are:
2438
2439  0 - Map name (a string)
2440  1 - X coordinate
2441  2 - Y coordinate
2442
2443 ---------------------------------------
2444
2445 *getcharip({"<character name>"|<account id>|<char id>})
2446
2447 This function will return the IP address of the invoking character, or, if a player
2448 is specified, of that character. A blank string is returned if no player is attached.
2449
2450 Examples:
2451
2452 // Outputs IP address of attached player.
2453         mes "Your IP: " + getcharip();
2454
2455 // Outputs IP address of character "Silver".
2456         mes "Silver's IP: " + getcharip("Silver");
2457
2458 ---------------------------------------
2459
2460 *vip_status(<type>,{"<character name>"})
2461
2462 Returns various information about a player's VIP status.
2463
2464 Valid types:
2465  VIP_STATUS_ACTIVE - VIP status: true if the player is a VIP or false if not
2466  VIP_STATUS_EXPIRE - VIP expire timestamp if the player is VIP or 0 if not
2467  VIP_STATUS_REMAINING - VIP time remaining in seconds
2468
2469 NOTE: This command is only available if the VIP System is enabled.
2470
2471 ---------------------------------------
2472
2473 *vip_time <time>,{"<character name>"};
2474
2475 Changes a player's VIP time (in minutes). A positive value will increase time, and a
2476 negative value will decrease time.
2477
2478 NOTE: This command is only available if the VIP System is enabled.
2479
2480 ---------------------------------------
2481
2482 *addspiritball <count>,<duration>{,<char_id>};
2483
2484 Adds spirit ball to player for 'duration' in milisecond.
2485
2486 ---------------------------------------
2487
2488 *delspiritball <count>{,<char_id>};
2489
2490 Deletes the spirit ball(s) from player.
2491
2492 ---------------------------------------
2493
2494 *countspiritball {<char_id>};
2495
2496 Counts the spirit ball that player has.
2497
2498 ---------------------------------------
2499
2500 *ignoretimeout <flag>{,<char_id>};
2501
2502 Disables the SECURE_NPCTIMEOUT function on the character invoking the script,
2503 or by the given character ID/character name.
2504
2505 Valid flag:
2506  0 - Enabled SECURE_NPCTIMEOUT.
2507  1 - Disable SECURE_NPCTIMEOUT.
2508
2509 Note: SECURE_NPCTIMEOUT must be enabled for this to work.
2510
2511 ---------------------------------------
2512 \\
2513 2,2 Item-related commands
2514 \\
2515 ---------------------------------------
2516
2517 *getequipid({<equipment slot>,<char_id>})
2518
2519 This function returns the item ID of the item slot that calls the script
2520 on the invoking character or the specified equipment slot. If nothing is
2521 equipped there, it returns -1.
2522 Valid equipment slots are:
2523
2524 EQI_COMPOUND_ON (-1)      - Item slot that calls this script (In context of item script)
2525 EQI_ACC_L (0)             - Accessory 1
2526 EQI_ACC_R (1)             - Accessory 2
2527 EQI_SHOES (2)             - Footgear (shoes, boots)
2528 EQI_GARMENT (3)           - Garment (mufflers, hoods, manteaux)
2529 EQI_HEAD_LOW (4)          - Lower Headgear (beards, some masks)
2530 EQI_HEAD_MID (5)          - Middle Headgear (masks, glasses)
2531 EQI_HEAD_TOP (6)          - Upper Headgear
2532 EQI_ARMOR (7)             - Armor (jackets, robes)
2533 EQI_HAND_L (8)            - Left hand (weapons, shields)
2534 EQI_HAND_R (9)            - Right hand (weapons)
2535 EQI_COSTUME_HEAD_TOP (10) - Upper Costume Headgear
2536 EQI_COSTUME_HEAD_MID (11) - Middle Costume Headgear
2537 EQI_COSTUME_HEAD_LOW (12) - Lower Costume Headgear
2538 EQI_COSTUME_GARMENT (13)  - Costume Garment
2539 EQI_AMMO (14)                     - Arrow/Ammunition
2540 EQI_SHADOW_ARMOR (15)     - Shadow Armor
2541 EQI_SHADOW_WEAPON (16)    - Shadow Weapon
2542 EQI_SHADOW_SHIELD (17)    - Shadow Shield
2543 EQI_SHADOW_SHOES (18)     - Shadow Shoes
2544 EQI_SHADOW_ACC_R (19)     - Shadow Accessory 2
2545 EQI_SHADOW_ACC_L (20)     - Shadow Accessory 1
2546
2547 Notice that a few items occupy several equipment slots, and if the character is
2548 wearing such an item, 'getequipid' will return its ID number for either slot.
2549
2550 Can be used to check if you have something equipped, or if you haven't got
2551 something equipped:
2552
2553         if (getequipid(EQI_HEAD_TOP) == 2234)
2554                 mes "What a lovely Tiara you have on";
2555         else
2556                 mes "Come back when you have a Tiara on";
2557         close;
2558
2559 You can also use it to make sure people don't pass a point before removing an
2560 item totally from them. Let's say you don't want people to wear Legion Plate
2561 armor, but also don't want them to equip if after the check, you would do this:
2562
2563         if (getequipid(EQI_ARMOR) == 2341 || getequipid(EQI_ARMOR) == 2342) {
2564                 mes "You are wearing some Legion Plate Armor, please drop that in your stash before continuing";
2565                 close;
2566         }
2567         // the || is used as an or argument, there is 2341 and 2342 cause there are
2568         // two different legion plate armors, one with a slot one without.
2569
2570         if (countitem(2341) > 0 || countitem(2432) > 0) {
2571                 mes "You have some Legion Plate Armor in your inventory, please drop that in your stash before continuing";
2572                 close;
2573         }
2574         mes "I will lets you pass.";
2575         close2;
2576         warp "place",50,50;
2577         end;
2578
2579 ---------------------------------------
2580
2581 *getequipuniqueid(<equipment slot>{,<char_id>})
2582
2583 This function returns the unique ID (as a string) of the item equipped in the equipment slot
2584 specified on the invoking character. If nothing is equipped there, it returns an empty string.
2585 See 'getequipid' for a full list of valid equipment slots.
2586
2587 ---------------------------------------
2588
2589 *getequipname(<equipment slot>{,<char_id>})
2590
2591 Returns the jname of the item equipped in the specified equipment slot on the
2592 invoking character, or an empty string if nothing is equipped in that position.
2593 Does the same thing as getitemname(getequipid()). Useful for an NPC to state
2594 what your are wearing, or maybe saving as a string variable.
2595 See 'getequipid' for a full list of valid equipment slots.
2596
2597         if ( getequipname(EQI_HEAD_TOP) != "" )
2598                 mes "So you are wearing a " + getequipname(EQI_HEAD_TOP) + " on your head";
2599         else
2600                 mes "You are not wearing any head gear";
2601
2602 ---------------------------------------
2603
2604 *getitemname(<item id>)
2605
2606 Given the database ID number of an item, this function will return the text
2607 stored in the 'japanese name' field (which, in rAthena, stores an English name
2608 the players would normally see on screen.)
2609
2610 ---------------------------------------
2611
2612 *getbrokenid(<number>{,<char_id>})
2613
2614 This function will search the invoking character's inventory for any broken
2615 items, and will return their item ID numbers. Since the character may have
2616 several broken items, 1 given as an argument will return the first one found, 2
2617 will return the second one, etc. Will return 0 if no such item is found.
2618
2619         // Let's see if they have anything broken:
2620         if (getbrokenid(1) == 0)
2621                 mes "You don't have anything broken, quit bothering me.";
2622         else
2623         // They do, so let's print the name of the first broken item:
2624                 mes "Oh, I see you have a broken " + getitemname(getbrokenid(1)) + " here!";
2625         end;
2626
2627 ---------------------------------------
2628
2629 *getequipisequiped(<equipment slot>{,<char_id>})
2630
2631 This functions will return 1 if there is an equipment placed on the specified
2632 equipment slot and 0 otherwise. For a list of equipment slots
2633 see 'getequipid'. Function originally used by the refining NPCs:
2634
2635     if (getequipisequiped(EQI_HEAD_TOP)) {
2636         mes "[Refiner]";
2637         mes "That's a fine hat you are wearing there...";
2638         close;
2639         } else {
2640                 mes "[Refiner]";
2641                 mes "Do you want me to refine your dumb head?";
2642                 close;
2643         }
2644
2645 ---------------------------------------
2646
2647 *getequipisenableref(<equipment slot>{,<char_id>})
2648
2649 Will return 1 if the item equipped on the invoking character in the specified
2650 equipment slot is refinable, and 0 if it isn't. For a list of equipment slots
2651 see 'getequipid'.
2652
2653         if (getequipisenableref(EQI_HEAD_TOP)) {
2654                 mes "[Refiner]";
2655                 mes "Ok I can refine this";
2656                 close;
2657         } else {
2658                 mes "[Refiner]";
2659                 mes "I can't refine this hat!...";
2660                 close;
2661         }
2662
2663 ---------------------------------------
2664
2665 *getequiprefinerycnt(<equipment slot>{,<char_id>})
2666
2667 Returns the current number of pluses for the item in the specified equipment
2668 slot. For a list of equipment slots see 'getequipid'.
2669
2670 Can be used to check if you have reached a maximum refine value, default for
2671 this is +10:
2672
2673         if (getequiprefinerycnt(EQI_HEAD_TOP) < 10)
2674                 mes "I will now upgrade your " + getequipname(EQI_HEAD_TOP);
2675         else
2676                 mes "Sorry, it's not possible to refine hats better than +10";
2677         close;
2678
2679 ---------------------------------------
2680
2681 *getequipweaponlv(<equipment slot>{,<char_id>})
2682
2683 This function returns the weapon level for the weapon equipped in the specified
2684 equipment slot on the invoking character. For a list of equipment slots see
2685 'getequipid'.
2686
2687 Only EQI_HAND_L and EQI_HAND_R normally make sense, since only weapons have
2688 a weapon level. You can, however, probably, use this field for other equippable
2689 custom items as a flag or something.
2690
2691 If no item is equipped in this slot, or if it doesn't have a weapon level
2692 according to the database, 0 will be returned.
2693
2694 Examples:
2695
2696 // Right hand can only contain a weapon.
2697     switch (getequipweaponlv(EQI_HAND_R)) {
2698       case 1: mes "You are holding a lvl 1 weapon."; break;
2699       case 2: mes "You are holding a lvl 2 weapon."; break;
2700       case 3: mes "You are holding a lvl 3 weapon."; break;
2701       case 4: mes "You are holding a lvl 4 weapon."; break;
2702       case 5: mes "You are holding a lvl 5 weapon, hm, must be a custom design..."; break;
2703       default: mes "Seems you don't have a weapon on."; break;
2704     }
2705
2706 // Left hand can hold either a weapon or shield.
2707     if (getequipid(EQI_HAND_R) == 0) {
2708         mes "Seems you have nothing equipped here.";
2709         close;
2710     }
2711     switch (getequipweaponlv(EQI_HAND_L)) {
2712       case 0: mes "You are holding a shield, so it doesn't have a level."; break;
2713       case 1: mes "You are holding a lvl 1 weapon."; break;
2714       case 2: mes "You are holding a lvl 2 weapon."; break;
2715       case 3: mes "You are holding a lvl 3 weapon."; break;
2716       case 4: mes "You are holding a lvl 4 weapon."; break;
2717       case 5: mes "You are holding a lvl 5 weapon, hm, must be a custom design..."; break;
2718     }
2719
2720 ---------------------------------------
2721
2722 *getequippercentrefinery(<equipment slot>{,<enriched>,<char_id>})
2723
2724 This function calculates and returns the percent value chance to successfully
2725 refine the item found in the specified equipment slot of the invoking character
2726 by +1. There is no actual formula, the success rate for a given weapon level of
2727 a certain refine level is found in the db/(pre-)re/refine_db.yml file. For a list of
2728 equipment slots see 'getequipid'.
2729
2730 If enriched parameter is set to true, chance to successfully refine the item with
2731 enriched material is returned instead.
2732
2733 These values can be displayed for the player to see, or used to calculate the
2734 random change of a refine succeeding or failing and then going through with it
2735 (which is what the official NPC refinery scripts use it for)
2736
2737 // This will find a random number from 0 - 99 and if that is equal to or more
2738 // than the value recovered by this command it will go to L_Fail
2739     if (getequippercentrefinery(EQI_HAND_L)<=rand(100)) goto L_Fail;
2740
2741 ---------------------------------------
2742
2743 *getequiprefinecost(<equipment slot>,<type>,<information>{,<char id>})
2744
2745 This function returns refine cost for equipment in <equipment slot> based on
2746 passed arguments <type> and <information>.
2747
2748 Valid cost types are:
2749
2750 REFINE_COST_NORMAL     - For normal refining
2751 REFINE_COST_OVER10     - For refining over +10
2752 REFINE_COST_HD         - For refining with HD ores
2753 REFINE_COST_ENRICHED   - For refining with enriched ores
2754 REFINE_COST_OVER10_HD  - For refining over +10 with HD ores
2755
2756 This function will return required cost for refining based on <information> argument.
2757
2758 Valid information types are:
2759
2760 REFINE_ZENY_COST       - Zeny
2761 REFINE_MATERIAL_ID     - Material Item ID
2762
2763 This function will return -1 on failure. The function fails if the cost type
2764 is invalid or if there is no item in the equipment slot. 
2765
2766 ---------------------------------------
2767
2768 *getareadropitem("<map name>",<x1>,<y1>,<x2>,<y2>,<item>)
2769
2770 This function will count all the items with the specified ID number lying on the
2771 ground on the specified map within the x1/y1-x2/y2 square on it and return that
2772 number.
2773
2774 This is the only function around where a parameter may be either a string or a
2775 number! If it's a number, it means that only the items with that item ID number
2776 will be counted. If it is a string, it is assumed to mean the 'english name'
2777 field from the item database. If you give it an empty string, or something that
2778 isn't found from the item database, it will count items number '512' (apples).
2779
2780 ---------------------------------------
2781
2782 *getequipcardcnt(<equipment slot>)
2783
2784 This function will return the number of cards that have been compounded onto a
2785 specific equipped item for the invoking character. See 'getequipid' for a list
2786 of possible equipment slots.
2787
2788 ---------------------------------------
2789
2790 *getinventorylist {<char_id>};
2791
2792 This command sets a bunch of arrays with a complete list of whatever the
2793 invoking character has in their inventory, including all the data needed to
2794 recreate these items perfectly if they are destroyed. Here's what you get:
2795
2796 @inventorylist_id[]        - array of item ids.
2797 @inventorylist_amount[]    - their corresponding item amounts.
2798 @inventorylist_equip[]     - on which position the item is equipped (see EQP_* constants)
2799                              It will contain 0 if the item is not equipped.
2800 @inventorylist_refine[]    - for how much it is refined.
2801 @inventorylist_identify[]  - whether it is identified.
2802 @inventorylist_attribute[] - whether it is broken.
2803 @inventorylist_card1[]     - These four arrays contain card data for the items.
2804 @inventorylist_card2[]       These data slots are also used to store names
2805 @inventorylist_card3[]       inscribed on the items, so you can explicitly check
2806 @inventorylist_card4[]       if the character owns an item made by a specific
2807                              craftsman.
2808 @inventorylist_expire[]    - expire time (Unix time stamp). 0 means never expires.
2809 @inventorylist_bound[]     - the bound type of the items (see BOUND_* constants)
2810 @inventorylist_count       - the number of items in these lists.
2811
2812 This could be handy to save/restore a character's inventory, since no other
2813 command returns such a complete set of data, and could also be the only way to
2814 correctly handle an NPC trader for carded and named items who could resell them
2815 - since NPC objects cannot own items, so they have to store item data in
2816 variables and recreate the items.
2817
2818 Notice that the variables this command generates are all temporary, attached to
2819 the character, and integer.
2820
2821 Be sure to use @inventorylist_count to go through these arrays, and not
2822 'getarraysize', because the arrays are not automatically cleared between runs
2823 of 'getinventorylist'.
2824
2825 ---------------------------------------
2826
2827 *cardscnt()
2828
2829 This function will return the number of cards inserted into the equipment
2830 from which the function is called.
2831
2832 This function is intended for use in item scripts.
2833
2834 ---------------------------------------
2835
2836 *getrefine()
2837
2838 This function will return the refine count of the equipment from which the
2839 function is called.
2840
2841 This function is intended for use in item scripts.
2842
2843 ---------------------------------------
2844
2845 *getnameditem(<item id>,"<name to inscribe>"|<char id>);
2846 *getnameditem("<item name>","<name to inscribe>"|<char id>);
2847
2848 This function is equivalent to using 'getitem', however, it will not just give
2849 the character an item object, but will also inscribe it with a specified
2850 character's name. You may not inscribe items with arbitrary strings, only with
2851 names of characters that actually exist. While this isn't said anywhere
2852 specifically, apparently, named items may not have cards in them, slots or no -
2853 these data slots are taken by the character ID who's name is inscribed. Only one
2854 remains free and it's not quite clear if a card may be there.
2855
2856 This function will return 1 if an item was successfully created and 0 if it
2857 wasn't for whatever reason. Like 'getitem', this function will also accept an
2858 'english name' from the item database as an item name and will return 0 if no
2859 such item exists.
2860
2861 ---------------------------------------
2862
2863 *getitemslots(<item ID>)
2864
2865 This function will look up the item with the specified ID number in the database
2866 and return the number of slots this kind of items has - 0 if they are not
2867 slotted. It will also be 0 for all non-equippable items, naturally, unless
2868 someone messed up the item database. It will return -1 if there is no such item.
2869
2870 Example:
2871
2872 //.@slots now has the amount of slots of the item with ID 1205.
2873         .@slots = getitemslots(1205);
2874
2875 ---------------------------------------
2876
2877 *getiteminfo(<item ID>,<type>)
2878
2879 This function will look up the item with the specified ID number in the database
2880 and return the info set by TYPE argument.
2881 It will return -1 if there is no such item.
2882
2883 Valid types are:
2884         0  - Buy Price
2885         1  - Sell Price
2886         2  - Type
2887         3  - maxchance (max drop chance of this item, e.g. 1 = 0.01%)
2888                  if = 0, then monsters don't drop it at all (rare or a quest item)
2889                  if = 10000, then this item is sold in NPC shops only
2890         4  - Gender
2891         5  - Loc
2892         6  - Weight
2893         7  - ATK
2894         8  - DEF
2895         9  - Range
2896         10 - Slot
2897         11 - View
2898         12 - eLV
2899         13 - wLV
2900         14 - SpriteID from 'db/item_avail.txt'
2901         15 - eLVMax
2902         16 - matk if RENEWAL is defined
2903
2904 See the sample in 'doc/sample/getiteminfo.txt'.
2905
2906 ---------------------------------------
2907
2908 *getequipcardid(<equipment slot>,<card slot>)
2909
2910 Returns value from equipped item slot in the indicated slot (0, 1, 2, or 3).
2911
2912 This function returns CARD ID, CARD0_FORGE, CARD0_CREATE, or CARD0_PET (for card 0, if the item is produced).
2913 It's useful for when you want to check whether an item contains cards or if it's signed.
2914
2915 ---------------------------------------
2916
2917 *mergeitem({,<char_id>});
2918
2919 Open merge item window to merge available item can be merged.
2920
2921 Examples
2922 1. See the NPC 'npc/re/other/merge_item.txt'.
2923 2. Simple usage:
2924     mes "Let's check if any item can be merged.";
2925     close2;
2926     mergeitem;
2927     end;
2928
2929 ---------------------------------------
2930
2931 *mergeitem2({<item_id>{,<char_id>}});
2932 *mergeitem2({"<item name>"{,<char_id>}});
2933
2934 Merge all stackable items that separated by GUID flags
2935 (either by flag 4 item_flag.txt or GUID  in item_group).
2936 If no item ID/name given, all possible items in player's inventory will be merged.
2937
2938 ---------------------------------------
2939 //
2940 2,1.- End of item-related commands.
2941 //
2942 ---------------------------------------
2943
2944 *getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"})
2945
2946 This function will locate a character object, NPC object or pet's coordinates
2947 and place their coordinates into the variables specified when calling it. It
2948 will return 0 if the search was successful, and -1 if the parameters given were
2949 not variables or the search was not successful.
2950
2951 Type is the type of object to search for:
2952
2953         UNITTYPE_PC   - Character object
2954         UNITTYPE_NPC  - NPC object
2955         UNITTYPE_PET  - Pet object
2956         UNITTYPE_HOM  - Homunculus object
2957         UNITTYPE_MER  - Mercenary object
2958         UNITTYPE_ELEM - Elemental object
2959
2960 The search string is optional. If it is not specified, the location of the
2961 invoking character will always be returned for types UNITTYPE_PC and UNITTYPE_PET,
2962 the location of the NPC running this function for type 1.
2963
2964 If a search string is specified, for types UNITTYPE_PC and UNITTYPE_NPC, the
2965 character or NPC with the specified name will be located.
2966
2967 If type is UNITTYPE_PET/UNITTYPE_HOM/UNITTYPE_MER/UNITTYPE_ELEM, the search
2968 will locate the current object of the character who's name is given in the
2969 search string, it will NOT locate the object by name.
2970
2971 Example:
2972
2973     prontera,164,301,3%TAB%script%TAB%Meh%TAB%730,{
2974         mes "My name is Meh. I'm here so that Nyah can find me.";
2975         close;
2976     }
2977
2978     prontera,164,299,3%TAB%script%TAB%Nyah%TAB%730,{
2979         mes "My name is Nyah.";
2980         mes "I will now search for Meh all across the world!";
2981         if (getmapxy(@mapname$, @mapx, @mapy, UNITTYPE_NPC, "Meh") != 0) {
2982                 mes "I can't seem to find Meh anywhere!";
2983                 close;
2984         }
2985         mes "And I found him on map " + @mapname$ + " at X:" + @mapx + " Y:" + @mapy + " !";
2986         close;
2987    }
2988
2989 Notice that NPC objects disabled with 'disablenpc' will still be located.
2990
2991 ---------------------------------------
2992
2993 *mapid2name(<map ID>)
2994
2995 Returns the map name of the given map ID. Returns an empty string if given
2996 map ID doesn't exist.
2997
2998 ---------------------------------------
2999
3000 *getgmlevel({<char_id>})
3001
3002 This function will return the (GM) level associated with the player group to which
3003 the invoking character belongs. If this is somehow executed from a console command,
3004 99 will be returned, and 0 will be returned if the account has no GM level.
3005
3006 This allows you to make NPC's only accessible for certain GM levels, or behave
3007 specially when talked to by GMs.
3008
3009    if (getgmlevel()) mes "What is your command, your godhood?";
3010
3011 ---------------------------------------
3012
3013 *getgroupid({<char_id>})
3014
3015 This function will return the group id to which the invoking player belongs.
3016
3017 ---------------------------------------
3018
3019 *gettimetick(<tick type>)
3020
3021 This function will return a tick depending on <tick type>:
3022  0: The server's tick, a measurement in milliseconds used by the server's timer
3023     system. This tick is an unsigned int which loops every ~50 days.
3024  1: The time, in seconds, since the start of the current day.
3025  2: The system time in UNIX epoch time, or the number of seconds elapsed since
3026     January 1st, 1970. Useful for reliably measuring time intervals.
3027
3028 ---------------------------------------
3029
3030 *gettime(<type>)
3031
3032 This function will return specified information about the current system time.
3033
3034 DT_SECOND - Seconds (of the current minute)
3035 DT_MINUTE - Minutes (of the current hour)
3036 DT_HOUR - Hour (of the current day)
3037 DT_DAYOFWEEK - Week day (constants for MONDAY to SUNDAY are available)
3038 DT_DAYOFMONTH - Day of the current month
3039 DT_MONTH - Month (constants for JANUARY to DECEMBER are available)
3040 DT_YEAR - Year
3041 DT_DAYOFYEAR - Day of the year
3042
3043 It will only return numbers. If another type is supplied -1 will be returned.
3044
3045         if (gettime(DT_DAYOFWEEK) == SATURDAY) mes "It's a Saturday. I don't work on Saturdays.";
3046
3047 ---------------------------------------
3048
3049 *gettimestr(<"time format">,<max length>{,<time_tick>})
3050
3051 This function will return a string containing time data as specified by the
3052 time format.
3053
3054 This uses the C function 'strfmtime', which obeys special format characters. For
3055 a full description see, for example, the description of 'strfmtime' at
3056 http://www.delorie.com/gnu/docs/glibc/libc_437.html
3057 All the format characters given in there should properly work.
3058 Max length is the maximum length of a time string to generate.
3059
3060 The example given in rAthena sample scripts works like this:
3061
3062   mes gettimestr("%Y-%m/%d %H:%M:%S",21);
3063
3064 The example above will print the current date and time like 'YYYY-MM/DD HH:MM:SS'.
3065 The following example will print the date and time when the player's VIP status
3066 expires by the given <time_tick>:
3067
3068   mes gettimestr("%Y-%m/%d %H:%M:%S",21,vip_status(VIP_STATUS_EXPIRE));
3069
3070 ---------------------------------------
3071
3072 *getusers(<type>)
3073
3074 This function will return a number of users on a map or the whole server. What
3075 it returns is specified by Type.
3076
3077 Type can be one of the following values, which control what will be returned:
3078
3079     0 - Count of all characters on the map of the invoking character.
3080     1 - Count of all characters in the entire server.
3081     8 - Count of all characters on the map of the NPC the script is
3082         running in.
3083
3084 ---------------------------------------
3085
3086 *getmapusers("<map name>")
3087
3088 This function will return the number of users currently located on the specified
3089 map.
3090
3091 This is used officially in PVP scripts to check whether a room is filled to capacity.
3092
3093 ---------------------------------------
3094
3095 *getareausers("<map name>",<x1>,<y1>,<x2>,<y2>)
3096
3097 This function will return the count of connected characters which are located
3098 within the specified area - an x1/y1-x2/y2 square on the specified map.
3099
3100 This is useful for maps that are split into many buildings, such as all the
3101 "*_in" maps, due to all the shops and houses.
3102
3103 ---------------------------------------
3104 \\
3105 2,2.- Guild-related commands
3106 \\
3107 ---------------------------------------
3108
3109 *getguildname(<guild id>)
3110
3111 This function returns a guild's name given an ID number. If there is no such
3112 guild, "null" will be returned.
3113
3114 Example:
3115         mes "The guild " + getguildname(10007) + " are all nice people.";
3116
3117 ---------------------------------------
3118
3119 *getguildmember <guild id>{,<type>{,<array_variable>}};
3120
3121 This command will find all members of a specified guild and returns their names
3122 (or character id or account id depending on the value of "type") into an array
3123 of temporary global variables.
3124
3125 Upon executing this,
3126
3127 $@guildmembername$[] is a global temporary string array which contains all the
3128                      names of these guild members.
3129                      (only set when type is 0 or not specified)
3130
3131 $@guildmembercid[]   is a global temporary number array which contains the
3132                      character id of these guild members.
3133                      (only set when type is 1)
3134
3135 $@guildmemberaid[]   is a global temporary number array which contains the
3136                      account id of these guild members.
3137                      (only set when type is 2)
3138
3139 $@guildmembercount   is the number of guild members that were found.
3140
3141 The guild members will be found regardless of whether they are online or offline.
3142 Note that the names come in no particular order.
3143
3144 Be sure to use $@guildmembercount to go through this array, and not
3145 'getarraysize', because it is not cleared between runs of 'getguildmember'.
3146
3147 If 'array_variable' is set, the result will be stored to that variable instead
3148 using global variable.
3149
3150 For usage examples, see 'getpartymember'.
3151
3152 ---------------------------------------
3153
3154 *getguildmaster(<guild id>)
3155
3156 This function return the name of the master of the guild which has the specified
3157 ID number. If there is no such guild, "null" will be returned.
3158
3159 Example 1:
3160         // Prints the guild master of guild 10007, whoever that might be.
3161         mes getguildmaster(10007) + " runs " + getguildname(10007);
3162
3163 Example 2:
3164         // Checks if the character is the guild master of the specified guild.
3165         .@GID = getcharid(2);
3166         if (.@GID == 0) {
3167                 mes "Sorry, you are not in a guild.";
3168                 close;
3169         }
3170         if (strcharinfo(0) != getguildmaster(.@GID)) {
3171                 mes "Sorry, you don't own the guild you are in.";
3172                 close;
3173         }
3174         mes "Welcome, guild master of " + getguildname(.@GID);
3175         close;
3176
3177 ---------------------------------------
3178
3179 *getguildmasterid(<guild id>)
3180
3181 This function will return the character ID number of the guild master of the
3182 guild specified by the ID. 0 if the character is not a guild master of any guild.
3183
3184 ---------------------------------------
3185
3186 *getcastlename("<map name>")
3187
3188 This function returns the name of the castle when given the map name for that
3189 castle. The data is read from 'db/castle_db.txt'.
3190
3191 ---------------------------------------
3192
3193 *getcastledata("<map name>",<type of data>)
3194 *setcastledata "<map name>",<type of data>,<value>;
3195
3196 This function returns the castle ownership information for the castle referred
3197 to by its map name. Castle information is stored in `guild_castle` SQL table.
3198
3199 Types of data correspond to `guild_castle` table columns:
3200
3201  1 - `guild_id`   - Guild ID.
3202  2 - `economy`    - Castle Economy score.
3203  3 - `defense`    - Castle Defense score.
3204  4 - `triggerE`   - Number of times the economy was invested in today.
3205  5 - `triggerD`   - Number of times the defense was invested in today.
3206  6 - `nextTime`   - unused
3207  7 - `payTime`    - unused
3208  8 - `createTime` - unused
3209  9 - `visibleC`   - Is 1 if a Kafra was hired for this castle, 0 otherwise.
3210 10 - `visibleG0`  - Is 1 if the 1st guardian is present (Soldier Guardian)
3211 11 - `visibleG1`  - Is 1 if the 2nd guardian is present (Soldier Guardian)
3212 12 - `visibleG2`  - Is 1 if the 3rd guardian is present (Soldier Guardian)
3213 13 - `visibleG3`  - Is 1 if the 4th guardian is present (Archer Guardian)
3214 14 - `visibleG4`  - Is 1 if the 5th guardian is present (Archer Guardian)
3215 15 - `visibleG5`  - Is 1 if the 6th guardian is present (Knight Guardian)
3216 16 - `visibleG6`  - Is 1 if the 7th guardian is present (Knight Guardian)
3217 17 - `visibleG7`  - Is 1 if the 8th guardian is present (Knight Guardian)
3218
3219 All types of data have their meaning determined by War of Emperium scripts,
3220 with exception of:
3221  - `guild_id` that is always considered ID of the guild that owns the castle,
3222  - `defense` that is used in Guardians & Emperium HP calculations,
3223  - `visibleG` that is always considered to hold guardian presence bits.
3224
3225 The 'setcastledata' command will behave identically, but instead of returning
3226 values for the specified types of accessible data, it will alter them and cause
3227 them to be sent to the char-server for storage.
3228
3229 Changing Guild ID or Castle Defense will trigger additional actions, like
3230 recalculating guardians' HP.
3231
3232 ---------------------------------------
3233
3234 *getgdskilllv(<guild id>,<skill id>)
3235 *getgdskilllv(<guild id>,"<skill name>")
3236
3237 This function returns the level of the skill <skill id> of the guild <guild id>.
3238 If the guild does not have that skill, 0 is returned.
3239 If the guild does not exist, -1 is returned.
3240 Refer to 'db/(pre-)re/skill_db.txt' for the full list of skills. (GD_* are guild skills)
3241
3242 ---------------------------------------
3243
3244 *requestguildinfo <guild id>{,"<event label>"};
3245
3246 This command requests the guild data from the char server and merrily continues
3247 with the execution. Whenever the guild information becomes available (which
3248 happens instantly if the guild information is already in memory, or later, if it
3249 isn't and the map server has to wait for the char server to reply) it will run
3250 the specified event as in a 'donpcevent' call.
3251
3252 ---------------------------------------
3253
3254 *getmapguildusers("<map name>",<guild id>)
3255
3256 Returns the amount of characters from the specified guild on the given map.
3257
3258 Example:
3259
3260 mes "You have " + getMapGuildUsers("prontera",getcharid(2)) + " guild members in Prontera.";
3261
3262 ---------------------------------------
3263 //
3264 2,2.- End of guild-related commands
3265 //
3266 ---------------------------------------
3267
3268 *getskilllv(<skill id>)
3269 *getskilllv("<skill name>")
3270
3271 This function returns the level of the specified skill that the invoking
3272 character has. If they don't have the skill, 0 will be returned. The full list
3273 of character skills is available in 'db/(pre-)re/skill_db.txt'.
3274
3275 There are two main uses for this function, it can check whether the character
3276 has a skill or not, and it can tell you if the level is high enough.
3277
3278 Example 1:
3279         if (getskilllv(152))
3280                 mes "You have got the skill Throw Stone";
3281         else
3282                 mes "You don't have Throw Stone";
3283         close;
3284
3285 Example 2:
3286         if (getskilllv(28) >= 5)
3287                 mes "Your heal lvl is 5 or more";
3288         else if (getskilllv(28) == 10)
3289                 mes "Your heal lvl has been maxed";
3290         else
3291                 mes "You heal skill is below lvl 5";
3292         close;
3293
3294 ---------------------------------------
3295
3296 *getskilllist({<char_id>});
3297
3298 This command sets a bunch of arrays with a complete list of skills the
3299 invoking character has. Here's what you get:
3300
3301 @skilllist_id[]   - skill ids.
3302 @skilllist_lv[]   - skill levels.
3303 @skilllist_flag[] - see 'skill' for the meaning of skill flags.
3304 @skilllist_count  - number of skills in the above arrays.
3305
3306 While 'getskillv' is probably more useful for most situations, this is the
3307 easiest way to store all the skills and make the character something else for a
3308 while. Advanced job for a day? This could also be useful to see how many
3309 skills a character has.
3310
3311 This command does not count skills which are set as flag 4 (permament granted) (ALL_BUYING_STORE/ALL_INCCARRY)
3312
3313 ---------------------------------------
3314
3315 *getmonsterinfo(<mob ID>,<type>)
3316
3317 This function will look up the monster with the specified ID number in the
3318 mob database and return the info set by TYPE argument.
3319 It will return -1 if there is no such monster (or the type value is invalid),
3320 or "null" if you requested the monster's name.
3321
3322 Valid types are:
3323         MOB_NAME - monster's name, if there is no such monster "null" is returned
3324         MOB_LV - monster's level
3325         MOB_MAXHP - monster's maximum hp
3326         MOB_BASEEXP - monster's base experience
3327         MOB_JOBEXP - monster's job experience
3328         MOB_ATK1 - monster's atk
3329         MOB_ATK2 - monster's atk2
3330         MOB_DEF - monster's def
3331         MOB_MDEF - monster's mdef
3332         MOB_STR - monster's str
3333         MOB_AGI - monster's agi
3334         MOB_VIT - monster's vit
3335         MOB_INT - monster's int
3336         MOB_DEX - monster's dex
3337         MOB_LUK - monster's luk
3338         MOB_RANGE - monster's range
3339         MOB_RANGE2 - monster's range2
3340         MOB_RANGE3 - monster's range3
3341         MOB_SIZE - monster's size
3342         MOB_RACE - monster's race
3343         MOB_ELEMENT - monster's element(doesn't return the element level, only the element ID)
3344         MOB_MODE - monster's mode
3345         MOB_MVPEXP - monster's mvp experience
3346
3347 For more details, see the sample in 'doc/sample/getmonsterinfo.txt'.
3348
3349 ---------------------------------------
3350
3351 *getmobdrops(<mob id>)
3352
3353 This command will find all drops of the specified mob and return the item IDs
3354 and drop percentages into arrays of temporary global variables.
3355 'getmobdrops' returns 1 if successful and 0 if the mob ID doesn't exist.
3356
3357 Upon executing this,
3358
3359 $@MobDrop_item[] is a global temporary number array which contains the
3360                  item IDs of the monster's drops.
3361
3362 $@MobDrop_rate[] is a global temporary number array which contains the
3363                  drop percentages of each item. (1 = .01%)
3364
3365 $@MobDrop_count is the number of item drops found.
3366
3367 Be sure to use $@MobDrop_count to go through the arrays, and not
3368 'getarraysize', because the temporary global arrays are not cleared between
3369 runs of 'getmobdrops'. If a mob with 7 item drops is looked up, the arrays would
3370 have 7 elements. But if another mob is looked up and it only has 5 item drops,
3371 the server will not clear the arrays for you, overwriting the values instead. So
3372 in addition to returning the 5 item drops, the 6th and 7th elements from the
3373 last call remain, and you will get 5+2 item drops, of which the last 2 don't
3374 belong to the new mob. $@MobDrop_count will always contain the correct number
3375 (5), unlike 'getarraysize()' which would return 7 in this case.
3376
3377 Example:
3378
3379         // get a Mob ID from the user
3380         input .@mob_id;
3381
3382         if (getmobdrops(.@mob_id)) {    // 'getmobdrops' returns 1 on success
3383                 // immediately copy global temporary variables into scope variables,
3384                 // since we don't know when 'getmobdrops' will get called again for
3385                 // another mob, overwriting your global temporary variables
3386                 .@count = $@MobDrop_count;
3387                 copyarray .@item[0],$@MobDrop_item[0],.@count;
3388                 copyarray .@rate[0],$@MobDrop_rate[0],.@count;
3389
3390                 mes getmonsterinfo(.@mob_id,MOB_NAME) + " - " + .@count + " drops found:";
3391                 for( .@i = 0; .@i < .@count; .@i++ ) {
3392                         mes .@item[.@i] + " (" + getitemname(.@item[.@i]) + ") " + .@rate[.@i]/100 + ((.@rate[.@i]%100 < 10) ? ".0":".") + .@rate[.@i]%100 + "%";
3393                 }
3394         } else {
3395                 mes "Unknown monster ID.";
3396         }
3397         close;
3398
3399 ---------------------------------------
3400
3401 *skillpointcount({<char_id>})
3402
3403 Returns the total amount of skill points a character possesses (SkillPoint+SP's used in skills)
3404 This command can be used to check the currently attached characters total amount of skill points.
3405 This means the skill points used in skill are counted, and added to SkillPoints (number of skill points not used).
3406 This command does not count skills which are set as flag 4 (permament granted) (ALL_BUYING_STORE/ALL_INCCARRY)
3407
3408 Example 1:
3409         .@skillPoints = skillpointcount();
3410         mes "You have " + .@skillPoints + " skill points in total!";
3411
3412 Example 2:
3413         if (skillpointcount() > 20)
3414                 mes "Wow, you have more then 20 Skill Points in total!";
3415
3416 ---------------------------------------
3417
3418 *getscrate(<effect type>,<base rate>{,<GID>})
3419
3420 This function will return the chance of a status effect affecting the invoking
3421 character, in percent, modified by the their current defense against said
3422 status. The 'base rate' is the base chance of the status effect being inflicted,
3423 in percent.
3424
3425     if (rand(100) > getscrate(Eff_Blind, 50)) goto BlindHimNow;
3426
3427 You can see the full list of available effect types you can possibly inflict in
3428 'db/const.txt' under 'Eff_'.
3429
3430 ---------------------------------------
3431
3432 ========================
3433 |3.- Checking commands.|
3434 ========================
3435 -------------------------
3436
3437 *playerattached()
3438
3439 Returns the ID of the player currently attached to the script. It will return
3440 0 if no one is attached, or if the attached player no longer exists on the map
3441 server. It is wise to check for the attached player in script functions that
3442 deal with timers as there's no guarantee the player will still be logged on
3443 when the timer triggers. Note that the ID of a player is actually their
3444 account ID.
3445
3446 ---------------------------------------
3447
3448 *getattachedrid();
3449
3450 Returns RID from running script. Script may not be attached to any RID like
3451 a floating script or function and will return 0.
3452
3453 ---------------------------------------
3454
3455 *isloggedin(<account id>{,<char id>})
3456
3457 This function returns 1 if the specified account is logged in and 0 if they
3458 aren't. You can also pass the char id to check for both account and char id.
3459
3460 ---------------------------------------
3461
3462 *checkweight(<item id>,<amount>{,<item id>,<amount>,<item id>,<amount>,...});
3463 *checkweight("<item name>",<amount>{,"<item name>",<amount>,"<item name>",<amount>,...});
3464 *checkweight2(<id_array>,<amount_array>);
3465
3466 These functions will compute and return 1 if the total weight of the specified
3467 number of specific items does not exceed the invoking character's carrying
3468 capacity, and 0 otherwise. It is important to see if a player can carry the
3469 items you expect to give them, failing to do that may open your script up to
3470 abuse or create some very unfair errors.
3471
3472 The second function will check an array of items and amounts, and also
3473 returns 1 on success and 0 on failure.
3474
3475 The functions, in addition to checking to see if the player is capable of
3476 holding a set amount of items, also ensure the player has room in their
3477 inventory for the item(s) they will be receiving.
3478
3479 Like 'getitem', this function will also accept an 'english name' from the
3480 database as an argument.
3481
3482 Example 1:
3483
3484         if (checkweight(512,10)) {
3485                 getitem 512,10;
3486         } else {
3487                 mes "Sorry, you cannot hold this amount of apples!";
3488         }
3489
3490 Example 2:
3491
3492         setarray .@item[0],512,513,514;
3493         setarray .@amount[0],10,5,5;
3494         if (!checkweight2(.@item,.@amount)) {
3495                 mes "Sorry, you cannot hold this amount of fruit!";
3496         }
3497
3498 ---------------------------------------
3499
3500 *basicskillcheck()
3501
3502 This function will return the state of the configuration option
3503 'basic_skill_check' in 'battle_athena.conf'. It returns 1 if the option is
3504 enabled and 0 if it isn't. If the 'basic_skill_check' option is enabled, which
3505 it is by default, characters must have a certain number of basic skill levels to
3506 sit, request a trade, use emotions, etc. Making your script behave differently
3507 depending on whether the characters must actually have the skill to do all these
3508 things might in some cases be required.
3509
3510 ---------------------------------------
3511
3512 *checkoption(<option number>{,<char_id>})
3513 *checkoption1(<option number>{,<char_id>})
3514 *checkoption2(<option number>{,<char_id>})
3515 *setoption <option number>{,<flag>{,<char_id>}};
3516
3517 The 'setoption' series of functions check for a so-called option that is set on
3518 the invoking character. 'Options' are used to store status conditions and a lot
3519 of other non-permanent character data of the yes-no kind. For most common cases,
3520 it is better to use 'checkcart','checkfalcon','checkriding' and other similar
3521 functions, but there are some options which you cannot get at this way. They
3522 return 1 if the option is set and 0 if the option is not set.
3523
3524 Option numbers valid for the first (option) version of this command are:
3525
3526 0x1       - Sight in effect.
3527 0x2       - Hide in effect.
3528 0x4       - Cloaking in effect.
3529 0x8       - Cart number 1 present.
3530 0x10      - Falcon present.
3531 0x20      - Peco Peco present.
3532 0x40      - GM Perfect Hide in effect.
3533 0x80      - Cart number 2 present.
3534 0x100     - Cart number 3 present.
3535 0x200     - Cart number 4 present.
3536 0x400     - Cart number 5 present.
3537 0x800     - Orc head present.
3538 0x1000    - The character is wearing a wedding sprite.
3539 0x2000    - Ruwach is in effect.
3540 0x4000    - Chasewalk in effect.
3541 0x8000    - Flying or Xmas suit.
3542 0x10000   - Sighttrasher.
3543 0x100000  - Warg present.
3544 0x200000  - The character is riding a warg.
3545
3546 Option numbers valid for the second version (opt1) of this command are:
3547
3548 1 - Petrified.
3549 2 - Frozen.
3550 3 - Stunned.
3551 4 - Sleeping.
3552 6 - Petrifying (the state where you can still walk)
3553
3554 Option numbers valid for the third version (opt2) of this command are:
3555
3556 0x1  - Poisoned.
3557 0x2  - Cursed.
3558 0x4  - Silenced.
3559 0x8  - Signum Crucis (plays a howl-like sound effect, but otherwise no visible effects are displayed)
3560 0x10 - Blinded.
3561 0x80 - Deadly poisoned.
3562
3563 Option numbers (except for opt1) are bit-masks - you can add them up to check
3564 for several states, but the functions will return true if at least one of them
3565 is in effect.
3566
3567 'setoption' will set options on the invoking character. There are no second and
3568 third versions of this command, so you can only change the values in the first
3569 list (cloak, cart, ruwach, etc). if flag is 1 (default when omitted),
3570 the option will be added to what the character currently has; if 0, the option is removed.
3571
3572 This is definitely not a complete list of available option flag numbers. Ask a
3573 core developer (or read the source: src/map/status.h) for the full list.
3574
3575 ---------------------------------------
3576
3577 *setcart {<type>{,<char_id>}};
3578 *checkcart({<char_id>});
3579
3580 If <type> is 0 this command will remove the cart from the character.
3581 Otherwise it gives the invoking character a cart. The cart given will be
3582 cart number <type> and will work regardless of whether the character is a
3583 merchant class or not.
3584 Note: the character needs to have the skill MC_PUSHCART to gain a cart
3585
3586 The accompanying function will return 1 if the invoking character has a cart
3587 (any kind of cart) and 0 if they don't.
3588
3589     if (checkcart()) mes "But you already have a cart!";
3590
3591 ---------------------------------------
3592
3593 *setfalcon {<flag>{,<char_id>}};
3594 *checkfalcon({<char_id>});
3595
3596 If <flag> is 0 this command will remove the falcon from the character.
3597 Otherwise it gives the invoking character a falcon. The falcon will be there
3598 regardless of whether the character is a hunter or not. It will (probably) not
3599 have any useful effects for non-hunters though.
3600 Note: the character needs to have the skill HT_FALCON to gain a falcon
3601
3602 The accompanying function will return 1 if the invoking character has a falcon
3603 and 0 if they don't.
3604
3605     if (checkfalcon()) mes "But you already have a falcon!";
3606
3607 ---------------------------------------
3608
3609 *setriding {<flag>{,<char_id>}};
3610 *checkriding({<char_id>});
3611
3612 If <flag> is 0 this command will remove the mount from the character.
3613 Otherwise it gives the invoking character a PecoPeco (if they are a Knight
3614 series class), a GrandPeco (if they are a Crusader series class), or
3615 a Gryphon (if they are a Royal Guard). Unlike 'setfalcon' and 'setcart'
3616 this will not work at all if they aren't of a class which can ride.
3617 Note: the character needs to have the skill KN_RIDING to gain a mount
3618
3619 The accompanying function will return 1 if the invoking character is riding a
3620 bird and 0 if they aren't.
3621
3622     if (checkriding()) mes "PLEASE leave your bird outside! No riding birds on the floor here!";
3623
3624 ---------------------------------------
3625
3626 *setdragon {<color>{,<char_id>}};
3627 *checkdragon({<char_id>});
3628
3629 The 'setdragon' function toggles mounting a dragon for the invoking character.
3630 It will return 1 if successful, 0 otherwise.
3631
3632 The available colors are:
3633  1 - Green Dragon (default)
3634  2 - Brown Dragon
3635  3 - Gray Dragon
3636  4 - Blue Dragon
3637  5 - Red Dragon
3638
3639 Note: the character must be a Rune Knight and have the skill RK_DRAGONTRAINING to gain a mount
3640
3641 The accompanying function will return 1 if the invoking character is riding a
3642 dragon and 0 if they aren't.
3643
3644 ---------------------------------------
3645
3646 *setmadogear {<flag>{,<char_id>}};
3647 *checkmadogear({<char_id>});
3648
3649 If <flag> is 0 this command will remove the mount from the character.
3650 Otherwise it gives the invoking character a Mado (if they are a Mechanic).
3651
3652 The accompanying function will return 1 if the invoking character has a
3653 Mado and 0 if they don't.
3654
3655 ---------------------------------------
3656
3657 *setmounting {<char_id>};
3658 *ismounting({<char_id>});
3659
3660 The 'setmounting' function toggles cash mount for the invoking character.
3661 It will return 1 if successful, 0 otherwise.
3662
3663 Note: Character must not be mounting a non-cash mount (eg. dragon, peco, wug, etc.)
3664
3665 The accompanying function will return 1 if the invoking character has a
3666 cash mount and 0 if they don't.
3667
3668 ---------------------------------------
3669
3670 *checkwug({<char_id>});
3671
3672 This function will return 1 if the invoking character has a
3673 warg and 0 if they don't.
3674
3675 ---------------------------------------
3676
3677 *checkvending({"<Player Name>"})
3678
3679 Checks if the player is vending or has has a buyingstore. Additionally
3680 it gives you the information whether the player uses autotrade or not.
3681 Name is optional, and defaults to the attached player if omitted.
3682
3683 The returned value is bitmask of.
3684   0 = doesn't have a vending or buyingstore (which also means he can't use autotrade)
3685   1 = normal vending
3686   2 = using @autotrade
3687   4 = has a buyingstore
3688
3689 Examples:
3690         //This will check Aaron's state
3691         .@state = checkvending("Aaron");
3692         if (.@state&1)
3693                 mes "Aaron is currently vending!";
3694         if (.@state&4)
3695                 mes "Aaron has a buying store!";
3696         if (.@state&2)
3697                 mes "Aaron is autotrading!";
3698
3699 ---------------------------------------
3700
3701 *checkchatting({"<Player Name>"})
3702
3703 Checks if the player is in a chatroom.
3704 Name is optional, and defaults to the attached player if omitted.
3705 Returns 1 if they are in a chat room, 0 if they are not.
3706
3707 Examples:
3708         //This will check if the attached player in a chat room or not.
3709         if (checkchatting())
3710                 mes "You are currently in a chat room!";
3711
3712 ---------------------------------------
3713
3714 *checkidle({"<Player Name>"})
3715
3716 Returns the time, in seconds, that the specified player has been idle.
3717 Name is optional, and defaults to the attached player if omitted.
3718
3719 ---------------------------------------
3720
3721 *agitcheck()
3722 *agitcheck2()
3723 *agitcheck3()
3724
3725 These function will let you check whether the server is currently in WoE:FE mode
3726 (agitcheck()), WoE:SE mode (agitcheck2()), or WoE:TE mode (agitcheck3()) and will
3727 return true if War of Emperium is on and false if it isn't.
3728
3729 ---------------------------------------
3730
3731 *isnight()
3732 *isday()
3733
3734 These functions will return 1 or 0 depending on whether the server is in night
3735 mode or day mode. 'isnight' returns 1 if it's night and 0 if it isn't, 'isday'
3736 the other way around. They can be used interchangeably, pick the one you like
3737 more:
3738
3739     // These two are equivalent:
3740     if (isday()) mes "I only prowl in the night.";
3741     if (isnight() != 1) mes "I only prowl in the night.";
3742
3743 ---------------------------------------
3744
3745 *checkre(<type>)
3746
3747 Checks if a renewal feature is enabled or not in renewal.h, and returns 1 if
3748 enabled and 0 for disabled.
3749
3750 The renewal feature to check is determined by type.
3751  0 - RENEWAL (game renewal server mode)
3752  1 - RENEWAL_CAST (renewal cast time)
3753  2 - RENEWAL_DROP (renewal drop rate algorithms)
3754  3 - RENEWAL_EXP (renewal exp rate algorithms)
3755  4 - RENEWAL_LVDMG (renewal level modifier on damage)
3756  5 - RENEWAL_ASPD (renewal ASPD)
3757
3758 ---------------------------------------
3759 \\
3760 3,1.- Item-related commands
3761 \\
3762 ---------------------------------------
3763
3764 *isequipped(<id>{,<id>{,<id>{,<id>}}})
3765
3766 This function will return 1 if the invoking character has all of the item
3767 IDs given equipped (if card IDs are passed, then it checks if the cards are
3768 inserted into slots in the equipment they are currently wearing). Theoretically
3769 there is no limit to the number of items that may be tested for at the same time.
3770 If even one of the items given is not equipped, 0 will be returned.
3771
3772     // (Poring,Santa Poring,Poporing,Marin)
3773     if (isequipped(4001,4005,4033,4196)) mes "Wow! You're wearing a full complement of possible poring cards!";
3774     // (Poring)
3775     if (isequipped(4001)) mes "A poring card is useful, don't you think?";
3776
3777 The function was meant for item scripts to support the cards released by Gravity
3778 in February 2005, but it will work just fine in normal NPC scripts.
3779
3780 ---------------------------------------
3781
3782 *isequippedcnt(<card id>{,<card id>{,<card id>{,<card id>}}})
3783
3784 This function is similar to 'isequipped', but instead of 1 or 0, it will return
3785 the number of cards in the list given that were found on the invoking character.
3786
3787 If a given parameter is not a card, the function returns the amount of that
3788 item equipped on the invoking character.
3789
3790     if (isequippedcnt(4001,4005,4033,4196) == 4) mes "Finally got all four poring cards?";
3791
3792 ---------------------------------------
3793
3794 *checkequipedcard(<card id>)
3795
3796 This function will return 1 if the card specified by its item ID number is
3797 inserted into any equipment they have in their inventory, currently equipped or
3798 not.
3799
3800 ---------------------------------------
3801 //
3802 3,1.- End of item-related commands
3803 //
3804 ---------------------------------------
3805
3806 ==============================
3807 |4.- Player-related commands.|
3808 ==============================
3809 -------------------------
3810
3811 *attachrid(<account ID>)
3812 *detachrid;
3813
3814 These commands allow the manipulation of the script's currently attached player.
3815 While 'attachrid' allows attaching of a different player by using its account id
3816 for the parameter RID, 'detachrid' makes the following commands run as if the
3817 script was never invoked by a player.
3818
3819 The command returns 0 if the player cannot be attached (if the account is offline
3820 or does not exist), and 1 upon success.
3821
3822 -------------------------
3823
3824 *addrid(<type>{,<flag>{,<parameters>}});
3825
3826 This command will attach other RIDs to the current script without detaching the
3827 invoking RID. It returns 1 if successful and 0 upon failure.
3828
3829 <type> determines what RIDs are attached:
3830  0: All players in the server.
3831  1: All players in the map of the invoking player, or the invoking NPC if no player is attached.
3832  2: Party members of a specified party ID.
3833     [ Parameters: <party id> ]
3834  3: Guild members of a specified guild ID.
3835     [ Parameters: <guild id> ]
3836  4: All players in a specified area of the map of the invoking player (or NPC).
3837     [ Parameters: <x0>,<y0>,<x1>,<y1> ]
3838  5: All players in the map.
3839     [ Parameters: "<map name>" ]
3840  Account ID: If type is Account ID, attach the specified account ID.
3841
3842 <flag> can prevent certain players from being attached:
3843  0: Players are always attached. (default)
3844  1: Players currently running another script will not be attached.
3845
3846 ---------------------------------------
3847
3848 *rid2name(<rid>)
3849
3850 Converts rid to name. Note: The player/monster/NPC must be online/enabled.
3851 Good for PCKillEvent where you can convert 'killedrid' to the name of the player.
3852
3853 Note: rid2name may not produce correct character names since rid = account id.
3854       It will return the current online character of the account only.
3855
3856 ---------------------------------------
3857
3858 *message "<character name>","<message>";
3859
3860 That command will send a message to the chat window of the character specified
3861 by name. The text will also appear above the head of that character. It will not
3862 be seen by anyone else.
3863
3864 ---------------------------------------
3865
3866 *dispbottom "<message>"{,<color>{,<char_id>}};
3867
3868 This command will send the given message with color into the invoking character's chat
3869 window. The color format is in RGB (0xRRGGBB). The color is
3870 by default green
3871
3872 ---------------------------------------
3873
3874 *showscript "<message>"{,<GID>, <flag>};
3875
3876 Makes attached player or GID says a message like shouting a skill name, the message
3877 will be seen to everyone around but not in chat window.
3878 flag: Specify target
3879    AREA - Message is sent to players in the vicinity of the source (default).
3880    SELF - Message is sent only to player attached.
3881
3882 ---------------------------------------
3883
3884 *warp "<map name>",<x>,<y>{,<char id>};
3885
3886 This command will take the invoking character or <char id>, if specified, to the specified map, and if
3887 wanted, specified coordinates too, but these can be random.
3888
3889         warp "place",50,55;
3890
3891 This would take them to X 50 Y 55 on the map called "place". If your X and Y
3892 coordinates land on an unwalkable map square, it will send the warped character
3893 to a random place. Same will happen if they are both zero:
3894
3895         warp "place",0,0;
3896
3897 Notice that while warping people to coordinates 0,0 will normally get them into
3898 a random place, it's not certain to always be so. Darned if I know where this is
3899 actually coded, it might be that this happens because square 0,0 is unwalkable
3900 on all official maps. If you're using custom maps, beware.
3901
3902 There are also three special 'map names' you can use.
3903
3904 "Random" will warp the player randomly on the current map.
3905 "Save" and "SavePoint" will warp the player back to their save point.
3906
3907 ---------------------------------------
3908
3909 *areawarp "<from map name>",<x1>,<y1>,<x2>,<y2>,"<to map name>",<x3>,<y3>{,<x4>,<y4>};
3910
3911 This command is similar to 'warp', however, it will not refer to the invoking
3912 character, but instead, all characters within a specified area, defined by the
3913 x1/y1-x2/y2 square, will be warped. Nobody outside the area will be affected,
3914 including the activating character, if they are outside the area.
3915
3916         areawarp "place",10,10,120,120,"place2",150,150;
3917
3918 Everyone that is in the area between X 10 Y 10 and X 120 Y 120, in a square
3919 shape, on the map called "place", will be affected, and warped to "place2" X 150
3920 Y 150
3921
3922         areawarp "place",10,10,120,120,"place2",0,0;
3923
3924 By using ,0,0; as the destination coordinates it will take all the characters in
3925 the affected area to a random set of co-ordinates on "place2".
3926
3927         areawarp "place",10,10,120,120,"place2",150,150,200,200;
3928
3929 By using the optional x4 and y4 parameters, the destination coordinates will be a
3930 random place within the defined x3/y3-x4/y4 square.
3931
3932 Like 'warp', areawarp will also explicitly warp characters randomly into the
3933 current map if you give the 'to map name' as "Random".
3934
3935 See also 'warp'.
3936
3937 ---------------------------------------
3938
3939 *warpparty "<to_mapname>",<x>,<y>,<party_id>,{"<from_mapname>",<range x>,<range y>};
3940
3941 Warps a party to specified map and coordinate given the party ID, which you can get with
3942 getcharid(1). You can also request another party id given a member's name with getcharid(1,<player_name>).
3943
3944 You can use the following "map names" for special warping behavior:
3945 Random:       All party members are randomly warped in their current map (as if they
3946               all used a fly wing)
3947 SavePointAll: All party members are warped to their respective save point.
3948 SavePoint:    All party members are warped to the save point of the currently
3949               attached player (will fail if there's no player attached).
3950 Leader:       All party members are warped to the leader's position. The leader must
3951               be online and in the current map-server for this to work.
3952
3953 If you specify a from_mapname, 'warpparty' will only affect those on that map.
3954
3955 The <range x> and <range y> optional values allow for a randomization with the
3956 player's warp point. The values will randomly add or subtract from the given <x>
3957 and <y> coordinates.
3958
3959 Example:
3960         mes "[Party Warper]";
3961         mes "Here you go!";
3962         close2;
3963         .@party_id = getcharid(1);
3964         warpparty "prontera",150,100,.@party_id;
3965         close;
3966
3967 ---------------------------------------
3968
3969 *warpguild "<map name>",<x>,<y>,<guild_id>;
3970
3971 Warps a guild to specified map and coordinate given the guild id, which you can get with
3972 getcharid(2). You can also request another guild id given the member's name with getcharid(2,<player_name>).
3973
3974 You can use the following "map names" for special warping behavior:
3975 Random:       All guild members are randomly warped in their current map (as if they
3976               all used a fly wing)
3977 SavePointAll: All guild members are warped to their respective save point.
3978 SavePoint:    All guild members are warped to the save point of the currently
3979               attached player (will fail if there's no player attached).
3980
3981 Example:
3982
3983 warpguild "prontera",x,y,Guild_ID;
3984
3985 ---------------------------------------
3986
3987 *warppartner("<map name>",<x>,<y>);
3988
3989 This function will find the invoking character's marriage partner, if any, and
3990 warp them to the map and coordinates given. It will return 1 upon success and
3991 0 if the partner is not online, the character is not married, or if there's no
3992 invoking character (no RID). 0,0 will, as usual, normally translate to random coordinates.
3993
3994 ---------------------------------------
3995
3996 *savepoint "<map name>",<x>,<y>{,{<range x>,<range y>,}<char_id>};
3997 *save "<map name>",<x>,<y>{,{<range x>,<range y>,}<char_id>};
3998
3999 These commands save where the invoking character will return to upon clicking
4000 "Return to Save Point", after death and in some other cases. The two versions are
4001 equivalent. They ignore any and all mapflags, and can make a character respawn where
4002 no teleportation is otherwise possible.
4003
4004 The <range x> and <range y> optional values allow for a randomization with the
4005 player's save point. The values will randomly add or subtract from the given <x>
4006 and <y> coordinates.
4007
4008         savepoint "place",350,75;
4009         savepoint "place",350,75,2,2; // Randomly save the character between 348,73 and 352,77
4010
4011 ---------------------------------------
4012
4013 *heal <hp>,<sp>{,<char_id>};
4014
4015 This command will heal a set amount of HP and/or SP on the invoking character.
4016
4017         heal 30000,0; // This will heal 30,000 HP
4018         heal 0,30000; // This will heal 30,000 SP
4019         heal 300,300; // This will heal 300 HP and 300 SP
4020
4021 This command just alters the hit points and spell points of the invoking
4022 character and produces no other output whatsoever.
4023
4024 ---------------------------------------
4025
4026 *itemheal <hp>,<sp>{,<char_id>};
4027
4028 This command heals relative amounts of HP and/or SP on the invoking character.
4029 Unlike heal, this command is intended for use in item scripts. It applies
4030 potion-related bonuses, such as alchemist ranking, cards, and status changes.
4031 When used inside an NPC script, certain bonuses are omitted.
4032
4033 The command also applies a SP/VIT-related bonus:
4034         heal = heal * [(100 + STATUS*2) / 100]
4035
4036 Example:
4037         // If the player has 50 vit and no bonuses, this will heal
4038         // anything from 200 to 300 HP and 5 SP
4039         itemheal rand(100,150),5;
4040
4041 ---------------------------------------
4042
4043 *percentheal <hp>,<sp>{,<char_id>};
4044
4045 This command will heal the invoking character. It heals the character, but not
4046 by a set value - it adds percent of their maximum HP/SP.
4047
4048         percentheal 100,0; // This will heal 100% HP
4049         percentheal 0,100; // This will heal 100% SP
4050         percentheal 50,50; // This will heal 50% HP and 50% SP
4051
4052 So the amount that this will heal will depend on the total amount of HP or SP
4053 you have maximum. Like 'heal', this will not call up any animations or effects.
4054
4055 ---------------------------------------
4056
4057 *recovery <type>{,<option>,<revive_flag>{,<map name>}};
4058
4059 This command will revive and fully restore the HP/SP of the selected characters.
4060 It returns 1 upon successful use.
4061
4062 <type> is the target, and determines the <option> parameter:
4063  0: Player  -> Character ID number
4064  1: Party   -> Party ID number
4065  2: Guild   -> Guild ID number
4066  3: Map     -> Map name (a string)
4067  4: All     -> None (takes <revive_flag> as option)
4068
4069 If no option is specified, the invoking player's character ID, party ID, guild ID,
4070 or map will be used.
4071
4072 <revive_flag> determines the action:
4073  1: Revive and heal all players (default)
4074  2: Heal living players only
4075  4: Revive dead players only
4076
4077 <map name> can optionally be used to define a single map to execute the command on
4078 for types 1 (party) and 2 (guild).
4079
4080 Examples:
4081         // Only revive characters in invoking party on map "morocc"
4082         recovery 1,getcharid(1),4,"morocc";
4083
4084         // Fully heal (don't revive) all members of invoking character's guild
4085         recovery 2,getcharid(2),2;
4086
4087         // Revive and fully heal everyone in map "prontera"
4088         recovery 3,"prontera";
4089
4090         // Only revive all dead characters on server
4091         recovery 4,4;
4092
4093 ---------------------------------------
4094
4095 *jobchange <job number>{,<upper flag>,<char_id>};
4096
4097 This command will change the job class of the invoking character.
4098
4099         jobchange 1; // This would change your player into a Swordman
4100         jobchange 4002; // This would change your player into a Swordman High
4101
4102 This command does work with numbers, but you can also use job names. The full
4103 list of job names and the numbers they correspond to can be found in
4104 'src/map/script_constants.h'.
4105
4106         // This would change your player into a Swordman
4107         jobchange Job_Swordman;
4108         // This would change your player into a Swordman High
4109         jobchange Job_Swordman_High;
4110
4111 'upper flag' can alternatively be used to specify the type of job one changes
4112 to. For example, jobchange Job_Swordman,1; will change the character to a high
4113 swordsman. The upper values are:
4114 -1 (or when omitted): preserves the current job type.
4115 0: Normal/standard classes
4116 1: High/Advanced classes
4117 2: Baby classes
4118
4119 This command will also set a permanent character-based variable
4120 'jobchange_level' which will contain the job level at the time right before
4121 changing jobs, which can be checked for later in scripts.
4122
4123 ---------------------------------------
4124
4125 *jobname(<job number>)
4126
4127 This command retrieves the name of the given job using the map_msg entries 550->655.
4128
4129         mes "[Kid]";
4130         mes "I never thought I'd met a " + jobname(Class) + " here of all places.";
4131         close;
4132
4133 ---------------------------------------
4134
4135 *eaclass({<job number>,<char_id>})
4136
4137 This commands returns the "eA job-number" corresponding to the given class, and
4138 uses the invoking player's class if none is given. The eA job-number is also a
4139 class number system, but it's one that comes with constants which make it easy
4140 to convert among classes. The command will return -1 if you pass it a job number
4141 which doesn't have an eA job-number equivalent.
4142
4143         @eac = eaclass();
4144         if ((@eac&EAJ_BASEMASK) == EAJ_SWORDMAN)
4145                 mes "Your base job is Swordman.";
4146         if (@eac&EAJL_UPPER)
4147                 mes "You are a rebirth job.";
4148         if ((@eac&EAJ_UPPERMASK) == EAJ_SWORDMAN)
4149                 mes "You must be a Swordman, Baby Swordman or High Swordman.";
4150
4151 For more information on the eA Job System, see the docs/ea_job_system.txt file.
4152
4153 ---------------------------------------
4154
4155 *roclass(<job number>{,<gender>})
4156
4157 Does the opposite of eaclass. That is, given an eA job-number, it returns the
4158 corresponding RO class number. A gender is required because both Bard and Dancers
4159 share the same eA job-number (EAJ_BARDDANCER), and uses the invoking player's
4160 gender if none is given (if no player is attached, male will be used by default).
4161 The command will return -1 if there is no valid class to represent the specified
4162 job (for example, if you try to get the baby version of a Taekwon class).
4163
4164         @eac = eaclass();
4165         //Check if class is already rebirth
4166         if (@eac&EAJL_UPPER) {
4167                 mes "You look strong.";
4168                 close;
4169         }
4170         @eac = roclass(@eac|EAJL_UPPER);
4171         //Check if class has a rebirth version
4172         if (@eac != -1) {
4173                 mes "Bet you can't wait to become a " + jobname(@eac) + "!";
4174                 close;
4175         }
4176
4177 ---------------------------------------
4178
4179 *changebase <job ID number>{,<account ID>};
4180
4181 This command will change a character's appearance to that of the specified job
4182 class. Nothing but appearance will change.
4183
4184 The command will run for the invoking character unless an account ID is given.
4185
4186         changebase Job_Novice; // Changes player to Novice sprite.
4187         changebase Class; // Changes player back to default sprite.
4188
4189 ---------------------------------------
4190
4191 *classchange(<view id>{,"<NPC name>","<flag>"});
4192
4193 This command is very ancient, its origins are clouded in mystery.
4194 It will send a 'display id change' packet to everyone in the immediate area of
4195 the NPC object, which will supposedly make the NPC look like a different sprite,
4196 an NPC sprite ID, or a monster ID. This effect is not stored anywhere and will
4197 not persist (Which is odd, cause it would be relatively easy to make it do so)
4198 and most importantly, will not work at all since this command was broken with
4199 the introduction of advanced classes. The code is written with the assumption
4200 that the lowest sprite IDs are the job sprites and the anything beyond them is
4201 monster and NPC sprites, but since the advanced classes rolled in, they got the
4202 ID numbers on the other end of the number pool where monster sprites float.
4203
4204 As a result it is currently impossible to call this command with a valid view
4205 id. It will do nothing whatsoever if the view ID is below 4047. Getting it to
4206 run will actually just crash the client.
4207
4208 It could be a real gem if it can be gotten to actually do what it's supposed to
4209 do, but this will only happen in a later SVN revision.
4210
4211 Empty <NPC name> means attached NPC.
4212
4213 Target for <flag>:
4214 - bc_area : Sprite is sent to players in the vicinity of the source (default value).
4215 - bc_self : Sprite is sent only to player attached.
4216
4217 ---------------------------------------
4218
4219 *changesex({<char_id>});
4220
4221 This command will change the gender for the attached character's account. If it
4222 was male, it will become female, if it was female, it will become male. The
4223 change will be written to the character server, the player will receive the
4224 message: "Need disconnection to perform change-sex request..." and the player
4225 will be immediately kicked to the login screen. When they log back in, they will
4226 be the opposite sex.
4227
4228 If there are any Dancer/Gypsy or Bard/Clown characters on the account,
4229 they will also have their skills reset upon 'changesex'.
4230
4231 ---------------------------------------
4232
4233 *changecharsex({<char_id>});
4234
4235 This command will change the gender of the attached character. If it
4236 was male, it will become female, if it was female, it will become male. The
4237 change will be written to the character server, the player will receive the
4238 message: "Need disconnection to perform change-sex request..." and the player
4239 will be immediately kicked to the login screen. When they log back in, they will
4240 be the opposite sex.
4241
4242 If the character being changed is a Dancer/Gypsy or Bard/Clown class type,
4243 the character will also have their skills reset upon 'changecharsex'.
4244
4245 ---------------------------------------
4246
4247 *getexp <base_exp>,<job_exp>{,<char_id>};
4248
4249 This command will give the invoking character a specified number of base and job
4250 experience points. Used for a quest reward. Negative values won't work.
4251
4252 The EXP values are adjustted by 'quest_exp_rate' config value, VIP bonus, Guild
4253 Tax and EXP boost items such Battle Manual, Bubble Gum, or items that have
4254 SC_EXPBOOST or SC_ITEMBOOST.
4255
4256         getexp 10000,5000;
4257
4258 ---------------------------------------
4259
4260 *getexp2 <base_exp>,<job_exp>{,<char_id>};
4261
4262 This command is safety version of 'set' command for BaseExp and JobExp. If using
4263 'set' while the BaseExp or JobExp value is more than 2,147,483,647 (INT_MAX) will
4264 causing overflow error.
4265
4266 Unlike 'getexp', this command ignores the adjustment factors!
4267
4268 ---------------------------------------
4269
4270 *setlook <look type>,<look value>{,<char_id>};
4271 *changelook <look type>,<look value>{,<char_id>};
4272
4273 'setlook' will alter the look data for the invoking character. It is used
4274 mainly for changing the palette used on hair and clothes: you specify which look
4275 type you want to change, then the palette you want to use. Make sure you specify
4276 a palette number that exists/is usable by the client you use.
4277 'changelook' works the same, but is only client side (it doesn't save the look value).
4278
4279         // This will change your hair color, so that it uses palette 8, what ever your
4280         // palette 8 is, your hair will use that color
4281
4282         setlook LOOK_HAIR_COLOR,8;
4283
4284         // This will change your clothes color, so they are using palette 1, whatever
4285         // your palette 1 is, your clothes will then use that set of colors.
4286
4287         setlook LOOK_CLOTHES_COLOR,1;
4288
4289 Here are the possible look types:
4290
4291  LOOK_BASE - Base sprite
4292  LOOK_HAIR - Hairstyle
4293  LOOK_WEAPON - Weapon
4294  LOOK_HEAD_BOTTOM - Head bottom
4295  LOOK_HEAD_TOP - Head top
4296  LOOK_HEAD_MID - Head mid
4297  LOOK_HAIR_COLOR - Hair color
4298  LOOK_CLOTHES_COLOR - Clothes color
4299  LOOK_SHIELD - Shield
4300  LOOK_SHOES - Shoes
4301  LOOK_BODY2 - Body style
4302
4303 Whatever 'shoes' means is anyone's guess, ask Gravity - the client does nothing
4304 with this value. It still wants it from the server though, so it is kept, but
4305 normally doesn't do a thing.
4306
4307 Only the look data for hairstyle, hair color and clothes color are saved to the
4308 char server's database and will persist. Body style will also persist if 'save_body_style'
4309 configuration is enabled in '/conf/battle/client.conf'. The rest freely change as the character
4310 puts on and removes equipment, changes maps, logs in and out and otherwise you
4311 should not expect to set them. In fact, messing with them is generally
4312 hazardous, do it at your own risk, it is not tested what will this actually do -
4313 it won't cause database corruption and probably won't cause a server crash, but
4314 it's easy to crash the client with just about anything unusual.
4315
4316 However, it might be an easy way to quickly check for empty view IDs for
4317 sprites, which is essential for making custom headgear.
4318
4319 Since a lot of people have different palettes for hair and clothes, it's
4320 impossible to tell you what all the color numbers are. If you want a serious
4321 example, there is a Stylist script inside the default rAthena installation that
4322 you can look at: 'npc/custom/stylist.txt'
4323
4324 ---------------------------------------
4325
4326 *pushpc <direction>,<cells>;
4327
4328 This command will push the currently attached player to given direction by given
4329 amount of square cells. Direction is the same as used when declaring NPCs, and
4330 can be specified by using one of the DIR_* constants (src/map/script_constants.h).
4331
4332 The knock-back is not restricted by items or map flags, only obstacles are taken
4333 into account. If there is not enough space to perform the push (e.g. due to a
4334 wall), the character is pushed only up to the obstacle.
4335
4336         // pushes the character 5 cells in 3 o'clock direction from its
4337         // current position.
4338         pushpc DIR_EAST, 5;
4339
4340 ---------------------------------------
4341
4342 *recalculatestat;
4343
4344 This command will force a stat recalculation for the attached player.
4345
4346 ---------------------------------------
4347
4348 *needed_status_point(<type>,<val>{,<char id>});
4349
4350 Returns the number of stat points needed to change the specified stat <type> by <val>.
4351 If <val> is negative, returns the number of stat points that would be needed to
4352 raise the specified stat from (current value - <val>) to current value.
4353
4354 ---------------------------------------
4355
4356 *jobcanentermap("<mapname>"{,<JobID>});
4357
4358 Return true if player (decided by job) can enter the map, false otherwise.
4359
4360 For optional 'JobID', see constant of Job_*, or use player's Class, BaseJob,
4361 and BaseClass. If no player is attached, this param must have a value.
4362
4363 See also db/[pre-]re/job_noenter_map.txt
4364
4365 ---------------------------------------
4366
4367 *get_revision()
4368
4369 This command will return the SVN revision number that the server is currently
4370 running on.
4371
4372         if (get_revision() >= 15000)
4373                 mes "Welcome to rAthena!";
4374
4375 ---------------------------------------
4376
4377 *get_githash()
4378
4379 This command will return the Git Hash that the server is currently running on.
4380
4381         mes "Welcome to rAthena! Git Hash: " + get_githash();
4382
4383 ---------------------------------------
4384 \\
4385 4,1.- Item-related commands
4386 \\
4387 ---------------------------------------
4388
4389 *getitem <item id>,<amount>{,<account ID>};
4390 *getitem "<item name>",<amount>{,<account ID>};
4391
4392 This command will give an amount of specified items to the invoking character.
4393 If an optional account ID is specified, and the target character is currently
4394 online, items will be created in their inventory instead. If they are not
4395 online, nothing will happen.
4396
4397 In the first and most commonly used version of this command, items are
4398 referred to by their database ID number found inside 'db/(pre-)re/item_db.txt'.
4399
4400         getitem 502,10 // The person will receive 10 apples
4401         getitem 617,1  // The person will receive 1 Old Violet Box
4402
4403 This transaction is logged if the log script generated transactions option is
4404 enabled.
4405
4406 You may also create an item by its name in the 'english name' field in the
4407 item database:
4408
4409         getitem "RED_POTION",10;
4410
4411 Which will do what you'd expect. If it can't find that name in the database,
4412 apples will be created anyway. It is often a VERY GOOD IDEA to use it like this.
4413
4414 This is used in pretty much all NPC scripts that have to do with items and
4415 quite a few item scripts. For more examples check just about any official script.
4416
4417 ---------------------------------------
4418
4419 *getitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4420 *getitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4421 *getitem3 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>{,<account ID>};
4422 *getitem3 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>{,<account ID>};
4423
4424 This command will give an amount of specified items to the invoking character.
4425 If an optional account ID is specified, and the target character is currently
4426 online, items will be created in their inventory instead. If they are not
4427 online, nothing will happen. It works essentially the same as 'getitem' but is
4428 a lot more flexible.
4429
4430 Those parameters that are different from 'getitem' are:
4431
4432 identify    - Whether you want the item to be identified (1) or not (0).
4433 refine      - For how many pluses will it be refined.
4434               It will not let you refine an item higher than the max refine.
4435 attribute   - Whether the item is broken (1) or not (0).
4436 card1,2,3,4 - If you want a card compound to it, place the card ID number into
4437               the specific card slot.
4438
4439 Card1-card4 values are also used to store name information for named items, as
4440 well as the elemental property of weapons and armor. You can create a named item
4441 in this manner, however, if you just need a named piece of standard equipment,
4442 it is much easier to the 'getnameditem' function instead.
4443
4444 You will need to keep these values if you want to destroy and then perfectly
4445 recreate a named item, for this see 'getinventorylist'.
4446
4447 If you still want to try creating a named item with this command because
4448 'getnameditem' won't do it for you cause it's too limited, you can do it like
4449 this. Careful, minor magic ahead.
4450
4451         // First, let's get an ID of a character who's name will be on the item.
4452         // Only an existing character's name may be there.
4453         // Let's assume our character is 'Adam' and find his ID.
4454         @charid = getcharid(0,"Adam");
4455
4456         // Now we split the character ID number into two portions with a binary
4457         // shift operation. If you don't understand what this does, just copy it.
4458         @card3 = @charid & 65535;
4459         @card4 = @charid >> 16;
4460
4461         // If you're inscribing non-equipment, @card1 must be 254.
4462         // Arrows are also not equipment.
4463         @card1 = 254;
4464
4465         // For named equipment, card2 means the Star Crumbs and elemental
4466         // crystals used to make this equipment. For everything else, it's 0.
4467         @card2 = 0;
4468
4469         // Now, let's give the character who invoked the script some
4470         // Adam's Apples:
4471         getitem2 512,1,1,0,0,@card1,@card2,@card3,@card4;
4472
4473 This wasn't tested with all possible items, so I can't give any promises,
4474 experiment first before relying on it.
4475
4476 To create equipment, continue this example it like this:
4477
4478         // We've already have card3 and card4 loaded with correct
4479         // values so we'll just set up card1 and card2 with data
4480         // for an Ice Stiletto.
4481
4482         // If you're inscribing equipment, @card1 must be 255.
4483         @card1 = 255;
4484
4485         // That's the number of star crumbs in a weapon.
4486         @sc = 2;
4487
4488         // That's the number of elemental property of the weapon.
4489         @ele = 1;
4490
4491         // And that's the wacky formula that makes them into
4492         // a single number.
4493         @card2 = @ele+((@sc*5)<<8);
4494
4495         // That will make us an Adam's +2 VVS Ice Stiletto:
4496         getitem2 1216,1,1,2,0,@card1,@card2,@card3,@card4;
4497
4498 Experiment with the number of star crumbs - I'm not certain just how much will
4499 work most and what it depends on. The valid element numbers are:
4500
4501  1 - Ice, 2 - Earth 3 - Fire 4 - Wind.
4502
4503 You can, apparently, even create duplicates of the same pet egg with this
4504 command, creating a pet which is the same, but simultaneously exists in two
4505 eggs, and may hatch from either, although, I'm not sure what kind of a mess will
4506 this really cause.
4507
4508 'getitem3' is advance version of 'getitem2' that also use Item Random Option as additional values.
4509 <RandomIDArray>    : Array variable of ID for item random option, see db/[pre-]re/item_randomopt_db.txt
4510 <RandomValueArray> : Array variable of item random option's value.
4511 <RandomParamArray> : Array variable of item random option's param.
4512
4513 Example to get Crimson Weapon with Ghost property:
4514         // +9 Crimson Dagger [2]
4515         setarray .@OptID[0],RDMOPT_WEAPON_ATTR_TELEKINESIS;
4516         setarray .@OptVal[0],0;
4517         setarray .@OptParam[0],0;
4518         getitem3 28705,1,1,9,0,0,0,0,0,.@OptID,.@OptVal,.@OptParam;
4519
4520 ---------------------------------------
4521
4522 *getitembound <item id>,<amount>,<bound type>{,<account ID>};
4523 *getitembound "<item name>",<amount>,<bound type>{,<account ID>};
4524
4525 This command behaves identically to 'getitem', but the items created will be
4526 bound to the target character as specified by the bound type. All items created
4527 in this manner cannot be dropped, sold, vended, auctioned, or mailed, and in
4528 some cases cannot be traded or stored.
4529
4530 Valid bound types are:
4531  Bound_Account : Account Bound item
4532  Bound_Guild   : Guild Bound item
4533  Bound_Party   : Party Bound item
4534  Bound_Char    : Character Bound item
4535
4536 ---------------------------------------
4537
4538 *getitembound2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<bound type>{,<account ID>};
4539 *getitembound2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<bound type>{,<account ID>};
4540 *getitembound3 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<bound type>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>{,<account ID>};
4541 *getitembound3 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<bound type>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>{,<account ID>};
4542
4543 This command behaves identically to 'getitem2', but the items created will be
4544 bound to the target character as specified by the bound type. All items created
4545 in this manner cannot be dropped, sold, vended, auctioned, or mailed, and in
4546 some cases cannot be traded or stored.
4547
4548 For a list of bound types see 'getitembound'.
4549
4550 'getitembound3' is advance version of 'getitembound2' that also use Item Random Option as additional values.
4551 <RandomIDArray>    : Array variable of ID for item random option, see db/[pre-]re/item_randomopt_db.txt
4552 <RandomValueArray> : Array variable of item random option's value.
4553 <RandomParamArray> : Array variable of item random option's param.
4554
4555 Example to get Crimson Weapon with Ghost property:
4556         // +9 Crimson Dagger [2]
4557         setarray .@OptID[0],RDMOPT_WEAPON_ATTR_TELEKINESIS;
4558         setarray .@OptVal[0],0;
4559         setarray .@OptParam[0],0;
4560         getitembound3 28705,1,1,9,0,0,0,0,0,BOUND_CHAR,.@OptID,.@OptVal,.@OptParam;
4561
4562 ---------------------------------------
4563
4564 *getnameditem <item id>,<character name|character ID>;
4565 *getnameditem "<item name>",<character name|character ID>;
4566
4567 Create an item signed with the given character's name.
4568
4569 The command returns 1 when the item is created successfully, or 0 if it fails.
4570 Failure occurs when:
4571 - There is no player attached.
4572 - Item name or ID is not valid.
4573 - The given character ID/name is offline.
4574
4575 Example:
4576
4577 //This will give the currently attached player a Aaron's Apple (if Aaron is online).
4578         getnameditem "Apple","Aaron";
4579
4580 //Self-explanatory (I hope).
4581         if (getnameitem("Apple","Aaron")) {
4582                 mes "You now have a Aaron's Apple!";
4583         }
4584
4585 ---------------------------------------
4586
4587 *rentitem <item id>,<time>{,<account_id>};
4588 *rentitem "<item name>",<time>{,<account_id>};
4589
4590 Creates a rental item in the attached character's inventory. The item will expire
4591 in <time> seconds and be automatically deleted. When receiving a rental item,
4592 the character will receive a message in their chat window. The character will
4593 also receive warning messages in their chat window before the item disappears.
4594
4595 When rentals expire it will call the OnUnequip Script of the item. This can be used
4596 for special cases such as removing a status change or resetting a variable or state
4597 of the player.
4598
4599 This command can not be used to rent stackable items. Rental items cannot be
4600 dropped, traded, sold to NPCs, or placed in guild storage. (i.e. trade mask 75)
4601 Note: 'delitem' in an NPC script can still remove rental items.
4602
4603 ---------------------------------------
4604
4605 *rentitem2 <item id>,<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account_id>};
4606 *rentitem2 "<item name>",<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account_id>};
4607 *rentitem3 <item id>,<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>{,<account_id>};
4608 *rentitem3 "<item name>",<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>{,<account_id>};
4609
4610 Creates a rental item in the attached character's inventory. The item will expire
4611 in <time> seconds and be automatically deleted. See 'rentitem' for further details.
4612
4613 See 'getitem2' for an explanation of the expanded parameters.
4614
4615 'rentitem3' is advance version of 'rentitem2' that also use Item Random Option as additional values.
4616 <RandomIDArray>    : Array variable of ID for item random option, see db/[pre-]re/item_randomopt_db.txt
4617 <RandomValueArray> : Array variable of item random option's value.
4618 <RandomParamArray> : Array variable of item random option's param.
4619
4620 Example to get Crimson Weapon with Ghost property:
4621         // +9 Crimson Dagger [2]
4622         setarray .@OptID[0],RDMOPT_WEAPON_ATTR_TELEKINESIS;
4623         setarray .@OptVal[0],0;
4624         setarray .@OptParam[0],0;
4625         rentitem3 28705,(24*60*60),1,9,0,0,0,0,0,.@OptID,.@OptVal,.@OptParam;
4626
4627 ---------------------------------------
4628
4629 *makeitem <item id>,<amount>,"<map name>",<X>,<Y>;
4630 *makeitem "<item name>",<amount>,"<map name>",<X>,<Y>;
4631
4632 This command will create an item on the specified cell of a map.
4633
4634 As with any dropped items, the items created with this command will disappear after
4635 a period of time. Using an amount greater than 1 will create a single stack of the
4636 given amount, not multiple stacks of 1.
4637
4638 Like 'getitem', it also accepts an 'english name' field from the database and creates
4639 Apples if the name isn't found.
4640 If the map name is given as "this", the map the invoking character is on will be used.
4641
4642 ---------------------------------------
4643
4644 *makeitem2 <item id>,<amount>,"<map name>",<X>,<Y>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
4645 *makeitem2 "<item name>",<amount>,"<map name>",<X>,<Y>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
4646 *makeitem3 <item id>,<amount>,"<map name>",<X>,<Y>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>;
4647 *makeitem3 "<item name>",<amount>,"<map name>",<X>,<Y>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>;
4648
4649 This command will create an item on the specified cell of a map. See 'makeitem' for
4650 further details.
4651
4652 See 'getitem2' for an explanation of the expanded parameters.
4653
4654 'makeitem3' is advance version of 'makeitem2' that also use Item Random Option as additional values.
4655 <RandomIDArray>    : Array variable of ID for item random option, see db/[pre-]re/item_randomopt_db.txt
4656 <RandomValueArray> : Array variable of item random option's value.
4657 <RandomParamArray> : Array variable of item random option's param.
4658
4659 Example to get Crimson Weapon with Ghost property:
4660         // 0.5% chance to get +0 Valkyrie Shield [1]
4661         // with Neutral Resistance +10% and 5% damage reduction from Demi-Human or Player
4662         // when Valkyrie Randgris killed
4663         OnNPCKillEvent:
4664                 if (killedrid == 1751 && rand(0,1000) > 950) { // Valkyrie Randgris
4665                         getmapxy(.@map$,.@x,.@y,UNITTYPE_PC);
4666                         setarray .@OptID[0],RDMOPT_ATTR_TOLERACE_NOTHING,RDMOPT_RACE_TOLERACE_HUMAN;
4667                         setarray .@OptVal[0],10,5;
4668                         setarray .@OptParam[0],0;
4669                         makeitem3 2115,1,.@map$,.@x,.@y,0,0,0,0,0,0,0,.@OptID,.@OptVal,.@OptParam;
4670                 }
4671                 end;
4672
4673 ---------------------------------------
4674
4675 *cleanarea "<map name>",<x1>,<y1>,<x2>,<y2>;
4676 *cleanmap "<map name>";
4677
4678 These commands will clear all items lying on the ground on the specified map, either
4679 within the x1/y1-x2/y2 rectangle or across the entire map.
4680
4681 ---------------------------------------
4682
4683 *searchitem <array name>,"<item name>";
4684
4685 This command will fill the given array with the ID of items whose name matches
4686 the given one. It returns the number of items found. For performance reasons,
4687 the results array is limited to 10 items.
4688
4689         mes "What item are you looking for?";
4690         input .@name$;
4691         .@qty = searchitem(.@matches[0],.@name$);
4692         mes "I found " + .@qty + " items:";
4693         for (.@i = 0; .@i < .@qty; .@i++)
4694                 // Display name (eg: "Apple[0]")
4695                 mes getitemname(.@matches[.@i]) + "[" + getitemslots(.@matches[.@i]) + "]";
4696
4697 ---------------------------------------
4698
4699 *delitem <item id>,<amount>{,<account ID>};
4700 *delitem "<item name>",<amount>{,<account ID>};
4701
4702 This command will remove a specified amount of items from the invoking/target character.
4703 Like all the item commands, it uses the item ID found inside 'db/(pre-)re/item_db.txt'.
4704
4705     delitem 502,10; // The person will lose 10 apples
4706     delitem 617,1;  // The person will lose 1 Old Violet Box
4707
4708 It is always a good idea to check if the player actually has the items before you delete them.
4709 If you try to delete more items that the player has, the player will lose the ones he/she has
4710 and the script will terminate with an error.
4711
4712 Like 'getitem', this command will also accept an 'english name' field from the
4713 database. If the name is not found, nothing will be deleted.
4714
4715 ---------------------------------------
4716
4717 *cartdelitem <item id>,<amount>{,<account ID>};
4718 *cartdelitem "<item name>",<amount>{,<account ID>};
4719 *storagedelitem <item id>,<amount>{,<account ID>};
4720 *storagedelitem "<item name>",<amount>{,<account ID>};
4721 *guildstoragedelitem <item id>,<amount>{,<account ID>};
4722 *guildstoragedelitem "<item name>",<amount>{,<account ID>};
4723
4724 This command behaves identically to 'delitem', but deletes items from the player's
4725 cart, storage, or guild storage.
4726
4727 If no cart is mounted, 'cartdelitem' will return -1.
4728 If player is not in a guild or storage is open, 'guildstoragedelitem' will return -1.
4729
4730 ---------------------------------------
4731
4732 *delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4733 *delitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4734 *delitem3 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>{,<account ID>};
4735 *delitem3 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>{,<account ID>};
4736
4737 This command will remove a specified amount of items from the invoking/target character.
4738 See 'getitem2' for an explanation of the expanded parameters.
4739
4740 'delitem3' is advance version of 'delitem2' that also use Item Random Option as criteria.
4741 <RandomIDArray>    : Array variable of ID for item random option, see db/[pre-]re/item_randomopt_db.txt
4742 <RandomValueArray> : Array variable of item random option's value.
4743 <RandomParamArray> : Array variable of item random option's param.
4744
4745 ---------------------------------------
4746
4747 *cartdelitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4748 *cartdelitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4749 *storagedelitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4750 *storagedelitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4751 *guildstoragedelitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4752 *guildstoragedelitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
4753
4754 This command behaves identically to 'delitem2', but deletes items from the player's
4755 cart, storage, or guild storage.
4756
4757 If no cart is mounted, 'cartdelitem2' will return -1.
4758 If player is not in a guild or storage is open, 'guildstoragedelitem2' will return -1.
4759
4760 ---------------------------------------
4761
4762 *countitem(<item id>)
4763 *countitem("<item name>")
4764
4765 This function will return the number of items for the specified item ID that the
4766 invoking character has in the inventory.
4767
4768         mes "[Item Checker]";
4769         mes "Hmmm, it seems you have " + countitem(502) + " apples";
4770         close;
4771
4772 Like 'getitem', this function will also accept an 'english name' from the
4773 database as an argument.
4774
4775 If you want to state the number at the end of a sentence, you can do it by
4776 adding up strings:
4777
4778         mes "[Item Checker]";
4779         mes "Hmmm, the total number of apples you are holding is " + countitem("APPLE");
4780         close;
4781
4782 ---------------------------------------
4783
4784 *cartcountitem(<item id>{,<accountID>})
4785 *cartcountitem("<item name>"{,<accountID>})
4786 *storagecountitem(<item id>{,<accountID>})
4787 *storagecountitem("<item name>"{,<accountID>})
4788 *guildstoragecountitem(<nameID>{,<accountID>})
4789 *guildstoragecountitem("<item name>"{,<accountID>})
4790
4791 This command behaves identically to 'countitem', but counts items from the player's
4792 cart, storage, or guild storage.
4793
4794 If no cart is mounted, 'cartcountitem' will return -1.
4795 If player is not in a guild or storage is open, 'guildstoragecountitem' will return -1.
4796
4797 ---------------------------------------
4798
4799 *countitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
4800 *countitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
4801 *countitem3(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>)
4802 *countitem3("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>)
4803
4804 Expanded version of 'countitem' function, used for created/carded/forged items.
4805
4806 This function will return the number of items for the specified item ID and
4807 other parameters that the invoking character has in the inventory.
4808 See 'getitem2' for an explanation of the expanded parameters.
4809
4810 'countitem3' is advance version of 'countitem2' that also use Item Random Option as criteria.
4811 <RandomIDArray>    : Array variable of ID for item random option, see db/[pre-]re/item_randomopt_db.txt
4812 <RandomValueArray> : Array variable of item random option's value.
4813 <RandomParamArray> : Array variable of item random option's param.
4814
4815 ---------------------------------------
4816
4817 *cartcountitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<accountID>})
4818 *cartcountitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<accountID>})
4819 *storagecountitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<accountID>})
4820 *storagecountitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<accountID>})
4821 *guildstoragecountitem2(<nameID>,<Identified>,<Refine>,<Attribute>,<Card0>,<Card1>,<Card2>,<Card3>{,<accountID>})
4822 *guildstoragecountitem2("<item name>",<Identified>,<Refine>,<Attribute>,<Card0>,<Card1>,<Card2>,<Card3>{,<accountID>})
4823
4824 This command behaves identically to 'countitem2', but counts items from the player's
4825 cart, storage, or guild storage.
4826
4827 If no cart is mounted, 'cartcountitem2' will return -1.
4828 If player is not in a guild or storage is open, 'guildstoragecountitem2' will return -1.
4829
4830 ---------------------------------------
4831
4832 *countbound({<bound type>{,<char_id>}})
4833
4834 This function will return the number of bounded items in the character's
4835 inventory, and sets an array @bound_items[] containing all item IDs of the
4836 counted items. If a bound type is specified, only those items will be counted.
4837
4838 For a list of bound types see 'getitembound'.
4839
4840 Example:
4841         mes "You currently have " + countbound() + " bounded items.";
4842         next;
4843         mes "The list of bounded items include:";
4844         for(.@i = 0; .@i < getarraysize(@bound_items); .@i++)
4845                 mes getitemname(@bound_items[.@i]);
4846         close;
4847
4848 ---------------------------------------
4849
4850 *groupranditem <group id>{,<sub_group>};
4851
4852 Returns the item_id of a random item picked from the group specified. The
4853 different groups and their group number are specified in 'db/(pre-)re/item_group_db.txt'.
4854
4855 When used in conjunction with other functions, you can get a random item. For
4856 example, for a random pet lure:
4857
4858 getitem groupranditem(IG_Taming),1;
4859
4860 'sub_group' is used to get the available random items of item group from specified random
4861 group. 0 for 'must' item group, and random item group is 1 until 5 (MAX_ITEMGROUP_RANDGROUP+1).
4862
4863 More info, see doc/item_group.txt.
4864
4865 ---------------------------------------
4866
4867 *getrandgroupitem <group_id>{,<quantity>{,<sub_group>}};
4868
4869 Similar to the above example, this command allows players to obtain the specified
4870 quantity of a random item from the group "<group id>". The different groups and
4871 their group number are specified in db/(pre-)re/item_group_db.txt
4872
4873 If 'quantity' is not defined or 0, it will uses defined amount from Item Group list.
4874
4875 If 'sub_group' is not defined the value will be 1 (since random group is 1 ~ 5, and 0 is
4876 'must' item group).
4877
4878 More info, see doc/item_group.txt.
4879
4880 ---------------------------------------
4881
4882 *getgroupitem <group_id>{,<char_id>};
4883
4884 Gives item(s) to the attached player based on item group contents.
4885 This is not working like 'getrandgroupitem' which only give 1 item for specified
4886 item group & sub_group.
4887
4888 More info, see doc/item_group.txt.
4889
4890 ---------------------------------------
4891
4892 *enable_items;
4893 *disable_items;
4894
4895 These commands toggle the ability to change equipment while interacting with
4896 an NPC. To avoid possible exploits, the commands affect the particular script
4897 instance only. Note that if a different script also calls enable_items, it
4898 will override the last call (so you may want to call this command at the start
4899 of your script without assuming it is still in effect).
4900
4901 The default setting, 'item_enabled_npc', is defined in 'conf/battle/items.conf'.
4902
4903 ---------------------------------------
4904
4905 *itemskill <skill id>,<skill level>{,<keep requirement>};
4906 *itemskill "<skill name>",<skill level>{,<keep requirement>};
4907
4908 This command is meant for item scripts to replicate single-use skills in usable
4909 items. It will not work properly if there is a visible dialog window or menu.
4910 If the skill is self or auto-targeting, it will be used immediately; otherwise a
4911 target cursor is shown.
4912
4913 If <keep requirement> parameter is set to true, the skill's requirements will be checked.
4914 By default, the requirements for item skills are not checked, and therefore the default value is false.
4915
4916 // When Anodyne is used, it will cast Endure (8), Level 1, as if the actual
4917 // skill has been used from skill tree.
4918 605,Anodyne,Anodyne,11,2000,0,100,,,,,10477567,2,,,,,{ itemskill 8,1; },{}
4919
4920 // When Sienna_Execrate_Scroll_1_5 is used, it will cast Sienna Execrate Level 5 and consume 2 Red_Gemstones.
4921 23194,Sienna_Execrate_Scroll_1_5,Level 5 Sienna Execrate,11,10,,10,,,,,0xFFFFFFFF,63,2,,,,,,{ itemskill "WL_SIENNAEXECRATE",5,true; },{},{}
4922
4923 ---------------------------------------
4924
4925 *consumeitem <item id>{,<char_id>};
4926 *consumeitem "<item name>"{,<char_id>};
4927
4928 This command will run the item script of the specified item on the invoking
4929 character. The character does not need to possess the item, and the item will
4930 not be deleted. While this command is intended for usable items, it will run
4931 for any item type.
4932
4933 This command does not currently work with the 'itemskill' script command.
4934
4935 ---------------------------------------
4936
4937 *produce <item level>;
4938
4939 This command will open a crafting window on the client connected to the invoking
4940 character. The 'item level' is a number which determines what kind of a crafting
4941 window will pop-up.
4942
4943 You can see the full list of such item levels in 'db/produce_db.txt' which determines
4944 what can actually be produced. The window will not be empty only if the invoking
4945 character can actually produce the items of that type and has the appropriate raw
4946 materials in their inventory.
4947
4948 The success rate to produce the item is the same as the success rate of the skill
4949 associated with the item level. If there is no skill id, the success rate will be 50%.
4950
4951 Valid item levels are:
4952
4953  1   - Level 1 Weapons
4954  2   - Level 2 Weapons
4955  3   - Level 3 Weapons
4956  21  - Blacksmith's Stones and Metals
4957  22  - Alchemist's Potions, Holy Water, Assassin Cross's Deadly Poison
4958  23  - Elemental Converters
4959
4960 ---------------------------------------
4961
4962 *cooking <dish level>;
4963
4964 This command will open a produce window on the client connected to the invoking
4965 character. The 'dish level' is the number which determines what kind of dish
4966 level you can produce. You can see the full list of dishes that can be produced in
4967 'db/produce_db.txt'.
4968
4969 The window will be shown empty if the invoking character does not have enough of
4970 the required incredients to cook a dish.
4971
4972 Valid dish levels are:
4973
4974 11 - Level 1 Dish
4975 12 - Level 2 Dish
4976 13 - Level 3 Dish
4977 14 - Level 4 Dish
4978 15 - Level 5 Dish
4979 16 - Level 6 Dish
4980 17 - Level 7 Dish
4981 18 - Level 8 Dish
4982 19 - Level 9 Dish
4983 20 - Level 10 Dish
4984
4985 Although it's required to set a dish level, it doesn't matter if you set it to 1
4986 and you want to cook a level 10 dish, as long as you got the required incredients
4987 to cook the dish the command works.
4988
4989 ---------------------------------------
4990
4991 *makerune <% success bonus>{,<char_id>};
4992
4993 This command will open a rune crafting window on the client connected to the
4994 invoking character. Since this command is officially used in rune ores, a bonus
4995 success rate must be specified (which adds to the base formula).
4996
4997 You can see the full list of runes that can be produced in 'db/produce_db.txt'.
4998 The window will not be empty only if the invoking character can actually produce
4999 a rune and has the appropriate raw materials in their inventory.
5000
5001 ---------------------------------------
5002
5003 *successremovecards <equipment slot>;
5004
5005 This command will remove all cards of the cards slots defined by item_db.txt
5006 from the item found in the specified equipment slot of the invoking character,
5007 create new card items and give them to the character.
5008 If any cards were removed in this manner, it will also show a success effect.
5009
5010 ---------------------------------------
5011
5012 *failedremovecards <equipment slot>,<type>;
5013
5014 This command will remove all cards from the item found in the specified
5015 equipment slot of the invoking character. 'type' determines what happens to the
5016 item and the cards:
5017
5018  0 - will destroy both the item and the cards.
5019  1 - will keep the item, but destroy the cards.
5020  2 - will keep the cards, but destroy the item.
5021
5022 Whatever the type is, it will also show a failure effect on screen.
5023
5024 ---------------------------------------
5025
5026 *repair <broken item number>{,<char_id>};
5027
5028 This command repairs a broken piece of equipment, using the same list of broken
5029 items as available through 'getbrokenid'.
5030
5031 ---------------------------------------
5032
5033 *repairall {<char_id>};
5034
5035 This command repairs all broken equipment in the attached player's inventory.
5036 A repair effect will be shown if any items are repaired, else the command will
5037 end silently.
5038
5039 ---------------------------------------
5040
5041 *successrefitem <equipment slot>{,<count>{,<char_id>}};
5042
5043 This command will refine an item in the specified equipment slot of the invoking
5044 character by +1, or a count if given. For a list of equipment slots see 'getequipid'.
5045 This command will also display a 'refine success' effect on the character and put
5046 appropriate messages into their chat window. It will also give the character fame
5047 points if a weapon reached +10 this way, even though these will only take effect for
5048 blacksmith who will later forge a weapon.
5049
5050 ---------------------------------------
5051
5052 *failedrefitem <equipment slot>{,<char_id>};
5053
5054 This command will fail to refine an item in the specified equipment slot of the
5055 invoking character. The item will be destroyed. This will also display a 'refine
5056 failure' effect on the character and put appropriate messages into their chat
5057 window.
5058
5059 ---------------------------------------
5060
5061 *downrefitem <equipment slot>{,<count>{,<char_id>}};
5062
5063 This command will downgrade an item in the specified equipment slot of the invoking
5064 character by -1, or a count if given. For a list of equipment slots see 'getequipid'.
5065 This command will also display a 'refine failure' effect on the character and put
5066 appropriate messages into their chat window.
5067
5068 ---------------------------------------
5069
5070 *unequip <equipment slot>{,<char_id>};
5071
5072 This command will unequip whatever is currently equipped in the invoking
5073 character's specified equipment slot. For a full list of possible equipment
5074 slots see 'getequipid'.
5075
5076 If an item occupies several equipment slots, it will get unequipped from all of
5077 them.
5078
5079 ---------------------------------------
5080
5081 *delequip <equipment slot>{,<char_id>};
5082
5083 This command will destroy whatever is currently equipped in the invoking
5084 character's specified equipment slot. For a full list of possible equipment
5085 slots see 'getequipid'.
5086
5087 This command will return 1 if an item was deleted and 0 otherwise.
5088
5089 ---------------------------------------
5090
5091 *breakequip <equipment slot>{,<char_id>};
5092
5093 This command will break and unequip whatever is currently equipped in the
5094 invoking character's specified equipment slot. For a full list of possible
5095 equipment slots see 'getequipid'.
5096
5097 This command will return 1 if an item was broken and 0 otherwise.
5098
5099 ---------------------------------------
5100
5101 *clearitem {<char_id>};
5102
5103 This command will destroy all items the invoking character has in their
5104 inventory (including equipped items). It will not affect anything else, like
5105 storage or cart.
5106
5107 ---------------------------------------
5108
5109 *equip <item id>{,<char_id>};
5110 *autoequip <item id>,<option>;
5111
5112 These commands are to equip a equipment on the attached character.
5113 The equip function will equip the item ID given when the player has
5114 this item in his/her inventory, while the autoequip function will
5115 equip the given item ID when this is looted. The option parameter of
5116 the autoequip is 1 or 0, 1 to turn it on, and 0 to turn it off.
5117
5118 Examples:
5119
5120 //This will equip a 1104 (falchion) on the character if this is in the inventory.
5121         equip 1104;
5122
5123 //The invoked character will now automatically equip a falchion when it's looted.
5124         autoequip 1104,1;
5125
5126 //The invoked character will no longer automatically equip a falchion.
5127         autoequip 1104,0;
5128
5129 ---------------------------------------
5130
5131 *buyingstore <slots>;
5132
5133 Invokes buying store preparation window like the skill 'Open Buying Store',
5134 without the item requirement. Amount of slots is limited by the server to
5135 a maximum of 5 slots by default.
5136
5137 Example:
5138         // Gives the player opportunity to buy 4 different kinds of items.
5139         buyingstore 4;
5140
5141 ---------------------------------------
5142
5143 *searchstores <uses>,<effect>;
5144
5145 Invokes the store search window, which allows to search for both vending
5146 and buying stores. Parameter uses indicates, how many searches can be
5147 started, before the window has to be reopened. Effect value affects,
5148 what happens, when a result item is double-clicked and can be one of the
5149 following:
5150
5151         0 = Shows the store's position on the mini-map and highlights the
5152             shop sign with yellow color, when the store is on same map
5153             as the invoking player.
5154         1 = Directly opens the shop, regardless of distance.
5155
5156 Example:
5157         // Item Universal_Catalog_Gold (10 uses, effect: open shop)
5158         searchstores 10,1;
5159
5160 ---------------------------------------
5161
5162 *enable_command;
5163 *disable_command;
5164
5165 These commands toggle the ability to use atcommand while interacting with an NPC.
5166
5167 The default setting, 'atcommand_enable_npc', is defined in 'conf/battle/gm.conf'.
5168
5169 ---------------------------------------
5170 //
5171 4,1.- End of item-related commands
5172 //
5173 ---------------------------------------
5174
5175 *openstorage;
5176
5177 This will open character's Kafra storage window on the client connected to the
5178 invoking character. It can be used from any kind of NPC or item script, not just
5179 limited to Kafra Staff.
5180
5181 The storage window opens regardless of whether there are open NPC dialogs or
5182 not, but it is preferred to close the dialog before displaying the storage
5183 window, to avoid any disruption when both windows overlap.
5184
5185     mes "Close this window to open your storage.";
5186     close2;
5187     openstorage;
5188     end;
5189
5190 ---------------------------------------
5191
5192 *openstorage2 <storage_id>,<mode>{,<account_id>};
5193
5194 Just like the 'openstorage' command, except this command can open additional storages
5195 by the specified <storage_id>. For <storage_id>, please read the conf/inter_server.yml
5196 for storage groups.
5197
5198 Values for <mode> are:
5199         STOR_MODE_NONE : Player only can read the storage entries.
5200         STOR_MODE_GET  : Player can get items from the storage.
5201         STOR_MODE_PUT  : Player can put items in the storage.
5202
5203 Example:
5204         if (vip_status(VIP_STATUS_ACTIVE)) {
5205                 mes "I will open your Premium storage.";
5206                 mes "Thank you for using our service.";
5207                 close2;
5208                 openstorage2 1,STOR_MODE_GET|STOR_MODE_PUT;
5209         } else {
5210                 mes "Sorry, your Premium status is expired.";
5211                 mes "Storage will be opened but you can't put any item into it.";
5212                 close2;
5213                 openstorage2 1,STOR_MODE_GET;
5214         }
5215         end;
5216
5217 ---------------------------------------
5218
5219 *openmail({<char_id>});
5220
5221 This will open a character's Mail window on the client connected to the
5222 invoking character.
5223
5224         mes "Close this window to open your mail inbox.";
5225         close2;
5226         openmail;
5227         end;
5228
5229 ---------------------------------------
5230
5231 *openauction({<char_id>});
5232
5233 This will open the Auction window on the client connected to the invoking character.
5234
5235         mes "Close this window to open the Auction window.";
5236         close2;
5237         openauction;
5238         end;
5239
5240 ---------------------------------------
5241 \\
5242 4,2.- Guild-related commands
5243 \\
5244 ---------------------------------------
5245
5246 *guildopenstorage()
5247
5248 This function works the same as 'openstorage' but will open a guild storage
5249 window instead for the guild storage of the guild the invoking character belongs
5250 to. This is a function because it returns a value - 0 if the guild storage was
5251 opened successfully and 1 if it wasn't. (Notice, it's a ZERO upon success.)
5252 Since guild storage is only accessible to one character at one time, it may fail
5253 if another character is accessing the guild storage at the same time.
5254
5255 This will also fail and return 2 if the character does not belong to any guild.
5256
5257 ---------------------------------------
5258
5259 *guildchangegm(<guild id>,<new master's name>)
5260
5261 This function will change the Guild Master of a guild. The ID is the guild's
5262 id, and the new guild master's name must be passed.
5263
5264 Returns 1 on success, 0 otherwise.
5265
5266 ---------------------------------------
5267
5268 *guildgetexp <amount>;
5269
5270 This will give the specified amount of guild experience points to the guild the
5271 invoking character belongs to. It will silently fail if they do not belong to
5272 any guild.
5273
5274 ---------------------------------------
5275
5276 *guildskill <skill id>,<level>
5277 *guildskill "<skill name>",<level>
5278
5279 This command will bump up the specified guild skill by the specified number of
5280 levels. This refers to the invoking character and will only work if the invoking
5281 character is a member of a guild AND its guild master, otherwise no failure
5282 message will be given and no error will occur, but nothing will happen - same
5283 about the guild skill trying to exceed the possible maximum. The full list of
5284 guild skills is available in 'db/(pre-)re/skill_db.txt', these are all the GD_ skills at
5285 the end.
5286
5287 // This would give your character's guild one level of Approval (GD_APPROVAL ID
5288 // 10000). Notice that if you try to add two levels of Approval, or add
5289 // Approval when the guild already has it, it will only have one level of
5290 // Approval afterwards.
5291         guildskill 10000,1,0;
5292
5293 You might want to make a quest for getting a certain guild skill, make it hard
5294 enough that all the guild needs to help or something. Doing this for the Glory
5295 of the Guild skill, which allows your guild to use an emblem, is a good idea for
5296 a fun quest.
5297
5298 ---------------------------------------
5299 //
5300 4,2 End of guild-related commands.
5301 //
5302 ---------------------------------------
5303
5304 *resetlvl <action type>{,<char_id>};
5305
5306 This is a character reset command, meant mostly for rebirth script supporting
5307 Advanced jobs, which will reset the invoking character's stats and level
5308 depending on the action type given. Valid action types are:
5309
5310  1 - Base level 1, Job level 1, 0 skill points, 0 base exp, 0 job exp, wipes the
5311      status effects (only the ones settable by 'setoption'), sets all stats to 1.
5312      If the new job is 'Novice High', give 100 status points, give First Aid and
5313      Play Dead skills.
5314  2 - Base level 1, Job level 1, 0 skill points, 0 base exp, 0 job exp.
5315      Skills and attribute values are not altered.
5316  3 - Base level 1, base exp 0. Nothing else is changed.
5317  4 - Job level 1, job exp 0. Nothing else is changed.
5318
5319 In all cases everything the character has on will be unequipped.
5320
5321 Even though it doesn't return a value, it is used as a function in the official
5322 rebirth scripts. Ask AppleGirl why.
5323
5324 ---------------------------------------
5325
5326 *resetstatus({<char_id>});
5327
5328 This is a character reset command, which will reset the stats on the invoking
5329 character and give back all the stat points used to raise them previously.
5330 Nothing will happen to any other numbers about the character.
5331
5332 Used in reset NPC's (duh!)
5333
5334 ---------------------------------------
5335
5336 *resetskill({<char_id>});
5337
5338 This command takes off all the skill points on the invoking character, so they
5339 only have Basic Skill blanked out (lvl 0) left, and returns the points for them
5340 to spend again. Nothing else will change but the skills. Quest skills will also
5341 reset if 'quest_skill_reset' option is set to Yes in 'battle_athena.conf'. If
5342 the 'quest_skill_learn' option is set in there, the points in the quest skills
5343 will also count towards the total.
5344
5345 Used in reset NPC's (duh!)
5346
5347 ---------------------------------------
5348
5349 *sc_start <effect type>,<ticks>,<value 1>{,<rate>,<flag>{,<GID>}};
5350 *sc_start2 <effect type>,<ticks>,<value 1>,<value 2>{,<rate>,<flag>{,<GID>}};
5351 *sc_start4 <effect type>,<ticks>,<value 1>,<value 2>,<value 3>,<value 4>{,<rate>,<flag>{,<GID>}};
5352 *sc_end <effect type>{,<GID>};
5353 *sc_end_class {<char_id>};
5354
5355 These commands will bestow a status effect on a character.
5356
5357 The <effect type> determines which status is invoked. This can be either a number
5358 or constant, with the common statuses (mostly negative) found in 'src/map/script_constants.h'
5359 with the 'SC_' prefix. A full list is located in 'src/map/status.h', though
5360 they are not currently documented.
5361
5362 The duration of the status is given in <ticks>, or milleseconds.
5363
5364 Certain status changes take an additional parameter <value 1>, which typically
5365 modifies player stats by the given number or percentage. This differs for each
5366 status, and is sometimes zero.
5367
5368 Optional value <rate> is the chance that the status will be invoked (100 = 1%).
5369 This is used primarily in item scripts. When used in an NPC script, a flag MUST
5370 be defined for the rate to work.
5371
5372 Optional value <flag> is how the status change start will be handled (a bitmask).
5373  SCSTART_NOAVOID   : Status change cannot be avoided.
5374  SCSTART_NOTICKDEF : Tick cannot be reduced by stats (default).
5375  SCSTART_LOADED    : sc_data loaded, so no value will be altered.
5376  SCSTART_NORATEDEF : Rate cannot be reduced.
5377  SCSTART_NOICON    : Status icon won't be sent to client
5378
5379 If a <GID> is given, the status change will be invoked on the specified character
5380 instead of the one attached to the script. This can only be defined after setting
5381 a rate and flag.
5382
5383 'sc_start2' and 'sc_start4' allow extra parameters to be passed, and are used only
5384 for effects that require them. The meaning of the extra values vary depending on the
5385 effect type. For more infos, read status_change.txt containing a list of all Status Changes
5386 and theirs val1, val2, val3, and val4 usage in source.
5387
5388 'sc_end' will remove a specified status effect. If SC_ALL (-1) is given, it will
5389 perform a complete removal of all statuses (although permanent ones will re-apply).
5390
5391 'sc_end_class' works like 'sc_end' but will remove all status effects from any learned
5392 skill on the invoking character.
5393
5394 Examples:
5395         // This will poison the invoking character for 10 minutes at 50% chance.
5396         sc_start SC_POISON,600000,0,5000;
5397
5398         // This will bestow the effect of Level 10 Blessing.
5399         sc_start SC_BLESSING,240000,10;
5400
5401         // Adjust element resistance by percentage. Sample with Resist_Fire item script:
5402         // val1: Water resistance
5403         // val2: Earth resistance
5404         // val3: Fire resistance
5405         // val4: Wind resistance
5406         sc_start4 SC_ARMOR_ELEMENT,1200000,-15,0,20,0;
5407
5408         // This will end the Freezing status for the invoking character.
5409         sc_end SC_FREEZE;
5410
5411 Note: to use SC_NOCHAT you should alter Manner
5412         set Manner, -5; // Will mute a user for 5 minutes
5413         set Manner, 0;  // Will unmute a user
5414         set Manner, 5;  // Will unmute a user and prevent the next use of 'Manner'
5415
5416 ---------------------------------------
5417
5418 *getstatus(<effect type>{,<type>{,<char_id>}})
5419
5420 Retrieve information about a specific status effect when called. Depending on <type>
5421 specified the function will return different information.
5422
5423 Possible <type> values:
5424         - 0 or undefined: whether the status is active
5425         - 1: the val1 of the status
5426         - 2: the val2 of the status
5427         - 3: the val3 of the status
5428         - 4: the val4 of the status
5429         - 5: the amount of time in milliseconds that the status has remaining
5430
5431 If <type> is not defined or is set to 0, then the script function will either
5432 return 1 if the status is active, or 0 if the status is not active. If the status
5433 is not active when any of the <type> fields are provided, this script function
5434 will always return 0.
5435
5436 ---------------------------------------
5437
5438 *skilleffect <skill id>,<number>;
5439 *skilleffect "<skill name>",<number>;
5440
5441 This command displays visual and aural effects of given skill on currently
5442 attached character. The number parameter is for skill whose visual effect
5443 involves displaying of a number (healing or damaging). Note, that this command
5444 will not actually use the skill, it is intended for scripts, which simulate
5445 skill usage by the NPC, such as buffs, by setting appropriate status and
5446 displaying the skill's effect.
5447
5448         mes "Be blessed!";
5449         // Heal of 2000 HP
5450         heal 2000,0;
5451         skilleffect 28,2000;
5452         // Blessing Level 10
5453         sc_start SC_BLESSING,240000,10;
5454         skilleffect 34,0;
5455         // Increase AGI Level 5
5456         sc_start SC_INCREASEAGI,140000,5;
5457         skilleffect 29,0;
5458
5459 This will heal the character with 2000 HP, buff it with Blessing Lv 10 and
5460 Increase AGI Lv 5, and display appropriate effects.
5461
5462 ---------------------------------------
5463
5464 *npcskilleffect <skill id>,<number>,<x>,<y>;
5465 *npcskilleffect "<skill name>",<number>,<x>,<y>;
5466
5467 This command behaves identically to 'skilleffect', however, the effect will not
5468 be centered on the invoking character's sprite, nor on the NPC sprite, if any,
5469 but will be centered at map coordinates given on the same map as the invoking
5470 character.
5471
5472 ---------------------------------------
5473
5474 *specialeffect <effect number>{,<send_target>{,"<NPC Name>"}};
5475
5476 This command will display special effect with the given number, centered on the
5477 specified NPCs coordinates, if any. For a full list of special effect numbers
5478 known see 'doc/effect_list.txt'. Some effect numbers are known not to work in
5479 some client releases. (Notably, rain is absent from any client executables
5480 released after April 2005.)
5481
5482 <NPC name> parameter will display <effect number> on another NPC. If the NPC
5483 specified does not exist, the command will do nothing. When specifying an NPC,
5484 <send_target> must be specified when specifying an <NPC Name>, specifying AREA
5485 will retain the default behavior of the command.
5486
5487         // this will make the NPC "John Doe#1"
5488         // show the effect "EF_HIT1" specified by
5489         // Jane Doe. I wonder what John did...
5490         mes "[Jane Doe]";
5491         mes "Well, I never!";
5492         specialeffect EF_HIT1,AREA,"John Doe#1";
5493         close;
5494
5495 ---------------------------------------
5496
5497 *specialeffect2 <effect number>{,<send_target>{,"<Player Name>"}};
5498
5499 This command behaves identically to 'specialeffect', but the effect will be
5500 centered on the invoking character's sprite.
5501
5502 <Player name> parameter will display <effect number> on another Player than the
5503 one currently attached to the script. Like with specialeffect, when specifying
5504 a player, <send_target> must be supplied, specifying AREA will retain the default
5505 behavior of the command.
5506
5507 ---------------------------------------
5508
5509 *statusup <stat>{,<char_id>};
5510
5511 This command will change a specified stat of the invoking character up by one
5512 permanently. Stats are to be given as number, but you can use these constants to
5513 replace them:
5514
5515 bStr -  Strength
5516 bVit -  Vitality
5517 bInt -  Intelligence
5518 bAgi -  Agility
5519 bDex -  Dexterity
5520 bLuk -  Luck
5521
5522 ---------------------------------------
5523
5524 *statusup2 <stat>,<amount>{,<char_id>};
5525
5526 This command will change a specified stat of the invoking character by the
5527 specified amount permanently. The amount can be negative. See 'statusup'.
5528
5529         // This will decrease a character's Vit forever.
5530         statusup2 bVit,-1;
5531
5532 ---------------------------------------
5533
5534 *bonus <bonus type>,<val1>;
5535 *bonus2 <bonus type>,<val1>,<val2>;
5536 *bonus3 <bonus type>,<val1>,<val2>,<val3>;
5537 *bonus4 <bonus type>,<val1>,<val2>,<val3>,<val4>;
5538 *bonus5 <bonus type>,<val1>,<val2>,<val3>,<val4>,<val5>;
5539
5540 These commands are meant to be used in item scripts. They will probably work
5541 outside item scripts, but the bonus will not persist for long. They, as
5542 expected, refer only to an invoking character.
5543
5544 You can find the full list of possible bonuses and which command to use for each
5545 kind in 'doc/item_bonus.txt'.
5546
5547 ---------------------------------------
5548
5549 *autobonus <bonus script>,<rate>,<duration>{,<flag>,{<other script>}};
5550 *autobonus2 <bonus script>,<rate>,<duration>{,<flag>,{<other script>}};
5551 *autobonus3 <bonus script>,<rate>,<duration>,<skill id>,{<other script>};
5552 *autobonus3 <bonus script>,<rate>,<duration>,"<skill name>",{<other script>};
5553
5554 These commands are meant to be used in item scripts. They will probably work
5555 outside item scripts, but the bonus will not persist for long. They, as
5556 expected, refer only to an invoking character.
5557
5558 What these commands do is 'attach' a script to the player which will get
5559 executed on attack (or when attacked in the case of autobonus2).
5560
5561 Rate is the trigger rate of the script (1000 = 100%).
5562
5563 Duration is the time that the bonus will last for since the script has triggered.
5564
5565 Skill ID/skill name the skill which will be used as trigger to start the bonus. (autobonus3)
5566
5567 The optional argument 'flag' is used to classify the type of attack where the script
5568 can trigger (it shares the same flags as the bAutoSpell bonus script):
5569
5570 Range criteria:
5571         BF_SHORT:  Trigger on melee attack
5572         BF_LONG:   Trigger on ranged attack
5573         Default:   BF_SHORT+BF_LONG
5574 Attack type criteria:
5575         BF_WEAPON: Trigger on weapon skills
5576         BF_MAGIC:  Trigger on magic skills
5577         BF_MISC:   Trigger on misc skills
5578         Default:   BF_WEAPON
5579 Skill criteria:
5580         BF_NORMAL: Trigger on normal attacks
5581         BF_SKILL:  Trigger on skills
5582         default:   If the attack type is BF_WEAPON (only) BF_NORMAL is used,
5583                    otherwise BF_SKILL+BF_NORMAL is used.
5584
5585 The difference between the optional argument 'other script' and the 'bonus script' is that,
5586 the former one triggers only when attacking(or attacked) and the latter one runs on
5587 status calculation as well, which makes sure, within the duration, the "bonus" that get
5588 lost on status calculation is restored. So, 'bonus script' is technically supposed to accept
5589 "bonus" command only. And we usually use 'other script' to show visual effects.
5590
5591 In all cases, when the script triggers, the attached player will be the one
5592 who holds the bonus. There is currently no way of knowing within this script
5593 who was the other character (the attacker in autobonus2, or the target in
5594 autobonus and autobonus3).
5595
5596 //Grants a 1% chance of starting the state "all stats +10" for 10 seconds when
5597 //using weapon or misc attacks (both melee and ranged skills) and shows a special
5598 //effect when the bonus is active.
5599         autobonus "{ bonus bAllStats,10; }",10,10000,BF_WEAPON|BF_MISC,"{ specialeffect2 EF_FIRESPLASHHIT; }";
5600
5601 ---------------------------------------
5602
5603 *bonus_script "<script code>",<duration>{,<flag>{,<type>{,<status_icon>{,<char_id>}}}};
5604
5605 This command will attach a script to a player for a given duration, in seconds.
5606 After that time, the script will automatically expire. The same bonus cannot be
5607 stacked. By default, this bonus will be stored on `bonus_script` table when player
5608 logs out.
5609
5610 Flags (bitmask):
5611         1   : Remove when dead.
5612         2   : Removable by Dispell.
5613         4   : Removable by Clearance.
5614         8   : Remove when player logs out.
5615         16  : Removeable by Banishing Buster.
5616         32  : Removable by Refresh.
5617         64  : Removable by Lux Anima.
5618         128 : Remove when Madogear is activated or deactivated.
5619         256 : Remove when receive damage.
5620         512 : Script is permanent, cannot be cleared by bonus_script_clear.
5621         1024: Force to replace duplicated script by expanding the duration.
5622         2048: Force to add duplicated script. This flag cannot be stacked with 1024,
5623               if both are defined, 1024 will be checked first and ignore this flag.
5624
5625 Types:
5626         This will be used to decide negative or positive buff for 'debuff_on_logout'.
5627         0: Ignore the buff type and won't be removed if the flag is not &8 (Default)
5628         1: Buff
5629         2: Debuff
5630
5631 Status_icon: See "Status Icon" section in 'src/map/script_constants.h'. Default is SI_BLANK (-1).
5632
5633 Example:
5634         // Apple gives you +5 Str bonus for 1 minute when it's consumed.
5635         512,Apple,Apple,0,15,,20,,,,,0xFFFFFFFF,63,2,,,,,,{ bonus_script "{ bonus bStr,5; }",60; },{},{}
5636
5637 ---------------------------------------
5638
5639 *bonus_script_clear {<flag>,{<char_id>}};
5640
5641 Removes attached bonus_script from player. If no 'char_id' given, it will removes
5642 from the invoker.
5643
5644 If 'flag' is 1, means will clears all scripts even it's Permanent effect. By default,
5645 it just removes non-permanent script.
5646
5647 ---------------------------------------
5648
5649 *skill <skill id>,<level>{,<flag>};
5650 *skill "<skill name>",<level>{,<flag>};
5651 *addtoskill <skill id>,<level>{,<flag>};
5652 *addtoskill "<skill name>",<level>{,<flag>};
5653
5654 These commands will give the invoking character a specified skill. This is also
5655 used for item scripts.
5656
5657 Level is obvious. Skill id is the ID number of the skill in question as per
5658 'db/(pre-)re/skill_db.txt'. It is not known for certain whether this can be used to give
5659 a character a monster's skill, but you're welcome to try with the numbers given
5660 in 'db/(pre-)re/mob_skill_db.txt'.
5661
5662 Flag is 0 if the skill is given permanently (will get written with the character
5663 data) or 1 if it is temporary (will be lost eventually, this is meant for card
5664 item scripts usage.).  The flag parameter is optional, and defaults to 1 in
5665 'skill' and to 2 in 'addtoskill'.
5666
5667 Flag 2 means that the level parameter is to be interpreted as a stackable
5668 additional bonus to the skill level. If the character did not have that skill
5669 previously, they will now at 0+the level given.
5670
5671 Flag 3 is the same as flag 1 in that it saves to the database.  However, these skills
5672 are ignored when any action is taken that adjusts the skill tree (reset/job change).
5673
5674 Flag constants:
5675         0 - SKILL_PERM
5676         1 - SKILL_TEMP
5677         2 - SKILL_TEMPLEVEL
5678         3 - SKILL_PERM_GRANT
5679
5680 // This will permanently give the character Stone Throw (TF_THROWSTONE,152), at
5681 // level 1.
5682     skill 152,1,0;
5683
5684 ---------------------------------------
5685
5686 *nude {<char_id>};
5687
5688 This command will unequip anything equipped on the invoking character.
5689
5690 It is not required to do this when changing jobs since 'jobchange' will unequip
5691 everything not equippable by the new job class anyway.
5692
5693 ---------------------------------------
5694
5695 *sit {"<character name>"};
5696 *stand {"<character name>"};
5697
5698 These commands will make a character sit or stand.
5699 If no character is specified, the command will run for the invoking character.
5700
5701 Additionnally Sitting constant is true when the character is sitting, false otherwise.
5702
5703 ---------------------------------------
5704
5705 *disguise <Monster ID>{,<char_id>};
5706 *undisguise {<char_id>};
5707
5708 This command disguises the current player with a monster sprite.
5709 The disguise lasts until 'undisguise' is issued or the player logs out.
5710
5711 Example:
5712
5713 disguise 1002; // Disguise character as a Poring.
5714 next;
5715 undisguise; // Return to normal character sprite.
5716
5717 ---------------------------------------
5718
5719 *transform <monster ID>,<duration>{,<sc type>,<val1>,<val2>,<val3>,<val4>};
5720 *transform "<monster name>",<duration>{,<sc type>,<val1>,<val2>,<val3>,<val4>};
5721 *active_transform <monster ID>,<duration>{,<sc type>,<val1>,<val2>,<val3>,<val4>};
5722 *active_transform "<monster name>",<duration>{,<sc type>,<val1>,<val2>,<val3>,<val4>};
5723
5724 This command will turn a player into a monster for a given duration and can grant
5725 a SC attribute effect while transformed. Note that players cannot be transformed
5726 during War of Emperium or if already disguised.
5727 Can only be removed when you die or the duration ends.
5728
5729 'transform' and 'active_transform' can stack on each other but using 'transform' or
5730 'active_transform' twice will not stack (it will cancel the previous bonus for the new).
5731 'active_transform' will take priority over transform for its duration.
5732
5733 ---------------------------------------
5734 \\
5735 4,3 Marriage-related commands
5736 \\
5737 ---------------------------------------
5738
5739 *marriage("<spouse name>");
5740
5741 This function will marry two characters, the invoking character and the one
5742 referred to by name given, together, setting them up as each other's marriage
5743 partner. No second function call has to be issued (in current SVN at least) to
5744 make sure the marriage works both ways. The function returns 1 upon success, or
5745 0 if the marriage could not be completed, either because the other character
5746 wasn't found or because one of the two characters is already married.
5747
5748 This will do nothing else for the marriage except setting up the spouse ID for
5749 both of these characters. No rings will be given and no effects will be shown.
5750
5751 ---------------------------------------
5752
5753 *wedding;
5754
5755 This command will call up wedding effects - the music and confetti - centered on
5756 the invoking character. Example can be found in the wedding script.
5757
5758 ---------------------------------------
5759
5760 *divorce({<char_id>})
5761
5762 This function will "un-marry" the invoking character from whoever they were
5763 married to. Both will no longer be each other's marriage partner, (at least in
5764 current SVN, which prevents the cases of multi-spouse problems). It will return
5765 1 upon success or 0 if the character was not married at all.
5766
5767 This function will also destroy both wedding rings and send a message to both
5768 players, telling them they are now divorced.
5769
5770 ---------------------------------------
5771
5772 *adopt("<parent_name>","<baby_name>");
5773 *adopt(<parent_id>,<baby_id>);
5774
5775 This function will send the client adoption request to the specified baby
5776 character. The parent value can be either parent. Both parents and the baby
5777 need to be online in order for adoption to work.
5778
5779 Return values:
5780  ADOPT_ALLOWED - Sent message to Baby to accept or deny.
5781  ADOPT_ALREADY_ADOPTED - Character is already adopted.
5782  ADOPT_MARRIED_AND_PARTY - Parents need to be married and in a party with the baby.
5783  ADOPT_EQUIP_RINGS - Parents need wedding rings equipped.
5784  ADOPT_NOT_NOVICE - Baby is not a Novice.
5785  ADOPT_CHARACTER_NOT_FOUND - A parent or Baby was not found.
5786  ADOPT_MORE_CHILDREN - You cannot adopt more than 1 child. (client message)
5787  ADOPT_LEVEL_70 - Parents need to be at least level 70 in order to adopt someone. (client message)
5788  ADOPT_MARRIED - You cannot adopt a married person. (client message)
5789
5790 ---------------------------------------
5791 //
5792 4,3.- End of marriage-related commands
5793 //
5794 ---------------------------------------
5795
5796 *pcfollow <id>,<target id>;
5797 *pcstopfollow <id>;
5798
5799 Makes a character follow or stop following someone. This command does the same
5800 as the @follow command. The main difference is that @follow can use character
5801 names, and this commands needs the account ID for the target.
5802
5803 Examples:
5804         // This will make Aaron follow Bullah, when both of these characters are online.
5805         pcfollow getCharID(3,"Aaron"),getCharID(3,"Bullah");
5806
5807         // Makes Aaron stop following whoever he is following.
5808         pcstopfollow getCharID(3,"Aaron");
5809
5810 ---------------------------------------
5811
5812 *pcblockmove <id>,<option>;
5813 *unitblockmove <id>,<option>;
5814
5815 Prevents the given GID from moving when the option is 1, and enables the ID to
5816 move again when the option is 0. This command will run for the attached unit
5817 if the given GID is zero.
5818
5819 Examples:
5820         // Prevents the current char from moving away.
5821         pcblockmove getcharid(3),1;
5822
5823         // Enables the current char to move again.
5824         pcblockmove getcharid(3),0;
5825
5826 ---------------------------------------
5827
5828 *pcblockskill <id>,<option>;
5829 *unitblockskill <id>,<option>;
5830
5831 Prevents the given GID from casting skills when the option is 1, and enables
5832 the ID to cast skills again when the option is 0. This command will run for
5833 the attached unit if the given GID is zero.
5834
5835 Examples:
5836         // Prevents the current char from casting skills.
5837         pcblockskill getcharid(3),1;
5838
5839         // Enables the current char to cast skills again.
5840         pcblockskill getcharid(3),0;
5841
5842 ---------------------------------------
5843
5844 ==================================
5845 |5.- Mob / NPC -related commands.|
5846 ==================================
5847 ---------------------------------------
5848
5849 *monster     "<map name>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>",<size>,<ai>};
5850 *areamonster "<map name>",<x1>,<y1>,<x2>,<y2>,"<name to show>",<mob id>,<amount>{,"<event label>",<size>,<ai>};
5851
5852 This command will spawn a monster on the specified coordinates on the specified
5853 map. If the script is invoked by a character, a special map name, "this", will
5854 be recognized to mean the name of the map the invoking character is located at.
5855 This command works fine in the item scripts.
5856
5857 The same command arguments mean the same things as described above in the
5858 beginning of this document when talking about permanent monster spawns. Monsters
5859 spawned in this manner will not respawn upon being killed.
5860
5861 Unlike the permanent monster spawns, if the mob id is -1, a random monster will
5862 be picked from the entire database according to the rules configured in the
5863 server for dead branches. This will work for all other kinds of non-permanent
5864 monster spawns.
5865
5866 The only very special thing about this command is an event label, which is an
5867 optional parameter. This label is written like '<NPC object name>::<label name>'
5868 and upon the monster being killed, it will execute the script inside of the
5869 specified NPC object starting from the label given. The RID of the player
5870 attached at this execution will be the RID of the killing character. The variable
5871 'killedrid' is set to the Class (mob ID) of the monster killed.
5872
5873 <size> can be:
5874         Size_Small      (0)             (default)
5875         Size_Medium     (1)
5876         Size_Large      (2)
5877
5878 <ai> can be:
5879         AI_NONE         (0)             (default)
5880         AI_ATTACK       (1)             (attack/friendly)
5881         AI_SPHERE       (2)             (Alchemist skill)
5882         AI_FLORA        (3)             (Alchemist skill)
5883         AI_ZANZOU       (4)             (Kagerou/Oboro skill)
5884         AI_LEGION       (5)             (Sera skill)
5885         AI_FAW          (6)             (Mechanic skill)
5886
5887     monster "place",60,100,"Poring",1002,1,"NPCNAME::OnLabel";
5888
5889 The coordinates of 0,0 will spawn the monster on a random place on the map.
5890
5891 The 'areamonster' command works much like the 'monster' command and is not
5892 significantly different, but spawns the monsters within a square defined by
5893 x1/y1-x2/y2.
5894
5895 Returned value is an array with the game ID of the spawned monster(s) depending
5896 on the amount spawned. Array is stored in $@mobid[].
5897
5898 Simple monster killing script:
5899
5900                 <Normal NPC object definition. Let's assume you called him NPCNAME.>
5901                 mes "[Summon Man]";
5902                 mes "Want to start the Poring hunt?";
5903                 next;
5904                 if (select("Yes.:No.") == 2) {
5905                         mes "[Summon Man]";
5906                         mes "Come back later.";
5907                         close;
5908                 }
5909
5910                 // Summon 10 Porings.
5911                 // Using coordinates 0,0 will spawn them in a random location.
5912                 monster "prontera",0,0,"Quest Poring",1002,10,"NPCNAME::OnPoringKilled";
5913
5914                 mes "[Summon Man]";
5915                 mes "Now go and kill all the Porings I summoned.";
5916                 close;
5917
5918         OnPoringKilled:
5919                 $PoringKilled++;
5920                 if ($PoringKilled >= 10) {
5921                         announce "Summon Man: Well done. All the Porings are dead!",3;
5922                         $PoringKilled = 0;
5923                 }
5924                 end;
5925
5926 For more good examples see just about any official 2-1 or 2-2 job quest script.
5927
5928 ---------------------------------------
5929
5930 *areamobuseskill "<map name>",<x>,<y>,<range>,<mob id>,<skill id>,<skill level>,<cast time>,<cancelable>,<emotion>,<target type>;
5931 *areamobuseskill "<map name>",<x>,<y>,<range>,<mob id>,"<skill name>",<skill level>,<cast time>,<cancelable>,<emotion>,<target type>;
5932
5933 This command will make all monsters of the specified mob ID in the specified
5934 area use the specified skill. Map name, x, and y define the center of the area,
5935 which extending <range> cells in each direction (ex: a range of 3 would create
5936 a 7x7 square). The skill can be specified by skill ID or name. <cast time> is in
5937 milliseconds (1000 = 1 second), and the rest should be self-explanatory.
5938
5939 <target type> can be:
5940         0 = self
5941         1 = the mob's current target
5942         2 = the mob's master
5943         3 = random target
5944
5945 Example:
5946
5947         // spawn 1 Shining Plant in the 5x5 area centered on (155,188)
5948         areamonster "prontera",153,186,157,190,"Shining Plant",1083,1;
5949         // make the plant cast level 10 Cold Bolt on a random target
5950         areamobuseskill "prontera",155,188,2,1083,"MG_COLDBOLT",10,3000,1,e_gg,3;
5951
5952 ---------------------------------------
5953
5954 *killmonster "<map name>","<event label>"{,<type>};
5955
5956 This command will kill all monsters that were spawned with 'monster' or
5957 'addmonster' and have a specified event label attached to them. Commonly used to
5958 get rid of remaining quest monsters once the quest is complete.
5959
5960 If the label is given as "All", all monsters which have their respawn times set
5961 to -1 (like all the monsters summoned with 'monster' or 'areamonster' script
5962 command, and all monsters summoned with GM commands, but no other ones - that
5963 is, all non-permanent monsters) on the specified map will be killed regardless
5964 of the event label value.
5965
5966 As of r12876 killmonster now supports an optional argument type. Using 1 for type
5967 will make the command fire "OnMyMobDead" events from any monsters that do die
5968 as a result of this command.
5969
5970 ---------------------------------------
5971
5972 *killmonsterall "<map name>"{,<type>};
5973
5974 This command will kill all monsters on a specified map name, regardless of how
5975 they were spawned or what they are. As of r12873, The behavior has changed slightly.
5976 In light of a label behavior fix for mob spawning commands that will now allow the label to
5977 trigger when there is no player, killmonsterall has also been modified to support this.
5978
5979 Using this the normal/old way means labels don't trigger when a player didn't
5980 attack/kill a monster. This is because it breaks compatibility with older scripts if
5981 forced to use the new method. However, if you wish to use the new label type with this
5982 command, simply use 1 for type. Any other number won't be recognized.
5983
5984 ---------------------------------------
5985
5986 *strmobinfo(<type>,<monster id>);
5987
5988 This function will return information about a monster record in the database, as
5989 per 'db/(pre-)re/mob_db.txt'. Type is the kind of information returned. Valid types are:
5990 It will return 0 if there is no such monster (or the type value is invalid),
5991 or an empty string if you requested the monster's name.
5992
5993  1 - 'english name' field in the database, a string.
5994  2 - 'japanese name' field in the database, a string.
5995      All other returned values are numbers:
5996  3 - Level.
5997  4 - Maximum HP.
5998  5 - Maximum SP.
5999  6 - Experience reward.
6000  7 - Job experience reward.
6001
6002 ---------------------------------------
6003
6004 *mobcount("<map name>","<event label>")
6005
6006 This function will count all the monsters on the specified map that have a given
6007 event label and return the number or 0 if it can't find any. Naturally, only
6008 monsters spawned with 'monster' and 'areamonster' script commands can have non-empty
6009 event label.
6010 If you pass this function an empty string for the event label, it will return
6011 the total count of monster without event label, including permanently spawning monsters.
6012 With the dynamic mobs system enabled, where mobs are not kept
6013 in memory for maps with no actual people playing on them, this will return a 0
6014 for any such map.
6015 If the event label is given as "all", all monsters will be counted, regardless of
6016 having any event label attached.
6017
6018 If the map name is given as "this", the map the invoking character is on will
6019 be used. If the map is not found, or the invoker is not a character while the map
6020 is "this", it will return -1.
6021
6022 ---------------------------------------
6023
6024 *clone "<map name>",<x>,<y>,"<event>",<char id>{,<master_id>{,<mode>{,<flag>,<duration>}}}
6025
6026 This command creates a monster which is a copy of another player. The first
6027 four arguments serve the same purpose as in the monster script command, The
6028 <char id> is the character id of the player to clone (player must be online).
6029 If <master id> is given, the clone will be a 'slave/minion' of it. Master_id
6030 must be a character id of another online player.
6031
6032 The mode can be specified to determine the behavior of the clone. Its
6033 values are the same as the ones used for the mode field in the mob_db. The
6034 default mode is aggressive, assists, can move, can attack.
6035
6036 Flag can be either zero or one currently. If zero, the clone is a normal
6037 monster that'll target players, if one, it is considered a summoned monster,
6038 and as such, it'll target other monsters. Defaults to zero.
6039
6040 The duration specifies how long the clone will live before it is auto-removed.
6041 Specified in seconds, defaults to no limit (zero).
6042
6043 Returned value is the monster ID of the spawned clone. If command fails,
6044 returned value is zero.
6045
6046 ---------------------------------------
6047
6048 *summon "monster name",<monster id>{,<Time Out>{,"event label"}};
6049
6050 This command will summon a monster. (see also 'monster') Unlike monsters spawned
6051 with other commands, this one will set up the monster to fight to protect the
6052 invoking character. Monster name and mob id obey the same rules as the one given
6053 at the beginning of this document for permanent monster spawns with the
6054 exceptions mentioned when describing 'monster' command.
6055
6056 The effect for the skill 'Call Homunculus' will be displayed centered on the
6057 invoking character.
6058
6059 Timeout is the time in milliseconds the summon lives, and is set default
6060 to 60000 (1 minute). Note that also the value 0 will set the timer to default,
6061 and it is not possible to create a spawn that lasts forever.
6062 If an event label is given, upon the monster being killed, the event label will
6063 run as if by 'donpcevent'.
6064
6065 Returned value is the game ID of the spawned monster.
6066
6067 // Will summon a dead branch-style monster to fight for the character.
6068 summon "--ja--",-1;
6069
6070 ---------------------------------------
6071
6072 *addmonsterdrop <monster id>,<item id>,<rate>;
6073 *addmonsterdrop "<monster name>",<item id>,<rate>;
6074 *delmonsterdrop <monster id>,<item id>;
6075 *delmonsterdrop "<monster name>",<item id>;
6076
6077 These commands will temporarily add or delete a monster drop, which will be reset
6078 when the mob database reloads or the server shuts down. They return 1 upon success.
6079
6080 If the monster already drops the specified item, its drop rate will be updated with
6081 the given rate (100 = 1%).
6082
6083 Examples:
6084         // Makes Owl Baron drop Honey at an 80% rate.
6085         addmonsterdrop 1295,518,8000;
6086
6087         // Deletes Executioner's Mitten from Rybio.
6088         delmonsterdrop 1201,7017;
6089
6090 ---------------------------------------
6091
6092 *disablenpc "<NPC object name>";
6093 *enablenpc "<NPC object name>";
6094
6095 These two commands will disable and enable, respectively, an NPC object
6096 specified by name. The disabled NPC will disappear from sight and will no longer
6097 be triggerable in the normal way. It is not clear whether it will still be
6098 accessible through 'donpcevent' and other triggering commands, but it probably
6099 will be. You can disable even warp NPCs if you know their object names, which is
6100 an easy way to make a map only accessible through walking half the time. Then
6101 you 'enablenpc' them back.
6102
6103 You can also use these commands to create the illusion of an NPC switching
6104 between several locations, which is often better than actually moving the NPC -
6105 create one NPC object with a visible and a hidden part to their name, make a few
6106 copies, and then disable all except one.
6107
6108 ---------------------------------------
6109
6110 *hideonnpc "<NPC object name>";
6111 *hideoffnpc "<NPC object name>";
6112
6113 These commands will make the NPC object specified display as hidden/visible,
6114 even though not actually disabled per se. Hidden as in thief Hide skill, but
6115 unfortunately, not detectable by Ruwach or Sight.
6116
6117 As they are now, these commands are pointless, it is suggested to use
6118 'disablenpc'/'enablenpc', because these two commands actually unload the NPC
6119 sprite location and other accompanying data from memory when it is not used.
6120 However, you can use these for some quest ideas (such as cloaking NPCs talking
6121 while hidden then revealing.... you can wonder around =P
6122
6123 ---------------------------------------
6124
6125 *unloadnpc "<NPC object name>";
6126
6127 This command will fully unload a NPC object and all of it's duplicates.
6128
6129 ---------------------------------------
6130
6131 *doevent "<NPC object name>::<event label>";
6132
6133 This command will start a new execution thread in a specified NPC object at the
6134 specified label. The execution of the script running this command will not stop,
6135 and the event called by the 'doevent' command will not run until the invoking
6136 script has terminated. No parameters may be passed with a doevent call.
6137
6138 The script of the NPC object invoked in this manner will run as if it's been
6139 invoked by the RID that was active in the script that issued a 'doevent'. As
6140 such, the command will not work if an RID is not attached.
6141
6142         place,100,100,1%TAB%script%TAB%NPC%TAB%53,{
6143                 mes "This is what you will see when you click me";
6144                 close;
6145         OnLabel:
6146                 mes "This is what you will see if the doevent is activated";
6147                 close;
6148         }
6149
6150         ....
6151
6152         doevent "NPC::OnLabel";
6153
6154 ---------------------------------------
6155
6156 *donpcevent "<NPC object name>::<event label>";
6157
6158 This command invokes the event label code within an another NPC or NPCs. It
6159 starts a separate instance of execution, and the invoking NPC will resume
6160 execution its immediately.
6161
6162 If the supplied event label has the form "NpcName::OnLabel", then only given
6163 NPC's event label will be invoked (much like 'goto' into another NPC). If the
6164 form is "::OnLabel" (NPC name omitted), the event code of all NPCs with given
6165 label will be invoked, one after another. In both cases the invoked script
6166 will run without an attached RID, whether or not the invoking script was
6167 attached to a player. The event label name is required to start with "On".
6168
6169 This command can be used to make other NPCs act, as if they were responding to
6170 the invoking NPC's actions, such as using an emotion or talking.
6171
6172         place,100,100,1%TAB%script%TAB%NPC1%TAB%53,{
6173                 mes "NPC2 copies my actions!";
6174                 close2;
6175                 donpcevent "NPC2::OnEmote";
6176                 end;
6177         OnEmote:
6178                 emotion rand(1,30);
6179                 end;
6180         }
6181
6182         place,102,100,1%TAB%script%TAB%NPC2%TAB%53,{
6183                 mes "NPC1 copies my actions!";
6184                 close2;
6185                 donpcevent "NPC1::OnEmote";
6186                 end;
6187         OnEmote:
6188                 emotion rand(1,30);
6189                 end;
6190         }
6191
6192 Whichever of the both NPCs is talked to, both will show a random emotion at the
6193 same time.
6194
6195 As of r16564, command now returns 1 or 0 on success and failure.
6196 A debug message also shows on the console when no events are triggered.
6197
6198 ---------------------------------------
6199
6200 *cmdothernpc "<npc name>","<command>";
6201
6202 This is simply "donpcevent <npc name>::OnCommand<command>".
6203 It is an approximation of official server script language's 'cmdothernpc'.
6204
6205 Returns true if the command was executed on the other NPC successfully, false if not.
6206
6207 ---------------------------------------
6208
6209 *npctalk "<message>"{,"<NPC name>","<flag>"};
6210
6211 This command will display a message as if the NPC object running it was a player
6212 talking - that is, above their head and in the chat window.
6213 The display name of the NPC won't get appended in front of the message.
6214 If the <NPC name> option is given and not empty, then that NPC will display the message,
6215 else the attached NPC will display the message.
6216
6217 Target for <flag>:
6218 - bc_all  : Broadcast message is sent server-wide (only in the chat window).
6219 - bc_map  : Message is sent to everyone in the same map as the source of the npc.
6220 - bc_area : Message is sent to players in the vicinity of the source (default value).
6221 - bc_self : Message is sent only to player attached.
6222
6223         // This will make everyone in the area see the NPC greet the character
6224         // who just invoked it.
6225         npctalk "Hello " + strcharinfo(0) + ", how are you?";
6226
6227 ---------------------------------------
6228
6229 *chatmes "<message>"{,"<NPC name>"};
6230
6231 This command will display a message in the waitingroom (chat) of the NPC.
6232 If the <NPC name> option is given, then that NPC will display the message, else
6233 the attached NPC will display the message.
6234 If the NPC is not in a waitingroom, nothing happens.
6235
6236         // Everyone in the waitingroom will see this message:
6237         chatmes "Waiting 5 minutes until the next match will start";
6238
6239 ---------------------------------------
6240
6241 *setnpcdisplay("<npc name>", "<display name>", <class id>, <size>)
6242 *setnpcdisplay("<npc name>", "<display name>", <class id>)
6243 *setnpcdisplay("<npc name>", "<display name>")
6244 *setnpcdisplay("<npc name>", <class id>)
6245
6246 Changes the display name and/or display class of the target NPC.
6247 Returns 0 is successful, 1 if the NPC does not exist.
6248 Size is 0 = normal 1 = small 2 = big.
6249
6250 ---------------------------------------
6251 \\
6252 5,1.- Time-related commands
6253 \\
6254 ---------------------------------------
6255
6256 *addtimer <ticks>,"NPC::OnLabel";
6257 *deltimer "NPC::OnLabel";
6258 *addtimercount <ticks>,"NPC::OnLabel";
6259
6260 These commands will create, destroy, and delay a countdown timer - 'addtimer' to
6261 create, 'deltimer' to destroy and 'addtimercount' to delay it by the specified
6262 number of ticks. For all three cases, the event label given is the identifier of
6263 that timer. The timer runs on the character object that is attached to the script,
6264 and can have multiple instances. When the label is run, it is run as if the player that
6265 the timer runs on has clicked the NPC.
6266
6267 When this timer runs out, a new execution thread will start in the specified NPC
6268 object at the specified label.
6269
6270 The ticks are given in 1/1000ths of a second.
6271
6272 One more thing. These timers are stored as part of player data. If the player
6273 logs out, all of these get immediately deleted, without executing the script.
6274 If this behavior is undesirable, use some other timer mechanism (like 'sleep').
6275
6276 Example:
6277 <NPC Header> {
6278         dispbottom "Starting a 5 second timer...";
6279         addtimer 5000, strnpcinfo(3) + "::On5secs";
6280         end;
6281 On5secs:
6282         dispbottom "5 seconds have passed!";
6283         end;
6284 }
6285
6286 ---------------------------------------
6287
6288 *initnpctimer{ "<NPC name>" {, <Attach Flag>} } |
6289              { "<NPC name>" | <Attach Flag> };
6290 *stopnpctimer{ "<NPC name>" {, <Detach Flag>}  } |
6291              { "<NPC name>" | <Detach Flag> };
6292 *startnpctimer{ "<NPC name>" {, <Attach Flag>} } |
6293               { "<NPC name>" | <Attach Flag> };
6294 *setnpctimer <tick>{,"<NPC name>"};
6295 *getnpctimer(<type of information>{,"<NPC name>"})
6296 *attachnpctimer {"<character name>"};
6297 *detachnpctimer {"<NPC name>"};
6298
6299 This set of commands and functions will create and manage an NPC-based timer.
6300 The NPC name may be omitted, in which case the calling NPC is used as target.
6301
6302 Contrary to addtimer/deltimer commands which let you have many different timers
6303 referencing different labels in the same NPC, each with their own countdown,
6304 'initnpctimer' can only have one per NPC object. But it can trigger many labels
6305 and let you know how many were triggered already and how many still remain.
6306
6307 This timer is counting up from 0 in ticks of 1/1000ths of a second each. Upon
6308 creating this timer, the execution will not stop, but will happily continue
6309 onward. The timer will then invoke new execution threads at labels
6310 "OnTimer<time>:" in the NPC object it is attached to.
6311
6312 To create the timer, use the 'initnpctimer', which will start it running.
6313 'stopnpctimer' will pause the timer, without clearing the current tick, while
6314 'startnpctimer' will let the paused timer continue.
6315
6316 By default timers do not have a RID attached, which lets them continue even
6317 if the player that started them logs off. To attach a RID to a timer, you can
6318 either use the optional "attach flag" when using 'initnpctimer/startnpctimer',
6319 or do it manually by using 'attachnpctimer'. Likewise, the optional flag of
6320 stopnpctimer lets you detach any RID after stopping the timer, and by using
6321 'detachnpctimer' you can detach a RID at any time.
6322
6323 Normally there is only a single timer per NPC, but as an exception, as long as
6324 you attach a player to the timer, you can have multiple timers running at once,
6325 because these will get stored on the players instead of the NPC.
6326 NOTE: You need to attach the RID before the timer _before_ you start it to
6327 get a player-attached timer. Otherwise it'll stay a NPC timer (no effect).
6328
6329 If the player that is attached to the npctimer logs out, the "OnTimerQuit:"
6330 event label of that NPC will be triggered, so you can do the appropriate
6331 cleanup (the player is still attached when this event is triggered).
6332
6333 The 'setnpctimer' command will explicitly set the timer to a given tick.
6334 'getnpctimer' provides timer information. Its parameter defines what type:
6335
6336  0 - Will return the current tick count of the timer.
6337  1 - Will return 1 if there are remaining "OnTimer<ticks>:" labels in the
6338      specified NPC waiting for execution.
6339  2 - Will return the number of times the timer has triggered and will trigger
6340      an "OnTimer<tick>:"  label in the specified NPC.
6341
6342 Example 1:
6343
6344         <NPC Header> {
6345         // We need to use attachnpctimer because the mes command below needs RID attach
6346                 attachnpctimer;
6347                 initnpctimer;
6348                 npctalk "I cant talk right now, give me 10 seconds";
6349                 end;
6350         OnTimer5000:
6351                 npctalk "Ok 5 seconds more";
6352                 end;
6353         OnTimer6000:
6354                 npctalk "4";
6355                 end;
6356         OnTimer7000:
6357                 npctalk "3";
6358                 end;
6359         OnTimer8000:
6360                 npctalk "2";
6361                 end;
6362         OnTimer9000:
6363                 npctalk "1";
6364                 end;
6365         OnTimer10000:
6366                 stopnpctimer;
6367                 mes "[Man]";
6368                 mes "Ok we can talk now";
6369                 detachnpctimer;
6370                 // and remember attachnpctimer and detachnpctimer can only use while the NPC timer is not running !
6371         }
6372
6373 Example 2:
6374
6375         OnTimer15000:
6376                 npctalk "Another 15 seconds have passed.";
6377
6378                 // You have to use 'initnpctimer' instead of 'setnpctimer 0'.
6379                 // This is equal to 'setnpctimer 0' + 'startnpctimer'.
6380                 // Alternatively, you can also insert another 'OnTimer15001' label so that the timer won't stop. */
6381                 initnpctimer;
6382                 end;
6383
6384         // This OnInit label will run when the script is loaded, so that the timer
6385         // is initialized immediately as the server starts. It is dropped back to 0
6386         // every time the NPC says something, so it will cycle continuously.
6387         OnInit:
6388                 initnpctimer;
6389                 end;
6390
6391 Example 3:
6392
6393         mes "[Man]";
6394         mes "I have been waiting " + (getnpctimer(0)/1000) + " seconds for you.";
6395         // We divide the timer returned by 1000 to convert milliseconds to seconds.
6396         close;
6397
6398 Example 4:
6399
6400         mes "[Man]";
6401         mes "Ok, I will let you have 30 more seconds...";
6402         close2;
6403         setnpctimer (getnpctimer(0)-30000);
6404         // Notice the 'close2'. If there were a 'next' there the timer would be
6405         // changed only after the player pressed the 'next' button.
6406         end;
6407
6408 ---------------------------------------
6409
6410 *sleep {<milliseconds>};
6411 *sleep2 {<milliseconds>};
6412 *awake "<NPC name>";
6413
6414 These commands are used to control the pause of a NPC.
6415 sleep and sleep2 will pause the script for the given amount of milliseconds.
6416 Awake is used to cancel a sleep. When awake is called on a NPC it will run as
6417 if the sleep timer ran out, and thus making the script continue. Sleep and sleep2
6418 basically do the same, but the main difference is that sleep will not keep the rid,
6419 while sleep2 does. Also sleep2 will stop the script if there is no unit attached.
6420
6421 Examples:
6422         sleep 10000; //pause the script for 10 seconds and ditch the RID (so no player is attached anymore)
6423         sleep2 5000; //pause the script for 5 seconds, and continue with the RID attached.
6424         awake "NPC"; //Cancels any running sleep timers on the NPC 'NPC'.
6425
6426 ---------------------------------------
6427
6428 *progressbar "<color>",<seconds>;
6429
6430 This command works almost like sleep2, but displays a progress bar
6431 above the head of the currently attached character (like cast bar).
6432 Once the given amount of seconds passes, the script resumes. If the
6433 character moves while the progress bar progresses, it is aborted and
6434 the script ends. The color format is in RGB (RRGGBB). The color is
6435 currently ignored by the client and appears always green.
6436
6437 ---------------------------------------
6438
6439 *progressbar_npc "<color>",<seconds>{,<"NPC Name">};
6440
6441 This command works like progressbar, but displays a progress bar
6442 above the head of the currently attached (or given) NPC. Once the
6443 given amount of seconds passes, the script resumes. The color format
6444 is in RGB (RRGGBB). The color is currently ignored by the client and
6445 appears always green.
6446
6447 Note: If a player is attached to the NPC, they are detached from the NPC
6448 as soon as the progress bar activates.
6449
6450 ---------------------------------------
6451 //
6452 5,1.- End of time-related commands
6453 //
6454 ---------------------------------------
6455
6456 *announce "<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
6457
6458 This command will broadcast a message to all or most players, similar to
6459 @kami/@kamib GM commands.
6460
6461         announce "This will be shown to everyone at all in yellow.",0;
6462
6463 The region the broadcast is heard in (target), source of the broadcast
6464 and the color the message will come up as is determined by the flags.
6465
6466 The flag values are coded as constants in 'src/map/script_constants.h' to make them easier to use.
6467
6468 Target flags:
6469 - bc_all: Broadcast message is sent server-wide (default).
6470 - bc_map: Message is sent to everyone in the same map as the source of the broadcast (see below).
6471 - bc_area: Message is sent to players in the vicinity of the source.
6472 - bc_self: Message is sent only to current player.
6473 You cannot use more than one target flag.
6474
6475 Source flags:
6476 - bc_pc: Broadcast source is the attached player (default).
6477 - bc_npc: Broadcast source is the NPC, not the player attached to the script
6478   (useful when a player is not attached or the message should be sent to those
6479   nearby the NPC).
6480 You cannot use more than one source flag.
6481
6482 Special flags:
6483 - bc_yellow: Broadcast will be displayed in yellow color (default).
6484 - bc_blue: Broadcast will be displayed in blue color.
6485 - bc_woe: Indicates that this broadcast is 'WoE Information' that can be disabled client-side.
6486 Due to the way client handles broadcasts, it is impossible to set both bc_blue and bc_woe.
6487
6488 The optional parameters allow usage of broadcasts in custom colors, font-weights, sizes etc.
6489 If any of the optional parameters is used, special flag is ignored.
6490 Optional parameters may not work well (or at all) depending on a game client used.
6491
6492 The color parameter is a single number which can be in hexadecimal notation.
6493 For example:
6494     announce "This will be shown to everyone at all in green.",bc_all,0x00FF00;
6495 Will display a global announce in green. The color format is in RGB (0xRRGGBB).
6496
6497 In official scripts only two font-weights (types) are used:
6498  - normal (FW_NORMAL = 400, default),
6499  - bold (FW_BOLD = 700).
6500
6501 Default font size is 12.
6502
6503 Using this for private messages to players is probably not that good an idea,
6504 but it can be used instead in NPCs to "preview" an announce.
6505
6506         // This will be a private message to the player using the NPC that made the
6507         // announcement
6508         announce "This is my message just for you",bc_blue|bc_self;
6509
6510         // This will be shown on everyones screen that is in sight of the NPC.
6511         announce "This is my message just for you people here",bc_npc|bc_area;
6512
6513 ---------------------------------------
6514
6515 *mapannounce "<map name>","<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}}};
6516
6517 This command will work like 'announce' but will only broadcast to characters
6518 currently residing on the specified map. The flag and optional parameters
6519 parameters are the same as in 'announce', but target and source flags are ignored.
6520
6521 ---------------------------------------
6522
6523 *areaannounce "<map name>",<x1>,<y1>,<x2>,<y2>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}}};
6524
6525 This command works like 'announce' but will only broadcast to characters
6526 residing in the specified x1/y1-x2/y2 rectangle on the map given. The flags and
6527 optional parameters are the same as in 'announce', but target and source flags are ignored.
6528
6529         areaannounce "prt_church",0,0,350,350,"God's in his heaven, all right with the world",0;
6530
6531 ---------------------------------------
6532
6533 *callshop "<name>",<option>;
6534
6535 These are a series of commands used to create dynamic shops.
6536 The 'callshop' function calls an invisible shop (view -1) as if the player clicked on it.
6537
6538 The options are:
6539         0 = The normal window (buy, sell and cancel)
6540         1 = The buy window
6541         2 = The sell window
6542
6543 Note: The <option> parameter only works on the 'shop' type NPC.
6544
6545 A shop called with this command will trigger the labels "OnBuyItem" and "OnSellItem"
6546 (as long as an npcshop* command is executed from that NPC, see note below). These
6547 labels, if used, will replace how the shop handles the buying and selling of items,
6548 allowing for the creation of dynamic shops.
6549
6550 The label "OnBuyItem" sets the following arrays:
6551         @bought_nameid   - item ID bought
6552         @bought_quantity - amount bought
6553
6554 The label "OnSellItem" sets the following arrays:
6555         @sold_nameid     - item ID sold
6556         @sold_quantity   - amount sold
6557         @sold_refine     - refine count
6558         @sold_attribute  - if the item is broken (1) or not (0)
6559         @sold_identify   - if the item is identified (1) or not (0)
6560         @sold_card1      - card slot 1
6561         @sold_card2      - card slot 2
6562         @sold_card3      - card slot 3
6563         @sold_card4      - card slot 4
6564
6565 Note: These labels will only be triggered if an npcshop* command is executed because these
6566 commands set a special data on the shop NPC, named master_nd in the source. The above labels
6567 are triggered in the NPC whose master_nd is given in the shop.
6568
6569 A full example of a dynamic shop can be found in doc/sample/npc_dynamic_shop.txt.
6570
6571 ---------------------------------------
6572
6573 *npcshopitem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}};
6574
6575 This command lets you override the contents of an existing NPC shop or cashshop. The
6576 current sell list will be wiped, and only the items specified with the price
6577 specified will be for sale.
6578
6579 The function returns 1 if shop was updated successfully, or 0 if not found.
6580
6581 NOTES:
6582  - That you cannot use -1 to specify default selling price!
6583  - If attached shop type is market shop, need an extra param after price, it's <qty>
6584    and make sure don't add duplication item!
6585
6586 ---------------------------------------
6587
6588 *npcshopadditem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}};
6589
6590 This command will add more items at the end of the selling list for the
6591 specified NPC shop or cashshop. If you specify an item already for sell, that item will
6592 appear twice on the sell list.
6593
6594 The function returns 1 if shop was updated successfully, or 0 if not found.
6595
6596 NOTES:
6597  - That you cannot use -1 to specify default selling price!
6598  - If attached shop type is market shop, need an extra param after price, it's <qty>
6599    and make sure don't add duplication item!
6600
6601 ---------------------------------------
6602
6603 *npcshopdelitem "<name>",<item id>{,<item id>{,<item id>{,...}}};
6604
6605 This command will remove items from the specified NPC shop or cashshop.
6606 If the item to remove exists more than once on the shop, all instances will be
6607 removed.
6608
6609 Note that the function returns 1 even if no items were removed. The return
6610 value is only to confirm that the shop was indeed found.
6611
6612 ---------------------------------------
6613
6614 *npcshopattach "<name>"{,<flag>};
6615
6616 This command will attach the current script to the given NPC shop.
6617 When a script is attached to a shop, the events "OnBuyItem" and "OnSellItem"
6618 of your script will be executed whenever a player buys/sells from the shop.
6619 Additionally, the arrays @bought_nameid[], @bought_quantity[] or @sold_nameid[]
6620 and @sold_quantity[] will be filled up with the items and quantities
6621 bought/sold.
6622
6623 The optional parameter specifies whether to attach ("1") or detach ("0") from
6624 the shop (the default is to attach). Note that detaching will detach any NPC
6625 attached to the shop, even if it's from another script, while attaching will
6626 override any other script that may be already attached.
6627
6628 The function returns 0 if the shop was not found, 1 otherwise.
6629
6630 NOTES:
6631  - If attached shop type is market shop, will be default to call the 'buy' window.
6632
6633 ---------------------------------------
6634
6635 *npcshopupdate "<name>",<item_id>,<price>{,<stock>}
6636
6637 Update an entry from shop. If price is 0 means don't change the price, maybe used for
6638 marketshop to update the stock quantity. Except marketshop type, 'stock' value means
6639 nothing.
6640
6641 ---------------------------------------
6642
6643 *waitingroom "<chatroom name>",<limit>{,"<event label>"{,<trigger>{,<required zeny>{,<min lvl>{,<max lvl>}}}}};
6644
6645 This command will create a chat room, owned by the NPC object running this
6646 script and displayed above the NPC sprite.
6647 The maximum length of a chat room name is 60 letters.
6648
6649 The limit is the maximum number of people allowed to enter the chat room.
6650 The attached NPC is included in this count. If the optional event and trigger
6651 parameters are given, the event label ("<NPC object name>::<label name>")
6652 will be invoked as if with a 'doevent' upon the number of people in the chat
6653 room reaching the given triggering amount.
6654
6655 // The NPC will just show a box above its head that says "Hello World", clicking
6656 // it will do nothing, since the limit is zero.
6657     waitingroom "Hello World",0;
6658
6659 // The NPC will have a box above its head, it will say "Disco - Waiting Room"
6660 // and will have 8 waiting slots. Clicking this will enter the chat room, where
6661 // the player will be able to wait until 7 players accumulate. Once this happens,
6662 // it will cause the NPC "Bouncer" run the label "OnStart".
6663
6664     waitingroom "Disco - Waiting Room",8,"Bouncer::OnStart",7;
6665
6666 // The NPC will have a box above its head, it will say "Party - Waiting Room"
6667 // and will have 8 waiting slots. Clicking this will allow a player who has
6668 // 5000 zeny and lvl 50~99 to enter the chat room, where the player will be
6669 // able to wait until 7 players accumulate. Once this happens, it will cause
6670 // the NPC "Bouncer" run the label "OnStart".
6671
6672         waitingroom "Party - Waiting Room",8,"Bouncer::OnStart",7,5000,50,99;
6673
6674 Creating a waiting room does not stop the execution of the script and it will
6675 continue to the next line.
6676
6677 For more examples see the 2-1 and 2-2 job quest scripts which make extensive use
6678 of waiting rooms.
6679
6680 ---------------------------------------
6681
6682 *delwaitingroom {"<NPC object name"};
6683
6684 This command will delete a waiting room. If no parameter is given, it will
6685 delete a waiting room attached to the NPC object running this command, if it is,
6686 it will delete a waiting room owned by another NPC object. This is the only way
6687 to get rid of a waiting room, nothing else will cause it to disappear.
6688
6689 It's not clear what happens to a waiting room if the NPC is disabled with
6690 'disablenpc', by the way.
6691
6692 ---------------------------------------
6693
6694 *enablewaitingroomevent {"<NPC object name>"};
6695 *disablewaitingroomevent {"<NPC object name>"};
6696 *enablearena;
6697 *disablearena;
6698
6699 This will enable and disable triggering the waiting room event (see
6700 'waitingroom') respectively. Optionally giving an NPC object name will do that
6701 for a specified NPC object. The chat room will not disappear when triggering is
6702 disabled and enabled in this manner and players will not be kicked out of it.
6703 Enabling a chat room event will also cause it to immediately check whether the
6704 number of users in it exceeded the trigger amount and trigger the event
6705 accordingly.
6706
6707 Normally, whenever a waiting room was created to make sure that only one
6708 character is, for example, trying to pass a job quest trial, and no other
6709 characters are present in the room to mess up the script.
6710
6711 The 'enablearena'/'disablearena' commands are just aliases with no parameter.
6712 These are supposedly left here for compatibility with official server scripts,
6713 but no rAthena script uses these at the moment.
6714
6715 ---------------------------------------
6716
6717 *getwaitingroomstate(<information type>{,"<NPC object name>"})
6718
6719 This function will return information about the waiting room state for the
6720 attached waiting room or for a waiting room attached to the specified NPC if
6721 any.
6722
6723 The valid information types are:
6724
6725  0  - Number of users currently chatting.
6726  1  - Maximum number of users allowed.
6727  2  - Will return 1 if the waiting room has a trigger set.
6728       0 otherwise.
6729  3  - Will return 1 if the waiting room is currently disabled.
6730       0 otherwise.
6731  4  - The Title of the waiting room (string)
6732  5  - Password of the waiting room, if any. Pointless, since there is no way to
6733       set a password on a waiting room right now.
6734  16 - Event name of the waiting room (string)
6735  32 - Whether or not the waiting room is full.
6736  33 - Whether the amount of users in the waiting room is higher than the trigger
6737       number.
6738
6739 ---------------------------------------
6740
6741 *warpwaitingpc "<map name>",<x>,<y>{,<number of people>};
6742
6743 This command will warp the amount of characters equal to the trigger number of
6744 the waiting room chat attached to the NPC object running this command to the
6745 specified map and coordinates, kicking them out of the chat. Those waiting the
6746 longest will get warped first. It can also do a random warp on the same map
6747 ("Random" instead of map name) and warp to the save point ("SavePoint").
6748
6749 The list of characters to warp is taken from the list of the chat room members.
6750 Those not in the chat room will not be considered even if they are talking to
6751 the NPC in question. If the number of people is given, exactly this much people
6752 will be warped.
6753
6754 This command can also keep track of who just got warped. It does this by setting
6755 special variables:
6756
6757 $@warpwaitingpc[] is an array containing the account_id numbers of the
6758                   characters who were just warped.
6759 $@warpwaitingpcnum contains the number of the character it just warped.
6760
6761 See also 'getpartymember' for advice on what to do with those variables.
6762
6763 The obvious way of using this effectively would be to set up a waiting room for
6764 two characters to be warped onto a random PVP map for a one-on-one duel, for
6765 example.
6766
6767 ---------------------------------------
6768
6769 *waitingroomkick "<NPC object name>" , "<character name>";
6770
6771 This command kicks the given character from the waiting room attached to the given NPC.
6772
6773 ---------------------------------------
6774
6775 *getwaitingroomusers "<NPC object name>";
6776
6777 This command get all the characters in the waiting room of the given NPC and stores
6778 their gids in the array .@waitingroom_users[]. Also, stores the the number of characters
6779 in the variable .@waitingroom_usercount
6780
6781 ---------------------------------------
6782
6783 *kickwaitingroomall {"<NPC object name>"};
6784
6785 This command kicks everybody out of a specified waiting room chat.
6786
6787 ---------------------------------------
6788
6789 *setmapflagnosave "<map name>","<alternate map name>",<x>,<y>;
6790
6791 This command sets the 'nosave' flag for the specified map and also gives an
6792 alternate respawn-upon-relogin point.
6793
6794 It does not make a map impossible to make a save point on as you would normally
6795 think, 'savepoint' will still work. It will, however, make the specified map
6796 kick the reconnecting players off to the alternate map given to the coordinates
6797 specified.
6798
6799 ---------------------------------------
6800
6801 *setmapflag "<map name>",<flag>{,<zone>{,<type>}};
6802
6803 This command marks a specified map with the given map flag, which will alter the
6804 behavior of the map. A full list of mapflags is located in 'src/map/script_constants.h' with
6805 the 'mf_' prefix, and documentation can be found in 'doc/mapflags.txt'.
6806
6807 The map flags alter the behavior of the map regarding teleporting (mf_nomemo,
6808 mf_noteleport, mf_nowarp, mf_nogo), storing location when disconnected
6809 (mf_nosave), dead branch usage (mf_nobranch), penalties upon death
6810 (mf_nopenalty, mf_nozenypenalty), PVP behavior (mf_pvp, mf_pvp_noparty,
6811 mf_pvp_noguild), WoE behavior (mf_gvg,mf_gvg_noparty), ability to use
6812 skills or open up trade deals (mf_notrade, mf_novending, mf_noskill, mf_noicewall),
6813 current weather effects (mf_snow, mf_fog, mf_sakura, mf_leaves, mf_rain, mf_clouds,
6814 mf_fireworks) and whether night will be in effect on this map (mf_nightenabled).
6815
6816 The optional parameter 'zone' is used to set the zone for restricted mapflags.
6817
6818 For the 'skill_damage' mapflag, 'zone' functions as 'value' (-100 to 100000) and
6819 'type' can be:
6820  1: damage against players
6821  2: damage against mobs
6822  3: damage against bosses
6823  4: damage against other
6824  5: caster type
6825
6826 ---------------------------------------
6827
6828 *removemapflag "<map name>",<flag>{,<zone>};
6829
6830 This command removes a mapflag from a specified map.
6831 See 'setmapflag' for a list of mapflags.
6832
6833 The optional parameter 'zone' is used to remove the zone from restricted mapflags.
6834
6835 ---------------------------------------
6836
6837 *getmapflag("<map name>",<flag>{,<type>})
6838
6839 This command checks the status of a given mapflag and returns the mapflag's state.
6840 0 means OFF, and 1 means ON. See 'setmapflag' for a list of mapflags.
6841
6842 The optional parameter 'type' is used in the 'skill_damage' mapflag:
6843  0: if mapflag is set (default)
6844  1: damage against players
6845  2: damage against mobs
6846  3: damage against bosses
6847  4: damage against other
6848  5: caster type
6849
6850 ---------------------------------------
6851
6852 *setbattleflag "<battle flag>",<value>{,<reload>};
6853 *getbattleflag("<battle flag>")
6854
6855 Sets or gets the value of the given battle flag.
6856 Battle flags are the flags found in the battle / *.conf files and is also used in Lupus' variable rates script.
6857 If the reload value is given then the server will attempt to reload monster data
6858 to properly apply the new rates. This applies to EXP/Drop type configs. The server
6859 will only attempt to reload specific configs.
6860
6861 Examples:
6862
6863 // Will set the base experience rate to 20x (2000%) - Monster data will continue to use previous rates at server start
6864         setBattleFlag "base_exp_rate",2000;
6865
6866 // Will set the base experience rate to 20x (2000%) - Monster data will be reloaded to new value
6867         setBattleFlag "base_exp_rate",2000,true;
6868
6869 // Will return the value of the base experience rate (when used after the above example, it would print 2000).
6870         mes getBattleFlag("base_exp_rate");
6871
6872 ---------------------------------------
6873
6874 *warpportal <source x>,<source y>,"<map name>",<target x>,<target y>;
6875
6876 Creates a warp portal identical to the Acolyte "Warp Portal" skill.
6877 The source coordinates specify the portal's location on the map of the invoking NPC.
6878 The target map and coordinates determine the destination of the portal.
6879
6880 Examples:
6881
6882 // Will create a warp portal on the NPC's map at 150,150 leading to prontera, coords 150,180.
6883         warpportal 150,150,"prontera",150,180;
6884
6885 ---------------------------------------
6886
6887 *mapwarp "<from map>","<to map>",<x>,<y>{,<type>,<ID>};
6888
6889 This command will collect all characters located on the From map and warp them
6890 wholesale to the same point on the To map, or randomly distribute them there if
6891 the coordinates are zero. "Random" is understood as a special To map name and
6892 will mean randomly shuffling everyone on the same map.
6893
6894 Optionally, a type and ID can be specified. Available types are:
6895
6896  0 - Everyone
6897  1 - Guild
6898  2 - Party
6899
6900 Example:
6901
6902 // Will warp all members of guild with ID 63 on map prontera to map alberta.
6903         mapwarp "prontera","alberta",150,150,1,63;
6904
6905 ---------------------------------------
6906 \\
6907 5,2.- Guild-related commands
6908 \\
6909 ---------------------------------------
6910
6911 *maprespawnguildid "<map name>",<guild id>,<flag>;
6912
6913 This command goes through the specified map and for each player and monster
6914 found there does stuff.
6915
6916 Flag is a bit-mask (add up numbers to get effects you want)
6917  1 - warp all guild members to their save points.
6918  2 - warp all non-guild members (including guildless players) to their save points.
6919  4 - remove all monsters which are not guardian or Emperium.
6920
6921 Flag 7 will, therefore, mean 'wipe all mobs but guardians and the Emperium and
6922 kick all characters out', which is what the official scripts do upon castle
6923 surrender. Upon start of WoE, the scripts do 2 (warp all intruders out).
6924
6925 For examples, check the WoE scripts in the distribution.
6926
6927 ---------------------------------------
6928
6929 *agitstart;
6930 *agitend;
6931 *agitstart2;
6932 *agitend2;
6933 *agitstart3;
6934 *agitend3;
6935
6936 These commands will start and end War of Emperium FE, War of Emperium SE,
6937 or War of Emperium TE.
6938
6939 This is a bit more complex than it sounds, since the commands themselves won't
6940 actually do anything interesting, except causing all 'OnAgitStart:' and
6941 'OnAgitEnd:', 'OnAgitStart2:' and 'OnAgitEnd2:', or 'OnAgitStart3:' and
6942 'OnAgitEnd3:' in the case of latter two commands, events to run everywhere,
6943 respectively. They are used as  simple triggers to run a lot of complex scripts
6944 all across the server, and they, in turn, are triggered by clock with an
6945 'OnClock<time>:' time-triggering label.
6946
6947 ---------------------------------------
6948
6949 *gvgon "<map name>";
6950 *gvgoff "<map name>";
6951
6952 These commands will turn GVG mode for the specified maps on and off, setting up
6953 appropriate map flags. In GVG mode, maps behave as if during the time of WoE,
6954 even though WoE itself may or may not actually be in effect.
6955
6956 ---------------------------------------
6957
6958 *gvgon3 "<map name>";
6959 *gvgoff3 "<map name>";
6960
6961 Theses commands behave identically to gvgon/gvgoff, but apply GVG_TE mapflag.
6962
6963 ---------------------------------------
6964
6965 *flagemblem <guild id>;
6966
6967 This command only works when run by the NPC objects which have sprite id 722,
6968 which is a 3D guild flag sprite. If it isn't, the data will change, but nothing
6969 will be seen by anyone. If it is invoked in that manner, the emblem of the
6970 specified guild will appear on the flag, though, if any players are watching it
6971 at this moment, they will not see the emblem change until they move out of sight
6972 of the flag and return.
6973
6974 This is commonly used in official guildwar scripts with a function call which
6975 returns a guild id:
6976
6977 // This will change the emblem on the flag to that of the guild that owns
6978 // "guildcastle"
6979
6980     flagemblem GetCastleData("guildcastle",1);
6981
6982 ---------------------------------------
6983
6984 *guardian "<map name>",<x>,<y>,"<name to show>",<mob id>{,"<event label>"{,<guardian index>}};
6985
6986 This command is roughly equivalent to 'monster', but is meant to be used with
6987 castle guardian monsters and will only work with them. It will set the guardian
6988 characteristics up according to the castle's investment values and otherwise
6989 set the things up that only castle guardians need.
6990
6991 Since trunk r12524:
6992 Returns the id of the mob or 0 if an error occurred.
6993 When 'guardian index' isn't supplied it produces a temporary guardian.
6994 Temporary guardians are not saved with the castle and can't be accessed by guardianinfo.
6995
6996 ---------------------------------------
6997
6998 *guardianinfo("<map name>", <guardian number>, <type>);
6999
7000 This function will return various info about the specified guardian, or -1
7001 if it fails for some reason. It is primarily used in the castle manager NPC.
7002
7003 Map name and guardian number (value between 0 and 7) define the target.
7004 Type indicates what information to return:
7005  0 - visibility (whether the guardian is installed or not)
7006  1 - max. hp
7007  2 - current hp
7008
7009 ---------------------------------------
7010
7011 *getguildalliance(<guild id1>, <guild id2>);
7012
7013 This command will return the relation between 2 guilds.
7014
7015 NOTE: This should be used in collaboration with 'requestguildinfo' as the
7016 map-server needs to request for information from the char-server.
7017
7018 Return values:
7019         -2 - Guild ID1 does not exist
7020         -1 - Guild ID2 does not exist
7021          0 - Both guilds have no relation OR guild ID aren't given
7022          1 - Both guilds are allies
7023          2 - Both guilds are antagonists
7024
7025 ---------------------------------------
7026 //
7027 5,2.- End of guild-related commands
7028 //
7029 ---------------------------------------
7030
7031 *npcspeed <speed value>;
7032 *npcwalkto <x>,<y>;
7033 *npcstop;
7034
7035 These commands will make the NPC object in question move around the map. As they
7036 currently are, they are a bit buggy and are not useful for much more than making
7037 an NPC move randomly around the map.
7038
7039 'npcspeed' will set the NPCs walking speed to a specified value. As in the
7040 @speed GM command, 200 is the slowest possible speed while 0 is the fastest
7041 possible (instant motion). 100 is the default character walking speed.
7042
7043 'npcwalkto' will start the NPC sprite moving towards the specified coordinates
7044 on the same map it is currently on. The script proceeds immediately after the
7045 NPC begins moving.
7046
7047 'npcstop' will stop the motion.
7048
7049 While in transit, the NPC will be clickable, but invoking it will cause it to
7050 stop moving, which will make its coordinates different from what the client
7051 computed based on the speed and motion coordinates. The effect is rather
7052 unnerving.
7053
7054 Only a few NPC sprites have walking animations, and those that do, do not get
7055 the animation invoked when moving the NPC, due to the problem in the NPC walking
7056 code, which looks a bit silly. You might have better success by defining a job-
7057 sprite based sprite id in 'db/mob_avail.txt' with this.
7058
7059 ---------------------------------------
7060
7061 *movenpc "<NPC name>",<x>,<y>{,<dir>};
7062
7063 This command looks like the NPCWalkToxy function,but is a little different.
7064
7065 While NPCWalkToXY just makes the NPC 'walk' to the coordinates given (which
7066 sometimes gives problems if the path isn't a straight line without objects),
7067 this command just moves the NPC. It basically warps out and in on the current
7068 and given spot. Direction can be used to change the NPC's facing direction.
7069
7070 Example:
7071
7072 // This will move Bugga from it's old coordinates to the new coordinates at 100,20 (if those coordinates are legit).
7073         moveNPC "Bugga",100,20;
7074
7075 ---------------------------------------
7076
7077 =====================
7078 |6.- Other commands.|
7079 =====================
7080 ---------------------------------------
7081
7082 *debugmes "<message>";
7083
7084 This command will send the message to the server console (map-server window). It
7085 will not be displayed anywhere else.
7086
7087     // Displays "NAME has clicked me!" in the map-server window.
7088     debugmes strcharinfo(0) + " has clicked me!";
7089
7090 ---------------------------------------
7091
7092 *logmes "<message>";
7093
7094 This command will write the message given to the map server NPC log file, as
7095 specified in 'conf/log_athena.conf'. In the TXT version of the server, the log
7096 file is 'log/npclog.log' by default. In the SQL version, if SQL logging is
7097 enabled, the message will go to the 'npclog' table, otherwise, it will go to the
7098 same log file.
7099
7100 If logs are not enabled, nothing will happen.
7101
7102 ---------------------------------------
7103
7104 *globalmes "<message>"{,"<NPC name>"};
7105
7106 This command will send a message to the chat window of all currently connected
7107 characters.
7108
7109 If NPC name is specified, the message will be sent as if the sender would be
7110 the NPC with the said name.
7111 The display name of the NPC won't get appended in front of the message.
7112
7113 ---------------------------------------
7114
7115 *rand(<number>{,<number>});
7116
7117 This function returns a number ...
7118 (if you specify one) ... randomly positioned between 0 and the number you specify -1.
7119 (if you specify two) ... randomly positioned between the two numbers you specify.
7120
7121 rand(10)  would result in 0,1,2,3,4,5,6,7,8 or 9
7122 rand(0,9) would result in 0,1,2,3,4,5,6,7,8 or 9
7123 rand(2,5) would result in 2,3,4 or 5
7124
7125 ---------------------------------------
7126
7127 *viewpoint <action>,<x>,<y>,<point number>,<color>;
7128
7129 This command will mark places on the mini map in the client connected to the
7130 invoking character. It uses the normal X and Y coordinates from the main map.
7131 The colors of the marks are defined using a hexadecimal number, same as the ones
7132 used to color text in 'mes' output, but are written as hexadecimal numbers in C.
7133 (They look like 0x<six numbers>.)
7134
7135 Action is what you want to do with a point, 1 will set it, while 2 will clear
7136 it. 0 will also set it, but automatically removes the point after 15 seconds.
7137 Point number is the number of the point - you can have several. If more than
7138 one point is drawn at the same coordinates, they will cycle, which can be used
7139 to create flashing marks.
7140
7141         // This command will show a mark at coordinates X 30 Y 40, is mark number 1,
7142         // and will be red.
7143
7144         viewpoint 1,30,40,1,0xFF0000;
7145
7146 This will create three points:
7147
7148         viewpoint 1,30,40,1,0xFF0000;
7149         viewpoint 1,35,45,2,0xFF0000;
7150         viewpoint 1,40,50,3,0xFF0000;
7151
7152 And this is how you remove them:
7153
7154         viewpoint 2,30,40,1,0xFF0000;
7155         viewpoint 2,35,45,2,0xFF0000;
7156         viewpoint 2,40,50,3,0xFF0000;
7157
7158 The client determines what it does with the points entirely, the server keeps no
7159 memory of where the points are set whatsoever.
7160
7161 ---------------------------------------
7162
7163 *cutin "<filename>",<position>;
7164
7165 This command will display a picture, usually an NPC illustration, also called
7166 cutin, for the currently attached client. The position parameter determines the
7167 placement of the illustration and takes following values:
7168
7169         0 - bottom left corner
7170         1 - bottom middle
7171         2 - bottom right corner
7172         3 - middle of screen in a movable window with an empty title bar
7173         4 - middle of screen without the window header, but still movable
7174
7175 The picture is read from data\texture\유저인터페이스\illust, from both the GRF archive
7176 and data folder, and is required to be a bitmap. The file extension .bmp can be
7177 omitted. Magenta color (#ff00ff) is considered transparent. There is no limit
7178 placed on the size of the illustrations by the client, although loading of large
7179 pictures (about 700x700 and larger) causes the client to freeze shortly (lag).
7180 Typically the size is about 320x480. New illustrations can be added by just
7181 putting the new file into the location above.
7182
7183 The client is able to display only one cutin at the same time and each new one
7184 will cause the old one to disappear. To delete the currently displayed
7185 illustration without displaying a new one, an empty file name and position 255
7186 must be used.
7187
7188         // Displays the Comodo Kafra illustration in lower right corner.
7189         cutin "kafra_07",2;
7190
7191         // Typical way to end a script, which displayed an illustration during a
7192         // dialog with a player.
7193         mes "See you.";
7194         close2;
7195         cutin "",255;
7196         end;
7197
7198 ---------------------------------------
7199
7200 *emotion <emotion number>{,<target>{,"<target name>"}};
7201
7202 This command makes an object display an emotion sprite above their own as
7203 if they were doing that emotion. For a full list of emotion numbers,
7204 see 'src/map/script_constants.h' under 'e_'. The not so obvious ones are 'e_what'
7205 (a question mark) and 'e_gasp' (the exclamation mark).
7206
7207 The optional target parameter specifies who will get the emotion on top of
7208 their head. If 0 (the default if omitted), the NPC in current use will show
7209 the emotion, if 1, the player that is running the script will display it.
7210
7211 Target name parameter allows to display emotion on top of other NPC/PC without
7212 event labels. If specified name is not found, command does nothing.
7213
7214 ---------------------------------------
7215
7216 *misceffect <effect number>;
7217
7218 This command, if run from an NPC object that has a sprite, will call up a
7219 specified effect number, centered on the NPC sprite. If the running code does
7220 not have an object ID (a 'floating' NPC) or is not running from an NPC object at
7221 all (an item script) the effect will be centered on the character who's RID got
7222 attached to the script, if any. For usable item scripts, this command will
7223 create an effect centered on the player using the item.
7224
7225 A full list of known effects is found in 'doc/effect_list.txt'. The list of
7226 those that actually work may differ greatly between client versions.
7227
7228 ---------------------------------------
7229
7230 *soundeffect "<effect filename>",<type>;
7231 *soundeffectall "<effect filename>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>};
7232
7233 These two commands will play a sound effect to either the invoking character
7234 only ('soundeffect') or multiple characters ('soundeffectall'). If the running
7235 code does not have an object ID (a 'floating' NPC) or is not running from an NPC
7236 object at all (an item script) the sound will be centered on the character who's
7237 RID got attached to the script, if any. If it does, it will be centered on that
7238 object. (an NPC sprite)
7239
7240 Effect filename is the filename in a GRF. It must have the .wav extension.
7241
7242 It's not quite certain what the 'type' actually does, it is sent to the client
7243 directly. It probably determines which directory to play the effect from.
7244 It's certain that giving 0 for the number will play sound files from '\data\wav\',
7245 but where the other numbers will read from is unclear.
7246
7247 The sound files themselves must be in the PCM format, and file names should also
7248 have a maximum length of 23 characters including the .wav extension:
7249
7250 soundeffect "1234567890123456789.wav", 0; // this will play the soundeffect
7251 soundeffect "12345678901234567890.wav", 0; // throw gravity error
7252
7253 You can add your own effects this way, naturally.
7254
7255 ---------------------------------------
7256
7257 *playBGM "<BGM filename>";
7258 *playBGMall "<BGM filename>"{,"<map name>"{,<x0>,<y0>,<x1>,<y1>}};
7259
7260 These two commands will play a Background Music to either the invoking character
7261 only ('playBGM') or multiple characters ('playBGMall').
7262
7263 BGM filename is the filename in /BGM/ folder. It has to be in .mp3 extension.
7264
7265 It's not required to specify the extension inside the script.
7266 If coordinates are omitted, BGM will be broadcasted on the entire map. If the map name
7267 is omitted as well the BGM will be played for the entire server.
7268
7269 You can add your own BGMs this way, naturally.
7270
7271 ---------------------------------------
7272
7273 *pvpon "<map name>";
7274 *pvpoff "<map name>";
7275
7276 These commands will turn PVP mode for the specified maps on and off. Beside
7277 setting the flags referred to in 'setmapflag', 'pvpon' will also create a PVP
7278 timer and ranking as will @pvpon GM command do.
7279
7280 ---------------------------------------
7281
7282 *atcommand "<command>";
7283
7284 This command will run the given command line exactly as if it was typed in from
7285 the keyboard by the player connected to the invoking character, and that
7286 character belonged to an account which had GM level 99.
7287
7288         // This will ask the invoker for a character name and then use the '@nuke'
7289         // GM command on them, killing them mercilessly.
7290         input .@player$;
7291         atcommand "@nuke " + .@player$;
7292
7293 Note that for atcommands bound using 'bindatcmd', this command will execute the
7294 original atcommand, not the script-bound atcommand.
7295
7296 ---------------------------------------
7297
7298 *charcommand "<command>";
7299
7300 This command will run the given command line exactly as if it was typed in from
7301 the keyboard from a character that belonged to an account which had GM level 99.
7302
7303 The commands can also run without an attached rid.
7304
7305         // This would do the same as above, but now
7306         // it doesn't need a player attached by default.
7307         charcommand "#option 0 0 0 Roy";
7308
7309 ---------------------------------------
7310
7311 *bindatcmd "<command>","<NPC object name>::<event label>"{,<atcommand level>,<charcommand level>};
7312
7313 This command will bind a NPC event label to an atcommand. Upon execution of the
7314 atcommand, the user will invoke the NPC event label. Each atcommand is only allowed
7315 one binding. If you rebind, it will override the original binding.
7316
7317 The following variables are set upon execution:
7318         .@atcmd_command$       =  The name of the @command used.
7319         .@atcmd_parameters$[]  =  Array containing the given parameters, starting from an index of 0.
7320         .@atcmd_numparameters  =  The number of parameters defined.
7321
7322 Example:
7323
7324         When a user types the command "@test", an angel effect will be shown.
7325
7326         -       script  atcmd_example   -1,{
7327         OnInit:
7328                 bindatcmd "test",strnpcinfo(3) + "::OnAtcommand";
7329                 end;
7330         OnAtcommand:
7331                 specialeffect2 338;
7332                 end;
7333         }
7334
7335 ---------------------------------------
7336
7337 *unbindatcmd "<command>";
7338
7339 This command will unbind a NPC event label from an atcommand.
7340
7341 ---------------------------------------
7342
7343 *useatcmd "<command>";
7344
7345 This command will execute a script-bound atcommand for the attached RID. If the
7346 supplied command is not bound to any script, this command will act like 'atcommand'
7347 and attempt to execute a source-defined command.
7348
7349 The three .@atcmd_***** variables will NOT be set when invoking script-bound atcommands
7350 in this way.
7351
7352 ---------------------------------------
7353 \\
7354 6,1.- Unit-related commands
7355 \\
7356 ---------------------------------------
7357
7358 *unitwalk <GID>,<x>,<y>{,"<event label>"};
7359 *unitwalkto <GID>,<Target GID>{,"<event label>"};
7360
7361 This command will tell a <GID> to walk to a position, defined either as a set of
7362 coordinates or another object. The command returns a 1 for success and 0 upon failure.
7363
7364 If coordinates are passed, the <GID> will walk to the given x,y coordinates on the
7365 unit's current map. While there is no way to move across an entire map with 1 command
7366 use, this could be used in a loop to move long distances.
7367
7368 If an object ID is passed, the initial <GID> will walk to the <Target GID> (similar to
7369 walking to attack). This is based on the distance from <GID> to <Target ID>. This command
7370 uses a hard walk check, so it will calculate a walk path with obstacles. Sending a bad
7371 target ID will result in an error.
7372
7373 An optional Event Label can be passed as well which will execute when the <GID> has reached
7374 the given coordinates or <Target GID>.
7375
7376 Examples:
7377
7378 // Makes player walk to the coordinates (150,150).
7379         unitwalk getcharid(3),150,150;
7380
7381 // Performs a conditional check with the command and reports success or failure to the player.
7382         if (unitwalk(getcharid(3),150,150))
7383                 dispbottom "Walking you there...";
7384         else
7385                 dispbottom "That's too far away, man.";
7386
7387 // Makes player walk to another character named "WalkToMe".
7388         unitwalkto getcharid(3),getcharid(3,"WalkToMe");
7389
7390 ---------------------------------------
7391
7392 *unitattack <GID>,<Target ID>{,<action type>};
7393 *unitattack <GID>,"<Target Name>"{,<action type>};
7394
7395 This command will make a <GID> attack the specified target. It returns true upon
7396 success and false for all failures.
7397
7398 If <GID> is a player and a non-zero <action type> is given, the unit will perform a
7399 continuous attack instead of a single attack.
7400
7401 Note:
7402 Using unitattack with <GID> 0 means that it will use the currently attached unit.
7403 For players any attack requests will fail, because talking to an NPC prevents attacking a monster.
7404 Therefore you need to detach the player from the NPC before using this command.
7405
7406 ---------------------------------------
7407
7408 *unitkill <GID>;
7409
7410 This command will kill a <GID>.
7411
7412 ---------------------------------------
7413
7414 *unitwarp <GID>,"<map name>",<x>,<y>;
7415
7416 This command will warp a <GID> to the specified map and coordinates.
7417
7418 If <GID> is zero, the command runs for the unit that invoked the script. This can be
7419 used with "OnTouch" to warp monsters:
7420
7421 OnTouch:
7422         unitwarp 0,"this",-1,-1;
7423
7424 ---------------------------------------
7425
7426 *unitstopattack <GID>;
7427
7428 This command will make a <GID> stop attacking.
7429
7430 ---------------------------------------
7431
7432 *unitstopwalk <GID>{,<flag>};
7433
7434 This command will make a <GID> stop moving.
7435
7436 Note: If this is called from OnTouch, then the walktimer attached to the unit is
7437 removed from OnTouch which causes this command to not stop the unit from walking.
7438 Suggest to use 'unitblockmove' to forcefully stop the unit with OnTouch.
7439
7440 The <flag> value affects how the unit is stopped. The following flags are bitwise
7441 values (can be combined using the pipe operator):
7442         USW_NONE = Unit will keep walking to their original destination.
7443         USW_FIXPOS = Issue a fixpos packet afterwards.
7444         USW_MOVE_ONCE = Force the unit to move one cell if it hasn't yet.
7445         USW_MOVE_FULL_CELL = Enable moving to the next cell when unit was already half-way there (may cause on-touch/place side-effects, such as a scripted map change).
7446         USW_FORCE_STOP = Force stop moving.
7447
7448 ---------------------------------------
7449
7450 *unittalk <GID>,"<text>"{,flag};
7451
7452 This command will make a <GID> say a message. The display name of the <GID> won't get appended in front of the message.
7453 flag: Specify target
7454    bc_area - Message is sent to players in the vicinity of the source (default).
7455    bc_self - Message is sent only to player attached.
7456
7457 ---------------------------------------
7458
7459 *unitemote <GID>,<emotion number>;
7460
7461 This command will make a <GID> display an emotion sprite.
7462 For a full list of emotion numbers, see 'src/map/script_constants.h' under 'e_'.
7463
7464 ---------------------------------------
7465
7466 *unitskilluseid <GID>,<skill id>,<skill lvl>{,<target id>,<casttime>};
7467 *unitskilluseid <GID>,"<skill name>",<skill lvl>{,<target id>,<casttime>};
7468 *unitskillusepos <GID>,<skill id>,<skill lvl>,<x>,<y>{,<casttime>};
7469 *unitskillusepos <GID>,"<skill name>",<skill lvl>,<x>,<y>{,<casttime>};
7470
7471 This is the replacement of the older commands, these use the same values for
7472 GID as the other unit* commands (See 'GID').
7473
7474 Skill ID is the ID of the skill, skill level is the level of the skill.
7475 Cast time is the amount of seconds to add or remove from the skill. Use a positive value to
7476 add and negative value to subtract. Using 0 or no value will use the default skill cast time.
7477 For the position, the x and y are given in the UnitSkillUsePos.
7478
7479 ---------------------------------------
7480
7481 *unitexists <GID>;
7482
7483 Checks if the given Game ID exists. Returns false if the object doesn't exist, or true if
7484 it does.
7485
7486 ---------------------------------------
7487
7488 *getunittype <GID>;
7489
7490 Returns the type of object from the given Game ID. Returns -1 if the given GID does not
7491 exist.
7492
7493         UNITTYPE_PC     0
7494         UNITTYPE_NPC    1
7495         UNITTYPE_PET    2
7496         UNITTYPE_MOB    3
7497         UNITTYPE_HOM    4
7498         UNITTYPE_MER    5
7499         UNITTYPE_ELEM   6
7500
7501 ---------------------------------------
7502
7503 *getunitname <GID>;
7504
7505 Gets the name of the given unit. Supported types are monster, homunculus, pet, and NPC.
7506 Mercenary and Elemental don't support custom names.
7507
7508 Returns "Unknown" if unit is not found.
7509
7510 ---------------------------------------
7511
7512 *setunitname <GID>,"<new name>";
7513
7514 Changes the name of the given unit to the new name given. Supported types are monster,
7515 homunculus, and pet. To change an NPC's name, see 'setnpcdisplay'. Mercenary and
7516 Elemental don't support custom names.
7517
7518 Changing a homunculus or pet name will be permanent.
7519
7520 Returns "Unknown" if unit is not found.
7521
7522 ---------------------------------------
7523
7524 *getunitdata <GID>,<arrayname>;
7525 *setunitdata <GID>,<parameter>,<new value>;
7526
7527 This is used to get and set special data related to the unit.
7528 With getunitdata, the array given will be filled with the current data. In setunitdata
7529 the indexes in the array would be used to set that data on the unit.
7530
7531 Both getunitdata and setunitdata will return -1 if the given GID does not exist.
7532
7533 Note: When adjusting a unit's stat (STR, AGI, etc) the unit's respective statuses are
7534       recalculated (HIT, FLEE, etc) automatically. Keep in mind that some stats don't
7535           affect a unit's status and will have to directly be modified.
7536
7537 Parameters (indexes) for monsters are:
7538         UMOB_SIZE
7539         UMOB_LEVEL
7540         UMOB_HP
7541         UMOB_MAXHP
7542         UMOB_MASTERAID
7543         UMOB_MAPID
7544         UMOB_X
7545         UMOB_Y
7546         UMOB_SPEED
7547         UMOB_MODE
7548         UMOB_AI
7549         UMOB_SCOPTION
7550         UMOB_SEX
7551         UMOB_CLASS
7552         UMOB_HAIRSTYLE
7553         UMOB_HAIRCOLOR
7554         UMOB_HEADBOTTOM
7555         UMOB_HEADMIDDLE
7556         UMOB_HEADTOP
7557         UMOB_CLOTHCOLOR
7558         UMOB_SHIELD
7559         UMOB_WEAPON
7560         UMOB_LOOKDIR
7561         UMOB_CANMOVETICK
7562         UMOB_STR
7563         UMOB_AGI
7564         UMOB_VIT
7565         UMOB_INT
7566         UMOB_DEX
7567         UMOB_LUK
7568         UMOB_SLAVECPYMSTRMD
7569         UMOB_DMGIMMUNE
7570         UMOB_ATKRANGE
7571         UMOB_ATKMIN
7572         UMOB_ATKMAX
7573         UMOB_MATKMIN
7574         UMOB_MATKMAX
7575         UMOB_DEF
7576         UMOB_MDEF
7577         UMOB_HIT
7578         UMOB_FLEE
7579         UMOB_PDODGE
7580         UMOB_CRIT
7581         UMOB_RACE
7582         UMOB_ELETYPE
7583         UMOB_ELELEVEL
7584         UMOB_AMOTION
7585         UMOB_ADELAY
7586         UMOB_DMOTION
7587
7588 -----
7589
7590 Parameter (indexes) for homunculi are:
7591         UHOM_SIZE
7592         UHOM_LEVEL
7593         UHOM_HP
7594         UHOM_MAXHP
7595         UHOM_SP
7596         UHOM_MAXSP
7597         UHOM_MASTERCID
7598         UHOM_MAPID
7599         UHOM_X
7600         UHOM_Y
7601         UHOM_HUNGER
7602         UHOM_INTIMACY
7603         UHOM_SPEED
7604         UHOM_LOOKDIR
7605         UHOM_CANMOVETICK
7606         UHOM_STR
7607         UHOM_AGI
7608         UHOM_VIT
7609         UHOM_INT
7610         UHOM_DEX
7611         UHOM_LUK
7612         UHOM_DMGIMMUNE
7613         UHOM_ATKRANGE
7614         UHOM_ATKMIN
7615         UHOM_ATKMAX
7616         UHOM_MATKMIN
7617         UHOM_MATKMAX
7618         UHOM_DEF
7619         UHOM_MDEF
7620         UHOM_HIT
7621         UHOM_FLEE
7622         UHOM_PDODGE
7623         UHOM_CRIT
7624         UHOM_RACE
7625         UHOM_ELETYPE
7626         UHOM_ELELEVEL
7627         UHOM_AMOTION
7628         UHOM_ADELAY
7629         UHOM_DMOTION
7630
7631 -----
7632
7633 Parameter (indexes) for pets are:
7634         UPET_SIZE
7635         UPET_LEVEL
7636         UPET_HP
7637         UPET_MAXHP
7638         UPET_MASTERAID
7639         UPET_MAPID
7640         UPET_X
7641         UPET_Y
7642         UPET_HUNGER
7643         UPET_INTIMACY
7644         UPET_SPEED
7645         UPET_LOOKDIR
7646         UPET_CANMOVETICK
7647         UPET_STR
7648         UPET_AGI
7649         UPET_VIT
7650         UPET_INT
7651         UPET_DEX
7652         UPET_LUK
7653         UPET_DMGIMMUNE
7654         UPET_ATKRANGE
7655         UPET_ATKMIN
7656         UPET_ATKMAX
7657         UPET_MATKMIN
7658         UPET_MATKMAX
7659         UPET_DEF
7660         UPET_MDEF
7661         UPET_HIT
7662         UPET_FLEE
7663         UPET_PDODGE
7664         UPET_CRIT
7665         UPET_RACE
7666         UPET_ELETYPE
7667         UPET_ELELEVEL
7668         UPET_AMOTION
7669         UPET_ADELAY
7670         UPET_DMOTION
7671
7672 -----
7673
7674 Parameter (indexes) for mercenaries are:
7675         UMER_SIZE
7676         UMER_HP
7677         UMER_MAXHP
7678         UMER_MASTERCID
7679         UMER_MAPID
7680         UMER_X
7681         UMER_Y
7682         UMER_KILLCOUNT
7683         UMER_LIFETIME
7684         UMER_SPEED
7685         UMER_LOOKDIR
7686         UMER_CANMOVETICK
7687         UMER_STR
7688         UMER_AGI
7689         UMER_VIT
7690         UMER_INT
7691         UMER_DEX
7692         UMER_LUK
7693         UMER_DMGIMMUNE
7694         UMER_ATKRANGE
7695         UMER_ATKMIN
7696         UMER_ATKMAX
7697         UMER_MATKMIN
7698         UMER_MATKMAX
7699         UMER_DEF
7700         UMER_MDEF
7701         UMER_HIT
7702         UMER_FLEE
7703         UMER_PDODGE
7704         UMER_CRIT
7705         UMER_RACE
7706         UMER_ELETYPE
7707         UMER_ELELEVEL
7708         UMER_AMOTION
7709         UMER_ADELAY
7710         UMER_DMOTION
7711
7712 -----
7713
7714 Parameter (indexes) for elementals are:
7715         UELE_SIZE
7716         UELE_HP
7717         UELE_MAXHP
7718         UELE_SP
7719         UELE_MAXSP
7720         UELE_MASTERCID
7721         UELE_MAPID
7722         UELE_X
7723         UELE_Y
7724         UELE_LIFETIME
7725         UELE_MODE
7726         UELE_SPEED
7727         UELE_LOOKDIR
7728         UELE_CANMOVETICK
7729         UELE_STR
7730         UELE_AGI
7731         UELE_VIT
7732         UELE_INT
7733         UELE_DEX
7734         UELE_LUK
7735         UELE_DMGIMMUNE
7736         UELE_ATKRANGE
7737         UELE_ATKMIN
7738         UELE_ATKMAX
7739         UELE_MATKMIN
7740         UELE_MATKMAX
7741         UELE_DEF
7742         UELE_MDEF
7743         UELE_HIT
7744         UELE_FLEE
7745         UELE_PDODGE
7746         UELE_CRIT
7747         UELE_RACE
7748         UELE_ELETYPE
7749         UELE_ELELEVEL
7750         UELE_AMOTION
7751         UELE_ADELAY
7752         UELE_DMOTION
7753
7754 -----
7755
7756 Parameter (indexes) for NPCs are:
7757         UNPC_DISPLAY
7758         UNPC_LEVEL
7759         UNPC_HP
7760         UNPC_MAXHP
7761         UNPC_MAPID
7762         UNPC_X
7763         UNPC_Y
7764         UNPC_LOOKDIR
7765         UNPC_STR
7766         UNPC_AGI
7767         UNPC_VIT
7768         UNPC_INT
7769         UNPC_DEX
7770         UNPC_LUK
7771         UNPC_PLUSALLSTAT
7772         UNPC_DMGIMMUNE
7773         UNPC_ATKRANGE
7774         UNPC_ATKMIN
7775         UNPC_ATKMAX
7776         UNPC_MATKMIN
7777         UNPC_MATKMAX
7778         UNPC_DEF
7779         UNPC_MDEF
7780         UNPC_HIT
7781         UNPC_FLEE
7782         UNPC_PDODGE
7783         UNPC_CRIT
7784         UNPC_RACE
7785         UNPC_ELETYPE
7786         UNPC_ELELEVEL
7787         UNPC_AMOTION
7788         UNPC_ADELAY
7789         UNPC_DMOTION
7790
7791 *Notes:
7792                 - *_SIZE: small (0); medium (1); large (2)
7793             - *_MAPID: this refers to the map_data index (from src/map/map.c), not the mapindex_db index (from src/common/mapindex.c)
7794                         -- For 'setunitdata', map name can also be passed in as a valid value instead of map ID
7795                 - *_SPEED: 20 - 1000
7796                 - *_MODE: see doc/mob_db_mode_list.txt
7797                 - *_LOOKDIR: north (0), northwest (1), west (2), etc
7798                 - *_CANMOVETICK: seconds * 1000 the unit will be unable to move
7799                 - *_DMGIMMUNE: unit will be immune to damage (1), or will receive damage (0)
7800                 - *_HUNGER: 0 - 100
7801                 - *_INTIMACY: 0 - 1000
7802                 - *_LIFETIME: seconds * 1000 the unit will be 'alive' for
7803                 - *_AMOTION: see doc/mob_db.txt
7804                 - *_ADELAY: see doc/mob_db.txt
7805                 - *_DMOTION: see doc/mob_db.txt
7806
7807                 - UMOB_AI: none (0); attack (1); marine sphere (2); flora (3); zanzou (4); legion (5); faw (6)
7808                 - UMOB_SCOPTION: see the 'Variables' section at the top of this document
7809                 - UMOB_SLAVECPYMSTRMD: make the slave copy the master's mode (1), or not (0)
7810
7811                 - UNPC_PLUSALLSTAT: same as 'bAllStats'; increases/decreses all stats by given amount
7812
7813 Example:
7814         // Spawn some Porings and save the Game ID.
7815         // - Keep in mind, when the 'monster' script command is used,
7816         // - all the spawned monster GID's are stored in an array
7817         // - called $@mobid[].
7818         monster "prontera",149,190,"Poring",1002,10;
7819         .GID = $@mobid[9]; // Store and modify the 10th Poring spawned to make him stronger!
7820
7821         // Save the strong Poring's mob data in the @por_arr[] variable. (@por_arr[1] being level, @por_arr[13] being class, etc.)
7822         // With this data we can have the NPC display or manipulate it how we want. This does not have to be ran before 'setunitdata'.
7823         getunitdata .GID,@por_arr;
7824
7825         // Set the max HP of the Poring to 1000 (current HP will also get updated to 1000).
7826         setunitdata .GID,UMOB_MAXHP,1000;
7827
7828 ---------------------------------------
7829
7830 *geteleminfo <type>{,<char_id>};
7831
7832 Get info of elemental of attached player or player by char_id.
7833 Other info can be obtained by 'getunitdata' command.
7834
7835 Valid types are:
7836    0: Elemental ID
7837    1: Elemental Game ID
7838
7839 ---------------------------------------
7840 \\
7841 6,1.- End of unit-related commands
7842 \\
7843 ---------------------------------------
7844
7845 *npcskill <skill id>,<skill lvl>,<stat point>,<NPC level>;
7846 *npcskill "<skill name>",<skill lvl>,<stat point>,<NPC level>;
7847
7848 This command causes the attached NPC object to cast a skill on the attached
7849 player. The skill will have no cast time or cooldown. The player must be
7850 within the default skill range or the command will fail silently.
7851
7852 The "stat point" parameter temporarily sets all NPC stats to the given value,
7853 and "NPC level" is the temporary level of the NPC (used in some skills).
7854 Neither value can be greater than the max level defined in config, and will
7855 not work properly if the NPC has a mob sprite.
7856
7857     // Casts Level 10 Heal on the attached player, calculated with
7858     // all stats 99 and base level 60.
7859     npcskill "AL_HEAL",10,99,60;
7860
7861 ---------------------------------------
7862
7863 *day;
7864 *night;
7865
7866 These two commands will switch the entire server between day and night mode
7867 respectively. If your server is set to cycle between day and night by
7868 configuration, it will eventually return to that cycle.
7869
7870 Example:
7871
7872 -       script  DayNight        -1,{
7873 OnClock0600:
7874         day;
7875         end;
7876 OnInit:
7877         // setting correct mode upon server start-up
7878         if (gettime(DT_HOUR)>=6 && gettime(DT_HOUR)<18) end;
7879 OnClock1800:
7880         night;
7881         end;
7882 }
7883
7884 This script allows to emulate the day/night cycle as the server does, but also
7885 allows triggering additional effects upon change, like announces, gifts, etc.
7886 The day/night cycle set by configuration should be disabled when this script is used.
7887
7888 ---------------------------------------
7889
7890 *defpattern <set number>,"<regular expression pattern>","<event label>";
7891 *activatepset <set number>;
7892 *deactivatepset <set number>;
7893 *deletepset <set number>;
7894
7895 This set of commands is only available if the server is compiled with regular
7896 expressions library enabled. Default compilation and most binary distributions
7897 aren't, which is probably bad, since these, while complex to use, are quite
7898 fascinating.
7899
7900 They will make the NPC object listen for text spoken publicly by players and
7901 match it against regular expression patterns, then trigger labels associated
7902 with these regular expression patterns.
7903
7904 Patterns are organized into sets, which are referred to by a set number. You can
7905 have multiple sets patterns, and multiple patterns may be active at once.
7906 Numbers for pattern sets start at 1.
7907
7908 'defpattern' will associate a given regular expression pattern with an event
7909 label. This event will be triggered whenever something a player says is matched
7910 by this regular expression pattern, if the pattern is currently active.
7911
7912 'activatepset' will make the pattern set specified active. An active pattern
7913 will enable triggering labels defined with 'defpattern', which will not happen
7914 by default.
7915 'deactivatepset' will deactivate a specified pattern set. Giving -1 as a pattern
7916 set number in this case will deactivate all pattern sets defined.
7917
7918 'deletepset' will delete a pattern set from memory, so you can create a new
7919 pattern set in its place.
7920
7921 Using regular expressions is high wizardry. But with this high wizardry comes
7922 unparalleled power of text manipulation. For an explanation of what a regular
7923 expression pattern is, see a few web pages:
7924
7925 http://www.regular-expressions.info/
7926 http://www.weitz.de/regex-coach/
7927
7928 For an example of this in use, see doc/sample/npc_test_pcre.txt
7929
7930 With this you could, for example, automatically punish players for asking for
7931 Zeny in public places, or alternatively, automatically give them Zeny instead if
7932 they want it so much.
7933
7934 ---------------------------------------
7935
7936 *pow(<number>,<power>)
7937
7938 Returns the result of the calculation.
7939
7940 Example:
7941         .@i = pow(2,3); // .@i will be 8
7942
7943 ---------------------------------------
7944
7945 *sqrt(<number>)
7946
7947 Returns the square-root of a number.
7948
7949 Example:
7950         .@i = sqrt(25); // .@i will be 5
7951
7952 ---------------------------------------
7953
7954 *distance(<x0>,<y0>,<x1>,<y1>)
7955
7956 Returns distance between 2 points.
7957
7958 Example:
7959         .@i = distance(100,200,101,202);
7960
7961 ---------------------------------------
7962
7963 *min(<number or array>{,<number or array>,...})
7964 *minimum(<number or array>{,<number or array>,...})
7965 *max(<number or array>{,<number or array>,...})
7966 *maximum(<number or array>{,<number or array>,...})
7967
7968 Returns the smallest (or biggest) from the set of given parameters.
7969 These parameters have to be either numbers or number arrays.
7970
7971 Example:
7972         .@minimum = min( 1, -6, -2, 8, 2 ); // .@minimum will be equal to -6
7973         .@maximum = max( 0, 5, 10, 4 ); // .@maximum will be equal to 10
7974         .@level = min( BaseLevel, 70 ); // .@level will be the character's base level, capped to 70
7975
7976         setarray .@testarray, 4, 5, 12, 6, 7, 3, 8, 9, 10;
7977
7978         .@minimum = min( .@testarray ); // .@minimum will be equal to 3
7979         .@maximum = max( .@testarray ); // .@maximum will be equal to 12
7980
7981         .@minimum = min( -6, 1, 2, 3, .@testarray ); // .@minimum will be equal to -6
7982         .@maximum = max( -6, 1, 2, 3, .@testarray ); // .@maximum will be equal to 12
7983
7984 ---------------------------------------
7985
7986 *md5("<string>")
7987
7988 Returns the md5 checksum of a number or string.
7989
7990 Example:
7991         mes md5(12345);
7992         mes md5("12345");       // Will both display 827ccb0eea8a706c4c34a16891f84e7b
7993         mes md5("qwerty");      // Will display d8578edf8458ce06fbc5bb76a58c5ca4
7994
7995 ---------------------------------------
7996
7997 *query_sql("your MySQL query"{, <array variable>{, <array variable>{, ...}}});
7998 *query_logsql("your MySQL query"{, <array variable>{, <array variable>{, ...}}});
7999
8000 Executes an SQL query. A 'select' query can fill array variables with up to 2 billion rows of
8001 values, and will return the number of rows (i.e. array size) or -1 on failure.
8002
8003 Note that 'query_sql' runs on the main database while 'query_logsql' runs on the log database.
8004
8005 Example:
8006         .@nb = query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", .@name$, .@fame);
8007         mes "Hall Of Fame: TOP5";
8008         mes "1." + .@name$[0] + "(" + .@fame[0] + ")"; // largest fame value.
8009         mes "2." + .@name$[1] + "(" + .@fame[1] + ")";
8010         mes "3." + .@name$[2] + "(" + .@fame[2] + ")";
8011         mes "4." + .@name$[3] + "(" + .@fame[3] + ")";
8012         mes "5." + .@name$[4] + "(" + .@fame[4] + ")";
8013
8014 ---------------------------------------
8015
8016 *escape_sql(<value>)
8017
8018 Converts the value to a string and escapes special characters so that it is safe to
8019 use in query_sql(). Returns the escaped form of the given value.
8020
8021 Example:
8022         .@name$ = "John's Laptop";
8023         .@esc_str$ = escape_sql(.@name$); // Escaped string: John\'s Laptop
8024
8025 ---------------------------------------
8026
8027 *setiteminfo(<item id>,<type>,<value>)
8028
8029 This function will set some value of an item.
8030 Returns the new value on success, or -1 on fail (item_id not found or invalid type).
8031
8032 Valid types are:
8033         0 - Buy Price; 1 - Sell Price; 2 - Item Type;
8034         3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..
8035                 if = 0, then monsters don't drop it at all (rare or a quest item)
8036                 if = 10000, then this item is sold in NPC shops only
8037         4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;
8038         10 - slot; 11 - look; 12 - elv; 13 - wlv; 14 - view id
8039
8040 Example:
8041         setiteminfo 7049,6,9990; // Stone now weighs 999.0
8042
8043 ---------------------------------------
8044
8045 *setitemscript(<item id>,<"{ new item script }">{,<type>});
8046
8047 Set a new script bonus to the Item. Very useful for game events.
8048 You can remove an item's itemscript by leaving the itemscript argument empty.
8049 Returns 1 on success, or 0 on fail (item_id not found or new item script is invalid).
8050 Type can optionally be used indicates which script to set (default is 0):
8051  0 - Script
8052  1 - OnEquip_Script
8053  2 - OnUnequip_Script
8054
8055 Example:
8056         setitemscript 2637,"{ if (isequipped(2236) == 0)end; if (getskilllv(26)){skill 40,1;}else{skill 26,1+isequipped(2636);} }";
8057         setitemscript 2637,"";
8058
8059 ---------------------------------------
8060
8061 *atoi("<string>")
8062 *axtoi("<string>")
8063 *strtol("<string>", base)
8064
8065 These commands are used to convert strings to numbers. 'atoi' will interpret
8066 given string as a decimal number (base 10), while 'axtoi' interprets strings as
8067 hexadecimal numbers (base 16). 'strtol' lets the user specify a base (valid range
8068 is between 2 and 36 inclusive, or the special value0, which means auto-detection).
8069
8070 The 'atoi' and 'strtol' functions conform to the C functions with the same names,
8071 and 'axtoi' is the same as strtol, with a base of 16. Results are clamped to signed
8072 32 bit int range (INT_MIN ~ INT_MAX).
8073
8074 Examples:
8075
8076         .@var = atoi("11");        // Sets .@var to 11
8077         .@var = axtoi("FF");       // Sets .@var to 255
8078         mes axtoi("11");           // Displays 17 (1 = 1, 10 = 16)
8079         .@var = strtol("11", 10);  // Sets .@var to 11 (11 base 10)
8080         .@var = strtol("11", 16);  // Sets .@var to 17 (11 base 16)
8081         .@var = strtol("11", 0);   // Sets .@var to 11 (11 base 10, auto-detected)
8082         .@var = strtol("0x11", 0); // Sets .@var to 17 (11 base 16, auto-detected because of the "0x" prefix)
8083         .@var = strtol("011", 0);  // Sets .@var to 9 (11 base 8, auto-detected because of the "0" prefix)
8084         .@var = strtol("11", 2);   // Sets .@var to 3 (binary 11)
8085
8086 ---------------------------------------
8087
8088 *compare("<string>","<substring>")
8089
8090 This command returns 1 or 0 when the substring is in the main string (1) or not (0).
8091 This command is not case sensitive.
8092
8093 Examples:
8094         //dothis; will be executed ('Bloody Murderer' contains 'Blood').
8095         if (compare("Bloody Murderer","Blood"))
8096                 dothis;
8097
8098         //dothat; will not be executed ('Blood butterfly' does not contain 'Bloody').
8099         if (compare("Blood Butterfly","Bloody"))
8100                 dothat;
8101
8102 ---------------------------------------
8103
8104 *strcmp("<string>","<string>")
8105
8106 This command compares two strings are returns a value:
8107    1: string 1 > string 2
8108    0: strings are equal
8109   -1: string 1 < string 2
8110
8111 ---------------------------------------
8112
8113 *getstrlen("<string>")
8114
8115 This function will return the length of the string given as an argument. It is
8116 useful to check if anything input by the player exceeds name length limits and
8117 other length limits and asking them to try to input something else.
8118
8119 ---------------------------------------
8120
8121 *charisalpha("<string>",<position>)
8122
8123 This function will return 1 if the character number Position in the given string
8124 is a letter, 0 if it isn't a letter but a digit or a space.
8125 The first letter is position 0.
8126
8127 ---------------------------------------
8128
8129 *charat(<string>,<index>)
8130
8131 Returns char at specified index. If index is out of range, returns empty string.
8132 The first letter of a string is index 0.
8133
8134 Example:
8135         charat("This is a string", 10); //returns "s"
8136
8137 ---------------------------------------
8138
8139 *setchar(<string>,<char>,<index>)
8140
8141 Returns the original string with the char at the specified index set to the
8142 specified char. If index out of range, the original string will be returned.
8143 Only the 1st char in the <char> parameter will be used.
8144
8145 Example:
8146         setchar("Cat", "B", 0); //returns "Bat"
8147
8148 ---------------------------------------
8149
8150 *insertchar(<string>,<char>,<index>)
8151
8152 Returns the original string with the specified char inserted at the specified
8153 index. If index is out of range, the char will be inserted on the end of the
8154 string that it is closest. Only the 1st char in the <char> parameter will be used.
8155
8156 Example:
8157         insertchar("laughter", "s", 0); //returns "slaughter"
8158
8159 ---------------------------------------
8160
8161 *delchar(<string>,<index>)
8162
8163 Returns the original string with the char at the specified index removed.
8164 If index is out of range, original string will be returned.
8165
8166 Example:
8167         delchar("Diet", 3); //returns "Die"
8168
8169 ---------------------------------------
8170
8171 *strtoupper(<string>)
8172 *strtolower(<string>)
8173
8174 Returns the specified string in its uppercase/lowercase form.
8175 All non-alpha characters will be preserved.
8176
8177 Example:
8178         strtoupper("The duck is blue!!"); //returns "THE DUCK IS BLUE!!"
8179
8180 ---------------------------------------
8181
8182 *charisupper(<string>,<index>)
8183 *charislower(<string>,<index>)
8184
8185 Returns 1 if character at specified index of specified string is
8186 uppercase/lowercase. Otherwise, 0. Characters not of the alphabet will return 0.
8187
8188 Example:
8189         charisupper("rAthena", 1); //returns 1
8190
8191 ---------------------------------------
8192
8193 *substr(<string>,<start_index>,<end_index>)
8194
8195 Returns the sub-string of the specified string inclusively between the set
8196 indexes. If indexes are out of range, or the start index is after the end
8197 index, an empty string will be returned.
8198
8199 Example:
8200         substr("foobar", 3, 5); //returns "bar"
8201
8202 ---------------------------------------
8203
8204 *explode(<dest_array>,<string>,<delimiter>)
8205
8206 Breaks a string up into substrings based on the specified delimiter. Substrings
8207 will be stored within the specified string array. Only the 1st char of the
8208 delimiter parameter will be used. If an empty string is passed as a delimiter,
8209 the string will be placed in the array in its original form.
8210
8211 Example:
8212         explode(.@my_array$, "Explode:Test:1965:red:PIE", ":");
8213         //.@my_array$ contents will be...
8214         //.@my_array$[0]: "Explode"
8215         //.@my_array$[1]: "Test"
8216         //.@my_array$[2]: "1965"
8217         //.@my_array$[3]: "red"
8218         //.@my_array$[4]: "PIE"
8219
8220 ---------------------------------------
8221
8222 *implode(<string_array>{,<glue>})
8223
8224 Combines all substrings within the specified string array into a single string.
8225 If the glue parameter is specified, it will be inserted inbetween each substring.
8226
8227 Example:
8228         setarray .@my_array$[0], "This", "is", "a", "test";
8229         implode(.@my_array$, " "); //returns "This is a test"
8230
8231 ---------------------------------------
8232
8233 *sprintf(<format>[,param[,param[,...]]])
8234
8235 C style sprintf. The resulting string is returned same as in PHP. All C format
8236 specifiers are supported except %n. More info: sprintf @ www.cplusplus.com.
8237 The number of params is only limited by rA's script engine.
8238
8239 Example:
8240         .@format$ = "The %s contains %d monkeys";
8241         dispbottom(sprintf(.@format$, "zoo", 5));        //prints "The zoo contains 5 monkeys"
8242         dispbottom(sprintf(.@format$, "barrel", 82));    //prints "The barrel contains 82 monkeys"
8243
8244 ---------------------------------------
8245
8246 *sscanf(<string>,<format>[,param[,param[,...]]])
8247
8248 C style sscanf. All C format specifiers are supported.
8249 More info: sscanf @ www.cplusplus.com. The number of params is only limited
8250 by rA's script engine.
8251
8252 Example:
8253         sscanf("This is a test: 42 foobar", "This is a test: %d %s", .@num, .@str$);
8254         dispbottom(.@num + " " + .@str$); //prints "42 foobar"
8255
8256 ---------------------------------------
8257
8258 *strpos(<haystack>,<needle>{,<offset>})
8259
8260 PHP style strpos. Finds a substring (needle) within a string (haystack).
8261 The offset parameter indicates the index of the string to start searching.
8262 Returns index of substring on successful search, else -1.
8263 Comparison is case sensitive.
8264
8265 Example:
8266         strpos("foobar", "bar", 0); //returns 3
8267         strpos("foobarfoo", "foo", 0); //returns 0
8268         strpos("foobarfoo", "foo", 1); //returns 6
8269
8270 ---------------------------------------
8271
8272 *replacestr(<input>, <search>, <replace>{, <usecase>{, <count>}})
8273
8274 Replaces all instances of a search string in the input with the specified
8275 replacement string. By default is case sensitive unless <usecase> is set
8276 to 0. If specified it will only replace as many instances as specified
8277 in the count parameter.
8278
8279 Example:
8280         replacestr("testing tester", "test", "dash"); //returns "dashing dasher"
8281         replacestr("Donkey", "don", "mon", 0); //returns "monkey"
8282         replacestr("test test test test test", "test", "yay", 0, 3); //returns "yay yay yay test test"
8283
8284 ---------------------------------------
8285
8286 *countstr(<input>, <search>{, <usecase>})
8287
8288 Counts all instances of a search string in the input. By default is case
8289 sensitive unless <usecase> is set to 0.
8290
8291 Example:
8292         countstr("test test test Test", "test"); //returns 3
8293         countstr("cake Cake", "Cake", 0); //returns 2
8294
8295 ---------------------------------------
8296
8297 *preg_match(<regular expression pattern>,<string>{,<offset>})
8298
8299 Searches a string for a match to the regular expression provided. The
8300 offset parameter indicates the index of the string to start searching.
8301 Returns offsets to captured substrings, or 0 if no match is found.
8302
8303 This command is only available if the server is compiled with the regular
8304 expressions library enabled.
8305
8306 ---------------------------------------
8307
8308 *setfont <font>;
8309
8310 This command sets the current RO client interface font to one of the
8311 fonts stored in data\*.eot by using an ID of the font. When the ID
8312 of the currently used font is used, default interface font is used
8313 again.
8314
8315         0 - Default
8316         1 - RixLoveangel
8317         2 - RixSquirrel
8318         3 - NHCgogo
8319         4 - RixDiary
8320         5 - RixMiniHeart
8321         6 - RixFreshman
8322         7 - RixKid
8323         8 - RixMagic
8324         9 - RixJJangu
8325
8326 ---------------------------------------
8327
8328 *showdigit <value>{,<type>};
8329
8330 Displays given numeric 'value' in large digital clock font on top of
8331 the screen. The optional parameter 'type' specifies visual aspects
8332 of the "clock" and can be one of the following values:
8333
8334         0 - Displays the value for 5 seconds (default).
8335         1 - Incremental counter (1 tick/second).
8336         2 - Decremental counter (1 tick/second). Does not stop at zero,
8337                 but overflows.
8338         3 - Decremental counter (2 ticks/second). Two digits only, stops
8339                 at zero.
8340
8341 Except for type 3 the value is interpreted as seconds and formatted
8342 as time in days, hours, minutes and seconds. Note, that the official
8343 script command does not have the optional parameter.
8344
8345         // displays 23:59:59 for 5 seconds
8346         showdigit 86399;
8347
8348         // counter that starts at 60 and runs for 30 seconds
8349         showdigit 60,3;
8350
8351 ---------------------------------------
8352
8353 *setcell "<map name>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>;
8354
8355 Each map cell has several 'flags' that specify the properties of that cell.
8356 These include terrain properties (walkability, shootability, presence of water),
8357 skills (basilica, land protector, ...) and other (NPC nearby, no vending, ...).
8358 Each of these can be 'on' or 'off'. Together they define a cell's behavior.
8359
8360 This command lets you alter these flags for all map cells in the specified
8361 (x1,y1)-(x2,y2) rectangle. The 'flag' can be 0 or 1 (0:clear flag, 1:set flag).
8362 The 'type' defines which flag to modify. Possible options see 'src/map/script_constants.h'.
8363
8364 Example:
8365
8366         setcell "arena",0,0,300,300,cell_basilica,1;
8367         setcell "arena",140,140,160,160,cell_basilica,0;
8368         setcell "arena",135,135,165,165,cell_walkable,0;
8369         setcell "arena",140,140,160,160,cell_walkable,1;
8370
8371 This will add a makeshift ring into the center of the map. The ring will be
8372 surrounded by a 5-cell wide 'gap' to prevent interference from outside, and
8373 the rest of the map will be marked as 'basilica', preventing observers from
8374 casting any offensive skills or fighting among themselves. Note that the wall
8375 will not be shown nor known client-side, which may cause movement problems.
8376
8377 Another example:
8378
8379 OnBarricadeDeploy:
8380         setcell "schg_cas05",114,51,125,51,cell_walkable,0;
8381         end;
8382 OnBarricadeBreak:
8383         setcell "schg_cas05",114,51,125,51,cell_walkable,1;
8384         end;
8385
8386 This could be a part of the WoE:SE script, where attackers are not allowed
8387 to proceed until all barricades are destroyed. This script would place and
8388 remove a nonwalkable row of cells after the barricade mobs.
8389
8390 ---------------------------------------
8391
8392 *checkcell ("<map name>",<x>,<y>,<type>);
8393
8394 This command will return 1 or 0, depending on whether the specified cell has
8395 the 'type' flag set or not. There are various types to check, all mimicking
8396 the server's cell_chk enumeration. The types can be found in 'src/map/script_constants.h'.
8397
8398 The meaning of the individual types can be confusing, so here's an overview:
8399   - cell_chkwall/water/cliff
8400     these check directly for the 'terrain component' of the specified cell
8401   - cell_chkpass/reach/nopass/noreach
8402     passable = not wall & not cliff, reachable = passable wrt. no-stacking mod
8403   - cell_chknpc/basilica/landprotector/novending/nochat
8404     these check for specific dynamic flags (their name indicates what they do)
8405
8406 Example:
8407         mes "Pick a destination map.";
8408         input .@map$;
8409         mes "Alright, now give me the coordinates.";
8410         input .@x;
8411         input .@y;
8412         if ( !checkcell(.@map$,.@x,.@y,cell_chkpass) ) {
8413                 mes "Can't warp you there, sorry!";
8414                 close;
8415         } else {
8416                 mes "Ok, get ready...";
8417                 close2;
8418                 warp .@map$, .@x, .@y;
8419                 end;
8420         }
8421
8422 ---------------------------------------
8423
8424 *getfreecell "<map name>",<rX>,<rY>{,<x>,<y>,<rangeX>,<rangeY>,<flag>};
8425
8426 Finds a free cell on the given map and stores the reference to the found cell
8427 in <rX> and <rY>. Passing <x> and <y> with <rangeX> and <rangeY> allows for
8428 searching within a specified area on the given map. The <flag> is a bitmask
8429 and has the following possible values:
8430  - 1 = Random cell on the map or from <x>,<y> range. (default)
8431  - 2 = The target should be able to walk to the target tile.
8432  - 4 = There shouldn't be any players around the target tile (use the no_spawn_on_player setting).
8433
8434 Examples:
8435         getfreecell("prontera",.@x,.@y); // Find a random empty cell in Prontera and store it within .@x and .@y
8436         getfreecell("prontera",.@x,.@y,150,150,5,5); // Find a random empty cell on 150,150 (with a range of 5x5) in Prontera and store it within .@x and .@y
8437
8438 ---------------------------------------
8439
8440 *setwall "<map name>",<x>,<y>,<size>,<dir>,<shootable>,"<name>";
8441 *delwall "<name>";
8442
8443 Creates an invisible wall, an array of "setcell" starting from x,y and doing a
8444 line of the given size in the given direction. The difference with setcell is
8445 this one update client part too to avoid the glitch problem. Directions are the
8446 same as NPC sprite facing directions: 0=north, 1=northwest, 2=west, etc.
8447
8448 ---------------------------------------
8449
8450 *readbook <book id>,<page>;
8451
8452 This command will open a book item at the specified page.
8453
8454 ---------------------------------------
8455
8456 ========================
8457 |7.- Instance commands.|
8458 ========================
8459 ---------------------------------------
8460
8461 *instance_create("<instance name>"{,<instance mode>{,<owner id>}});
8462
8463 Creates an instance for the <owner id> of <mode>. The instance name, along with
8464 all other instance data, is read from 'db/(pre-)re/instance_db.txt'. Upon success,
8465 the command generates a unique instance ID, duplicates all listed maps and NPCs,
8466 sets the alive time, and triggers the "OnInstanceInit" label in all NPCs inside
8467 the instance.
8468
8469 Instance Mode options:
8470  IM_NONE: Attached to no one.
8471  IM_CHAR: Attached to a single character.
8472  IM_PARTY: Attached to a party (default instance mode).
8473  IM_GUILD: Attached to a guild.
8474  IM_CLAN: Attached to a clan.
8475
8476 The command returns the instance ID upon success, and these values upon failure:
8477  -1: Invalid type.
8478  -2: Character/Party/Guild/Clan not found.
8479  -3: Instance already exists.
8480  -4: No free instances (MAX_INSTANCE exceeded).
8481
8482 ---------------------------------------
8483
8484 *instance_destroy {<instance id>};
8485
8486 Destroys instance with the ID <instance id>. If no ID is specified, the instance
8487 the script is attached to is used. If the script is not attached to an instance,
8488 the instance of the currently attached player is used (if it is a character, party,
8489 guild or clan mode). If it is not owned by anyone, no player needs to be attached. If
8490 that fails, the script will come to a halt. This will also trigger the "OnInstanceDestroy"
8491 label in all NPCs inside the instance.
8492
8493 ---------------------------------------
8494
8495 *instance_enter("<instance name>",{<x>,<y>,<char_id>,<instance id>});
8496
8497 Warps player to the specified instance after the script terminates. The map and
8498 coordinates are located in 'db/(pre-)re/instance_db.txt'.
8499
8500 The command returns IE_OK upon success, and these values upon failure:
8501  IE_NOMEMBER:   Party/Guild/Clan not found (for party/guild/clan modes).
8502  IE_NOINSTANCE: Character/Party/Guild/Clan does not have an instance.
8503  IE_OTHER:              Other errors (invalid instance name, instance doesn't match with character/party/guild/clan).
8504
8505 Put -1 for x and y if want to warp player with default entrance coordinates.
8506
8507 ---------------------------------------
8508
8509 *instance_npcname("<npc name>"{,<instance id>})
8510
8511 Returns the unique name of the instanced script. If no ID is specified,
8512 the instance the script is attached to is used. If the script is not attached to
8513 an instance, the instance of the currently attached NPC, player, party, guild
8514 or clan is used. If that fails, the script will come to a halt.
8515
8516 ---------------------------------------
8517
8518 *instance_mapname("<map name>"{,<instance id>})
8519
8520 Returns the unique name of the instanced map. If no instance ID is specified,
8521 the instance the script is attached to is used. If the script is not attached to
8522 an instance, the instance of the currently attached player is used (if it is a
8523 character, party, guild or clan mode). If it is not owned by anyone, no player needs
8524 to be attached. If that fails, the command returns an empty string instead.
8525
8526 ---------------------------------------
8527
8528 *instance_id()
8529
8530 Returns the unique instance id of the attached script. If the script is not
8531 attached to an instance, the instance of the currently attached player is
8532 used (if it is a character, party, guild or clan mode). If it is not owned by anyone, no
8533 player needs to be attached. If that fails, the function will return 0.
8534
8535 ---------------------------------------
8536
8537 *instance_warpall "<map name>",<x>,<y>{,<instance id>};
8538
8539 Warps all players in the instance <instance id> to <map name> at given
8540 coordinates. If no ID is specified, the instance the script is attached to
8541 is used. If the script is not attached to an instance, the instance of the
8542 currently attached player is used (if it is a character, party, guild or clan
8543 mode). If it is not owned by anyone, no player needs to be attached. If that
8544 fails, the script will come to a halt.
8545
8546 ---------------------------------------
8547
8548 *instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
8549
8550 Broadcasts a message to all players in the instance <instance id> currently
8551 residing on an instance map. If 0 is specified for <instance id>, the instance
8552 the script is attached to is used. If the script is not attached to an instance,
8553 the instance of the currently attached player is used (if it is a character,
8554 party, guild or clan mode). If it is not owned by anyone, no player needs to be attached.
8555
8556 For details on the other parameters, see 'announce'.
8557
8558 ---------------------------------------
8559
8560 *instance_check_party(<party id>{,<amount>{,<min>{,<max>}}})
8561
8562 This function checks if a party meets certain requirements, returning 1 if all
8563 conditions are met and 0 otherwise. It will only check online characters.
8564
8565 amount - number of online party members (default is 1).
8566 min    - minimum level of all characters in the party (default is 1).
8567 max    - maximum level of all characters in the party (default is max level in conf).
8568
8569 Example:
8570
8571 if (instance_check_party(getcharid(1),2,2,149)) {
8572         mes "Your party meets the Memorial Dungeon requirements.",
8573         mes "All online members are between levels 1-150 and at least two are online.";
8574         close;
8575 } else {
8576         mes "Sorry, your party does not meet requirements.";
8577         close;
8578 }
8579
8580 ---------------------------------------
8581
8582 *instance_check_guild(<guild id>{,<amount>{,<min>{,<max>}}})
8583
8584 This function checks if a guild meets certain requirements, returning 1 if all
8585 conditions are met and 0 otherwise. It will only check online characters.
8586
8587 amount - number of online guild members (default is 1).
8588 min    - minimum level of all characters in the guild (default is 1).
8589 max    - maximum level of all characters in the guild (default is max level in conf).
8590
8591 Example:
8592
8593 if (instance_check_guild(getcharid(2),2,2,149)) {
8594         mes "Your guild meets the Memorial Dungeon requirements.",
8595         mes "All online members are between levels 1-150 and at least two are online.";
8596         close;
8597 } else {
8598         mes "Sorry, your guild does not meet requirements.";
8599         close;
8600 }
8601
8602 ---------------------------------------
8603
8604 *instance_check_clan(<clan id>{,<amount>{,<min>{,<max>}}})
8605
8606 This function checks if a clan meets certain requirements, returning 1 if all
8607 conditions are met and 0 otherwise. It will only check online characters.
8608
8609 amount - number of online clan members (default is 1).
8610 min    - minimum level of all characters in the clan (default is 1).
8611 max    - maximum level of all characters in the clan (default is max level in conf).
8612
8613 Example:
8614
8615 if (instance_check_clan(getcharid(5),2,2,149)) {
8616         mes "Your clan meets the Memorial Dungeon requirements.",
8617         mes "All online members are between levels 1-150 and at least two are online.";
8618         close;
8619 } else {
8620         mes "Sorry, your clan does not meet requirements.";
8621         close;
8622 }
8623
8624 ---------------------------------------
8625
8626 *instance_info("<instance name>",<info type>{,<instance_db map index>});
8627
8628 Returns the specified <info type> of the given <instance name> from the instance database.
8629 If the <instance name> is unknown or an invalid <info type> is supplied -1 will be returned.
8630
8631 Valid info types:
8632  IIT_ID: Instance database ID as integer.
8633  IIT_TIME_LIMIT: Instance database total life time as integer.
8634  IIT_IDLE_TIMEOUT: Instance database timeout time as integer.
8635  IIT_ENTER_MAP: Instance database enter map as string.
8636  IIT_ENTER_X: Instance database enter X location as integer.
8637  IIT_ENTER_Y: Instance database enter Y location as integer.
8638  IIT_MAPCOUNT: Instance database total maps as integer.
8639  IIT_MAP: Instance database map name from the given <instance_db map index> as string.
8640           If the index is invalid an empty string will be returned.
8641
8642 Example:
8643
8644 .@name$ = "Endless Tower";
8645 mes .@name$ + " will be destroyed if no one is in the instance for " + instance_info(.@name$,IIT_IDLETIMEOUT) + " seconds.";
8646 // Endless Tower will be destroyed if no one is in the instance for 300 seconds.
8647
8648 ---------------------------------------
8649
8650 =========================
8651 |8.- Quest Log commands.|
8652 =========================
8653 ---------------------------------------
8654
8655 *questinfo <Quest ID>,<Icon>{,<Map Mark Color>{,<Job Class>}};
8656
8657 This is esentially a combination of checkquest and showevent. Use this only
8658 in an OnInit label. For the Quest ID, specify the quest ID that you want
8659 checked if it has been started yet.
8660
8661 For Icon, use one of the following:
8662
8663 No Icon                 : QTYPE_NONE
8664 ! Quest Icon    : QTYPE_QUEST
8665 ? Quest Icon    : QTYPE_QUEST2
8666 ! Job Icon              : QTYPE_JOB
8667 ? Job Icon              : QTYPE_JOB2
8668 ! Event Icon    : QTYPE_EVENT
8669 ? Event Icon    : QTYPE_EVENT2
8670 Warg                    : QTYPE_WARG
8671 Warg Face               : QTYPE_WARG2 (Only for packetver >= 20120410)
8672
8673 Map Mark Color, when used, creates a mark in the user's mini map on the position of the NPC,
8674 the available color values are:
8675
8676 0 - No Marker (default)
8677 1 - Yellow Marker
8678 2 - Green Marker
8679 3 - Purple Marker
8680
8681 When a user shows up on a map, each NPC is checked for questinfo that has been set.
8682 If questinfo is present, it will check if the quest has been started, if it has not, the bubble will appear.
8683
8684 Optionally, you can also specify a Job Class if the quest bubble should only appear for a certain class.
8685
8686 Example
8687 izlude,100,100,4        script  Test    844,{
8688         mes "[Test]";
8689         mes "Hello World.";
8690         close;
8691
8692         OnInit:
8693                 questinfo 1001, QTYPE_QUEST, 0, Job_Novice;
8694                 end;
8695 }
8696
8697 ---------------------------------------
8698
8699 *setquestinfo_level <quest_id>,<min_level>,<max_level>;
8700
8701 Add level range criteria for quest info with quest id 'quest_id'.
8702
8703 This command must be used after 'questinfo'.
8704
8705 ---------------------------------------
8706
8707 *setquestinfo_req <quest_id>,<req_quest_id>,<state>{,<req_quest_id>,<state>,...};
8708
8709 Add 'req_quest_id' as requirement for quest info with quest id 'quest_id'.
8710
8711 Value os 'state' are:
8712     0: Player doesn't started 'req_quest_id'.
8713     1: Player has 'req_quest_id' (state is either "inactive" or "active").
8714     2: Player has 'req_quest_id' completed
8715
8716 This command must be used after 'questinfo'.
8717
8718 ---------------------------------------
8719
8720 *setquestinfo_job <quest_id>,<job_id>{,<job_id>...};
8721
8722 Add job criteria for quest info with quest id 'quest_id'.
8723 The job criteria may more than one job_id.
8724
8725 This command must be used after 'questinfo'.
8726
8727 ---------------------------------------
8728
8729 *setquest <ID>{,<char_id>};
8730
8731 Place quest of <ID> in the users quest log, the state of which is "active".
8732
8733 If *questinfo is set, and the same ID is specified here, the icon will be cleared when the quest is set.
8734
8735 ---------------------------------------
8736
8737 *completequest <ID>{,<char_id>};
8738
8739 Change the state for the given quest <ID> to "complete" and remove from the users quest log.
8740
8741 ---------------------------------------
8742
8743 *erasequest <ID>{,<char_id>};
8744
8745 Remove the quest of the given <ID> from the user's quest log.
8746
8747 ---------------------------------------
8748
8749 *changequest <ID>,<ID2>{,<char_id>};
8750
8751 Remove quest of the given <ID> from the user's quest log.
8752 Add quest of the <ID2> to the the quest log, and the state is "active".
8753
8754 ---------------------------------------
8755
8756 *checkquest(<ID>{,PLAYTIME|HUNTING{,<char_id>}})
8757
8758 If no additional argument supplied, return the state of the quest:
8759         -1 = Quest not started (not in quest log)
8760         0  = Quest has been given, but the state is "inactive"
8761         1  = Quest has been given, and the state is "active"
8762         2  = Quest completed
8763
8764 If parameter "PLAYTIME" is supplied:
8765         -1 = Quest not started (not in quest log)
8766         0  = the time limit has not yet been reached
8767         1  = the time limit has not been reached but the quest is marked as complete
8768         2  = the time limit has been reached
8769
8770 If parameter "HUNTING" is supplied:
8771         -1 = Quest not started (not in quest log)
8772         0  = you haven't killed all of the target monsters and the time limit has not been reached.
8773         1  = you haven't killed all of the target monsters but the time limit has been reached.
8774         2  = you've killed all of the target monsters
8775
8776 ---------------------------------------
8777
8778 *isbegin_quest(<ID>{,<char_id>})
8779
8780 Return the state of the quest:
8781         0  = Quest not started (not in quest log)
8782         1  = Quest has been given (state is either "inactive" or "active")
8783         2  = Quest completed
8784
8785 ---------------------------------------
8786
8787 *showevent <icon>{,<mark color>{,<char_id>}}
8788
8789 Show an emotion on top of a NPC, and optionally,
8790 a colored mark in the mini-map like "viewpoint".
8791 This is used to indicate that a NPC has a quest or an event to
8792 a certain player.
8793
8794 Available Icons:
8795
8796 Remove Icon             : QTYPE_NONE
8797 ! Quest Icon    : QTYPE_QUEST
8798 ? Quest Icon    : QTYPE_QUEST2
8799 ! Job Icon              : QTYPE_JOB
8800 ? Job Icon              : QTYPE_JOB2
8801 ! Event Icon    : QTYPE_EVENT
8802 ? Event Icon    : QTYPE_EVENT2
8803 Warg                    : QTYPE_WARG
8804 Warg Face               : QTYPE_WARG2 (Only for packetver >= 20120410)
8805
8806 Mark Color:
8807 0 - No Mark
8808 1 - Yellow Mark
8809 2 - Green Mark
8810 3 - Purple Mark
8811
8812 ---------------------------------------
8813
8814 ============================
8815 |9.- Battleground commands.|
8816 ============================
8817 ---------------------------------------
8818
8819 *waitingroom2bg_single(<battle group>,{"<map name>",<x>,<y>{,"<npc name>"}});
8820
8821 Adds the first waiting player from the chat room of the given NPC to an existing battleground group.
8822 The player will also be warped to the default spawn point of the battle group or to the specified coordinates <x> and <y> on the given <map>.
8823
8824 ---------------------------------------
8825
8826 *waitingroom2bg("<map name>",<x>,<y>,{"<On Quit Event>","<On Death Event>"{,"<NPC Name>"}});
8827
8828 <map name>,<x>,<y> refer to where the "respawn" base is, where the player group will respawn when they die.
8829 <On Quit Event> refers to an NPC label that attaches to the character and is run when they relog. (Optional)
8830 <On Death Event> refers to an NPC label that attaches to the character and is run when they die. (Optional)
8831
8832 Unlike the prior command, the latter will attach a GROUP in a waiting room to the battleground, and
8833 sets the array $@arenamembers[0] where 0 holds the IDs of the first group, and 1 holds the IDs of the second.
8834
8835 If the optional NPC Name parameter is left out, the waiting room of the current NPC is used.
8836
8837 Example:
8838         // Battle Group will be referred to as $@KvM01BG_id1, and when they die, respawn at bat_c01,52,129.
8839         set $@KvM01BG_id1, waitingroom2bg("bat_c01",52,129,"KvM01_BG::OnGuillaumeQuit","KvM01_BG::OnGuillaumeDie");
8840         end;
8841
8842 ---------------------------------------
8843
8844 *bg_create("<map name>",<x>,<y>{,"<On Quit Event>","<On Death Event>"});
8845
8846 Creates an instance of battleground battle group that can be used with other battleground commands.
8847
8848 <map name>,<x>,<y> refer to where the "respawn" base is, where the player group will respawn when they die.
8849 <On Quit Event> refers to an NPC label that attaches to the character and is run when they relog. (Optional)
8850 <On Death Event> refers to an NPC label that attaches to the character and is run when they die. (Optional)
8851
8852 Returns battle group ID on success. Returns 0 on failure.
8853
8854 ---------------------------------------
8855
8856 *bg_join(<battle group>,{"<map name>",{<x>,<y>{,<char id>}});
8857
8858 Adds an attached player or <char id> if specified to an existing battleground group. The player will also be warped to the default spawn point of the battle group or to the specified coordinates <x> and <y> on the given <map>.
8859
8860 Returns true on success. Returns false on failure.
8861
8862 ---------------------------------------
8863
8864 *bg_team_setxy <Battle Group ID>,<x>,<y>;
8865
8866 Updates the respawn point of the given Battle Group to x,y on the same map. <Battle Group ID> can be retrieved using getcharid(4).
8867
8868 Example:
8869         bg_team_setxy getcharid(4),56,212;
8870         mapannounce "bat_a01", "Group [1] has taken the work shop, and will now respawn there.",bc_map,"0xFFCE00";
8871         end;
8872
8873 ---------------------------------------
8874
8875 *bg_warp <Battle Group>,"<map name>",<x>,<y>;
8876
8877 Similar to the 'warp' command.
8878 Places all members of <Battle Group> at the specified map and coordinates.
8879
8880 Example:
8881         //place the battle group one for Tierra Gorge at starting position.
8882         bg_warp $@TierraBG1_id1,"bat_a01",352,342;
8883         end;
8884
8885 ---------------------------------------
8886
8887 *bg_monster <Battle Group>,"<map name>",<x>,<y>,"<name to show>",<mob id>,"<event label>";
8888 *bg_monster(<Battle Group>,"<map name>",<x>,<y>,"<name to show>",<mob id>,"<event label>");
8889
8890 Similar to the 'monster' command.
8891 Spawns a monster with allegiance to the given Battle Group.
8892 Does not allow for the summoning of multiple monsters.
8893 Monsters are similar to those in War of Emperium, in that the specified Battle Group is considered friendly.
8894
8895 Example:
8896         // It can be used in two different ways.
8897         bg_monster $@TierraBG1_id2,"bat_a01",167,50,"Food Depot",1910,"Feed Depot#1::OnMyMobDead";
8898         end;
8899
8900         // Alternatively, you can set an ID for the monster using "set".
8901         // This becomes useful when used with the command below.
8902         set $@Guardian_3, bg_monster($@TierraBG1_id2,"bat_a01",268,204,"Guardian",1949,"NPCNAME::OnMyMobDead");
8903         end;
8904
8905 ---------------------------------------
8906
8907 *bg_monster_set_team <GID>,<Battle Group>;
8908
8909 This command will change the allegiance if a monster in a battle ground.
8910 GID can be set when spawning the monster via the 'bg_monster' command.
8911
8912 Example:
8913
8914         end;
8915
8916 OnEnable:
8917         mapannounce "A guardian has been summoned for Battle Group 2!",bc_map,"0xFFCE00";
8918         set $@Guardian, bg_monster($@BG_2,"bat_a01",268,204,"Guardian",1949,"NPCNAME::OnMyMobDead");
8919         initnpctimer;
8920         end;
8921
8922 OnTimer1000:
8923         stopnpctimer;
8924         mapannounce "Erm, sorry about that! This monster was meant for Battle Group 1.",bc_map,"0xFFCE00";
8925         bg_monster_set_team $@Guardian, $@BG_1;
8926         end;
8927
8928 ---------------------------------------
8929
8930 *bg_leave {<char_id>};
8931
8932 Removes attached player from their Battle Group.
8933
8934 ---------------------------------------
8935
8936 *bg_destroy <Batte Group>;
8937
8938 Destroys the Battle Group created for that battle ground.
8939
8940 ---------------------------------------
8941
8942 *areapercentheal "<map name>",<x1>,<y1>,<x2>,<y2>,<hp>,<sp>;
8943
8944 Restores a percentage of the maximum HP/SP of players within a defined area.
8945 This is primarily used in battleground scripts, but is not limited to them.
8946
8947 Example:
8948         areapercentheal "bat_a01",52,208,61,217,100,100;
8949         end;
8950
8951 ---------------------------------------
8952
8953 *bg_get_data(<Battle Group>,<type>);
8954
8955 Retrieves data related to given Battle Group. Type can be one of the following:
8956
8957         0 - Amount of players currently belonging to the group.
8958         1 - Store GID of players in <Battle Group> in a temporary global array $@arenamembers
8959                 and returns amount of players currently belonging to the group.
8960
8961 ---------------------------------------
8962
8963 *bg_getareausers(<Battle Group>,"<map name>",<x0>,<y0>,<x1>,<y1>);
8964
8965 Retrieves the amount of players belonging to the given Battle Group on the given
8966 map within the specified rectangular area.
8967
8968 ---------------------------------------
8969
8970 *bg_updatescore "<map name>",<Guillaume Score>,<Croix Score>;
8971
8972 This command will force the update of the displayed scoreboard.
8973 It is only usable when the map is defined as a Type 2 Battleground:
8974 mapflag <map name>      battleground    2
8975
8976 ---------------------------------------
8977
8978 ====================
8979 |10.- Pet commands.|
8980 ====================
8981 ---------------------------------------
8982
8983 *bpet;
8984
8985 This command opens up a pet hatching window on the client connected to the
8986 invoking character. It is used in item script for the pet incubators and will
8987 let the player hatch an owned egg. If the character has no eggs, it will just
8988 open up an empty incubator window.
8989 This is still usable outside item scripts.
8990
8991 ---------------------------------------
8992
8993 *pet <pet id>;
8994
8995 This command is used in all the item scripts for taming items. Running this
8996 command will make the pet catching cursor appear on the client connected to the
8997 invoking character, usable on the monsters with the specified pet ID number. It
8998 will still work outside an item script.
8999
9000 A full list of pet IDs can be found inside 'db/pet_db.txt'.
9001
9002 ---------------------------------------
9003
9004 *makepet <pet id>;
9005
9006 This command will create a pet egg and put it in the invoking character's
9007 inventory. The kind of pet is specified by pet ID numbers listed in
9008 'db/pet_db.txt'. The egg is created exactly as if the character just successfully
9009 caught a pet in the normal way.
9010
9011         // This will make you a poring:
9012         makepet 1002;
9013
9014 Notice that you absolutely have to create pet eggs with this command. If you try
9015 to give a pet egg with 'getitem', pet data will not be created by the char
9016 server and the egg will disappear when anyone tries to hatch it.
9017
9018 ---------------------------------------
9019
9020 *getpetinfo(<type>{,<char_id>})
9021
9022 This function will return pet information for the pet the invoking character
9023 currently has active. Valid types are:
9024
9025  PETINFO_ID - Pet ID
9026  PETINFO_CLASS - Pet class number as per 'db/pet_db.txt' - will tell you what kind of a pet it
9027      is.
9028  PETINFO_NAME - Pet name. Will return "null" if there's no pet.
9029  PETINFO_INTIMATE - Pet friendly level (intimacy score). 1000 is full loyalty.
9030  PETINFO_HUNGRY - Pet hungry level. 100 is completely full.
9031  PETINFO_RENAMED - Pet rename flag. 0 means this pet has not been named yet.
9032  PETINFO_LEVEL - Pet level
9033  PETINFO_BLOCKID - Pet Game ID
9034
9035 ---------------------------------------
9036
9037 =============================
9038 |10.1.- The Pet AI commands.|
9039 =============================
9040 ---------------------------------------
9041
9042 These commands will only work if the invoking character has a pet, and are meant
9043 to be executed from pet scripts. They will modify the pet AI decision-making for
9044 the current pet of the invoking character, and will NOT have any independent
9045 effect by themselves, which is why only one of them each may be in effect at any
9046 time for a specific pet. A pet may have 'petloot', 'petskillbonus',
9047 'petskillattack' OR 'petpetskillattack2' and 'petskillsupport'.
9048
9049 All commands with delays and durations will only make the behavior active for
9050 the specified duration of seconds, with a delay of the specified number of
9051 seconds between activations. Rates are a chance of the effect occurring and are
9052 given in percent. 'bonusrate' is added to the normal rate if the pet intimacy is
9053 at the maximum possible.
9054
9055 The behavior modified with the below mentioned commands will only be exhibited if
9056 the pet is loyal and appropriate configuration options are set in
9057 'battle_athena.conf'.
9058
9059 Pet scripts in the database normally run whenever a pet of that type hatches
9060 from the egg. Other commands usable in item scripts (see 'bonus') will also
9061 happily run from pet scripts. Apparently, the pet-specific commands will also
9062 work in NPC scripts and modify the behavior of the current pet up until the pet
9063 is hatched again. (Which will also occur when the character is logged in again
9064 with the pet still out of the egg.) It is not certain for how long the effect of
9065 such command running from an NPC script will eventually persist, but apparently,
9066 it is possible to usefully employ them in usable item scripts to create pet
9067 buffing items.
9068
9069 Nobody tried this before, so you're essentially on your own here.
9070
9071 ---------------------------------------
9072
9073 *petskillbonus <bonus type>,<value>,<duration>,<delay>;
9074
9075 This command will make the pet give a bonus to the owner's stat in certain
9076 duration in seconds and will be repeated for certain delay in seconds.
9077
9078 For a full bonus list, see 'doc/item_bonus.txt'
9079 NOTE: Currently ONLY supported for bonuses that used by 'bonus' script.
9080
9081 ---------------------------------------
9082
9083 *petrecovery <status type>,<delay>;
9084
9085 This command will make the pet cure a specified status condition. The curing
9086 actions will occur once every Delay seconds. For a full list of status
9087 conditions that can be cured, see the list of 'SC_' status condition constants
9088 in 'src/map/script_constants.h'.
9089
9090 ---------------------------------------
9091
9092 *petloot <max items>;
9093
9094 This command will turn on pet looting, with a maximum number of items to loot
9095 specified. Pet will store items and return them when the maximum is reached or
9096 when pet performance is activated.
9097
9098 ---------------------------------------
9099
9100 *petskillsupport <skill id>,<skill level>,<delay>,<percent hp>,<percent sp>;
9101 *petskillsupport "<skill name>",<skill level>,<delay>,<percent hp>,<percent sp>;
9102
9103 This will make the pet use a specified support skill on the owner whenever the
9104 HP and SP are below the given percent values, with a specified delay time
9105 between activations. The skill numbers are as per 'db/(pre-)re/skill_db.txt'.
9106
9107 It's not quite certain who's stats will be used for the skills cast, the
9108 character's or the pets. Probably, Skotlex can answer that question.
9109
9110 ---------------------------------------
9111
9112 *petskillattack <skill id>,<skill level>,<rate>,<bonusrate>;
9113 *petskillattack "<skill name>",<skill level>,<rate>,<bonusrate>;
9114 *petskillattack2 <skill id>,<damage>,<number of attacks>,<rate>,<bonusrate>;
9115 *petskillattack2 "<skill name>",<damage>,<number of attacks>,<rate>,<bonusrate>;
9116
9117 These two commands will make the pet cast an attack skill on the enemy the pet's
9118 owner is currently fighting. Skill IDs and levels are as per 'petskillsupport'.
9119 'petskillattack2' will make the pet cast the skill with a fixed amount of damage
9120 inflicted and the specified number of attacks.
9121
9122 Value of 'rate' is between 1 and 100. 100 = 100%
9123
9124 ---------------------------------------
9125
9126 ===========================
9127 |11.- Homunculus commands.|
9128 ===========================
9129 ---------------------------------------
9130
9131 *homevolution;
9132
9133 This command will try to evolve the current player's homunculus.
9134 If it doesn't work, the /swt emotion is shown.
9135
9136 To evolve a homunculus, the invoking player must have a homunculus,
9137 the homunculus must not be the last evolution and
9138 the homunculus must have above 91000 intimacy with its owner.
9139
9140 ---------------------------------------
9141
9142 *morphembryo;
9143
9144 This command will try to put the invoking player's Homunculus in an
9145 uncallable state, required for mutation into a Homunculus S. The player
9146 will also receive a Strange Embryo (ID 6415) in their inventory if
9147 successful, which is deleted upon mutation.
9148
9149 The command will fail if the invoking player does not have an evolved
9150 Homunculus at level 99 or above. The /swt emotion is shown upon failure.
9151
9152 Returns 1 upon success and 0 for all failures.
9153
9154 ---------------------------------------
9155
9156 *hommutate {<ID>};
9157
9158 This command will try to mutate the invoking player's Homunculus into
9159 a Homunculus S. The Strange Embryo (ID 6415) is deleted upon success.
9160
9161 The command will fail if the invoking player does not have an evolved
9162 Homunculus at level 99 or above, if it is not in the embryo state
9163 (from the 'morphembryo' command), or if the invoking player does not
9164 possess a Strange Embryo. The /swt emotion is shown upon failure.
9165
9166 If the optional parameter <ID> is set, the invoking player's Homunculus
9167 will change into the specified Homunculus ID. Otherwise, a random Homunculus S
9168 will be chosen. See 'db/homunculus_db.txt' for a full list of IDs.
9169
9170 Returns 1 upon success and 0 for all failures.
9171
9172 ---------------------------------------
9173
9174 *checkhomcall()
9175
9176 This function checks if the attached player's Homunculus is active,
9177 and will return the following values:
9178  -1: The player has no Homunculus.
9179   0: The player's Homunculus is active.
9180   1: The player's Homunculus is vaporized.
9181   2: The player's Homunculus is in morph state.
9182
9183 ---------------------------------------
9184
9185 *gethominfo(<type>{,<char_id>})
9186
9187 This function will return Homunculus information for the Homunculus of the
9188 invoking character, regardless of its vaporize state. It returns zero or
9189 "null" if the player does not own a Homunculus.
9190
9191 Valid types are:
9192  0 - Homunculus ID
9193  1 - Homunculus Class
9194  2 - Homunculus Name
9195  3 - Homunculus friendly level (intimacy score). 100000 is full loyalty.
9196  4 - Homunculus hungry level. 100 is completely full.
9197  5 - Homunculus rename flag. 0 means this homunculus has not been named yet.
9198  6 - Homunculus level
9199  7 - Homunculus Game ID
9200
9201 ---------------------------------------
9202
9203 *homshuffle;
9204
9205 This will recalculate the homunculus stats according to its level, of the
9206 current invoking character.
9207
9208 ---------------------------------------
9209
9210 ==========================
9211 |12.- Mercenary commands.|
9212 ==========================
9213 ---------------------------------------
9214
9215 *mercenary_create <class>,<contract time>;
9216
9217 This command summons a mercenary for a given time (in milliseconds). For a
9218 list of all available classes, see 'db/mercenary_db.txt'.
9219
9220 This command is typically used in item scripts of mercenary scrolls.
9221
9222 ---------------------------------------
9223
9224 *mercenary_heal <hp>,<sp>;
9225
9226 This command works like 'heal', but affects the mercenary of the
9227 currently attached character.
9228
9229 ---------------------------------------
9230
9231 *mercenary_sc_start <type>,<tick>,<val1>;
9232
9233 This command works like 'sc_start', but affects the mercenary of the
9234 currently attached character.
9235
9236 ---------------------------------------
9237
9238 *mercenary_get_calls(<guild>);
9239 *mercenary_set_calls <guild>,<value>;
9240
9241 Sets or gets the mercenary calls value for given guild for currently
9242 attached character. Guild can be one or the following constants:
9243
9244         ARCH_MERC_GUILD
9245         SPEAR_MERC_GUILD
9246         SWORD_MERC_GUILD
9247
9248 ---------------------------------------
9249
9250 *mercenary_get_faith(<guild>);
9251 *mercenary_set_faith <guild>,<value>;
9252
9253 Sets or gets the mercenary faith value for given guild for currently
9254 attached character. Guild can be one or the following constants:
9255
9256         ARCH_MERC_GUILD
9257         SPEAR_MERC_GUILD
9258         SWORD_MERC_GUILD
9259
9260 ---------------------------------------
9261
9262 *getmercinfo(<type>{,<char id>});
9263
9264 Retrieves information about mercenary of the currently attached
9265 character. If char id is given, the information of that character is
9266 retrieved instead. Type specifies what information to retrieve and
9267 can be one of the following:
9268
9269         0 - Mercenary ID
9270         1 - Mercenary Class
9271         2 - Mercenary Name
9272         3 - Mercenary faith value for this mercenary's guild, if any
9273         4 - Mercenary calls value for this mercenary's guild, if any
9274         5 - Mercenary kill count
9275         6 - Mercenary remaining life time in msec
9276         7 - Mercenary level
9277         8 - Mercenary Game ID
9278
9279 If the character does not have a mercenary, the command returns ""
9280 for name and 0 for all other types.
9281
9282 ---------------------------------------
9283
9284 ======================
9285 |13.- Party commands.|
9286 ======================
9287 ---------------------------------------
9288
9289 *getpartyname(<party id>)
9290
9291 This function will return the name of a party that has the specified ID number.
9292 If there is no such party ID, "null" will be returned.
9293
9294 Lets say the ID of a party was saved as a global variable:
9295
9296         // This would return the name of the party from the ID stored in a variable
9297         mes "You're in the '" + getpartyname($@var) + "' party, I know!";
9298
9299 ---------------------------------------
9300
9301 *getpartymember <party id>{,<type>{,<array_variable>}};
9302
9303 This command will find all members of a specified party and returns their names
9304 (or character id or account id depending on the value of "type") into an array
9305 of temporary global variables. There's actually quite a few commands like this
9306 which will fill a special variable with data upon execution and not do anything
9307 else.
9308
9309 Upon executing this,
9310
9311 $@partymembername$[] is a global temporary string array which contains all the
9312                      names of these party members
9313                      (only set when type is 0 or not specified)
9314
9315 $@partymembercid[]   is a global temporary number array which contains the
9316                      character id of these party members.
9317                      (only set when type is 1)
9318
9319 $@partymemberaid[]   is a global temporary number array which contains the
9320                      account id of these party members.
9321                      (only set when type is 2)
9322
9323 $@partymembercount   is the number of party members that were found.
9324
9325 The party members will (apparently) be found regardless of whether they are
9326 online or offline. Note that the names come in no particular order.
9327
9328 Be sure to use $@partymembercount to go through this array, and not
9329 'getarraysize', because it is not cleared between runs of 'getpartymember'. If
9330 someone with 7 party members invokes this script, the array would have 7
9331 elements. But if another person calls up the NPC, and he has a party of 5, the
9332 server will not clear the array for you, overwriting the values instead. So in
9333 addition to returning the 5 member names, the 6th and 7th elements from the last
9334 call remain, and you will get 5+2 members, of which the last 2 don't belong to
9335 the new guy's party. $@partymembercount will always contain the correct number,
9336 (5) unlike 'getarraysize()' which will return 7 in this case.
9337
9338 If 'array_variable' is set, the result will be stored to that variable instead
9339 using global variable.
9340
9341 Example 1: list party member names
9342
9343         // get the party member names
9344         getpartymember getcharid(1),0;
9345
9346         // It's a good idea to copy the global temporary $@partymember*****
9347         // variables to your own scope variables because if you have pauses in this
9348         // script (sleep, sleep2, next, close2, input, menu, select, or prompt),
9349         // another player could click this NPC, trigger 'getpartymember', and
9350         // overwrite the $@partymember***** variables.
9351         .@count = $@partymembercount;
9352         copyarray .@name$[0], $@partymembername$[0], $@partymembercount;
9353
9354         // list the party member names
9355         for (.@i = 0; .@i < .@count; .@i++)
9356                 mes (.@i +1) + ". ^0000FF" + .@name$[.@i] + "^000000";
9357         close;
9358
9359
9360 Example 2: check party count (with a 'next' pause), before warping to event
9361
9362         .register_num = 5; // How many party members are required?
9363
9364         // get the charID and accountID of character's party members
9365         getpartymember getcharid(1), 1;
9366         getpartymember getcharid(1), 2;
9367
9368         if ( $@partymembercount != .register_num ) {
9369                 mes "Please form a party of " + .register_num + " to continue";
9370                 close;
9371         }
9372
9373         // loop through both and use 'isloggedin' to count online party members
9374         for ( .@i = 0; .@i < $@partymembercount; .@i++ )
9375                 if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) )
9376                         .@count_online++;
9377
9378         // We search accountID & charID because a single party can have multiple
9379         // characters from the same account. Without searching through the charID,
9380         // if a player has 2 characters from the same account inside the party but
9381         // only 1 char online, it would count their online char twice.
9382
9383         if ( .@count_online != .register_num ) {
9384                 mes "All your party members must be online to continue";
9385                 close;
9386         }
9387
9388         // copy the array to prevent players cheating the system
9389         copyarray .@partymembercid, $@partymembercid, .register_num;
9390
9391         mes "Are you ready ?";
9392         next; // careful here
9393         select("Yes");
9394
9395         // When a script hits a next, menu, sleep or input that pauses the script,
9396         // players can invite or /leave and make changes in their party. To prevent
9397         // this, we call getpartymember again and compare with the original values.
9398
9399         getpartymember getcharid(1), 1;
9400         if ( $@partymembercount != .register_num ) {
9401                 mes "You've made changes to your party !";
9402                 close;
9403         }
9404         for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
9405                 if ( .@partymembercid[.@i] != $@partymembercid[.@i] ) {
9406                         mes "You've made changes to your party !";
9407                         close;
9408                 }
9409         }
9410
9411         // Finally, it's safe to start the event!
9412         warpparty "event_map", 0,0, getcharid(1);
9413
9414 ---------------------------------------
9415
9416 *getpartyleader(<party id>{,<type>})
9417
9418 This function returns some information about the given party-id's leader.
9419 When type is omitted, the default information retrieved is the leader's name.
9420 Possible types are:
9421
9422         1: Leader account id
9423         2: Leader character id
9424         3: Leader's class
9425         4: Leader's current map name
9426         5: Leader's current level as stored on the party structure (may not be
9427            current level if leader leveled up recently).
9428
9429 If retrieval fails (leader not found or party does not exist), this function
9430 returns "null" instead of the character name, and -1 for the other types.
9431
9432 ---------------------------------------
9433
9434 *party_create("<party name>"{,<character id>{,<item share>,<item share type>}});
9435
9436 Organizes a party with the attached or specified character as leader. If
9437 successful, the command returns 1 and sets the global temporary variable
9438 "$@party_create_id" to the ID of the party created.
9439
9440 Additionally, item sharing options can be provided:
9441  - Item Share: 0-Each Take (default), 1-Party Share
9442  - Item Share Type: 0-Each Take (default), 1-Even Share
9443
9444 These values are returned upon failure:
9445  0: Unknown error.
9446 -1: Player not found.
9447 -2: Player already has a party.
9448 -3: Party name exists.
9449
9450 ---------------------------------------
9451
9452 *party_destroy(<party id>);
9453
9454 Disbands a party. The command returns 1 upon success and 0 upon failure.
9455
9456 ---------------------------------------
9457
9458 *party_addmember(<party id>,<character id>);
9459
9460 Adds a player to an existing party.
9461
9462 The command returns 1 upon success, and these values upon failure:
9463  0: Unknown error.
9464 -1: Player not found.
9465 -2: Player already has a party.
9466 -3: Party not found.
9467 -4: Party is full.
9468 -5: Another character from the same account is already in the party.
9469
9470 ---------------------------------------
9471
9472 *party_delmember({<character id>,<party id>});
9473
9474 Removes a player from his/her party. If no player is specified, the command
9475 will run for the invoking player. If that player is the only party member
9476 remaining, the party will be disbanded.
9477
9478 The command returns 1 upon success, and these values upon failure:
9479  0: Unknown error.
9480 -1: Player not found.
9481 -2: Party not found.
9482 -3: Player is not in the party.
9483
9484 ---------------------------------------
9485
9486 *party_changeleader(<party id>,<character id>);
9487
9488 Transfers leadership of a party to the specified character.
9489
9490 The command returns 1 upon success, and these values upon failure:
9491  0: Unknown error.
9492 -1: Party not found.
9493 -2: Player not found.
9494 -3: Player is not in the party.
9495 -4: Player is already party leader.
9496
9497 ---------------------------------------
9498
9499 *party_changeoption(<party id>,<option>,<flag>);
9500
9501 Changes a party option.
9502
9503 Valid options are:
9504  0 - Exp Share (flags: 0-Each Take, 1-Even Share)
9505  1 - Item Share (flags: 0-Each Take, 1-Party Share)
9506  2 - Item Share Type (flags: 0-Each Take, 1-Even Share)
9507
9508 The command returns 1 upon success, and these values upon failure:
9509  0: Invalid option.
9510 -1: Party not found.
9511
9512 ---------------------------------------
9513
9514 *opendressroom(<flag>{,<char_id>});
9515
9516 This will open the Dress Room window on the client connected to the invoking character.
9517
9518         mes "Close this window to open the Dress Room window.";
9519         close2;
9520         opendressroom(1);
9521         end;
9522
9523 Valid flag are:
9524  1 - Open the Dress Room window
9525
9526 ---------------------------------------
9527
9528 *navigateto("<map>"{,<x>,<y>,<flag>,<hide_window>,<monster_id>,<char_id>});
9529
9530 Generates a navigation for attached or specified character. Requires client
9531 2011-10-10aRagEXE or newer.
9532
9533 The flag specifies how the client will calculate the specific route.
9534
9535 Valid flags are:
9536  NAV_NONE - No services
9537  NAV_AIRSHIP_ONLY - Airship only
9538  NAV_SCROLL_ONLY - Scroll only
9539  NAV_AIRSHIP_AND_SCROLL - Airship and Scroll
9540  NAV_KAFRA_ONLY - Kafra only
9541  NAV_KAFRA_AND_AIRSHIP - Kafra and Airship
9542  NAV_KAFRA_AND_SCROLL - Kafra and Scroll
9543  NAV_ALL - All services
9544
9545 When flag is not specified, the default value is NAV_KAFRA_AND_AIRSHIP.
9546
9547 The hide_window specifies whether to display (0) or hide (1) the navigation window.
9548 By default the window is hidden.
9549
9550 You can specify the monster_id in combination with a mapname to make the
9551 navigation system tell you, that you have reached the desired mob.
9552
9553 Note:
9554 The client requires custom monster spawns be in the navigation file
9555 for using the embedded client Navigation feature to work properly. In this
9556 instance sending the player to the map where the monster spawns is a simpler
9557 solution rather than sending the map and the monster_id.
9558
9559 ---------------------------------------
9560
9561 *hateffect(<Hat Effect ID>,<State>);
9562
9563 This will set a Hat Effect onto the player. The state field allows you to
9564 enable (true) or disable (false) the effect on the player.
9565 The Hat Effect constants can be found in db/const.txt starting with HAT_EF_*.
9566
9567 Requires client 2015-05-13aRagEXE or newer.
9568
9569 ---------------------------------------
9570
9571 *getrandomoptinfo(<type>);
9572
9573 Returns value of an attribute of current random option.
9574
9575 Valid attributes are:
9576 ROA_ID - ID of current option
9577 ROA_VALUE - Value field of current option
9578 ROA_PARAM - Param field of current option
9579
9580 This script command is intended for using in random option scripts.
9581
9582 ---------------------------------------
9583
9584 *getequiprandomoption(<equipment index>,<index>,<type>{,<char id>});
9585
9586 Returns value of an attribute of a random option on an equipped item.
9587
9588 See 'getequipid' for a full list of valid equipment slots.
9589
9590 index parameter can be 0 to MAX_ITEM_RDM_OPT-1 (default 0-4).
9591
9592 For valid attribute types, see `getrandomoptinfo` command reference.
9593
9594 ---------------------------------------
9595
9596 *setrandomoption(<equipment slot>,<index>,<id>,<value>,<param>{,<char id>});
9597
9598 Sets <index+1>th random option for equipment equipped at <equipment slot>
9599 to <id>, <value> and <param>.
9600
9601 See 'getequipid' for a full list of valid equipment slots.
9602
9603 index parameter can be 0 to MAX_ITEM_RDM_OPT-1 (default 0-4).
9604
9605 ID - ID of random option. See db/const.txt for constants.
9606 Value - Value of random option
9607 Param - Parameter of random option
9608
9609 ---------------------------------------
9610
9611 *clan_join(<clan id>{,<char id>});
9612
9613 The attached player joins the clan with the <clan id>. On a successful join,
9614 true is returned, else false if the join failed.
9615 If <char id> is specified, the specified player is used rather than the attached one.
9616
9617 ---------------------------------------
9618
9619 *clan_leave({<char id>});
9620
9621 The attached player will leave their clan. On a successful leave, true is returned,
9622 else false if the leave failed.
9623 If <char id> is specified, the specified player is used rather than the attached one.
9624
9625 ---------------------------------------
9626
9627 ========================
9628 |14.- Channel commands.|
9629 ========================
9630 ---------------------------------------
9631
9632 *channel_create "<chname>","<alias>"{,"<password>"{<option>{,<delay>{,<color>{,<char_id>}}}}};
9633
9634 Creates a public channel with <chname> as the channel name. To protect the
9635 channel, use <password> or write "null" to create it without a password.
9636 Channel name must start with '#' and cannot be the same as the map or ally
9637 channel names.
9638
9639 <alias> will be used to change the channel name when the channel message
9640 is displayed.
9641
9642 <option> values are:
9643         CHAN_OPT_BASE               - Default option including CHAN_OPT_ANNOUNCE_SELF|CHAN_OPT_MSG_DELAY|CHAN_OPT_CAN_CHAT|CHAN_OPT_CAN_LEAVE
9644         CHAN_OPT_ANNOUNCE_SELF  - Show info for player itself if player has joined/leaves the channel
9645         CHAN_OPT_ANNOUNCE_JOIN  - Display message when player is joining the channel
9646         CHAN_OPT_ANNOUNCE_LEAVE - Display message when player is leaving the channel
9647         CHAN_OPT_MSG_DELAY          - Enable chat delay for the channel
9648         CHAN_OPT_COLOR_OVERRIDE - Player's unique font color will override channel's color
9649         CHAN_OPT_CAN_CHAT           - Player can chat in the channel
9650         CHAN_OPT_CAN_LEAVE          - Player can leave the channel
9651         CHAN_OPT_AUTOJOIN           - Players will auto join the channel at login
9652
9653 The <delay> is the minimum chat delay in millisecond for a single player before
9654 the player can chat again in the same channel.
9655
9656 Use <color> hex code to set the color for this channel, if not defined, default
9657 channel color will be used.
9658
9659 If <char_id> is defined, the channel will be a private channel and the player
9660 will be the the channel owner.
9661
9662 Returns 1 on success.
9663
9664         /**
9665          * This example will shows the message on this channel as
9666          * [rAthena] Admin : Hello world!
9667          * instead of
9668          * #rathena Admin : Hello world!
9669          **/
9670         channel_create("#rathena","[rAthena]");
9671         channel_create("#vip","[VIP]","vipmemberonly");
9672
9673 ---------------------------------------
9674
9675 *channel_setopt "<chname>",<option>,<value>;
9676
9677 Set option for the channel. Use 1 in <value> to set it, or 0 to unset.
9678 The <option> values are the same as the 'channel_create' options.
9679
9680 For CHAN_OPT_MSG_DELAY, the delay in millisecond must be sent or use 0
9681 to remove the delay at <value>.
9682
9683 Returns 1 on success.
9684
9685         // Example to set delay
9686         channel_setopt("#global",CHAN_OPT_MSG_DELAY,5000);
9687
9688 Only for public and private channel.
9689
9690 ---------------------------------------
9691
9692 *channel_setcolor "<chname>",<color>;
9693
9694 To change channel color.
9695 <color> uses hex RGB values.
9696
9697 Returns 1 on success.
9698
9699 ---------------------------------------
9700
9701 *channel_setpass "<chname>","<password>";
9702
9703 To set, unset, or change password of a channel.
9704 Use "null" to remove the password.
9705
9706 Returns 1 on success.
9707 Only for public and private channel.
9708
9709 ---------------------------------------
9710
9711 *channel_setgroup "<chname>",<group_id>{,...,<group_id>};
9712 *channel_setgroup2 "<chname>",<array_of_groups>;
9713
9714 Set group restriction for a channel. Only player with matching <group_id>
9715 are allowed to to join the channel.
9716
9717 By using 0 in the first group channel, the group restriction will be
9718 removed from the channel config.
9719
9720 'channel_setgroup2' receives input for group list as an array.
9721
9722 Returns 0 on failure, and 1 (or n groups count) on success.
9723
9724         // Example 1: Remove groups
9725         channel_setgroup("#event",0);
9726
9727         // Example 2: Multiple values
9728         channel_setgroup("#vip",2,5);
9729
9730         // Example 3: Using array
9731         setarray .@staffs[0],2,3,4,10,99;
9732         channel_setgroup("#staff",.@staffs);
9733
9734 Only for public and private channel.
9735
9736 ---------------------------------------
9737
9738 *channel_chat "<chname>","<message>"{,<color>};
9739
9740 Sends message to the channel.
9741 Returns 1 on success.
9742
9743         // Example if channel doesn't have alias
9744         channel_chat(#rathena,"Hello World!"); // #rathena Hello World!
9745
9746         // Example if channel has alias
9747         channel_chat(#rathena,"Hello World!"); // [rAthena] Hello World!
9748
9749 ---------------------------------------
9750
9751 *channel_ban "<chname>",<char_id>;
9752
9753 Ban player from a public or private channel.
9754 Channel's owner or group with PC_PERM_CHANNEL_ADMIN cannot be banned.
9755 Returns 1 on success.
9756
9757 ---------------------------------------
9758
9759 *channel_unban "<chname>",<char_id>;
9760
9761 Unban player from a public or private channel.
9762 Returns 1 on success.
9763
9764 ---------------------------------------
9765
9766 *channel_kick "<chname>",<char_id>;
9767 *channel_kick "<chname>","<char_name>";
9768
9769 Kick player from a public or private channel.
9770 Channel's owner or group with PC_PERM_CHANNEL_ADMIN cannot be kicked.
9771 Returns 1 on success.
9772
9773 ---------------------------------------
9774
9775 *channel_delete "<chname>";
9776
9777 Delete an existing public or private channel. Cannot delete ally or
9778 local map channel.
9779 Returns 0 on success.
9780
9781 ---------------------------------------
9782
9783 ============================
9784 |15.- Achievement commands.|
9785 ============================
9786 ---------------------------------------
9787
9788 *achievementadd(<achievement id>{,<char id>})
9789
9790 This function will add an achievement to the player's log for the attached
9791 player or the supplied <char id>. The objective requirements are not ignored
9792 when using this function.
9793 Returns true on success and false on failure.
9794
9795 ---------------------------------------
9796
9797 *achievementremove(<achievement id>{,<char id>})
9798
9799 This function will remove an achievement from the player's log for the attached
9800 player or the supplied <char id>.
9801 Returns true on success and false on failure.
9802
9803 ---------------------------------------
9804
9805 *achievementinfo(<achievement id>,<type>{,<char id>})
9806
9807 This function will return the specified <type> value for an achievement of the
9808 attached player or the supplied <char id>. If the player doesn't have the
9809 achievement active (no progress has been made): if the achievement doesn't
9810 exist -1 will be returned, or -2 will be returned on any other error such as
9811 an invalid <type>.
9812
9813 Valid types:
9814 - ACHIEVEINFO_COUNT1
9815 - ACHIEVEINFO_COUNT2
9816 - ACHIEVEINFO_COUNT3
9817 - ACHIEVEINFO_COUNT4
9818 - ACHIEVEINFO_COUNT5
9819 - ACHIEVEINFO_COUNT6
9820 - ACHIEVEINFO_COUNT7
9821 - ACHIEVEINFO_COUNT8
9822 - ACHIEVEINFO_COUNT9
9823 - ACHIEVEINFO_COUNT10
9824 - ACHIEVEINFO_COMPLETE
9825 - ACHIEVEINFO_COMPLETEDATE
9826 - ACHIEVEINFO_GOTREWARD
9827 - ACHIEVEINFO_LEVEL (<achievement id> is useless for this)
9828 - ACHIEVEINFO_SCORE (<achievement id> is useless for this)
9829
9830 ---------------------------------------
9831
9832 *achievementcomplete(<achievement id>{,<char id>})
9833
9834 This function will complete an achievement for the attached player or the supplied
9835 <char id>. The objective requirements are ignored when using this function.
9836 Returns true on success and false on failure.
9837
9838 ---------------------------------------
9839
9840 *achievementexists(<achievement id>{,<char id>});
9841
9842 This function will return if the achievement exists on the player or the supplied
9843 <char id>.
9844 Returns true on success and false on failure.
9845
9846 ---------------------------------------
9847
9848 *achievementupdate(<achievement id>,<type>,<value>{,<char id>})
9849
9850 This function will update an achievement's value for an achievement of the attached
9851 player or the supplied <char id>. If the player does not have the achievement active
9852 (no progress has been made) it will be added to the player's log first before updating
9853 the <type> value.
9854 Returns true on success and false on failure.
9855
9856 See 'achievementinfo' for valid <type> values.
9857 - ACHIEVEINFO_COMPLETE, ACHIEVEINFO_COMPLETEDATE, and ACHIEVEINFO_GOTREWARD require the
9858   specific value returned from 'gettimetick(2)'.
9859 - Excludes ACHIEVEINFO_LEVEL and ACHIEVEINFO_SCORE.
9860
9861 ---------------------------------------