script_commands.txt 202 KB

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