script_commands.txt 233 KB

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