diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/script_commands.txt | 5548 |
1 files changed, 3095 insertions, 2453 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 212ad25d6..8dc6cf8e5 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -9,7 +9,7 @@ //= Maeki Rika - A section on general concepts and lots of //= other updates and additions. //===== Version =========================================== -//= 2.11.20070109 +//= 3.00.20070208 //========================================================= //= 1.0 - First release, filled will as much info as I could //= remember or figure out, most likely there are errors, @@ -45,10 +45,19 @@ //= [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] //===== Compatible With =================================== //= LOL, can be used by anyone hopefully //===== Description ======================================= -//= A reference manual for the eAthena scripting language +//= A reference manual for the eAthena scripting language, +//= sorted out depending on their functionality. //========================================================= This document is a reference manual for all the scripting commands and functions @@ -61,16 +70,6 @@ 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 document is poorly structured and rather messy in general. In fact, further -cleaning up and reordering this document is probably pointless, due to upcoming -switch to Lua scripting language, which will rid us of most of the problems -mentioned herein and make a new manual necessary. But while we have this one, we -should make the most of it, and it might be helpful in making sure the new Lua -engine can actually do everything useful that the old engine could. -Note: The change to lua isn't going to happen because we are switching to eApp. - eApp has it's own scripting language and a converter to convert scripts - from the current script language. - 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 @@ -344,7 +343,7 @@ prices for items in different shops. ** Define a function object -function%TAB%<function name>%TAB%{<code>} +function%TAB%script%TAB%<function name>%TAB%{<code>} This will define a function object, callable with the 'callfunc' command (see below). This object will load on every map server separately, so you can get at @@ -370,6 +369,8 @@ valid and mean what exactly is pending. Once an object is defined which has a 'code' field to it's definition, it contains script commands which can actually be triggered and executed. +~ RID? GID? ~ + What a RID is and why do you need to know ----------------------------------------- @@ -396,6 +397,17 @@ used to check which is the currently attached player to the script (it will return 0 if the there is no player attached or the attached player no longer is logged on to the map-server). +But what about GID? +--- ---- ----- ---- + +GID stands for the Game ID of something, this can either be the GID obtained +through mobspawn (mob control commands) or the account ID of a character. +Another way would be to right click on a mob, +NPC or char as GM sprited char to view the GID. + +This is mostly used for the new version of skill and the mob control commmands +implemented (but NEVER documented by Lance. Shame on you...). + Item and pet scripts -------------------- @@ -594,6 +606,41 @@ Arrays can naturaly store strings: the '$', normally denoting a string variable, before the square brackets that denotes an array index. +Resume of the allowed variable and array scopes +------ -- --- ------- -------- --- ----- ------ + ++==========+======+=======+ +|VarType | Norm | Array | ++==========+======+=======+ +|$Str$ | OK! | OK! | ++----------+------+-------+ +|$@Str$ | OK! | OK! | ++----------+------+-------+ +|@Str$ | OK! | OK! | ++----------+------+-------+ +|#Str$ | OK! | FAIL! | ++----------+------+-------+ +|Str$ | OK! | FAIL! | ++----------+------+-------+ +|$Int | OK! | OK! | ++----------+------+-------+ +|$@Int | OK! | OK! | ++----------+------+-------+ +|@Int | OK! | OK! | ++----------+------+-------+ +|#Int | OK! | FAIL! | ++----------+------+-------+ +|Int | OK! | FAIL! | ++----------+------+-------+ +|.Str$ | OK! | OK! | ++----------+------+-------+ +|.Int | OK! | OK! | ++----------+------+-------+ +|.@Str$ | OK! | OK! | ++----------+------+-------+ +|.@Int | OK! | OK! | ++----------+------+-------+ + Operators --------- @@ -645,15 +692,71 @@ Comparisons can be stacked in the same condition: 1=1 && 2=1 is False. 1=1 || 2=1 is True. -Logical operators work only on numbers: +Logical bitwise operators work only on numbers, and they are the following: << - Left shift. >> - Right shift. + Left shift moves the binary 1(s) of a number n positions to the left, + which is the same as multiplying by 2, n times. + In the other hand, Right shift moves the binary 1(s) of a number n positions + to the right, which is the same as dividing by 2, n times. + Example: + set b,2; + set a, b << 3; + mes a; + set a, a >> 2; + mes a; + The first mes command would display 16, which is the same as 2 x (2 x 2 x 2) = 16. + The second mes command would display 4, which is the same as 16 / 2 = 8. 8 / 2 = 4. & - And. | - Or. + The bitwise operator AND (&) is used to test two values against eachother, + and results in setting bits which are active in both arguments. This can + be used for a few things, but in eAthena this operator is usually used to + create bitmasks in scripts. + + The bitwise operator OR (|)sets to 1 a binary position if the binary position + of one of the numbers is 1. This way a variable can hold several values we can check, + known as bitmaks. A variable currently can hold up to 32 bitmasks (from position 0 + to position 1). This is a cheap(skate) and easy way to avoid using arrays to store several checks + that a player can have. + + A bitmask basically is (ab)using the variables bits to set various options in + one variable. With the current limit if variables it is possible to store 32 + different options in one variable (by using the bits on position 0 to 31). + + Example(s): + - Basic example of the & operator, bit example: + 10 & 2 = 2 + Why? : + 10 = 2^1 + 2^3 (2 + 8), so in bits, it would be 1010 + 2 = 2^1 (2), so in bits (same size) it would be 0010 + The & (AND) operator sets bits which are active (1) in both arguments, so in the + example 1010 & 0010, only the 2^1 bit is active (1) in both. Resulting in the bit + 0010, which is 2. + - Basic example of creating and using a bit mask: + set @options,2|4|16; //(note: this is the same as 2+4+16, or 22) + if (@options & 1) mes "Option 1 is activated"; + if (@options & 2) mes "Option 2 is activated"; + if (@options & 4) mes "Option 3 is activated"; + if (@options & 8) mes "Option 4 is activated"; + if (@options & 16) mes "Options 5 is activated"; + This would return the messages about option 2, 3 and 5 being shown (since we've set + the 2,4 and 16 bit to 1). ^ - Xor. - -If you don't know what these five mean, don't bother, you don't need them. + The bitwise operator XOR (eXclusive OR) sets to 0 a binary position if both numbers have a 1 + in the said position. On the other hand, it sets to 1 if there's a 1 in any of the number in + the said binary position. + This is the counter-part of the OR operator, the opposite if you like. This is used to remove a + bitmask, which is the same as substracting it. + + Example: + - We set the variable first: + set a,2|4|8|16; // this would be the same as 2+4+8+16 = 30 + - After some checks, we find he didn't do the third quest, which we asigned the 3rd value (8) + so now we have to remove it: + set a,a^8; //this would be the same as 30-8 = 22. 22 = 16+4+2, which are the flags left. + Labels ------ @@ -720,6 +823,14 @@ altering the configuration options in 'script_athena.conf'. It's pretty obvious when those will get triggered. For more information, see 'npc/sample/PCLoginEvent.txt' +OnPCLoadMapEvent: + +This special label will trigger once a player steps in a map marked with the +'loadmap' mapflag and attach its RID. The fact that this label requires a +mapflag for it to work is because, otherwise, it'd be server-wide and trigger +everytime a player would change maps. Imagine the server load with 1,000 players +(oh the pain...) + Only the special labels which are not associated with any script command are listed here. There are other kinds of labels which may be triggered in a similar manner, but they are described with their associated commands. @@ -764,16 +875,20 @@ behave nicely if you do. ------------------------- -*playerattached; -Returns the ID of the player currently attached to the script. It will return -0 if noone is attached, or if the attached player no longer exists on the map -server. It is wise to check for the attached player in script functions that -deal with timers as there's no guarantee the player will still be logged on -when the timer triggers. Note that the ID of a player is actually their -account ID. +From here on, we will have the commands sorted as follow: -------------------------- +1.- Basic commands. +2.- Information-retrieving commands. +3.- Checking commands. +4.- Player-related commands. +5.- Mob / NPC -related commands. +6.- Other commands. + +===================== +|1.- Basic commands.| +===================== +--------------------------------------- *mes "<string>"; @@ -805,177 +920,6 @@ either side solves the problem. --------------------------------------- -*goto <label>; - -This command will make the script jump to a label, usually used in conjunction -with other command, such as "if", but often used on it's own. - - goto Label; - mes "This will not be seen"; - Label: - mes "This will be seen"; - ---------------------------------------- - -*callfunc "<function>"{,<argument>,...<argument>}; -*callfunc("<function>"{,<argument>,...<argument>}) - -This command lets you call up a function NPC. A function NPC can be called from -any script on any map server. Using the 'return' command it will come back to -the place that called it. - - place.gat,50,50,6%TAB%script%TAB%Woman%TAB%115,{ - mes "[Woman]" - mes "Lets see if you win"; - callfunc "funcNPC"; - mes "Well done you have won"; - close; - } - function%TAB%script%TAB%funcNPC%TAB%{ - set @win, rand(2); - if(@win==0) return; - mes "Sorry you lost"; - end; - } - -You can pass arguments to your function - values telling it what exactly to do - -which will be available there with getarg() (see 'getarg') -Notice that returning is not mandatory, you can end execution right there. - -If you want to return a real value from inside your function NPC, it is better -to write it in the function form, which will also work and will make the script -generally cleaner: - - place.gat,50,50,6%TAB%script%TAB%Man%TAB%115,{ - mes "[Man]" - mes "Gimme a number!"; - next; - input @number; - if (callfunc("OddFunc",@number)) mes "It's Odd!"; - close; - } - function%TAB%script%TAB%OddFunc%TAB%{ - if (getarg(0)%2==0) goto ItsEven; - return (1); - ItsEven: - return (0); - } - ---------------------------------------- - -*callsub <label name>{,<argument>,...<argument>}; - -This command will go to a specified label within the current script (do NOT use -quotes around it) coming in as if it were a 'callfunc' call, and pass it -arguments given, if any, which can be recovered there with 'getarg'. When done -there, you should use the 'return' command to go back to the point from where -this label was called. This is used when there is a specific thing the script -will do over and over, this lets you use the same bit of code as many times as -you like, to save space and time, without creating extra NPC objects which are -needed with 'callfunc'. A label is not callable in this manner from another -script. - - mes "[Woman]" - mes "Lets see if you win"; - callsub Check; - mes "Well done you have won"; - Check: - set @win, rand(2); - if(@win==0) return; - mes "Sorry you lost"; - ---------------------------------------- - -*return {(<value>)}; - -When you use callsub or callfunc, this command allows you to go back to the -calling script. You can optionally return with a value telling the calling -program what exactly happened. To get at this value, you will have to use the -'set' command: - - set <variable>,callfunc "<your function>" - -Note the round brackets. Turns out you have to enclose just about anything in -brackets if it isn't a straight number for the return command to work with it: - - return (@x+@y); - -Also note that - - if (<condition>) return (<whatever>); - -does NOT always work, even though it would make scripts a lot cleaner, and it -might be wiser to avoid using it like that. - -For an example see 'callfunc' and 'callsub' - ---------------------------------------- - -*getarg(<number>) - -This function is used when you use the 'callsub' or 'callfunc' commands. In the -call you can specify variables that will make that call different from another -one. This function willwill return an argument the function or subroutine was -called with, and is the normal way to get them. -This is another thing that can let you use the same but of code more than once. - -Argument numbering starts with 0, i.e. the first argument you gave is number 0. -If no such argument was given, a zero is returned. - - place.gat,50,50,6%TAB%script%TAB%Woman1%TAB%115,{ - mes "[Woman]"; - mes "Lets see if you win"; - callfunc "funcNPC",2; - mes "Well done you have won"; - - ... - - place.gat,52,50,6%TAB%script%TAB%Woman2%TAB%115,{ - mes "[Woman]"; - mes "Lets see if you win"; - callfunc "funcNPC",5; - mes "Well done you have won"; - - ... - - function%TAB%script%TAB%funcNPC%TAB%{ - set @win, rand(getarg(0)); - if(@win==0) return; - mes "Sorry you lost"; - -"woman1" NPC object calls the funcNPC. The argument it gives in this call is -stated as 2, so when the random number is generated by the 'rand' function, it -can only be 0 or 1. Whereas "woman2" gives 5 as the argument number 0 when -calling the function, so the random number could be 0, 1, 2, 3 or 4, this makes -"woman2" less likely to say the player won. - -You can pass multiple arguments in a function call: - - callfunc "funcNPC",5,4,3; - -getarg(0) would be 5, getarg(1) would be 4 and getarg(2) would be 3. - -'getarg()' can also be used to carry information back from using the "callfunc" -script command, if the 'return' command is set to return a value: - - place.gat,50,50,6%TAB%script%TAB%Woman%TAB%115,{ - mes "[Woman]"; - mes "Lets see if you win"; - callfunc "funcNPC"; - mes "Well it seems you have "+getarg(0); - } - function%TAB%script%TAB%funcNPC%TAB%{ - set @win, rand(2); - if(@win==0) return(won); - return(lost); - } - -It is, however, better to use 'set' to get this value instead (see 'callfunc') -because otherwise you can't call functions from within other functions. (Return -values mess up the stack.) - ---------------------------------------- - *next; This command will create a 'next' button in the message window for the invoking @@ -1024,7 +968,109 @@ Don't expect things to run smoothly if you don't make your scripts 'end'. --------------------------------------- -*menu "<menu option>",<label>{,"<menu option>",<label>...}; +*end; + +This command will stop the execution for this particular script. The two +versions are prefectly equivalent. It is the normal way to end a script which +does not use 'mes'. + + if (BaseLevel<=10) goto L_Lvl10; + if (BaseLevel<=20) goto L_Lvl20; + if (BaseLevel<=30) goto L_Lvl30; + if (BaseLevel<=40) goto L_Lvl40; + if (BaseLevel<=50) goto L_Lvl50; + if (BaseLevel<=60) goto L_Lvl60; + if (BaseLevel<=70) goto L_Lvl70; + L_Lvl10: + npctalk "Look at that you are still a n00b"; + end; + L_Lvl20: + npctalk "Look at that you are getting better, but still a n00b"; + end; + L_Lvl30: + npctalk "Look at that you are getting there, you are almost 2nd profession now right???"; + end; + L_Lvl40: + npctalk "Look at that you are almost 2nd profession"; + end; + +Without the use if 'end' it would travel through the labels until the end of the +script. If you were lvl 10 or less, you would see all the speech lines, the use +of 'end' stops this, and ends the script. + +--------------------------------------- + +*set <variable>,<expression>; + +This command will set a variable to the value that the expression results in. +This is the only way to set a variable directly. + +This is the most basic script command and is uses a lot whenever you try to do +anything more advanced than just printing text into a messagebox. + + set @x,100; + +will make @x equal 100. + + set @x,1+5/8+9; + +will compute 1+5/8+9 (which is, surprisingly, 10 - remember, all numbers are +integer in this language) and make @x equal it. + +--------------------------------------- + +*setd "variable name",<value>; + +Works almost identical as set, just that the variable name is identified as a string, +thus can be constructed dynamically. + +Example: +set $var$, "Poring"; + +setd "$var$", "Poporing"; +mes $var$; // Will return Poporing + +setd "$" + $var$ + "123$", "Poporing is cool"; +mes $Poporing123$; // Will return Poporing is cool. + +--------------------------------------- + +*getd("<variable name>") + +Retrieves variable, name can be constructed dynamically. Refer to setd for usage. + +Example: +set @i, getd("$pikachu"); + +--------------------------------------- + +*getvariableofnpc <variable name>,<npc name>; + +Enables you to get a NPC variable (. prefix) from the given NPC. This can only be used to get . variables. +Example(s): + +//This will return the value or .var, note that this can't be used, since the value isn't catched. + getvariableofnpc .var,"A NPC"; + +//This will set the .v variable to the value of the A NPC's .var variable. + set .v,getvariableofnpc(.var,"A NPC"); + +--------------------------------------- + +*goto <label>; + +This command will make the script jump to a label, usually used in conjunction +with other command, such as "if", but often used on it's own. + + ... + goto Label; + mes "This will not be seen"; + Label: + mes "This will be seen"; + +--------------------------------------- + +*menu "<menu option>",<label>{,"<menu option>",<label>,...}; This command will create a selectable menu for the invoking character. Only one menu can be on screen at the same time. @@ -1104,9 +1150,9 @@ that should actually go into the menu based on your condition, and an array (Remember, arrays start with 0.) There's less of them than the possible menu items you've defined, but the menu command can handle the empty lines - only if they are last in the list, and if it's made this way, they are. Now comes a -dirty trick: // X is whatever the most menu items you expect to handle. +dirty trick: menu @menulist$[0],-,@menulist$[1],-,....@menulist$[<X>],-; This calls up a menu of all your items. Since you didn't copy some of the @@ -1152,194 +1198,24 @@ perfectly equivalent. --------------------------------------- -*rand(<number>{,<number>}); - -This function returns a number, randomly positioned between 0 and the number you -specify (if you only specify one) and the two numbers you specify if you give it -two. - -rand(10) would result in 0,1,2,3,4,5,6,7,8 or 9 - -rand(2,10) would result in 2,3,4,5,6,7,8,9 or 10 - ---------------------------------------- - -*warp "<map name>",<x>,<y>; - -This command will take the invoking character to the specifed map, and if -wanted, specified coordinates too, but these can be random. - - warp "place.gat",50,55; - -This would take them to X 50 Y 55 on the map called "place". If your X and Y -coordinates land on an unwalkable map square, it will send the warped character -to a random place. Same will happen if they are both zero: - - warp "place.gat",0,0; - -Notice that while warping people to coordinates 0,0 will normally get them into -a random place, it's not certain to always be so. Darned if I know where this is -actually coded, it might be that this happens because square 0,0 is unwalkable -on all official maps. If you're using custom maps, beware. - -There are also three special 'map names' you can use. - -"Random" will warp the player randomly on the current map. -"Save" and "SavePoint" will warp the player back to their savepoint. - ---------------------------------------- - -*areawarp "<from map name>",<x1>,<y1>,<x2>,<y2>,"<to map name>",<x3>,<y3>; - -This command is similar to 'warp', however, it will not refer to the invoking -character, but instead, all characters within a specified area, defined by the -x1/y1-x2/y2 square, will be warped. Nobody outside the area will be affected, -including the activating character, if they are outside the area. - - areawarp "place.gat",10,10,120,120,"place2.gat",150,150; - -Everyone that is in the area between X 10 Y 10 and X 120 Y 120, in a square -shape, on the map called "place", will be affected, and warped to "place2" X 150 -Y 150 - - areawarp "place.gat",10,10,120,120,"place2.gat",0,0; - -By using ,0,0; as the destination coordinates it will take all the characters in -the affected area to a random set of co-ordinates on "place2". - -Like 'warp', areawarp will also explicitly warp characters randomly into the -current map if you give the 'to map name' as "Random". - -See also 'warp'. - ---------------------------------------- - -*heal <hp>,<sp>; - -This command will heal a set amount of HP and/or SP on the invoking character. - - heal 30000,0; // This will heal 30,000 HP - heal 0,30000; // This will heal 30,000 SP - heal 300,300; // This will heal 300 HP and 300 SP - -This command just alters the hit points and spell points of the invoking -character and produces no other output whatsoever. - ---------------------------------------- - -*itemheal <hp>,<sp>; - -This command works on the invoking character like 'heal', however, it is not -normally used in NPC scripts and will not work as expected there, but is used -all over in item scripts. - -Unlike 'heal', which just alters hp/sp and doesn't do anything else at all, this -command also shows healing animations for potions and other stuff, checks -whether the potion was made by a famous alchemist and alters the amount healed, -etc, etc. Since which kind of effect is shown depends on what item was used, -using it in an NPC script will not have a desired effect. - -There is also a nice example on using this with the 'rand' function, to give you -a random ammount of healing. - - // This will heal anything thing from 100 to 150 HP and no SP - itemheal rand(100,150),0; - ---------------------------------------- - -*percentheal <hp>,<sp>; - -This command will heal the invoking character. It heals the character, but not -by a set value - it adds percent of their maximum HP/SP. - - percentheal 100,0; // This will heal 100% HP - percentheal 0,100; // This will heal 100% SP - percentheal 50,50; // This will heal 50% HP and 50% SP - -So the amount that this will heal will depend on the total ammount of HP or SP -you have maximum. Like 'heal', this will not call up any animations or effects. - ---------------------------------------- - -*jobchange <job number>{,<upper flag>}; - -This command will change the job class of the invoking character. - - jobchange 1; // This would change your player into a Swordman - jobchange 4002; // This would change your player into a Swordman High - -This command does work with numbers, but you can also use job names. The full -list of job names and the numbers they correspond to can be found in -'db/const.txt'. - - // This would change your player into a Swordman - jobchange Job_Swordman; - // This would change your player into a Swordman High - jobchange Job_Swordman_High; - -'upper flag' can alternatively be used to specify the type of job one changes -to. For example, jobchange Job_Swordman,1; will change the character to a high -swordsman. The upper values are: --1 (or when omitted): preserves the current job type. -0: Normal/standard classes -1: High/Advanced classes -2: Baby classes - -This command will also set a permanent character-based variable -'jobchange_level' which will contain the job level at the time right before -changing jobs, which can be checked for later in scripts. - ---------------------------------------- - -*jobname <job number> - -This command retrieves the name of the given job using the msg_athena entries 550->650. - - mes "[Kid]"; - mes "I never thought I'd met a "+jobname(Class)+" here of all places."; - close; - ---------------------------------------- - -*eaclass {<job number>} - -This commands returns the "eA job-number" corresponding to the given class (if none is given, it returns uses -the invoking player's class as argument). The eA job-number is also a class number system, but it's one that -comes with constants which make it easy to convert among classes. The command will return -1 if you pass it a -job number which doesn't has a eA Job value equivalent. - - set @eac, eaclass(); - if ((@eac&EAJ_BASEMASK) == EAJ_SWORDMAN) - mes "You must be a swordman, knight, crusader, paladin, high swordman, lord knight, baby swordman,"; - mes "baby knight or baby crusader."; - if (@eac&EAJL_UPPER) - mes "You are a rebirth job."; - if ((@eac&EAJ_UPPERMASK) == EAJ_SWORDMAN) - mes "You must be a Swordman, Baby Swordman or High Swordman."; +*select("<option>"{,"<option>"..."<option>"}) +*prompt("<option>"{,"<option>"..."<option>"}) -For more information on the eA Job System, see the docs/ea_job_system.txt file. +This function is a handy replacement for 'menu' for some specific cases where +you don't want a complex label structure - like, for example, asking simple yes- +no questions. It will return the number of menu option picked, starting with 1. +Like 'menu', it will also set the variable @menu to contain the option the user +picked. ---------------------------------------- -*roclass <job number> {,<gender>} + if (select("Yes","No")==1) mes "You said yes, I know."; -Does the opposite of eaclass. That is, given a eA Job class, it returns which is the corresponding RO class number. -A gender is required because both Bard and Dancers share the same eA Job value (EAJ_BARDDANCER), if it isn't given, the -gender of the executing player is taken (if there's no player running the script, male will be used by default). -The command returns -1 when there isn't a valid class to represent the required job (for example, if you try to get the -baby version of a Taekwon class). +And like 'menu', this command has a problem with empty strings - if some of the +option strings given to it are empty, you won't be able to tell which one the +user really picked. The number it returns will only make sense if all the empty +strings are last in the list of options. - set @eac, eaclass(); - //Check if class is already rebirth - if (@eac&EAJL_UPPER) { - mes "You look strong."; - close; - } - set @eac, roclass(@eac|EAJL_UPPER); - //Check if class has a rebirth version - if (@eac != -1) { - mes "Bet you can't wait to become a "+jobname(@eac)+"!"; - close; - } +prompt works almost the same as select, except that when a character clicks +the Cancel button, this function will return 255 instead. --------------------------------------- @@ -1389,198 +1265,235 @@ command quite a bit. --------------------------------------- -*setlook <look type>,<look value>; +*callfunc "<function>"{,<argument>,...<argument>}; +*callfunc("<function>"{,<argument>,...<argument>}) -This command will alter the look data for the invoking character. It is used -mainly for changing the palette used on hair and clothes, you specify which look -type you want to change, then the palette you want to use. Make sure you specify -a palette number that exists/is usable by the client you use. +This command lets you call up a function NPC. A function NPC can be called from +any script on any map server. Using the 'return' command it will come back to +the place that called it. - // This will change your hair(6), so that it uses palette 8, what ever your - // palette 8 is your hair will use that colour + place.gat,50,50,6%TAB%script%TAB%Woman%TAB%115,{ + mes "[Woman]" + mes "Lets see if you win"; + callfunc "funcNPC"; + mes "Well done you have won"; + close; + } + function%TAB%script%TAB%funcNPC%TAB%{ + set @win, rand(2); + if(@win==0) return; + mes "Sorry you lost"; + end; + } - setlook 6,8; +You can pass arguments to your function - values telling it what exactly to do - +which will be available there with getarg() (see 'getarg') +Notice that returning is not mandatory, you can end execution right there. - // This will change your clothes(7), so they are using palette 1, whatever - // your palette 1 is, your clothes will then use that set of colours. - - setlook 7,1; +If you want to return a real value from inside your function NPC, it is better +to write it in the function form, which will also work and will make the script +generally cleaner: -Here are the possible look types: - - 0 - Base sprite - 1 - Hairstyle - 2 - Weapon - 3 - Head bottom - 4 - Head top - 5 - Head mid - 6 - Hair color - 7 - Clothes color - 8 - Shield - 9 - Shoes + place.gat,50,50,6%TAB%script%TAB%Man%TAB%115,{ + mes "[Man]" + mes "Gimme a number!"; + next; + input @number; + if (callfunc("OddFunc",@number)) mes "It's Odd!"; + close; + } + function%TAB%script%TAB%OddFunc%TAB%{ + if (getarg(0)%2==0) goto ItsEven; + return (1); + ItsEven: + return (0); + } -Whatever 'shoes' means is anybody's guess, ask Gravity - the client does nothing -with this value. It still wants it from the server though, so it is kept, but -normally doesn't do a thing. - -Only the look data for hairstyle, hair color and clothes color are saved to the -char server's database and will persist. The rest freely change as the character -puts on and removes equipment, changes maps, logs in and out and otherwise you -should not expect to set them. In fact, messing with them is generally -hazardous, do it at your own risk, it is not tested what will this actually do - -it won't cause database corruption and probably won't cause a server crash, but -it's easy to crash the client with just about anything unusual. +--------------------------------------- -However, it might be an easy way to quickly check for empty view IDs for -sprites, which is essential for making custom headgear. +*callsub <label name>{,<argument>,...<argument>}; -Since a lot of people have different palettes for hair and clothes, it's -impossible to tell you what all the colour numbers are. If you want a serious -example, there is a Stylist script inside the default eAthena installation that -you can look at, this may help you create a Stylist of your own: -'custom\dye.txt' +This command will go to a specified label within the current script (do NOT use +quotes around it) coming in as if it were a 'callfunc' call, and pass it +arguments given, if any, which can be recovered there with 'getarg'. When done +there, you should use the 'return' command to go back to the point from where +this label was called. This is used when there is a specific thing the script +will do over and over, this lets you use the same bit of code as many times as +you like, to save space and time, without creating extra NPC objects which are +needed with 'callfunc'. A label is not callable in this manner from another +script. + mes "[Woman]" + mes "Lets see if you win"; + callsub Check; + mes "Well done you have won"; + Check: + set @win, rand(2); + if(@win==0) return; + mes "Sorry you lost"; + --------------------------------------- -*set <variable>,<expression>; +*getarg(<number>) -This command will set a variable to the value that the expression results in. -This is the only way to set a variable directly. +This function is used when you use the 'callsub' or 'callfunc' commands. In the +call you can specify variables that will make that call different from another +one. This function willwill return an argument the function or subroutine was +called with, and is the normal way to get them. +This is another thing that can let you use the same but of code more than once. -This is the most basic script command and is uses a lot whenever you try to do -anything more advanced than just printing text into a messagebox. +Argument numbering starts with 0, i.e. the first argument you gave is number 0. +If no such argument was given, a zero is returned. - set @x,100; - -will make @x equal 100. + place.gat,50,50,6%TAB%script%TAB%Woman1%TAB%115,{ + mes "[Woman]"; + mes "Lets see if you win"; + callfunc "funcNPC",2; + mes "Well done you have won"; - set @x,1+5/8+9; - -will compute 1+5/8+9 (which is, surprisingly, 10 - remember, all numbers are -integer in this language) and make @x equal it. + ... ---------------------------------------- + place.gat,52,50,6%TAB%script%TAB%Woman2%TAB%115,{ + mes "[Woman]"; + mes "Lets see if you win"; + callfunc "funcNPC",5; + mes "Well done you have won"; -*setarray <array name>[<first value>],<value>{,<value>...<value>}; + ... -This command will allow you to quickly fill up an array in one go. Check the -Kafra scripts in the distribution to see this used a lot. + function%TAB%script%TAB%funcNPC%TAB%{ + set @win, rand(getarg(0)); + if(@win==0) return; + mes "Sorry you lost"; - setarray @array[0], 100, 200, 300, 400, 500, 600; +"woman1" NPC object calls the funcNPC. The argument it gives in this call is +stated as 2, so when the random number is generated by the 'rand' function, it +can only be 0 or 1. Whereas "woman2" gives 5 as the argument number 0 when +calling the function, so the random number could be 0, 1, 2, 3 or 4, this makes +"woman2" less likely to say the player won. -First value is the index of the first element of the array to alter. For -example: +You can pass multiple arguments in a function call: - setarray @array[0],200,200,200; - setarray @array[1],300,150; - -will produce: + callfunc "funcNPC",5,4,3; - @array[0]=200 - @array[1]=300 - @array[2]=150 +getarg(0) would be 5, getarg(1) would be 4 and getarg(2) would be 3. ---------------------------------------- +'getarg()' can also be used to carry information back from using the "callfunc" +script command, if the 'return' command is set to return a value: -*cleararray <array name>[<first value to alter>],<value>,<number of values to set>; + place.gat,50,50,6%TAB%script%TAB%Woman%TAB%115,{ + mes "[Woman]"; + mes "Lets see if you win"; + callfunc "funcNPC"; + mes "Well it seems you have "+getarg(0); + } + function%TAB%script%TAB%funcNPC%TAB%{ + set @win, rand(2); + if(@win==0) return(won); + return(lost); + } + +It is, however, better to use 'set' to get this value instead (see 'callfunc') +because otherwise you can't call functions from within other functions. (Return +values mess up the stack.) -This command will change many array values at the same time to the same value. +--------------------------------------- - setarray @array[0], 100, 200, 300, 400, 500, 600; - // This will make all 6 values 0 - cleararray @array[0],0,6; - // This will make array element 0 change to 245 - cleararray @array[0],245,1; - // This will make elements 1 and 2 change to 345 - cleararray @array[1],345,2; +*return {(<value>)}; -See 'setarray'. +When you use callsub or callfunc, this command allows you to go back to the +calling script. You can optionally return with a value telling the calling +program what exactly happened. To get at this value, you will have to use the +'set' command: ---------------------------------------- + set <variable>,callfunc "<your function>" -*copyarray <to array>[<first value>],<from array>[<first value>],<amount to copy>; +Note the round brackets. Turns out you have to enclose just about anything in +brackets if it isn't a straight number for the return command to work with it: -This command lets you quickly shuffle a lot of data between arrays, which is in -some cases invaluable. + return (@x+@y); - setarray @array[0], 100, 200, 300, 400, 500, 600; - // So we have made @array[] - copyarray @array2[0],@array[2],2; - - // Now, @array2[0] will be equal to @array[2] (300) and - // @array2[1] will be equal to @array[3]. +Also note that -So using the examples above: - @array[0] = 100 - @array[1] = 200 - @array[2] = 300 - @array[3] = 400 - @array[4] = 500 - @array[5] = 600 + if (<condition>) return (<whatever>); - @array2[0] = 300 - @array2[1] = 400 - @array2[2] = 500 - @array2[3] = 0 +does NOT always work, even though it would make scripts a lot cleaner, and it +might be wiser to avoid using it like that. -Notice that @array[5] wont be coppied to the second array, and it will return a -0. +For an example see 'callfunc' and 'callsub' --------------------------------------- -*getarraysize(<array name>); - -This function returns the number of values that are contained inside the -specified array. Notice that zeros and empty strings at the end of this array -are not counted towards this number. - -For example: +*function <function name>; +*<function name>; +*function <function name> { +<code> +} - setarray @array[0], 100, 200, 300, 400, 500, 600; - set @arraysize,getarraysize(@array); +(Skotlex stop being so selfish and give us all the commands T~T! J/k lol :P) -This will make @arraysize == 6. But if you try this: +This works like callfunc, but doesn't support arguments like callfunc. It's used for cleaner +and fast script that doesn't require arguments for it to work. Also they must be inside a script. +They're not separated scripts and they work more like labels. - setarray @array[0], 100, 200, 300, 400, 500, 600, 0; - set @arraysize,getarraysize(@array); - -@arraysize will still equal 6, even though you've set 7 values. +Note it looks like the normal declaration ---------------------------------------- +Usage: -*deletearray <array name>[<first value>],<how much to delete> +You first Declare the function with function <function name>;. -This command will delete a specified number of array elements totally from an -array, shifting all the elements beyond this towards the beginning. +Put the rest of your code. You can use then <function name>; to call the function. If it returns a value is unsure, +test it if you want and give us some comments ;3 - // This will delete array element 0, and move all the other array elements - // up one place. - deletearray @array[0],1 +And at least, but inside the script itself, put the function <function name> {<code>}. -// This would delete array elements numbered 1, 2 and 3, leave element 0 in its -// place, and move the other elements ups, so there are no gaps. +Example: - deletearray @array[1],3 +prontera.gat,154,189,4 script Item seller 767,{ -IMPORTANT: deletarray is horribly broken since the earliest days of jAthena. It -tends to merrily remove much more variables than it's told to remove, which -makes it pretty much useless for anything other than removing an array from -memory entirely. This would be very handy, if it always worked. +function SF_Selling; ---------------------------------------- +mes "I'll open this now if you have more than 50z and you are level 50 or bigger"; +next; -*getelementofarray(<array name>,<index>); +if (Zeny > 50) && (BaseLevel > 50) { + mes "Welcome"; + next; + SF_Selling; + close; +} else -This function will return an array's element when given an index. +set @needed,50-BaseLevel; +mes "You either are Level "+BaseLevel+", thus you need "+@needed+" more levels"; +mes "to be able to use this npc; or you don't have enough zeny, so get some please"; +close; - // This will find the 2nd array value - getelementofarray(@array,1) +function SF_Selling { -Pretty pointless now when we have + mes "Would you like to buy a phracon for 50z?"; + switch(select("Yes","No, thanks")) { - @array[1] + case 1: + mes "Ok, how many?"; + input @quantity; + set @check,Zeny/50; + if (@quantity > @check) { + mes "Sorry but you can only have "+@check+" Phracons with "+Zeny; + close; + } else + next; + mes "here you have"; + set Zeny,Zeny-@quantity*50; + getitem 1010,@quantity; + close; + case 2: + mes "Good bye then"; + close; + } + } + return; +} -which has the same effect. --------------------------------------- @@ -1692,322 +1605,201 @@ Example 6: Using complex conditions. delitem 512,5; close; ---------------------------------------- - -*getitem <item id>,<amount>{,<character ID>}; -*getitem "<item name>",<amount>{,<character ID>}; - -This command will give a specific amount of specified items to the target -character. If the character is not online, nothing will happen. -If <character ID> is not specified, items will be created in the invoking -character inventory instead. - -In the first and most commonly used version of this command, items are -referred to by their database ID number found inside 'db/item_db.txt'. - - getitem 502,10 // The person will receive 10 apples - getitem 617,1 // The person will receive 1 Old Violet Box - -Giving an item ID of -1 will give a specified number of random items from the -list of those that fall out of Old Blue Box. Unlike in all other cases, these -will be unidentified, if they turn out to be equipment. This is exactly what's -written in the Old Blue Box's item script. - -Other negative IDs also correspond to other random item generating item tables: - -Giving an item ID of -2 will produce the effects of Old Violet Box. -Giving an item ID of -3 will produce the effects of Old Card Album. -Giving an item ID of -4 will produce the effects of Gift Box. -Giving an item ID of -5 will produce the effects of Worn Out Scroll, which, in -current SVN, drops only Jellopies anyway. - -This transaction is logged if the log script generated transactions option is -enabled. - -You may also create an item by it's name in the 'english name' field in the -item database: - - getitem "RED_POTION",10; - -Which will do what you'd expect. If it can't find that name in the database, -apples will be created anyway. It is often a VERY GOOD IDEA to use it like this. +With the Advanced scripting engine, we got nested if's. That is: + +if (<condition>) + dothis; +else + dothat; + +If the condition doesn't meet, it'll do the action following the else. +We can also group several actions depending on a condition, the following way: + +if (<condition) +{ + dothis1; + dothis2; + dothis3; +} else { + dothat1; + dothat2; + dothat3; + dothat4; +} -This is used in pretty much all NPC scripts that have to do with items and -quite a few item scripts. For more examples check just about any official script. +Remember that if you plan to do several actions upon the condition being false, and +you forget to use the curlies (the { } ), the second action will be executed regardless +the output of the condition, unless of course, you stop the execution of the script if the +condition is true (that is, in the first grouping using a return; , and end; or a close; ) + +Also, you can have multiple conditions nested or chained, and don't worry about limits as to +how many nested if you can have, there is no spoon ;) + +... +if (<condition 1>) + dothis; +else if (<condition 2>) +{ + dotheother; + do that; + end; +} else + do this; +... --------------------------------------- -*getitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>}; -*getitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>}; - -This command will give an amount of specified items to the invoking character. -If an optional character ID is specified, and that character is currently -online, items will be created in their inventory instead. If they are not -online, nothing will happen. It works essentially the same as 'getitem' (it even -works for negative ID numbers the same way, which is kinda silly) but is a lot -more flexible, since it allows you to give the player an item altered with it's -specific properties. +*jump_zero (<condition>),<label>; -Those parameters that are different from 'getitem' are: +This command works kinda like an 'if'+'goto' combination in one go. (See 'if'). +If the condition is false (equal to zero) this command will immediately jump to +the specified label like in 'goto'. -identify - Whether you want the item to be identified or not, 0 unidentified, - 1 identified. -refine - For how many plusses will it be refined. - It will not let you refine an item higher than +10, if you - specify more it'll still be 10. -attribute - Whether the item is broken (1) or not (0) and NOT an elemental - attribute. -card1,2,3,4 - If you want a card compound to it, place the card ID number into - the specific card slot. Card ID numbers also found in - 'db/item_db.txt' +While 'if' is more generally useful, for some cases this could be an +optimisation. -Card1-card4 values are also used to store name information for named items, as -well as the elemental property of weapons and armor. You can create a named item -in this manner, however, if you just need a named piece of standard equipment, -it is much easier to the 'getnameditem' function instead. +--------------------------------------- -You will need to keep these values if you want to destroy and then perfectly -recreate a named item, for this see 'getinventorylist'. +*setarray <array name>[<first value>],<value>{,<value>...<value>}; -If you still want to try creating a named item with this command because -'getnameditem' won't do it for you cause it's too limited, you can do it like -this. Careful, minor magic ahead. +This command will allow you to quickly fill up an array in one go. Check the +Kafra scripts in the distribution to see this used a lot. - // First, let's get an ID of a character who's name will be on the item. - // Only an existing character's name may be there. - // Let's assume our character is 'Adam' and find his ID. - - set @charid,getcharid(0,"Adam"); + setarray @array[0], 100, 200, 300, 400, 500, 600; - // Now we split the character ID number into two portions with a binary - // shift operation. If you don't understand what this does, just copy it. - - set @card3, @charid & 65535; - set @card4, @charid >> 16; +First value is the index of the first element of the array to alter. For +example: - // If you're inscribing non-equipment, @card1 must be 254. - // Arrows are also not equipment. :) - set @card1,254; - - // For named equipment, card2 means the Star Crumbs and elemental - // crystals used to make this equipment. For everything else, it's 0. - - set @card2,0; - - // Now, let's give the character who invoked the script some - // Adam's Apples: + setarray @array[0],200,200,200; + setarray @array[1],300,150; - getitem2 512,1,1,0,0,@card1,@card2,@card3,@card4; - -This wasn't tested with all possible items, so I can't give any promises, -experiment first before relying on it. - -To create equipment, continue this example it like this: +will produce: - // We've already have card3 and card4 loaded with correct - // values so we'll just set up card1 and card2 with data - // for an Ice Stiletto. + @array[0]=200 + @array[1]=300 + @array[2]=150 - // If you're inscribing equipment, @card1 must be 255. - set @card1,255; - - // That's the number of star crumbs in a weapon. - set @sc,2; - - // That's the number of elemental property of the weapon. - set @ele,1; +--------------------------------------- - // And that's the wacky formula that makes them into - // a single number. - set @card2,@ele+((@sc*5)<<8); +*cleararray <array name>[<first value to alter>],<value>,<number of values to set>; - // That will make us an Adam's +2 VVS Ice Stiletto: - - getitem2 1216,1,1,2,0,@card1,@card2,@card3,@card4; +This command will change many array values at the same time to the same value. -Experiment with the number of star crumbs - I'm not certain just how much will -work most and what it depends on. The valid element numbers are: + setarray @array[0], 100, 200, 300, 400, 500, 600; + // This will make all 6 values 0 + cleararray @array[0],0,6; + // This will make array element 0 change to 245 + cleararray @array[0],245,1; + // This will make elements 1 and 2 change to 345 + cleararray @array[1],345,2; - 1 - Ice, 2 - Earth 3 - Fire 4 - Wind. - -You can, apparently, even create duplicates of the same pet egg with this -command, creating a pet which is the same, but simultaneously exists in two -eggs, and may hatch from either, although, I'm not sure what kind of a mess will -this really cause. +See 'setarray'. --------------------------------------- -*groupranditem <group id>; -Returns the item_id of a random item picked from the group specified. The -different groups and their group number are specified in db/item_group_db.txt +*copyarray <destination array>[<first value>],<source array>[<first value>],<amount of data to copy>; -When used in conjunction with other functions, you can get a random item. For -example, for a random pet lure: - -getitem groupranditem(15),1; - ---------------------------------------- - -*makeitem <item id>,<amount>,<X>,<Y>,"<map name>"; -*makeitem "<item name>",<amount>,<X>,<Y>,"<map name>"; +This command lets you quickly shuffle a lot of data between arrays, which is in +some cases invaluable. -This command will create an item lying around on a specified map in the -specified location. + setarray @array[0], 100, 200, 300, 400, 500, 600; + // So we have made @array[] + copyarray @array2[0],@array[2],2; + + // Now, @array2[0] will be equal to @array[2] (300) and + // @array2[1] will be equal to @array[3]. - itemid - Found in 'db/item_db.txt' - amount - Amount you want produced - X - The X coordinate - Y - The Y coordinate - map name - The map name. +So using the examples above: + @array[0] = 100 + @array[1] = 200 + @array[2] = 300 + @array[3] = 400 + @array[4] = 500 + @array[5] = 600 + +New Array: + @array2[0] = 300 + @array2[1] = 400 + @array2[2] = 0 + @array2[3] = 0 -This item will still disappear just like any other dropped item. Like 'getitem', -it also accepts an 'english name' field from the database and creates apples if -the name isn't found. +Notice that @array[4] and @array[5] won't be copied to the second array, and it will return a +0. --------------------------------------- -*delitem <item id>,<amount>; -*delitem "<item name>",<amount>; - -This command will take a specified amount of items from the invoking character. -As all the item commands, this one uses the ID of the item found inside -'db/item_db.txt'. The items are destroyed - there is no way an NPC can simply -own items and have an inventory of them, other as by destroying and recreating -them when needed. - - delitem 502,10 // The person will lose 10 apples - delitem 617,1 // The person will lose 1 Old Violet Box +*deletearray <array name>[<first value>],<how much to delete> -It is always a good idea to to check if the player actually has the item before -you take it from them, Otherwise, you could try to delete items which the -players don't actually have, which won't fail and won't give an error message, -but might open up ways to exploit your script. +This command will delete a specified number of array elements totally from an +array, shifting all the elements beyond this towards the beginning. -Like 'getitem' this command will also accept an 'english name' field from the -database. If the name is not found, nothing will be deleted. + // This will delete array element 0, and move all the other array elements + // up one place. + deletearray @array[0],1 ---------------------------------------- +// This would delete array elements numbered 1, 2 and 3, leave element 0 in its +// place, and move the other elements ups, so there are no gaps. -*delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>}; -*delitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>}; + deletearray @array[1],3 -This command will take a specified amount of items from the invoking character. -Check 'getitem2' to understand its expanded parameters. +IMPORTANT: deletarray is horribly broken since the earliest days of jAthena. It +tends to merrily remove much more variables than it's told to remove, which +makes it pretty much useless for anything other than removing an array from +memory entirely. This would be very handy, if it always worked. --------------------------------------- -*enable_items; -*disable_items; - -These commands enable item usage while an npc is running. When enable_items is -run, items can be used during scripts until disable_items is called. -To avoid possible exploits, when enable_items is invoked, it will only enable -item usage while running that script in particular. Note that if a different -script also calls enable_items, it will override the last call (so you may -want to call this command at the start of your script without assuming the -effect is still in effect). - +====================================== +|2.- Information-retrieving commands.| +====================================== --------------------------------------- -*viewpoint <action>,<x>,<y>,<point number>,<color>; - -This command will mark places on the mini map in the client connected to the -invoking character. It uses the normal X and Y coordinates from the main map. -The colors of the marks are defined using a hexidecimal number, same as the ones -used to color text in 'mes' output, but are written as hexadecimal numbers in C. -(They look like 0x<six numbers>.) - -Action is what you want to do with a point, 1 will set it, while 2 will clear -it. Point number is the number of the point - you can have several. If more than -one point is drawn at the same coordinates, they will cycle, which can be used -to create flashing marks. - - // This command will show a mark at coordinates X 30 Y 40, is mark number 1, - // and will be red. - - viewpoint 1,30,40,1,0xFF0000; - -This will create three points: - - viewpoint 1,30,40,1,0xFF0000; - viewpoint 1,35,45,2,0xFF0000; - viewpoint 1,40,50,3,0xFF0000; +*strcharinfo(<type>) -And this is how you remove them: +This function will return either the name, party name or guild name for the +invoking character. Whatever it returns is determined by type. - viewpoint 2,30,40,1,0xFF0000; - viewpoint 2,35,45,2,0xFF0000; - viewpoint 2,40,50,3,0xFF0000; - -The client determines what it does with the points entirely, the server keeps no -memory of where the points are set whatsoever. + 0 - Character's name. + 1 - The name of the party they're in if any. + 2 - The name of the guild they're in if any. + +If a character is not a member of any party or guild, an empty string will be +returned when requesting that information. --------------------------------------- -*countitem(<item id>) -*countitem("<item name>") +*getarraysize(<array name>) -This function will return the number of items for the specified item ID that the -invoking character has in the inventory. +This function returns the number of values that are contained inside the +specified array. Notice that zeros and empty strings at the end of this array +are not counted towards this number. - mes "[Item Checker]"; - mes "Hmmm, it seems you have "+countitem(502)+" apples"; - close; +For example: -Like 'getitem', this function will also accept an 'english name' from the -database as an argument. + setarray @array[0], 100, 200, 300, 400, 500, 600; + set @arraysize,getarraysize(@array); -If you want to state the number at the end of a sentence, you can do it by -adding up strings: +This will make @arraysize == 6. But if you try this: - mes "[Item Checker]"; - mes "Hmmm, the total number of apples you are holding is "+countitem("APPLE"); - close; + setarray @array[0], 100, 200, 300, 400, 500, 600, 0; + set @arraysize,getarraysize(@array); ---------------------------------------- - -*countitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>) -*countitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>) - -Expanded version of 'countitem' function, used for created/carded/forged items. +@arraysize will still equal 6, even though you've set 7 values. -This function will return the number of items for the specified item ID and -other parameters that the invoking character has in the inventory. -Check 'getitem2' to understand the arguments of the function. - --------------------------------------- -*checkweight(<item id>,<amount>) -*checkweight("<item name>",<amount>) - -This function will compute and return 1 if the total weight of a specified -number of specific items does not exceed the invoking character's carrying -capacity, and 0 otherwise. It is important to see if a player can carry the -items you expect to give them, failing to do that may open your script up to -abuse or create some very unfair errors. - -Like 'getitem', this function will also accept an 'english name' from the -database as an argument. +*getelementofarray(<array name>,<index>) - checkweight(502,10) // 10 apples +This function will return an array's element when given an index. - if (checkweight(502,10) == 0 ) goto L_OverWeight; - getitem 502,10; - close; - L_OverWeight: - mes "Sorry you cannot hold this ammount of apples"; - close; + // This will find the 2nd array value + getelementofarray(@array,1) -Or to put this another way: +Pretty pointless now when we have - if (checkweight("APPLE",10)) goto L_Getapples; - mes "Sorry you cannot hold this ammount of apples"; - close; - L_Getapples: - getitem 502,10; - close; + @array[1] -Both these examples have the same effect. +which has the same effect. --------------------------------------- @@ -2077,6 +1869,34 @@ if (getcharid(2)) mes "Only members of a guild are allowed beyond this point!"; --------------------------------------- +*getchildid() +*getmotherid() +*getfatherid() + +These functions return the characters (shild/mother/father) ID + + if (getmotherid()) mes "Oh... I know your mother's ID:"+getmotherid(); + +--------------------------------------- + +*ispartneron() + +This function returns 1 if the invoking character's marriage partner is +currently online and 0 if they are not or if the character has no partner. + +--------------------------------------- + +*getpartnerid() + +This function returns the character ID of the invoking character's marriage +partner, if any. If the invoking character is not married, it will return 0, +which is a quick way to see if they are married: + + if (getpartnerid()) mes "I'm not going to be your girlfriend!"; + if (getpartnerid()) mes "You're married already!"; + +--------------------------------------- + *getpartyname(<party id>) This function will return the name of a party that has the specified ID number. @@ -2089,7 +1909,7 @@ Lets say the ID of a party was saved as a global variable: --------------------------------------- -*getpartymember <party id>,[<type>]; +*getpartymember <party id>,{<type>}; Thank you to HappyDenn for all this information. @@ -2153,7 +1973,7 @@ Example: --------------------------------------- -*getpartyleader <party id>,[<type>]; +*getpartyleader <party id>,{<type>}; This function returns some information about the given party-id's leader. When type is ommitted, the default information retrieved is the leader's name. @@ -2170,77 +1990,31 @@ If retrieval fails (leader not found or party does not exist), this function returns "null" instead of the character name, and -1 is for the other types. --------------------------------------- -*getguildname(<guild id>) - -This function returns a guild's name given an ID number. If there is no such -guild, "null" will be returned; - - // Would print what ever guild 10007 is, in my case this would return "AlcoROhics" - mes "The guild "+GetGuildName(10007)+" are all nice people."; - - // This will do the same as above: - set @var,10007; - mes "We have some friends in "+GetGuildName(@var)+", you know."; - -This is used all over the WoE controlling scripts. You could also use it for a -guild-based event. - ---------------------------------------- - -*getguildmaster(<guild id>) - -This function return the name of the master of the guild which has the specified -ID number. If there is no such guild, "null" will be returned. - -// Would return the guild master of guild 10007, whatever that might be. -// In this example it would return "MissDjax" cause she owns "AlcoROhics" (10007) - mes getguildmaster(10007)+" runs "+getguildname(10007); -Can be used to check if the character is the guildmaster of the specified guild. - -Maybe you want to make a room only guildmasters can enter: +*getlook(<type>) - set @GID,getcharid(2); - if(@GID==0) goto L_NoGuild; - if(strcharinfo(0)==getguildmaster(@GID)) goto L_GuildMaster; - mes "Sorry you don't own the guild you are in"; - close; - L_NoGuild: - mes "Sorry you are not in a guild"; - close; - L_GuildMaster: - mes "Welcome guild master of "+GetGuildName(@GID); - close; +This function will return the number for the currentcharacter look value +specified by type. See 'setlook' for valid look types. +This can be used to make a certain script behave differently for characters +dressed in black. :) --------------------------------------- -*guildchangegm(<guild id>,<new master's name>) -This function will change the Guild Master of a guild. The ID is the guild's -id, and the new guildmaster's name must be passed. - -Returns 1 on success, 0 otherwise. +*getsavepoint(<information type>) ---------------------------------------- -*getguildmasterid(<guild id>) +This function will return information about the invoking character's save point. +You can use it to let a character swap between several recorded savepoints. +Available information types are: -This function will return the character ID number of the guildmaster of the -guild specified by the ID. 0 if the character is not a guildmaster of any guild. + 0 - Map name (a string) + 1 - X coordinate + 2 - Y coordinate --------------------------------------- - -*strcharinfo(<type>) - -This function will return either the name, party name or guild name for the -invoking character. Whatever it returns is determined by type. - - 0 - Character's name. - 1 - The name of the party they're in if any. - 2 - The name of the guild they're in if any. - -If a character is not a member of any party or guild, an empty string will be -returned when requesting that information. - +\\ +2,2 Item-related commands +\\ --------------------------------------- *getequipid(<equipment slot>) @@ -2310,6 +2084,14 @@ See 'getequipid' for a full list of valid equipment slots. --------------------------------------- +*getitemname(<item id>) + +Given the database ID number of an item, this function will return the text +stored in the 'japanese name' field (which, in eAthena, stores an english name +the players would normally see on screen.) + +--------------------------------------- + *getbrokenid(<number>) This function will search the invoking character's inventory for any broken @@ -2326,17 +2108,6 @@ will return the second one, etc. Will return 0 if no such item is found. --------------------------------------- -*repair <broken item number>; - -This command repairs a broken peice of equipment, using the same list of broken -items as available through 'getbrokenid'. - -The official scripts seem to use the repair command as a function instead: -'repair(<number>)' but it returns nothing on the stack. Probably only Valaris, -who made it, can answer why is it so. - ---------------------------------------- - *getequipisequiped(<equipment slot>) This functions will return 1 if there is an equipment placed on the specified @@ -2372,17 +2143,6 @@ see 'getequipid'. --------------------------------------- -*getequipisidentify(<equipment slot>) - -This function will return 1 if an item in the specified equipment slot is -identified and 0 if it isn't. Since you can't even equip unidentified equipment, -there's a question of whether it can actually end up there, and it will normally -return 1 all the time if there is an item in this equipment slot. -Which is kinda pointless. -For a list of equipment slots see 'getequipid'. - ---------------------------------------- - *getequiprefinerycnt(<equipment slot>) Returns the current number of plusses for the item in the specified equipment @@ -2453,202 +2213,448 @@ random change of a refine succeeding or failing and then going through with it --------------------------------------- -*successrefitem <equipment slot>; +*getareadropitem("<map name>",<x1>,<y1>,<x2>,<y2>,<item>) -This command will refine an item in the specified equipment slot of the invoking -character by +1. For a list of equipment slots see 'getequipid'. This command -will not only add the +1, but also display a 'refine success' effect on the -character and put appropriate messages into their chat window. It will also give -the character fame points if a weapon reached +10 this way, even though these -will only take effect for blacksmith who will later forge a weapon. +This function will count all the items with the specified ID number lying on the +ground on the specified map within the x1/y1-x2/y2 square on it and return that +number. -The official scripts seem to use the 'successrefitem' command as a function -instead: 'successrefitem(<number>)' but it returns nothing on the stack. -This is since jAthena, so probably nobody knows for sure why is it so. +This is the only function around where a parameter may be either a string or a +number! If it's a number, it means that only the items with that item ID number +will be counted. If it is a string, it is assumed to mean the 'english name' +field from the item database. If you give it an empty string, or something that +isn't found from the item database, it will count items number '512' (apples). --------------------------------------- -*failedrefitem <equipment slot>; +*getequipcardcnt(<equipment slot>) -This command will fail to refine an item in the specified equipment slot of the -invoking character. The item will be destroyed. This will also display a 'refine -failure' effect on the character and put appropriate messages into their chat -window. +This function will return the number of cards that have been compounded onto a +specific equipped item for the invoking character. See 'getequipid' for a list +of possible equipment slots. -The official scripts seem to use the 'failedrefitem' command as a function -instead: 'failedrefitem(<number>)' but it returns nothing on the stack. This is -since jAthena, so probably nobody knows for sure why is it so. +--------------------------------------- + +*getinventorylist; + +This command sets a bunch of arrays with a complete list of whatever the +invoking character has in their inventory, including all the data needed to +recreate these items perfectly if they are destroyed. Here's what you get: + +@inventorylist_id[] - array of item ids. +@inventorylist_amount[] - their corresponding item amounts. +@inventorylist_equip[] - whether the item is equipped or not. +@inventorylist_refine[] - for how much it is refined. +@inventorylist_identify[] - whether it's refined. +@inventorylist_attribute[] - whether it is broken. +@inventorylist_card1[] - These four arrays contain card data for the items. +@inventorylist_card2[] These data slots are also used to store names +@inventorylist_card3[] inscribed on the items, so you can explicitly check +@inventorylist_card4[] if the character owns an item made by a specific + craftsman. +@inventorylist_count - the number of items in these lists. + +This could be handy to save/restore a character's inventory, since no other +command returns such a complete set of data, and could also be the only way to +correctly handle an NPC trader for carded and named items who could resell them +- since NPC objects cannot own items, so they have to store item data in +variables and recreate the items. +Notice that the variables this command generates are all local and numeric. --------------------------------------- -*cutin "<filename with no extension>",<position>; +*cardscnt() -This command will display a picture stored in the GRF file in the client for the -player. +This function will return the number of cards inserted into the weapon currently +equipped on the invoking character. +While this function was meant for item scripts, it will work outside them: -The files are taken from '\data\texture\A_A£AII’„AI«§\illust' directory in the -GRF file. The filename must be given with no extension, '.bmp' is added by the -client itself and you can't have any other picture format displayed as a cutin. -The biggest one that comes with the client is 400x503 pixels, and the smallest -is 303x493 pixels, it is not known how big a picture has to be before the client -goes insane. Bright magenta (color FF00FF) is considered to be transparent in -these pictures. You can easily add and alter them, but how to do this is outside -of the scope of this document. + if (cardscnt()==4) mes "So you've stuck four cards into that weapon, think you're cool now?"; -The position determines just where on screen the picture will appear: - 0 - bottom left corner - 1 - bottom middle - 2 - bottom right corner - 3 - middle of screen in a movable window with an empty title bar. - 4 - middle of screen without the window header, but still movable. - 255 - will remove the cutin previously displayed. - -Giving an empty string for the filename and 255 for the position will remove all -cutin pictures. Any other position value will not cause a script error but will -cause the player's client to curl up and die. Only one cutin may be on screen at -any given time, any new cutins will replace it. +--------------------------------------- - // This will display the picture of the 7th kafra, - // the one in orange and the mini-skirt :P - cutin "kafra_7",2; +*getrefine() - // This will remove the displayed picture. - cutin "Kafra_7",255; +This function will return the number of plusses the weapon currently equipped on +the invoking character has been refined for. +While this function was meant for item scripts, it will work outside them: - // This will remove all pictures displayed. - cutin "",255; + if (getrefine()==10) mes "Wow. That's a murder weapon."; -The client comes with those cutin pictures preinstalled which you can use: +--------------------------------------- -mets_alpha - This is a old fat man, holding a pipe, also with a pocket watch - and cane -pay_soldier - Wanna take a wild guess, thats right, the Soldiers that appear in - Payon :D -prt_soldier - Obvious -ein_soldier - This guy looks cool, you've got to see him ;) This picture is for - the new Einbroch guards -moc_soldier - Obvious -gef_soldier - Obvious -katsua01 - It is not certain who this girl is (There is no sprite coming with -katsua02 - the client that seems to match very well) but she is believed to -katsua03 - be an NPC in official Comodo. The three pictures give different - facial expressions. -kafra_01 - Obvious -kafra_02 - Obvious -kafra_03 - Obvious -kafra_04 - Obvious -kafra_05 - Obvious -kafra_06 - Obvious -kafra_07 - Do I need to mention this one again ;) +*getnameditem(<item id>,"<name to inscribe>"); +*getnameditem("<item name>","<name to inscribe>"); + +This function is equivalent to using 'getitem', however, it will not just give +the character an item object, but will also inscribe it with a specified +character's name. You may not inscribe items with arbitrary strings, only with +names of characters that actually exist. While this isn't said anywhere +specifically, apparently, named items may not have cards in them, slots or no - +these data slots are taken by the character ID who's name is inscribed. Only one +remains free and it's not quite clear if a card may be there. + +This function will return 1 if an item was successfully created and 0 if it +wasn't for whatever reason. Like 'getitem', this function will also accept an +'english name' from the item database as an item name and will return 0 if no +such item exists. --------------------------------------- -*cutincard <item id>; +*getitemslots(<item ID>) -This command will display a card picture as a cutin on the client connected to -the invoking character, with position number 4 (middle of screen, movable, but -no title bar). See 'cutin'. To remove this cutin, use the regular 'cutin' -command. Unlike the 'cutin' command, it will not take a filename, but will -instead take an item ID. It will then refer to the text file listing card images -which is normally found within your server's copy of the GRF file to find the -real (korean) filename. +This function will look up the item with the specified ID number in the database +and return the number of slots this kind of items has - 0 if they are not +slotted. It will also be 0 for all non-equippable items, naturally, unless +someone messed up the item database. It will return -1 if there is no such item. -If your server doesn't have that text file in that GRF or can't read it, it -probably won't work. +--------------------------------------- + +*getiteminfo(<item ID>,<type>) + +This function will look up the item with the specified ID number in the database +and return the info set by TYPE argument. +It will return -1 if there is no such item. + +Valid types are: + 0 - Buy Price; 1 - Sell Price; 2 - Item Type; + 3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc.. + if = 0, then monsters don't drop it at all (rare or a quest item) + if = 10000, then this item is sold in NPC shops only + 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range; + 10 - slot; 11 - look; 12 - elv; 13 - wlv; + +Check sample in nps\sample\getiteminfo.txt --------------------------------------- -*statusup <stat>; +*getequipcardid (<equipment slot>,<card slot>); -This command will bump a specified stat of the invoking character up by one -permanently. Stats are to be given as number, but you can use these constants to -replace them: +Returns value from equipped item slot in the indicated slot: -bStr - Strength -bVit - Vitality -bInt - Intelligence -bAgi - Agility -bDex - Dexterity -bLuk - Luck +getequipcardid(num,slot) + +where: + num = eqip position slot + slot = 0,1,2,3 (Card Slot N) + +This func returns CARD ID, 255,254,-255 (for card 0, if the item is produced) it's useful +when you want to check item cards or if it's signed. Useful for such quests as +"Sign this refined item with players name" etc; + Hat[0] +4 -> Player's Hat[0] +4 + +-------------------------------------- + +* getitemslots (<item id>); + +Returns the amount of slots the item has. +Example(s): + +//@slots now has the amount of slots of the item with ID 1205. + set @slots, getItemSlots(1205); + +-------------------------------------- +// +2,1.- End of item-related commands. +// --------------------------------------- -*statusup2 <stat>,<amount>; +*getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"}) -This command will bump a specified stat of the invoking character up by the -specified amount permanently. The amount can be negative. See 'statusup'. +This function will locate a character object, NPC object or pet's coordinates +and place their coordinates into the variables specified when calling it. It +will return 0 if the search was successful, and -1 if the parameters given were +not variables or the search was not successful. - // This will decrease a character's Vit forever. - statusup bVit,-1; +Type is the type of object to search for: + + 0 - Character object + 1 - NPC object + 2 - Pet object + 3 - Monster object. + +While 3 is meant to look for a monster object, no searching will be done if you +specify type 3, and the function will always return -1. + +The search string is optional. If it is not specified, the location of the +invoking character will always be returned for types 0 and 2, the location of +the NPC running this function for type 1. +If a search string is specified, for types 0 and 1, the character or NPC with +the specified name will be located. If type is 3, the search will locate the +current pet of the character who's name is given in the search string, it will +NOT locate a pet by name. + +What a mess. Example, a working and tested one now: + + prontera.gat,164,301,3%TAB%script%TAB%Meh%TAB%730,{ + mes "My name is Meh. I'm here so that Nyah can find me."; + close; + } + + prontera.gat,164,299,3%TAB%script%TAB%Nyah%TAB%730,{ + mes "My name is Nyah."; + mes "I will now search for Meh all across the world!"; + if (getmapxy(@mapname$,@mapx,@mapy,1,"Meh")!=0) goto Notfound; + mes "And I found him on map "+@mapname$+" at X:"+@mapx+" Y:"+@mapy+" !"; + close; + Notfound: + mes "I can't seem to find Meh anywhere!"; + close; + } + +Notice that NPC objects disabled with 'disablenpc' will still be located. --------------------------------------- -*bonus <bonus type>,<val1>; -*bonus2 <bonus type>,<val1>,<val2>; -*bonus3 <bonus type>,<val1>,<val2>,<val3>; -*bonus4 <bonus type>,<val1>,<val2>,<val3>,<val4>; +*getgmlevel() -These commands are meant to be used in item scripts. They will probably work -outside item scripts, but the bonus will not persist for long. They, as -expected, refer only to an invoking character. +This function will return the GM level of the account to which the invoking +character belongs. If this is somehow executed from a console command, 99 will +be returned, and 0 will be returned if the account has no GM level. -You can find the full list of possible bonuses and which command to use for each -kind in 'doc/item_bonus.txt'. +This allows you to make NPC's only accessable for certain GM levels, or behave +specially when talked to by GMs. + + if (getgmlevel()) mes "What is your command, your godhood?"; + if (getgmlevel()) goto Wherever; --------------------------------------- -*skill <skill id>,<level>{,<flag>}; -*addtoskill <skill id>,<level>{,<flag>} +*gettimetick(<tick type>) -These commands will give the invoking character a specified skill. This is also -used for item scripts. +This function will return the system time in UNIX epoch time (if tick type is 2) +or the time since the start of the current day in seconds if tick type is 1. +Passing 0 will make it return the server's tick, which is a measurement in +milliseconds used by the server's timer system. The server's tick is an +unsigned int which loops every ~50 days. -Level is obvious. Skill id is the ID number of the skill in question as per -'db/skill_db.txt'. It is not known for certain whether this can be used to give -a character a monster's skill, but you're welcome to try with the numbers given -in 'db/mob_skill_db.txt'. +Just in case you don't know, UNIX epoch time is the number of seconds elapsed +since 1st of January 1970, and is useful to see, for example, for how long the +character has been online with OnPCLoginEvent and OnPCLogoutEvent, which could allow +you to make an 'online time counted for conviction only' jail script. -Flag is 0 if the skill is given permanently (will get written with the character -data) or 1 if it is temporary (will be lost eventually, this is meant for card -item scripts usage.). The flag parameter is optional, and defaults to 1 in -'skill' and to 2 in 'addtoskill'. +--------------------------------------- -Flag 2 means that the level parameter is to be interpreted as a stackable -additional bonus to the skill level. If the character did not have that skill -previously, they will now at 0+the level given. +*gettime(<type>) -// This will permanently give the character Stone Throw (TF_THROWSTONE,152), at -// level 1. - skill 152,1,0; +This function will return specified information about the current system time. + +1 - Seconds (of a minute) +2 - Minutes (of an hour) +3 - Hour (of a day) +4 - Week day (0 for Sunday, 6 is Saturday) +5 - Day of the month. +6 - Number of the month. +7 - Year. +8 - Day of the year. + +It will only return numbers. + + if (gettime(4)==6) mes "It's a Saturday. I don't work on Saturdays."; --------------------------------------- -*guildskill <skill id>,<level> +*gettimestr(<format string>,<max length>) -This command will bump up the specified guild skill by the specified number of -levels. This refers to the invoking character and will only work if the invoking -character is a member of a guild AND it's guildmaster, otherwise no failure -message will be given and no error will occur, but nothing will happen - same -about the guild skill trying to exceed the possible maximum. The full list of -guild skills is available in 'db/skill_db.txt', these are all the GD_ skills at -the end. +This function will return a string containing time data as specified by the +format string. -The flag parameter is currently not functional and it's a mystery of what it -would actually do. (Though probably, like for character skills, it would allow -temporary bumping.) Using this command will bump the guild skill up permanently. +This uses the C function 'strfmtime', which obeys special format characters. For +a full description see, for example, the description of 'strfmtime' at +http://www.delorie.com/gnu/docs/glibc/libc_437.html +All the format characters given in there should properly work. +Max length is the maximum length of a time string to generate. -// This would give your character's guild one level of Approval (GD_APPROVAL ID -// 10000). Notice that if you try to add two levels of Approval, or add -// Approval when the guild already has it, it will only have one level of -// Approval afterwards. - guildskill 10000,1,0; +The example given in eAthena sample scripts works like this: -You might want to make a quest for getting a certain guild skill, make it hard -enough that all the guild needs to help or something. Doing this for the Glory -of the Guild skill, which allows your guild to use an emblem, is a good idea for -a fun quest. (Wasting a level point on that is really annoying :D) + mes gettimestr("%Y-%m/%d %H:%M:%S",21); + +This will print a full date and time like 'YYYY-MM/DD HH:MM:SS'. + +--------------------------------------- + +*getusers(<type>) + +This function will return a number of users on a map or the whole server. What +it returns is specified by Type. + +Type is a bitmask, add up to get the effects you want: + + 8 - This will count all characters on the same map as the current NPC. + (By default, it will count people on the same map as the character) + 7 - Return the amount of players for the entire server. + (By default, only the players on the map will be counted.) + +So 'getusers(0)' will return the number of characters on the same map as the +invoking character, while 'getusers(7)' will give the count for entire server. + +--------------------------------------- + +*getmapusers("<map name>") + +This function will return the number of users currently located on the specified +map. + +Currently being used in the PVP scripts to check if a PVP room is full of not, +if the number returned it equal to the maximum allowed it will not let you +enter. + +--------------------------------------- + +*getareausers("<map name>",<x1>,<y1>,<x2>,<y2>) + +This function will return the count of connected characters which are located +within the specified area - an x1/y1-x2/y2 square on the specified map. + +This is useful for maps that are split into many buildings, such as all the +"*_in.gat" maps, due to all the shops and houses. + +--------------------------------------- + +*getusersname; + +This command will give the invoking character a list of names of the connected +characters (including themselves) into an NPC script message window (see 'mes') +paging it by 10 names as if with the 'next' command. + +You need to put a 'close' after that yourself. + +--------------------------------------- +\\ +2,2.- Guild-related commands +\\ +--------------------------------------- +*getguildname(<guild id>) + +This function returns a guild's name given an ID number. If there is no such +guild, "null" will be returned; + + // Would print what ever guild 10007 is, in my case this would return "AlcoROhics" + mes "The guild "+GetGuildName(10007)+" are all nice people."; + + // This will do the same as above: + set @var,10007; + mes "We have some friends in "+GetGuildName(@var)+", you know."; + +This is used all over the WoE controlling scripts. You could also use it for a +guild-based event. + +--------------------------------------- + +*getguildmaster(<guild id>) + +This function return the name of the master of the guild which has the specified +ID number. If there is no such guild, "null" will be returned. + +// Would return the guild master of guild 10007, whatever that might be. +// In this example it would return "MissDjax" cause she owns "AlcoROhics" (10007) + mes getguildmaster(10007)+" runs "+getguildname(10007); + +Can be used to check if the character is the guildmaster of the specified guild. + +Maybe you want to make a room only guildmasters can enter: + + set @GID,getcharid(2); + if(@GID==0) goto L_NoGuild; + if(strcharinfo(0)==getguildmaster(@GID)) goto L_GuildMaster; + mes "Sorry you don't own the guild you are in"; + close; + L_NoGuild: + mes "Sorry you are not in a guild"; + close; + L_GuildMaster: + mes "Welcome guild master of "+GetGuildName(@GID); + close; + + +--------------------------------------- + +*getguildmasterid(<guild id>) + +This function will return the character ID number of the guildmaster of the +guild specified by the ID. 0 if the character is not a guildmaster of any guild. + +--------------------------------------- + +*getcastlename("<map name>") + +This function returns the name of the castle when given the map name for that +castle. The data is read from 'db/castle_db.txt'. + +--------------------------------------- + +*getcastledata("<map name>",<type of data>) +*setcastledata "<map name>",<type of data>,<value>; + +This function returns the castle ownership information for the castle referred +to by it's map name. Castle information stored in 'save\castle.txt' for the TXT +version of the server and in 'guild_castle' table for the SQL version. + +Valid types of data are: + + 0 - Will make the map server request the castle data from the char server, and + always return 0. This, apparently, will also cause indirectly the execution + of an 'OnAgitInit:' event mentioned at the beginning of this document. + 1 - Guild ID + 2 - Castle Economy score. + 3 - Castle Defence score. + 4 - Number of times the economy was invested in today. + 5 - Number of times the defence was invested in today. + 9 - Will return 1 if a Kafra was hired for this castle, 0 otherwise. +10 - Is 1 if the 1st guardian is present (Soldier Guardian) +11 - Is 1 if the 2nd guardian is present (Soldier Guardian) +12 - Is 1 if the 3rd guardian is present (Soldier Guardian) +13 - Is 1 if the 4th guardian is present (Archer Guardian) +14 - Is 1 if the 5th guardian is present (Archer Guardian) +15 - Is 1 if the 6th guardian is present (Knight Guardian) +16 - Is 1 if the 7th guardian is present (Knight Guardian) +17 - Is 1 if the 8th guardian is present (Knight Guardian) + +18-25 types of data will return current hit point values for guardians 1-8 +respectively. + +The 'setcastledata' command will behave identically, but instead of returning +values for the specified types of accessible data, it will alter them and cause +them to be sent to the char server for storage. Data type of 0 won't do +anything, obviously. + +--------------------------------------- + +*getgdskilllv(<guild id>,<skill id>) + +This function returns the level of the skill <skill id> of the guild <guild id>. +If the guild does not have that skill, 0 is returned. +If the guild does not exist, -1 is returned. +Refer to 'db/skill_db.txt' for the full list of skills. (GD_* are guild skills) + +--------------------------------------- + +*requestguildinfo <guild id>,"<event label>"; +This command requests the guild data from the char server and merrily continues +with the execution. Whenever the guild information becomes available (which +happens instantly if the guild information is already in memory, or later, if it +isn't and the map server has to wait for the char server to reply) it will run +the specified event as in a 'doevent' call. + +--------------------------------------- + +*getmapguildusers <mapname>,<guild id>; + +Returns the amount of persons from the given guild that are on the given map. +Example(s): + +//Will set the @persons variable to the amount of persons from the guild +//which ID's = 10 and are at prontera. + + set @persons,getMapGuildUsers "prontera.gat",10; + +--------------------------------------- +// +2,2.- End of guild-related commands +// --------------------------------------- *getskilllv(<skill id>) @@ -2684,70 +2690,200 @@ Example 2: --------------------------------------- -*getgdskilllv(<guild id>,<skill id>) +*getskilllist; -This function returns the level of the skill <skill id> of the guild <guild id>. -If the guild does not have that skill, 0 is returned. -If the guild does not exist, -1 is returned. -Refer to 'db/skill_db.txt' for the full list of skills. (GD_* are guild skills) +This command sets a bunch of arrays with a complete list of skills the +invoking character has. Here's what you get: + +@skilllist_id[] - skill ids. +@skilllist_lv[] - skill levels. +@skilllist_flag[] - see 'skill' for the meaning of skill flags. +@skilllist_count - number of skills in the above arrays. + +While 'getskillv' is probably more useful for most situations, this is the +easiest way to store all the skills and make the character something else for a +while. Advanced job for a day? :) This could also be useful to see how many +skills a character has. --------------------------------------- -*basicskillcheck() +*getpetinfo(<type>) -This function will return the state of the configuration option -'basic_skill_check' in 'battle_athena.conf'. It returns 1 if the option is -enabled and 0 if it isn't. If the 'basic_skill_check' option is enabled, which -it is by default, characters must have a certain number of basic skill levels to -sit, request a trade, use emoticons, etc. Making your script behave differently -depending on whether the characters must actually have the skill to do all these -things might in some cases be required. +This function will return pet information for the pet the invoking character +currently has active. Valid types are: + + 0 - Unique pet ID number as stored by the char server and distinguishing it + from all other pets the characters actually have. This value is currently + useless, at most you can use it to tell pets apart reliably. + 1 - Pet ID number as per 'db/pet_db.txt' - will tell you what kind of a pet it + is. + 2 - Pet name. Will return "null" if there's no pet. + 3 - Pet friendly level (intimacy score). 1000 is full loyalty. + 4 - Pet hungry level. 100 is completely full. --------------------------------------- -*getgmlevel() +*petstat(<flag>) -This function will return the GM level of the account to which the invoking -character belongs. If this is somehow executed from a console command, 99 will -be returned, and 0 will be returned if the account has no GM level. +Returns current pet status, all are integers except name. +Returns 0 or "" if the player doesn't have pets. -This allows you to make NPC's only accessable for certain GM levels, or behave -specially when talked to by GMs. +Flags usable >> +PET_CLASS +PET_NAME +PET_LEVEL +PET_HUNGRY +PET_INTIMATE + +Example: +set @i, petstat(PET_CLASS); - if (getgmlevel()) mes "What is your command, your godhood?"; - if (getgmlevel()) goto Wherever; --------------------------------------- -*end; +*getmonsterinfo(<item ID>,<type>) -This command will stop the execution for this particular script. The two -versions are prefectly equivalent. It is the normal way to end a script which -does not use 'mes'. +This function will look up the monster with the specified ID number in the database +and return the info set by TYPE argument. +It will return -1 if there is no such item. Due to specific of MOB DB routines, +it's better to check monster name. It'd return "Dummy" for a non-existing monster. - if (BaseLevel<=10) goto L_Lvl10; - if (BaseLevel<=20) goto L_Lvl20; - if (BaseLevel<=30) goto L_Lvl30; - if (BaseLevel<=40) goto L_Lvl40; - if (BaseLevel<=50) goto L_Lvl50; - if (BaseLevel<=60) goto L_Lvl60; - if (BaseLevel<=70) goto L_Lvl70; - L_Lvl10: - npctalk "Look at that you are still a n00b"; - end; - L_Lvl20: - npctalk "Look at that you are getting better, but still a n00b"; - end; - L_Lvl30: - npctalk "Look at that you are getting there, you are almost 2nd profession now right???"; - end; - L_Lvl40: - npctalk "Look at that you are almost 2nd profession"; - end; +Valid types are listed in const.txt: + MOB_NAME 0 MOB_LV 1 + MOB_MAXHP 2 MOB_BASEEXP 3 + MOB_JOBEXP 4 MOB_ATK1 5 + MOB_ATK2 6 MOB_DEF 7 + MOB_MDEF 8 MOB_STR 9 + MOB_AGI 10 MOB_VIT 11 + MOB_INT 12 JOB_DEX 13 + MOB_LUK 14 MOB_RANGE 15 + MOB_RANGE2 16 MOB_RANGE3 17 + MOB_SIZE 18 MOB_RACE 19 + MOB_ELEMENT 20 MOB_MODE 21 -Without the use if 'end' it would travel through the labels until the end of the -script. If you were lvl 10 or less, you would see all the speech lines, the use -of 'end' stops this, and ends the script. +Check sample in nps\sample\getmonsterinfo.txt + +--------------------------------------- + +*getmapmobs("<map name>") + +This function will return the total count of monsters currently located on the +specified map. If the map name is given as "this", the map the invoking +character is on will be used. If the map is not found, or the invoker is not a +character while the map is "this", it will return -1. + +--------------------------------------- + +*getstrlen("<string>") + +This function will return the length of the string given as an argument. It is +useful to check if anything input by the player exceeds name length limits and +other length limits and asking them to try to input something else. + +--------------------------------------- + +*skillpointcount; + +Returns the total amount of skill points a character posesses (SkillPoint+SP's used in skills) +This command can be used to check the currently attached characters total amount of skillpoints. +This means the skillpoints used in skill are counted, and added to SkillPoints (number of skill points not used). + +Example: + +//This will set the temp character variable @skillPoints to the amount of skillpoints, +//and then tell the player the value. + set @skillPoints, skillPointCount(); + mes "You have "+@skillPoints+" skillpoints in total!"; + +//Self-explanatory... :P + if (skillPointCount() > 20) + mes "Wow, you have more then 20 Skill Points in total!"; + +--------------------------------------- + +*getscrate(<effect type>,<base rate>{,<target ID number>}) + +This function will return the chance of a status effect affecting the invoking +character, in percent, modified by the their current defense against said +status. The 'base rate' is the base chance of the status effect being inflicted, +in percent. + + if (rand(100) > getscrate(Eff_Blind, 50)) goto BlindHimNow; + +You can see the full list of available effect types you can possibly inflict in +'db/const.txt' under 'Eff_'. + +It is pretty certain that addressing the target by an ID number will not +currently work due to a bug. + +--------------------------------------- + +======================== +|3.- Checking commands.| +======================== +------------------------- + +*playerattached; + +Returns the ID of the player currently attached to the script. It will return +0 if noone is attached, or if the attached player no longer exists on the map +server. It is wise to check for the attached player in script functions that +deal with timers as there's no guarantee the player will still be logged on +when the timer triggers. Note that the ID of a player is actually their +account ID. + +------------------------- + +*isloggedin(<character id>) + +This function returns 1 if the specified character is logged in and 0 if they +aren't. + +--------------------------------------- + +*checkweight(<item id>,<amount>) +*checkweight("<item name>",<amount>) + +This function will compute and return 1 if the total weight of a specified +number of specific items does not exceed the invoking character's carrying +capacity, and 0 otherwise. It is important to see if a player can carry the +items you expect to give them, failing to do that may open your script up to +abuse or create some very unfair errors. + +Like 'getitem', this function will also accept an 'english name' from the +database as an argument. + + checkweight(502,10) // 10 apples + + if (checkweight(502,10) == 0 ) goto L_OverWeight; + getitem 502,10; + close; + L_OverWeight: + mes "Sorry you cannot hold this ammount of apples"; + close; + +Or to put this another way: + + if (checkweight("APPLE",10)) goto L_Getapples; + mes "Sorry you cannot hold this ammount of apples"; + close; + L_Getapples: + getitem 502,10; + close; + +Both these examples have the same effect. + +--------------------------------------- + +*basicskillcheck() + +This function will return the state of the configuration option +'basic_skill_check' in 'battle_athena.conf'. It returns 1 if the option is +enabled and 0 if it isn't. If the 'basic_skill_check' option is enabled, which +it is by default, characters must have a certain number of basic skill levels to +sit, request a trade, use emoticons, etc. Making your script behave differently +depending on whether the characters must actually have the skill to do all these +things might in some cases be required. --------------------------------------- @@ -2863,6 +2999,252 @@ bird and 0 if they don't. --------------------------------------- +*checkvending ({"<player name>"}) +*checkchatting ({"<Player Name>"}) + +If the player's name is given, this command checks for that player +to be online and wether he/she is chatting or vending. +When no name is given, the attached player is used for checking. +Returns true or false (1 or 0) when the player is chatting/vending or not. + +Example(s): +if (checkVending("Aaron")) mes "Aaron is currently vending!"; + //This will check if Aaron is vending, and if so, put a message in front + //of the attached player saying Aaron is vending. + +if (checkChatting()) mes "You are currently chatting!"; + //This will check if you're in a chat room or not + +--------------------------------------- + +*agitcheck() + +This function will let you check whether the server is currently in WoE mode. +It will return 1 if the War of Emperium is on and 0 if it isn't. + +--------------------------------------- + +*isnight() +*isday() + +These functions will return 1 or 0 depending on whether the server is in night +mode or day mode. 'isnight' returns 1 if it's night and 0 if it isn't, 'isday' +the other way around. They can be used interchangeably, pick the one you like +more: + + // These two are equivalent: + if (isday()) mes "I only prowl in the night."; + if (isnight()!=1) mes "I only prowl in the night."; + +--------------------------------------- +\\ +3,1.- Item-related commands +\\ +--------------------------------------- +*isequipped(<id>{,<id>{,<id>{,<id>}}}) + +This function will return 1 if the invoking character has all of the item +IDs given equipped (if card IDs are passed, then it checks if the cards are +inserted into slots in the equipment they are currently wearing). Theorically +there is no limit to the number of items that may be tested for at the same time. +If even one of the items given is not equipped, 0 will be returned. + + // (Poring,Santa Poring,Poporing,Marin) + if (isequipped(4001,4005,4033,4196)) mes "Wow! You're wearing a full complement of possible poring cards!"; + // (Poring) + if (isequipped(4001)) mes "A poring card is useful, don't you think?"; + +The function was meant for item scripts to support the cards released by Gravity +in February 2005, but it will work just fine in normal NPC scripts. + +--------------------------------------- + +*isequippedcnt(<card id>{,<card id>{,<card id>{,<card id>}}}) + +This function is similar to 'isequipped', but instead of 1 or 0, it will return +the number of cards in the list given that were found on the invoking character. + + if (isequippedcnt(4001,4005,4033,4196)=4) mes "Finally got all four poring cards?"; + +--------------------------------------- + +*checkequipedcard(<card id>) + +This function will return 1 if the card specified by it's item ID number is +inserted into any equipment they have in their inventory, currently equipped or +not. + +--------------------------------------- + +*hasitems(0) + +This function will return 1 if the invoking character has anything at all in +their inventory and 0 if they do not. Even though the argument is not used for +anything, it is required. + +--------------------------------------- + +*getequipisidentify(<equipment slot>) + +This function will return 1 if an item in the specified equipment slot is +identified and 0 if it isn't. Since you can't even equip unidentified equipment, +there's a question of whether it can actually end up there, and it will normally +return 1 all the time if there is an item in this equipment slot. +Which is kinda pointless. +For a list of equipment slots see 'getequipid'. + +--------------------------------------- +// +3,1.- End of item-related commands +// +--------------------------------------- + +============================== +|4.- Player-related commands.| +============================== +------------------------- + +*attachrid(<character ID>) +*detachrid; + +A 'RID' is an ID of a character who caused the NPC script to run, as has been +explained above in the introduction section. Quite a bit of commands want a RID +to work, since they wouldn't know where to send information otherwise. And in +quite a few cases the script gets invoked with a RID of zero (like through +OnTime special labels). If an NPC script needs this, it can attach a specified +character's id to itself. by calling the 'attachrid' function. + +'attachrid' returns 1 if the character was found online and 0 if it wasn't. + +This could also be used, while running in a script invoked by a character +through talking to an NPC, to mess with other characters. +Detaching the RID will make the RID of the script zero. + +--------------------------------------- + +*rid2name(<rid>) + +Converts rid to name. Note: The player/monster/NPC must be online/enabled. +Good for PCKillEvent where you can convert 'killedrid' to the name of the player. + +Note: rid2name may not produce correct character names since rid = account id. + It will return the current online character of the account only. + +--------------------------------------- + +*message "<character name>","<message>"; + +That command will send a message to the chat window of the character specified +by name. The text will also appear above the head of that character. It will not +be seen by anyone else. + +--------------------------------------- + +*dispbottom "<message>"; + +This command will send the given message into the invoking character's chat +window. + +--------------------------------------- + +*warp "<map name>",<x>,<y>; + +This command will take the invoking character to the specifed map, and if +wanted, specified coordinates too, but these can be random. + + warp "place.gat",50,55; + +This would take them to X 50 Y 55 on the map called "place". If your X and Y +coordinates land on an unwalkable map square, it will send the warped character +to a random place. Same will happen if they are both zero: + + warp "place.gat",0,0; + +Notice that while warping people to coordinates 0,0 will normally get them into +a random place, it's not certain to always be so. Darned if I know where this is +actually coded, it might be that this happens because square 0,0 is unwalkable +on all official maps. If you're using custom maps, beware. + +There are also three special 'map names' you can use. + +"Random" will warp the player randomly on the current map. +"Save" and "SavePoint" will warp the player back to their savepoint. + +--------------------------------------- + +*areawarp "<from map name>",<x1>,<y1>,<x2>,<y2>,"<to map name>",<x3>,<y3>; + +This command is similar to 'warp', however, it will not refer to the invoking +character, but instead, all characters within a specified area, defined by the +x1/y1-x2/y2 square, will be warped. Nobody outside the area will be affected, +including the activating character, if they are outside the area. + + areawarp "place.gat",10,10,120,120,"place2.gat",150,150; + +Everyone that is in the area between X 10 Y 10 and X 120 Y 120, in a square +shape, on the map called "place", will be affected, and warped to "place2" X 150 +Y 150 + + areawarp "place.gat",10,10,120,120,"place2.gat",0,0; + +By using ,0,0; as the destination coordinates it will take all the characters in +the affected area to a random set of co-ordinates on "place2". + +Like 'warp', areawarp will also explicitly warp characters randomly into the +current map if you give the 'to map name' as "Random". + +See also 'warp'. + +--------------------------------------- + +*warpparty "<mapname.gat>",<x>,<y>,<party_id>; + +Warps a party to specified map and coordinate given the party ID, which you can get with +getcharid(1). You can also request another party id given a member's name with getcharid(1,<player_name>). + +Example: +mes "[Party Warper]"; +mes "Here you go!"; +close2; +set @id,getcharid(1); +warpparty "prontera.gat",150,100,@id; +close; + +--------------------------------------- + +*warpchar "<mapname.gat>",<x>,<y>,<char_id>; + +Warps another player to specified map and coordinate given the char id, which you can get with +getcharid(0,<player_name>). Obviously this is useless if you want to warp the same player that +is executing this script, unless it's some kind of "chosen" script. + +Example: + +warpchar "prontera.gat",150,100,20000001; + +--------------------------------------- + +*warpguild "<mapname.gat>",<x>,<y>,<guild_id>; + +Warps a guild to specified map and coordinate given the guild id, which you can get with +getcharid(2). You can also request another guild id given the member's name with getcharid(2,<player_name>). + +Example: + +warpguild "prontera.gat",x,y,Guild_ID; + +--------------------------------------- + +*warppartner("<map name>",<x>,<y>); + +This function will find the invoking character's marriage partner, if any, and +warp them to the map and coordinates given. Go kidnap that spouse. :) It will +return 1 upon success and 0 if the partner is not online, the character is not +married, or if there's no invoking character (no RID). 0,0 will, as usual, +normally translate to random coordinates. + +--------------------------------------- + *savepoint "<map name>",<x>,<y>; *save "<map name>",<x>,<y>; @@ -2876,87 +3258,548 @@ teleportation is otherwise possible. --------------------------------------- -*gettimetick(<tick type>) +*heal <hp>,<sp>; -This function will return the system time in UNIX epoch time (if tick type is 2) -or the time since the start of the current day in seconds if tick type is 1. -Passing 0 will make it return the server's tick, which is a measurement in -milliseconds used by the server's timer system. The server's tick is an -unsigned int which loops every ~50 days. +This command will heal a set amount of HP and/or SP on the invoking character. -Just in case you don't know, UNIX epoch time is the number of seconds elapsed -since 1st of January 1970, and is useful to see, for example, for how long the -character has been online with OnPCLoginEvent and OnPCLogoutEvent, which could allow -you to make an 'online time counted for conviction only' jail script. + heal 30000,0; // This will heal 30,000 HP + heal 0,30000; // This will heal 30,000 SP + heal 300,300; // This will heal 300 HP and 300 SP + +This command just alters the hit points and spell points of the invoking +character and produces no other output whatsoever. --------------------------------------- -*gettime(<type>) +*itemheal <hp>,<sp>; -This function will return specified information about the current system time. +This command works on the invoking character like 'heal', however, it is not +normally used in NPC scripts and will not work as expected there, but is used +all over in item scripts. -1 - Seconds (of a minute) -2 - Minutes (of an hour) -3 - Hour (of a day) -4 - Week day (0 for Sunday, 6 is Saturday) -5 - Day of the month. -6 - Number of the month. -7 - Year. -8 - Day of the year. +Unlike 'heal', which just alters hp/sp and doesn't do anything else at all, this +command also shows healing animations for potions and other stuff, checks +whether the potion was made by a famous alchemist and alters the amount healed, +etc, etc. Since which kind of effect is shown depends on what item was used, +using it in an NPC script will not have a desired effect. -It will only return numbers. +There is also a nice example on using this with the 'rand' function, to give you +a random ammount of healing. - if (gettime(4)==6) mes "It's a Saturday. I don't work on Saturdays."; + // This will heal anything thing from 100 to 150 HP and no SP + itemheal rand(100,150),0; --------------------------------------- -*gettimestr(<format string>,<max length>) +*percentheal <hp>,<sp>; -This function will return a string containing time data as specified by the -format string. +This command will heal the invoking character. It heals the character, but not +by a set value - it adds percent of their maximum HP/SP. -This uses the C function 'strfmtime', which obeys special format characters. For -a full description see, for example, the description of 'strfmtime' at -http://www.delorie.com/gnu/docs/glibc/libc_437.html -All the format characters given in there should properly work. -Max length is the maximum length of a time string to generate. + percentheal 100,0; // This will heal 100% HP + percentheal 0,100; // This will heal 100% SP + percentheal 50,50; // This will heal 50% HP and 50% SP -The example given in eAthena sample scripts works like this: +So the amount that this will heal will depend on the total ammount of HP or SP +you have maximum. Like 'heal', this will not call up any animations or effects. - mes gettimestr("%Y-%m/%d %H:%M:%S",21); - -This will print a full date and time like 'YYYY-MM/DD HH:MM:SS'. +--------------------------------------- + +*recovery; + +This command will revive and restore full HP and SP to all characters currently +connected to the server. --------------------------------------- -*openstorage; +*jobchange <job number>{,<upper flag>}; -This will open a character's Kafra storage window on the client connected to the -invoking character. It does not check wherever it is run from, so you can allow -any feasible NPC to open a kafra storage. (It's not certain whether this works -in item scripts, but if it does, it could be interesting.) +This command will change the job class of the invoking character. -The storage window might not open if a message box or a trade deal is present on -screen already, so you should at least make sure the message box is closed -before you open storage. + jobchange 1; // This would change your player into a Swordman + jobchange 4002; // This would change your player into a Swordman High - mes "I will now open your stash for you"; - close2; - openstorage; - end; +This command does work with numbers, but you can also use job names. The full +list of job names and the numbers they correspond to can be found in +'db/const.txt'. + + // This would change your player into a Swordman + jobchange Job_Swordman; + // This would change your player into a Swordman High + jobchange Job_Swordman_High; + +'upper flag' can alternatively be used to specify the type of job one changes +to. For example, jobchange Job_Swordman,1; will change the character to a high +swordsman. The upper values are: +-1 (or when omitted): preserves the current job type. +0: Normal/standard classes +1: High/Advanced classes +2: Baby classes + +This command will also set a permanent character-based variable +'jobchange_level' which will contain the job level at the time right before +changing jobs, which can be checked for later in scripts. --------------------------------------- -*guildopenstorage() +*jobname (<job number>) -This function works the same as 'openstorage' but will open a guild storage -window instead for the guild storage of the guild the invoking character belongs -to. This is a function because it returns a value - 0 if the guild storage was -opened successfully and 1 if it wasn't. (Notice, it's a ZERO upon success.) -Since guild storage is only accessible to one character at one time, it may fail -if another character is accessing the guild storage at the same time. +This command retrieves the name of the given job using the msg_athena entries 550->650. -This will also fail and return 2 if the character does not belong to any guild. + mes "[Kid]"; + mes "I never thought I'd met a "+jobname(Class)+" here of all places."; + close; + +--------------------------------------- + +*eaclass ({<job number>}) + +This commands returns the "eA job-number" corresponding to the given class (if none is given, it returns uses +the invoking player's class as argument). The eA job-number is also a class number system, but it's one that +comes with constants which make it easy to convert among classes. The command will return -1 if you pass it a +job number which doesn't has a eA Job value equivalent. + + set @eac, eaclass(); + if ((@eac&EAJ_BASEMASK) == EAJ_SWORDMAN) + mes "You must be a swordman, knight, crusader, paladin, high swordman, lord knight, baby swordman,"; + mes "baby knight or baby crusader."; + if (@eac&EAJL_UPPER) + mes "You are a rebirth job."; + if ((@eac&EAJ_UPPERMASK) == EAJ_SWORDMAN) + mes "You must be a Swordman, Baby Swordman or High Swordman."; + +For more information on the eA Job System, see the docs/ea_job_system.txt file. + +--------------------------------------- +*roclass <job number> {,<gender>} + +Does the opposite of eaclass. That is, given a eA Job class, it returns which is the corresponding RO class number. +A gender is required because both Bard and Dancers share the same eA Job value (EAJ_BARDDANCER), if it isn't given, the +gender of the executing player is taken (if there's no player running the script, male will be used by default). +The command returns -1 when there isn't a valid class to represent the required job (for example, if you try to get the +baby version of a Taekwon class). + + set @eac, eaclass(); + //Check if class is already rebirth + if (@eac&EAJL_UPPER) { + mes "You look strong."; + close; + } + set @eac, roclass(@eac|EAJL_UPPER); + //Check if class has a rebirth version + if (@eac != -1) { + mes "Bet you can't wait to become a "+jobname(@eac)+"!"; + close; + } + +--------------------------------------- + +*changebase <job ID number>; + +This will change the appearance of the invoking character to that of a specified +job class. Nothing but appearance will change. This command is used in item +scripts for "Wedding Dress" and "Tuxedo" so the character like job 22, which is +the job number of the wedding sprites. + +It would be entered in the equip bonus section of an item + +2338,Wedding_Dress,Wedding Dress,5,43000,,500,,0,,0,119529470,7,0,16,,0,1,0,{ bonus bMdef,15; changebase 22; } + +This command only works when inside item scripts. + +--------------------------------------- + +*classchange <view id>,<type>; + +This command is very ancient, it's origins are clouded in mystery. +It will send a 'display id change' packet to everyone in the immediate area of +the NPC object, which will supposedly make the NPC look like a different sprite, +an NPC sprite ID, or a monster ID. This effect is not stored anywhere and will +not persist (Which is odd, cause it would be relatively easy to make it do so) +and most importantly, will not work at all since this command was broken with +the introduction of advanced classes. The code is written with the assumption +that the lowest sprite IDs are the job sprites and the anything beyond them is +monster and NPC sprites, but since the advanced classes rolled in, they got the +ID numbers on the other end of the number pool where monster sprites float. + +As a result it is currently impossible to call this command with a valid view +id. It will do nothing whatsoever if the view ID is below 4047. Getting it to +run will actually just crash the client. + +It could be a real gem if it can be gotten to actually do what it's supposed to +do, but this will only happen in a later SVN revision. + +--------------------------------------- + +*changesex; + +This command will change the gender for the attached character's account. If it +was male, it will become female, if it was female, it will become male. The +change will be written to the character server, but there is no way to send this +information to the client, so the player will continue to see their character as +the gender it previously was. What the other players will see before the +relogin is not clear. + +If the character currently connected when this command was invoked was a +Dancer/Gypsy or Bard/Clown, they will become a Swordman upon 'changesex'. +Whatever happens to their skills is not clear. Whatever happens if another +character on the same account was a gender-specific class is not clear either, +but it's likely that the client will have serious issues with that, since no +other characters on the same account will get altered. + +There's good reasons to be very careful when using this command. + +--------------------------------------- + +*getexp <base xp>,<job xp>; + +This command will give the invoking character a specified number of base and job +experience points. Can be used as a quest reward. Negative amounts of experience +were not tested but should work. + + getexp 10000,5000; + +You can also use the "set" command with the constants defined in 'db/const.txt': + + // These 2 combined has the same effect as the above command + set BaseExp,BaseExp+10000; + set JobExp,JobExp+5000; + +You can also reduce the ammount of experience points: + + set BaseExp,BaseExp-10000; + +--------------------------------------- + +*setlook <look type>,<look value>; + +This command will alter the look data for the invoking character. It is used +mainly for changing the palette used on hair and clothes, you specify which look +type you want to change, then the palette you want to use. Make sure you specify +a palette number that exists/is usable by the client you use. + + // This will change your hair(6), so that it uses palette 8, what ever your + // palette 8 is your hair will use that colour + + setlook 6,8; + + // This will change your clothes(7), so they are using palette 1, whatever + // your palette 1 is, your clothes will then use that set of colours. + + setlook 7,1; + +Here are the possible look types: + + 0 - Base sprite + 1 - Hairstyle + 2 - Weapon + 3 - Head bottom + 4 - Head top + 5 - Head mid + 6 - Hair color + 7 - Clothes color + 8 - Shield + 9 - Shoes + +Whatever 'shoes' means is anybody's guess, ask Gravity - the client does nothing +with this value. It still wants it from the server though, so it is kept, but +normally doesn't do a thing. + +Only the look data for hairstyle, hair color and clothes color are saved to the +char server's database and will persist. The rest freely change as the character +puts on and removes equipment, changes maps, logs in and out and otherwise you +should not expect to set them. In fact, messing with them is generally +hazardous, do it at your own risk, it is not tested what will this actually do - +it won't cause database corruption and probably won't cause a server crash, but +it's easy to crash the client with just about anything unusual. + +However, it might be an easy way to quickly check for empty view IDs for +sprites, which is essential for making custom headgear. + +Since a lot of people have different palettes for hair and clothes, it's +impossible to tell you what all the colour numbers are. If you want a serious +example, there is a Stylist script inside the default eAthena installation that +you can look at, this may help you create a Stylist of your own: +'custom\dye.txt' + +--------------------------------------- +\\ +4,1.- Item-related commands +\\ +--------------------------------------- + +*getitem <item id>,<amount>{,<character ID>}; +*getitem "<item name>",<amount>{,<character ID>}; + +This command will give a specific amount of specified items to the target +character. If the character is not online, nothing will happen. +If <character ID> is not specified, items will be created in the invoking +character inventory instead. + +In the first and most commonly used version of this command, items are +referred to by their database ID number found inside 'db/item_db.txt'. + + getitem 502,10 // The person will receive 10 apples + getitem 617,1 // The person will receive 1 Old Violet Box + +Giving an item ID of -1 will give a specified number of random items from the +list of those that fall out of Old Blue Box. Unlike in all other cases, these +will be unidentified, if they turn out to be equipment. This is exactly what's +written in the Old Blue Box's item script. + +Other negative IDs also correspond to other random item generating item tables: + +Giving an item ID of -2 will produce the effects of Old Violet Box. +Giving an item ID of -3 will produce the effects of Old Card Album. +Giving an item ID of -4 will produce the effects of Gift Box. +Giving an item ID of -5 will produce the effects of Worn Out Scroll, which, in +current SVN, drops only Jellopies anyway. + +This transaction is logged if the log script generated transactions option is +enabled. + +You may also create an item by it's name in the 'english name' field in the +item database: + + getitem "RED_POTION",10; + +Which will do what you'd expect. If it can't find that name in the database, +apples will be created anyway. It is often a VERY GOOD IDEA to use it like this. + +This is used in pretty much all NPC scripts that have to do with items and +quite a few item scripts. For more examples check just about any official script. + +--------------------------------------- + +*getitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>}; +*getitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>}; + +This command will give an amount of specified items to the invoking character. +If an optional character ID is specified, and that character is currently +online, items will be created in their inventory instead. If they are not +online, nothing will happen. It works essentially the same as 'getitem' (it even +works for negative ID numbers the same way, which is kinda silly) but is a lot +more flexible, since it allows you to give the player an item altered with it's +specific properties. + +Those parameters that are different from 'getitem' are: + +identify - Whether you want the item to be identified or not, 0 unidentified, + 1 identified. +refine - For how many plusses will it be refined. + It will not let you refine an item higher than +10, if you + specify more it'll still be 10. +attribute - Whether the item is broken (1) or not (0) and NOT an elemental + attribute. +card1,2,3,4 - If you want a card compound to it, place the card ID number into + the specific card slot. Card ID numbers also found in + 'db/item_db.txt' + +Card1-card4 values are also used to store name information for named items, as +well as the elemental property of weapons and armor. You can create a named item +in this manner, however, if you just need a named piece of standard equipment, +it is much easier to the 'getnameditem' function instead. + +You will need to keep these values if you want to destroy and then perfectly +recreate a named item, for this see 'getinventorylist'. + +If you still want to try creating a named item with this command because +'getnameditem' won't do it for you cause it's too limited, you can do it like +this. Careful, minor magic ahead. + + // First, let's get an ID of a character who's name will be on the item. + // Only an existing character's name may be there. + // Let's assume our character is 'Adam' and find his ID. + + set @charid,getcharid(0,"Adam"); + + // Now we split the character ID number into two portions with a binary + // shift operation. If you don't understand what this does, just copy it. + + set @card3, @charid & 65535; + set @card4, @charid >> 16; + + // If you're inscribing non-equipment, @card1 must be 254. + // Arrows are also not equipment. :) + set @card1,254; + + // For named equipment, card2 means the Star Crumbs and elemental + // crystals used to make this equipment. For everything else, it's 0. + + set @card2,0; + + // Now, let's give the character who invoked the script some + // Adam's Apples: + + getitem2 512,1,1,0,0,@card1,@card2,@card3,@card4; + +This wasn't tested with all possible items, so I can't give any promises, +experiment first before relying on it. + +To create equipment, continue this example it like this: + + // We've already have card3 and card4 loaded with correct + // values so we'll just set up card1 and card2 with data + // for an Ice Stiletto. + + // If you're inscribing equipment, @card1 must be 255. + set @card1,255; + + // That's the number of star crumbs in a weapon. + set @sc,2; + + // That's the number of elemental property of the weapon. + set @ele,1; + + // And that's the wacky formula that makes them into + // a single number. + set @card2,@ele+((@sc*5)<<8); + + // That will make us an Adam's +2 VVS Ice Stiletto: + + getitem2 1216,1,1,2,0,@card1,@card2,@card3,@card4; + +Experiment with the number of star crumbs - I'm not certain just how much will +work most and what it depends on. The valid element numbers are: + + 1 - Ice, 2 - Earth 3 - Fire 4 - Wind. + +You can, apparently, even create duplicates of the same pet egg with this +command, creating a pet which is the same, but simultaneously exists in two +eggs, and may hatch from either, although, I'm not sure what kind of a mess will +this really cause. + +--------------------------------------- + +* getnameditem <item name|item id>,<Character name|character ID>; + +-Note: there's a total of 4 possible combinations of this command. +E.g: item name and character name, or with character id, etc... + +Create a item signed with the given character's name. +This is the same as using the hard(ly) explained way with getitem2. + +The command returns 1 when the item is created succesfully, or 0 when failed. +Failure occurs when there is: +- no player attached +- Item name or ID is not valid +- The given character ID/name is offline. + +Example: + +//This will give the currently attached player a Aaron's Apple (if Aaron is online). + getnameditem "Apple","Aaron"; + +//Self-explanatory (I hope). + if (getnameitem("Apple,"Aaron")) { + mes "You now have a Aaron's Apple!"; + } + +--------------------------------------- + +*makeitem <item id>,<amount>,<X>,<Y>,"<map name>"; +*makeitem "<item name>",<amount>,<X>,<Y>,"<map name>"; + +This command will create an item lying around on a specified map in the +specified location. + + itemid - Found in 'db/item_db.txt' + amount - Amount you want produced + X - The X coordinate + Y - The Y coordinate + map name - The map name. + +This item will still disappear just like any other dropped item. Like 'getitem', +it also accepts an 'english name' field from the database and creates apples if +the name isn't found. + +--------------------------------------- + +*delitem <item id>,<amount>; +*delitem "<item name>",<amount>; + +This command will take a specified amount of items from the invoking character. +As all the item commands, this one uses the ID of the item found inside +'db/item_db.txt'. The items are destroyed - there is no way an NPC can simply +own items and have an inventory of them, other as by destroying and recreating +them when needed. + + delitem 502,10 // The person will lose 10 apples + delitem 617,1 // The person will lose 1 Old Violet Box + +It is always a good idea to to check if the player actually has the item before +you take it from them, Otherwise, you could try to delete items which the +players don't actually have, which won't fail and won't give an error message, +but might open up ways to exploit your script. + +Like 'getitem' this command will also accept an 'english name' field from the +database. If the name is not found, nothing will be deleted. + +--------------------------------------- + +*delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>}; +*delitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>}; + +This command will take a specified amount of items from the invoking character. +Check 'getitem2' to understand its expanded parameters. + +--------------------------------------- + +*countitem(<item id>) +*countitem("<item name>") + +This function will return the number of items for the specified item ID that the +invoking character has in the inventory. + + mes "[Item Checker]"; + mes "Hmmm, it seems you have "+countitem(502)+" apples"; + close; + +Like 'getitem', this function will also accept an 'english name' from the +database as an argument. + +If you want to state the number at the end of a sentence, you can do it by +adding up strings: + + mes "[Item Checker]"; + mes "Hmmm, the total number of apples you are holding is "+countitem("APPLE"); + close; + +--------------------------------------- + +*countitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>) +*countitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>) + +Expanded version of 'countitem' function, used for created/carded/forged items. + +This function will return the number of items for the specified item ID and +other parameters that the invoking character has in the inventory. +Check 'getitem2' to understand the arguments of the function. + +--------------------------------------- + +*groupranditem <group id>; + +Returns the item_id of a random item picked from the group specified. The +different groups and their group number are specified in db/item_group_db.txt + +When used in conjunction with other functions, you can get a random item. For +example, for a random pet lure: + +getitem groupranditem(15),1; + +--------------------------------------- + +*enable_items; +*disable_items; + +These commands enable item usage while an npc is running. When enable_items is +run, items can be used during scripts until disable_items is called. +To avoid possible exploits, when enable_items is invoked, it will only enable +item usage while running that script in particular. Note that if a different +script also calls enable_items, it will override the last call (so you may +want to call this command at the start of your script without assuming the +effect is still in effect). --------------------------------------- @@ -2997,6 +3840,527 @@ Valid item levels are: --------------------------------------- +*successremovecards <equipment slot>; + +This command will remove all cards from the item found in the specified +equipment slot of the invoking character, create new card items and give them to +the character. If any cards were removed in this manner, it will also show a +success effect. + +--------------------------------------- + +*failedremovecards <equipment slot>,<type>; + +This command will remove all cards from the item found in the specified +equipment slot of the invoking character. 'type' determines what happens to the +item and the cards: + + 0 - will destroy both the item and the cards. + 1 - will keep the item, but destroy the cards. + 2 - will keep the cards, but destroy the item. + +Whatever the type is, it will also show a failure effect on screen. + +--------------------------------------- + +*repair <broken item number>; + +This command repairs a broken peice of equipment, using the same list of broken +items as available through 'getbrokenid'. + +The official scripts seem to use the repair command as a function instead: +'repair(<number>)' but it returns nothing on the stack. Probably only Valaris, +who made it, can answer why is it so. + +--------------------------------------- + +*successrefitem <equipment slot>; + +This command will refine an item in the specified equipment slot of the invoking +character by +1. For a list of equipment slots see 'getequipid'. This command +will not only add the +1, but also display a 'refine success' effect on the +character and put appropriate messages into their chat window. It will also give +the character fame points if a weapon reached +10 this way, even though these +will only take effect for blacksmith who will later forge a weapon. + +The official scripts seem to use the 'successrefitem' command as a function +instead: 'successrefitem(<number>)' but it returns nothing on the stack. +This is since jAthena, so probably nobody knows for sure why is it so. + +--------------------------------------- + +*failedrefitem <equipment slot>; + +This command will fail to refine an item in the specified equipment slot of the +invoking character. The item will be destroyed. This will also display a 'refine +failure' effect on the character and put appropriate messages into their chat +window. + +The official scripts seem to use the 'failedrefitem' command as a function +instead: 'failedrefitem(<number>)' but it returns nothing on the stack. This is +since jAthena, so probably nobody knows for sure why is it so. + + +--------------------------------------- + +*unequip <equipment slot>; + +This command will unequip whatever is currently equipped in the invoking +character's specified equipment slot. For a full list of possible equipment +slots see 'getequipid'. + +If an item occupies several equipment slots, it will get unequipped from all of +them. (Which is a good thing.) + +--------------------------------------- + +*clearitem; + +This command will destroy all items the invoking character has in their +inventory. (that includes equipped items) It will not affect anything else, like +storage or cart. + +--------------------------------------- + +*equip <item id>; +*autoEquip <item id>,<option>; + +These commands are to equip a equipment on the attached character. +The equip function will equip the item ID given when the player has +this item in his/her inventory, while the autoequip function will +equip the given item ID when this is looted. The option parameter of +the autoequip is 1 or 0, 1 to turn it on, and 0 to turn it off. + +Example(s): + +//This will equip a 1104 (falchion) on the character if this is in the inventory. + equip 1104; + +//The invoked character will now automatically equip a falchion when it's looted. + autoequip 1104,1; + +//The invoked character will no longer automatically equip a falchion. + autoequip 1104,0; + +--------------------------------------- +// +4,1.- End of item-related commands +// +--------------------------------------- + +*openstorage; + +This will open a character's Kafra storage window on the client connected to the +invoking character. It does not check wherever it is run from, so you can allow +any feasible NPC to open a kafra storage. (It's not certain whether this works +in item scripts, but if it does, it could be interesting.) + +The storage window might not open if a message box or a trade deal is present on +screen already, so you should at least make sure the message box is closed +before you open storage. + + mes "I will now open your stash for you"; + close2; + openstorage; + end; +--------------------------------------- +\\ +4,2.- Guild-related commands +\\ +--------------------------------------- + +*guildopenstorage() + +This function works the same as 'openstorage' but will open a guild storage +window instead for the guild storage of the guild the invoking character belongs +to. This is a function because it returns a value - 0 if the guild storage was +opened successfully and 1 if it wasn't. (Notice, it's a ZERO upon success.) +Since guild storage is only accessible to one character at one time, it may fail +if another character is accessing the guild storage at the same time. + +This will also fail and return 2 if the character does not belong to any guild. + +--------------------------------------- + +*guildchangegm(<guild id>,<new master's name>) + +This function will change the Guild Master of a guild. The ID is the guild's +id, and the new guildmaster's name must be passed. + +Returns 1 on success, 0 otherwise. + +--------------------------------------- + +*guildgetexp <amount>; + +This will give the specified amount of guild experience points to the guild the +invoking character belongs to. It will silently fail if they do not belong to +any guild. + +--------------------------------------- + +*guildskill <skill id>,<level> + +This command will bump up the specified guild skill by the specified number of +levels. This refers to the invoking character and will only work if the invoking +character is a member of a guild AND it's guildmaster, otherwise no failure +message will be given and no error will occur, but nothing will happen - same +about the guild skill trying to exceed the possible maximum. The full list of +guild skills is available in 'db/skill_db.txt', these are all the GD_ skills at +the end. + +The flag parameter is currently not functional and it's a mystery of what it +would actually do. (Though probably, like for character skills, it would allow +temporary bumping.) Using this command will bump the guild skill up permanently. + +// This would give your character's guild one level of Approval (GD_APPROVAL ID +// 10000). Notice that if you try to add two levels of Approval, or add +// Approval when the guild already has it, it will only have one level of +// Approval afterwards. + guildskill 10000,1,0; + +You might want to make a quest for getting a certain guild skill, make it hard +enough that all the guild needs to help or something. Doing this for the Glory +of the Guild skill, which allows your guild to use an emblem, is a good idea for +a fun quest. (Wasting a level point on that is really annoying :D) + +--------------------------------------- +// +4,2 End of guild-related commands. +// +--------------------------------------- + +*resetlvl <action type>; + +This is a character reset command, meant mostly for rebirth script supporting +Advanced jobs, which will reset the invoking character's stats and level +depending on the action type given. Valid action types are: + + 1 - Base level 1, Job level 1, 0 skill points, 0 base xp, 0 job xp, wipes the + status effects, sets all stats to 1. If the new job is 'Novice High', give + 100 status points, give First Aid and Play Dead skills. + 2 - Base level 1, Job level 1, 0 skill points, 0 XP/JXP. Skills and attribute + values are not altered. + 3 - Base level 1, base xp 0. Nothing else is changed. + 4 - Job level 1, job xp 0. Nothing else is changed. + +In all cases it will also unequip everything the character has on. + +Even though it doesn't return a value, it is used as a function in the official +rebirth scripts. Ask AppleGirl why. + +--------------------------------------- + +*resetstatus; + +This is a character reset command, which will reset the stats on the invoking +character and give back all the stat points used to raise them previously. +Nothing will happen to any other numbers about the character. + +Used in reset NPC's (duh!) + +--------------------------------------- + +*resetskill; + +This command takes off all the skill points on the invoking character, so they +only have Basic Skill blanked out (lvl 0) left, and returns the points for them +to spend again. Nothing else will change but the skills. Quest skills will also +reset if 'quest_skill_reset' option is set to Yes in 'battle_athena.conf'. If +the 'quest_skill_learn' option is set in there, the points in the quest skills +will also count towards the total. + +Used in reset NPC's (duh!) + +--------------------------------------- + +*sc_start <effect type>,<ticks>,<extra argument>{,<target ID number>}; +*sc_start2 <effect type>,<ticks>,<extra argument>,<percent chance>{,<target ID number>}; +*sc_start4 <effect type>,<ticks>,<value 1>,<value 2>,<value 3>,<value 4>{,<target ID number>}; +*sc_end <effect type>{,<target ID number>}; + +These command bestow a status effect on the invoking character. This command is +used a lot in the item scripts. + + // This would poison them for 10 min + sc_start SC_Poison,600000,0; + +Effect type is a number of effect, 'db/const.txt' lists the common (mostly +negative) status effect types as constants, starting with 'SC_'. You can also +use this to give someone an effect of a player-cast spell: + + // This will bless someone as if with Bless 10: + sc_start 10,240000,10; + +Extra argument's meaning differs depending on the effect type, for most effects +caused by a player skill the extra argument means the level of the skill that +would have been used to create that effect, for others it might have no meaning +whatsoever. You can actually bless someone with a 0 bless spell level this way, +which is fun, but weird. + +The target ID number, if given, will cause the status effect to appear on a +specified character, instead of the one attached to the running script. This has +not been properly tested. + +'sc_start2' is perfectly equivalent, but unlike 'sc_start', a status change +effect will only occur with a specified percentage chance. 10000 given as the +chance is equivalent to a 100% chance, 0 is a zero. + +'sc_start4' is just like sc_start, however it takes four parameters for the +status change instead of one. What these values are depends on the status +change in question. For example, elemental armor defense takes the following +four values: +- val1 is the first element, val2 is the resistance to the element val1. +- val3 is the second element, val4 is the resistance to said element. +eg: sc_start4 SC_DefEle,60000,Ele_Fire,20,Ele_Water,-15; + +'sc_end' will remove a specified status effect. If SC_All is used (-1), it will +do a complete removal of all statuses (although permanent ones will re-apply). + +You can see the full list of status effects caused by skills in +'src/map/status.h' - they are currently not fully documented, but most of that +should be rather obvious. + +--------------------------------------- + +*skilleffect <skill id>,<number>; + +This command will display the visual and sound effects of a specified skill (see +'db/skill_db.txt' for a full list of skills) on the invoking character's sprite. +Nothing but the special effects and animation will happen. If the skill's normal +effect displays a floating number, the number given will float up. + + // This will heal the character with 2000 hp, buff with + // Bless 10 and Increase AGI 5, and display appropriate + // effects. + mes "Blessed be!"; + skilleffect 28,2000; + heal 2000,0; + skilleffect 34,0; + // That's bless 10. + sc_start 10,240000,10; + skilleffect 29,0; + // That's agi 5 + sc_start 12,140000,5; + +--------------------------------------- + +*npcskilleffect <skill id>,<number>,<x>,<y>; + +This command behaves identically to 'skilleffect', however, the effect will not +be centered on the invoking character's sprite, nor on the NPC sprite, if any, +but will be centered at map coordinates given on the same map as the invoking +character. + +--------------------------------------- + +*specialeffect <effect number>; + +This command will display special effect with the given number, centered on the +specified NPCs coordinates, if any. For a full list of special effect numbers +known see 'doc/effect_list.txt'. Some effect numbers are known not to work in +some client releases. (Notably, rain is absent from any client executables +released after April 2005.) + +--------------------------------------- + +*specialeffect2 <effect number>; + +This command behaves identically to the 'specialeffect', but the effect will be +centered on the invoking character's sprite. + +--------------------------------------- + +*statusup <stat>; + +This command will bump a specified stat of the invoking character up by one +permanently. Stats are to be given as number, but you can use these constants to +replace them: + +bStr - Strength +bVit - Vitality +bInt - Intelligence +bAgi - Agility +bDex - Dexterity +bLuk - Luck + +--------------------------------------- + +*statusup2 <stat>,<amount>; + +This command will bump a specified stat of the invoking character up by the +specified amount permanently. The amount can be negative. See 'statusup'. + + // This will decrease a character's Vit forever. + statusup bVit,-1; + +--------------------------------------- + +*bonus <bonus type>,<val1>; +*bonus2 <bonus type>,<val1>,<val2>; +*bonus3 <bonus type>,<val1>,<val2>,<val3>; +*bonus4 <bonus type>,<val1>,<val2>,<val3>,<val4>; + +These commands are meant to be used in item scripts. They will probably work +outside item scripts, but the bonus will not persist for long. They, as +expected, refer only to an invoking character. + +You can find the full list of possible bonuses and which command to use for each +kind in 'doc/item_bonus.txt'. + +--------------------------------------- + +*skill <skill id>,<level>{,<flag>}; +*addtoskill <skill id>,<level>{,<flag>} + +These commands will give the invoking character a specified skill. This is also +used for item scripts. + +Level is obvious. Skill id is the ID number of the skill in question as per +'db/skill_db.txt'. It is not known for certain whether this can be used to give +a character a monster's skill, but you're welcome to try with the numbers given +in 'db/mob_skill_db.txt'. + +Flag is 0 if the skill is given permanently (will get written with the character +data) or 1 if it is temporary (will be lost eventually, this is meant for card +item scripts usage.). The flag parameter is optional, and defaults to 1 in +'skill' and to 2 in 'addtoskill'. + +Flag 2 means that the level parameter is to be interpreted as a stackable +additional bonus to the skill level. If the character did not have that skill +previously, they will now at 0+the level given. + +// This will permanently give the character Stone Throw (TF_THROWSTONE,152), at +// level 1. + skill 152,1,0; + +--------------------------------------- + +*nude; + +This command will unequip anything equipped on the invoking character. + +It is not required to do this when changing jobs since 'jobchange' will unequip +everything not equippable by the new job class anyway. + +--------------------------------------- + +*disguise <Monster ID>; +*undisguise; + +This command disgueses current player with a monster sprite. +The disguise is disappearing on re-login or on 'undisguise' command. + +Note: It doesn't work with "Pets with equipment on" +Note: If u're a Sniper, u'd get an old Falcon over your head +Note: You can kill yourself with some skills +Note: Monsters of your type could heal you + +Example: + +disquise 1002; //Yay! You're a Poring!!! +next; +undisquise; //Yay!!!! You're a human again!! + +--------------------------------------- +\\ +4,3 Marriage-related commands +\\ +--------------------------------------- +*marriage("<spouse name>"); + +This function will marry two characters, the invoking character and the one +referred to by name given, together, setting them up as each other's marriage +partner. No second function call has to be issued (in current SVN at least) to +make sure the marriage works both ways. The function returns 1 upon success, or +0 if the marriage could not be completed, either because the other character +wasn't found or because one of the two characters is already married. + +This will do nothing else for the marriage except setting up the spouse ID for +both of these characters. No rings will be given and no effects will be shown. + +--------------------------------------- + +*wedding; + +This command will call up wedding effects - the music and confetti - centered on +the invoking character. + +--------------------------------------- + +*divorce() + +This function will un-marry the invoking character from whoever they were +married to. Both will no longer be each other's marriage partner, (at least in +current SVN, which prevents the cases of multi-spouse problems). It will return +1 upon success or 0 if the character was not married at all. + +This function will also destroy both wedding rings and send a message to both +players, telling them they are now divorced. + +--------------------------------------- + +*adopt "<parent name>","<parent name>","<novice name>"; +*adopt("<parent name>","<parent name>","<novice name>") + +This command will set up a novice as a baby of a married couple. All three are +referred to by character name. The correct variables are set on all three +characters in the same call. The command will unequip anything the novice has +equipped and make them a Job_Baby class, as well as send them a 'your job has +been changed' message. + +Beware of calling this from inside a 'callfunc' function, cause upon successful +adoption, this command returns a zero, as if it were a function. This is likely +to screw up execution of a 'return' command. You may try to call it as a +function instead, but it doesn't return anything upon an error, which may also +cause script execution to throw up errors. + +Nothing will happen (and nothing will be returned either) if either future +parent is below base level 70 and/or if any of the three characters is not found +online. + +--------------------------------------- +// +4,3.- End of marriage-related commands +// +--------------------------------------- + +*pcfollow <id>,<target id>; +*pcstopfollow <id>; + +Makes a character follow or stop following someone. This command does the same as the @follow command. +The main difference is that @follow can use character names, and this commands needs the Account ID for the target. + +Example(s): + +//This will make Aaron follow Bullah, when both of these characters are online. + PCFollow getCharID(3,"Aaron"),getCharID(3,"Bullah"); + +//Makes Aaron stop following whoever he is following. + PCStopFollow getCharID(3,"Aaron"); + +--------------------------------------- + +* pcblockmove <id>,<option>; + +Prevents the given ID from moving when the option != 0, 0 enables the ID to move again. +ID should be able to be GID of a monster/npc or AID from a character. + +Example(s): + +//prevents the current char from moving away; + pcblockmove getcharid(3),1; + +//enables the current char to move again. + pcblockmove getcharid(3),0; + +--------------------------------------- + +================================== +|5.- Mob / NPC -related commands.| +================================== +--------------------------------------- + *monster "<map name>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>"}; *areamonster "<map name>",<x1>,<y1>,<x2>,<y2>,"<monster name>",<amount>{,"<event label>"}; @@ -3081,6 +4445,38 @@ This command will kill all monsters on a specified map name, regardless of how they were spawned or what they are. --------------------------------------- + +*strmobinfo(<type>,<monster id>); + +This function will return information about a monster record in the database, as +per 'db/mob_db.txt'. Type is the kind of information returned. Valid types are: + + 1 - 'english name' field in the database, a string. + 2 - 'japanese name' field in the database, a string. + All other returned values are numbers: + 3 - Level. + 4 - Maximum HP. + 5 - Maximum SP. + 6 - Experience reward. + 7 - Job experience reward. + +--------------------------------------- + +*mobcount("<map name>","<event label>") + +This function will count all the monsters on the specified map that have a given +event label and return the number or 0 if it can't find any. Naturally, only +monsters spawned with 'monster' and 'areamonster' script commands can be like +this. + +However, apparently, if you pass this function an empty string for the event +label, it should return the total count of normal permanently respawning +monsters instead. With the current dynamic mobs system, where mobs are not kept +in memory for maps with no actual people playing on them, this will return a 0 +for any such map. + +--------------------------------------- + *clone "<map name>",<x>,<y>,"<event>",<char id>{,<master_id>{,<mode>{,<flag>,<duration>}}} This command creates a monster which is a copy of another player. The first @@ -3105,6 +4501,192 @@ returned value is zero. --------------------------------------- +*summon "Monster name",<monster id>{,<Time Out>{,"event label"}}; + +This command will summon a monster. (see also 'monster') Unlike monsters spawned +with other commands, this one will set up the monster to fight to protect the +invoking character. Monster name and mob id obey the same rules as the one given +at the beginning of this document for permanent monster spawns with the +exceptions mentioned when describing 'monster' command. + +The effect for the skill 'Call Homonuculus' will be displayed centered on the +invoking character. + +Timeout is the time in milliseconds the summon lives, and is set default +to 60000 (1 minute). Note that also the value 0 will set the timer to default, +and it is not possible to create a spawn that lastst forever. +If an event label is given, upon the monster being killed, the event label will +run as if by 'donpcevent'. + +// Will summon a dead branch-style monster to fight for the character. +summon "--ja--",-1; + +--------------------------------------- + +* homunculus_evolution; + +This command will try to evolve the current player's homunculus. +If it doesn't work, the /swt emoticon is shown. + +To evolve a homunculus, the invoking player must have a homunculus, +the homunculus must not be the last evolution and +the homunculus must be on at least 91000/100000 intimacy with it's owner. + +--------------------------------------- +------------------------------------------------ +//===========================================\\ +|| Mob Control Suit Commands || +\\===========================================// +------------------------------------------------ + +--------------------------------------- + +* mobspawn (<monster name>,<monster ID>,<mapname>,<x>,<y>) +* mobRemove <GID>; + +This is used to spawn a monster and return it's Game ID, to be used +in the unit/mobcontrol commands. + +Note, I will use the stuff here in the examples for the unitcontrol. + +Example(s): + +//Spawns a poring named poi poi and put's it's GID in .GID. + set .GID,mobspawn("Poi Poi",1002,"prontera.gat",160,180); +//would kill our poring. + mobRemove .GID; + +--------------------------------------- + +* getmobdata (<GID>,<arrayname>) +* setmobdata <GID>,<parameter>,<new value>; + +This is used to get and set special data related to the monster. +With getmobdata, the array given will be filled with the current data. In setmobdata +the indexes in the array would be used to set that data on the monster. +Parameters (indexes) are: + +0 = class (big, small, normal) 7 = y 14 = hair style 21 = weapon +1 = level 8 = speed 15 = hair color 22 = shield (again) +2 = HP 9 = mode (see doc/mob_db_mode_list.txt) 16 = head gear bottom 23 = looking dir +3 = max HP 10 = special AI state (?) 17 = head gear middle 24 = killer state (1 or 0) +4 = master ID (aid of the master, summon) 11 = SC option 18 = head gear top 25 = callback flag +5 = map index 12 = sex 19 = cloth color 26 = no random walk (1 or 0) +6 = x 13 = class (Monster ID, Job ID) 20 = shield + +Example(s): + +//this will set all the mobdata in the @array variable. (@array[1] being level, @array[13] class etc) + getmobdata .GID,@array; + +//set the max hp of our poring to 1000. + setmobdata .GID,3,1000; + +--------------------------------------- + +* mobassist <GID>,<target id>; +This will make the monster assist the Target ID as if it was a summon of it. +Example(s): + +/this will make our poring assist the current attached player! >:3 + mobassist .GID,getcharid(3); + +--------------------------------------- + +* mobattach <GID>{,"<NPC Name>"}; + +GID is the GID of a monster, NPC or account id. The NPC running or +he NPC name given is used to attach the monster. + +By attaching a monster, the NPC to which it is attached is ran on special actions by the monster. +The system will set specific data in the .ai_action variable array on the NPC invoked. +The special AI actions types are set in the .ai_action at place AI_ACTION_TAR_TYPE + +More AI_ vars are set in const.txt, and you can also look at sample/monstercontroller.cpp: + +--------------------------------------- + +* unitwalk <GID>,<x>,<y>; +* unitwalk <GID>,<mapid>; + +This is one command, but can be used in two ways. If only the first argument is given, +the unit whose GID is given will start walking towards the map with the given mapid +(we believe these are the mapindexes found in db/map_index.txt). + +When 2 arguments are passed, the given unit will walk to the given x,y coordinates on +the map where the unit currently is. + +Example(s): + +//Will move/walk the poring we made to the coordinates 150,150 + unitwalk .GID,150,150; + +//Will move the poring towards alberta (if my assumed mapindexes are correct). + unitwalk .GID,3; + +--------------------------------------- + +* unitkill <GID>; +* unitwarp <GID>,<Mapname>,<x>,<y>; +* unitattack <GID>,<Target ID>; +* unitstop <GID>; +* unittalk <GID>,<Text>; +* unitemote <GID>,<Emote>; +* unitdeadsit <GID>,<Action?>; + +Okay, these commands should be fairly self explaining. + +For the emotions, you can look in db/const.txt for prefixes with e_ +The unitdeadsit uses an action, not exactly sure why it's named unitdeadsit... + +Anyhoo: actions are +0: normal attack +1: pick stone like +2: normal sit +3: nothing? + +--------------------------------------- + +------------------------------------------------ +//===========================================\\ +|| End of Mob Control Suit Commands || +\\===========================================// +------------------------------------------------ +--------------------------------------- + +*disablenpc "<NPC object name>"; +*enablenpc "<NPC object name>"; + +These two commands will disable and enable, respectively, an NPC object +specified by name. The disabled NPC will disappear from sight and will no longer +be triggerable in the normal way. It is not clear whether it will still be +accessible through 'donpcevent' and other triggering commands, but it probably +will be. You can disable even warp NPCs if you know their object names, which is +an easy way to make a map only accessible through walking half the time. Then +you 'enablenpc' them back. + +You can also use these commands to create the illusion of an NPC switching +between several locations, which is often better than actually moving the NPC - +create one NPC object with a visible and a hidden part to their name, make a few +copies, and then disable all except one. + +--------------------------------------- + +*hideonnpc "<NPC object name>"; +*hideoffnpc "<NPC object name>"; + +These commands will make the NPC object specified display as hidden/visible, +even though not actually disabled per se. Hidden as in thief Hide skill, but +unfortunately, not detectable by Ruwach or Sight. + +As they are now, these commands are pointless, it is suggested to use +'disablenpc'/'enablenpc', because these two commands actually unload the NPC +sprite location and other accompanying data from memory when it is not used. +However, you can use these for some quest ideas (such as cloaking npcs talking +while hidden then revealing.... you can wonder around =P + +--------------------------------------- + *doevent "<NPC object name>::<event label>"; This command will start a new execution thread in a specified NPC object at the @@ -3128,7 +4710,7 @@ invoked by the RID that was active in the script that issued a 'doevent'. --------------------------------------- -*donpcevent "<event label>"; +*donpcevent "{NPC NAME}::<event label>"; This command is kinda confusing cause it performs in two completely different ways. @@ -3171,6 +4753,22 @@ emotion will appear above each of their heads. --------------------------------------- +*npctalk "<message>"; + +This command will display a message to the surrounding area as if the NPC object +running it was a player talking - that is, above their head and in the chat +window. The display name of the NPC will get appended in front of the message to +complete the effect. + + // This will make everyone in the area see the NPC greet the character + // who just invoked it. + npctalk "Hello "+strcharinfo(0)+" how are you"; + +--------------------------------------- +\\ +5,1.- Time-related commands +\\ +--------------------------------------- *addtimer <ticks>,"<NPC object name>::<label>"; *deltimer "<NPC object name>::<event label>"; *addtimercount <ticks>,"<NPC object name>::<event label>"; @@ -3352,18 +4950,24 @@ Example 4: *sleep2 {<milliseconds>}; *awake "<NPC name>"; -Sleep Timers: -'sleep' and 'sleep2' pauses the execution of the script. -'sleep' detaches the player from the script and 'sleep2' doesn't. -'awake' forces all sleep queues on an NPC to execute. +These commands are used to control the pause of a NPC. +sleep and sleep2 will pause the script for the given amount of milliseconds. +Awake is used to cancel a sleep. When awake is callen on a NPC it will run as +if the sleep timer ran out, and thus making the script continue. Sleep and sleep2 +basically do the same, but the main difference is that sleep will not keep the rid, +while sleep2 does. - sleep 10000; // Sleep for 10 seconds, without player attached. - sleep2 5000; // Sleep for 5 seconds, with player attached. - awake "npc_name"; // Awakes the NPC. +Examples: + sleep 10000; //pause the script for 10 seconds and ditch the RID (so no player is attached anymore) + sleep2 5000; //pause the script for 5 seconds, and continue with the RID attached. + awake "NPC"; //Cancels any running sleep timers on the NPC 'NPC'. --------------------------------------- +// +5,1.- End of time-related commands +// -*announce "<text>",<flag>{,<color>} +*announce "<text>",<flag>{,<color>}; This command will broadcast a message to all or most players, similar to @kami/@kamib GM commands. @@ -3404,7 +5008,7 @@ but it can be used instead in NPCs to "preview" an announce. --------------------------------------- -*mapannounce "<map name>","<text>",<flag>[,<color>]; +*mapannounce "<map name>","<text>",<flag>{,<color>}; This command will work like 'announce' but will only broadcast to characters currently residing on the specified map. The flag and optional color @@ -3424,182 +5028,43 @@ related ones have effect. --------------------------------------- -*getusers(<type>) - -This function will return a number of users on a map or the whole server. What -it returns is specified by Type. - -Type is a bitmask, add up to get the effects you want: - - 8 - This will count all characters on the same map as the current NPC. - (By default, it will count people on the same map as the character) - 7 - Return the amount of players for the entire server. - (By default, only the players on the map will be counted.) - -So 'getusers(0)' will return the number of characters on the same map as the -invoking character, while 'getusers(7)' will give the count for entire server. - ---------------------------------------- - -*getmapusers("<map name>") - -This function will return the number of users currently located on the specified -map. - -Currently being used in the PVP scripts to check if a PVP room is full of not, -if the number returned it equal to the maximum allowed it will not let you -enter. - ---------------------------------------- - -*getareausers("<map name>",<x1>,<y1>,<x2>,<y2>) - -This function will return the count of connected characters which are located -within the specified area - an x1/y1-x2/y2 square on the specified map. - -This is useful for maps that are split into many buildings, such as all the -"*_in.gat" maps, due to all the shops and houses. - ---------------------------------------- - -*getareadropitem("<map name>",<x1>,<y1>,<x2>,<y2>,<item>) - -This function will count all the items with the specified ID number lying on the -ground on the specified map within the x1/y1-x2/y2 square on it and return that -number. - -This is the only function around where a parameter may be either a string or a -number! If it's a number, it means that only the items with that item ID number -will be counted. If it is a string, it is assumed to mean the 'english name' -field from the item database. If you give it an empty string, or something that -isn't found from the item database, it will count items number '512' (apples). - ---------------------------------------- - -*disablenpc "<NPC object name>"; -*enablenpc "<NPC object name>"; - -These two commands will disable and enable, respectively, an NPC object -specified by name. The disabled NPC will disappear from sight and will no longer -be triggerable in the normal way. It is not clear whether it will still be -accessible through 'donpcevent' and other triggering commands, but it probably -will be. You can disable even warp NPCs if you know their object names, which is -an easy way to make a map only accessible through walking half the time. Then -you 'enablenpc' them back. - -You can also use these commands to create the illusion of an NPC switching -between several locations, which is often better than actually moving the NPC - -create one NPC object with a visible and a hidden part to their name, make a few -copies, and then disable all except one. - ---------------------------------------- - -*hideonnpc "<NPC object name>"; -*hideoffnpc "<NPC object name>"; - -These commands will make the NPC object specified display as hidden/visible, -even though not actually disabled per se. Hidden as in thief Hide skill, but -unfortunately, not detectable by Ruwach or Sight. - -As they are now, these commands are pointless, it is suggested to use -'disablenpc'/'enablenpc', because these two commands actually unload the NPC -sprite location and other accompanying data from memory when it is not used. -However, you can use these for some quest ideas (such as cloaking npcs talking -while hidden then revealing.... you can wonder around =P - ---------------------------------------- - -*sc_start <effect type>,<ticks>,<extra argument>{,<target ID number>}; -*sc_start2 <effect type>,<ticks>,<extra argument>,<percent chance>{,<target ID number>}; -*sc_start4 <effect type>,<ticks>,<value 1>,<value 2>,<value 3>,<value 4>{,<target ID number>}; -*sc_end <effect type>{,<target ID number>}; - -These command bestow a status effect on the invoking character. This command is -used a lot in the item scripts. - - // This would poison them for 10 min - sc_start SC_Poison,600000,0; - -Effect type is a number of effect, 'db/const.txt' lists the common (mostly -negative) status effect types as constants, starting with 'SC_'. You can also -use this to give someone an effect of a player-cast spell: - - // This will bless someone as if with Bless 10: - sc_start 10,240000,10; - -Extra argument's meaning differs depending on the effect type, for most effects -caused by a player skill the extra argument means the level of the skill that -would have been used to create that effect, for others it might have no meaning -whatsoever. You can actually bless someone with a 0 bless spell level this way, -which is fun, but weird. - -The target ID number, if given, will cause the status effect to appear on a -specified character, instead of the one attached to the running script. This has -not been properly tested. - -'sc_start2' is perfectly equivalent, but unlike 'sc_start', a status change -effect will only occur with a specified percentage chance. 10000 given as the -chance is equivalent to a 100% chance, 0 is a zero. - -'sc_start4' is just like sc_start, however it takes four parameters for the -status change instead of one. What these values are depends on the status -change in question. For example, elemental armor defense takes the following -four values: -- val1 is the first element, val2 is the resistance to the element val1. -- val3 is the second element, val4 is the resistance to said element. -eg: sc_start4 SC_DefEle,60000,Ele_Fire,20,Ele_Water,-15; - -'sc_end' will remove a specified status effect. If SC_All is used (-1), it will -do a complete removal of all statuses (although permanent ones will re-apply). - -You can see the full list of status effects caused by skills in -'src/map/status.h' - they are currently not fully documented, but most of that -should be rather obvious. - ---------------------------------------- - -*getscrate(<effect type>,<base rate>{,<target ID number>}) - -This function will return the chance of a status effect affecting the invoking -character, in percent, modified by the their current defense against said -status. The 'base rate' is the base chance of the status effect being inflicted, -in percent. - - if (rand(100) > getscrate(Eff_Blind, 50)) goto BlindHimNow; - -You can see the full list of available effect types you can possibly inflict in -'db/const.txt' under 'Eff_'. - -It is pretty certain that addressing the target by an ID number will not -currently work due to a bug. - ---------------------------------------- - -*callshop "<shop name>",<flag>; +*callshop "<name>",<option>; -This command forces an npc shop to be invoked as if the player clicked on it. -With normal shops it will not work unless the player is within clicking range, -but the real use of this script command is together with "invisible shops", -which are specified in the same way an invisible npc would be specified. -For example, a generic invisible tool shop could be: +These are a series of commands used to create dynamic shops. +The callshop function calls a invisible shop (view -1) as if the player clicked on it. -- shop INVISIBLE_SHOP -,611:-1,1750:-1,501:-1,502:-1,503:-1,504:-1,506:-1 +For the options on callShop: + 0 = The normal window (buy, sell and cancel) + 1 = The buy window + 2 = The sell window + +Example(s): -Which players cannot click on, but can be invoked using: +callshop "DaShop",1; //Will call the shop named DaShop and opens the buy menu. -callshop "INVISIBLE_SHOP", 0; +The shop which is called by callshop (as long as an npcshop* command is executed +from that NPC (see note 1)) will trigger the labels OnBuyItem and OnSellitem. These +labels can take over handling for relatively the buying of items from the shop +and selling the items to a shop. Via these labels you can customize the way an item +is bought or sold by a player. -The flag values are: 1 invokes the buying window, 2 invokes the selling -window, any other value invokes the buy/sell dialogue. +In the OnBuyItem, two arrays are set (@bought_nameid and @bough_quantity), which +hold information about the name id (item id) sold and the amount sold of it. Same +goes for the OnSellItem label, only the variables are named different +(@sold_nameid and @sold_quantity). An example on a shop comes with eAthena, and +can be found in the npc/sample/npc_dynamic_shop.txt file. + +This example shows how to use the labels and their set variables to create a dynamic shop. -The function returns 1 on success, and the script is not automatically -closed, so be careful to not do any item trading on the same script to prevent -possible exploits (if possible, use close or close2 before invoking the shop -itself). +Note 1: These labels will only be triggered if a npcshop* command is executed, this is +because these commands set a special data on the shop npc,named master_nd in the source. +The OnSellItem and OnBuyItem are triggered in the NPC whose master_nd is given in the shop. +This was found out thanks to 'Hondacrx', noticing the OnBuyItem wasn't triggered unless +npcshopitem was used. After rechecking the source, I found what caused this. --------------------------------------- -*npcshopitem "<name>",<itemId>,<Price>{,<itemId>,<Price>{,<itemId>,<Price>{,...}}} +*npcshopitem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}} This command lets you override the contents of an existing npc shop. The current sell list will be wiped, and only the items specified with the price @@ -3611,7 +5076,7 @@ Note that you cannot use -1 to specify default selling price! --------------------------------------- -*npcshopadditem "<name>",<itemId>,<Price>{,<itemId>,<Price>{,<itemId>,<Price>{,...}}} +*npcshopadditem "<name>",<item id>,<price>{,<item id>,<price>{,<item id>,<price>{,...}}} This command will add more items at the end of the selling list for the specified npc shop. If you specify an item already for sell, that item will @@ -3623,7 +5088,7 @@ Note that you cannot use -1 to specify default selling price! --------------------------------------- -*npcshopdelitem "<name>",<itemId>{,<itemId>{,<itemId>{,...}}} +*npcshopdelitem "<name>",<item id>{,<item id>{,<item id>{,...}}} This command will remove items from the specified npc shop. If the item to remove exists more than once on the shop, all instances will be @@ -3652,117 +5117,6 @@ The function returns 0 if the shop was not found, 1 otherwise. --------------------------------------- -*debugmes "<message>"; - -This command will send the message to the server console (map-server window). It -will not be displayed anywhere else. - - debugmes strcharinfo(0)+" has just done this that and the other"; - // You would see in the map-server window "NAME has just done this that and - // the other" - ---------------------------------------- - -*pet <pet id>; - -This command is used in all the item scripts for taming items. Running this -command will make the pet catching cursor appear on the client connected to the -invoking character, usable on the monsters with the specified pet ID number. It -will still work outside an item script. - -A full list of pet IDs can be found inside 'db/pet_db.txt' - ---------------------------------------- - -*bpet; - -This command opens up a pet hatching window on the client connected to the -invoking character. It is used in item script for the pet incubators and will -let the player hatch an owned egg. If the character has no eggs, it will just -open up an empty incubator window. -This is still usable outside item scripts. - ---------------------------------------- - -*resetlvl <action type>; - -This is a character reset command, meant mostly for rebirth script supporting -Advanced jobs, which will reset the invoking character's stats and level -depending on the action type given. Valid action types are: - - 1 - Base level 1, Job level 1, 0 skill points, 0 base xp, 0 job xp, wipes the - status effects, sets all stats to 1. If the new job is 'Novice High', give - 100 status points, give First Aid and Play Dead skills. - 2 - Base level 1, Job level 1, 0 skill points, 0 XP/JXP. Skills and attribute - values are not altered. - 3 - Base level 1, base xp 0. Nothing else is changed. - 4 - Job level 1, job xp 0. Nothing else is changed. - -In all cases it will also unequip everything the character has on. - -Even though it doesn't return a value, it is used as a function in the official -rebirth scripts. Ask AppleGirl why. - ---------------------------------------- - -*resetstatus; - -This is a character reset command, which will reset the stats on the invoking -character and give back all the stat points used to raise them previously. -Nothing will happen to any other numbers about the character. - -Used in reset NPC's (duh!) - ---------------------------------------- - -*resetskill; - -This command takes off all the skill points on the invoking character, so they -only have Basic Skill blanked out (lvl 0) left, and returns the points for them -to spend again. Nothing else will change but the skills. Quest skills will also -reset if 'quest_skill_reset' option is set to Yes in 'battle_athena.conf'. If -the 'quest_skill_learn' option is set in there, the points in the quest skills -will also count towards the total. - -Used in reset NPC's (duh!) - ---------------------------------------- - -*changebase <job ID number>; - -This will change the appearance of the invoking character to that of a specified -job class. Nothing but appearance will change. This command is used in item -scripts for "Wedding Dress" and "Tuxedo" so the character like job 22, which is -the job number of the wedding sprites. - -It would be entered in the equip bonus section of an item - -2338,Wedding_Dress,Wedding Dress,5,43000,,500,,0,,0,119529470,7,0,16,,0,1,0,{ bonus bMdef,15; changebase 22; } - -This command only works when inside item scripts. - ---------------------------------------- - -*changesex; - -This command will change the gender for the attached character's account. If it -was male, it will become female, if it was female, it will become male. The -change will be written to the character server, but there is no way to send this -information to the client, so the player will continue to see their character as -the gender it previously was. What the other players will see before the -relogin is not clear. - -If the character currently connected when this command was invoked was a -Dancer/Gypsy or Bard/Clown, they will become a Swordman upon 'changesex'. -Whatever happens to their skills is not clear. Whatever happens if another -character on the same account was a gender-specific class is not clear either, -but it's likely that the client will have serious issues with that, since no -other characters on the same account will get altered. - -There's good reasons to be very careful when using this command. - ---------------------------------------- - *waitingroom "<chatroom name>",<limit>{,<event label>,<trigger>}; This command will create a chat room, owned by the NPC object running this @@ -3886,31 +5240,6 @@ releases. --------------------------------------- -*attachrid(<character ID>) -*detachrid - -A 'RID' is an ID of a character who caused the NPC script to run, as has been -explained above in the introduction section. Quite a bit of commands want a RID -to work, since they wouldn't know where to send information otherwise. And in -quite a few cases the script gets invoked with a RID of zero (like through -OnTime special labels). If an NPC script needs this, it can attach a specified -character's id to itself. by calling the 'attachrid' function. - -'attachrid' returns 1 if the character was found online and 0 if it wasn't. - -This could also be used, while running in a script invoked by a character -through talking to an NPC, to mess with other characters. -Detaching the RID will make the RID of the script zero. - ---------------------------------------- - -*isloggedin(<character id>) - -This function returns 1 if the specified character is logged in and 0 if they -aren't. - ---------------------------------------- - *setmapflagnosave "<map name>","<alternate map name>",<x>,<y>; This command sets the 'nosave' flag for the specified map and also gives an @@ -3919,7 +5248,7 @@ alternate respawn-upon-relogin point. It does not make a map impossible to make a savepoint on as you would normally think, 'savepoint' will still work. It will, however, make the specified map kick the reconnecting players off to the alternate map given to the coordinates -specified. + specified. --------------------------------------- @@ -3940,42 +5269,53 @@ mf_fireworks) and whether day/night will be in effect on this map (mf_indoors). --------------------------------------- -*removemapflag "<map name>",<flag>; +*setbattleflag "<battle flag>",<value>; +*getbattleflag "<battle flag>"; -This command removes a mapflag from a specified map. See 'setmapflag'. +Sets or gets the value of the given battle flag. +Battle flags are the flags found in the battle/*.conf files and is also used in Lupus' variable rates script. + +Example(s): + +//will set the base experience rate to 20x (2000%) + setBattleFlag "base_exp_rate",2000; + +//will return the value of the base experience rate (when used after the above example, it would return 2000). + getBattleFlag "base_exp_rate"; --------------------------------------- -*pvpon "<map name>"; -*pvpoff "<map name>"; +*removemapflag "<map name>",<flag>; -These commands will turn PVP mode for the specified maps on and off. Beside -setting the flags referred to in 'setmapflag', 'pvpon' will also create a PVP -timer and ranking as will @pvpon GM command do. +This command removes a mapflag from a specified map. See 'setmapflag'. --------------------------------------- -*gvgon "<map name>"; -*gvgoff "<map name>"; +*warpportal <x>,<y>,"<mapname>",<x>,<y>; -These commands will turn GVG mode for the specified maps on and off, setting up -appropriate map flags. In GVG mode, maps behave as if during the time of WoE, -even though WoE itself may or may not actually be in effect. +Creates a warp Portal as if a acolyte class character did it. +The first x and y is the place of the warp portal on the map where the NPC is on +The mapname and second x and y is the target area of the warp portal. ---------------------------------------- +Example(s): -*emotion <emotion number>{, target}; +//Will create a warp portal on the NPC's map at 150,150 leading to prontera, coords 150,180. + warpPortal 150,150,"prontera.gat",150,180; -This command makes an object display an emoticon sprite above their own as -if they were doing that emotion. For a full list of emotion numbers, -see 'db/const.txt' under 'e_'. The inobvious ones are 'e_what' (a question mark) -and 'e_gasp' (the exclamation mark). +--------------------------------------- -The optional target parameter specifies who will get the emotion on top of -their head. If 0 (the default if omitted), the NPC in current use will show -the emotion, if 1, the player that is running the script will display it. +*mapwarp "<from map>","<to map>",<x>,<y>; + +This command will collect all characters located on the From map and warp them +wholesale to the same point on the To map, or randomly distribute them there if +the coordinates are zero. "Random" is understood as a special To map name and +will mean randomly shuffling everyone on the same map. --------------------------------------- +\\ +5,2.- Guild-related Commands +\\ +--------------------------------------- *maprespawnguildid "<map name>",<guild id>,<flag>; @@ -4010,10 +5350,12 @@ in turn, are triggered by clock with an 'OnClock<time>:' time-triggering label. --------------------------------------- -*agitcheck() +*gvgon "<map name>"; +*gvgoff "<map name>"; -This function will let you check whether the server is currently in WoE mode. -It will return 1 if the War of Emperium is on and 0 if it isn't. +These commands will turn GVG mode for the specified maps on and off, setting up +appropriate map flags. In GVG mode, maps behave as if during the time of WoE, +even though WoE itself may or may not actually be in effect. --------------------------------------- @@ -4036,300 +5378,256 @@ returns a guild id: --------------------------------------- -*getcastlename("<map name>") +*guardian "<map name>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>"}{,<guardian index>}; -This function returns the name of the castle when given the map name for that -castle. The data is read from 'db/castle_db.txt'. +This command is roughly equivalent to 'monster', but is meant to be used with +castle guardian monsters and will only work with them. It will set the guardian +characteristics up according to the castle's investment values and otherwise +set the things up that only castle guardians need. --------------------------------------- -*getcastledata("<map name>",<type of data>) -*setcastledata "<map name>",<type of data>,<value>; - -This function returns the castle ownership information for the castle referred -to by it's map name. Castle information stored in 'save\castle.txt' for the TXT -version of the server and in 'guild_castle' table for the SQL version. - -Valid types of data are: - - 0 - Will make the map server request the castle data from the char server, and - always return 0. This, apparently, will also cause indirectly the execution - of an 'OnAgitInit:' event mentioned at the beginning of this document. - 1 - Guild ID - 2 - Castle Economy score. - 3 - Castle Defence score. - 4 - Number of times the economy was invested in today. - 5 - Number of times the defence was invested in today. - 9 - Will return 1 if a Kafra was hired for this castle, 0 otherwise. -10 - Is 1 if the 1st guardian is present (Soldier Guardian) -11 - Is 1 if the 2nd guardian is present (Soldier Guardian) -12 - Is 1 if the 3rd guardian is present (Soldier Guardian) -13 - Is 1 if the 4th guardian is present (Archer Guardian) -14 - Is 1 if the 5th guardian is present (Archer Guardian) -15 - Is 1 if the 6th guardian is present (Knight Guardian) -16 - Is 1 if the 7th guardian is present (Knight Guardian) -17 - Is 1 if the 8th guardian is present (Knight Guardian) - -18-25 types of data will return current hit point values for guardians 1-8 -respectively. +*guardianinfo(<guardian number>) -The 'setcastledata' command will behave identically, but instead of returning -values for the specified types of accessible data, it will alter them and cause -them to be sent to the char server for storage. Data type of 0 won't do -anything, obviously. +This function will return the current hit point value for the specified guardian +number, if such guardian is currently installed. This function will only work if +the invoking character is on a castle map, and will refer only to the guardians +of that castle, regardless of anything else, i.e. whether the character is a +member of the guild owning the castle, etc, etc. +If no guardian is installed in this slot, the function will return -1. --------------------------------------- - -*requestguildinfo <guild id>,"<event label>"; - -This command requests the guild data from the char server and merrily continues -with the execution. Whenever the guild information becomes available (which -happens instantly if the guild information is already in memory, or later, if it -isn't and the map server has to wait for the char server to reply) it will run -the specified event as in a 'doevent' call. - +// +5,2.- End of guild-related commands +// --------------------------------------- -*getequipcardcnt(<equipment slot>) +*npcspeed <speed value>; +*npcwalkto <x>,<y>; +*npcstop; -This function will return the number of cards that have been compounded onto a -specific equipped item for the invoking character. See 'getequipid' for a list -of possible equipment slots. +These commands will make the NPC object in question move around the map. As they +currently are, they are a bit buggy and are not useful for much more than making +an NPC move randomly around the map. (see 'npc/custom/devnpc.txt' for an example +of such usage) ---------------------------------------- +'npcspeed' will set the NPCs walking speed to a specified value. As in the +@speed GM command, 200 is the slowest possible speed while 0 is the fastest +possible (instant motion). 100 is the default character walking speed. +'npcwalkto' will start the NPC sprite moving towards the specified coordinates +on the same map as it is currently on. +'npcstop' will stop the motion. -*successremovecards <equipment slot>; +While in transit, the NPC will be clickable, but invoking it will cause it to +stop motion, which will make it's coordinates different from what the client +computed based on the speed and motion coordinates. The effect is rather +unnerving. -This command will remove all cards from the item found in the specified -equipment slot of the invoking character, create new card items and give them to -the character. If any cards were removed in this manner, it will also show a -success effect. +Only a few NPC sprites have walking animations, and those that do, do not get +the animation invoked when moving the NPC, due to the problem in the npc walking +code, which looks a bit silly. You might have better success by defining a job- +sprite based sprite id in 'db/mob-avail.txt' with this. --------------------------------------- -*failedremovecards <equipment slot>,<type>; - -This command will remove all cards from the item found in the specified -equipment slot of the invoking character. 'type' determines what happens to the -item and the cards: - - 0 - will destroy both the item and the cards. - 1 - will keep the item, but destroy the cards. - 2 - will keep the cards, but destroy the item. - -Whatever the type is, it will also show a failure effect on screen. - ---------------------------------------- +*movenpc <NPC name>,x,y; -*marriage("<spouse name>"); +This command looks like the NPCWalkToxy function,but is a little different. -This function will marry two characters, the invoking character and the one -referred to by name given, together, setting them up as each other's marriage -partner. No second function call has to be issued (in current SVN at least) to -make sure the marriage works both ways. The function returns 1 upon success, or -0 if the marriage could not be completed, either because the other character -wasn't found or because one of the two characters is already married. +While NPCWalkToXY just makes the NPC 'walk' to the coordinates given +(which sometimes gives problems if the path isn't a straight line without objects), +this command just moves the NPC. It basically warps out and in on the current and given spot. -This will do nothing else for the marriage except setting up the spouse ID for -both of these characters. No rings will be given and no effects will be shown. +Example(s): +//This will move Bugga from it's current position to the coords 100,20 (if those coords are walkable (legit)). + moveNPC "Bugga",100,20; + --------------------------------------- -*wedding; - -This command will call up wedding effects - the music and confetti - centered on -the invoking character. - +===================== +|6.- Other commands.| +===================== --------------------------------------- -*divorce() - -This function will un-marry the invoking character from whoever they were -married to. Both will no longer be each other's marriage partner, (at least in -current SVN, which prevents the cases of multi-spouse problems). It will return -1 upon success or 0 if the character was not married at all. - -This function will also destroy both wedding rings and send a message to both -players, telling them they are now divorced. - ---------------------------------------- +*debugmes "<message>"; -*ispartneron() +This command will send the message to the server console (map-server window). It +will not be displayed anywhere else. -This function returns 1 if the invoking character's marriage partner is -currently online and 0 if they are not or if the character has no partner. + debugmes strcharinfo(0)+" has just done this that and the other"; + // You would see in the map-server window "NAME has just done this that and + // the other" --------------------------------------- -*getpartnerid() - -This function returns the character ID of the invoking character's marriage -partner, if any. If the invoking character is not married, it will return 0, -which is a quick way to see if they are married: - - if (getpartnerid()) mes "I'm not going to be your girlfriend!"; - if (getpartnerid()) mes "You're married already!"; - ---------------------------------------- +*logmes "<message>"; -*warppartner("<map name>",<x>,<y>); +This command will write the message given to the map server npc log file, as +specified in 'conf/log_athena.conf'. In the TXT version of the server, the log +file is 'log/npclog.log' by default. In the SQL version, if SQL logging is +enabled, the message will go to the 'npclog' table, otherwise, it will go to the +same log file. -This function will find the invoking character's marriage partner, if any, and -warp them to the map and coordinates given. Go kidnap that spouse. :) It will -return 1 upon success and 0 if the partner is not online, the character is not -married, or if there's no invoking character (no RID). 0,0 will, as usual, -normally translate to random coordinates. +If logs are not enabled, nothing will happen. --------------------------------------- -*adopt "<parent name>","<parent name>","<novice name>"; -*adopt("<parent name>","<parent name>","<novice name>"); - -This command will set up a novice as a baby of a married couple. All three are -referred to by character name. The correct variables are set on all three -characters in the same call. The command will unequip anything the novice has -equipped and make them a Job_Baby class, as well as send them a 'your job has -been changed' message. +*globalmes "<message>"{,"<NPC name>"}; -Beware of calling this from inside a 'callfunc' function, cause upon successful -adoption, this command returns a zero, as if it were a function. This is likely -to screw up execution of a 'return' command. You may try to call it as a -function instead, but it doesn't return anything upon an error, which may also -cause script execution to throw up errors. +This command will send a message to the chat window of all currently connected +characters. -Nothing will happen (and nothing will be returned either) if either future -parent is below base level 70 and/or if any of the three characters is not found -online. +If NPC name is specified, the message will be sent as if the sender would be +the npc with the said name. --------------------------------------- -*getchildid() -*getmotherid() -*getfatherid() - -These functions return the characters (shild/mother/father) ID - - if (getmotherid()) mes "Oh... I know your mother's ID:"+getmotherid(); +*rand(<number>{,<number>}); ---------------------------------------- +This function returns a number, randomly positioned between 0 and the number you +specify (if you only specify one) and the two numbers you specify if you give it +two. -*getitemname(<item id>) +rand(10) would result in 0,1,2,3,4,5,6,7,8 or 9 -Given the database ID number of an item, this function will return the text -stored in the 'japanese name' field (which, in eAthena, stores an english name -the players would normally see on screen.) +rand(2,10) would result in 2,3,4,5,6,7,8,9 or 10 --------------------------------------- -*makepet <pet id>; +*viewpoint <action>,<x>,<y>,<point number>,<color>; -This command will create a pet egg and put it in the invoking character's -inventory. The kind of pet is specified by pet ID numbers listed in -'db/pet_db.txt'. The egg is created exactly as if the character just successfuly -caught a pet in the normal way. +This command will mark places on the mini map in the client connected to the +invoking character. It uses the normal X and Y coordinates from the main map. +The colors of the marks are defined using a hexidecimal number, same as the ones +used to color text in 'mes' output, but are written as hexadecimal numbers in C. +(They look like 0x<six numbers>.) - // This will make you a poring: - makepet 1002; +Action is what you want to do with a point, 1 will set it, while 2 will clear +it. Point number is the number of the point - you can have several. If more than +one point is drawn at the same coordinates, they will cycle, which can be used +to create flashing marks. -Notice that you absolutely have to create pet eggs with this command. If you try -to give a pet egg with 'getitem', pet data will not be created by the char -server and the egg will disappear when anyone tries to hatch it. + // This command will show a mark at coordinates X 30 Y 40, is mark number 1, + // and will be red. + + viewpoint 1,30,40,1,0xFF0000; ---------------------------------------- +This will create three points: -*getexp <base xp>,<job xp>; + viewpoint 1,30,40,1,0xFF0000; + viewpoint 1,35,45,2,0xFF0000; + viewpoint 1,40,50,3,0xFF0000; -This command will give the invoking character a specified number of base and job -experience points. Can be used as a quest reward. Negative amounts of experience -were not tested but should work. +And this is how you remove them: - getexp 10000,5000; + viewpoint 2,30,40,1,0xFF0000; + viewpoint 2,35,45,2,0xFF0000; + viewpoint 2,40,50,3,0xFF0000; + +The client determines what it does with the points entirely, the server keeps no +memory of where the points are set whatsoever. -You can also use the "set" command with the constants defined in 'db/const.txt': +--------------------------------------- - // These 2 combined has the same effect as the above command - set BaseExp,BaseExp+10000; - set JobExp,JobExp+5000; +*cutin "<filename with no extension>",<position>; -You can also reduce the ammount of experience points: +This command will display a picture stored in the GRF file in the client for the +player. - set BaseExp,BaseExp-10000; +The files are taken from '\data\texture\A_A£AII’„AI«§\illust' directory in the +GRF file. The filename must be given with no extension, '.bmp' is added by the +client itself and you can't have any other picture format displayed as a cutin. +The biggest one that comes with the client is 400x503 pixels, and the smallest +is 303x493 pixels, it is not known how big a picture has to be before the client +goes insane. Bright magenta (color FF00FF) is considered to be transparent in +these pictures. You can easily add and alter them, but how to do this is outside +of the scope of this document. ---------------------------------------- +The position determines just where on screen the picture will appear: + 0 - bottom left corner + 1 - bottom middle + 2 - bottom right corner + 3 - middle of screen in a movable window with an empty title bar. + 4 - middle of screen without the window header, but still movable. + 255 - will remove the cutin previously displayed. + +Giving an empty string for the filename and 255 for the position will remove all +cutin pictures. Any other position value will not cause a script error but will +cause the player's client to curl up and die. Only one cutin may be on screen at +any given time, any new cutins will replace it. -*getinventorylist; + // This will display the picture of the 7th kafra, + // the one in orange and the mini-skirt :P + cutin "kafra_7",2; -This command sets a bunch of arrays with a complete list of whatever the -invoking character has in their inventory, including all the data needed to -recreate these items perfectly if they are destroyed. Here's what you get: + // This will remove the displayed picture. + cutin "Kafra_7",255; -@inventorylist_id[] - array of item ids. -@inventorylist_amount[] - their corresponding item amounts. -@inventorylist_equip[] - whether the item is equipped or not. -@inventorylist_refine[] - for how much it is refined. -@inventorylist_identify[] - whether it's refined. -@inventorylist_attribute[] - whether it is broken. -@inventorylist_card1[] - These four arrays contain card data for the items. -@inventorylist_card2[] These data slots are also used to store names -@inventorylist_card3[] inscribed on the items, so you can explicitly check -@inventorylist_card4[] if the character owns an item made by a specific - craftsman. -@inventorylist_count - the number of items in these lists. + // This will remove all pictures displayed. + cutin "",255; -This could be handy to save/restore a character's inventory, since no other -command returns such a complete set of data, and could also be the only way to -correctly handle an NPC trader for carded and named items who could resell them -- since NPC objects cannot own items, so they have to store item data in -variables and recreate the items. +The client comes with those cutin pictures preinstalled which you can use: -Notice that the variables this command generates are all local and numeric. +mets_alpha - This is a old fat man, holding a pipe, also with a pocket watch + and cane +pay_soldier - Wanna take a wild guess, thats right, the Soldiers that appear in + Payon :D +prt_soldier - Obvious +ein_soldier - This guy looks cool, you've got to see him ;) This picture is for + the new Einbroch guards +moc_soldier - Obvious +gef_soldier - Obvious +katsua01 - It is not certain who this girl is (There is no sprite coming with +katsua02 - the client that seems to match very well) but she is believed to +katsua03 - be an NPC in official Comodo. The three pictures give different + facial expressions. +kafra_01 - Obvious +kafra_02 - Obvious +kafra_03 - Obvious +kafra_04 - Obvious +kafra_05 - Obvious +kafra_06 - Obvious +kafra_07 - Do I need to mention this one again ;) --------------------------------------- -*getskilllist; - -This command sets a bunch of arrays with a complete list of skills the -invoking character has. Here's what you get: +*cutincard <item id>; -@skilllist_id[] - skill ids. -@skilllist_lv[] - skill levels. -@skilllist_flag[] - see 'skill' for the meaning of skill flags. -@skilllist_count - number of skills in the above arrays. +This command will display a card picture as a cutin on the client connected to +the invoking character, with position number 4 (middle of screen, movable, but +no title bar). See 'cutin'. To remove this cutin, use the regular 'cutin' +command. Unlike the 'cutin' command, it will not take a filename, but will +instead take an item ID. It will then refer to the text file listing card images +which is normally found within your server's copy of the GRF file to find the +real (korean) filename. -While 'getskillv' is probably more useful for most situations, this is the -easiest way to store all the skills and make the character something else for a -while. Advanced job for a day? :) This could also be useful to see how many -skills a character has. +If your server doesn't have that text file in that GRF or can't read it, it +probably won't work. --------------------------------------- -*clearitem; +*pet <pet id>; -This command will destroy all items the invoking character has in their -inventory. (that includes equipped items) It will not affect anything else, like -storage or cart. +This command is used in all the item scripts for taming items. Running this +command will make the pet catching cursor appear on the client connected to the +invoking character, usable on the monsters with the specified pet ID number. It +will still work outside an item script. ---------------------------------------- +A full list of pet IDs can be found inside 'db/pet_db.txt' -*classchange <view id>,<type>; +--------------------------------------- -This command is very ancient, it's origins are clouded in mystery. -It will send a 'display id change' packet to everyone in the immediate area of -the NPC object, which will supposedly make the NPC look like a different sprite, -an NPC sprite ID, or a monster ID. This effect is not stored anywhere and will -not persist (Which is odd, cause it would be relatively easy to make it do so) -and most importantly, will not work at all since this command was broken with -the introduction of advanced classes. The code is written with the assumption -that the lowest sprite IDs are the job sprites and the anything beyond them is -monster and NPC sprites, but since the advanced classes rolled in, they got the -ID numbers on the other end of the number pool where monster sprites float. +*emotion <emotion number>{, target}; -As a result it is currently impossible to call this command with a valid view -id. It will do nothing whatsoever if the view ID is below 4047. Getting it to -run will actually just crash the client. +This command makes an object display an emoticon sprite above their own as +if they were doing that emotion. For a full list of emotion numbers, +see 'db/const.txt' under 'e_'. The inobvious ones are 'e_what' (a question mark) +and 'e_gasp' (the exclamation mark). -It could be a real gem if it can be gotten to actually do what it's supposed to -do, but this will only happen in a later SVN revision. +The optional target parameter specifies who will get the emotion on top of +their head. If 0 (the default if omitted), the NPC in current use will show +the emotion, if 1, the player that is running the script will display it. --------------------------------------- @@ -4369,193 +5667,12 @@ You can add your own effects this way, naturally. --------------------------------------- -*mapwarp "<from map>","<to map>",<x>,<y>; - -This command will collect all characters located on the From map and warp them -wholesale to the same point on the To map, or randomly distribute them there if -the coordinates are zero. "Random" is understood as a special To map name and -will mean randomly shuffling everyone on the same map. - ---------------------------------------- - -*mobcount("<map name>","<event label>") - -This function will count all the monsters on the specified map that have a given -event label and return the number or 0 if it can't find any. Naturally, only -monsters spawned with 'monster' and 'areamonster' script commands can be like -this. - -However, apparently, if you pass this function an empty string for the event -label, it should return the total count of normal permanently respawning -monsters instead. With the current dynamic mobs system, where mobs are not kept -in memory for maps with no actual people playing on them, this will return a 0 -for any such map. - ---------------------------------------- - -*strmobinfo(<type>,<monster id>); - -This function will return information about a monster record in the database, as -per 'db/mob_db.txt'. Type is the kind of information returned. Valid types are: - - 1 - 'english name' field in the database, a string. - 2 - 'japanese name' field in the database, a string. - All other returned values are numbers: - 3 - Level. - 4 - Maximum HP. - 5 - Maximum SP. - 6 - Experience reward. - 7 - Job experience reward. - ---------------------------------------- - -*guardian "<map name>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>"}{,<guardian index>}; - -This command is roughly equivalent to 'monster', but is meant to be used with -castle guardian monsters and will only work with them. It will set the guardian -characteristics up according to the castle's investment values and otherwise -set the things up that only castle guardians need. - ---------------------------------------- - -*guardianinfo(<guardian number>) - -This function will return the current hit point value for the specified guardian -number, if such guardian is currently installed. This function will only work if -the invoking character is on a castle map, and will refer only to the guardians -of that castle, regardless of anything else, i.e. whether the character is a -member of the guild owning the castle, etc, etc. -If no guardian is installed in this slot, the function will return -1. - ---------------------------------------- - -* The Pet AI commands - -These commands will only work if the invoking character has a pet, and are meant -to be executed from pet scripts. They will modify the pet AI decision-making for -the current pet of the invoking character, and will NOT have any independent -effect by themselves, which is why only one of them each may be in effect at any -time for a specific pet. A pet may have 'petloot', 'petskillbonus', -'petskillattack' OR 'petpetskillattack2' and 'petskillsupport' OR 'petheal' at -the same time. 'petheal' is deprecated and is no longer used in the default pet -scripts. - -*petskillbonus <bonus type>,<value>,<duration>,<delay>; - -This command will make the pet give a bonus to the owner's stat (bonus type - -bInt,bVit,bDex,bAgi,bLuk,bStr,bSpeedRate - for a full list, see the values -starting with 'b' in 'db/const.txt') - -*petrecovery <status type>,<delay>; - -This command will make the pet cure a specified status condition. The curing -actions will occur once every Delay seconds. For a full list of status -conditions that can be cured, see the list of 'SC_' status condition constants -in 'db/const.txt' - -*petloot <max items>; - -This command will turn on pet looting, with a maximum number of items to loot -specified. Pet will store items and return them when the maximum is reached or -when pet performance is activated. - -*petskillsupport <skill id>,<skill level>,<delay>,<percent hp>,<percent sp>; -*petheal <level>,<delay>,<percent hp>,<percent sp>; - -This will make the pet use a specified support skill on the owner whenever the -HP and SP are below the given percent values, with a specified delay time -between activations. The skill numbers are as per 'db/skill_db.txt'. -'petheal' works the same as 'petskillsupport' but has the skill ID hardcoded to -28 (Heal). This command is deprecated. -It's not quite certain who's stats will be used for the skills cast, the -character's or the pets. Probably, Skotlex can answer that question. - -*petskillattack <skill id>,<skill level>,<rate>,<bonusrate>; -*petskillattack2 <skill id>,<damage>,<number of attacks>,<rate>,<bonusrate>; - -These two commands will make the pet cast an attack skill on the enemy the pet's -owner is currently fighting. Skill IDs and levels are as per 'petskillsupport'. -'petskillattack2' will make the pet cast the skill with a fixed amount of damage -inflicted and the specified number of attacks. - -All commands with delays and durations will only make the behavior active for -the specified duration of seconds, with a delay of the specified number of -seconds between activations. Rates are a chance of the effect occuring and are -given in percent. 'bonusrate' is added to the normal rate if the pet intimacy is -at the maximum possible. - -The behavior modified with the abovementioned commands will only be exibited if -the pet is loyal and appropriate configuration options are set in -'battle_athena.conf'. - -Pet scripts in the database normally run whenever a pet of that type hatches -from the egg. Other commands usable in item scripts (see 'bonus') will also -happily run from pet scripts. Apparently, the pet-specific commands will also -work in NPC scripts and modify the behavior of the current pet up until the pet -is hatched again. (Which will also occur when the character is logged in again -with the pet still out of the egg.) It is not certain for how long the effect of -such command running from an NPC script will eventually persist, but apparently, -it is possible to usefully employ them in usable item scripts to create pet -buffing items. - -Nobody tried this before, so you're essentially on your own here. - --------------------------------------- - -*skilleffect <skill id>,<number>; - -This command will display the visual and sound effects of a specified skill (see -'db/skill_db.txt' for a full list of skills) on the invoking character's sprite. -Nothing but the special effects and animation will happen. If the skill's normal -effect displays a floating number, the number given will float up. - - // This will heal the character with 2000 hp, buff with - // Bless 10 and Increase AGI 5, and display appropriate - // effects. - mes "Blessed be!"; - skilleffect 28,2000; - heal 2000,0; - skilleffect 34,0; - // That's bless 10. - sc_start 10,240000,10; - skilleffect 29,0; - // That's agi 5 - sc_start 12,140000,5; - ---------------------------------------- - -*npcskilleffect <skill id>,<number>,<x>,<y>; - -This command behaves identically to 'skilleffect', however, the effect will not -be centered on the invoking character's sprite, nor on the NPC sprite, if any, -but will be centered at map coordinates given on the same map as the invoking -character. - ---------------------------------------- - -*specialeffect <effect number>; - -This command will display special effect with the given number, centered on the -specified NPCs coordinates, if any. For a full list of special effect numbers -known see 'doc/effect_list.txt'. Some effect numbers are known not to work in -some client releases. (Notably, rain is absent from any client executables -released after April 2005.) - ---------------------------------------- - -*specialeffect2 <effect number>; - -This command behaves identically to the 'specialeffect', but the effect will be -centered on the invoking character's sprite. - ---------------------------------------- - -*nude; - -This command will unequip anything equipped on the invoking character. +*pvpon "<map name>"; +*pvpoff "<map name>"; -It is not required to do this when changing jobs since 'jobchange' will unequip -everything not equippable by the new job class anyway. +These commands will turn PVP mode for the specified maps on and off. Beside +setting the flags referred to in 'setmapflag', 'pvpon' will also create a PVP +timer and ranking as will @pvpon GM command do. --------------------------------------- @@ -4568,253 +5685,48 @@ character belonged to an account which had GM level 99. // This will ask the invoker for a character name and then use the '@nuke' // GM command on them, killing them mercilessly. input @player$; - gmcommand "@nuke "+@player$ + atcommand "@nuke "+@player$; This command has a lot of good uses, I am sure you can have some fun with this one. --------------------------------------- -*message "<character name>","<message>"; - -That command will send a message to the chat window of the character specified -by name. The text will also appear above the head of that character. It will not -be seen by anyone else. - ---------------------------------------- - -*npctalk "<message>"; - -This command will display a message to the surrounding area as if the NPC object -running it was a player talking - that is, above their head and in the chat -window. The display name of the NPC will get appended in front of the message to -complete the effect. - - // This will make everyone in the area see the NPC greet the character - // who just invoked it. - npctalk "Hello "+strcharinfo(0)+" how are you"; - ---------------------------------------- - -*hasitems(0) - -This function will return 1 if the invoking character has anything at all in -their inventory and 0 if they do not. Even though the argument is not used for -anything, it is required. - ---------------------------------------- - -*getlook(<type>) - -This function will return the number for the currentcharacter look value -specified by type. See 'setlook' for valid look types. - -This can be used to make a certain script behave differently for characters -dressed in black. :) - ---------------------------------------- - -*getsavepoint(<information type>) - -This function will return information about the invoking character's save point. -You can use it to let a character swap between several recorded savepoints. -Available information types are: - - 0 - Map name (a string) - 1 - X coordinate - 2 - Y coordinate - ---------------------------------------- - -*npcspeed <speed value>; -*npcwalkto <x>,<y>; -*npcstop; - -These commands will make the NPC object in question move around the map. As they -currently are, they are a bit buggy and are not useful for much more than making -an NPC move randomly around the map. (see 'npc/custom/devnpc.txt' for an example -of such usage) - -'npcspeed' will set the NPCs walking speed to a specified value. As in the -@speed GM command, 200 is the slowest possible speed while 0 is the fastest -possible (instant motion). 100 is the default character walking speed. -'npcwalkto' will start the NPC sprite moving towards the specified coordinates -on the same map as it is currently on. -'npcstop' will stop the motion. - -While in transit, the NPC will be clickable, but invoking it will cause it to -stop motion, which will make it's coordinates different from what the client -computed based on the speed and motion coordinates. The effect is rather -unnerving. - -Only a few NPC sprites have walking animations, and those that do, do not get -the animation invoked when moving the NPC, due to the problem in the npc walking -code, which looks a bit silly. You might have better success by defining a job- -sprite based sprite id in 'db/mob-avail.txt' with this. - ---------------------------------------- - -*getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"}) - -This function will locate a character object, NPC object or pet's coordinates -and place their coordinates into the variables specified when calling it. It -will return 0 if the search was successful, and -1 if the parameters given were -not variables or the search was not successful. - -Type is the type of object to search for: - - 0 - Character object - 1 - NPC object - 2 - Pet object - 3 - Monster object. - -While 3 is meant to look for a monster object, no searching will be done if you -specify type 3, and the function will always return -1. - -The search string is optional. If it is not specified, the location of the -invoking character will always be returned for types 0 and 2, the location of -the NPC running this function for type 1. -If a search string is specified, for types 0 and 1, the character or NPC with -the specified name will be located. If type is 3, the search will locate the -current pet of the character who's name is given in the search string, it will -NOT locate a pet by name. - -What a mess. Example, a working and tested one now: - - prontera.gat,164,301,3%TAB%script%TAB%Meh%TAB%730,{ - mes "My name is Meh. I'm here so that Nyah can find me."; - close; - } - - prontera.gat,164,299,3%TAB%script%TAB%Nyah%TAB%730,{ - mes "My name is Nyah."; - mes "I will now search for Meh all across the world!"; - if (getmapxy(@mapname$,@mapx,@mapy,1,"Meh")!=0) goto Notfound; - mes "And I found him on map "+@mapname$+" at X:"+@mapx+" Y:"+@mapy+" !"; - close; - Notfound: - mes "I can't seem to find Meh anywhere!"; - close; - } - -Notice that NPC objects disabled with 'disablenpc' will still be located. - ---------------------------------------- - -*guildgetexp <amount>; - -This will give the specified amount of guild experience points to the guild the -invoking character belongs to. It will silently fail if they do not belong to -any guild. - ---------------------------------------- - -*skilluseid <skill>,<level>; -*doskill <skill>,<level>; -*skillusepos <skill>,<level>,<x>,<y>; - -These commands will cause the invoking character to use a specified skill at the -specified level, as if they had that skill, with their current level and stats. -If the skill involves targeting a character, no targeting pointer will come up - -the invoking character will automatically be the skill target. - -'doskill' is an alias for 'skilluseid'. - -'skillusepos' will specify a target map square for the skill to be used. If that -skill is an area effect skill, it will be centered at the square specified. It -will not work if the skill is supposed to be targeted on character or monster. - ---------------------------------------- - -*logmes "<message>"; - -This command will write the message given to the map server npc log file, as -specified in 'conf/log_athena.conf'. In the TXT version of the server, the log -file is 'log/npclog.log' by default. In the SQL version, if SQL logging is -enabled, the message will go to the 'npclog' table, otherwise, it will go to the -same log file. - -If logs are not enabled, nothing will happen. - ---------------------------------------- - -*summon "<monster name>",<mob id>{,"<event label>"}; - -This command will summon a monster. (see also 'monster') Unlike monsters spawned -with other commands, this one will set up the monster to fight to protect the -invoking character. Monster name and mob id obey the same rules as the one given -at the beginning of this document for permanent monster spawns with the -exceptions mentioned when describing 'monster' command. - -The effect for the skill 'Call Homonuculus' will be displayed centered on the -invoking character. - -If an event label is given, upon the monster being killed, the event label will -run as if by 'donpcevent'. - - // Will summon a dead branch-style monster to fight for the character. - summon "--ja--",-1; - ---------------------------------------- - -*isnight() -*isday() - -These functions will return 1 or 0 depending on whether the server is in night -mode or day mode. 'isnight' returns 1 if it's night and 0 if it isn't, 'isday' -the other way around. They can be used interchangeably, pick the one you like -more: - - // These two are equivalent: - if (isday()) mes "I only prowl in the night."; - if (isnight()!=1) mes "I only prowl in the night."; - ---------------------------------------- - -*isequipped(<id>{,<id>{,<id>{,<id>}}}) - -This function will return 1 if the invoking character has all of the item -IDs given equipped (if card IDs are passed, then it checks if the cards are -inserted into slots in the equipment they are currently wearing). Theorically -there is no limit to the number of items that may be tested for at the same time. -If even one of the items given is not equipped, 0 will be returned. +*charcommand <command>; - // (Poring,Santa Poring,Poporing,Marin) - if (isequipped(4001,4005,4033,4196)) mes "Wow! You're wearing a full complement of possible poring cards!"; - // (Poring) - if (isequipped(4001)) mes "A poring card is useful, don't you think?"; - -The function was meant for item scripts to support the cards released by Gravity -in February 2005, but it will work just fine in normal NPC scripts. +NOTE: This command is changed a bit on newer trunk versions, +scroll down a bit for the new version! ---------------------------------------- +On older trunk versions and stable: -*isequippedcnt(<card id>{,<card id>{,<card id>{,<card id>}}}) +command is the name of the current character (strcharinfo(0)) +followed by ':' and the command and it's parameters. -This function is similar to 'isequipped', but instead of 1 or 0, it will return -the number of cards in the list given that were found on the invoking character. +Example(s): - if (isequippedcnt(4001,4005,4033,4196)=4) mes "Finally got all four poring cards?"; +//Will be executed as if a lvl 99 GM done the #option command. + charCommand strcharinfo(0)+":#option 0 0 0 Roy"; ---------------------------------------- +Newer Trunk version: -*cardscnt() +The big change is that the character name is no longer needed. +This also enabled the commands to run without a player attached (according to Lance). -This function will return the number of cards inserted into the weapon currently -equipped on the invoking character. -While this function was meant for item scripts, it will work outside them: +Example(s): - if (cardscnt()==4) mes "So you've stuck four cards into that weapon, think you're cool now?"; +//this would do the same as above, but now doesn't need a player attached by default. + charCommand "#option 0 0 0 Roy"; --------------------------------------- -*getrefine() +*unitskilluseid <GID>,<skill id>,<skill lvl>; +*unitskillusepos <GID>,<skill id>,<skill lvl>,<x>,<y>; -This function will return the number of plusses the weapon currently equipped on -the invoking character has been refined for. -While this function was meant for item scripts, it will work outside them: +This is the replacement of the older commands, these use the same values for +GID as the other unit* commands (See 'GID'). - if (getrefine()==10) mes "Wow. That's a murder weapon."; +Skill ID is the ID of the skill, skill level is the level of the skill. +For the position, the x and y are given in the unitSkillUsePos. --------------------------------------- @@ -4858,109 +5770,6 @@ OnInit: --------------------------------------- -*getusersname; - -This command will give the invoking character a list of names of the connected -characters (including themselves) into an NPC script message window (see 'mes') -paging it by 10 names as if with the 'next' command. - -You need to put a 'close' after that yourself. - ---------------------------------------- - -*dispbottom "<message>"; - -This command will send the given message into the invoking character's chat -window. - ---------------------------------------- - -*recovery; - -This command will revive and restore full HP and SP to all characters currently -connected to the server. - ---------------------------------------- - -*getpetinfo(<type>) - -This function will return pet information for the pet the invoking character -currently has active. Valid types are: - - 0 - Unique pet ID number as stored by the char server and distinguishing it - from all other pets the characters actually have. This value is currently - useless, at most you can use it to tell pets apart reliably. - 1 - Pet ID number as per 'db/pet_db.txt' - will tell you what kind of a pet it - is. - 2 - Pet name. Will return "null" if there's no pet. - 3 - Pet friendly level (intimacy score). 1000 is full loyalty. - 4 - Pet hungry level. 100 is completely full. - ---------------------------------------- - -*checkequipedcard(<card id>) - -This function will return 1 if the card specified by it's item ID number is -inserted into any equipment they have in their inventory, currently equipped or -not. - ---------------------------------------- - -*globalmes "message"; - -This command will send a message to the chat window of all currently connected -characters. - ---------------------------------------- - -*jump_zero (<condition>),<label>; - -This command works kinda like an 'if'+'goto' combination in one go. (See 'if'). -If the condition is false (equal to zero) this command will immediately jump to -the specified label like in 'goto'. - -While 'if' is more generally useful, for some cases this could be an -optimisation. - ---------------------------------------- - -*select("<option>"{,"<option>"..."<option>"}) - -This function is a handy replacement for 'menu' for some specific cases where -you don't want a complex label structure - like, for example, asking simple yes- -no questions. It will return the number of menu option picked, starting with 1. -Like 'menu', it will also set the variable @menu to contain the option the user -picked. - - if (select("Yes","No")==1) mes "You said yes, I know."; - -And like 'menu', this command has a problem with empty strings - if some of the -option strings given to it are empty, you won't be able to tell which one the -user really picked. The number it returns will only make sense if all the empty -strings are last in the list of options. - ---------------------------------------- - -*getmapmobs("<map name>") - -This function will return the total count of monsters currently located on the -specified map. If the map name is given as "this", the map the invoking -character is on will be used. If the map is not found, or the invoker is not a -character while the map is "this", it will return -1. - ---------------------------------------- - -*unequip <equipment slot>; - -This command will unequip whatever is currently equipped in the invoking -character's specified equipment slot. For a full list of possible equipment -slots see 'getequipid'. - -If an item occupies several equipment slots, it will get unequipped from all of -them. (Which is a good thing.) - ---------------------------------------- - *defpattern <set number>,"<regular expression pattern>","<event label>"; *activatepset <set number>; *deactivatepset <set number>; @@ -5007,90 +5816,6 @@ they want it so much. --------------------------------------- -*getstrlen("<string>") - -This function will return the length of the string given as an argument. It is -useful to check if anything input by the player exceeds name length limits and -other length limits and asking them to try to input something else. - ---------------------------------------- - -*charisalpha("<string>",<position>) - -This function will return 1 if the character number Position in the given string -is a letter, 0 if it isn't a letter but a digit or a space. - ---------------------------------------- - -*getnameditem(<item id>,"<name to inscribe>"); -*getnameditem("<item name>","<name to inscribe>"); - -This function is equivalent to using 'getitem', however, it will not just give -the character an item object, but will also inscribe it with a specified -character's name. You may not inscribe items with arbitrary strings, only with -names of characters that actually exist. While this isn't said anywhere -specifically, apparently, named items may not have cards in them, slots or no - -these data slots are taken by the character ID who's name is inscribed. Only one -remains free and it's not quite clear if a card may be there. - -This function will return 1 if an item was successfully created and 0 if it -wasn't for whatever reason. Like 'getitem', this function will also accept an -'english name' from the item database as an item name and will return 0 if no -such item exists. - ---------------------------------------- - -*getitemslots(<item ID>) - -This function will look up the item with the specified ID number in the database -and return the number of slots this kind of items has - 0 if they are not -slotted. It will also be 0 for all non-equippable items, naturally, unless -someone messed up the item database. It will return -1 if there is no such item. - ---------------------------------------- - -*getiteminfo(<item ID>,<type>) - -This function will look up the item with the specified ID number in the database -and return the info set by TYPE argument. -It will return -1 if there is no such item. - -Valid types are: - 0 - Buy Price; 1 - Sell Price; 2 - Item Type; - 3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc.. - if = 0, then monsters don't drop it at all (rare or a quest item) - if = 10000, then this item is sold in NPC shops only - 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range; - 10 - slot; 11 - look; 12 - elv; 13 - wlv; - -Check sample in nps\sample\getiteminfo.txt - ---------------------------------------- - -*getmonsterinfo(<item ID>,<type>) - -This function will look up the monster with the specified ID number in the database -and return the info set by TYPE argument. -It will return -1 if there is no such item. Due to specific of MOB DB routines, -it's better to check monster name. It'd return "Dummy" for a non-existing monster. - -Valid types are listed in const.txt: - MOB_NAME 0 MOB_LV 1 - MOB_MAXHP 2 MOB_BASEEXP 3 - MOB_JOBEXP 4 MOB_ATK1 5 - MOB_ATK2 6 MOB_DEF 7 - MOB_MDEF 8 MOB_STR 9 - MOB_AGI 10 MOB_VIT 11 - MOB_INT 12 JOB_DEX 13 - MOB_LUK 14 MOB_RANGE 15 - MOB_RANGE2 16 MOB_RANGE3 17 - MOB_SIZE 18 MOB_RACE 19 - MOB_ELEMENT 20 MOB_MODE 21 - -Check sample in nps\sample\getmonsterinfo.txt - ---------------------------------------- - *pow(<number>,<power>) Returns the result of the calculation. @@ -5117,7 +5842,9 @@ Example: set @i, distance(100,200,101,202); --------------------------------------- -*query_sql "your MySQL query", <array name>, [<array name>] + +*query_sql "your MySQL query", <array name>{,<array name>{; + Returns up to 127 values into array and return the number of row Example: @@ -5130,250 +5857,165 @@ mes "4."+@name$[3]+"("+@fame[3]+")"; mes "5."+@name$[4]+"("+@fame[4]+")"; Note: In the TXT version it doesn't fill the array and always return -1. -Note: Use Text$[] array to recieve all data as text. - ---------------------------------------- - -*setd "variable name", <value> - -Works almost identical as set, just that the variable name is identified as a string, -thus can be constructed dynamically. - -Example: -set $var$, "Poring"; - -setd "$var$", "Poporing"; -mes $var$; // Will return Poporing - -setd "$" + $var$ + "123$", "Poporing is cool"; -mes $Poporing123$; // Will return Poporing is cool. +Note: Use $ as suffix in the array to recieve all data as text. --------------------------------------- -*getd("variable name") - -Retrieves variable, name can be constructed dynamically. Refer to setd for usage. - -Example: -set @i, getd("$pikachu"); - ---------------------------------------- - -*petstat(<flag>) - -Returns current pet status, all are integers except name. -Returns 0 or "" if the player doesn't have pets. - -Flags usable >> -PET_CLASS -PET_NAME -PET_LEVEL -PET_HUNGRY -PET_INTIMATE - -Example: -set @i, petstat(PET_CLASS); - - ---------------------------------------- - -*setitemscript(<ItemID>,<"{ new item script }">) +*setitemscript(<ItemID>,<"{ new item script }">); Set a new script bonus to the Item. Very useful for game events. +You can remove an item's itemscript by leaving empty the itemscript argument. Example: setitemscript 2637,"{ bonus bDamageWhenUnequip,40; if(isequipped(2236)==0)end; if(getskilllv(26)){skill 40,1;}else{skill 26,1+isequipped(2636);} }"; +setitemscript 2639,""; --------------------------------------- -*disguise <Monster ID>; -*undisguise; +*atoi ("<string>") +*axtoi ("<string>") -This command disgueses current player with a monster sprite. -The disguise is disappearing on re-login or on 'undisguise' command. - -Note: It doesn't work with "Pets with equipment on" -Note: If u're a Sniper, u'd get an old Falcon over your head -Note: You can kill yourself with some skills -Note: Monsters of your type could heal you +These commands are used to convert strings to numbers. +atoi will convert string using normal number (0,1,2,3,etc) while axtoi converts them to +hexadecimal numbers (0,1,11,01). Example: -disquise 1002; //Yay! You're a Poring!!! -next; -undisquise; //Yay!!!! You're a human again!! ---------------------------------------- + mes atoi("11"); // Will display 11 (can also be used to set a @var to 11) + set @var, axtoi("FF"); // Will set the @var to 255 + mes axtoi("11"); // Will display 17 (1 = 1, 10 = 16, + // hexadecimal number set: {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}) -*axtoi(<hexadecimal_value>); +--------------------------------------- -This command will convert an hexadecimal value into integers (numbers). -The inputted value must not have neither # or 0x in it, just 6 numbers and/or letters. -The variable registering this value, if so, must be a string (letter) variable, due that -it contains letters in some cases. +*compare (<string>,<substring>) -This is mostly used for the new announce command, which uses hexadecimal values for announce -colors, using the Ragnarok coloring system. +This command returns 1 or 0 when a the substring is in the main string (1) or not (0). +This command is not case sensitive. -Example: +Example(s): -amatsu.gat,171,166,4 script Testing npc 767,{ - -mes "Input hex color"; -input @trying$; -next; -set @try2$,axtoi(@trying$); -announce "zOMG TEH PWNZ0RDZ",bc_all,@try2$; -close; -} +//dothis; will be executed ('Bloody Murderer' contains 'Blood'). + if (compare("Bloody Murderer","Blood")) + dothis; +//dothat; will not be executed ('Blood butterfly' does not contain 'Bloody'). + if (compare("Blood Butterfly","Bloody")) + dothat; -If you want a list of hexadecimal colors, check these two links: +-------------------------------------- -http://webmonkey.wired.com/webmonkey/reference/color_codes/ +*charisalpha("<string>",<position>) -http://www.december.com/html/spec/color.html +This function will return 1 if the character number Position in the given string +is a letter, 0 if it isn't a letter but a digit or a space. --------------------------------------- -*rid2name(rid) +*wedding_effect; +Starts the effect used when a wedding is done (music and everything else) +Example can be found in the wedding script. -Converts rid to name. Note: The player/monster/NPC must be online/enabled. -Good for PCKillEvent where you can convert 'killedrid' to the name of the player. - -Note: rid2name may not produce correct character names since rid = account id. - It will return the current online character of the account only. +-------------------------------------- ---------------------------------------- +* The Pet AI commands -*function <function name>; -*<function name>; -*function <function name> { -<code> -} +These commands will only work if the invoking character has a pet, and are meant +to be executed from pet scripts. They will modify the pet AI decision-making for +the current pet of the invoking character, and will NOT have any independent +effect by themselves, which is why only one of them each may be in effect at any +time for a specific pet. A pet may have 'petloot', 'petskillbonus', +'petskillattack' OR 'petpetskillattack2' and 'petskillsupport' OR 'petheal' at +the same time. 'petheal' is deprecated and is no longer used in the default pet +scripts. -(Skotlex stop being so selfish and give us all the commands T~T! J/k lol :P) +*petskillbonus <bonus type>,<value>,<duration>,<delay>; -This works like callfunc, but doesn't support arguments like callfunc. It's used for cleaner -and fast script that doesn't require arguments for it to work. Also they must be inside a script. -They're not separated scripts and they work more like labels. +This command will make the pet give a bonus to the owner's stat (bonus type - +bInt,bVit,bDex,bAgi,bLuk,bStr,bSpeedRate - for a full list, see the values +starting with 'b' in 'db/const.txt') -Note it looks like the normal declaration +*petrecovery <status type>,<delay>; -Usage: +This command will make the pet cure a specified status condition. The curing +actions will occur once every Delay seconds. For a full list of status +conditions that can be cured, see the list of 'SC_' status condition constants +in 'db/const.txt' -You first Declare the function with function <function name>;. +*petloot <max items>; -Put the rest of your code. You can use then <function name>; to call the function. If it returns a value is unsure, -test it if you want and give us some comments ;3 +This command will turn on pet looting, with a maximum number of items to loot +specified. Pet will store items and return them when the maximum is reached or +when pet performance is activated. -And at least, but inside the script itself, put the function <function name> {<code>}. +*petskillsupport <skill id>,<skill level>,<delay>,<percent hp>,<percent sp>; +*petheal <level>,<delay>,<percent hp>,<percent sp>; -Example: +This will make the pet use a specified support skill on the owner whenever the +HP and SP are below the given percent values, with a specified delay time +between activations. The skill numbers are as per 'db/skill_db.txt'. +'petheal' works the same as 'petskillsupport' but has the skill ID hardcoded to +28 (Heal). This command is deprecated. +It's not quite certain who's stats will be used for the skills cast, the +character's or the pets. Probably, Skotlex can answer that question. -prontera.gat,154,189,4 script Item seller 767,{ +*petskillattack <skill id>,<skill level>,<rate>,<bonusrate>; +*petskillattack2 <skill id>,<damage>,<number of attacks>,<rate>,<bonusrate>; -function SF_Selling; +These two commands will make the pet cast an attack skill on the enemy the pet's +owner is currently fighting. Skill IDs and levels are as per 'petskillsupport'. +'petskillattack2' will make the pet cast the skill with a fixed amount of damage +inflicted and the specified number of attacks. -mes "I'll open this now if you have more than 50z and you are level 50 or bigger"; -next; +All commands with delays and durations will only make the behavior active for +the specified duration of seconds, with a delay of the specified number of +seconds between activations. Rates are a chance of the effect occuring and are +given in percent. 'bonusrate' is added to the normal rate if the pet intimacy is +at the maximum possible. -if (Zeny > 50) && (BaseLevel > 50) { - mes "Welcome"; - next; - SF_Selling; - close; -} else +The behavior modified with the abovementioned commands will only be exibited if +the pet is loyal and appropriate configuration options are set in +'battle_athena.conf'. -set @needed,50-BaseLevel; -mes "You either are Level "+BaseLevel+", thus you need "+@needed+" more levels"; -mes "to be able to use this npc; or you don't have enough zeny, so get some please"; -close; +Pet scripts in the database normally run whenever a pet of that type hatches +from the egg. Other commands usable in item scripts (see 'bonus') will also +happily run from pet scripts. Apparently, the pet-specific commands will also +work in NPC scripts and modify the behavior of the current pet up until the pet +is hatched again. (Which will also occur when the character is logged in again +with the pet still out of the egg.) It is not certain for how long the effect of +such command running from an NPC script will eventually persist, but apparently, +it is possible to usefully employ them in usable item scripts to create pet +buffing items. -function SF_Selling { +Nobody tried this before, so you're essentially on your own here. - mes "Would you like to buy a phracon for 50z?"; - switch(select("Yes","No, thanks")) { +-------------------------------------- - case 1: - mes "Ok, how many?"; - input @quantity; - set @check,Zeny/50; - if (@quantity > @check) { - mes "Sorry but you can only have "+@check+" Phracons with "+Zeny; - close; - } else - next; - mes "here you have"; - set Zeny,Zeny-@quantity*50; - getitem 1010,@quantity; - close; - case 2: - mes "Good bye then"; - close; - } - } - return; -} +*bpet; +This command opens up a pet hatching window on the client connected to the +invoking character. It is used in item script for the pet incubators and will +let the player hatch an owned egg. If the character has no eggs, it will just +open up an empty incubator window. +This is still usable outside item scripts. --------------------------------------- -*getequipcardid (<equipment slot>,<card slot>); - -Returns value from equipped item slot in the indicated slot: - -getequipcardid(num,slot) +*makepet <pet id>; -where: - num = eqip position slot - slot = 0,1,2,3 (Card Slot N) +This command will create a pet egg and put it in the invoking character's +inventory. The kind of pet is specified by pet ID numbers listed in +'db/pet_db.txt'. The egg is created exactly as if the character just successfuly +caught a pet in the normal way. -This func returns CARD ID, 255,254,-255 (for card 0, if the item is produced) it's useful -when you want to check item cards or if it's signed. Useful for such quests as -"Sign this refined item with players name" etc; - Hat[0] +4 -> Player's Hat[0] +4 + // This will make you a poring: + makepet 1002; -By Lupus +Notice that you absolutely have to create pet eggs with this command. If you try +to give a pet egg with 'getitem', pet data will not be created by the char +server and the egg will disappear when anyone tries to hatch it. --------------------------------------- - -*warpparty "mapname.gat",x,y,<party_id>; - -Warps a party to specified map and coordinate given the party ID, which you can get with -getcharid(1). You can also request another party id given a member's name with getcharid(1,<player_name>). - -Example: -mes "[Party Warper]"; -mes "Here you go!"; -close2; -set @id,getcharid(1); -warpparty "prontera.gat",150,100,@id; -close; - ---------------------------------------- - -*warpchar "mapname.gat",x,y,<char_id>; - -Warps another player to specified map and coordinate given the char id, which you can get with -getcharid(0,<player_name>). Obviously this is useless if you want to warp the same player that -is executing this script, unless it's some kind of "chosen" script. - -Example: - -warpchar "prontera.gat",150,100,20000001; - ---------------------------------------- - -*warpguild "mapname.gat",x,y,<guild_id>; - -Warps a guild to specified map and coordinate given the guild id, which you can get with -getcharid(2). You can also request another guild id given the member's name with getcharid(2,<player_name>). - -Example: - -warpguild "prontera.gat",x,y,Guild_ID; - --------------------------------------- Whew. -What's about all of them. +That's about all of them. |