script_commands.txt 229 KB

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