script_commands.txt 197 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000
  1. //===== Athena Script =====================================
  2. //= eAthena Script Commands
  3. //===== By ================================================
  4. //= Fredzilla
  5. //===== Helped By =========================================
  6. //= Terminal Vertex & Z3R0 - Helped define getmapxy
  7. //= HappyDenn - Gave everything to do with getpartymember
  8. //= a great help
  9. //= Maeki Rika - A section on general concepts and lots of
  10. //= other updates and additions.
  11. //===== Version ===========================================
  12. //= 2.7c
  13. //=========================================================
  14. //= 1.0 - First release, filled will as much info as I could
  15. //= remember or figure out, most likely there are errors,
  16. //= and things I have missed out
  17. //= 1.1 - Added better discription for "getmapxy"
  18. //= 1.2b- Added a description for getpartymember
  19. //= (+few spelling mistakes corrected)
  20. //= 2.0 - +79kb extra stuff and numerous corrections by
  21. //= Maeki Rika.
  22. //= 2.1 - Small but important corrections, more proofreading.
  23. //= Some important discoveries in item functions, the
  24. //= secret of making VVS weapons with 'getitem2' and
  25. //= other news. (Rika again) +10kb :)
  26. //= 2.2 - added getItemInfo description [Lupus]
  27. //= 2.3 - added plenty of info for recent (and not so) script commands I added
  28. // [Skotlex]
  29. //= 2.4 - Explained the upper parameter of jobchange. [Skotlex]
  30. //= 2.5 - Added pow, sqrt and distance. [Lance]
  31. //= 2.6 - Added setd and getd. [Lance]
  32. //= 2.7 - petstat command. [Lance]
  33. //= 2.7a - delitem2, countitems2 commands [Lupus]
  34. //= 2.7b - clone command [Skotlex]
  35. //= 2.7c - disguise / undisguise, query_sql commands [Lupus]
  36. //===== Compatible With ===================================
  37. //= LOL, can be used by anyone hopefully
  38. //===== Description =======================================
  39. //= A reference manual for the eAthena scripting language
  40. //=========================================================
  41. This document is a reference manual for all the scripting commands and functions
  42. available in current eAthena SVN. It is not a simple tutorial. When people tell
  43. you to "Read The F***ing Manual", they mean this.
  44. The information was mostly acquired through looking up how things actually work
  45. in the source code of the server, which was written by many people over time,
  46. and lots of them don't speak English and never left any notes - or are otherwise
  47. not available for comments. As such, anything written in here might not be
  48. correct, it is only correct to the best of our knowledge, which is limited.
  49. This document is poorly structured and rather messy in general. In fact, further
  50. cleaning up and reordering this document is probably pointless, due to upcoming
  51. switch to Lua scripting language, which will rid us of most of the problems
  52. mentioned herein and make a new manual necessary. But while we have this one, we
  53. should make the most of it, and it might be helpful in making sure the new Lua
  54. engine can actually do everything useful that the old engine could.
  55. This is not a place to teach you basic programming. This document will not teach
  56. you basic programming by itself. It's more of a reference for those who have at
  57. least a vague idea of what they want to do and want to know what tools they have
  58. available to do it. We've tried to keep it as simple as feasible, but if you
  59. don't understand it, getting a clear book on programming in general will help
  60. better than yelling around the forum for help.
  61. A little learning never caused anyone's head to explode.
  62. Structure
  63. ---------
  64. The commands and functions are listed in no particular order:
  65. *Name of the command and how to call it.
  66. Descriptive text
  67. Small example if possible. Will usually be incomplete, it's there just to
  68. give you an idea of how it works in practice.
  69. To find a specific command, use Ctrl+F, (or whatever keys call up a search
  70. function in whatever you're reading this with) put an * followed by the command
  71. name, and it should find the command description for you.
  72. If you find anything omitted, please respond. :)
  73. Syntax
  74. ------
  75. Throughout this document, wherever a command wants an argument, it is given in
  76. <angle brackets>. This doesn't mean you should type the angle brackets. :) If an
  77. argument of a command is optional, it is given in {curly brackets}. You've
  78. doubtlessly seen this convention somewhere, if you didn't, get used to it,
  79. that's how big boys do it. If a command can optionally take an unspecified
  80. number of arguments, you'll see a list like this:
  81. command <argument>{,<argument>...<argument>}
  82. This still means they will want to be separated by commas.
  83. Where a command wants a string, it will be given in "quotes", if it's a number,
  84. it will be given without them. Normally, you can put an expression, like a bunch
  85. of functions or operators returning a value, in (round brackets) instead of most
  86. numbers. Round brackets will not always be required, but they're often a good
  87. idea.
  88. Wherever you refer to a map name, it's always 'mapname.gat' or 'mapname.afm' if
  89. you are using AFM maps, (if you don't know what they are, you aren't using them)
  90. and not just 'mapname'. While some commands do know that if you didn't give
  91. '.gat', it should add it, it's pretty tricky to tell which ones they are.
  92. Script loading structure
  93. ------------------------
  94. Scripts are loaded by the map server as referenced in the 'conf/map_athena.conf'
  95. configuration file, but in the default configuration, it doesn't load any script
  96. files itself. Instead, it loads the file 'npc/scripts_main.conf' which itself
  97. contains references to other files. The actual scripts are loaded from txt
  98. files, which are linked up like this:
  99. npc: <path to a filename>
  100. Any line like this, invoked, ultimately, by 'map_athena.conf' will load up the
  101. script contained in this file, which will make the script available. No file
  102. will get loaded twice, to prevent possible errors.
  103. Another configuration file option of relevance is:
  104. delnpc: <path to a filename>
  105. This will unload a specifiled script filename from memory, which, while
  106. seemingly useless, may sometimes be required.
  107. Whenever '//' is encountered in a line upon reading, everything beyond this on
  108. that line is considered to be a comment and is ignored. This works wherever you
  109. place it.
  110. Upon loading all the files, the server will execute all the top-level commands
  111. in them. No variables exist yet at this point, no commands can be called other
  112. than those given in this section. These commands set up the basic server script
  113. structure - create NPC objects, spawn monster objects, set map flags, etc. No
  114. code is actually executed at this point except them. The top-level commands the
  115. scripting are pretty confusing, since they aren't structured like you would
  116. expect commands, command name first, but rather, normally start with a map name.
  117. What's more confusing about the top-level commands is that most of them use a
  118. tab symbol to divide their arguments.
  119. To prevent problems and confusion, the tab symbols are written as '%TAB%'
  120. throughout this document, even though this makes the text a bit less readable.
  121. Using an invisible symbol to denote arguments is one of the bad things about
  122. this language, but we're stuck with it for now. :)
  123. Here is a list of valid top-level commands:
  124. ** Set a map flag:
  125. <map name>%TAB%mapflag%TAB%<flag>
  126. This will, upon loading, set a specified map flag on a map you like. These are
  127. normally in files inside 'conf/mapflag' and are loaded first, so by the time the
  128. server's up, all the maps have the flags they should have. Map flags determine
  129. the behavior of the map regarding various common problems, for a better
  130. explanation, see 'setmapflag'.
  131. ** Create a permanent monster spawn:
  132. <map name>,<x1>,<y1>,<x2>,<y2>%TAB%monster%TAB%<monster name>%TAB%<mob id>,<amount>,<delay1>,<delay2>,<event>
  133. Map name is the name of the map the monsters will spawn on. x1/y1-y1/y2 is a
  134. square of map coordinates which will limit where they will initially spawn.
  135. Putting zeros instead of these coordinates will spawn the monsters randomly.
  136. It's not certain whether monsters will later be able to venture out of this
  137. square when randomly moving or not. (Can anyone confirm?)
  138. Monster name is the name the monsters will have on screen, and has no relation
  139. whatsoever to their names anywhere else. It's the mob id that counts, which
  140. identifies monster record in 'mob_db.txt' database of monsters. If the mob name
  141. is given as "--ja--", the 'japanese name' field from the monster database is
  142. used, (which, in eAthena, actually contains an english name) if it's "--en--",
  143. it's the 'english name' from the monster database (which contains an uppercase
  144. name used to summon the monster with a GM command).
  145. If you add 4000 to the monster ID, the monster will be spawned in a 'big
  146. version', (monster size class will increase) and if you add 2000, the 'tiny
  147. version' of the monster will be created. This will not, however, make the
  148. monster spawn with a bigger or smaller sprite, like with
  149. @monstersmall/@monsterbig GM commands. Monster size class relates only to the
  150. damage calculation.
  151. Amount is the amount of monsters that will be spawned when this command is
  152. executed, it is affected by spawn rates in 'battle_athena.conf'.
  153. Delay1 and delay2 are the monster respawn delays - the first one counts the time
  154. since a monster defined in this spawn was last respawned and the second one
  155. counts the time since the monster of this spawn was last killed. Whichever turns
  156. out to be higher will be used. If the resulting number is smaller than a random
  157. value between 5 and 10 seconds, this value will be used instead. (Which is
  158. normally the case if both delay values are zero.) If both delay values are -1,
  159. the monster will never respawn upon death until the server restarts. The times
  160. are given in 1/1000ths of a second.
  161. Level overrides the monster's level from the monster id database, if it is 0,
  162. the level from the database is used.
  163. ** Define a warp point
  164. <from map name>,<fromX>,<fromY>,<facing>%TAB%warp%TAB%<warp name>%TAB%<spanx>,<spany>,<to map name>,<toX>,<toY>
  165. This will define a warp NPC that will warp a player between maps, and while most
  166. arguments of that are obvious, some deserve special mention.
  167. SpanX and SpanY will make the warp sensitive to a character who didn't step
  168. directly on it, but walked into a zone which is centered on the warp from
  169. coordinates and is SpanX in each direction across the X axis and SpanY in each
  170. direction across the Y axis.
  171. Warp NPC objects also have a name, because you can use it to refer to them later
  172. with 'enablenpc'/'disablenpc'
  173. Facing of a warp object is irrelevant, it is not used in the code and all
  174. current scripts have a zero in there.
  175. ** Define an NPC object.
  176. <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,{<code>}
  177. <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>}
  178. This will place an NPC object on a specified map at the specified location, and
  179. is a top-level command you will use the most in your custom scripting. The NPCs
  180. are triggered by clicking on them, and/or by walking in their trigger area, if
  181. defined, see that below.
  182. Facing is a direction the NPC sprite will face in. Not all NPC sprites have
  183. different images depending on the direction you look from, so for some facing
  184. will be meaningless. Facings are counted counterclockwise in increments of 45
  185. degrees, where 0 means facing towards the top of the map. (So to turn the sprite
  186. towards the bottom of the map, you use facing 4, and to make it look southeast
  187. it's facing 5.)
  188. Sprite id is the sprite number used to display this particular NPC. For a full
  189. list of sprite id numbers see http://kalen.s79.xrea.com/npc/npce.shtml You may
  190. also use a monster's ID number instead to display a monster sprite for this NPC.
  191. It is possible to use a job sprite as well, but you must first define it as a
  192. monster sprite in 'mob_avail.txt', a full description on how to do this is for
  193. another manual. A '-1' sprite id will make the NPC invisible (and unclickable).
  194. A '111' sprite id will make an NPC which does not have a sprite, but is still
  195. clickable, which is useful if you want to make a clickable object of the 3D
  196. terrain.
  197. TriggerX and triggerY, if given, will define an area, centered on NPC and
  198. spanning triggerX cells in every direction across X and triggerY in every
  199. direction across Y. Walking into that area will trigger the NPC. If no
  200. 'OnTouch:' special label is present in the NPC code, the execution will start
  201. from the beginning of the script, otherwise, it will start from the 'OnTouch:'
  202. label.
  203. NPC name is kinda special, because it's not only the name of NPC you will see on
  204. screen. It's formatted this way:
  205. <Screen name>{#<Extra name identifier>}{::<Label name>}
  206. The extra identifier is there that you can make an npc with an invisible name
  207. (just omit the screen name, but keep the identifier name) and so that you can
  208. refer to several NPCs which have the same name on screen, which is useful to
  209. make an NPC that relocates depending on special conditions, for example - you
  210. define several NPC objects and hide all except one.
  211. ('Hunter#hunter1','Hunter#hunter2'...) The extra name identifiers will let your
  212. code tell them apart.
  213. Label name is used to duplicate NPC objects (more on that below).
  214. The complete NPC name (Screen name + extra identifier) may not exceed 24
  215. characters. The label name is counted separately but also limited to 24
  216. characters.
  217. The code part is the script code that will execute whenever the NPC is
  218. triggered. It may contain commands and function calls, descriptions of which
  219. compose most of this document. It has to be in curly brackets, unlike elsewhere
  220. where we use curly brackets, these do NOT signify an optional parameter.
  221. ** Define an NPC duplicate.
  222. <map name>,<x>,<y>,<facing>%TAB%duplicate(<NPC label>)%TAB%<sprite id>
  223. <map name>,<x>,<y>,<facing>%TAB%duplicate(<NPC label>)%TAB%<sprite id>,<triggerX>,<triggerY>
  224. This will duplicate an NPC referred to by the label. The duplicate runs the same
  225. code as the NPC it refers to, but may have different location, facing and sprite
  226. ID. Whether it may actually have it's own size of trigger area is unclear at the
  227. moment - if you need that, try it and tell us of the results.
  228. ** Define a 'floating' NPC object.
  229. -%TAB%script%TAB%-1,{<code>}
  230. This will define an NPC object not triggerable by normal means. This would
  231. normally mean it's pointless since it can't do anything, but there are
  232. exceptions, mostly related to running scripts at specified time, which is what
  233. these floating NPC objects are for. More on that below.
  234. ** Define a shop NPC.
  235. <map name>,<x>,<y>,<facing>%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
  236. This will define a shop NPC, which, when triggered (which can only be done by
  237. clicking) will cause a shop window to come up. No code whatsoever runs in shop
  238. NPCs and you can't change the prices otherwise than by editing the script
  239. itself. (No variables even exist at this point of scripting, so don't even
  240. bother trying to use them.)
  241. The item id is the number of item in the 'item_db.txt' database. If Price is set
  242. to -1, the 'buy price' given in the item database will be used. Otherwise, the
  243. price you gave will be used for this item, which is how you create differing
  244. prices for items in different shops.
  245. ** Define a function object
  246. function%TAB%<function name>%TAB%{<code>}
  247. This will define a function object, callable with the 'callfunc' command (see
  248. below). This object will load on every map server separately, so you can get at
  249. it from anywhere. It's not possible to call the code in this object by
  250. anything other than the 'callfunc' script command.
  251. The code part is the script code that will execute whenever the function is
  252. called with 'callfunc'. It has to be in curly brackets, unlike elsewhere where
  253. we use curly brackets, these do NOT signify an optional parameter.
  254. ** Alter a map cell
  255. <map name>%TAB%setcell%TAB%<type>,<x1>,<y1>,<x2>,<y2>
  256. This is sneaky, and isn't used in any official scripts, but it will let you
  257. define an area (x1/y1-x2/y2 square) of a map as having cell type 'type', where
  258. type is a number, which, among other things, defines whether the area is
  259. walkable or not, whether it has Basilica working in it or not, and some other
  260. things. This is a solution just itching for a problem and there's a number of
  261. interesting things you could use it for. Further investigation on what types are
  262. valid and mean what exactly is pending.
  263. Once an object is defined which has a 'code' field to it's definition, it
  264. contains script commands which can actually be triggered and executed.
  265. What a RID is and why do you need to know
  266. -----------------------------------------
  267. Most scripting commands and functions will want to request data about a
  268. character, store variables referenced to that character, send stuff to the
  269. client connected to that specific character. Whenever a script is invoked by a
  270. character, it is passed a so-called RID - this is the character ID number of a
  271. character that caused the code to execute by clicking on it, walking into it's
  272. OnTouch zone, or otherwise.
  273. If you are only writing common NPCs, you don't need to bother with it. However,
  274. if you use functions, if you use timers, if you use clock-based script
  275. activation, you need to be aware of all cases when a script execution can be
  276. triggered without a RID attached. This will make a lot of commands and functions
  277. unusable, since they want data from a specific character, want to send stuff to
  278. a specific client, want to store variables specific to that character, and they
  279. would not know what character to work on if there's no RID.
  280. Unless you use 'attachrid' to explicitly attach a character to the script first.
  281. Whenever we say 'invoking character', we mean 'the character who's RID is
  282. attached to the running script. The script function "playerattached" can be
  283. used to check which is the currently attached player to the script (it will
  284. return 0 if the there is no player attached or the attached player no longer
  285. is logged on to the map-server).
  286. Item and pet scripts
  287. --------------------
  288. Each item in the item database has two special fields - EquipScript and
  289. UseScript. The first is script code run every time a character equips the item,
  290. with the RID of the equipping character. Every time they unequip an item, all
  291. temporary bonuses given by the script commands are cleared, and all the scripts
  292. are executed once again to rebuild them. This also happens in several other
  293. situations (like upon login) but the full list is currently unknown.
  294. UseScript is a piece of script code run whenever the item is used by a character
  295. by doubleclicking on it.
  296. Not all script commands work properly in the item scripts. Where commands and
  297. functions are known to be meant specifically for use in item scripts, they are
  298. described as such.
  299. Every pet in the pet database has a PetScript field, which determines pet
  300. behavior. It is invoked wherever a pet of the specified type is spawned.
  301. (hatched from an egg, or loaded from the char server when a character who had
  302. that pet following them connects) This may occur in some other situations as
  303. well. Don't expect anything other than commands definitely marked as usable in
  304. pet scripts to work in there reliably.
  305. Numbers
  306. -------
  307. Beside the common decimal numbers, which are nothing special whatsoever (though
  308. do not expect to use fractions, since ALL numbers are integer in this language),
  309. the script engine also handles hexadecimal numbers, which are otherwise
  310. identical. Writing a number like '0x<hex digits>' will make it recognised as a
  311. hexadecimal value. Notice that 0x10 is equal to 16. Also notice that if you try
  312. to 'mes 0x10' it will print '16'.
  313. This is not used much, but it pays to know about it.
  314. Variables and scope
  315. -------------------
  316. The meat of every programming language is variables - places where you store
  317. data.
  318. Variables are divided into global (not attached to any specific RID, and
  319. independent of whoever triggered the object) and local (attached to a specific
  320. character object or a specific account object). They are further divided into
  321. permanent (they come back when the server resets) and temporary (they only
  322. persist until the server dies). This is what's called variable scope. :)
  323. Unlike in more advanced languages, all temporary variables are essentially
  324. 'global', but not in the sense described above - if one NPC sets a temporary
  325. variable, even if it is character based, if that character triggers another NPC
  326. object, the variable will still be there, so you should be careful and set the
  327. variables you mean to be temporary to something sensible before using them. It
  328. also pays to keep variable names descriptive and reasonably long.
  329. Variable scope is defined by a prefix before the variable name:
  330. " " - Thats right, nothing before a variable, this a permanent variable
  331. attached to the character object.
  332. "@" - A temporary version of a character-based variable.
  333. SVN versions before 2094 revision and RC5 version will also treat 'l' as
  334. a temporary variable prefix, so bevare of having variable names starting
  335. with 'l', they will also be considered temporary, even if you didn't mean
  336. them to be!
  337. "$" - A global permanent variable.
  338. They are stored in "save\mapreg.txt" file and are the only kind of
  339. variables stored in a text file in the SQL version.
  340. "$@" - A global temporary variable.
  341. This is important for scripts which are called with no RID attached, that
  342. is, not triggered by a specific character object.
  343. "#" - A permanent account-based variable.
  344. They are stored with all the account data in "save\accreg.txt" in TXT
  345. versions and in the SQL versions in the 'global_reg_value' table using
  346. type 2.
  347. "##" - A permanent account-based variable stored by the login server.
  348. They are stored in "save\account.txt" and in the SQL versions in the
  349. 'global_reg_value' table, using type 1. The only difference you will
  350. note from normal # variables is when you have multiple char-servers
  351. connected to the same login server. The # variables are unique to each
  352. char-server, while the ## variables are shared by all these
  353. char-servers.
  354. Some variables are special, that is, they are already defined for you by the
  355. scripting engine. You can see the full list somewhere in 'db/const.txt', which
  356. is a file you should read, since it also allows you to replace lots of numbered
  357. arguments for many commands with easier to read text. The special variables most
  358. commonly used are all permanent character-based variables:
  359. StatusPoint - Amount of status points remaining.
  360. BaseLevel - Current base level
  361. SkillPoint - Amount of skill points remaining
  362. Class - Current job
  363. Upper - 1 if the character is an advanced job class.
  364. Zeny - Current amount of zeny
  365. Sex - Character's gender, 0 if female, 1 if male.
  366. Weight - The weight the character currently carries.
  367. MaxWeight - The maximum weight the character can carry.
  368. JobLevel - Character's job level
  369. BaseExp - The amount of base experience points the character has.
  370. Notice that it's zero (or close) if the character just got a level.
  371. JobExp - Same for job levels
  372. NextBaseExp - Amount of experience points needed to reach the next base level.
  373. NextJobExp - Same for job levels.
  374. Hp - Current amount of hit points.
  375. MaxHp - Maximum amount of hit points.
  376. Sp - Current spell points.
  377. MaxSp - Maximum amount of spell points.
  378. BaseJob - This is sneaky, apparently meant for baby class support.
  379. This will supposedly equal Job_Acolyte regardless of whether the
  380. character is an acolyte or a baby acolyte, for example.
  381. Karma - The character's karma. Karma system is not fully functional, but
  382. this doesn't mean this doesn't work at all. Not tested.
  383. Manner - The character's manner rating. Becomes negative if the player
  384. utters words forbidden through the use of 'manner.txt' client-side
  385. file.
  386. While these behave as variables, do not always expect to just set them - it is
  387. not certain whether this will work for all of them. Whenever there is a command
  388. or a function to set something, it's usually preferable to use that instead. The
  389. notable exception is Zeny, which you can and often will address directly -
  390. setting it will make the character own this number of zeny.
  391. All of the above variables store numbers. They can store positive and negative
  392. numbers, but only whole numbers (so don't expect to do any fractional math). You
  393. can also store a string in a variable, but this means naming it specially to
  394. denote it contains text rather than a number:
  395. @variable$ is a temporary string variable.
  396. $@variable$ is a global temporary string variable.
  397. Etc, etc.
  398. If a variable was never set, it is considered to equal zero (for number
  399. variables) or an empty string ("", nothing between the quotes) for string
  400. variables. Once you set it to that, the variable is as good as forgotten
  401. forever, and no trace remains of it even if it was stored with character or
  402. account data.
  403. Arrays
  404. ------
  405. Arrays (in eAthena at least) are essentially a set of variables going under the
  406. same name. You can tell between the specific variables of an array with an
  407. 'array index', a number of a variable in that array:
  408. <variable name>[<array index>]
  409. Variables stored in this way, inside an array, are also called 'array elements'.
  410. Arrays are specifically useful for storing a set of similar data (like several
  411. item IDs for example) and then looping through it. You can address any array
  412. variable as if it was a normal variable:
  413. set @arrayofnumbers[0],1;
  414. You can also do sneaky things like using a variable (or an expression, or even a
  415. value from an another array) to get at an array value:
  416. set @x,100;
  417. set @arrayofnumbers[@x],10;
  418. This will make @arrayofnumbers[100] equal to 10.
  419. Notice that index numbering always starts with 0. Arrays cannot hold more than
  420. 128 variables. (So the last one can't have a number higher than 127)
  421. And array indices probably can't be negative. Nobody tested what happens when
  422. you try to get a negatively numbered variable from an array, but it's not going
  423. to be pretty. :)
  424. Arrays can naturaly store strings:
  425. @menulines$[0] is the 0th element of the @menulines$ array of strings. Notice
  426. the '$', normally denoting a string variable, before the square brackets that
  427. denotes an array index.
  428. Operators
  429. ---------
  430. Operators are things you can do to variables and numbers. They are either the
  431. common mathematical operations or conditional operators
  432. + - will add two numbers. If you try to add two strings, the result will be a
  433. string glued together at the +. You can add a number to a string, and the
  434. result will be a string. No other math operators work with strings.
  435. - - will subtract two numbers.
  436. * - will multiply two numbers.
  437. / - will divide two numbers. Note that this is an integer division, i.e.
  438. 7/2 is not equal 3.5, it's equal 3.
  439. % - will give you the remainder of the division. 7%2 is equal to 1.
  440. There are also conditional operators. This has to do with the conditional
  441. command 'if' and they are meant to return either 1 if the condition is satisfied
  442. and 0 if it isn't. (That's what they call 'boolean' variables. 0 means 'False'.
  443. Anything except the zero is 'True' Odd as it is, -1 and -5 and anything below
  444. zero will also be True.)
  445. You can compare numbers to each other and you compare strings to each other, but
  446. you can not compare numbers to strings.
  447. == - Is true if both sides are equal. For strings, it means they are the same.
  448. >= - True if the first value is equal to, or greater than, the second value.
  449. <= - True if the first value is equal to, or less than, the second value
  450. > - True if the first value greater than the second value
  451. < - True if the first value is less than the second value
  452. != - True if the first value IS NOT equal to the second one
  453. Examples:
  454. 1=1 is True.
  455. 1<2 is True while 1>2 is False.
  456. @x>2 is True if @x is equal to 3. But it isn't true if @x is 2.
  457. Only '==' and '!=' have been tested for comparing strings. Since there's no way
  458. to code a seriously complex data structure in this language, trying to sort
  459. strings by alphabet would be pointless anyway.
  460. Comparisons can be stacked in the same condition:
  461. && - Is True if and only if BOTH sides are true.
  462. ('1==1 && 2=2' is true. '2=1 && 1=1' is false.)
  463. || - Is True if either side of this expression is True.
  464. 1=1 && 2=2 is True.
  465. 1=1 && 2=1 is False.
  466. 1=1 || 2=1 is True.
  467. Logical operators work only on numbers:
  468. << - Left shift.
  469. >> - Right shift.
  470. & - And.
  471. | - Or.
  472. ^ - Xor.
  473. If you don't know what these five mean, don't bother, you don't need them.
  474. Labels
  475. ------
  476. Within executable script code, some lines can be labels:
  477. <label name>:
  478. Labels are points of reference in your script, which can be used to route
  479. execution with 'goto', 'menu' and 'jump_zero' commands, invoked with 'doevent'
  480. and 'donpcevent' commands and are otherwise essential. A label's name may not be
  481. longer than 22 characters. (23rd is the ':'.) There is some confusion in the
  482. source about whether it's 22, 23 or 24 all over the place, so keeping labels
  483. under 22 characters could be wise. In addition to labels you name yourself,
  484. there are also some special labels which the script engine will start execution
  485. from if a special event happens:
  486. OnClock<hour><minute>:
  487. OnHour<hour>:
  488. On<weekday><hour><minute>:
  489. OnDay<month><day>:
  490. This will execute when the server clock hits the specified date or time. Hours
  491. and minutes are given in military time. ('0105' will mean 01:05 AM). Weekdays
  492. are Sun,Mon,Tue,Wed,Thu,Fri,Sat. Months are 01 to 12, days are 01 to 31.
  493. Remember the zero. :)
  494. OnInit:
  495. OnInterIfInit:
  496. OnInterIfInitOnce:
  497. OnInit will execute every time the scripts loading is complete, including when
  498. they are reloaded with @reloadscript command. OnInterIfInit will execute when
  499. the map server connects to a char server, OnInterIfInitOnce will only execute
  500. once and will not execute if the map server reconnects to the char server later.
  501. OnAgitStart:
  502. OnAgitEnd:
  503. OnAgitInit:
  504. OnAgitStart will run whenever the server shifts into WoE mode, whether it is
  505. done with @agitstart GM command or with 'AgitStart' script command. OnAgitEnd
  506. will do likewise for the end of WoE. OnAgitInit will run when castle data is
  507. loaded from the char-server by the map server.
  508. No RID will be attached while any of the abovementioned labels are triggered, so
  509. no character or account-based variables will be accessible, until you attach a
  510. RID with 'attachrid' (see below).
  511. OnTouch:
  512. This label will be executed if a trigger area is defined for the NPC object it's
  513. in. If it isn't present, the execution will start from the beginning of the NPC
  514. code. The RID of the triggering character object will be attached.
  515. PCDieEvent:
  516. PCKillEvent:
  517. PCLogoutEvent:
  518. PCLoginEvent:
  519. These four special labels will be invoked if you have set 'event_script_type'
  520. value in your 'script_athena.conf' to 1, and you can change their names by
  521. altering the configuration options in 'script_athena.conf'. It's pretty obvious
  522. when those will get triggered. For more information, see
  523. 'npc/sample/PCLoginEvent.txt'
  524. Only the special labels which are not associated with any script command are
  525. listed here. There are other kinds of labels which may be triggered in a similar
  526. manner, but they are described with their associated commands.
  527. Scripting commands and functions
  528. --------------------------------
  529. The commands and functions are listed here in no particular order. There's a
  530. difference between commands and functions - commands leave no 'return value'
  531. which might be used in a conditional statement, as a command argument, or stored
  532. in a variable. Calling commands as if they were functions will sometimes work,
  533. but is not advised, as this can lead to some hard to track errors. Calling
  534. functions as if they were commands will mess up the stack, so 'return' command
  535. will not return correctly after this happens in a particular script.
  536. All commands must end with a ';'. Actually, you may expect to have multiple
  537. commands on one line if you properly terminate them with a ';', but it's better
  538. if you don't, since it is not certain just whether the scripting engine will
  539. behave nicely if you do.
  540. -------------------------
  541. *playerattached;
  542. Returns the ID of the player currently attached to the script. It will return
  543. 0 if noone is attached, or if the attached player no longer exists on the map
  544. server. It is wise to check for the attached player in script functions that
  545. deal with timers as there's no guarantee the player will still be logged on
  546. when the timer triggers. Note that the ID of a player is actually their
  547. account ID.
  548. -------------------------
  549. *mes "<string>";
  550. This command will displays a box on the screen for the invoking character, if no
  551. such box is displayed already, and will print the string specified into that
  552. box. There is normally no 'close' or 'next' button on this box, unless you
  553. create one with 'close' or 'next', and while it's open the player can't do much
  554. else, so it's important to create a button later. If the string is empty, it
  555. will show up as an empty line.
  556. mes "Text that will appear in the box";
  557. Inside the string you may put color codes, which will alter the color of the
  558. text printed after them. The color codes are all '^<R><G><B>' and contain three
  559. hexadecimal numbers representing colors as if they were HTML colors - ^FF0000 is
  560. bright red, ^00FF00 is bright green, ^0000FF is bright blue, ^000000 is black.
  561. ^FF00FF is a pure magenta, but it's also a color that is considered transparent
  562. whenever the client is drawing windows on screen, so printing text in that color
  563. will have kind of a weird effect. Once you've set a text's color to something,
  564. you have to set it back to black unless you want all the rest of the text be in
  565. that color:
  566. mes "This is ^FF0000 red ^000000 and this is ^00FF00 green, ^000000 so.";
  567. Notice that the text coloring is handled purely by the client. If you use non-
  568. english characters, the color codes might get screwed if they stick to letters
  569. with no intervening space. Separating them with spaces from the letters on
  570. either side solves the problem.
  571. ---------------------------------------
  572. *goto <label>;
  573. This command will make the script jump to a label, usually used in conjunction
  574. with other command, such as "if", but often used on it's own.
  575. goto Label;
  576. mes "This will not be seen";
  577. Label:
  578. mes "This will be seen";
  579. ---------------------------------------
  580. *callfunc "<function>"{,<argument>,...<argument>};
  581. *callfunc("<function>"{,<argument>,...<argument>})
  582. This command lets you call up a function NPC. A function NPC can be called from
  583. any script on any map server. Using the 'return' command it will come back to
  584. the place that called it.
  585. place.gat,50,50,6%TAB%script%TAB%Woman%TAB%115,{
  586. mes "[Woman]"
  587. mes "Lets see if you win";
  588. callfunc "funcNPC";
  589. mes "Well done you have won";
  590. close;
  591. }
  592. function%TAB%script%TAB%funcNPC%TAB%{
  593. set @win, rand(2);
  594. if(@win==0) return;
  595. mes "Sorry you lost";
  596. end;
  597. }
  598. You can pass arguments to your function - values telling it what exactly to do -
  599. which will be available there with getarg() (see 'getarg')
  600. Notice that returning is not mandatory, you can end execution right there.
  601. If you want to return a real value from inside your function NPC, it is better
  602. to write it in the function form, which will also work and will make the script
  603. generally cleaner:
  604. place.gat,50,50,6%TAB%script%TAB%Man%TAB%115,{
  605. mes "[Man]"
  606. mes "Gimme a number!";
  607. next;
  608. input @number;
  609. if (callfunc("OddFunc",@number)) mes "It's Odd!";
  610. close;
  611. }
  612. function%TAB%script%TAB%OddFunc%TAB%{
  613. if (getarg(0)%2==0) goto ItsEven;
  614. return (1);
  615. ItsEven:
  616. return (0);
  617. }
  618. ---------------------------------------
  619. *callsub <label name>{,<argument>,...<argument>};
  620. This command will go to a specified label within the current script (do NOT use
  621. quotes around it) coming in as if it were a 'callfunc' call, and pass it
  622. arguments given, if any, which can be recovered there with 'getarg'. When done
  623. there, you should use the 'return' command to go back to the point from where
  624. this label was called. This is used when there is a specific thing the script
  625. will do over and over, this lets you use the same bit of code as many times as
  626. you like, to save space and time, without creating extra NPC objects which are
  627. needed with 'callfunc'. A label is not callable in this manner from another
  628. script.
  629. mes "[Woman]"
  630. mes "Lets see if you win";
  631. callsub Check;
  632. mes "Well done you have won";
  633. Check:
  634. set @win, rand(2);
  635. if(@win==0) return;
  636. mes "Sorry you lost";
  637. ---------------------------------------
  638. *return {(<value>)};
  639. When you use callsub or callfunc, this command allows you to go back to the
  640. calling script. You can optionally return with a value telling the calling
  641. program what exactly happened. To get at this value, you will have to use the
  642. 'set' command:
  643. set <variable>,callfunc "<your function>"
  644. Note the round brackets. Turns out you have to enclose just about anything in
  645. brackets if it isn't a straight number for the return command to work with it:
  646. return (@x+@y);
  647. Also note that
  648. if (<condition>) return (<whatever>);
  649. does NOT always work, even though it would make scripts a lot cleaner, and it
  650. might be wiser to avoid using it like that.
  651. For an example see 'callfunc' and 'callsub'
  652. ---------------------------------------
  653. *getarg(<number>)
  654. This function is used when you use the 'callsub' or 'callfunc' commands. In the
  655. call you can specify variables that will make that call different from another
  656. one. This function willwill return an argument the function or subroutine was
  657. called with, and is the normal way to get them.
  658. This is another thing that can let you use the same but of code more than once.
  659. Argument numbering starts with 0, i.e. the first argument you gave is number 0.
  660. If no such argument was given, a zero is returned.
  661. place.gat,50,50,6%TAB%script%TAB%Woman1%TAB%115,{
  662. mes "[Woman]";
  663. mes "Lets see if you win";
  664. callfunc "funcNPC",2;
  665. mes "Well done you have won";
  666. ...
  667. place.gat,52,50,6%TAB%script%TAB%Woman2%TAB%115,{
  668. mes "[Woman]";
  669. mes "Lets see if you win";
  670. callfunc "funcNPC",5;
  671. mes "Well done you have won";
  672. ...
  673. function%TAB%script%TAB%funcNPC%TAB%{
  674. set @win, rand(getarg(0));
  675. if(@win==0) return;
  676. mes "Sorry you lost";
  677. "woman1" NPC object calls the funcNPC. The argument it gives in this call is
  678. stated as 2, so when the random number is generated by the 'rand' function, it
  679. can only be 0 or 1. Whereas "woman2" gives 5 as the argument number 0 when
  680. calling the function, so the random number could be 0, 1, 2, 3 or 4, this makes
  681. "woman2" less likely to say the player won.
  682. You can pass multiple arguments in a function call:
  683. callfunc "funcNPC",5,4,3;
  684. getarg(0) would be 5, getarg(1) would be 4 and getarg(2) would be 3.
  685. 'getarg()' can also be used to carry information back from using the "callfunc"
  686. script command, if the 'return' command is set to return a value:
  687. place.gat,50,50,6%TAB%script%TAB%Woman%TAB%115,{
  688. mes "[Woman]";
  689. mes "Lets see if you win";
  690. callfunc "funcNPC";
  691. mes "Well it seems you have "+getarg(0);
  692. }
  693. function%TAB%script%TAB%funcNPC%TAB%{
  694. set @win, rand(2);
  695. if(@win==0) return(won);
  696. return(lost);
  697. }
  698. It is, however, better to use 'set' to get this value instead (see 'callfunc')
  699. because otherwise you can't call functions from within other functions. (Return
  700. values mess up the stack.)
  701. ---------------------------------------
  702. *next;
  703. This command will create a 'next' button in the message window for the invoking
  704. character. If no window is currently on screen, it will be created. Used to
  705. segment NPC talking, this command is used A LOT. See 'mes'.
  706. mes "[Woman]";
  707. mes "This would appear on the page";
  708. next;
  709. // This is needed cause it is a new page and the top will now be blank
  710. mes "[Woman]";
  711. mes "This would appear on the 2nd page";
  712. ---------------------------------------
  713. *close;
  714. This command will create a 'close' button in the message window for the invoking
  715. character. If no window is currently on screen, it will be created. This is one
  716. of the ways to end a speech from an NPC. Once the button is clicked, the NPC
  717. script execution will end, and the message box will disappear.
  718. mes "[Woman]";
  719. mes "I am finished talking to you, click the close button";
  720. close;
  721. mes "This command will not run at all, cause the script has ended.";
  722. ---------------------------------------
  723. *close2;
  724. This command will create a 'close' button in the message window for the invoking
  725. character. If no window is currently on screen, it will be created. See 'close'.
  726. There is one important difference, though - even though the message box will
  727. have closed, the script execution will not stop, and commands after 'close2'
  728. will still run, meaning an 'end' has to be used to stop the script, unless you
  729. make it stop in some other manner.
  730. mes "[Woman]";
  731. mes "I will warp you now";
  732. close2;
  733. warp "place.gat",50,50;
  734. end;
  735. Don't expect things to run smoothly if you don't make your scripts 'end'.
  736. ---------------------------------------
  737. *menu "<menu option>",<label>{,"<menu option>",<label>...};
  738. This command will create a selectable menu for the invoking character. Only one
  739. menu can be on screen at the same time.
  740. Depending on what the player picks from the menu, the script execution will
  741. continue from the corresponding label. (it's string-label pairs, not label-
  742. string)
  743. It also sets a special temporary character variable @menu, which contains the
  744. number of option the player picked. (Numbering of options starts at 1.)
  745. menu "I want to Start",L_Start,"I want to end",L_End;
  746. L_Start:
  747. //If they click "I want to Start" they will end up here
  748. L_End:
  749. //If they click "I want to end" they will end up here
  750. If a label is '-', the script execution will continue right after the menu
  751. command if that option is selected, this can be used to save you time, and
  752. optimize big scripts.
  753. menu "I want to Start",-,"I want to end",L_End;
  754. //If they click "I want to Start" they will end up here
  755. L_End:
  756. //If they click "I want to end" they will end up here
  757. Both these examples will perform the same task.
  758. If you give an empty string as a menu item, the item will not display. This
  759. can effectively be used to script dynamic menus by using empty string for
  760. entries that should be unavailable at that time.
  761. You can do it by using arrays, but watch carefully - this trick isn't high
  762. wizardry, but minor magic at least. You can't expect to easily duplicate it
  763. until you understand how it works.
  764. Create a temporary array of strings to contain your menu items, and populate it
  765. with the strings that should go into the menu at this execution, making sure not
  766. to leave any gaps. Normally, you do it with a loop and an extra counter, like
  767. this:
  768. setarray @possiblemenuitems$[0],<list of potential menu items>;
  769. set @i,0; // That's our loop counter.
  770. set @j,0; // That's the menu lines counter.
  771. makemenuloop:
  772. // We record the number of option into the list of options actually
  773. // available. That 'condition' is whatever condition that determines whether
  774. // a menu item number @i actually goes into the menu or not.
  775. if (<condition>) set @menulist$[@j],@possiblemenuitems$[@i];
  776. // We just copied the string, we do need it's number for later though, so we
  777. // file it away as well.
  778. if (<condition>) set @menureference[@j],@i;
  779. // Since we've just added a menu item into the list, we increment the menu
  780. // lines counter.
  781. if (<condition>) set @j,@j+1;
  782. // We go on to the next possible menu item.
  783. set @i,@i+1;
  784. // And continue looping through the list of possible menu items until it
  785. // ends.
  786. if (@i<=getarraysize(@possiblemenuitems)) goto makemenuloop;
  787. This will create you an array @menulist$ which contains the text of all items
  788. that should actually go into the menu based on your condition, and an array
  789. @menureference, which contains their numbers in the list of possible menu items.
  790. (Remember, arrays start with 0.) There's less of them than the possible menu
  791. items you've defined, but the menu command can handle the empty lines - only if
  792. they are last in the list, and if it's made this way, they are. Now comes a
  793. dirty trick:
  794. // X is whatever the most menu items you expect to handle.
  795. menu @menulist$[0],-,@menulist$[1],-,....@menulist$[<X>],-;
  796. This calls up a menu of all your items. Since you didn't copy some of the
  797. possible menu items into the list, it's end is empty and so no menu items will
  798. show up past the end. But this menu call doesn't jump anywhere, it just
  799. continues execution right after the menu command. (And it's a good thing it
  800. doesn't, cause you can only explicitly define labels to jump to, and how do you
  801. know which ones to define if you don't know beforehand which options will end up
  802. where in your menu?)
  803. But how do you figure out which option the user picked? Enter the @menu.
  804. @menu contains the number of option that the user selected from the list,
  805. starting with 1 for the first option. You know now which option the user picked
  806. and which number in your real list of possible menu items it translated to:
  807. mes "You selected "+@possiblemenuitems$[@menureference[@menu-1]]+"!";
  808. @menu is the number of option the user picked.
  809. @menu-1 is the array index for the list of actually used menu items that we
  810. made.
  811. @menureference[@menu-1] is the number of the item in the array of possible menu
  812. items that we've saved just for this purpose.
  813. And @possiblemenuitems$[@menureference[@menu-1]] is the string that we used to
  814. display the menu line the user picked. (Yes, it's a handful, but it works.)
  815. You can set up a bunch of 'if (@menureference[@menu-1]==X) goto Y' statements to
  816. route your execution based on the line selected and still generate a different
  817. menu every time, which is handy when you want to, for example, make users select
  818. items in any specific order before proceeding, or make a randomly shuffled menu.
  819. Kafra code bundled with the standard distribution uses a similar array-based
  820. menu technique for teleport lists, but it's much simpler and doesn't use @menu,
  821. probably since that wasn't documented anywhere.
  822. See also 'select', which is probably better in this particular case. Instead of
  823. menu, you could use 'select' like this:
  824. set @dummy,select(@menulist$[0],@menulist$[1],....@menulist$[<X>]);
  825. For the purposes of the technique described above these two statements are
  826. perfectly equivalent.
  827. ---------------------------------------
  828. *rand(<number>{,<number>});
  829. This function returns a number, randomly positioned between 0 and the number you
  830. specify (if you only specify one) and the two numbers you specify if you give it
  831. two.
  832. rand(10) would result in 0,1,2,3,4,5,6,7,8 or 9
  833. rand(2,10) would result in 2,3,4,5,6,7,8,9 or 10
  834. ---------------------------------------
  835. *warp "<map name>",<x>,<y>;
  836. This command will take the invoking character to the specifed map, and if
  837. wanted, specified coordinates too, but these can be random.
  838. warp "place.gat",50,55;
  839. This would take them to X 50 Y 55 on the map called "place". If your X and Y
  840. coordinates land on an unwalkable map square, it will send the warped character
  841. to a random place. Same will happen if they are both zero:
  842. warp "place.gat",0,0;
  843. Notice that while warping people to coordinates 0,0 will normally get them into
  844. a random place, it's not certain to always be so. Darned if I know where this is
  845. actually coded, it might be that this happens because square 0,0 is unwalkable
  846. on all official maps. If you're using custom maps, beware.
  847. There are also three special 'map names' you can use.
  848. "Random" will warp the player randomly on the current map.
  849. "Save" and "SavePoint" will warp the player back to their savepoint.
  850. ---------------------------------------
  851. *areawarp "<from map name>",<x1>,<y1>,<x2>,<y2>,"<to map name>",<x3>,<y3>;
  852. This command is similar to 'warp', however, it will not refer to the invoking
  853. character, but instead, all characters within a specified area, defined by the
  854. x1/y1-x2/y2 square, will be warped. Nobody outside the area will be affected,
  855. including the activating character, if they are outside the area.
  856. areawarp "place.gat",10,10,120,120,"place2.gat",150,150;
  857. Everyone that is in the area between X 10 Y 10 and X 120 Y 120, in a square
  858. shape, on the map called "place", will be affected, and warped to "place2" X 150
  859. Y 150
  860. areawarp "place.gat",10,10,120,120,"place2.gat",0,0;
  861. By using ,0,0; as the destination coordinates it will take all the characters in
  862. the affected area to a random set of co-ordinates on "place2".
  863. Like 'warp', areawarp will also explicitly warp characters randomly into the
  864. current map if you give the 'to map name' as "Random".
  865. See also 'warp'.
  866. ---------------------------------------
  867. *heal <hp>,<sp>;
  868. This command will heal a set amount of HP and/or SP on the invoking character.
  869. heal 30000,0; // This will heal 30,000 HP
  870. heal 0,30000; // This will heal 30,000 SP
  871. heal 300,300; // This will heal 300 HP and 300 SP
  872. This command just alters the hit points and spell points of the invoking
  873. character and produces no other output whatsoever.
  874. ---------------------------------------
  875. *itemheal <hp>,<sp>;
  876. This command works on the invoking character like 'heal', however, it is not
  877. normally used in NPC scripts and will not work as expected there, but is used
  878. all over in item scripts.
  879. Unlike 'heal', which just alters hp/sp and doesn't do anything else at all, this
  880. command also shows healing animations for potions and other stuff, checks
  881. whether the potion was made by a famous alchemist and alters the amount healed,
  882. etc, etc. Since which kind of effect is shown depends on what item was used,
  883. using it in an NPC script will not have a desired effect.
  884. There is also a nice example on using this with the 'rand' function, to give you
  885. a random ammount of healing.
  886. // This will heal anything thing from 100 to 150 HP and no SP
  887. itemheal rand(100,150),0;
  888. ---------------------------------------
  889. *percentheal <hp>,<sp>;
  890. This command will heal the invoking character. It heals the character, but not
  891. by a set value - it adds percent of their maximum HP/SP.
  892. percentheal 100,0; // This will heal 100% HP
  893. percentheal 0,100; // This will heal 100% SP
  894. percentheal 50,50; // This will heal 50% HP and 50% SP
  895. So the amount that this will heal will depend on the total ammount of HP or SP
  896. you have maximum. Like 'heal', this will not call up any animations or effects.
  897. ---------------------------------------
  898. *jobchange <job number>{,<upper flag>};
  899. This command will change the job class of the invoking character.
  900. jobchange 1; // This would change your player into a Swordman
  901. jobchange 4002; // This would change your player into a Swordman High
  902. This command does work with numbers, but you can also use job names. The full
  903. list of job names and the numbers they correspond to can be found in
  904. 'db/const.txt'.
  905. // This would change your player into a Swordman
  906. jobchange Job_Swordman;
  907. // This would change your player into a Swordman High
  908. jobchange Job_Swordman_High;
  909. 'upper flag' can alternatively be used to specify the type of job one changes
  910. to. For example, jobchange Job_Swordman,1; will change the character to a high
  911. swordsman. The upper values are:
  912. -1 (or when omitted): preserves the current job type.
  913. 0: Normal/standard classes
  914. 1: High/Advanced classes
  915. 2: Baby classes
  916. This command will also set a permanent character-based variable
  917. 'jobchange_level' which will contain the job level at the time right before
  918. changing jobs, which can be checked for later in scripts.
  919. ---------------------------------------
  920. *input <variable>;
  921. This command will make an input box pop up on the client connected to the
  922. invoking character, to allow entering of a number or a string. This has many
  923. uses, one example would be a guessing game, also making use of the 'rand'
  924. function:
  925. mes "[Woman]";
  926. mes "Try and guess the number I am thinking of.";
  927. mes "The number will be between 1 and 10.";
  928. next;
  929. set @number, rand(1,10);
  930. input @guess;
  931. if(@guess==@number) goto L_Correct;
  932. mes "[Woman]";
  933. mes "Sorry, that wasn't the number I was thinking of.";
  934. close;
  935. L_Correct:
  936. mes "[Woman]";
  937. mes "Well done that was the number I was thinking of";
  938. close;
  939. If you give the input command a string variable to put the input in, it will
  940. allow the player to enter text. Otherwise, only numbers will be allowed.
  941. mes "[Woman]";
  942. mes "Please say HELLO";
  943. next;
  944. input @var$;
  945. if(@var$=="HELLO") goto L_Correct;
  946. mes "[Woman]";
  947. mes "Sorry you got it wrong";
  948. close;
  949. L_Correct:
  950. mes "[Woman]";
  951. mes "Well done you typed it correctly";
  952. close;
  953. Notice that in current SVN, you may not input a negative number with this
  954. command. This was done to prevent exploits in badly written scripts, which would
  955. let people, for example, put negative amounts of zeny into a bank script and
  956. recieve free zeny as a result. Unfortunately it limits the uses of the 'input'
  957. command quite a bit.
  958. ---------------------------------------
  959. *setlook <look type>,<look value>;
  960. This command will alter the look data for the invoking character. It is used
  961. mainly for changing the palette used on hair and clothes, you specify which look
  962. type you want to change, then the palette you want to use. Make sure you specify
  963. a palette number that exists/is usable by the client you use.
  964. // This will change your hair(6), so that it uses palette 8, what ever your
  965. // palette 8 is your hair will use that colour
  966. setlook 6,8;
  967. // This will change your clothes(7), so they are using palette 1, whatever
  968. // your palette 1 is, your clothes will then use that set of colours.
  969. setlook 7,1;
  970. Here are the possible look types:
  971. 0 - Base sprite
  972. 1 - Hairstyle
  973. 2 - Weapon
  974. 3 - Head bottom
  975. 4 - Head top
  976. 5 - Head mid
  977. 6 - Hair color
  978. 7 - Clothes color
  979. 8 - Shield
  980. 9 - Shoes
  981. Whatever 'shoes' means is anybody's guess, ask Gravity - the client does nothing
  982. with this value. It still wants it from the server though, so it is kept, but
  983. normally doesn't do a thing.
  984. Only the look data for hairstyle, hair color and clothes color are saved to the
  985. char server's database and will persist. The rest freely change as the character
  986. puts on and removes equipment, changes maps, logs in and out and otherwise you
  987. should not expect to set them. In fact, messing with them is generally
  988. hazardous, do it at your own risk, it is not tested what will this actually do -
  989. it won't cause database corruption and probably won't cause a server crash, but
  990. it's easy to crash the client with just about anything unusual.
  991. However, it might be an easy way to quickly check for empty view IDs for
  992. sprites, which is essential for making custom headgear.
  993. Since a lot of people have different palettes for hair and clothes, it's
  994. impossible to tell you what all the colour numbers are. If you want a serious
  995. example, there is a Stylist script inside the default eAthena installation that
  996. you can look at, this may help you create a Stylist of your own:
  997. 'custom\dye.txt'
  998. ---------------------------------------
  999. *set <variable>,<expression>;
  1000. This command will set a variable to the value that the expression results in.
  1001. This is the only way to set a variable directly.
  1002. This is the most basic script command and is uses a lot whenever you try to do
  1003. anything more advanced than just printing text into a messagebox.
  1004. set @x,100;
  1005. will make @x equal 100.
  1006. set @x,1+5/8+9;
  1007. will compute 1+5/8+9 (which is, surprisingly, 10 - remember, all numbers are
  1008. integer in this language) and make @x equal it.
  1009. ---------------------------------------
  1010. *setarray <array name>[<first value>],<value>{,<value>...<value>};
  1011. This command will allow you to quickly fill up an array in one go. Check the
  1012. Kafra scripts in the distribution to see this used a lot.
  1013. setarray @array[0], 100, 200, 300, 400, 500, 600;
  1014. First value is the index of the first element of the array to alter. For
  1015. example:
  1016. setarray @array[0],200,200,200;
  1017. setarray @array[1],300,150;
  1018. will produce:
  1019. @array[0]=200
  1020. @array[1]=300
  1021. @array[2]=150
  1022. ---------------------------------------
  1023. *cleararray <array name>[<first value to alter>],<value>,<number of values to set>;
  1024. This command will change many array values at the same time to the same value.
  1025. setarray @array[0], 100, 200, 300, 400, 500, 600;
  1026. // This will make all 6 values 0
  1027. cleararray @array[0],0,6;
  1028. // This will make array element 0 change to 245
  1029. cleararray @array[0],245,1;
  1030. // This will make elements 1 and 2 change to 345
  1031. cleararray @array[1],345,2;
  1032. See 'setarray'.
  1033. ---------------------------------------
  1034. *copyarray <to array>[<first value>],<from array>[<first value>],<amount to copy>;
  1035. This command lets you quickly shuffle a lot of data between arrays, which is in
  1036. some cases invaluable.
  1037. setarray @array[0], 100, 200, 300, 400, 500, 600;
  1038. // So we have made @array[]
  1039. copyarray @array2[0],@array[2],2;
  1040. // Now, @array2[0] will be equal to @array[2] (300) and
  1041. // @array2[1] will be equal to @array[3].
  1042. So using the examples above:
  1043. @array[0] = 100
  1044. @array[1] = 200
  1045. @array[2] = 300
  1046. @array[3] = 400
  1047. @array[4] = 500
  1048. @array[5] = 600
  1049. @array2[0] = 300
  1050. @array2[1] = 400
  1051. @array2[2] = 500
  1052. @array2[3] = 0
  1053. Notice that @array[5] wont be coppied to the second array, and it will return a
  1054. 0.
  1055. ---------------------------------------
  1056. *getarraysize(<array name>);
  1057. This function returns the number of values that are contained inside the
  1058. specified array. Notice that zeros and empty strings at the end of this array
  1059. are not counted towards this number.
  1060. For example:
  1061. setarray @array[0], 100, 200, 300, 400, 500, 600;
  1062. set @arraysize,getarraysize(@array);
  1063. This will make @arraysize == 6. But if you try this:
  1064. setarray @array[0], 100, 200, 300, 400, 500, 600, 0;
  1065. set @arraysize,getarraysize(@array);
  1066. @arraysize will still equal 6, even though you've set 7 values.
  1067. ---------------------------------------
  1068. *deletearray <array name>[<first value>],<how much to delete>
  1069. This command will delete a specified number of array elements totally from an
  1070. array, shifting all the elements beyond this towards the beginning.
  1071. // This will delete array element 0, and move all the other array elements
  1072. // up one place.
  1073. deletearray @array[0],1
  1074. // This would delete array elements numbered 1, 2 and 3, leave element 0 in its
  1075. // place, and move the other elements ups, so there are no gaps.
  1076. deletearray @array[1],3
  1077. IMPORTANT: deletarray is horribly broken since the earliest days of jAthena. It
  1078. tends to merrily remove much more variables than it's told to remove, which
  1079. makes it pretty much useless for anything other than removing an array from
  1080. memory entirely. This would be very handy, if it always worked.
  1081. ---------------------------------------
  1082. *getelementofarray(<array name>,<index>);
  1083. This function will return an array's element when given an index.
  1084. // This will find the 2nd array value
  1085. getelementofarray(@array,1)
  1086. Pretty pointless now when we have
  1087. @array[1]
  1088. which has the same effect.
  1089. ---------------------------------------
  1090. *if (<condition>) <statement>;
  1091. This is the basic conditional statement command, and just about the only one
  1092. available in this scripting language.
  1093. The condition can be any expression. All expressions resulting in a non-zero
  1094. value will be considered True, including negative values. All expressions
  1095. resulting in a zero are false.
  1096. If the expression results in True, the statement will be executed. If it isn't
  1097. true, nothing happens and we move on to the next line of the script.
  1098. if (1) mes "This will always print.";
  1099. if (0) mes "And this will never print.";
  1100. if (5) mes "This will also always print.";
  1101. if (-1) mes "Funny as it is, this will also print just fine.";
  1102. For more information on conditional operators see the operators section above.
  1103. Anything that is returned by a function can be used in a condition check without
  1104. bothering to store it in a specific variable:
  1105. if (strcharinfo(0)=="Daniel Jackson") mes "It is true, you are Daniel!";
  1106. More examples of using the 'if' command in the real world:
  1107. Example 1:
  1108. set @var1,1;
  1109. input @var2;
  1110. if(@var1==@var2) goto L_Same;
  1111. mes "Sorry that is wrong";
  1112. close;
  1113. L_Same:
  1114. close;
  1115. Example 2:
  1116. set @var1,1;
  1117. input @var2;
  1118. if(@var1!=@var2) mes "Sorry that is wrong";
  1119. close;
  1120. (Notice examples 1 and 2 have the same effect.)
  1121. Example 3:
  1122. set @var1,@var1+1;
  1123. mes "[Forgetfull Man]";
  1124. if (@var==1) mes "This is the first time you have talked to me";
  1125. if (@var==2) mes "This is the second time you have talked to me";
  1126. if (@var==3) mes "This is the third time you have talked to me";
  1127. if (@var==4) mes "This is the forth time you have talked to me, but I think I am getting amnesia, I have forgoten about you";
  1128. if (@var==4) set @var,0;
  1129. close;
  1130. Example 4:
  1131. mes "[Quest Person]";
  1132. if(countitem(512)>=1) goto L_GiveApple;
  1133. // The number 512 was found from item_db, it is the item number for the Apple.
  1134. mes "Can you please bring me an apple?";
  1135. close;
  1136. L_GiveApple:
  1137. mes "Oh an apple, I didnt want it, I just wanted to see one";
  1138. close;
  1139. Example 5:
  1140. mes "[Person Checker]";
  1141. if($name$!=null) goto L_Check;
  1142. mes "Please tell me someones name";
  1143. next;
  1144. input $name$;
  1145. set $name2$,strcharinfo(0);
  1146. mes "[Person Checker]";
  1147. mes "Thank you";
  1148. L_Check:
  1149. if($name$==strcharinfo(0) ) goto L_SameName;
  1150. mes "[Person Checker]";
  1151. mes "You are not the person that " +$name2$+ " mentioned";
  1152. L_End:
  1153. set $name$,null;
  1154. set $name2$,null;
  1155. close;
  1156. L_SameName:
  1157. mes "[Person Checker]";
  1158. mes "You are the person that " +$name2$+ " just mentioned";
  1159. mes "nice to meet you";
  1160. goto L_End;
  1161. See 'strcharinfo' for explanation of what this function does.
  1162. Example 6: Using complex conditions.
  1163. mes "[Multi Checker]";
  1164. if( (@queststarted==1) && (countitem(512)>=5) ) goto L_MultiCheck;
  1165. // Only if the quest has been started AND You have 5 apples will it goto "L_MultiCheck"
  1166. mes "Please get me 5 apples";
  1167. set @queststarted,1;
  1168. close;
  1169. L_MultiCheck:
  1170. mes "[Multi Checker]";
  1171. mes "Well done you have started the quest of got me 5 apples";
  1172. mes "Thank you";
  1173. set @queststarted,0;
  1174. delitem 512,5;
  1175. close;
  1176. ---------------------------------------
  1177. *getitem <item id>,<amount>{,<character ID>};
  1178. *getitem "<item name>",<amount>{,<character ID>};
  1179. This command will give a specific amount of specified items to the invoking
  1180. character. If an optional character ID is specified, and that character is
  1181. currently online, items will be created in their inventory instead. If they are
  1182. not online, nothing will happen.
  1183. In the first and most commonly used version of this command, tems are referred
  1184. to by their database ID number found inside 'db/item_db.txt'.
  1185. getitem 502,10 // The person will recieve 10 apples
  1186. getitem 617,1 // The person will recieve 1 Old Violet Box
  1187. Giving an item ID of -1 will give a specified number of random items from the
  1188. list of those that fall out of Old Blue Box. Unlike in all other cases, these
  1189. will be unidentified, if they turn out to be equipment. This is exactly what's
  1190. written in the Old Blue Box's item script.
  1191. Other negative IDs also correspond to other random item generating item tables:
  1192. Giving an item ID of -2 will produce the effects of Old Violet Box.
  1193. Giving an item ID of -3 will produce the effects of Old Card Album.
  1194. Giving an item ID of -4 will produce the effects of Gift Box.
  1195. Giving an item ID of -5 will produce the effects of Worn Out Scroll, which, in
  1196. current SVN, drops only Jellopies anyway.
  1197. Calling this command with a negative item ID to create a random item will create
  1198. an entry in the log file for those if such logging is enabled.
  1199. You may also create an item by it's name in the 'english name' field in the item
  1200. database:
  1201. getitem "RED_POTION",10;
  1202. Which will do what you'd expect. If it can't find that name in the database,
  1203. apples will be created anyway. It is often a VERY GOOD IDEA to use it like this.
  1204. This used in pretty much all NPC scripts that have to do with items and quite a
  1205. few item scripts. For more examples check just about any official script.
  1206. ---------------------------------------
  1207. *getitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>};
  1208. *getitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>};
  1209. This command will give an amount of specified items to the invoking character.
  1210. If an optional character ID is specified, and that character is currently
  1211. online, items will be created in their inventory instead. If they are not
  1212. online, nothing will happen. It works essentially the same as 'getitem' (it even
  1213. works for negative ID numbers the same way, which is kinda silly) but is a lot
  1214. more flexible, since it allows you to give the player an item altered with it's
  1215. specific properties.
  1216. Those parameters that are different from 'getitem' are:
  1217. identify - Whether you want the item to be identified or not, 0 unidentified,
  1218. 1 identified.
  1219. refine - For how many plusses will it be refined.
  1220. It will not let you refine an item higher than +10, if you
  1221. specify more it'll still be 10.
  1222. attribute - Whether the item is broken (1) or not (0) and NOT an elemental
  1223. attribute.
  1224. card1,2,3,4 - If you want a card compound to it, place the card ID number into
  1225. the specific card slot. Card ID numbers also found in
  1226. 'db/item_db.txt'
  1227. Card1-card4 values are also used to store name information for named items, as
  1228. well as the elemental property of weapons and armor. You can create a named item
  1229. in this manner, however, if you just need a named piece of standard equipment,
  1230. it is much easier to the 'getnameditem' function instead.
  1231. You will need to keep these values if you want to destroy and then perfectly
  1232. recreate a named item, for this see 'getinventorylist'.
  1233. If you still want to try creating a named item with this command because
  1234. 'getnameditem' won't do it for you cause it's too limited, you can do it like
  1235. this. Careful, minor magic ahead.
  1236. // First, let's get an ID of a character who's name will be on the item.
  1237. // Only an existing character's name may be there.
  1238. // Let's assume our character is 'Adam' and find his ID.
  1239. set @charid,getcharid(0,"Adam");
  1240. // Now we split the character ID number into two portions with a binary
  1241. // shift operation. If you don't understand what this does, just copy it.
  1242. set @card3, @charid & 65535;
  1243. set @card4, @charid >> 16;
  1244. // If you're inscribing non-equipment, @card1 must be 254.
  1245. // Arrows are also not equipment. :)
  1246. set @card1,254;
  1247. // For named equipment, card2 means the Star Crumbs and elemental
  1248. // crystals used to make this equipment. For everything else, it's 0.
  1249. set @card2,0;
  1250. // Now, let's give the character who invoked the script some
  1251. // Adam's Apples:
  1252. getitem2 512,1,1,0,0,@card1,@card2,@card3,@card4;
  1253. This wasn't tested with all possible items, so I can't give any promises,
  1254. experiment first before relying on it.
  1255. To create equipment, continue this example it like this:
  1256. // We've already have card3 and card4 loaded with correct
  1257. // values so we'll just set up card1 and card2 with data
  1258. // for an Ice Stiletto.
  1259. // If you're inscribing equipment, @card1 must be 255.
  1260. set @card1,255;
  1261. // That's the number of star crumbs in a weapon.
  1262. set @sc,2;
  1263. // That's the number of elemental property of the weapon.
  1264. set @ele,1;
  1265. // And that's the wacky formula that makes them into
  1266. // a single number.
  1267. set @card2,@ele+((@sc*5)<<8);
  1268. // That will make us an Adam's +2 VVS Ice Stiletto:
  1269. getitem2 1216,1,1,2,0,@card1,@card2,@card3,@card4;
  1270. Experiment with the number of star crumbs - I'm not certain just how much will
  1271. work most and what it depends on. The valid element numbers are:
  1272. 1 - Ice, 2 - Earth 3 - Fire 4 - Wind.
  1273. You can, apparently, even create duplicates of the same pet egg with this
  1274. command, creating a pet which is the same, but simultaneously exists in two
  1275. eggs, and may hatch from either, although, I'm not sure what kind of a mess will
  1276. this really cause.
  1277. ---------------------------------------
  1278. *groupranditem <group id>;
  1279. Returns the item_id of a random item picked from the group specified. The
  1280. different groups and their group number are specified in db/item_group_db.txt
  1281. When used in conjunction with other functions, you can get a random item. For
  1282. example, for a random pet lure:
  1283. getitem groupranditem(15),1;
  1284. ---------------------------------------
  1285. *makeitem <item id>,<amount>,<X>,<Y>,"<map name>";
  1286. *makeitem "<item name>",<amount>,<X>,<Y>,"<map name>";
  1287. This command will create an item lying around on a specified map in the
  1288. specified location.
  1289. itemid - Found in 'db/item_db.txt'
  1290. amount - Amount you want produced
  1291. X - The X coordinate
  1292. Y - The Y coordinate
  1293. map name - The map name.
  1294. This item will still disappear just like any other dropped item. Like 'getitem',
  1295. it also accepts an 'english name' field from the database and creates apples if
  1296. the name isn't found.
  1297. ---------------------------------------
  1298. *delitem <item id>,<amount>;
  1299. *delitem "<item name>",<amount>;
  1300. This command will take a specified amount of items from the invoking character.
  1301. As all the item commands, this one uses the ID of the item found inside
  1302. 'db/item_db.txt'. The items are destroyed - there is no way an NPC can simply
  1303. own items and have an inventory of them, other as by destroying and recreating
  1304. them when needed.
  1305. delitem 502,10 // The person will lose 10 apples
  1306. delitem 617,1 // The person will lose 1 Old Violet Box
  1307. It is always a good idea to to check if the player actually has the item before
  1308. you take it from them, Otherwise, you could try to delete items which the
  1309. players don't actually have, which won't fail and won't give an error message,
  1310. but might open up ways to exploit your script.
  1311. Like 'getitem' this command will also accept an 'english name' field from the
  1312. database. If the name is not found, nothing will be deleted.
  1313. ---------------------------------------
  1314. *delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>};
  1315. *delitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<character ID>};
  1316. This command will take a specified amount of items from the invoking character.
  1317. Check 'getitem2' to understand its expanded parameters.
  1318. ---------------------------------------
  1319. *enable_items;
  1320. *disable_items;
  1321. These commands enable item usage while an npc is running. When enable_items is
  1322. run, items can be used during scripts until disable_items is called.
  1323. To avoid possible exploits, when enable_items is invoked, it will only enable
  1324. item usage while running that script in particular. Note that if a different
  1325. script also calls enable_items, it will override the last call (so you may
  1326. want to call this command at the start of your script without assuming the
  1327. effect is still in effect).
  1328. ---------------------------------------
  1329. *viewpoint <action>,<x>,<y>,<point number>,<color>;
  1330. This command will mark places on the mini map in the client connected to the
  1331. invoking character. It uses the normal X and Y coordinates from the main map.
  1332. The colors of the marks are defined using a hexidecimal number, same as the ones
  1333. used to color text in 'mes' output, but are written as hexadecimal numbers in C.
  1334. (They look like 0x<six numbers>.)
  1335. Action is what you want to do with a point, 1 will set it, while 2 will clear
  1336. it. Point number is the number of the point - you can have several. If more than
  1337. one point is drawn at the same coordinates, they will cycle, which can be used
  1338. to create flashing marks.
  1339. // This command will show a mark at coordinates X 30 Y 40, is mark number 1,
  1340. // and will be red.
  1341. viewpoint 1,30,40,1,0xFF0000;
  1342. This will create three points:
  1343. viewpoint 1,30,40,1,0xFF0000;
  1344. viewpoint 1,35,45,2,0xFF0000;
  1345. viewpoint 1,40,50,3,0xFF0000;
  1346. And this is how you remove them:
  1347. viewpoint 2,30,40,1,0xFF0000;
  1348. viewpoint 2,35,45,2,0xFF0000;
  1349. viewpoint 2,40,50,3,0xFF0000;
  1350. The client determines what it does with the points entirely, the server keeps no
  1351. memory of where the points are set whatsoever.
  1352. ---------------------------------------
  1353. *countitem(<item id>)
  1354. *countitem("<item name>")
  1355. This function will return the number of items for the specified item ID that the
  1356. invoking character has in the inventory.
  1357. mes "[Item Checker]";
  1358. mes "Hmmm, it seems you have "+countitem(502)+" apples";
  1359. close;
  1360. Like 'getitem', this function will also accept an 'english name' from the
  1361. database as an argument.
  1362. If you want to state the number at the end of a sentence, you can do it by
  1363. adding up strings:
  1364. mes "[Item Checker]";
  1365. mes "Hmmm, the total number of apples you are holding is "+countitem("APPLE");
  1366. close;
  1367. ---------------------------------------
  1368. *countitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
  1369. *countitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
  1370. Expanded version of 'countitem' function, used for created/carded/forged items.
  1371. This function will return the number of items for the specified item ID and
  1372. other parameters that the invoking character has in the inventory.
  1373. Check 'getitem2' to understand the arguments of the function.
  1374. ---------------------------------------
  1375. *checkweight(<item id>,<amount>)
  1376. *checkweight("<item name>",<amount>)
  1377. This function will compute and return 1 if the total weight of a specified
  1378. number of specific items does not exceed the invoking character's carrying
  1379. capacity, and 0 otherwise. It is important to see if a player can carry the
  1380. items you expect to give them, failing to do that may open your script up to
  1381. abuse or create some very unfair errors.
  1382. Like 'getitem', this function will also accept an 'english name' from the
  1383. database as an argument.
  1384. checkweight(502,10) // 10 apples
  1385. if (checkweight(502,10) == 0 ) goto L_OverWeight;
  1386. getitem 502,10;
  1387. close;
  1388. L_OverWeight:
  1389. mes "Sorry you cannot hold this ammount of apples";
  1390. close;
  1391. Or to put this another way:
  1392. if (checkweight("APPLE",10)) goto L_Getapples;
  1393. mes "Sorry you cannot hold this ammount of apples";
  1394. close;
  1395. L_Getapples:
  1396. getitem 502,10;
  1397. close;
  1398. Both these examples have the same effect.
  1399. ---------------------------------------
  1400. *readparam(<parameter number>)
  1401. This function will return the basic stats of an invoking character, referred to
  1402. by the parameter number. Instead of a number, you can use a parameter name if it
  1403. is defined in "db/const.txt".
  1404. For reference, in there these things are defined:
  1405. StatusPoint, BaseLevel, SkillPoint, Class, Upper, Zeny, Sex, Weight, MaxWeight,
  1406. JobLevel, BaseExp, JobExp, NextBaseExp, NextJobExp, Hp, MaxHp, Sp, MaxSp,
  1407. BaseJob, Karma, Manner, bVit, bDex, bAgi, bStr, bInt, bLuk
  1408. All of these also behave as variables, but don't expect to be able to just 'set'
  1409. all of them - some will not work for various internal reasons.
  1410. // This would return how many status points you haven't spent yet
  1411. readparam(9)
  1412. Using this particular information as a function call is not required. Just
  1413. putting
  1414. StatusPoint
  1415. will give you the same result, and some of these parameters work just like
  1416. variables (i.e. you can 'set Zeny,100' to make the character have 100 zeny,
  1417. destroying whatever zeny they had before, or 'set Zeny,Zeny+100' to give them
  1418. 100 zeny)
  1419. You can also use this command to get stat values:
  1420. readparam(bVit)
  1421. if(readparam(bVit)<=77) goto L_End;
  1422. mes "Only people with over 77 Vit are reading this";
  1423. L_End:
  1424. close;
  1425. ---------------------------------------
  1426. *getcharid(<type>{,"<character name>"})
  1427. This function will return a unique ID number of the invoking character, or, if a
  1428. character name is specified, of that character.
  1429. Type is the kind of associated ID number required:
  1430. 0 - Character ID number.
  1431. 1 - Party ID number.
  1432. 2 - Guild ID number.
  1433. 3 - Account ID number.
  1434. For most purposes other than printing it, a number is better to have than a name
  1435. (people do horrifying things to their character names).
  1436. If the character is not in a party or not in a guild, the function will return 0
  1437. if guild or party number is requested. If a name is specified and the character
  1438. is not found, 0 is returned.
  1439. If getcharid(0) returns a zero, the script got called not by a character and
  1440. doesn't have an attached RID. Note that this will cause the map server to
  1441. print "player not attached!" error messages, so it is preferred to use
  1442. "playerattached" to check for the character attached to the script.
  1443. if (getcharid(2)) mes "Only members of a guild are allowed beyond this point!";
  1444. ---------------------------------------
  1445. *getpartyname(<party id>)
  1446. This function will return the name of a party that has the specified ID number.
  1447. If there is no such party ID, "null" will be returned.
  1448. Lets say the ID of a party was saved as a global variable:
  1449. // This would return the name of the party from the ID stored in a variable
  1450. mes "You're in the '"+getpartyname($@var)"' party, I know!";
  1451. ---------------------------------------
  1452. *getpartymember <party id>;
  1453. Thank you to HappyDenn for all this information.
  1454. This command will finds all members of a specified party and returns their names
  1455. into an array of temporary global variables. There's actually quite a few
  1456. commands like this which will fill a special variable with data upon execution
  1457. and not do anything else.
  1458. Upon executing this,
  1459. $@partymembername$[] is a global temporary stringarray which contains all the
  1460. names of these party members.
  1461. $@partymembercount is the number of party members that were found.
  1462. The party members will (apparently) be found regardless of whether they are
  1463. online or offline. Note that the names come in no particular order.
  1464. Be sure to use $@partymembercount to go through this array, and not
  1465. 'getarraysize', because it is not cleared between runs of 'getpartymember'. If
  1466. someone with 7 party members invokes this script, the array would have 7
  1467. elements. But if another person calls up the NPC, and he has a party of 5, the
  1468. server will not clear the array for you, overwriting the values instead. So in
  1469. addition to returning the 5 member names, the 6th and 7th elements from the last
  1470. call remain, and you will get 5+2 members, of which the last 2 don't belong to
  1471. the new guy's party. $@partymembercount will always contain the correct number,
  1472. (5) unlike 'getarraysise()' which will return 7 in this case.
  1473. Example:
  1474. // get the character's party ID
  1475. getpartymember(getcharid(1));
  1476. // immediately copy $@partymembercount value to a new variable, since
  1477. // you don't know when 'getpartymember' will get called again for someone
  1478. // else's party, overwriting your global array.
  1479. set @partymembercount,$@partymembercount;
  1480. // copy $@partymembername array to a new array
  1481. copyarray @partymembername$[0],$@partymembername$[0],@partymembercount;
  1482. //list the party members in NPC dialog
  1483. set @count,0;
  1484. L_DisplayMember:
  1485. if(@count == @partymembercount) goto L_DisplayMemberEnd;
  1486. mes (@count + 1) + ". ^0000FF" + @partymembername$[@count] + "^000000";
  1487. set @count,@count+1;
  1488. goto L_DisplayMember;
  1489. L_DisplayMemberEnd:
  1490. close;
  1491. ---------------------------------------
  1492. *getguildname(<guild id>)
  1493. This function returns a guild's name given an ID number. If there is no such
  1494. guild, "null" will be returned;
  1495. // Would print what ever guild 10007 is, in my case this would return "AlcoROhics"
  1496. mes "The guild "+GetGuildName(10007)+" are all nice people.";
  1497. // This will do the same as above:
  1498. set @var,10007;
  1499. mes "We have some friends in "+GetGuildName(@var)+", you know.";
  1500. This is used all over the WoE controlling scripts. You could also use it for a
  1501. guild-based event.
  1502. ---------------------------------------
  1503. *getguildmaster(<guild id>)
  1504. This function return the name of the master of the guild which has the specified
  1505. ID number. If there is no such guild, "null" will be returned.
  1506. // Would return the guild master of guild 10007, whatever that might be.
  1507. // In this example it would return "MissDjax" cause she owns "AlcoROhics" (10007)
  1508. mes getguildmaster(10007)+" runs "+getguildname(10007);
  1509. Can be used to check if the character is the guildmaster of the specified guild.
  1510. Maybe you want to make a room only guildmasters can enter:
  1511. set @GID,getcharid(2);
  1512. if(@GID==0) goto L_NoGuild;
  1513. if(strcharinfo(0)==getguildmaster(@GID)) goto L_GuildMaster;
  1514. mes "Sorry you dont own the guild you are in";
  1515. close;
  1516. L_NoGuild:
  1517. mes "Sorry you are not in a guild";
  1518. close;
  1519. L_GuildMaster:
  1520. mes "Welcome guild master of "+GetGuildName(@GID);
  1521. close;
  1522. ---------------------------------------
  1523. *guildchangegm(<guild id>,<new master's name>)
  1524. This function will change the Guild Master of a guild. The ID is the guild's
  1525. id, and the new guildmaster's name must be passed.
  1526. Returns 1 on success, 0 otherwise.
  1527. ---------------------------------------
  1528. *getguildmasterid(<guild id>)
  1529. This function will return the character ID number of the guildmaster of the
  1530. guild specified by the ID. 0 if the character is not a guildmaster of any guild.
  1531. ---------------------------------------
  1532. *strcharinfo(<type>)
  1533. This function will return either the name, party name or guild name for the
  1534. invoking character. Whatever it returns is determined by type.
  1535. 0 - Character's name.
  1536. 1 - The name of the party they're in if any.
  1537. 2 - The name of the guild they're in if any.
  1538. If a character is not a member of any party or guild, an empty string will be
  1539. returned when requesting that information.
  1540. ---------------------------------------
  1541. *getequipid(<equipment slot>)
  1542. This function returns the item ID of the item equipped in the equipment slot
  1543. specified on the invoking character. If nothing is equpped there, it returns 0.
  1544. Valid equipment slots are:
  1545. 1 - Upper head gear
  1546. 2 - Armor (Where you keep your Jackets and Robes)
  1547. 3 - What is in your Left hand.
  1548. 4 - What is in your Right hand.
  1549. 5 - The garment slot (Mufflers, Hoods, Manteaus)
  1550. 6 - What foot gear the player has on.
  1551. 7 - Accessory 1.
  1552. 8 - Accessory 2.
  1553. 9 - Middle Headgear (masks and glasses)
  1554. 10 - Lower Headgear (beards, some masks)
  1555. Notice that a few items occupy several equipment slots, and if the character is
  1556. wearing such an item, 'getequipid' will return it's ID number for either slot.
  1557. Can be used to check if you have something equiped, or if you haven't got
  1558. something equiped:
  1559. if(getequipid(1)==2234) goto L_WearingTiara;
  1560. mes "Come back when you have a Tiara on";
  1561. close;
  1562. L_WearingTiara:
  1563. mes "What a lovely Tiara you have on";
  1564. close;
  1565. You can also use it to make sure people dont pass a point before removing an
  1566. item totally from them. Let's say you dont want people to wear Legion Plate
  1567. armor, but also dont want them to equip if after the check, you would do this:
  1568. if ((getequipid(2) == 2341) || (getequipid(2) == 2342) goto L_EquipedLegionPlate;
  1569. // the || is used as an or argument, there is 2341 and 2342 cause there are
  1570. // two different legion plate armors, one with a slot one without.
  1571. if ((countitem(2341) > 0) || (countitem(2432) > 0) goto L_InventoryLegionPlate;
  1572. mes "I will lets you pass";
  1573. close2;
  1574. warp "place.gat",50,50;
  1575. end;
  1576. L_EquipedLegionPlate:
  1577. mes "You are wearing some Legion Plate Armor, please drop that in your stash before continuing";
  1578. close;
  1579. L_InventoryLegionPlate:
  1580. mes "You have some Legion Plate Armor in your inventory, please drop that in your stash before continuing";
  1581. close;
  1582. ---------------------------------------
  1583. *getequipname(<equpment slot>)
  1584. This function will return the name of the item equipped in the specified
  1585. equipment slot on the invoking character. Almost identical to 'getequipid', good
  1586. for an NPC to state what your are wearing, or maybe saving as a string variable.
  1587. See 'getequipid' for a full list of valid equipment slots.
  1588. if (getequipname(1)==0) goto L_No_HeadGear;
  1589. mes "So you are wearing a "+getequipname(1)+" on your head";
  1590. close;
  1591. L_No_HeadGear:
  1592. mes "You are not wearing any head gear";
  1593. close;
  1594. ---------------------------------------
  1595. *getbrokenid(<number>)
  1596. This function will search the invoking character's inventory for any broken
  1597. items, and will return their item ID numbers. Since the character may have
  1598. several broken items, 0 given as an argument will return the first one found, 1
  1599. will return the second one, etc. Will return 0 if no such item is found.
  1600. // Let's see if they have anything broken:
  1601. if (getbrokenid(0)==0) goto Skip;
  1602. // They do, so let's print the name of the first broken item:
  1603. mes "Oh, I see you have a broken "+getitemname(getbrokenid(0))+" here!";
  1604. Skip:
  1605. mes "You don't have anything broken, quit bothering me.";
  1606. ---------------------------------------
  1607. *repair <broken item number>;
  1608. This command repairs a broken peice of equipment, using the same list of broken
  1609. items as available through 'getbrokenid'.
  1610. The official scripts seem to use the repair command as a function instead:
  1611. 'repair(<number>)' but it returns nothing on the stack. Probably only Valaris,
  1612. who made it, can answer why is it so.
  1613. ---------------------------------------
  1614. *getequipisequiped(<equipment slot>)
  1615. This functions will return 1 if there is an equipment placed on the specified
  1616. equipment slot and 0 otherwise. For a list of equipment slots
  1617. see 'getequipid'. Function originally used by the refining NPCs:
  1618. if (getequipisequiped(1)) goto L_equipped;
  1619. mes "[Refiner]";
  1620. mes "Do you want me to refine your dumb head?";
  1621. close;
  1622. L_equipped:
  1623. mes "[Refiner]";
  1624. mes "That's a fine hat you are wearing there...";
  1625. close;
  1626. ---------------------------------------
  1627. *getequipisenableref(<equipment slot>)
  1628. Will return 1 if the item equipped on the invoking character in the specified
  1629. equipment slot is refinable, and 0 if it isn't. For a list of equipment slots
  1630. see 'getequipid'.
  1631. if (getequipisenableref(1)) goto L_Refine;
  1632. mes "[Refiner]";
  1633. mes "I can't refine this hat!...";
  1634. close;
  1635. L_Refine:
  1636. mes "[Refiner]";
  1637. mes "Ok I can refine this";
  1638. close;
  1639. ---------------------------------------
  1640. *getequipisidentify(<equipment slot>)
  1641. This function will return 1 if an item in the specified equipment slot is
  1642. identified and 0 if it isn't. Since you can't even equip unidentified equipment,
  1643. there's a question of whether it can actually end up there, and it will normally
  1644. return 1 all the time if there is an item in this equipment slot.
  1645. Which is kinda pointless.
  1646. For a list of equipment slots see 'getequipid'.
  1647. ---------------------------------------
  1648. *getequiprefinerycnt(<equipment slot>)
  1649. Returns the current number of plusses for the item in the specified equipment
  1650. slot. For a list of equipment slots see 'getequipid'.
  1651. Can be used to check if you have reached a maximum refine value, default for
  1652. this is +10:
  1653. if(getequiprefinerycnt(1) < 10) goto L_Refine_HeadGear;
  1654. mes "Sorry, it's not possible to refine hats better than +10";
  1655. close;
  1656. L_Refine_HeadGear:
  1657. mes "I will now upgrade your "+getequipname(1);
  1658. ---------------------------------------
  1659. *getequipweaponlv(<equipment slot>)
  1660. This function returns the weapon level for the weapon equipped in the specified
  1661. equipment slot on the invoking character. For a list of equipment slots see
  1662. 'getequipid'.
  1663. Only 3 (Left hand) and 4 (Right hand) normally make sense, since only weapons
  1664. have a weapon level. You can, however, probably, use this field for other
  1665. equippable custom items as a flag or something.
  1666. If no item is equipped in this slot, or if it doesn't have a weapon level
  1667. according to the database, 0 will be returned.
  1668. if(getequipweaponlv(4)==0) mes "Seems you dont have a weapon on";
  1669. if(getequipweaponlv(4)==1) mes "You are holding a lvl 1 weapon";
  1670. if(getequipweaponlv(4)==2) mes "You are holding a lvl 2 weapon";
  1671. if(getequipweaponlv(4)==3) mes "You are holding a lvl 3 weapon";
  1672. if(getequipweaponlv(4)==4) mes "You are holding a lvl 4 weapon";
  1673. if(getequipweaponlv(4)==5) mes "You are holding a lvl 5 weapon, hm, must be a custom design";
  1674. Or for the left hand, cause it can hold a weapon or a shield:
  1675. if(getequipid(3)==0) goto L_NothingEquiped;
  1676. if(getequipweaponlv(3)==0) mes "You are holding a shield, so it doesnt have a level";
  1677. if(getequipweaponlv(3)==1) mes "You are holding a lvl 1 weapon";
  1678. if(getequipweaponlv(3)==2) mes "You are holding a lvl 2 weapon";
  1679. if(getequipweaponlv(3)==3) mes "You are holding a lvl 3 weapon";
  1680. if(getequipweaponlv(3)==4) mes "You are holding a lvl 4 weapon";
  1681. if(getequipweaponlv(3)==5) mes "You are holding a lvl 5 weapon, hm, must be a custom design";
  1682. close;
  1683. L_NothingEquiped:
  1684. mes "Seems you have nothing equiped";
  1685. close;
  1686. ---------------------------------------
  1687. *getequippercentrefinery(<equipment slot>)
  1688. This function calculates and returns the percent value chance to successfully
  1689. refine the item found in the specified equipment slot of the invoking character
  1690. by +1. The actual formula is beyond the scope of this document, however, it is
  1691. calculated as if the character was a blacksmith trying to refine this particular
  1692. weapon, and depends on lots and lots of stuff. For a list of equipment slots see
  1693. 'getequipid'.
  1694. These values can be displayed for the player to see, or used to calculate the
  1695. random change of a refine succeeding or failing and then going through with it
  1696. (which is what the official NPC refinery scripts use it for)
  1697. // This will find a random number from 0 - 99 and if that is equal to or more
  1698. // than the value recoverd by this command it will go to L_Fail
  1699. if (getequippercentrefinery(3)<=rand(100)) goto L_Fail;
  1700. ---------------------------------------
  1701. *successrefitem <equipment slot>;
  1702. This command will refine an item in the specified equipment slot of the invoking
  1703. character by +1. For a list of equipment slots see 'getequipid'. This command
  1704. will not only add the +1, but also display a 'refine success' effect on the
  1705. character and put appropriate messages into their chat window. It will also give
  1706. the character fame points if a weapon reached +10 this way, even though these
  1707. will only take effect for blacksmith who will later forge a weapon.
  1708. The official scripts seem to use the 'successrefitem' command as a function
  1709. instead: 'successrefitem(<number>)' but it returns nothing on the stack.
  1710. This is since jAthena, so probably nobody knows for sure why is it so.
  1711. ---------------------------------------
  1712. *failedrefitem <equipment slot>;
  1713. This command will fail to refine an item in the specified equipment slot of the
  1714. invoking character. The item will be destroyed. This will also display a 'refine
  1715. failure' effect on the character and put appropriate messages into their chat
  1716. window.
  1717. The official scripts seem to use the 'failedrefitem' command as a function
  1718. instead: 'failedrefitem(<number>)' but it returns nothing on the stack. This is
  1719. since jAthena, so probably nobody knows for sure why is it so.
  1720. ---------------------------------------
  1721. *cutin "<filename with no extension>",<position>;
  1722. This command will display a picture stored in the GRF file in the client for the
  1723. player.
  1724. The files are taken from '\data\texture\A_A£AI�I’„AI«§\illust' directory in the
  1725. GRF file. The filename must be given with no extension, '.bmp' is added by the
  1726. client itself and you can't have any other picture format displayed as a cutin.
  1727. The biggest one that comes with the client is 400x503 pixels, and the smallest
  1728. is 303x493 pixels, it is not known how big a picture has to be before the client
  1729. goes insane. Bright magenta (color FF00FF) is considered to be transparent in
  1730. these pictures. You can easily add and alter them, but how to do this is outside
  1731. of the scope of this document.
  1732. The position determines just where on screen the picture will appear:
  1733. 0 - bottom left corner
  1734. 1 - bottom middle
  1735. 2 - bottom right corner
  1736. 3 - middle of screen in a movable window with an empty title bar.
  1737. 4 - middle of screen without the window header, but still movable.
  1738. 255 - will remove the cutin previously displayed.
  1739. Giving an empty string for the filename and 255 for the position will remove all
  1740. cutin pictures. Any other position value will not cause a script error but will
  1741. cause the player's client to curl up and die. Only one cutin may be on screen at
  1742. any given time, any new cutins will replace it.
  1743. // This will display the picture of the 7th kafra,
  1744. // the one in orange and the mini-skirt :P
  1745. cutin "kafra_7",2;
  1746. // This will remove the displayed picture.
  1747. cutin "Kafra_7",255;
  1748. // This will remove all pictures displayed.
  1749. cutin "",255;
  1750. The client comes with those cutin pictures preinstalled which you can use:
  1751. mets_alpha - This is a old fat man, holding a pipe, also with a pocket watch
  1752. and cane
  1753. pay_soldier - Wanna take a wild guess, thats right, the Soldiers that appear in
  1754. Payon :D
  1755. prt_soldier - Obvious
  1756. ein_soldier - This guy looks cool, you've got to see him ;) This picture is for
  1757. the new Einbroch guards
  1758. moc_soldier - Obvious
  1759. gef_soldier - Obvious
  1760. katsua01 - It is not certain who this girl is (There is no sprite coming with
  1761. katsua02 - the client that seems to match very well) but she is believed to
  1762. katsua03 - be an NPC in official Comodo. The three pictures give different
  1763. facial expressions.
  1764. kafra_01 - Obvious
  1765. kafra_02 - Obvious
  1766. kafra_03 - Obvious
  1767. kafra_04 - Obvious
  1768. kafra_05 - Obvious
  1769. kafra_06 - Obvious
  1770. kafra_07 - Do I need to mention this one again ;)
  1771. ---------------------------------------
  1772. *cutincard <item id>;
  1773. This command will display a card picture as a cutin on the client connected to
  1774. the invoking character, with position number 4 (middle of screen, movable, but
  1775. no title bar). See 'cutin'. To remove this cutin, use the regular 'cutin'
  1776. command. Unlike the 'cutin' command, it will not take a filename, but will
  1777. instead take an item ID. It will then refer to the text file listing card images
  1778. which is normally found within your server's copy of the GRF file to find the
  1779. real (korean) filename.
  1780. If your server doesn't have that text file in that GRF or can't read it, it
  1781. probably won't work.
  1782. ---------------------------------------
  1783. *statusup <stat>;
  1784. This command will bump a specified stat of the invoking character up by one
  1785. permanently. Stats are to be given as number, but you can use these constants to
  1786. replace them:
  1787. bStr - Strength
  1788. bVit - Vitality
  1789. bInt - Intelligence
  1790. bAgi - Agility
  1791. bDex - Dexterity
  1792. bLuk - Luck
  1793. ---------------------------------------
  1794. *statusup2 <stat>,<amount>;
  1795. This command will bump a specified stat of the invoking character up by the
  1796. specified amount permanently. The amount can be negative. See 'statusup'.
  1797. // This will decrease a character's Vit forever.
  1798. statusup bVit,-1;
  1799. ---------------------------------------
  1800. *bonus <bonus type>,<amount>;
  1801. *bonus2 <bonus type>,<amount>;
  1802. *bonus3 <bonus type>,<amount>;
  1803. *bonus4 <bonus type>,<amount>;
  1804. These commands are meant to be used in item scripts. They will probably work
  1805. outside item scripts, but the bonus will not persist for long. They, as
  1806. expected, refer only to an invoking character.
  1807. You can find the full list of possible bonuses and which command to use for each
  1808. kind in 'doc/item_bonus.txt'.
  1809. ---------------------------------------
  1810. *skill <skill id>,<level>{,<flag>};
  1811. *addtoskill <skill id>,<level>{,<flag>}
  1812. These commands will give the invoking character a specified skill. This is also
  1813. used for item scripts.
  1814. Level is obvious. Skill id is the ID number of the skill in question as per
  1815. 'db/skill_db.txt'. It is not known for certain whether this can be used to give
  1816. a character a monster's skill, but you're welcome to try with the numbers given
  1817. in 'db/mob_skill_db.txt'.
  1818. Flag is 0 if the skill is given permanently (will get written with the character
  1819. data) or 1 if it is temporary (will be lost eventually, this is meant for card
  1820. item scripts usage.). The flag parameter is optional, and defaults to 1 in
  1821. 'skill' and to 2 in 'addtoskill'.
  1822. Flag 2 means that the level parameter is to be interpreted as a stackable
  1823. additional bonus to the skill level. If the character did not have that skill
  1824. previously, they will now at 0+the level given.
  1825. // This will permanently give the character Stone Throw (TF_THROWSTONE,152), at
  1826. // level 1.
  1827. skill 152,1,0;
  1828. ---------------------------------------
  1829. *guildskill <skill id>,<level>{,<flag>}
  1830. This command will bump up the specified guild skill by the specified number of
  1831. levels. This refers to the invoking character and will only work if the invoking
  1832. character is a member of a guild AND it's guildmaster, otherwise no failure
  1833. message will be given and no error will occur, but nothing will happen - same
  1834. about the guild skill trying to exceed the possible maximum. The full list of
  1835. guild skills is available in 'db/skill_db.txt', these are all the GD_ skills at
  1836. the end.
  1837. The flag parameter is currently not functional and it's a mystery of what it
  1838. would actually do. (Though probably, like for character skills, it would allow
  1839. temporary bumping.) Using this command will bump the guild skill up permanently.
  1840. // This would give your character's guild one level of Approval (GD_APPROVAL ID
  1841. // 10000). Notice that if you try to add two levels of Approval, or add
  1842. // Approval when the guild already has it, it will only have one level of
  1843. // Approval afterwards.
  1844. guildskill 10000,1,0;
  1845. You might want to make a quest for getting a certain guild skill, make it hard
  1846. enough that all the guild needs to help or something. Doing this for the Glory
  1847. of the Guild skill, which allows your guild to use an emblem, is a good idea for
  1848. a fun quest. (Wasting a level point on that is really annoying :D)
  1849. ---------------------------------------
  1850. *getskilllv(<skill id>)
  1851. This function returns the level of the specified skill that the invoking
  1852. character has. If they don't have the skill, 0 will be returned. The full list
  1853. of character skills is available in 'db/skill_db.txt'.
  1854. There are two main uses for this function, it can check whether the character
  1855. has a skill or not, and it can tell you if the level is high enough.
  1856. Example 1:
  1857. f (getskilllv(152)) goto L_HasSkillThrowStone;
  1858. mes "You dont have Throw Stone";
  1859. close;
  1860. L_HasSkillThrowStone:
  1861. mes "You have got the skill Throw Stone";
  1862. close;
  1863. Example 2:
  1864. if (getskilllv(28) >= 5) goto L_HasSkillHeallvl5orMore;
  1865. if (getskilllv(28) == 10) goto L_HasSkillHealMaxed;
  1866. mes "You heal skill is below lvl 5";
  1867. close;
  1868. L_HasSkillHeallvl6orMore:
  1869. mes "Your heal lvl is 5 or more";
  1870. close;
  1871. L_HasSkillHealMaxed:
  1872. mes "Your heal lvl has been maxed";
  1873. close;
  1874. ---------------------------------------
  1875. *getgdskilllv(<guild id>,<skill id>)
  1876. This function retirns the guild skills for the guild with a specified ID exactly
  1877. as 'getskilllv' does.
  1878. ---------------------------------------
  1879. *basicskillcheck()
  1880. This function will return the state of the configuration option
  1881. 'basic_skill_check' in 'battle_athena.conf'. It returns 1 if the option is
  1882. enabled and 0 if it isn't. If the 'basic_skill_check' option is enabled, which
  1883. it is by default, characters must have a certain number of basic skill levels to
  1884. sit, request a trade, use emoticons, etc. Making your script behave differently
  1885. depending on whether the characters must actually have the skill to do all these
  1886. things might in some cases be required.
  1887. ---------------------------------------
  1888. *getgmlevel()
  1889. This function will return the GM level of the account to which the invoking
  1890. character belongs. If this is somehow executed from a console command, 99 will
  1891. be returned, and 0 will be returned if the account has no GM level.
  1892. This allows you to make NPC's only accessable for certain GM levels, or behave
  1893. specially when talked to by GMs.
  1894. if (getgmlevel()) mes "What is your command, your godhood?";
  1895. if (getgmlevel()) goto Wherever;
  1896. ---------------------------------------
  1897. *end;
  1898. *break;
  1899. This command will stop the execution for this particular script. The two
  1900. versions are prefectly equivalent. It is the normal way to end a script which
  1901. does not use 'mes'.
  1902. if (BaseLevel<=10) goto L_Lvl10;
  1903. if (BaseLevel<=20) goto L_Lvl20;
  1904. if (BaseLevel<=30) goto L_Lvl30;
  1905. if (BaseLevel<=40) goto L_Lvl40;
  1906. if (BaseLevel<=50) goto L_Lvl50;
  1907. if (BaseLevel<=60) goto L_Lvl60;
  1908. if (BaseLevel<=70) goto L_Lvl70;
  1909. L_Lvl10:
  1910. npctalk "Look at that you are still a n00b";
  1911. end;
  1912. L_Lvl20:
  1913. npctalk "Look at that you are getting better, but still a n00b";
  1914. end;
  1915. L_Lvl30:
  1916. npctalk "Look at that you are getting there, you are almost 2nd profession now right???";
  1917. end;
  1918. L_Lvl40:
  1919. npctalk "Look at that you are almost 2nd profession";
  1920. end;
  1921. Without the use if 'end' it would travel through the labels until the end of the
  1922. script. If you were lvl 10 or less, you would see all the speech lines, the use
  1923. of 'end' stops this, and ends the script.
  1924. ---------------------------------------
  1925. *checkoption(<option number>)
  1926. *checkoption1(<option number>)
  1927. *checkoption2(<option number>)
  1928. *setoption <option number>;
  1929. The 'setoption' series of functions check for a so-called option that is set on
  1930. the invoking character. 'Options' are used to store status conditions and a lot
  1931. of other non-permanent character data of the yes-no kind. For most common cases,
  1932. it is better to use 'checkcart','checkfalcon','checkpeco' and other similar
  1933. functions, but there are some options which you cannot get at this way. They
  1934. return 1 if the option is set and 0 if the option is not set.
  1935. Option numbers valid for the first version of this command are:
  1936. 1 - Petrified.
  1937. 2 - Frozen.
  1938. 3 - Stunned.
  1939. 4 - Sleeping.
  1940. 32 - Riding a Peco.
  1941. 'setoption' will set options on the invoking character. There are no second and
  1942. third versions of this command, so you can only change the
  1943. petrified/frozen/stunned/sleeping/riding status in this manner.
  1944. Option numbers valid for the second version of this command are:
  1945. 1 - Poisoned.
  1946. 2 - Cursed.
  1947. 4 - Silenced.
  1948. 8 - Blinded (Notice that unless you specfy variable night darkness in the
  1949. configuration, all characters will be 'blinded' during the night)
  1950. Option numbers valid for the third version of this command are:
  1951. 1 - Sight in effect.
  1952. 2 - Hide in effect.
  1953. 4 - Cloaking in effect.
  1954. 8 - Falcon present.
  1955. 64 - GM Perfect Hide in effect.
  1956. 128 - Cart number 2 present.
  1957. 256 - Cart number 3 present.
  1958. 512 - Cart number 4 present.
  1959. 1024 - Cart number 5 present.
  1960. 2048 - Orc head present.
  1961. 4096 - The character is wearing a wedding sprite.
  1962. 8192 - Ruwach is in effect.
  1963. Option numbers are bitmasks - add up option numbers to check for all of them
  1964. being present at the same time in one go.
  1965. This is definitely not a complete list of available option flag numbers. Ask a
  1966. core developer for the full list.
  1967. ---------------------------------------
  1968. *setcart;
  1969. *checkcart()
  1970. This command will give the invoking character a cart. The cart given will be
  1971. cart number 1 and will work regardless of whether the character is a merchant
  1972. class or not.
  1973. The accompanying function will return 1 if the invoking character has a cart
  1974. (any kind of cart) and 0 if they don't.
  1975. if (checkcart()) mes "But you already have a cart!";
  1976. ---------------------------------------
  1977. *setfalcon;
  1978. *checkfalcon()
  1979. This command will give the invoking character a falcon. The falcon will be there
  1980. regardless of whether the character is a hunter or not. It will (probably) not
  1981. have any useful effects for non-hunters though.
  1982. The accompanying function will return 1 if the invoking character has a falcon
  1983. and 0 if they don't.
  1984. if (checkfalcon()) mes "But you already have a falcon!";
  1985. ---------------------------------------
  1986. *setriding;
  1987. *checkriding()
  1988. This command will give the invoking character a PecoPeco (if they are a Knight
  1989. series class) or a GrandPeco (if they are a Crusader seriesclass). Unlike
  1990. 'setfalcon' and 'setcart' this will not work at all if they aren't of a class
  1991. which can ride. This will work if the character doesn't have the riding skill,
  1992. however.
  1993. The accompanying function will return 1 if the invoking character is riding a
  1994. bird and 0 if they don't.
  1995. if (checkriding()) mes "PLEASE leave your bird outside! No riding birds on the floor here!";
  1996. ---------------------------------------
  1997. *savepoint "<map name>",<x>,<y>;
  1998. *save "<map name>",<x>,<y>;
  1999. This command saves a point that the invoking character will return to upon
  2000. 'return to save point' if dead or in some other cases. The two versions are
  2001. equivalent. Map name, X coordinate and Y coordinate should be perfectly obvious.
  2002. This ignores any and all map flags, and can make a character respawn where no
  2003. teleportation is otherwise possible.
  2004. savepoint "place.gat",350,75;
  2005. ---------------------------------------
  2006. *gettimetick(<tick type>)
  2007. This function will return the system time in UNIX epoch time (if tick type is 2)
  2008. or the time since the start of the current day in seconds if tick type is 1.
  2009. Passing 0 will make it return the server's tick, which is a measurement in
  2010. milliseconds used by the server's timer system. The server's tick is an
  2011. unsigned int which loops every ~50 days.
  2012. Just in case you don't know, UNIX epoch time is the number of seconds elapsed
  2013. since 1st of January 1970, and is useful to see, for example, for how long the
  2014. character has been online with PCLoginEvent and PCLogoutEvent, which could allow
  2015. you to make an 'online time counted for conviction only' jail script.
  2016. ---------------------------------------
  2017. *gettime(<type>)
  2018. This function will return specified information about the current system time.
  2019. 1 - Seconds (of a minute)
  2020. 2 - Minutes (of an hour)
  2021. 3 - Hour (of a day)
  2022. 4 - Week day (0 for Sunday, 6 is Saturday)
  2023. 5 - Day of the month.
  2024. 6 - Number of the month.
  2025. 7 - Year.
  2026. 8 - Day of the year.
  2027. It will only return numbers.
  2028. if (gettime(4)==6) mes "It's a Saturday. I don't work on Saturdays.";
  2029. ---------------------------------------
  2030. *gettimestr(<format string>,<max length>)
  2031. This function will return a string containing time data as specified by the
  2032. format string.
  2033. This uses the C function 'strfmtime', which obeys special format characters. For
  2034. a full description see, for example, the description of 'strfmtime' at
  2035. http://www.delorie.com/gnu/docs/glibc/libc_437.html
  2036. All the format characters given in there should properly work.
  2037. Max length is the maximum length of a time string to generate.
  2038. The example given in eAthena sample scripts works like this:
  2039. mes gettimestr("%Y-%m/%d %H:%M:%S",21);
  2040. This will print a full date and time like 'YYYY-MM/DD HH:MM:SS'.
  2041. ---------------------------------------
  2042. *openstorage;
  2043. This will open a character's Kafra storage window on the client connected to the
  2044. invoking character. It does not check wherever it is run from, so you can allow
  2045. any feasible NPC to open a kafra storage. (It's not certain whether this works
  2046. in item scripts, but if it does, it could be interesting.)
  2047. The storage window might not open if a message box or a trade deal is present on
  2048. screen already, so you should at least make sure the message box is closed
  2049. before you open storage.
  2050. mes "I will now open your stash for you";
  2051. close2;
  2052. openstorage;
  2053. end;
  2054. ---------------------------------------
  2055. *guildopenstorage()
  2056. This function works the same as 'openstorage' but will open a guild storage
  2057. window instead for the guild storage of the guild the invoking character belongs
  2058. to. This is a function because it returns a value - 0 if the guild storage was
  2059. opened successfully and 1 if it wasn't. (Notice, it's a ZERO upon success.)
  2060. Since guild storage is only accessible to one character at one time, it may fail
  2061. if another character is accessing the guild storage at the same time.
  2062. This will also fail and return 2 if the character does not belong to any guild.
  2063. ---------------------------------------
  2064. *itemskill <skill id>,<skill level>,"<skill name to show>";
  2065. This is a command meant for item scripts to replicate single-use skills. It will
  2066. not work properly in NPC scripts a lot of the time because casting a skill is
  2067. not allowed when there is a message window or menu on screen. If there isn't one
  2068. cause you've made sure to run this when they already closed it, it should work
  2069. just fine and even show a targeting pointer if this is a targeting skill.
  2070. // When you use Anodyne, you will cast Endure(8) level 1,
  2071. // and "Endure" will appear above your head as you use it.
  2072. 605,Anodyne,Anodyne,11,2000,0,100,,,,,10477567,2,,,,,{ itemskill 8,1,"Endure"; },{}
  2073. ---------------------------------------
  2074. *produce <item level>;
  2075. This command will open a crafting window on the client connected to the invoking
  2076. character. The 'item level' is a number which determines what kind of a crafting
  2077. window will pop-up. You can see the full list of such item levels in
  2078. 'db/produce_db.txt' which determines what can actually be produced.
  2079. The window will not be empty only if the invoking character can actually produce
  2080. the items of that type and has the appropriate raw materials in their inventory.
  2081. Valid item levels are:
  2082. 1 - Level 1 Weapons
  2083. 2 - Level 2 Weapons
  2084. 3 - Level 3 Weapons
  2085. 16 - Blacksmith's Stones and Metals
  2086. 32 - Alchemist's Potions
  2087. 64 - Whitesmith's Coins
  2088. 123 - Whitesmith's Nuggets
  2089. 256 - Assassin Cross's Deadly Poison
  2090. ---------------------------------------
  2091. *monster "<map name>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>"};
  2092. *areamonster "<map name>",<x1>,<y1>,<x2>,<y2>,"<monster name>",<amount>{,"<event label>"};
  2093. This command will spawn a monster on the specified coordinates on the specified
  2094. map. If the script is invoked by a character, a special map name, "this", will
  2095. be recognised to mean the name of the map the invoking character is located at.
  2096. This command works fine in the item scripts.
  2097. The same command arguments mean the same things as described above in the
  2098. beginning of this document when talking about permanent monster spawns. Monsters
  2099. spawned in this manner will not respawn upon being killed.
  2100. Unlike the permanent monster spawns, if the mob id is -1, a random monster will
  2101. be picked from the entire database according to the rules configured in the
  2102. server for dead branches. This will work for all other kinds of non-permanent
  2103. monster spawns.
  2104. The only very special thing about this command is an event label, which is an
  2105. optional parameter. This label is written like '<NPC object name>::<label name>'
  2106. and upon the monster being killed, it will execute the script inside of the
  2107. specified NPC object starting from the label given. The RID of the player
  2108. attached at this execution will be the RID of the killing character.
  2109. monster "place.gat",60,100,"Poring",1002,1,"NPCNAME::Label";
  2110. If you do not specify any event label, a label in the NPC object that ran this
  2111. command, called 'OnMyMobDead:' will execute anyway, if present.
  2112. The coordinates of 0,0 will spawn the monster on a random place on the map.
  2113. The 'areamonster' command works much like the 'monster' command and is not
  2114. significantly different, but spawns the monsters within a square defined by
  2115. x1/y1-x2/y2.
  2116. Simple monster killing script:
  2117. <Normal NPC object definition. Let's assume you called him NPCNAME.>
  2118. mes "[Summon Man]";
  2119. mes "Want to start the kill?";
  2120. next;
  2121. menu "Yes",L_Yes,"No",-;
  2122. mes "[Summon Man]";
  2123. mes "Come back later";
  2124. close;
  2125. L_Yes:
  2126. monster "prontera.gat",0,0,"Quest Poring",1002,10,"NPCNAME::L_PoringKilled";
  2127. // By using 0,0 it will spawn them in a random place.
  2128. mes "[Summon Man]";
  2129. mes "Now go and kill all the Poring I summoned";
  2130. // He summoned ten.
  2131. close;
  2132. L_PoringKilled:
  2133. set $PoringKilled,$PoringKilled+1;
  2134. if ($PoringKilled==10) goto L_AllDead;
  2135. end;
  2136. L_AllDead:
  2137. announce "Summon Man: Well done all the poring are dead",3;
  2138. set $PoringKilled,0;
  2139. end;
  2140. For more good examples see just about any official 2-1 or 2-2 job quest script.
  2141. ---------------------------------------
  2142. *killmonster "<map name>","<event label>";
  2143. This command will kill all monsters that were spawned with 'monster' or
  2144. 'addmonster' and have a specified event label attached to them. Commonly used to
  2145. get rid of remaining quest monsters once the quest is complete.
  2146. If the label is given as "All", all monsters which have their respawn times set
  2147. to -1 (like all the monsters summoned with 'monster' or 'areamonster' script
  2148. command, and all monsters summoned with GM commands, but no other ones - that
  2149. is, all non-permanent monsters) on the specified map will be killed regardless
  2150. of the event label value.
  2151. ---------------------------------------
  2152. *killmonsterall "<map name>";
  2153. This command will kill all monsters on a specified map name, regardless of how
  2154. they were spawned or what they are.
  2155. ---------------------------------------
  2156. *clone "<map name>",<x>,<y>,"<event>",<char id>{,<master_id>{,<mode>{,<flag>,<duration>}}}
  2157. This command creates a monster which is a copy of another player. The first
  2158. four arguments serve the same purpose as in the monster script command, The
  2159. <char id> is the character id of the player to clone (player must be online).
  2160. If <master id> is given, the clone will be a 'slave/minion' of it. Master_id
  2161. must be a character id of another online player.
  2162. The mode can be specified to determine the behaviour of the clone, it's
  2163. values are the same as the ones used for the mode field in the mob_db. The
  2164. default mode is aggressive, assists, can move, can attack.
  2165. Flag can be either zero or one currently. If zero, the clone is a normal
  2166. monster that'll target players, if one, it is considered a summoned monster,
  2167. and as such, it'll target other monsters. Defaults to zero.
  2168. The duration specifies how long the clone will live before it is auto-removed.
  2169. Specified in seconds, defaults to no limit (zero).
  2170. Returned value is the monster ID of the spawned clone. If command fails,
  2171. returned value is zero.
  2172. ---------------------------------------
  2173. *doevent "<NPC object name>::<event label>";
  2174. This command will start a new execution thread in a specified NPC object at the
  2175. specified label. The execution of the script running this command will not stop.
  2176. No parameters may be passed with a doevent call.
  2177. The script of the NPC object invoked in this manner will run as if it's been
  2178. invoked by the RID that was active in the script that issued a 'doevent'.
  2179. place.gat,100,100,1%TAB%script%TAB%NPC%TAB%53,{
  2180. mes "This is what you will see when you click me";
  2181. close;
  2182. Label:
  2183. mes "This is what you will see if the doevent is activated";
  2184. close;
  2185. }
  2186. ....
  2187. doevent "NPC::Label";
  2188. ---------------------------------------
  2189. *donpcevent "<event label>";
  2190. This command is kinda confusing cause it performs in two completely different
  2191. ways.
  2192. If the event label is phrased like "::<label name>", all NPC objects that have a
  2193. specified label in them will be invoked as if by a 'doevent', but no RID
  2194. whatsoever will be attached while they execute.
  2195. Otherwise, if the label is given as "<NPC name>::<label name>", a label within
  2196. the NPC object that runs this command will be called, but as if it was running
  2197. inside another, specified NPC object. No RID will be attached to it in this case
  2198. either.
  2199. This can be used for making another NPC react to an action that you have done
  2200. with the NPC that has this command in it, i.e. show an emotion, or say
  2201. something.
  2202. place.gat,100,100,1%TAB%script%TAB%NPC%TAB%53,{
  2203. mes "Hey NPC2 copy what I do";
  2204. close2;
  2205. set @emo, rand(1,30);
  2206. donpcevent "NPC2::Emo";
  2207. Emo:
  2208. emotion @emo;
  2209. end;
  2210. }
  2211. place.gat,102,100,1%TAB%script%TAB%NPC2%TAB%53,{
  2212. mes "Hey NPC copy what I do";
  2213. close2;
  2214. set @emo, rand(1,30);
  2215. donpcevent "NPC::Emo";
  2216. Emo:
  2217. emotion @emo;
  2218. end;
  2219. }
  2220. This will make both NPC perform the same random emotion from 1 to 30, and the
  2221. emotion will appear above each of their heads.
  2222. ---------------------------------------
  2223. *addtimer <ticks>,"<NPC object name>::<label>";
  2224. *deltimer "<NPC object name>::<event label>";
  2225. *addtimercount <ticks>,"<NPC object name>::<event label>";
  2226. These commands will create, destroy, and delay a countdown timer - 'addtimer' to
  2227. create, 'deltimer' to destroy and 'addtimercount' to delay it by the specified
  2228. number of ticks. For all three cases, the event label given is the identifier of
  2229. that timer.
  2230. When this timer runs out, a new execution thread will start in the specified NPC
  2231. object at the specified label. If no such label is found in the NPC object, it
  2232. will run as if clicked. In either case, no RID will be attached during
  2233. execution.
  2234. The ticks are given in 1/1000ths of a second.
  2235. ---------------------------------------
  2236. *stoptimer;
  2237. *inittimer;
  2238. *enablearena;
  2239. *disablearena;
  2240. *cmdothernpc "<npc name?>","<command?>";
  2241. This set of commands is marked as added by someone going under the nickname
  2242. 'RoVeRT', as mentioned the source code comments, and has to do with timers and
  2243. scheduling working entirely unlike any other timing commands. It is not certain
  2244. that they actually even work properly anymore, and most of these read no
  2245. arguments, though the 'inittimer'/'stoptimer' pair of commands has to do
  2246. something with an 'OnTimer' label and will probably invoke it and 'cmdothernpc'
  2247. will execute starting with the label 'OnCommand'. Whatever they actually do, the
  2248. other commands can most likely do it better. The two arena commands definitely
  2249. do not do anything useful at all.
  2250. None of these commands are used in any scripts bundled with eAthena. Most
  2251. probably they are deprecated and left in by mistake.
  2252. Unless RoVeRT can be found and asked to clarify what these were made for, that
  2253. is.
  2254. ---------------------------------------
  2255. *initnpctimer{ "<NPC object name>"};
  2256. *stopnpctimer{ "<NPC object name>"};
  2257. *startnpctimer{ "<NPC object name>"};
  2258. *setnpctimer <tick>{,"<NPC object name>"};
  2259. *getnpctimer(<type of information>{,"<NPC object name>"});
  2260. *attachnpctimer {"<character name>"};
  2261. *detachnpctimer {"<NPC object name>"};
  2262. This set of commands and functions will create and manage an NPC-object based
  2263. timer. The NPC object may be declared by name, or the name in all cases may be
  2264. omitted, in that case this timer will be based in the object the current script
  2265. is running in.
  2266. Why is it actually part of an NPCs structure we aren't sure, but it is, and
  2267. while 'addtimer'/'deltimer' commands will let you have many different timers
  2268. referencing different labels in the same NPC, one each and each with their own
  2269. countdown, 'initnpctimer' can only have one per NPC object. But it can trigger
  2270. many labels and it can let you know how many were triggered already and how many
  2271. still remain.
  2272. This timer is counting up from 0 in ticks of 1/1000ths of a second each. Upon
  2273. creating this timer, the execution will not stop, but will happily continue
  2274. onward. The timer will then invoke new execution threads at labels
  2275. "OnTimer<time>:" in the NPC object it is attached to.
  2276. To create the timer, use the 'initnpctimer', which will start it running.
  2277. 'stopnpctimer' will pause the timer, without clearing the current tick, while
  2278. 'startnpctimer' will let the paused timer continue.
  2279. It is not quite clear whether the new invocations will always have a RID.
  2280. Apparently, the RID that was in effect when the timer was initialised will still
  2281. be attached to these executions in some cases, but it's not quite clear -
  2282. experiment with RID-dependent commands, like 'mes', and tell us what happens and
  2283. who gets the message, if anyone.
  2284. Even if they don't have a RID by default, 'attachnpctimer' will allow you to
  2285. explicitly attach a character's RID to the timer, which will make them the
  2286. target for all character-referencing commands and functions, not to mention
  2287. variables. 'detachnpctimer' will make the RID zero, making all character-
  2288. referencing functions fail with an error.
  2289. 'setnpctimer' will explicitly set the timer to a given tick. To make it useful,
  2290. you will need the 'getnpctimer' function, which the type of information argument
  2291. means:
  2292. 0 - Will return the current tick count of the timer.
  2293. 1 - Will return 1 if there are remaining "OnTimer<ticks>:" labels in the
  2294. specified NPC waiting for execution.
  2295. 2 - Will return the number of times the timer has triggered an "OnTimer<tick>:"
  2296. label in the specified NPC.
  2297. Example 1:
  2298. <NPC Header> {
  2299. initnpctimer;
  2300. npctalk "I cant talk right now, give me 10 seconds";
  2301. end;
  2302. OnTimer5000:
  2303. npctalk "Ok 5 seconds more";
  2304. end;
  2305. OnTimer6000:
  2306. npctalk "4";
  2307. end;
  2308. OnTimer7000:
  2309. npctalk "3";
  2310. end;
  2311. OnTimer8000:
  2312. npctalk "2";
  2313. end;
  2314. OnTimer9000:
  2315. npctalk "1";
  2316. end;
  2317. OnTimer10000:
  2318. stopnpctimer;
  2319. mes "[Man]";
  2320. mes "Ok we can talk now";
  2321. }
  2322. Example 2:
  2323. OnTimer15000:
  2324. set $quote,rand(5);
  2325. if($quote == 0) goto Lquote0;
  2326. if($quote == 1) goto Lquote1;
  2327. if($quote == 2) goto Lquote2;
  2328. if($quote == 3) goto Lquote3;
  2329. if($quote == 4) goto Lquote4;
  2330. Lquote0:
  2331. npctalk "If 0 is randomly picked you will see this";
  2332. setnpctimer 0;
  2333. end;
  2334. Lquote1:
  2335. npctalk "If 1 is randomly picked you will see this";
  2336. setnpctimer 0;
  2337. end;
  2338. Lquote2:
  2339. npctalk "If 2 is randomly picked you will see this";
  2340. setnpctimer 0;
  2341. end;
  2342. Lquote3:
  2343. npctalk "If 3 is randomly picked you will see this";
  2344. setnpctimer 0;
  2345. end;
  2346. Lquote4:
  2347. npctalk "If 4 is randomly picked you will see this";
  2348. setnpctimer 0;
  2349. end;
  2350. // This OnInit label will run when the script is loaded, so that the timer
  2351. // is initialised immediately as the server starts. It is dropped back to 0
  2352. // every time the NPC says something, so it will cycle continiously.
  2353. OnInit:
  2354. initnpctimer;
  2355. end;
  2356. Example 3:
  2357. mes "[Man]";
  2358. mes "I have been waiting "+(getnpctimer(0)/1000)+" seconds for you";
  2359. // we divide the timer returned by 1000 cause it will be displayed in
  2360. // milliseconds otherwise
  2361. close;
  2362. Example 4:
  2363. mes "[Man]";
  2364. mes "Ok I will let you have 30 sec more";
  2365. close2;
  2366. setnpctimer (getnpctimer(0)-30000);
  2367. // Notice the 'close2'. If there were a 'next' there the timer would be
  2368. // changed only after the player pressed the 'next' button.
  2369. end;
  2370. ---------------------------------------
  2371. *announce "<text>",<flag>{,<color>}
  2372. This command will broadcast a message to all or most players, similar to
  2373. @kami/@kamib GM commands.
  2374. The region the broadcast is heard in and the color the message will come up as
  2375. will be determined by the flags:
  2376. announce "This will be shown to everyone at all in yellow.",0;
  2377. The flag values are coded as constants in db/const.txt to make them easier to use:
  2378. - bc_all: Broadcast message is sent server-wide
  2379. - bc_map: Message is sent to everyone in the same map
  2380. - bc_area: Message is sent to players in the vecinity of the source.
  2381. - bc_self: Message is sent only to current player.
  2382. - bc_npc: Broadcast source is the npc, not the player attached to the script
  2383. (useful when a player is not attached or the message should be sent to those
  2384. nearby the npc)
  2385. - bc_yellow: The default is to send broadcasts in yellow color.
  2386. - bc_blue: Alternate broadcast is displayed in blue color.
  2387. The optional parameter, color, allows usage of broadcasts in any custom color.
  2388. The color parameter is a single number which can be in hexadecimal notation.
  2389. For example:
  2390. announce "This will be shown to everyone at all in yellow.",bc_all,0xFFFF00;
  2391. Will display a global announce in yellow. The color format is in RGB (0xRRGGBB).
  2392. Using this for private messages to players is probably not that good an idea,
  2393. but it can be used instead in NPCs to "preview" an announce.
  2394. // This will be a private message to the player using the NPC that made the
  2395. // annonucement
  2396. announce "This is my message just for you",bc_blue|bc_self;
  2397. // This will be shown on everyones screen that is in sight of the NPC.
  2398. announce "This is my message just for you people here",bc_area;
  2399. ---------------------------------------
  2400. *mapannounce "<map name>","<text>",<flag>[,<color>];
  2401. This command will work like 'announce' but will only broadcast to characters
  2402. currently residing on the specified map. The flag and optional color
  2403. parameters are the same as in 'announce', even though the only ones that make
  2404. sense are the color related ones.
  2405. ---------------------------------------
  2406. *areaannounce "<map name>",<x1>,<y1>,<x2>,<y2>,"<text>",<flag>[,<color>];
  2407. This command works like 'announce' but will only broadcast to characters
  2408. residing in the specified x1/y1-x2/y2 square on the map given. The flags and
  2409. color parameter given are the same as in 'announce', but only the color
  2410. related ones have effect.
  2411. areaannounce "prt_church.gat",0,0,350,350,"God's in his heaven, all right with the world",0;
  2412. ---------------------------------------
  2413. *getusers(<type>)
  2414. This function will return a number of users on a map or the whole server. What
  2415. it returns is specified by Type.
  2416. Type is a bitmask, add up to get the effects you want:
  2417. 8 - This will count all characters on the same map as the current NPC.
  2418. (By default, it will count people on the same map as the character)
  2419. 7 - Return the amount of players for the entire server.
  2420. (By default, only the players on the map will be counted.)
  2421. So 'getusers(0)' will return the number of characters on the same map as the
  2422. invoking character, while 'getusers(7)' will give the count for entire server.
  2423. ---------------------------------------
  2424. *getmapusers("<map name>")
  2425. This function will return the number of users currently located on the specified
  2426. map.
  2427. Currently being used in the PVP scripts to check if a PVP room is full of not,
  2428. if the number returned it equal to the maximum allowed it will not let you
  2429. enter.
  2430. ---------------------------------------
  2431. *getareausers("<map name>",<x1>,<y1>,<x2>,<y2>)
  2432. This function will return the count of connected characters which are located
  2433. within the specified area - an x1/y1-x2/y2 square on the specified map.
  2434. This is useful for maps that are split into many buildings, such as all the
  2435. "*_in.gat" maps, due to all the shops and houses.
  2436. ---------------------------------------
  2437. *getareadropitem("<map name>",<x1>,<y1>,<x2>,<y2>,<item>)
  2438. This function will count all the items with the specified ID number lying on the
  2439. ground on the specified map within the x1/y1-x2/y2 square on it and return that
  2440. number.
  2441. This is the only function around where a parameter may be either a string or a
  2442. number! If it's a number, it means that only the items with that item ID number
  2443. will be counted. If it is a string, it is assumed to mean the 'english name'
  2444. field from the item database. If you give it an empty string, or something that
  2445. isn't found from the item database, it will count items number '512' (apples).
  2446. ---------------------------------------
  2447. *disablenpc "<NPC object name>";
  2448. *enablenpc "<NPC object name>";
  2449. These two commands will disable and enable, respectively, an NPC object
  2450. specified by name. The disabled NPC will disappear from sight and will no longer
  2451. be triggerable in the normal way. It is not clear whether it will still be
  2452. accessible through 'donpcevent' and other triggering commands, but it probably
  2453. will be. You can disable even warp NPCs if you know their object names, which is
  2454. an easy way to make a map only accessible through walking half the time. Then
  2455. you 'enablenpc' them back.
  2456. You can also use these commands to create the illusion of an NPC switching
  2457. between several locations, which is often better than actually moving the NPC -
  2458. create one NPC object with a visible and a hidden part to their name, make a few
  2459. copies, and then disable all except one.
  2460. ---------------------------------------
  2461. *hideonnpc "<NPC object name>";
  2462. *hideoffnpc "<NPC object name>";
  2463. These commands will make the NPC object specified display as hidden/visible,
  2464. even though not actually disabled per se. Hidden as in thief Hide skill, but
  2465. unfortunately, not detectable by Ruwach or Sight.
  2466. As they are now, these commands are pointless, it is suggested to use
  2467. 'disablenpc'/'enablenpc', because these two commands actually unload the NPC
  2468. sprite location and other accompanying data from memory when it is not used.
  2469. ---------------------------------------
  2470. *sc_start <effect type>,<ticks>,<extra argument>{,<target ID number>};
  2471. *sc_start2 <effect type>,<ticks>,<extra argument>,<percent chance>{,<target ID number>};
  2472. *sc_start4 <effect type>,<ticks>,<value 1>,<value 2>,<value 3>,<value 4>{,<target ID number>};
  2473. *sc_end <effect type>{,<target ID number>};
  2474. These command bestow a status effect on the invoking character. This command is
  2475. used a lot in the item scripts.
  2476. // This would poison them for 10 min
  2477. sc_start SC_Poison,600000,0;
  2478. Effect type is a number of effect, 'db/const.txt' lists the common (mostly
  2479. negative) status effect types as constants, starting with 'SC_'. You can also
  2480. use this to give someone an effect of a player-cast spell:
  2481. // This will bless someone as if with Bless 10:
  2482. sc_start 10,240000,10;
  2483. Extra argument's meaning differs depending on the effect type, for most effects
  2484. caused by a player skill the extra argument means the level of the skill that
  2485. would have been used to create that effect, for others it might have no meaning
  2486. whatsoever. You can actually bless someone with a 0 bless spell level this way,
  2487. which is fun, but weird.
  2488. The target ID number, if given, will cause the status effect to appear on a
  2489. specified character, instead of the one attached to the running script. This has
  2490. not been properly tested.
  2491. 'sc_start2' is perfectly equivalent, but unlike 'sc_start', a status change
  2492. effect will only occur with a specified percentage chance. 10000 given as the
  2493. chance is equivalent to a 100% chance, 0 is a zero.
  2494. 'sc_start4' is just like sc_start, however it takes four parameters for the
  2495. status change instead of one. What these values are depends on the status
  2496. change in question. For example, elemental armor defense takes the following
  2497. four values:
  2498. - val1 is the first element, val2 is the resistance to the element val1.
  2499. - val3 is the second element, val4 is the resistance to said element.
  2500. eg: sc_start4 SC_DefEle,60000,Ele_Fire,20,Ele_Water,-15;
  2501. 'sc_end' will remove a specified status effect.
  2502. You can see the full list of status effects caused by skills in
  2503. 'src/map/status.h' - they are currently not fully documented, but most of that
  2504. should be rather obvious.
  2505. ---------------------------------------
  2506. *getscrate(<effect type>,<base rate>{,<target ID number>})
  2507. This function will return the chance of a status effect affecting the invoking
  2508. character, in percent, modified by the their current defense against said
  2509. status. The 'base rate' is the base chance of the status effect being inflicted,
  2510. in percent.
  2511. if (rand(100) > getscrate(Eff_Blind, 50)) goto BlindHimNow;
  2512. You can see the full list of available effect types you can possibly inflict in
  2513. 'db/const.txt' under 'Eff_'.
  2514. It is pretty certain that addressing the target by an ID number will not
  2515. currently work due to a bug.
  2516. ---------------------------------------
  2517. *callshop "<shop name>",<flag>;
  2518. This command forces an npc shop to be invoked as if the player clicked on it.
  2519. With normal shops it will not work unless the player is within clicking range,
  2520. but the real use of this script command is together with "invisible shops",
  2521. which are specified in the same way an invisible npc would be specified.
  2522. For example, a generic invisible tool shop could be:
  2523. - shop INVISIBLE_SHOP -,611:-1,1750:-1,501:-1,502:-1,503:-1,504:-1,506:-1
  2524. Which players cannot click on, but can be invoked using:
  2525. callshop "INVISIBLE_SHOP", 0;
  2526. The flag values are: 1 invokes the buying window, 2 invokes the selling
  2527. window, any other value invokes the buy/sell dialogue.
  2528. The function returns 1 on success, and the script is not automatically
  2529. closed, so be careful to not do any item trading on the same script to prevent
  2530. possible exploits (if possible, use close or close2 before invoking the shop
  2531. itself).
  2532. ---------------------------------------
  2533. *debugmes "<message>";
  2534. This command will send the message to the server console (map-server window). It
  2535. will not be displayed anywhere else.
  2536. debugmes strcharinfo(0)+" has just done this that and the other";
  2537. // You would see in the map-server window "NAME has just done this that and
  2538. // the other"
  2539. ---------------------------------------
  2540. *pet <pet id>;
  2541. This command is used in all the item scripts for taming items. Running this
  2542. command will make the pet catching cursor appear on the client connected to the
  2543. invoking character, usable on the monsters with the specified pet ID number. It
  2544. will still work outside an item script.
  2545. A full list of pet IDs can be found inside 'db/pet_db.txt'
  2546. ---------------------------------------
  2547. *bpet;
  2548. This command opens up a pet hatching window on the client connected to the
  2549. invoking character. It is used in item script for the pet incubators and will
  2550. let the player hatch an owned egg. If the character has no eggs, it will just
  2551. open up an empty incubator window.
  2552. This is still usable outside item scripts.
  2553. ---------------------------------------
  2554. *resetlvl <action type>;
  2555. This is a character reset command, meant mostly for rebirth script supporting
  2556. Advanced jobs, which will reset the invoking character's stats and level
  2557. depending on the action type given. Valid action types are:
  2558. 1 - Base level 1, Job level 1, 0 skill points, 0 base xp, 0 job xp, wipes the
  2559. status effects, sets all stats to 1. If the new job is 'Novice High', give
  2560. 100 status points, give First Aid and Play Dead skills.
  2561. 2 - Base level 1, Job level 1, 0 skill points, 0 XP/JXP. Skills and attribute
  2562. values are not altered.
  2563. 3 - Base level 1, base xp 0. Nothing else is changed.
  2564. 4 - Job level 1, job xp 0. Nothing else is changed.
  2565. In all cases it will also unequip everything the character has on.
  2566. Even though it doesn't return a value, it is used as a function in the official
  2567. rebirth scripts. Ask AppleGirl why.
  2568. ---------------------------------------
  2569. *resetstatus;
  2570. This is a character reset command, which will reset the stats on the invoking
  2571. character and give back all the stat points used to raise them previously.
  2572. Nothing will happen to any other numbers about the character.
  2573. Used in reset NPC's (duh!)
  2574. ---------------------------------------
  2575. *resetskill;
  2576. This command takes off all the skill points on the invoking character, so they
  2577. only have Basic Skill blanked out (lvl 0) left, and returns the points for them
  2578. to spend again. Nothing else will change but the skills. Quest skills will also
  2579. reset if 'quest_skill_reset' option is set to Yes in 'battle_athena.conf'. If
  2580. the 'quest_skill_learn' option is set in there, the points in the quest skills
  2581. will also count towards the total.
  2582. Used in reset NPC's (duh!)
  2583. ---------------------------------------
  2584. *changebase <job ID number>;
  2585. This will change the appearance of the invoking character to that of a specified
  2586. job class. Nothing but appearance will change. This command is used in item
  2587. scripts for "Wedding Dress" and "Tuxedo" so the character like job 22, which is
  2588. the job number of the wedding sprites.
  2589. It would be entered in the equip bonus section of an item
  2590. 2338,Wedding_Dress,Wedding Dress,5,43000,0,500,,0,,0,2088958,0,16,,0,0,{(This is for use bonus)},{ bonus bMdef,15; changebase 22; },
  2591. This command only works when inside item scripts.
  2592. ---------------------------------------
  2593. *changesex;
  2594. This command will change the gender for the attached character's account. If it
  2595. was male, it will become female, if it was female, it will become male. The
  2596. change will be written to the character server, but there is no way to send this
  2597. information to the client, so the player will continue to see their character as
  2598. the gender it previously was. What the other players will see before the
  2599. relogin is not clear.
  2600. If the character currently connected when this command was invoked was a
  2601. Dancer/Gypsy or Bard/Clown, they will become a Swordman upon 'changesex'.
  2602. Whatever happens to their skills is not clear. Whatever happens if another
  2603. character on the same account was a gender-specific class is not clear either,
  2604. but it's likely that the client will have serious issues with that, since no
  2605. other characters on the same account will get altered.
  2606. There's good reasons to be very careful when using this command.
  2607. ---------------------------------------
  2608. *waitingroom "<chatroom name>",<limit>{,<event label>,<trigger>};
  2609. This command will create a chat room, owned by the NPC object running this
  2610. script and displayed above the NPC sprite.
  2611. The maximum length of a chatroom name is 60 letters.
  2612. The limit is the maximum number of people allowed to enter the chat room. If the
  2613. optional event and trigger parameters are given, the event label
  2614. ("<NPC object name>::<label name>") will be invoked as if with a 'doevent' upon
  2615. the number of people in the chat room reaching the given triggering amount.
  2616. It's funny, but for compatibility with jAthena, you can swap the event label and
  2617. the trigger parameters, and it will still work.
  2618. // The NPC will just show a box above its head that says "Hello World", clicking
  2619. // it will do nothing, since the limit is zero.
  2620. waitingroom "Hello World",0;
  2621. // The NPC will have a box above its head, it will say "Disco - Waiting Room"
  2622. // and will have 8 waiting slots. Clicking this will enter the chat room, where
  2623. // the player will be able to wait until 8 people accumulate. Once this happens,
  2624. // it will cause the NPC "Bouncer" run the label "OnStart"
  2625. waitingroom "Disco - Waiting Room",8,"Bouncer::OnStart",8;
  2626. Creating a waiting room does not stop the execution of the script and it will
  2627. continue to the next line.
  2628. For more examples see the 2-1 and 2-2 job quest scripts which make extensive use
  2629. of waiting rooms.
  2630. ---------------------------------------
  2631. *delwaitingroom {"<NPC object name"};
  2632. This command will delete a waiting room. If no parameter is given, it will
  2633. delete a waiting room attached to the NPC object running this command, if it is,
  2634. it will delete a waiting room owned by another NPC object. This is the only way
  2635. to get rid of a waiting room, nothing else will cause it to disappear.
  2636. It's not clear what happens to a waiting room if the NPC is disabled with
  2637. 'disablenpc', by the way.
  2638. ---------------------------------------
  2639. *enablewaitingroomevent {"<NPC object name>"};
  2640. *disablewaitingroomevent {"<NPC object name>"};
  2641. This will enable and disable triggering the waiting room event (see
  2642. 'waitingroom') respectively. Optionally giving an NPC object name will do that
  2643. for a specified NPC object. The chat room will not disappear when triggering is
  2644. disabled and enabled in this manner and players will not be kicked out of it.
  2645. Enabling a chat room event will also cause it to immediately check whether the
  2646. number of users in it exceeded the trigger amount and trigger the event
  2647. accordingly.
  2648. Normally, whenever a waiting room was created to make sure that only one
  2649. character is, for example, trying to pass a job quest trial, and no other
  2650. characters are present in the room to mess up the script.
  2651. ---------------------------------------
  2652. *getwaitingroomstate(<information type>{,"<NPC object name>"})
  2653. This function will return information about the wating room state for the
  2654. attached waiting room or for a waiting room attached to the specified NPC if
  2655. any.
  2656. The valid information types are:
  2657. 0 - Number of users currently chatting.
  2658. 1 - Maximum number of users allowed.
  2659. 2 - Will return 1 if the waiting room has a trigger set.
  2660. 0 otherwise.
  2661. 3 - Will return 1 if the waiting room is currently disabled.
  2662. 0 otherwise.
  2663. 4 - The Title of the waiting room (string)
  2664. 5 - Password of the waiting room, if any. Pointless, since there is no way to
  2665. set a password on a waiting room right now.
  2666. 16 - Event name of the waiting room (string)
  2667. 32 - Whether or not the waiting room is full.
  2668. 33 - Whether the amount of users in the waiting room is higher than the trigger
  2669. number.
  2670. ---------------------------------------
  2671. *warpwaitingpc "<map name>",<x>,<y>{,<number of people>};
  2672. This command will warp the amount of characters equal to the trigger number of
  2673. the waiting room chat attached to the NPC object running this command to the
  2674. specified map and coordinates, kicking them out of the chat. Those waiting the
  2675. longest will get warped first. It can also do a random warp on the same map
  2676. ("Random" instead of map name) and warp to the save point ("SavePoint").
  2677. The list of characters to warp is taken from the list of the chat room members.
  2678. Those not in the chat room will not be considered even if they are talking to
  2679. the NPC in question. If the number of people is given, exactly this much people
  2680. will be warped.
  2681. This command can also keep track of who just got warped. It does this by setting
  2682. special variables:
  2683. $@warpwaitingpc[] is an array containing the character id numbers of the
  2684. characters who were just warped.
  2685. $@warpwaitingpcnum contains the number of the character it just warped.
  2686. See also 'getpartymember' for advice on what to do with those variables.
  2687. The obvious way of using this effectively would be to set up a waiting room for
  2688. two characters to be warped onto a random PVP map for a one-on-one duel, for
  2689. example.
  2690. ---------------------------------------
  2691. *waitingroomkickall {"<NPC object name>"};
  2692. This command would kick everybody out of a specified waiting room chat. IF it
  2693. was properly linked into the script interpreter which it isn't, even though the
  2694. code for it is in place. Expect this to become available in upcoming SVN
  2695. releases.
  2696. ---------------------------------------
  2697. *attachrid(<character ID>)
  2698. *detachrid
  2699. A 'RID' is an ID of a character who caused the NPC script to run, as has been
  2700. explained above in the introduction section. Quite a bit of commands want a RID
  2701. to work, since they wouldn't know where to send information otherwise. And in
  2702. quite a few cases the script gets invoked with a RID of zero (like through
  2703. OnTime special labels). If an NPC script needs this, it can attach a specified
  2704. character's id to itself. by calling the 'attachrid' function.
  2705. 'attachrid' returns 1 if the character was found online and 0 if it wasn't.
  2706. This could also be used, while running in a script invoked by a character
  2707. through talking to an NPC, to mess with other characters.
  2708. Detaching the RID will make the RID of the script zero.
  2709. ---------------------------------------
  2710. *isloggedin(<character id>)
  2711. This function returns 1 if the specified character is logged in and 0 if they
  2712. aren't.
  2713. ---------------------------------------
  2714. *setmapflagnosave "<map name>","<alternate map name>",<x>,<y>;
  2715. This command sets the 'nosave' flag for the specified map and also gives an
  2716. alternate respawn-upon-relogin point.
  2717. It does not make a map impossible to make a savepoint on as you would normally
  2718. think, 'savepoint' will still work. It will, however, make the specified map
  2719. kick the reconnecting players off to the alternate map given to the coordinates
  2720. specified.
  2721. ---------------------------------------
  2722. *setmapflag "<map name>",<flag>;
  2723. This command marks a specified map with a map flag given. Map flags alter the
  2724. behavior of the map, you can see the list of the available ones in
  2725. 'db/const.txt' under 'mf_'.
  2726. The map flags alter the behavior of the map regarding teleporting (mf_nomemo,
  2727. mf_noteleport, mf_nowarp, mf_nogo) storing location when disconnected
  2728. (mf_nosave), dead branch usage (mf_nobranch), penalties upon death
  2729. (mf_nopenalty, mf_nozenypenalty), PVP behavior (mf_pvp, mf_pvp_noparty,
  2730. mf_pvp_noguild, mf_nopvp), WoE behavior (mf_gvg,mf_gvg_noparty), ability to use
  2731. skills or open up trade deals (mf_notrade, mf_noskill, mf_noicewall), current
  2732. weather effects (mf_snow, mf_fog, mf_sakura, mf_leaves, mf_rain, mf_clouds,
  2733. mf_fireworks) and whether day/night will be in effect on this map (mf_indoors).
  2734. ---------------------------------------
  2735. *removemapflag "<map name>",<flag>;
  2736. This command removes a mapflag from a specified map. See 'setmapflag'.
  2737. ---------------------------------------
  2738. *pvpon "<map name>";
  2739. *pvpoff "<map name>";
  2740. These commands will turn PVP mode for the specified maps on and off. Beside
  2741. setting the flags referred to in 'setmapflag', 'pvpon' will also create a PVP
  2742. timer and ranking as will @pvpon GM command do.
  2743. ---------------------------------------
  2744. *gvgon "<map name>";
  2745. *gvgoff "<map name>";
  2746. These commands will turn GVG mode for the specified maps on and off, setting up
  2747. appropriate map flags. In GVG mode, maps behave as if during the time of WoE,
  2748. even though WoE itself may or may not actually be in effect.
  2749. ---------------------------------------
  2750. *emotion <emotion number> <, target>;
  2751. This command makes an object display an emoticon sprite above their own as
  2752. if they were doing that emotion. For a full list of emotion numbers,
  2753. see 'db/const.txt' under 'e_'. The inobvious ones are 'e_what' (a question mark)
  2754. and 'e_gasp' (the exclamation mark).
  2755. The optional target parameter specifies who will get the emotion on top of
  2756. their head. If 0 (the default if omitted), the NPC in current use will show
  2757. the emotion, if 1, the player that is running the script will display it.
  2758. ---------------------------------------
  2759. *maprespawnguildid "<map name>",<guild id>,<flag>;
  2760. This command goes through the specified map and for each player and monster
  2761. found there does stuff.
  2762. Flag is a bitmask (add up numbers to get effects you want)
  2763. 1 - warp all guild members to their savepoints.
  2764. 2 - warp all non-guild members to their savepoints.
  2765. 4 - remove all monsters which are not guardian or emperium.
  2766. Flag 7 will, therefore, mean 'wipe all mobs but guardians and the emperium and
  2767. kick all characters out', which is what the official scripts do upon castle
  2768. surrender. Upon start of WoE, the scripts do 2 (warp all intruiders out).
  2769. Characters not belonging to any guild will warp out regardless of the flag setting.
  2770. For examples, check the WoE scripts in the distribution.
  2771. ---------------------------------------
  2772. *agitstart;
  2773. *agitend;
  2774. These two commands will start and end War of Emperium.
  2775. This is a bit more complex than it sounds, since the commands themselves won't
  2776. actually do anything interesting, except causing all 'OnAgitStart:' and
  2777. 'OnAgitEnd:' events to run everywhere, respectively, and setting a so-called
  2778. 'agit_flag' which also doesn't do much interesting itself. They are used as
  2779. simple triggers to run a lot of complex scripts all across the server, and they,
  2780. in turn, are triggered by clock with an 'OnClock<time>:' time-triggering label.
  2781. ---------------------------------------
  2782. *agitcheck(0)
  2783. *agitcheck 1;
  2784. These function and command will let you check whether the server is currently in
  2785. the War of Emperium mode. (that is, if 'agit_flag' is set. Even if it is set,
  2786. doesn't mean that there's even one map in GVG mode somewhere) Calling
  2787. 'agitcheck' as a function (the argument must be zero) will return 1 if WoE is on
  2788. and 0 if it isn't. Running 'agitcheck' as a command will instead set a local
  2789. variable @agit_flag to 1 if the server is in WoE mode and 0 if it isn't.
  2790. ---------------------------------------
  2791. *flagemblem <guild id>;
  2792. This command only works when run by the NPC objects which have sprite id 722,
  2793. which is a 3D guild flag sprite. If it isn't, the data will change, but nothing
  2794. will be seen by anyone. If it is invoked in that manner, the emblem of the
  2795. specified guild will appear on the flag, though, if any players are watching it
  2796. at this moment, they will not see the emblem change until they move out of sight
  2797. of the flag and return.
  2798. This is commonly used in official guildwar scripts with a function call which
  2799. returns a guild id:
  2800. // This will change the emblem on the flag to that of the guild that owns
  2801. // "guildcastle"
  2802. flagemblem GetCastleData("guildcastle.gat",1);
  2803. ---------------------------------------
  2804. *getcastlename("<map name>")
  2805. This function returns the name of the castle when given the map name for that
  2806. castle. The data is read from 'db/castle_db.txt'.
  2807. ---------------------------------------
  2808. *getcastledata("<map name>",<type of data>)
  2809. *setcastledata "<map name>",<type of data>,<value>;
  2810. This function returns the castle ownership information for the castle referred
  2811. to by it's map name. Castle information stored in 'save\castle.txt' for the TXT
  2812. version of the server and in 'guild_castle' table for the SQL version.
  2813. Valid types of data are:
  2814. 0 - Will make the map server request the castle data from the char server, and
  2815. always return 0. This, apparently, will also cause indirectly the execution
  2816. of an 'OnAgitInit:' event mentioned at the beginning of this document.
  2817. 1 - Guild ID
  2818. 2 - Castle Economy score.
  2819. 3 - Castle Defence score.
  2820. 4 - Number of times the economy was invested in today.
  2821. 5 - Number of times the defence was invested in today.
  2822. 9 - Will return 1 if a Kafra was hired for this castle, 0 otherwise.
  2823. 10 - Is 1 if the 1st guardian is present (Soldier Guardian)
  2824. 11 - Is 1 if the 2nd guardian is present (Soldier Guardian)
  2825. 12 - Is 1 if the 3rd guardian is present (Soldier Guardian)
  2826. 13 - Is 1 if the 4th guardian is present (Archer Guardian)
  2827. 14 - Is 1 if the 5th guardian is present (Archer Guardian)
  2828. 15 - Is 1 if the 6th guardian is present (Knight Guardian)
  2829. 16 - Is 1 if the 7th guardian is present (Knight Guardian)
  2830. 17 - Is 1 if the 8th guardian is present (Knight Guardian)
  2831. 18-25 types of data will return current hit point values for guardians 1-8
  2832. respectively.
  2833. The 'setcastledata' command will behave identically, but instead of returning
  2834. values for the specified types of accessible data, it will alter them and cause
  2835. them to be sent to the char server for storage. Data type of 0 won't do
  2836. anything, obviously.
  2837. ---------------------------------------
  2838. *requestguildinfo <guild id>,"<event label>";
  2839. This command requests the guild data from the char server and merrily continues
  2840. with the execution. Whenever the guild information becomes available (which
  2841. happens instantly if the guild information is already in memory, or later, if it
  2842. isn't and the map server has to wait for the char server to reply) it will run
  2843. the specified event as in a 'doevent' call.
  2844. ---------------------------------------
  2845. *getequipcardcnt(<equipment slot>)
  2846. This function will return the number of cards that have been compounded onto a
  2847. specific equipped item for the invoking character. See 'getequipid' for a list
  2848. of possible equipment slots.
  2849. ---------------------------------------
  2850. *successremovecards <equipment slot>;
  2851. This command will remove all cards from the item found in the specified
  2852. equipment slot of the invoking character, create new card items and give them to
  2853. the character. If any cards were removed in this manner, it will also show a
  2854. success effect.
  2855. ---------------------------------------
  2856. *failedremovecards <equipment slot>,<type>;
  2857. This command will remove all cards from the item found in the specified
  2858. equipment slot of the invoking character. 'type' determines what happens to the
  2859. item and the cards:
  2860. 0 - will destroy both the item and the cards.
  2861. 1 - will keep the item, but destroy the cards.
  2862. 2 - will keep the cards, but destroy the item.
  2863. Whatever the type is, it will also show a failure effect on screen.
  2864. ---------------------------------------
  2865. *marriage("<spouse name>");
  2866. This function will marry two characters, the invoking character and the one
  2867. referred to by name given, together, setting them up as each other's marriage
  2868. partner. No second function call has to be issued (in current SVN at least) to
  2869. make sure the marriage works both ways. The function returns 1 upon success, or
  2870. 0 if the marriage could not be completed, either because the other character
  2871. wasn't found or because one of the two characters is already married.
  2872. This will do nothing else for the marriage except setting up the spouse ID for
  2873. both of these characters. No rings will be given and no effects will be shown.
  2874. ---------------------------------------
  2875. *wedding;
  2876. This command will call up wedding effects - the music and confetti - centered on
  2877. the invoking character.
  2878. ---------------------------------------
  2879. *divorce()
  2880. This function will un-marry the invoking character from whoever they were
  2881. married to. Both will no longer be each other's marriage partner, (at least in
  2882. current SVN, which prevents the cases of multi-spouse problems). It will return
  2883. 1 upon success or 0 if the character was not married at all.
  2884. This function will also destroy both wedding rings and send a message to both
  2885. players, telling them they are now divorced.
  2886. ---------------------------------------
  2887. *ispartneron()
  2888. This function returns 1 if the invoking character's marriage partner is
  2889. currently online and 0 if they are not or if the character has no partner.
  2890. ---------------------------------------
  2891. *getpartnerid()
  2892. This function returns the character ID of the invoking character's marriage
  2893. partner, if any. If the invoking character is not married, it will return 0,
  2894. which is a quick way to see if they are married:
  2895. if (getpartnerid()) mes "I'm not going to be your girlfriend!";
  2896. if (getpartnerid()) mes "You're married already!";
  2897. ---------------------------------------
  2898. *warppartner("<map name>",<x>,<y>);
  2899. This function will find the invoking character's marriage partner, if any, and
  2900. warp them to the map and coordinates given. Go kidnap that spouse. :) It will
  2901. return 1 upon success and 0 if the partner is not online, the character is not
  2902. married, or if there's no invoking character (no RID). 0,0 will, as usual,
  2903. normally translate to random coordinates.
  2904. ---------------------------------------
  2905. *adopt "<parent name>","<parent name>","<novice name>";
  2906. *adopt("<parent name>","<parent name>","<novice name>");
  2907. This command will set up a novice as a baby of a married couple. All three are
  2908. referred to by character name. The correct variables are set on all three
  2909. characters in the same call. The command will unequip anything the novice has
  2910. equipped and make them a Job_Baby class, as well as send them a 'your job has
  2911. been changed' message.
  2912. Beware of calling this from inside a 'callfunc' function, cause upon successful
  2913. adoption, this command returns a zero, as if it were a function. This is likely
  2914. to screw up execution of a 'return' command. You may try to call it as a
  2915. function instead, but it doesn't return anything upon an error, which may also
  2916. cause script execution to throw up errors.
  2917. Nothing will happen (and nothing will be returned either) if either future
  2918. parent is below base level 70 and/or if any of the three characters is not found
  2919. online.
  2920. ---------------------------------------
  2921. *getchildid()
  2922. *getmotherid()
  2923. *getfatherid()
  2924. These functions return the characters (shild/mother/father) ID
  2925. if (getmotherid()) mes "Oh... I know your mother's ID:"+getmotherid();
  2926. ---------------------------------------
  2927. *getitemname(<item id>)
  2928. Given the database ID number of an item, this function will return the text
  2929. stored in the 'japanese name' field (which, in eAthena, stores an english name
  2930. the players would normally see on screen.)
  2931. ---------------------------------------
  2932. *makepet <pet id>;
  2933. This command will create a pet egg and put it in the invoking character's
  2934. inventory. The kind of pet is specified by pet ID numbers listed in
  2935. 'db/pet_db.txt'. The egg is created exactly as if the character just successfuly
  2936. caught a pet in the normal way.
  2937. // This will make you a poring:
  2938. makepet 1002;
  2939. Notice that you absolutely have to create pet eggs with this command. If you try
  2940. to give a pet egg with 'getitem', pet data will not be created by the char
  2941. server and the egg will disappear when anyone tries to hatch it.
  2942. ---------------------------------------
  2943. *getexp <base xp>,<job xp>;
  2944. This command will give the invoking character a specified number of base and job
  2945. experience points. Can be used as a quest reward. Negative amounts of experience
  2946. were not tested but should work.
  2947. getexp 10000,5000;
  2948. You can also use the "set" command with the constants defined in 'db/const.txt':
  2949. // These 2 combined has the same effect as the above command
  2950. set BaseExp,BaseExp+10000;
  2951. set JobExp,JobExp+5000;
  2952. You can also reduce the ammount of experience points:
  2953. set BaseExp,BaseExp-10000;
  2954. ---------------------------------------
  2955. *getinventorylist;
  2956. This command sets a bunch of arrays with a complete list of whatever the
  2957. invoking character has in their inventory, including all the data needed to
  2958. recreate these items perfectly if they are destroyed. Here's what you get:
  2959. @inventorylist_id[] - array of item ids.
  2960. @inventorylist_amount[] - their corresponding item amounts.
  2961. @inventorylist_equip[] - whether the item is equipped or not.
  2962. @inventorylist_refine[] - for how much it is refined.
  2963. @inventorylist_identify[] - whether it's refined.
  2964. @inventorylist_attribute[] - whether it is broken.
  2965. @inventorylist_card1[] - These four arrays contain card data for the items.
  2966. @inventorylist_card2[] These data slots are also used to store names
  2967. @inventorylist_card3[] inscribed on the items, so you can explicitly check
  2968. @inventorylist_card4[] if the character owns an item made by a specific
  2969. craftsman.
  2970. @inventorylist_count - the number of items in these lists.
  2971. This could be handy to save/restore a character's inventory, since no other
  2972. command returns such a complete set of data, and could also be the only way to
  2973. correctly handle an NPC trader for carded and named items who could resell them
  2974. - since NPC objects cannot own items, so they have to store item data in
  2975. variables and recreate the items.
  2976. Notice that the variables this command generates are all local and numeric.
  2977. ---------------------------------------
  2978. *getskilllist;
  2979. This command sets a bunch of arrays with a complete list of skills the
  2980. invoking character has. Here's what you get:
  2981. @skilllist_id[] - skill ids.
  2982. @skilllist_lv[] - skill levels.
  2983. @skilllist_flag[] - see 'skill' for the meaning of skill flags.
  2984. @skilllist_count - number of skills in the above arrays.
  2985. While 'getskillv' is probably more useful for most situations, this is the
  2986. easiest way to store all the skills and make the character something else for a
  2987. while. Advanced job for a day? :) This could also be useful to see how many
  2988. skills a character has.
  2989. ---------------------------------------
  2990. *clearitem;
  2991. This command will destroy all items the invoking character has in their
  2992. inventory. (that includes equipped items) It will not affect anything else, like
  2993. storage or cart.
  2994. ---------------------------------------
  2995. *classchange <view id>,<type>;
  2996. This command is very ancient, it's origins are clouded in mystery.
  2997. It will send a 'display id change' packet to everyone in the immediate area of
  2998. the NPC object, which will supposedly make the NPC look like a different sprite,
  2999. an NPC sprite ID, or a monster ID. This effect is not stored anywhere and will
  3000. not persist (Which is odd, cause it would be relatively easy to make it do so)
  3001. and most importantly, will not work at all since this command was broken with
  3002. the introduction of advanced classes. The code is written with the assumption
  3003. that the lowest sprite IDs are the job sprites and the anything beyond them is
  3004. monster and NPC sprites, but since the advanced classes rolled in, they got the
  3005. ID numbers on the other end of the number pool where monster sprites float.
  3006. As a result it is currently impossible to call this command with a valid view
  3007. id. It will do nothing whatsoever if the view ID is below 4047. Getting it to
  3008. run will actually just crash the client.
  3009. It could be a real gem if it can be gotten to actually do what it's supposed to
  3010. do, but this will only happen in a later SVN revision.
  3011. ---------------------------------------
  3012. *misceffect <effect number>;
  3013. This command, if run from an NPC object that has a sprite, will call up a
  3014. specified effect number, centered on the NPC sprite. If the running code does
  3015. not have an object ID (a 'floating' npc) or is not running from an NPC object at
  3016. all (an item script) the effect will be centered on the character who's RID got
  3017. attached to the script, if any. For usable item scripts, this command will
  3018. create an effect centered on the player using the item.
  3019. A full list of known effects is found in 'doc/effect_list.txt'. The list of
  3020. those that actually work may differ greatly between client versions.
  3021. ---------------------------------------
  3022. *soundeffect "<effect filename>",<number>
  3023. *soundeffectall "<effect filename>",<number>
  3024. These two commands will play a sound effect to either the invoking character
  3025. only 'soundeffect' or everyone around ('soundeffectall'). If the running code
  3026. does not have an object ID (a 'floating' npc) or is not running from an NPC
  3027. object at all (an item script) the sound will be centered on the character who's
  3028. RID got attached to the script, if any. If it does, it will be centered on that
  3029. object. (an NPC sprite)
  3030. Effect filename is the filename of the wav in GRF. It must have an extension.
  3031. It's not quite certain what the number actually does, it is sent to the client
  3032. directly, probably it determines which directory of the GRF the effect is played
  3033. from - the sound effect type. It's certain that giving 0 for the number will
  3034. play sound files from 'data/wav', but where the other numbers will read from is
  3035. unclear.
  3036. You can add your own effects this way, naturally.
  3037. ---------------------------------------
  3038. *mapwarp "<from map>","<to map>",<x>,<y>;
  3039. This command will collect all characters located on the From map and warp them
  3040. wholesale to the same point on the To map, or randomly distribute them there if
  3041. the coordinates are zero. "Random" is understood as a special To map name and
  3042. will mean randomly shuffling everyone on the same map.
  3043. ---------------------------------------
  3044. *mobcount("<map name>","<event label>")
  3045. This function will count all the monsters on the specified map that have a given
  3046. event label and return the number or 0 if it can't find any. Naturally, only
  3047. monsters spawned with 'monster' and 'areamonster' script commands can be like
  3048. this.
  3049. However, apparently, if you pass this function an empty string for the event
  3050. label, it should return the total count of normal permanently respawning
  3051. monsters instead. With the current dynamic mobs system, where mobs are not kept
  3052. in memory for maps with no actual people playing on them, this will return a 0
  3053. for any such map.
  3054. ---------------------------------------
  3055. *strmobinfo(<type>,<monster id>);
  3056. This function will return information about a monster record in the database, as
  3057. per 'db/mob_db.txt'. Type is the kind of information returned. Valid types are:
  3058. 1 - 'english name' field in the database, a string.
  3059. 2 - 'japanese name' field in the database, a string.
  3060. All other returned values are numbers:
  3061. 3 - Level.
  3062. 4 - Maximum HP.
  3063. 5 - Maximum SP.
  3064. 6 - Experience reward.
  3065. 7 - Job experience reward.
  3066. ---------------------------------------
  3067. *guardian "<map name>",<x>,<y>,"<name to show>",<mob id>,<amount>{,"<event label>"};
  3068. This command is roughly equivalent to 'monster', but is meant to be used with
  3069. castle guardian monsters and will only work with them. It will set the guardian
  3070. characteristics up according to the castle's investment values and otherwise
  3071. set the things up that only castle guardians need.
  3072. ---------------------------------------
  3073. *guardianinfo(<guardian number>)
  3074. This function will return the current hit point value for the specified guardian
  3075. number, if such guardian is currently installed. This function will only work if
  3076. the invoking character is on a castle map, and will refer only to the guardians
  3077. of that castle, regardless of anything else, i.e. whether the character is a
  3078. member of the guild owning the castle, etc, etc.
  3079. If no guardian is installed in this slot, the function will return -1.
  3080. ---------------------------------------
  3081. * The Pet AI commands
  3082. These commands will only work if the invoking character has a pet, and are meant
  3083. to be executed from pet scripts. They will modify the pet AI decision-making for
  3084. the current pet of the invoking character, and will NOT have any independent
  3085. effect by themselves, which is why only one of them each may be in effect at any
  3086. time for a specific pet. A pet may have 'petloot', 'petskillbonus',
  3087. 'petskillattack' OR 'petpetskillattack2' and 'petskillsupport' OR 'petheal' at
  3088. the same time. 'petheal' is deprecated and is no longer used in the default pet
  3089. scripts.
  3090. *petskillbonus <bonus type>,<value>,<duration>,<delay>;
  3091. This command will make the pet give a bonus to the owner's stat (bonus type -
  3092. bInt,bVit,bDex,bAgi,bLuk,bStr,bSpeedRate - for a full list, see the values
  3093. starting with 'b' in 'db/const.txt')
  3094. *petrecovery <status type>,<delay>;
  3095. This command will make the pet cure a specified status condition. The curing
  3096. actions will occur once every Delay seconds. For a full list of status
  3097. conditions that can be cured, see the list of 'SC_' status condition constants
  3098. in 'db/const.txt'
  3099. *petloot <max items>;
  3100. This command will turn on pet looting, with a maximum number of items to loot
  3101. specified. Pet will store items and return them when the maximum is reached or
  3102. when pet performance is activated.
  3103. *petskillsupport <skill id>,<skill level>,<delay>,<percent hp>,<percent sp>;
  3104. *petheal <level>,<delay>,<percent hp>,<percent sp>;
  3105. This will make the pet use a specified support skill on the owner whenever the
  3106. HP and SP are below the given percent values, with a specified delay time
  3107. between activations. The skill numbers are as per 'db/skill_db.txt'.
  3108. 'petheal' works the same as 'petskillsupport' but has the skill ID hardcoded to
  3109. 28 (Heal). This command is deprecated.
  3110. It's not quite certain who's stats will be used for the skills cast, the
  3111. character's or the pets. Probably, Skotlex can answer that question.
  3112. *petskillattack <skill id>,<skill level>,<rate>,<bonusrate>;
  3113. *petskillattack2 <skill id>,<damage>,<number of attacks>,<rate>,<bonusrate>;
  3114. These two commands will make the pet cast an attack skill on the enemy the pet's
  3115. owner is currently fighting. Skill IDs and levels are as per 'petskillsupport'.
  3116. 'petskillattack2' will make the pet cast the skill with a fixed amount of damage
  3117. inflicted and the specified number of attacks.
  3118. All commands with delays and durations will only make the behavior active for
  3119. the specified duration of seconds, with a delay of the specified number of
  3120. seconds between activations. Rates are a chance of the effect occuring and are
  3121. given in percent. 'bonusrate' is added to the normal rate if the pet intimacy is
  3122. at the maximum possible.
  3123. The behavior modified with the abovementioned commands will only be exibited if
  3124. the pet is loyal and appropriate configuration options are set in
  3125. 'battle_athena.conf'.
  3126. Pet scripts in the database normally run whenever a pet of that type hatches
  3127. from the egg. Other commands usable in item scripts (see 'bonus') will also
  3128. happily run from pet scripts. Apparently, the pet-specific commands will also
  3129. work in NPC scripts and modify the behavior of the current pet up until the pet
  3130. is hatched again. (Which will also occur when the character is logged in again
  3131. with the pet still out of the egg.) It is not certain for how long the effect of
  3132. such command running from an NPC script will eventually persist, but apparently,
  3133. it is possible to usefully employ them in usable item scripts to create pet
  3134. buffing items.
  3135. Nobody tried this before, so you're essentially on your own here.
  3136. --------------------------------------
  3137. *skilleffect <skill id>,<number>;
  3138. This command will display the visual and sound effects of a specified skill (see
  3139. 'db/skill_db.txt' for a full list of skills) on the invoking character's sprite.
  3140. Nothing but the special effects and animation will happen. If the skill's normal
  3141. effect displays a floating number, the number given will float up.
  3142. // This will heal the character with 2000 hp, buff with
  3143. // Bless 10 and Increase AGI 5, and display appropriate
  3144. // effects.
  3145. mes "Blessed be!";
  3146. skilleffect 28,2000;
  3147. heal 2000,0;
  3148. skilleffect 34,0;
  3149. // That's bless 10.
  3150. sc_start 10,240000,10;
  3151. skilleffect 29,0;
  3152. // That's agi 5
  3153. sc_start 12,140000,5;
  3154. ---------------------------------------
  3155. *npcskilleffect <skill id>,<number>,<x>,<y>;
  3156. This command behaves identically to 'skilleffect', however, the effect will not
  3157. be centered on the invoking character's sprite, nor on the NPC sprite, if any,
  3158. but will be centered at map coordinates given on the same map as the invoking
  3159. character.
  3160. ---------------------------------------
  3161. *specialeffect <effect number>;
  3162. This command will display special effect with the given number, centered on the
  3163. specified NPCs coordinates, if any. For a full list of special effect numbers
  3164. known see 'doc/effect_list.txt'. Some effect numbers are known not to work in
  3165. some client releases. (Notably, rain is absent from any client executables
  3166. released after April 2005.)
  3167. ---------------------------------------
  3168. *specialeffect2 <effect number>;
  3169. This command behaves identically to the 'specialeffect', but the effect will be
  3170. centered on the invoking character's sprite.
  3171. ---------------------------------------
  3172. *nude;
  3173. This command will unequip anything equipped on the invoking character.
  3174. It is not required to do this when changing jobs since 'jobchange' will unequip
  3175. everything not equippable by the new job class anyway.
  3176. ---------------------------------------
  3177. *atcommand "<character name>:<command line>";
  3178. This command will run the given command line exactly as if it was typed in from
  3179. the keyboard by the player connected to the invoking character, and that
  3180. character belonged to an account which had GM level 99.
  3181. Even though the character name and the ':' are not used for anything whatsoever,
  3182. it is required to give them in this command because it is processed exactly as
  3183. if typed from the keyboard, and that is how it will arrive into the processing
  3184. function if it is typed from the keyboard. The character name given must be the
  3185. same length as the name of the invoking character object, although nothing else
  3186. is required of it.
  3187. // This will ask the invoker for a character name and then use the '@nuke'
  3188. // GM command on them, killing them mercilessly.
  3189. input @player$;
  3190. gmcommand strcharinfo(0)+":@nuke "+@player$
  3191. This command has a lot of good uses, I am sure you can have some fun with this
  3192. one.
  3193. ---------------------------------------
  3194. *message "<character name>","<message>";
  3195. That command will send a message to the chat window of the character specified
  3196. by name. The text will also appear above the head of that character. It will not
  3197. be seen by anyone else.
  3198. ---------------------------------------
  3199. *npctalk "<message>";
  3200. This command will display a message to the surrounding area as if the NPC object
  3201. running it was a player talking - that is, above their head and in the chat
  3202. window. The display name of the NPC will get appended in front of the message to
  3203. complete the effect.
  3204. // This will make everyone in the area see the NPC greet the character
  3205. // who just invoked it.
  3206. npctalk "Hello "+strcharinfo(0)+" how are you";
  3207. ---------------------------------------
  3208. *hasitems(0)
  3209. This function will return 1 if the invoking character has anything at all in
  3210. their inventory and 0 if they do not. Even though the argument is not used for
  3211. anything, it is required.
  3212. ---------------------------------------
  3213. *getlook(<type>)
  3214. This function will return the number for the currentcharacter look value
  3215. specified by type. See 'setlook' for valid look types.
  3216. This can be used to make a certain script behave differently for characters
  3217. dressed in black. :)
  3218. ---------------------------------------
  3219. *getsavepoint(<information type>)
  3220. This function will return information about the invoking character's save point.
  3221. You can use it to let a character swap between several recorded savepoints.
  3222. Available information types are:
  3223. 0 - Map name (a string)
  3224. 1 - X coordinate
  3225. 2 - Y coordinate
  3226. ---------------------------------------
  3227. *npcspeed <speed value>;
  3228. *npcwalkto <x>,<y>;
  3229. *npcstop;
  3230. These commands will make the NPC object in question move around the map. As they
  3231. currently are, they are a bit buggy and are not useful for much more than making
  3232. an NPC move randomly around the map. (see 'npc/custom/devnpc.txt' for an example
  3233. of such usage)
  3234. 'npcspeed' will set the NPCs walking speed to a specified value. As in the
  3235. @speed GM command, 200 is the slowest possible speed while 0 is the fastest
  3236. possible (instant motion). 100 is the default character walking speed.
  3237. 'npcwalkto' will start the NPC sprite moving towards the specified coordinates
  3238. on the same map as it is currently on.
  3239. 'npcstop' will stop the motion.
  3240. While in transit, the NPC will be clickable, but invoking it will cause it to
  3241. stop motion, which will make it's coordinates different from what the client
  3242. computed based on the speed and motion coordinates. The effect is rather
  3243. unnerving.
  3244. Only a few NPC sprites have walking animations, and those that do, do not get
  3245. the animation invoked when moving the NPC, due to the problem in the npc walking
  3246. code, which looks a bit silly. You might have better success by defining a job-
  3247. sprite based sprite id in 'db/mob-avail.txt' with this.
  3248. ---------------------------------------
  3249. *getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"})
  3250. This function will locate a character object, NPC object or pet's coordinates
  3251. and place their coordinates into the variables specified when calling it. It
  3252. will return 0 if the search was successful, and -1 if the parameters given were
  3253. not variables or the search was not successful.
  3254. Type is the type of object to search for:
  3255. 0 - Character object
  3256. 1 - NPC object
  3257. 2 - Pet object
  3258. 3 - Monster object.
  3259. While 3 is meant to look for a monster object, no searching will be done if you
  3260. specify type 3, and the function will always return -1.
  3261. The search string is optional. If it is not specified, the location of the
  3262. invoking character will always be returned for types 0 and 2, the location of
  3263. the NPC running this function for type 1.
  3264. If a search string is specified, for types 0 and 1, the character or NPC with
  3265. the specified name will be located. If type is 3, the search will locate the
  3266. current pet of the character who's name is given in the search string, it will
  3267. NOT locate a pet by name.
  3268. What a mess. Example, a working and tested one now:
  3269. prontera.gat,164,301,3%TAB%script%TAB%Meh%TAB%730,{
  3270. mes "My name is Meh. I'm here so that Nyah can find me.";
  3271. close;
  3272. }
  3273. prontera.gat,164,299,3%TAB%script%TAB%Nyah%TAB%730,{
  3274. mes "My name is Nyah.";
  3275. mes "I will now search for Meh all across the world!";
  3276. if (getmapxy(@mapname$,@mapx,@mapy,1,"Meh")!=0) goto Notfound;
  3277. mes "And I found him on map "+@mapname$+" at X:"+@mapx+" Y:"+@mapy+" !";
  3278. close;
  3279. Notfound:
  3280. mes "I can't seem to find Meh anywhere!";
  3281. close;
  3282. }
  3283. Notice that NPC objects disabled with 'disablenpc' will still be located.
  3284. ---------------------------------------
  3285. *guildgetexp <amount>;
  3286. This will give the specified amount of guild experience points to the guild the
  3287. invoking character belongs to. It will silently fail if they do not belong to
  3288. any guild.
  3289. ---------------------------------------
  3290. *skilluseid <skill>,<level>;
  3291. *doskill <skill>,<level>;
  3292. *skillusepos <skill>,<level>,<x>,<y>;
  3293. These commands will cause the invoking character to use a specified skill at the
  3294. specified level, as if they had that skill, with their current level and stats.
  3295. If the skill involves targeting a character, no targeting pointer will come up -
  3296. the invoking character will automatically be the skill target.
  3297. 'doskill' is an alias for 'skilluseid'.
  3298. 'skillusepos' will specify a target map square for the skill to be used. If that
  3299. skill is an area effect skill, it will be centered at the square specified. It
  3300. will not work if the skill is supposed to be targeted on character or monster.
  3301. ---------------------------------------
  3302. *logmes "<message>";
  3303. This command will write the message given to the map server npc log file, as
  3304. specified in 'conf/log_athena.conf'. In the TXT version of the server, the log
  3305. file is 'log/npclog.log' by default. In the SQL version, if SQL logging is
  3306. enabled, the message will go to the 'npclog' table, otherwise, it will go to the
  3307. same log file.
  3308. If logs are not enabled, nothing will happen.
  3309. ---------------------------------------
  3310. *summon "<monster name>",<mob id>{,"<event label>"};
  3311. This command will summon a monster. (see also 'monster') Unlike monsters spawned
  3312. with other commands, this one will set up the monster to fight to protect the
  3313. invoking character. Monster name and mob id obey the same rules as the one given
  3314. at the beginning of this document for permanent monster spawns with the
  3315. exceptions mentioned when describing 'monster' command.
  3316. The effect for the skill 'Call Homonuculus' will be displayed centered on the
  3317. invoking character.
  3318. If an event label is given, upon the monster being killed, the event label will
  3319. run as if by 'donpcevent'.
  3320. // Will summon a dead branch-style monster to fight for the character.
  3321. summon "--ja--",-1;
  3322. ---------------------------------------
  3323. *isnight()
  3324. *isday()
  3325. These functions will return 1 or 0 depending on whether the server is in night
  3326. mode or day mode. 'isnight' returns 1 if it's night and 0 if it isn't, 'isday'
  3327. the other way around. They can be used interchangeably, pick the one you like
  3328. more:
  3329. // These two are equivalent:
  3330. if (isday()) mes "I only prowl in the night.";
  3331. if (isnight()!=1) mes "I only prowl in the night.";
  3332. ---------------------------------------
  3333. *isequipped(<id>{,<id>{,<id>{,<id>}}})
  3334. This function will return 1 if the invoking character has all of the item
  3335. IDs given equipped (if card IDs are passed, then it checks if the cards are
  3336. inserted into slots in the equipment they are currently wearing). Theorically
  3337. there is no limit to the number of items that may be tested for at the same time.
  3338. If even one of the items given is not equipped, 0 will be returned.
  3339. // (Poring,Santa Poring,Poporing,Marin)
  3340. if (isequipped(4001,4005,4033,4196)) mes "Wow! You're wearing a full complement of possible poring cards!";
  3341. // (Poring)
  3342. if (isequipped(4001)) mes "A poring card is useful, don't you think?";
  3343. The function was meant for item scripts to support the cards released by Gravity
  3344. in February 2005, but it will work just fine in normal NPC scripts.
  3345. ---------------------------------------
  3346. *isequippedcnt(<card id>{,<card id>{,<card id>{,<card id>}}})
  3347. This function is similar to 'isequipped', but instead of 1 or 0, it will return
  3348. the number of cards in the list given that were found on the invoking character.
  3349. if (isequippedcnt(4001,4005,4033,4196)=4) mes "Finally got all four poring cards?";
  3350. ---------------------------------------
  3351. *cardscnt()
  3352. This function will return the number of cards inserted into the weapon currently
  3353. equipped on the invoking character.
  3354. While this function was meant for item scripts, it will work outside them:
  3355. if (cardscnt()==4) mes "So you've stuck four cards into that weapon, think you're cool now?";
  3356. ---------------------------------------
  3357. *getrefine()
  3358. This function will return the number of plusses the weapon currently equipped on
  3359. the invoking character has been refined for.
  3360. While this function was meant for item scripts, it will work outside them:
  3361. if (getrefine()==10) mes "Wow. That's a murder weapon.";
  3362. ---------------------------------------
  3363. *day;
  3364. *night;
  3365. These two commands will switch the entire server between day and night mode.
  3366. Depending on the configuration, it may cause differing client effects. If your
  3367. server is set to cycle between day and night, it will eventually return to that
  3368. cycle.
  3369. This example will set the night time to start at 03 AM and end at 08 AM, and the
  3370. nighttime will persist if the server restarts during the night, if the automated
  3371. day/night switching is turned off in the configuration files. Figure it out on
  3372. your own:
  3373. -%TAB%script%TAB%DayNight%TAB%-1,{
  3374. end;
  3375. OnClock0300:
  3376. OnClock0800:
  3377. OnInit:
  3378. set $@minutesfrommidnight, gettime(3)*60+gettime(2);
  3379. set $@night_start, 180; // 03:00
  3380. set $@night_end, 480; // 08:00
  3381. if ($@minutesfrommidnight>=$@night_start && $@minutesfrommidnight<$@night_end) goto StartNight;
  3382. goto StartDay;
  3383. StartNight:
  3384. night;
  3385. end;
  3386. StartDay:
  3387. day;
  3388. end; }
  3389. ---------------------------------------
  3390. *getusersname;
  3391. This command will give the invoking character a list of names of the connected
  3392. characters (including themselves) into an NPC script message window (see 'mes')
  3393. paging it by 10 names as if with the 'next' command.
  3394. You need to put a 'close' after that yourself.
  3395. ---------------------------------------
  3396. *dispbottom "<message>";
  3397. This command will send the given message into the invoking character's chat
  3398. window.
  3399. ---------------------------------------
  3400. *recovery;
  3401. This command will revive and restore full HP and SP to all characters currently
  3402. connected to the server.
  3403. ---------------------------------------
  3404. *getpetinfo(<type>)
  3405. This function will return pet information for the pet the invoking character
  3406. currently has active. Valid types are:
  3407. 0 - Unique pet ID number as stored by the char server and distinguishing it
  3408. from all other pets the characters actually have. This value is currently
  3409. useless, at most you can use it to tell pets apart reliably.
  3410. 1 - Pet ID number as per 'db/pet_db.txt' - will tell you what kind of a pet it
  3411. is.
  3412. 2 - Pet name. Will return "null" if there's no pet.
  3413. 4 - Pet friendly level (intimacy score). 1000 is full loyalty.
  3414. 3 - Pet hungry level. 100 is completely full.
  3415. ---------------------------------------
  3416. *checkequipedcard(<card id>)
  3417. This function will return 1 if the card specified by it's item ID number is
  3418. inserted into any equipment they have in their inventory, currently equipped or
  3419. not.
  3420. ---------------------------------------
  3421. *globalmes "message";
  3422. This command will send a message to the chat window of all currently connected
  3423. characters.
  3424. ---------------------------------------
  3425. *jump_zero (<condition>),<label>;
  3426. This command works kinda like an 'if'+'goto' combination in one go. (See 'if').
  3427. If the condition is false (equal to zero) this command will immediately jump to
  3428. the specified label like in 'goto'.
  3429. While 'if' is more generally useful, for some cases this could be an
  3430. optimisation.
  3431. ---------------------------------------
  3432. *select("<option>"{,"<option>"..."<option>"})
  3433. This function is a handy replacement for 'menu' for some specific cases where
  3434. you don't want a complex label structure - like, for example, asking simple yes-
  3435. no questions. It will return the number of menu option picked, starting with 1.
  3436. Like 'menu', it will also set the variable @menu to contain the option the user
  3437. picked.
  3438. if (select("Yes","No")==1) mes "You said yes, I know.";
  3439. And like 'menu', this command has a problem with empty strings - if some of the
  3440. option strings given to it are empty, you won't be able to tell which one the
  3441. user really picked. The number it returns will only make sense if all the empty
  3442. strings are last in the list of options.
  3443. ---------------------------------------
  3444. *getmapmobs("<map name>")
  3445. This function will return the total count of monsters currently located on the
  3446. specified map. If the map name is given as "this", the map the invoking
  3447. character is on will be used. If the map is not found, or the invoker is not a
  3448. character while the map is "this", it will return -1.
  3449. ---------------------------------------
  3450. *unequip <equipment slot>;
  3451. This command will unequip whatever is currently equipped in the invoking
  3452. character's specified equipment slot. For a full list of possible equipment
  3453. slots see 'getequipid'.
  3454. If an item occupies several equipment slots, it will get unequipped from all of
  3455. them. (Which is a good thing.)
  3456. ---------------------------------------
  3457. *defpattern <set number>,"<regular expression pattern>","<event label>";
  3458. *activatepset <set number>;
  3459. *deactivatepset <set number>;
  3460. *deletepset <set number>;
  3461. This set of commands is only available if the server is compiled with regular
  3462. expressions library enabled. Default compilation and most binary distributions
  3463. aren't, which is probably bad, since these, while complex to use, are quite
  3464. fascinating.
  3465. They will make the NPC object listen for text spoken publicly by players and
  3466. match it against regular expression patterns, then trigger labels associated
  3467. with these regular expression patterns.
  3468. Patterns are organised into sets, which are referred to by a set number. You can
  3469. have multiple sets patterns, and multiple patterns may be active at once.
  3470. Numbers for pattern sets start at 1.
  3471. 'defpattern' will associate a given regular expression pattern with an event
  3472. label. This event will be triggered whenever something a player says is matched
  3473. by this regular expression pattern, if the pattern is currently active.
  3474. 'activatepset' will make the pattern set specified active. An active pattern
  3475. will enable triggering labels defined with 'defpattern', which will not happen
  3476. by default.
  3477. 'deactivatepset' will deactivate a specified pattern set. Giving -1 as a pattern
  3478. set number in this case will deactivate all pattern sets defined.
  3479. 'deletepset' will delete a pattern set from memory, so you can create a new
  3480. pattern set in it's place.
  3481. Using regular expressions is high wizardry. But with this high wizardry comes
  3482. unparallelled power of text manipulation. For an explanation of what a regular
  3483. expression pattern is, see a few web pages:
  3484. http://www.regular-expressions.info/
  3485. http://www.weitz.de/regex-coach/
  3486. For an example of this in use, see 'npc\custom\eliza.txt'.
  3487. With this you could, for example, automagically punish players for asking for
  3488. zeny in public places, or alternatively, automagically give them zeny instead if
  3489. they want it so much.
  3490. ---------------------------------------
  3491. *getstrlen("<string>")
  3492. This function will return the length of the string given as an argument. It is
  3493. useful to check if anything input by the player exceeds name length limits and
  3494. other length limits and asking them to try to input something else.
  3495. ---------------------------------------
  3496. *charisalpha("<string>",<position>)
  3497. This function will return 1 if the character number Position in the given string
  3498. is a letter, 0 if it isn't a letter but a digit or a space.
  3499. ---------------------------------------
  3500. *getnameditem(<item id>,"<name to inscribe>");
  3501. *getnameditem("<item name>","<name to inscribe>");
  3502. This function is equivalent to using 'getitem', however, it will not just give
  3503. the character an item object, but will also inscribe it with a specified
  3504. character's name. You may not inscribe items with arbitrary strings, only with
  3505. names of characters that actually exist. While this isn't said anywhere
  3506. specifically, apparently, named items may not have cards in them, slots or no -
  3507. these data slots are taken by the character ID who's name is inscribed. Only one
  3508. remains free and it's not quite clear if a card may be there.
  3509. Items that may not be equipped may NOT be inscribed with a name with this
  3510. function. Which is why this is a function which will return a value - 1 if an
  3511. item was successfully created and 0 if it wasn't for whatever reason. Like
  3512. 'getitem' this function will also take an 'english name' from the itemdb
  3513. database as an item name and will return 0 if nothing is found.
  3514. ---------------------------------------
  3515. *getitemslots(<item ID>)
  3516. This function will look up the item with the specified ID number in the database
  3517. and return the number of slots this kind of items has - 0 if they are not
  3518. slotted. It will also be 0 for all non-equippable items, naturally, unless
  3519. someone messed up the item database. It will return -1 if there is no such item.
  3520. ---------------------------------------
  3521. *getiteminfo(<item ID>,<type>)
  3522. This function will look up the item with the specified ID number in the database
  3523. and return the info set by TYPE argument.
  3524. It will return -1 if there is no such item.
  3525. Valid types are:
  3526. 0 - Buy Price; 1 - Sell Price; 2 - Item Type; 3 - Allowed Classes;
  3527. 3 - maxchance (Max drop chance of this item e.g. 1 = 0.01% , etc..
  3528. if = 0, then monsters don't drop it at all (rare or a quest item)
  3529. if = 10000, then this item is sold in NPC shops only
  3530. 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range;
  3531. 10 - slot; 11 - look; 12 - elv; 13 - wlv;
  3532. Check sample in nps\sample\getiteminfo.txt
  3533. ---------------------------------------
  3534. *getmonsterinfo(<item ID>,<type>)
  3535. This function will look up the monster with the specified ID number in the database
  3536. and return the info set by TYPE argument.
  3537. It will return -1 if there is no such item. Due to specific of MOB DB routines,
  3538. it's better to check monster name. It'd return "Dummy" for a non-existing monster.
  3539. Valid types are listed in const.txt:
  3540. MOB_NAME 0 MOB_LV 1
  3541. MOB_MAXHP 2 MOB_BASEEXP 3
  3542. MOB_JOBEXP 4 MOB_ATK1 5
  3543. MOB_ATK2 6 MOB_DEF 7
  3544. MOB_MDEF 8 MOB_STR 9
  3545. MOB_AGI 10 MOB_VIT 11
  3546. MOB_INT 12 JOB_DEX 13
  3547. MOB_LUK 14 MOB_RANGE 15
  3548. MOB_RANGE2 16 MOB_RANGE3 17
  3549. MOB_SIZE 18 MOB_RACE 19
  3550. MOB_ELEMENT 20 MOB_MODE 21
  3551. Check sample in nps\sample\getmonsterinfo.txt
  3552. ---------------------------------------
  3553. *pow(<number>,<power>)
  3554. Returns the result of the calculation.
  3555. Example:
  3556. set @i, pow(2,3); // @i will be 8
  3557. ---------------------------------------
  3558. *sqrt(<number>)
  3559. Returns square-root of number.
  3560. Examlpe:
  3561. set @i, sqrt(25); // @i will be 5
  3562. ---------------------------------------
  3563. *distance(<x0>,<y0>,<x1>,<y1>)
  3564. Returns distance between 2 points.
  3565. Example:
  3566. set @i, distance(100,200,101,202);
  3567. ---------------------------------------
  3568. *query_sql "your MySQL query", <array name>
  3569. Returns up to 127 values into array.
  3570. Example:
  3571. query_sql "SELECT name FROM 'char' ORDER BY fame DESC LIMIT 5", @most_fame_dude$;
  3572. mes "Hall Of Fame: TOP5";
  3573. mes "1."+@most_fame_dude$[0]; // Will return a person with the biggest fame value.
  3574. mes "2."+@most_fame_dude$[1];
  3575. mes "3."+@most_fame_dude$[2];
  3576. mes "4."+@most_fame_dude$[3];
  3577. mes "5."+@most_fame_dude$[4];
  3578. Note: It is available in SQL version only.
  3579. Note: Use Text$[] array to recieve all data as text.
  3580. ---------------------------------------
  3581. *setd "variable name", <value>
  3582. Works almost identical as set, just that the variable name is identified as a string,
  3583. thus can be constructed dynamically.
  3584. Example:
  3585. set $var$, "Poring";
  3586. setd "$var$", "Poporing";
  3587. mes $var$; // Will return Poporing
  3588. setd "$" + $var$ + "123$", "Poporing is cool";
  3589. mes $Poporing123$; // Will return Poporing is cool.
  3590. ---------------------------------------
  3591. *getd("variable name")
  3592. Retrieves variable, name can be constructed dynamically. Refer to setd for usage.
  3593. Example:
  3594. set @i, getd("$pikachu");
  3595. ---------------------------------------
  3596. *petstat(<flag>)
  3597. Returns current pet status, all are integers except name.
  3598. Returns 0 or "" if the player doesn't have pets.
  3599. Flags usable >>
  3600. PET_CLASS
  3601. PET_NAME
  3602. PET_LEVEL
  3603. PET_HUNGRY
  3604. PET_INTIMATE
  3605. Example:
  3606. set @i, petstat(PET_CLASS);
  3607. Whew.
  3608. What's about all of them.
  3609. ---------------------------------------
  3610. *setitemscript(<ItemID>,<"{ new item script }">)
  3611. Set a new script bonus to the Item. Very useful for game events.
  3612. Example:
  3613. setitemscript 2637,"{ bonus bDamageWhenUnequip,40; if(isequipped(2236)==0)end; if(getskilllv(26)){skill 40,1;}else{skill 26,1+isequipped(2636);} }";
  3614. ---------------------------------------
  3615. *disguise <Monster ID>;
  3616. *undisguise;
  3617. This command disgueses current player with a monster sprite.
  3618. The disguise is disappearing on re-login or on 'undisguise' command.
  3619. Note: It doesn't work with "Pets with equipment on"
  3620. Note: If u're a Sniper, u'd get an old Falcon over your head
  3621. Note: You can kill yourself with some skills
  3622. Note: Monsters of your type could heal you
  3623. Example:
  3624. disquise 1002; //Yay! You're a Poring!!!
  3625. next;
  3626. undisquise; //Yay!!!! You're a human again!!
  3627. ---------------------------------------
  3628. *nude;
  3629. This command will unequip anything equipped on the invoking character.
  3630. It is not required to do this when changing jobs since 'jobchange' will unequip
  3631. everything not equippable by the new job class anyway.
  3632. ---------------------------------------
  3633. *rid2name(rid)
  3634. Converts rid to name. Note: The player/monster/NPC must be online/enabled.
  3635. Good for PCKillEvent where you can convert 'killedrid' to the name of the player.
  3636. Note: rid2name may not produce correct character names since rid = account id.
  3637. It will return the current online character of the account only.