script_commands.txt 223 KB

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