script_commands.txt 232 KB

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