//===== Athena Doc ======================================== //= eAthena Script Commands //===== Description ======================================= //= A reference manual for the eAthena scripting language. //= Commands are sorted depending on their functionality. //===== Version =========================================== //= 3.45.20110709 //========================================================= //= 1.0 - First release, filled will as much info as I could //= remember or figure out, most likely there are errors, //= and things I have missed out [Fredzilla] //= 1.1 - Added better discription for "getmapxy" (by Terminal Vertex & Z3R0) //= 1.2b- Added a description for getpartymember (by HappyDenn) //= (+few spelling mistakes corrected) //= 2.0 - +79kb extra stuff and numerous corrections by //= Maeki Rika. //= 2.1 - Small but important corrections, more proofreading. //= Some important discoveries in item functions, the //= secret of making VVS weapons with 'getitem2' and //= other news. (Rika again) +10kb :) //= 2.2 - added getItemInfo description [Lupus] //= 2.3 - added plenty of info for recent (and not so) script commands I added //= [Skotlex] //= 2.4 - Explained the upper parameter of jobchange. [Skotlex] //= 2.5 - Added pow, sqrt and distance. [Lance] //= 2.6 - Added setd and getd. [Lance] //= 2.7 - petstat command. [Lance] //= 2.7a- delitem2, countitems2 commands [Lupus] //= 2.7b- clone command [Skotlex] //= 2.7c- disguise / undisguise, query_sql commands [Lupus] //= 2.8 - Deleted a copy of the nude command. Added axtoi command (needing a //= clearer explanation of atoi.Gave a better explanation of OnLabels //= and modified monster explanation due that L_Label isn't working with //= monster. //= 2.9.20061230 - Updated getitem and guardian. [FlavioJS] //= 2.10.20070101 - added sleep,sleep2,awake and updated the variables section. //= [FlavioJS] //= 2.11.20070109 - removed the unused flag argument in guildskill, added an //= optional argument to setcart,setfalcon,setriding and other cleanups //= [FlavioJS] //= 2.12.20070201 - Added npcshopitem, npcshopadditem, npcshopdelitem and //= npcshopattach [Skotlex] //= 3.00.20070208 //= - Explained Logical Bitwise Operators. //= Dj-Yhn contributed to AND (&) operator, rest by myself. [erKURITA] //= - Added a resume of allowed variable and arrays scopes. [erKURITA] //= - Re-organized the script commands, and grouped them depending //= on what they do. [erKURITA] //= - Added a packload of commands that were missing, //= and corrected some of the wrong ones [Dj-Yhn, erKURITA & Trancid] //= 3.01.20070209 //= Updated 'cutin' (removed lies, removed outdated bmp list) [ultramage] //= Removed 'cutincard' since eA no longer implements it //= 3.02.20070209 //= Corrected/updated info on Xor/setd/getd/callfunc/callsub/return and //= updated some examples to use "better" code. [FlavioJS] //= 3.03.20070216 //= Expanded/clarified information on npc timers, added info about the //= new attach flag for script commands startnpctimer/ stopnpctimer/ //= initnpctimer [Skotlex] //= 3.03.20070226 //= Updated makeitem and how to include " in strings [Lupus] //= 3.03.20070228 //= Added info on OnTimerQuit label to npctimer section. [Skotlex] //= 3.04.20070317 //= Removed all .gat refferences from the examples [Lupus] //= 3.04.20070330 //= Adjusted the 'itemskill' description due to recent change [ultramage] //= 3.04.20070409 //= Fixed the incorrect order of parameters in 'makeitem' [ultramage] //= 3.05.20070423 //= menu/select/prompt produce consistent results for grouped and empty //= options [FlavioJS] //= 3.05.20070819 //= Removed the messy 'unitdeadsit' command reference [ultramage] //= 3.05.20070823 //= Fixed typo in 'areamonster' description (missing argument) [ultramage] //= 3.06 20070909 //= Added 'gethominfo' description [Skotlex] //= 3.06.20070910 //= Added info about the new behavior of 'getexp' [ultramage] //= 3.07.20070915 //= Fixed 'duplicate' missing the target 'name' parameter! [ultramage] //= 3.08.20071018 //= Clarified how npc names work. [FlavioJS] //= 3.09.20071103 //= Added script function 'strnpcinfo' [ultramage] //= 3.10.20071122 //= Added setnpcdisplay. [FlavioJS] //= 3.10.20071211 //= Added query_logsql. [Skotlex] //= 3.11.20071215 //= Updated guardianinfo and get-/setcastledata [ultramage] //= 3.12.20071218 //= Corrected various mistakes mentioned in bugreport:373 [ultramage] //= 3.12.20071227 //= Corrected description of scope and npc variables. [FlavioJS] //= 3.13.20080104 //= Updated 'setcell' desc to match latest code changes [ultramage] //= 3.14.20080211 //= Updated 'input' (new arguments and return value). [FlavioJS] //= 3.15.20080227 //= Updated 'checkweight' description slightly. [L0ne_W0lf] //= 3.16.20080229 //= Updated 'Shop' NPC type description to include cashshop. [L0ne_W0lf] //= Woopth. Fixed spelling. ;P Should be a bit clearer now. [L0ne_W0lf] //= 3.17.20080312 //= Corrected cashshop description. (#FREEPOINTS->#KAFRAPOINTS) [L0ne_W0lf] //= 3.18.20080327 //= Added documentation for the 'checkcell' command [ultramage] //= 3.19.20080407 //= Extended the behaviour of 'guardian'. [FlavioJS] //= 3.20.20080425 //= Corrected 'getitem', 'getitem2' & 'delitem2' (charid instead of accountid) [Toms] //= Modified 'delitem' (added optional accountid parameter) [Toms] //= 3.21.20080612 //= Script commands extended to support skill names: [FlavioJS] //= skill, addtoskill, guildskill, getskilllv, getgdskilllv, itemskill, //= petskillattack, petskillattack2, petskillsupport, skilleffect, npcskilleffect, //= unitskilluseid, unitskillusepos, bonus/bonus2/bonus3/bonus4/bonus5 //= 3.22.20080622 //= Extended 'set' to return the variable reference. [FlavioJS] //= 3.22.20080901 //= Adjusted the 'getequipname' description to match src [ultramage] //= 3.23.20080909 //= Added WoE SE related commands. [L0ne_W0lf] //= 3.24.20081111 //= Changed the error behaviour of delitem/delitem2/Zeny. [FlavioJS] //= 3.25.20081220 //= Extended the behaviour of duplicates (warps/shops/cashshops). [FlavioJS] //= 3.26.20090702 //= Replaced 'bonusautoscript' by 'autobonus'. [Inkfish] //= 3.27.20090725 //= Added Quest Log related commands. [Inkfish] //= 3.28.20091119 //= Added showevent and searchitem commands [Skotlex] //= Added info on strcharinfo(3) [Skotlex] //= 3.29.20101123 //= Added 'pushpc' command. [Ai4rei] //= 3.30.20101126 //= Added 'setfont', 'mercenary_create', 'mercenary_heal', //= 'mercenary_sc_start', 'mercenary_get_calls', 'mercenary_set_calls', //= 'mercenary_get_faith' and 'mercenary_set_faith' commands. [Ai4rei] //= 3.31.20101130 //= Added 'progressbar' command. [Ai4rei] //= 3.32.20101208 //= Updated description for commands 'next', 'return', 'attachrid', //= 'detachrid', 'itemskill', 'openstorage', 'skilleffect', 'donpcevent', //= 'day', 'night', 'atoi', 'axtoi', 'jump_zero', 'getelementofarray', //= 'changebase', 'kickwaitingroomall', 'cutin' and 'charcommand'. [Ai4rei] //= 3.33.20101212 //= Updated description of 'playBGM' and 'playBGMall' to reflect the actual //= behavior. [Ai4rei] //= 3.34.20101217 //= Spellcheck. [Ai4rei] //= 3.35.20110106 //= Removed bug warning from 'deletearray'. [Ai4rei] //= 3.36.20110219 //= Added 'buyingstore' command. [Ai4rei] //= 3.37.20110306 //= Added 'searchstores' command. [Ai4rei] //= 3.38.20110313 //= Added 'cooking' command. [Ai4rei] //= Fixed item levels in 'produce' command. //= 3.39.20110322 //= Added 'bg_getareausers' and 'bg_get_data' commands. [Ai4rei] //= Updated description of 'waitingroom2bg_single' command. //= Documented optional parameter 'npc name' of 'waitingroom2bg' command. //= 3.40.20110404 //= Updated description of 'waitingroom' command to include required zeny/lvl. [Kisuka] //= 3.41.20110427 //= Updated description of 'itemheal' primarily to remove overhead and lies //= about client effects. [Ai4rei] //= 3.42.20110508 //= Updated description of all instance commands to reflect actual behavior. //= [Ai4rei] //= 3.43.20110529 //= Updated 'npcshopitem', 'npcshopadditem' and 'npcshopdelitem' to support //= cashshops as well. [Ai4rei] //= 3.44.20110530 //= Documented special map names recognized by 'warpguild'. [Ai4rei] //= 3.45.20110709 //= Added 'getmercinfo' command. [Ai4rei] //= 3.46.20110810 //= Added information on OnTouchNPC and 'unitwarp' special case [Skotlex] //= 3.47.20111025 //= Documented successruneuse and setdragon. [L0ne_W0lf] //= Ammended documentation for Produce. //========================================================= This document is a reference manual for all the scripting commands and functions available in current eAthena SVN. It is not a simple tutorial. When people tell you to "Read The F***ing Manual", they mean this. The information was mostly acquired through looking up how things actually work in the source code of the server, which was written by many people over time, and lots of them don't speak English and never left any notes - or are otherwise not available for comments. As such, anything written in here might not be correct, it is only correct to the best of our knowledge, which is limited. This is not a place to teach you basic programming. This document will not teach you basic programming by itself. It's more of a reference for those who have at least a vague idea of what they want to do and want to know what tools they have available to do it. We've tried to keep it as simple as feasible, but if you don't understand it, getting a clear book on programming in general will help better than yelling around the forum for help. A little learning never caused anyone's head to explode. Structure --------- The commands and functions are listed in no particular order: *Name of the command and how to call it. Descriptive text Small example if possible. Will usually be incomplete, it's there just to give you an idea of how it works in practice. To find a specific command, use Ctrl+F, (or whatever keys call up a search function in whatever you're reading this with) put an * followed by the command name, and it should find the command description for you. If you find anything omitted, please respond. :) Syntax ------ Throughout this document, wherever a command wants an argument, it is given in . This doesn't mean you should type the angle brackets. :) If an argument of a command is optional, it is given in {curly brackets}. You've doubtlessly seen this convention somewhere, if you didn't, get used to it, that's how big boys do it. If a command can optionally take an unspecified number of arguments, you'll see a list like this: command {,...} This still means they will want to be separated by commas. Where a command wants a string, it will be given in "quotes", if it's a number, it will be given without them. Normally, you can put an expression, like a bunch of functions or operators returning a value, in (round brackets) instead of most numbers. Round brackets will not always be required, but they're often a good idea. Wherever you refer to a map name, it's always 'mapname' or 'mapname.gat' (Please, don't use .gat suffix anymore. It's useless.) Script loading structure ------------------------ Scripts are loaded by the map server as referenced in the 'conf/map_athena.conf' configuration file, but in the default configuration, it doesn't load any script files itself. Instead, it loads the file 'npc/scripts_main.conf' which itself contains references to other files. The actual scripts are loaded from txt files, which are linked up like this: npc: Any line like this, invoked, ultimately, by 'map_athena.conf' will load up the script contained in this file, which will make the script available. No file will get loaded twice, to prevent possible errors. Another configuration file option of relevance is: delnpc: This will unload a specified script filename from memory, which, while seemingly useless, may sometimes be required. Whenever '//' is encountered in a line upon reading, everything beyond this on that line is considered to be a comment and is ignored. This works wherever you place it. Upon loading all the files, the server will execute all the top-level commands in them. No variables exist yet at this point, no commands can be called other than those given in this section. These commands set up the basic server script structure - create NPC objects, spawn monster objects, set map flags, etc. No code is actually executed at this point except them. The top-level commands the scripting are pretty confusing, since they aren't structured like you would expect commands, command name first, but rather, normally start with a map name. What's more confusing about the top-level commands is that most of them use a tab symbol to divide their arguments. To prevent problems and confusion, the tab symbols are written as '%TAB%' throughout this document, even though this makes the text a bit less readable. Using an invisible symbol to denote arguments is one of the bad things about this language, but we're stuck with it for now. :) Here is a list of valid top-level commands: ** Set a map flag: %TAB%mapflag%TAB% This will, upon loading, set a specified map flag on a map you like. These are normally in files inside 'conf/mapflag' and are loaded first, so by the time the server's up, all the maps have the flags they should have. Map flags determine the behavior of the map regarding various common problems, for a better explanation, see 'setmapflag'. ** Create a permanent monster spawn: ,,,,%TAB%monster%TAB%%TAB%,,,, Map name is the name of the map the monsters will spawn on. x,y are the coordinates where the mob should spawn. If xs and ys are non-zero, they specify the diameters of a spawn-rectangle area who's center is x,y. Putting zeros instead of these coordinates will spawn the monsters randomly. Note this is only the initial spawn zone, as mobs random-walk, they are free to move away from their specified spawn region. Monster name is the name the monsters will have on screen, and has no relation whatsoever to their names anywhere else. It's the mob id that counts, which identifies monster record in 'mob_db.txt' database of monsters. If the mob name is given as "--ja--", the 'japanese name' field from the monster database is used, (which, in eAthena, actually contains an english name) if it's "--en--", it's the 'english name' from the monster database (which contains an uppercase name used to summon the monster with a GM command). If you add 20000 to the monster ID, the monster will be spawned in a 'big version', (monster size class will increase) and if you add 10000, the 'tiny version' of the monster will be created. However, this method is deprecated and not recommended, as the values to add can change at a later time (20000 and 10000 actually stand for 2*MAX_MOB_DB and MAX_MOB_DB respectively, which is defined on mob.h, and can change in the future as more mobs are created). The recommended way to change a mob's size is to use the event-field (see below). Amount is the amount of monsters that will be spawned when this command is executed, it is affected by spawn rates in 'battle_athena.conf'. Delay1 and delay2 are the monster respawn delays - the first one counts the time since a monster defined in this spawn was last respawned and the second one counts the time since the monster of this spawn was last killed. Whichever turns out to be higher will be used. If the resulting number is smaller than a random value between 5 and 10 seconds, this value will be used instead. (Which is normally the case if both delay values are zero.) The times are given in 1/1000ths of a second. You can specify a custom level to use for the mob different from the one of the database by adjoining the level after the name with a comma. eg: "Poring,50" for a name will spawn a monster with name Poring and level 50. Event is a script event to be executed when the mob is killed. The event must be in the form "NPCName::OnEventName" to execute, and the event name label should start with "On". As with all events, if the NPC is an on-touch NPC, the player who triggers the script must be within 'trigger' range for the event to work. The Event field can be used alternatively to specify other mob properties. Use 2 to specify that the mob should be small, 4 for big monsters, and 8 for special ai mobs (which by default attack other monsters instead of players). You can add these, so using 10 will spawn small monsters that attack other mobs (if you specify both 2 and 4, the small version takes priority). ** NPC names /!\ WARNING: this applies to warps, NPCs, duplicates and shops /!\ NPC names are kinda special and are formatted this way: {::} All NPCs need to have a unique name that is used for identification purposes. When you have to identify a NPC by it's name, you should use . If is not provided, use instead. The client has a special feature when displaying names: if the display name contains a '#' character, it hides that part of the name. ex: if your NPC is named 'Hunter#hunter1', it will be displayed as 'Hunter' must be at most 24 characters in length. must be at most 24 characters in length. ** Define a warp point ,,,%TAB%warp%TAB%%TAB%,,,, This will define a warp NPC that will warp a player between maps, and while most arguments of that are obvious, some deserve special mention. SpanX and SpanY will make the warp sensitive to a character who didn't step directly on it, but walked into a zone which is centered on the warp from coordinates and is SpanX in each direction across the X axis and SpanY in each direction across the Y axis. Warp NPC objects also have a name, because you can use it to refer to them later with 'enablenpc'/'disablenpc' Facing of a warp object is irrelevant, it is not used in the code and all current scripts have a zero in there. ** Define an NPC object. ,,,%TAB%script%TAB%%TAB%,{} ,,,%TAB%script%TAB%%TAB%,,,{} This will place an NPC object on a specified map at the specified location, and is a top-level command you will use the most in your custom scripting. The NPCs are triggered by clicking on them, and/or by walking in their trigger area, if defined, see that below. Facing is a direction the NPC sprite will face in. Not all NPC sprites have different images depending on the direction you look from, so for some facing will be meaningless. Facings are counted counterclockwise in increments of 45 degrees, where 0 means facing towards the top of the map. (So to turn the sprite towards the bottom of the map, you use facing 4, and to make it look southeast it's facing 5.) Sprite id is the sprite number used to display this particular NPC. For a full list of sprite id numbers see http://kalen.s79.xrea.com/npc/npce.shtml You may also use a monster's ID number instead to display a monster sprite for this NPC. It is possible to use a job sprite as well, but you must first define it as a monster sprite in 'mob_avail.txt', a full description on how to do this is not in the scope of this manual. A '-1' sprite id will make the NPC invisible (and unclickable). A '111' sprite id will make an NPC which does not have a sprite, but is still clickable, which is useful if you want to make a clickable object of the 3D terrain. TriggerX and triggerY, if given, will define an area, centered on NPC and spanning triggerX cells in every direction across X and triggerY in every direction across Y. Walking into that area will trigger the NPC. If no 'OnTouch:' special label is present in the NPC code, the execution will start from the beginning of the script, otherwise, it will start from the 'OnTouch:' label. Monsters can also trigger the NPC, though the label 'OnTouchNPC:' is used in this case. The code part is the script code that will execute whenever the NPC is triggered. It may contain commands and function calls, descriptions of which compose most of this document. It has to be in curly brackets, unlike elsewhere where we use curly brackets, these do NOT signify an optional parameter. ** Define a 'floating' NPC object. -%TAB%script%TAB%%TAB%-1,{} This will define an NPC object not triggerable by normal means. This would normally mean it's pointless since it can't do anything, but there are exceptions, mostly related to running scripts at specified time, which is what these floating NPC objects are for. More on that below. ** Define a shop/cashshop NPC. -%TAB%shop%TAB%%TAB%,:{,:...} ,,,%TAB%shop%TAB%%TAB%,:{,:...} This will define a shop NPC, which, when triggered (which can only be done by clicking) will cause a shop window to come up. No code whatsoever runs in shop NPCs and you can't change the prices otherwise than by editing the script itself. (No variables even exist at this point of scripting, so don't even bother trying to use them.) The item id is the number of item in the 'item_db.txt' database. If Price is set to -1, the 'buy price' given in the item database will be used. Otherwise, the price you gave will be used for this item, which is how you create differing prices for items in different shops. Since trunk r12264 you can alternatively use "cashshop" in place of "shop" to use the Cash Shop interface, allowing you to buy items with special points (Currently stored as account vars in global_reg #CASHPOINTS and #KAFRAPOINTS.) This type of shop will not allow you to sell items at it, you may only purchase items here. The layout used to define sale items still count, and "" refers to how many points will be spent purchasing the them. ** Define an warp/shop/cashshop/NPC duplicate. warp: ,,,%TAB%duplicate(