script_commands.txt 230 KB

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