atcommand.c 276 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "atcommand.h"
  14. #include "battle.h"
  15. #include "chat.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "duel.h"
  19. #include "intif.h"
  20. #include "itemdb.h"
  21. #include "log.h"
  22. #include "map.h"
  23. #include "pc.h"
  24. #include "status.h"
  25. #include "skill.h"
  26. #include "mob.h"
  27. #include "npc.h"
  28. #include "pet.h"
  29. #include "homunculus.h"
  30. #include "mercenary.h"
  31. #include "party.h"
  32. #include "guild.h"
  33. #include "script.h"
  34. #include "trade.h"
  35. #include "unit.h"
  36. #ifndef TXT_ONLY
  37. #include "mail.h"
  38. #endif
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include <math.h>
  43. // extern variables
  44. char atcommand_symbol = '@'; // first char of the commands
  45. char charcommand_symbol = '#';
  46. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  47. // local declarations
  48. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  49. typedef struct AtCommandInfo
  50. {
  51. const char* command;
  52. int level;
  53. int level2;
  54. AtCommandFunc func;
  55. } AtCommandInfo;
  56. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  57. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  58. ACMD_FUNC(commands);
  59. /*=========================================
  60. * Generic variables
  61. *-----------------------------------------*/
  62. char atcmd_output[CHAT_SIZE_MAX];
  63. char atcmd_player_name[NAME_LENGTH];
  64. char atcmd_temp[100];
  65. // compare function for sorting high to lowest
  66. int hightolow_compare (const void * a, const void * b)
  67. {
  68. return ( *(int*)b - *(int*)a );
  69. }
  70. // compare function for sorting lowest to highest
  71. int lowtohigh_compare (const void * a, const void * b)
  72. {
  73. return ( *(int*)a - *(int*)b );
  74. }
  75. //-----------------------------------------------------------
  76. // Return the message string of the specified number by [Yor]
  77. //-----------------------------------------------------------
  78. const char* msg_txt(int msg_number)
  79. {
  80. if (msg_number >= 0 && msg_number < MAX_MSG &&
  81. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  82. return msg_table[msg_number];
  83. return "??";
  84. }
  85. //-----------------------------------------------------------
  86. // Returns Players title (from msg_athena.conf) [Lupus]
  87. //-----------------------------------------------------------
  88. static char* player_title_txt(int level)
  89. {
  90. const char* format;
  91. format = (level >= battle_config.title_lvl8) ? msg_txt(342)
  92. : (level >= battle_config.title_lvl7) ? msg_txt(341)
  93. : (level >= battle_config.title_lvl6) ? msg_txt(340)
  94. : (level >= battle_config.title_lvl5) ? msg_txt(339)
  95. : (level >= battle_config.title_lvl4) ? msg_txt(338)
  96. : (level >= battle_config.title_lvl3) ? msg_txt(337)
  97. : (level >= battle_config.title_lvl2) ? msg_txt(336)
  98. : (level >= battle_config.title_lvl1) ? msg_txt(335)
  99. : "";
  100. sprintf(atcmd_temp, format, level);
  101. return atcmd_temp;
  102. }
  103. /*==========================================
  104. * Read Message Data
  105. *------------------------------------------*/
  106. int msg_config_read(const char* cfgName)
  107. {
  108. int msg_number;
  109. char line[1024], w1[1024], w2[1024];
  110. FILE *fp;
  111. static int called = 1;
  112. if ((fp = fopen(cfgName, "r")) == NULL) {
  113. ShowError("Messages file not found: %s\n", cfgName);
  114. return 1;
  115. }
  116. if ((--called) == 0)
  117. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  118. while(fgets(line, sizeof(line), fp))
  119. {
  120. if (line[0] == '/' && line[1] == '/')
  121. continue;
  122. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  123. continue;
  124. if (strcmpi(w1, "import") == 0)
  125. msg_config_read(w2);
  126. else
  127. {
  128. msg_number = atoi(w1);
  129. if (msg_number >= 0 && msg_number < MAX_MSG)
  130. {
  131. if (msg_table[msg_number] != NULL)
  132. aFree(msg_table[msg_number]);
  133. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  134. strcpy(msg_table[msg_number],w2);
  135. }
  136. }
  137. }
  138. fclose(fp);
  139. return 0;
  140. }
  141. /*==========================================
  142. * Cleanup Message Data
  143. *------------------------------------------*/
  144. void do_final_msg(void)
  145. {
  146. int i;
  147. for (i = 0; i < MAX_MSG; i++)
  148. aFree(msg_table[i]);
  149. }
  150. /*==========================================
  151. * @send (used for testing packet sends from the client)
  152. *------------------------------------------*/
  153. ACMD_FUNC(send)
  154. {
  155. int len=0,off,end,type;
  156. long num;
  157. (void)command; // not used
  158. // read message type as hex number (without the 0x)
  159. if(!message || !*message ||
  160. !((sscanf(message, "len %x", &type)==1 && (len=1))
  161. || sscanf(message, "%x", &type)==1) )
  162. {
  163. clif_displaymessage(fd, "Usage:");
  164. clif_displaymessage(fd, " @send len <packet hex number>");
  165. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  166. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  167. return -1;
  168. }
  169. #define PARSE_ERROR(error,p) \
  170. {\
  171. clif_displaymessage(fd, (error));\
  172. sprintf(atcmd_output, ">%s", (p));\
  173. clif_displaymessage(fd, atcmd_output);\
  174. }
  175. //define PARSE_ERROR
  176. #define CHECK_EOS(p) \
  177. if(*(p) == 0){\
  178. clif_displaymessage(fd, "Unexpected end of string");\
  179. return -1;\
  180. }
  181. //define CHECK_EOS
  182. #define SKIP_VALUE(p) \
  183. {\
  184. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  185. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  186. }
  187. //define SKIP_VALUE
  188. #define GET_VALUE(p,num) \
  189. {\
  190. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  191. PARSE_ERROR("Invalid number in:",(p));\
  192. return -1;\
  193. }\
  194. }
  195. //define GET_VALUE
  196. if (type > 0 && type < MAX_PACKET_DB) {
  197. if(len)
  198. {// show packet length
  199. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  200. clif_displaymessage(fd, atcmd_output);
  201. return 0;
  202. }
  203. len=packet_db[sd->packet_ver][type].len;
  204. off=2;
  205. if(len == 0)
  206. {// unknown packet - ERROR
  207. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  208. clif_displaymessage(fd, atcmd_output);
  209. return -1;
  210. } else if(len == -1)
  211. {// dynamic packet
  212. len=SHRT_MAX-4; // maximum length
  213. off=4;
  214. }
  215. WFIFOHEAD(fd, len);
  216. WFIFOW(fd,0)=TOW(type);
  217. // parse packet contents
  218. SKIP_VALUE(message);
  219. while(*message != 0 && off < len){
  220. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  221. {// default (byte)
  222. GET_VALUE(message,num);
  223. WFIFOB(fd,off)=TOB(num);
  224. ++off;
  225. } else if(TOUPPER(*message) == 'B')
  226. {// byte
  227. ++message;
  228. GET_VALUE(message,num);
  229. WFIFOB(fd,off)=TOB(num);
  230. ++off;
  231. } else if(TOUPPER(*message) == 'W')
  232. {// word (2 bytes)
  233. ++message;
  234. GET_VALUE(message,num);
  235. WFIFOW(fd,off)=TOW(num);
  236. off+=2;
  237. } else if(TOUPPER(*message) == 'L')
  238. {// long word (4 bytes)
  239. ++message;
  240. GET_VALUE(message,num);
  241. WFIFOL(fd,off)=TOL(num);
  242. off+=4;
  243. } else if(TOUPPER(*message) == 'S')
  244. {// string - escapes are valid
  245. // get string length - num <= 0 means not fixed length (default)
  246. ++message;
  247. if(*message == '"'){
  248. num=0;
  249. } else {
  250. GET_VALUE(message,num);
  251. while(*message != '"')
  252. {// find start of string
  253. if(*message == 0 || ISSPACE(*message)){
  254. PARSE_ERROR("Not a string:",message);
  255. return -1;
  256. }
  257. ++message;
  258. }
  259. }
  260. // parse string
  261. ++message;
  262. CHECK_EOS(message);
  263. end=(num<=0? 0: min(off+((int)num),len));
  264. for(; *message != '"' && (off < end || end == 0); ++off){
  265. if(*message == '\\'){
  266. ++message;
  267. CHECK_EOS(message);
  268. switch(*message){
  269. case 'a': num=0x07; break; // Bell
  270. case 'b': num=0x08; break; // Backspace
  271. case 't': num=0x09; break; // Horizontal tab
  272. case 'n': num=0x0A; break; // Line feed
  273. case 'v': num=0x0B; break; // Vertical tab
  274. case 'f': num=0x0C; break; // Form feed
  275. case 'r': num=0x0D; break; // Carriage return
  276. case 'e': num=0x1B; break; // Escape
  277. default: num=*message; break;
  278. case 'x': // Hexadecimal
  279. {
  280. ++message;
  281. CHECK_EOS(message);
  282. if(!ISXDIGIT(*message)){
  283. PARSE_ERROR("Not a hexadecimal digit:",message);
  284. return -1;
  285. }
  286. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  287. if(ISXDIGIT(*message)){
  288. ++message;
  289. CHECK_EOS(message);
  290. num<<=8;
  291. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  292. }
  293. WFIFOB(fd,off)=TOB(num);
  294. ++message;
  295. CHECK_EOS(message);
  296. continue;
  297. }
  298. case '0':
  299. case '1':
  300. case '2':
  301. case '3':
  302. case '4':
  303. case '5':
  304. case '6':
  305. case '7': // Octal
  306. {
  307. num=*message-'0'; // 1st octal digit
  308. ++message;
  309. CHECK_EOS(message);
  310. if(ISDIGIT(*message) && *message < '8'){
  311. num<<=3;
  312. num+=*message-'0'; // 2nd octal digit
  313. ++message;
  314. CHECK_EOS(message);
  315. if(ISDIGIT(*message) && *message < '8'){
  316. num<<=3;
  317. num+=*message-'0'; // 3rd octal digit
  318. ++message;
  319. CHECK_EOS(message);
  320. }
  321. }
  322. WFIFOB(fd,off)=TOB(num);
  323. continue;
  324. }
  325. }
  326. } else
  327. num=*message;
  328. WFIFOB(fd,off)=TOB(num);
  329. ++message;
  330. CHECK_EOS(message);
  331. }//for
  332. while(*message != '"')
  333. {// ignore extra characters
  334. ++message;
  335. CHECK_EOS(message);
  336. }
  337. // terminate the string
  338. if(off < end)
  339. {// fill the rest with 0's
  340. memset(WFIFOP(fd,off),0,end-off);
  341. off=end;
  342. }
  343. } else
  344. {// unknown
  345. PARSE_ERROR("Unknown type of value in:",message);
  346. return -1;
  347. }
  348. SKIP_VALUE(message);
  349. }
  350. if(packet_db[sd->packet_ver][type].len == -1)
  351. {// send dynamic packet
  352. WFIFOW(fd,2)=TOW(off);
  353. WFIFOSET(fd,off);
  354. } else
  355. {// send static packet
  356. if(off < len)
  357. memset(WFIFOP(fd,off),0,len-off);
  358. WFIFOSET(fd,len);
  359. }
  360. } else {
  361. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  362. return -1;
  363. }
  364. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  365. clif_displaymessage(fd, atcmd_output);
  366. return 0;
  367. #undef PARSE_ERROR
  368. #undef CHECK_EOS
  369. #undef SKIP_VALUE
  370. #undef GET_VALUE
  371. }
  372. /*==========================================
  373. * @rura, @warp, @mapmove
  374. *------------------------------------------*/
  375. ACMD_FUNC(mapmove)
  376. {
  377. char map_name[MAP_NAME_LENGTH_EXT];
  378. unsigned short mapindex;
  379. short x = 0, y = 0;
  380. int m = -1;
  381. nullpo_retr(-1, sd);
  382. memset(map_name, '\0', sizeof(map_name));
  383. if (!message || !*message ||
  384. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  385. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  386. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  387. return -1;
  388. }
  389. mapindex = mapindex_name2id(map_name);
  390. if (mapindex)
  391. m = map_mapindex2mapid(mapindex);
  392. if (!mapindex) { // m < 0 means on different server! [Kevin]
  393. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  394. return -1;
  395. }
  396. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  397. { //This is to prevent the pc_setpos call from printing an error.
  398. clif_displaymessage(fd, msg_txt(2));
  399. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  400. x = y = 0; //Invalid cell, use random spot.
  401. }
  402. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  403. clif_displaymessage(fd, msg_txt(247));
  404. return -1;
  405. }
  406. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  407. clif_displaymessage(fd, msg_txt(248));
  408. return -1;
  409. }
  410. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  411. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  412. return -1;
  413. }
  414. clif_displaymessage(fd, msg_txt(0)); // Warped.
  415. return 0;
  416. }
  417. /*==========================================
  418. * Displays where a character is. Corrected version by Silent. [Skotlex]
  419. *------------------------------------------*/
  420. ACMD_FUNC(where)
  421. {
  422. struct map_session_data* pl_sd;
  423. nullpo_retr(-1, sd);
  424. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  425. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  426. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  427. return -1;
  428. }
  429. pl_sd = map_nick2sd(atcmd_player_name);
  430. if( pl_sd == NULL
  431. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  432. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  433. ) {
  434. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  435. return -1;
  436. }
  437. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  438. clif_displaymessage(fd, atcmd_output);
  439. return 0;
  440. }
  441. /*==========================================
  442. *
  443. *------------------------------------------*/
  444. ACMD_FUNC(jumpto)
  445. {
  446. struct map_session_data *pl_sd = NULL;
  447. nullpo_retr(-1, sd);
  448. if (!message || !*message) {
  449. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  450. return -1;
  451. }
  452. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  453. {
  454. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  455. return -1;
  456. }
  457. if (pl_sd == sd)
  458. {
  459. clif_displaymessage(fd, "But you are already where you are...");
  460. return -1;
  461. }
  462. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  463. {
  464. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  465. return -1;
  466. }
  467. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  468. {
  469. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  470. return -1;
  471. }
  472. if( pc_isdead(sd) )
  473. {
  474. clif_displaymessage(fd, "You cannot use this command when dead.");
  475. return -1;
  476. }
  477. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  478. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  479. clif_displaymessage(fd, atcmd_output);
  480. return 0;
  481. }
  482. /*==========================================
  483. *
  484. *------------------------------------------*/
  485. ACMD_FUNC(jump)
  486. {
  487. short x = 0, y = 0;
  488. nullpo_retr(-1, sd);
  489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  490. sscanf(message, "%hd %hd", &x, &y);
  491. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  492. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  493. return -1;
  494. }
  495. if( pc_isdead(sd) )
  496. {
  497. clif_displaymessage(fd, "You cannot use this command when dead.");
  498. return -1;
  499. }
  500. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  501. { //This is to prevent the pc_setpos call from printing an error.
  502. clif_displaymessage(fd, msg_txt(2));
  503. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  504. x = y = 0; //Invalid cell, use random spot.
  505. }
  506. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  507. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  508. clif_displaymessage(fd, atcmd_output);
  509. return 0;
  510. }
  511. /*==========================================
  512. * @who3 = Player name, his location
  513. *------------------------------------------*/
  514. ACMD_FUNC(who3)
  515. {
  516. char temp0[100];
  517. struct map_session_data *pl_sd;
  518. struct s_mapiterator* iter;
  519. int j, count;
  520. int pl_GM_level, GM_level;
  521. char match_text[100];
  522. char player_name[NAME_LENGTH];
  523. nullpo_retr(-1, sd);
  524. memset(atcmd_output, '\0', sizeof(atcmd_output));
  525. memset(match_text, '\0', sizeof(match_text));
  526. memset(player_name, '\0', sizeof(player_name));
  527. if (sscanf(message, "%99[^\n]", match_text) < 1)
  528. strcpy(match_text, "");
  529. for (j = 0; match_text[j]; j++)
  530. match_text[j] = TOLOWER(match_text[j]);
  531. count = 0;
  532. GM_level = pc_isGM(sd);
  533. iter = mapit_getallusers();
  534. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  535. {
  536. pl_GM_level = pc_isGM(pl_sd);
  537. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  538. {// you can look only lower or same level
  539. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  540. for (j = 0; player_name[j]; j++)
  541. player_name[j] = TOLOWER(player_name[j]);
  542. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  543. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  544. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  545. } else {
  546. atcmd_output[0]=0;
  547. }
  548. //Player name
  549. sprintf(temp0, msg_txt(343), pl_sd->status.name);
  550. strcat(atcmd_output,temp0);
  551. //Player title, if exists
  552. if (pl_GM_level > 0) {
  553. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  554. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  555. strcat(atcmd_output,temp0);
  556. }
  557. //Players Location: map x y
  558. sprintf(temp0, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  559. strcat(atcmd_output,temp0);
  560. clif_displaymessage(fd, atcmd_output);
  561. count++;
  562. }
  563. }
  564. }
  565. mapit_free(iter);
  566. if (count == 0)
  567. clif_displaymessage(fd, msg_txt(28)); // No player found.
  568. else if (count == 1)
  569. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  570. else {
  571. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  572. clif_displaymessage(fd, atcmd_output);
  573. }
  574. return 0;
  575. }
  576. /*==========================================
  577. * Player name, BLevel, Job,
  578. *------------------------------------------*/
  579. ACMD_FUNC(who2)
  580. {
  581. char temp0[100];
  582. struct map_session_data *pl_sd;
  583. struct s_mapiterator* iter;
  584. int j, count;
  585. int pl_GM_level, GM_level;
  586. char match_text[100];
  587. char player_name[NAME_LENGTH];
  588. nullpo_retr(-1, sd);
  589. memset(atcmd_output, '\0', sizeof(atcmd_output));
  590. memset(match_text, '\0', sizeof(match_text));
  591. memset(player_name, '\0', sizeof(player_name));
  592. if (sscanf(message, "%99[^\n]", match_text) < 1)
  593. strcpy(match_text, "");
  594. for (j = 0; match_text[j]; j++)
  595. match_text[j] = TOLOWER(match_text[j]);
  596. count = 0;
  597. GM_level = pc_isGM(sd);
  598. iter = mapit_getallusers();
  599. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  600. {
  601. pl_GM_level = pc_isGM(pl_sd);
  602. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  603. {// you can look only lower or same level
  604. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  605. for (j = 0; player_name[j]; j++)
  606. player_name[j] = TOLOWER(player_name[j]);
  607. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  608. //Players Name
  609. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  610. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  611. //Player title, if exists
  612. if (pl_GM_level > 0) {
  613. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  614. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  615. strcat(atcmd_output,temp0);
  616. }
  617. //Players Base Level / Job name
  618. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  619. sprintf(temp0, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  620. strcat(atcmd_output,temp0);
  621. clif_displaymessage(fd, atcmd_output);
  622. count++;
  623. }
  624. }
  625. }
  626. mapit_free(iter);
  627. if (count == 0)
  628. clif_displaymessage(fd, msg_txt(28)); // No player found.
  629. else if (count == 1)
  630. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  631. else {
  632. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  633. clif_displaymessage(fd, atcmd_output);
  634. }
  635. return 0;
  636. }
  637. /*==========================================
  638. * Player name, Playrs Party / Guild name
  639. *------------------------------------------*/
  640. ACMD_FUNC(who)
  641. {
  642. char temp0[100];
  643. struct map_session_data *pl_sd;
  644. struct s_mapiterator* iter;
  645. int j, count;
  646. int pl_GM_level, GM_level;
  647. char match_text[100];
  648. char player_name[NAME_LENGTH];
  649. struct guild *g;
  650. struct party_data *p;
  651. nullpo_retr(-1, sd);
  652. memset(temp0, '\0', sizeof(temp0));
  653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  654. memset(match_text, '\0', sizeof(match_text));
  655. memset(player_name, '\0', sizeof(player_name));
  656. if (sscanf(message, "%99[^\n]", match_text) < 1)
  657. strcpy(match_text, "");
  658. for (j = 0; match_text[j]; j++)
  659. match_text[j] = TOLOWER(match_text[j]);
  660. count = 0;
  661. GM_level = pc_isGM(sd);
  662. iter = mapit_getallusers();
  663. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  664. {
  665. pl_GM_level = pc_isGM(pl_sd);
  666. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  667. {// you can look only lower or same level
  668. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  669. for (j = 0; player_name[j]; j++)
  670. player_name[j] = TOLOWER(player_name[j]);
  671. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  672. g = guild_search(pl_sd->status.guild_id);
  673. p = party_search(pl_sd->status.party_id);
  674. //Players Name
  675. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  676. //Player title, if exists
  677. if (pl_GM_level > 0) {
  678. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  679. strcat(atcmd_output,temp0);
  680. }
  681. //Players Party if exists
  682. if (p != NULL) {
  683. //sprintf(temp0," | Party: '%s'", p->name);
  684. sprintf(temp0, msg_txt(345), p->party.name);
  685. strcat(atcmd_output,temp0);
  686. }
  687. //Players Guild if exists
  688. if (g != NULL) {
  689. //sprintf(temp0," | Guild: '%s'", g->name);
  690. sprintf(temp0, msg_txt(346), g->name);
  691. strcat(atcmd_output,temp0);
  692. }
  693. clif_displaymessage(fd, atcmd_output);
  694. count++;
  695. }
  696. }
  697. }
  698. mapit_free(iter);
  699. if (count == 0)
  700. clif_displaymessage(fd, msg_txt(28)); // No player found.
  701. else if (count == 1)
  702. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  703. else {
  704. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  705. clif_displaymessage(fd, atcmd_output);
  706. }
  707. return 0;
  708. }
  709. /*==========================================
  710. *
  711. *------------------------------------------*/
  712. ACMD_FUNC(whomap3)
  713. {
  714. struct map_session_data *pl_sd;
  715. struct s_mapiterator* iter;
  716. int count;
  717. int pl_GM_level, GM_level;
  718. int map_id;
  719. char map_name[MAP_NAME_LENGTH_EXT];
  720. memset(atcmd_output, '\0', sizeof(atcmd_output));
  721. memset(map_name, '\0', sizeof(map_name));
  722. if (!message || !*message)
  723. map_id = sd->bl.m;
  724. else {
  725. sscanf(message, "%15s", map_name);
  726. if ((map_id = map_mapname2mapid(map_name)) < 0)
  727. map_id = sd->bl.m;
  728. }
  729. count = 0;
  730. GM_level = pc_isGM(sd);
  731. iter = mapit_getallusers();
  732. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  733. {
  734. pl_GM_level = pc_isGM(pl_sd);
  735. if( pl_sd->bl.m != map_id )
  736. continue;
  737. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  738. continue;
  739. if (pl_GM_level > 0)
  740. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  741. else
  742. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  743. clif_displaymessage(fd, atcmd_output);
  744. count++;
  745. }
  746. mapit_free(iter);
  747. if (count == 0)
  748. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  749. else if (count == 1)
  750. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  751. else {
  752. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  753. }
  754. clif_displaymessage(fd, atcmd_output);
  755. return 0;
  756. }
  757. /*==========================================
  758. *
  759. *------------------------------------------*/
  760. ACMD_FUNC(whomap2)
  761. {
  762. struct map_session_data *pl_sd;
  763. struct s_mapiterator* iter;
  764. int count;
  765. int pl_GM_level, GM_level;
  766. int map_id = 0;
  767. char map_name[MAP_NAME_LENGTH_EXT];
  768. nullpo_retr(-1, sd);
  769. memset(atcmd_output, '\0', sizeof(atcmd_output));
  770. memset(map_name, '\0', sizeof(map_name));
  771. if (!message || !*message)
  772. map_id = sd->bl.m;
  773. else {
  774. sscanf(message, "%15s", map_name);
  775. if ((map_id = map_mapname2mapid(map_name)) < 0)
  776. map_id = sd->bl.m;
  777. }
  778. count = 0;
  779. GM_level = pc_isGM(sd);
  780. iter = mapit_getallusers();
  781. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  782. {
  783. pl_GM_level = pc_isGM(pl_sd);
  784. if( pl_sd->bl.m != map_id )
  785. continue;
  786. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  787. continue;
  788. if (pl_GM_level > 0)
  789. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  790. else
  791. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  792. clif_displaymessage(fd, atcmd_output);
  793. count++;
  794. }
  795. mapit_free(iter);
  796. if (count == 0)
  797. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  798. else if (count == 1)
  799. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  800. else {
  801. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  802. }
  803. clif_displaymessage(fd, atcmd_output);
  804. return 0;
  805. }
  806. /*==========================================
  807. *
  808. *------------------------------------------*/
  809. ACMD_FUNC(whomap)
  810. {
  811. char temp0[100];
  812. char temp1[100];
  813. struct map_session_data *pl_sd;
  814. struct s_mapiterator* iter;
  815. int count;
  816. int pl_GM_level, GM_level;
  817. int map_id = 0;
  818. char map_name[MAP_NAME_LENGTH_EXT];
  819. struct guild *g;
  820. struct party_data *p;
  821. nullpo_retr(-1, sd);
  822. memset(temp0, '\0', sizeof(temp0));
  823. memset(temp1, '\0', sizeof(temp1));
  824. memset(atcmd_output, '\0', sizeof(atcmd_output));
  825. memset(map_name, '\0', sizeof(map_name));
  826. if (!message || !*message)
  827. map_id = sd->bl.m;
  828. else {
  829. sscanf(message, "%15s", map_name);
  830. if ((map_id = map_mapname2mapid(map_name)) < 0)
  831. map_id = sd->bl.m;
  832. }
  833. count = 0;
  834. GM_level = pc_isGM(sd);
  835. iter = mapit_getallusers();
  836. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  837. {
  838. pl_GM_level = pc_isGM(pl_sd);
  839. if( pl_sd->bl.m != map_id )
  840. continue;
  841. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  842. continue;
  843. g = guild_search(pl_sd->status.guild_id);
  844. if (g == NULL)
  845. sprintf(temp1, "None");
  846. else
  847. sprintf(temp1, "%s", g->name);
  848. p = party_search(pl_sd->status.party_id);
  849. if (p == NULL)
  850. sprintf(temp0, "None");
  851. else
  852. sprintf(temp0, "%s", p->party.name);
  853. if (pl_GM_level > 0)
  854. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  855. else
  856. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  857. clif_displaymessage(fd, atcmd_output);
  858. count++;
  859. }
  860. mapit_free(iter);
  861. if (count == 0)
  862. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  863. else if (count == 1)
  864. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  865. else {
  866. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  867. }
  868. clif_displaymessage(fd, atcmd_output);
  869. return 0;
  870. }
  871. /*==========================================
  872. *
  873. *------------------------------------------*/
  874. ACMD_FUNC(whogm)
  875. {
  876. struct map_session_data* pl_sd;
  877. struct s_mapiterator* iter;
  878. int j, count;
  879. int pl_GM_level, GM_level;
  880. char match_text[CHAT_SIZE_MAX];
  881. char player_name[NAME_LENGTH];
  882. struct guild *g;
  883. struct party_data *p;
  884. nullpo_retr(-1, sd);
  885. memset(atcmd_output, '\0', sizeof(atcmd_output));
  886. memset(match_text, '\0', sizeof(match_text));
  887. memset(player_name, '\0', sizeof(player_name));
  888. if (sscanf(message, "%199[^\n]", match_text) < 1)
  889. strcpy(match_text, "");
  890. for (j = 0; match_text[j]; j++)
  891. match_text[j] = TOLOWER(match_text[j]);
  892. count = 0;
  893. GM_level = pc_isGM(sd);
  894. iter = mapit_getallusers();
  895. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  896. {
  897. pl_GM_level = pc_isGM(pl_sd);
  898. if (!pl_GM_level)
  899. continue;
  900. if (match_text[0])
  901. {
  902. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  903. for (j = 0; player_name[j]; j++)
  904. player_name[j] = TOLOWER(player_name[j]);
  905. // search with no case sensitive
  906. if (strstr(player_name, match_text) == NULL)
  907. continue;
  908. }
  909. if (pl_GM_level > GM_level) {
  910. if (pl_sd->sc.option & OPTION_INVISIBLE)
  911. continue;
  912. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  913. clif_displaymessage(fd, atcmd_output);
  914. count++;
  915. continue;
  916. }
  917. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  918. pl_sd->status.name, pl_GM_level,
  919. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  920. clif_displaymessage(fd, atcmd_output);
  921. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  922. pl_sd->status.base_level,
  923. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  924. clif_displaymessage(fd, atcmd_output);
  925. p = party_search(pl_sd->status.party_id);
  926. g = guild_search(pl_sd->status.guild_id);
  927. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  928. p?p->party.name:"None", g?g->name:"None");
  929. clif_displaymessage(fd, atcmd_output);
  930. count++;
  931. }
  932. mapit_free(iter);
  933. if (count == 0)
  934. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  935. else if (count == 1)
  936. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  937. else {
  938. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  939. clif_displaymessage(fd, atcmd_output);
  940. }
  941. return 0;
  942. }
  943. /*==========================================
  944. *
  945. *------------------------------------------*/
  946. ACMD_FUNC(save)
  947. {
  948. nullpo_retr(-1, sd);
  949. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  950. if (sd->status.pet_id > 0 && sd->pd)
  951. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  952. chrif_save(sd,0);
  953. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  954. return 0;
  955. }
  956. /*==========================================
  957. *
  958. *------------------------------------------*/
  959. ACMD_FUNC(load)
  960. {
  961. int m;
  962. nullpo_retr(-1, sd);
  963. m = map_mapindex2mapid(sd->status.save_point.map);
  964. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  965. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  966. return -1;
  967. }
  968. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  969. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  970. return -1;
  971. }
  972. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  973. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  974. return 0;
  975. }
  976. /*==========================================
  977. *
  978. *------------------------------------------*/
  979. ACMD_FUNC(speed)
  980. {
  981. int speed;
  982. nullpo_retr(-1, sd);
  983. memset(atcmd_output, '\0', sizeof(atcmd_output));
  984. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  985. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  986. clif_displaymessage(fd, atcmd_output);
  987. return -1;
  988. }
  989. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  990. status_calc_bl(&sd->bl, SCB_SPEED);
  991. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  992. return 0;
  993. }
  994. /*==========================================
  995. *
  996. *------------------------------------------*/
  997. ACMD_FUNC(storage)
  998. {
  999. nullpo_retr(-1, sd);
  1000. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  1001. return -1;
  1002. if (storage_storageopen(sd) == 1)
  1003. { //Already open.
  1004. clif_displaymessage(fd, msg_txt(250));
  1005. return -1;
  1006. }
  1007. clif_displaymessage(fd, "Storage opened.");
  1008. return 0;
  1009. }
  1010. /*==========================================
  1011. *
  1012. *------------------------------------------*/
  1013. ACMD_FUNC(guildstorage)
  1014. {
  1015. nullpo_retr(-1, sd);
  1016. if (!sd->status.guild_id) {
  1017. clif_displaymessage(fd, msg_txt(252));
  1018. return -1;
  1019. }
  1020. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  1021. return -1;
  1022. if (sd->state.storage_flag == 1) {
  1023. clif_displaymessage(fd, msg_txt(250));
  1024. return -1;
  1025. }
  1026. if (sd->state.storage_flag == 2) {
  1027. clif_displaymessage(fd, msg_txt(251));
  1028. return -1;
  1029. }
  1030. storage_guild_storageopen(sd);
  1031. clif_displaymessage(fd, "Guild storage opened.");
  1032. return 0;
  1033. }
  1034. /*==========================================
  1035. *
  1036. *------------------------------------------*/
  1037. ACMD_FUNC(option)
  1038. {
  1039. int param1 = 0, param2 = 0, param3 = 0;
  1040. nullpo_retr(-1, sd);
  1041. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1042. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1043. return -1;
  1044. }
  1045. sd->sc.opt1 = param1;
  1046. sd->sc.opt2 = param2;
  1047. pc_setoption(sd, param3);
  1048. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1049. return 0;
  1050. }
  1051. /*==========================================
  1052. *
  1053. *------------------------------------------*/
  1054. ACMD_FUNC(hide)
  1055. {
  1056. nullpo_retr(-1, sd);
  1057. if (sd->sc.option & OPTION_INVISIBLE) {
  1058. sd->sc.option &= ~OPTION_INVISIBLE;
  1059. if (sd->disguise)
  1060. status_set_viewdata(&sd->bl, sd->disguise);
  1061. else
  1062. status_set_viewdata(&sd->bl, sd->status.class_);
  1063. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1064. if( map[sd->bl.m].flag.pvp )
  1065. {// increment the number of pvp players on the map
  1066. map[sd->bl.m].users_pvp++;
  1067. if( !map[sd->bl.m].flag.pvp_nocalcrank )
  1068. {// register the player for ranking calculations
  1069. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  1070. }
  1071. }
  1072. } else {
  1073. sd->sc.option |= OPTION_INVISIBLE;
  1074. sd->vd.class_ = INVISIBLE_CLASS;
  1075. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1076. if( map[sd->bl.m].flag.pvp )
  1077. {// decrement the number of pvp players on the map
  1078. map[sd->bl.m].users_pvp--;
  1079. if( !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  1080. {// unregister the player for ranking
  1081. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  1082. sd->pvp_timer = INVALID_TIMER;
  1083. }
  1084. }
  1085. }
  1086. clif_changeoption(&sd->bl);
  1087. return 0;
  1088. }
  1089. /*==========================================
  1090. * Changes a character's class
  1091. *------------------------------------------*/
  1092. ACMD_FUNC(jobchange)
  1093. {
  1094. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1095. int job = 0, upper = 0;
  1096. nullpo_retr(-1, sd);
  1097. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1098. {
  1099. int i, found = 0;
  1100. const struct { char name[24]; int id; } jobs[] = {
  1101. { "novice", 0 },
  1102. { "swordsman", 1 },
  1103. { "mage", 2 },
  1104. { "archer", 3 },
  1105. { "acolyte", 4 },
  1106. { "merchant", 5 },
  1107. { "thief", 6 },
  1108. { "knight", 7 },
  1109. { "priest", 8 },
  1110. { "priestess", 8 },
  1111. { "wizard", 9 },
  1112. { "blacksmith", 10 },
  1113. { "hunter", 11 },
  1114. { "assassin", 12 },
  1115. { "crusader", 14 },
  1116. { "monk", 15 },
  1117. { "sage", 16 },
  1118. { "rogue", 17 },
  1119. { "alchemist", 18 },
  1120. { "bard", 19 },
  1121. { "dancer", 20 },
  1122. { "super novice", 23 },
  1123. { "supernovice", 23 },
  1124. { "gunslinger", 24 },
  1125. { "gunner", 24 },
  1126. { "ninja", 25 },
  1127. { "high novice", 4001 },
  1128. { "swordsman high", 4002 },
  1129. { "mage high", 4003 },
  1130. { "archer high", 4004 },
  1131. { "acolyte high", 4005 },
  1132. { "merchant high", 4006 },
  1133. { "thief high", 4007 },
  1134. { "lord knight", 4008 },
  1135. { "high priest", 4009 },
  1136. { "high priestess", 4009 },
  1137. { "high wizard", 4010 },
  1138. { "whitesmith", 4011 },
  1139. { "sniper", 4012 },
  1140. { "assassin cross", 4013 },
  1141. { "paladin", 4015 },
  1142. { "champion", 4016 },
  1143. { "professor", 4017 },
  1144. { "stalker", 4018 },
  1145. { "creator", 4019 },
  1146. { "clown", 4020 },
  1147. { "gypsy", 4021 },
  1148. { "baby novice", 4023 },
  1149. { "baby swordsman", 4024 },
  1150. { "baby mage", 4025 },
  1151. { "baby archer", 4026 },
  1152. { "baby acolyte", 4027 },
  1153. { "baby merchant", 4028 },
  1154. { "baby thief", 4029 },
  1155. { "baby knight", 4030 },
  1156. { "baby priest", 4031 },
  1157. { "baby priestess", 4031 },
  1158. { "baby wizard", 4032 },
  1159. { "baby blacksmith",4033 },
  1160. { "baby hunter", 4034 },
  1161. { "baby assassin", 4035 },
  1162. { "baby crusader", 4037 },
  1163. { "baby monk", 4038 },
  1164. { "baby sage", 4039 },
  1165. { "baby rogue", 4040 },
  1166. { "baby alchemist", 4041 },
  1167. { "baby bard", 4042 },
  1168. { "baby dancer", 4043 },
  1169. { "super baby", 4045 },
  1170. { "taekwon", 4046 },
  1171. { "taekwon boy", 4046 },
  1172. { "taekwon girl", 4046 },
  1173. { "star gladiator", 4047 },
  1174. { "soul linker", 4049 },
  1175. { "rune knight", 4054 },
  1176. { "warlock", 4055 },
  1177. { "ranger", 4056 },
  1178. { "arch bishop", 4057 },
  1179. { "mechanic", 4058 },
  1180. { "guillotine", 4059 },
  1181. { "rune knight (Trans)", 4060 },
  1182. { "warlock (Trans)", 4061 },
  1183. { "ranger (Trans)", 4062 },
  1184. { "arch bishop (Trans)", 4063 },
  1185. { "mechanic (Trans)", 4064 },
  1186. { "guillotine (Trans)", 4065 },
  1187. { "royal guard", 4066 },
  1188. { "sorcerer", 4067 },
  1189. { "minstrel", 4068 },
  1190. { "wanderer", 4069 },
  1191. { "sura", 4070 },
  1192. { "genetic", 4071 },
  1193. { "shadow chaser", 4072 },
  1194. { "royal guard (Trans)", 4073 },
  1195. { "sorcerer (Trans)", 4074 },
  1196. { "minstrel (Trans)", 4075 },
  1197. { "wanderer (Trans)", 4076 },
  1198. { "sura (Trans)", 4077 },
  1199. { "genetic (Trans)", 4078 },
  1200. { "shadow chaser (Trans)", 4079 },
  1201. };
  1202. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1203. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1204. job = jobs[i].id;
  1205. upper = 0;
  1206. found = 1;
  1207. break;
  1208. }
  1209. }
  1210. if (!found) {
  1211. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1212. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1213. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1214. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1215. clif_displaymessage(fd, "----- 2nd Class -----");
  1216. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1217. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1218. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1219. clif_displaymessage(fd, " 20 Dancer");
  1220. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1221. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1222. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1223. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1224. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1225. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1226. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1227. clif_displaymessage(fd, "4021 Gypsy");
  1228. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1229. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1230. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1231. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1232. clif_displaymessage(fd, "4072 Shadow Chaser");
  1233. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1234. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1235. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1236. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1237. clif_displaymessage(fd, "4079 Shadow Chaser");
  1238. clif_displaymessage(fd, "----- Expanded Class -----");
  1239. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1240. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1241. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1242. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1243. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1244. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1245. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1246. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1247. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1248. clif_displaymessage(fd, "4045 Super Baby");
  1249. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1250. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1251. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1252. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1253. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1254. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1255. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1256. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1257. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1258. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1259. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1260. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1261. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1262. return -1;
  1263. }
  1264. }
  1265. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27
  1266. || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1267. ) // Deny direct transformation into dummy jobs
  1268. return 0;
  1269. if (pcdb_checkid(job))
  1270. {
  1271. if (pc_jobchange(sd, job, upper) == 0)
  1272. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1273. else {
  1274. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1275. return -1;
  1276. }
  1277. } else {
  1278. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1279. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1280. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1281. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1282. clif_displaymessage(fd, "----- 2nd Class -----");
  1283. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1284. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1285. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1286. clif_displaymessage(fd, " 20 Dancer");
  1287. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1288. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1289. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1290. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1291. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1292. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1293. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1294. clif_displaymessage(fd, "4021 Gypsy");
  1295. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1296. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1297. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1298. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1299. clif_displaymessage(fd, "4072 Shadow Chaser");
  1300. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1301. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1302. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1303. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1304. clif_displaymessage(fd, "4079 Shadow Chaser");
  1305. clif_displaymessage(fd, "----- Expanded Class -----");
  1306. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1307. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1308. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1309. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1310. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1311. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1312. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1313. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1314. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1315. clif_displaymessage(fd, "4045 Super Baby");
  1316. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1317. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1318. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1319. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1320. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1321. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1322. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1323. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1324. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1325. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1326. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1327. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1328. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1329. return -1;
  1330. }
  1331. return 0;
  1332. }
  1333. /*==========================================
  1334. *
  1335. *------------------------------------------*/
  1336. ACMD_FUNC(die)
  1337. {
  1338. nullpo_retr(-1, sd);
  1339. clif_specialeffect(&sd->bl,450,SELF);
  1340. status_kill(&sd->bl);
  1341. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1342. return 0;
  1343. }
  1344. /*==========================================
  1345. *
  1346. *------------------------------------------*/
  1347. ACMD_FUNC(kill)
  1348. {
  1349. struct map_session_data *pl_sd;
  1350. nullpo_retr(-1, sd);
  1351. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1352. if (!message || !*message) {
  1353. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1354. return -1;
  1355. }
  1356. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1357. {
  1358. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1359. return -1;
  1360. }
  1361. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1362. { // you can kill only lower or same level
  1363. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1364. return -1;
  1365. }
  1366. status_kill(&pl_sd->bl);
  1367. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1368. if (fd != pl_sd->fd)
  1369. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1370. return 0;
  1371. }
  1372. /*==========================================
  1373. *
  1374. *------------------------------------------*/
  1375. ACMD_FUNC(alive)
  1376. {
  1377. nullpo_retr(-1, sd);
  1378. if (!status_revive(&sd->bl, 100, 100))
  1379. {
  1380. clif_displaymessage(fd, "You're not dead.");
  1381. return -1;
  1382. }
  1383. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1384. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1385. return 0;
  1386. }
  1387. /*==========================================
  1388. * +kamic [LuzZza]
  1389. *------------------------------------------*/
  1390. ACMD_FUNC(kami)
  1391. {
  1392. unsigned long color=0;
  1393. nullpo_retr(-1, sd);
  1394. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1395. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1396. if (!message || !*message) {
  1397. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1398. return -1;
  1399. }
  1400. sscanf(message, "%199[^\n]", atcmd_output);
  1401. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1402. } else {
  1403. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1404. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1405. return -1;
  1406. }
  1407. if(color > 0xFFFFFF) {
  1408. clif_displaymessage(fd, "Invalid color.");
  1409. return -1;
  1410. }
  1411. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1412. }
  1413. return 0;
  1414. }
  1415. /*==========================================
  1416. *
  1417. *------------------------------------------*/
  1418. ACMD_FUNC(heal)
  1419. {
  1420. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1421. nullpo_retr(-1, sd);
  1422. sscanf(message, "%d %d", &hp, &sp);
  1423. // some overflow checks
  1424. if( hp == INT_MIN ) hp++;
  1425. if( sp == INT_MIN ) sp++;
  1426. if ( hp == 0 && sp == 0 ) {
  1427. if (!status_percent_heal(&sd->bl, 100, 100))
  1428. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1429. else
  1430. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1431. return 0;
  1432. }
  1433. if ( hp > 0 && sp >= 0 ) {
  1434. if(!status_heal(&sd->bl, hp, sp, 0))
  1435. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1436. else
  1437. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1438. return 0;
  1439. }
  1440. if ( hp < 0 && sp <= 0 ) {
  1441. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1442. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1443. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1444. return 0;
  1445. }
  1446. //Opposing signs.
  1447. if ( hp ) {
  1448. if (hp > 0)
  1449. status_heal(&sd->bl, hp, 0, 0);
  1450. else {
  1451. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1452. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1453. }
  1454. }
  1455. if ( sp ) {
  1456. if (sp > 0)
  1457. status_heal(&sd->bl, 0, sp, 0);
  1458. else
  1459. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1460. }
  1461. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1462. return 0;
  1463. }
  1464. /*==========================================
  1465. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1466. *------------------------------------------*/
  1467. ACMD_FUNC(item)
  1468. {
  1469. char item_name[100];
  1470. int number = 0, item_id, flag;
  1471. struct item item_tmp;
  1472. struct item_data *item_data;
  1473. int get_count, i;
  1474. nullpo_retr(-1, sd);
  1475. memset(item_name, '\0', sizeof(item_name));
  1476. if (!message || !*message || (
  1477. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1478. sscanf(message, "%99s %d", item_name, &number) < 1
  1479. )) {
  1480. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1481. return -1;
  1482. }
  1483. if (number <= 0)
  1484. number = 1;
  1485. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1486. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1487. {
  1488. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1489. return -1;
  1490. }
  1491. item_id = item_data->nameid;
  1492. get_count = number;
  1493. //Check if it's stackable.
  1494. if (!itemdb_isstackable2(item_data))
  1495. get_count = 1;
  1496. for (i = 0; i < number; i += get_count) {
  1497. // if not pet egg
  1498. if (!pet_create_egg(sd, item_id)) {
  1499. memset(&item_tmp, 0, sizeof(item_tmp));
  1500. item_tmp.nameid = item_id;
  1501. item_tmp.identify = 1;
  1502. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1503. clif_additem(sd, 0, 0, flag);
  1504. }
  1505. }
  1506. //Logs (A)dmins items [Lupus]
  1507. log_pick_pc(sd, LOG_TYPE_COMMAND, item_id, number, NULL);
  1508. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1509. return 0;
  1510. }
  1511. /*==========================================
  1512. *
  1513. *------------------------------------------*/
  1514. ACMD_FUNC(item2)
  1515. {
  1516. struct item item_tmp;
  1517. struct item_data *item_data;
  1518. char item_name[100];
  1519. int item_id, number = 0;
  1520. int identify = 0, refine = 0, attr = 0;
  1521. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1522. int flag;
  1523. int loop, get_count, i;
  1524. nullpo_retr(-1, sd);
  1525. memset(item_name, '\0', sizeof(item_name));
  1526. if (!message || !*message || (
  1527. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1528. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1529. )) {
  1530. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1531. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1532. return -1;
  1533. }
  1534. if (number <= 0)
  1535. number = 1;
  1536. item_id = 0;
  1537. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1538. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1539. item_id = item_data->nameid;
  1540. if (item_id > 500) {
  1541. loop = 1;
  1542. get_count = number;
  1543. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1544. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1545. loop = number;
  1546. get_count = 1;
  1547. if (item_data->type == IT_PETEGG) {
  1548. identify = 1;
  1549. refine = 0;
  1550. }
  1551. if (item_data->type == IT_PETARMOR)
  1552. refine = 0;
  1553. if (refine > MAX_REFINE)
  1554. refine = MAX_REFINE;
  1555. } else {
  1556. identify = 1;
  1557. refine = attr = 0;
  1558. }
  1559. for (i = 0; i < loop; i++) {
  1560. memset(&item_tmp, 0, sizeof(item_tmp));
  1561. item_tmp.nameid = item_id;
  1562. item_tmp.identify = identify;
  1563. item_tmp.refine = refine;
  1564. item_tmp.attribute = attr;
  1565. item_tmp.card[0] = c1;
  1566. item_tmp.card[1] = c2;
  1567. item_tmp.card[2] = c3;
  1568. item_tmp.card[3] = c4;
  1569. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1570. clif_additem(sd, 0, 0, flag);
  1571. }
  1572. //Logs (A)dmins items [Lupus]
  1573. log_pick_pc(sd, LOG_TYPE_COMMAND, item_tmp.nameid, number, &item_tmp);
  1574. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1575. } else {
  1576. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1577. return -1;
  1578. }
  1579. return 0;
  1580. }
  1581. /*==========================================
  1582. *
  1583. *------------------------------------------*/
  1584. ACMD_FUNC(itemreset)
  1585. {
  1586. int i;
  1587. nullpo_retr(-1, sd);
  1588. for (i = 0; i < MAX_INVENTORY; i++) {
  1589. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1590. //Logs (A)dmins items [Lupus]
  1591. log_pick_pc(sd, LOG_TYPE_COMMAND, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1592. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0);
  1593. }
  1594. }
  1595. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1596. return 0;
  1597. }
  1598. /*==========================================
  1599. * Atcommand @lvlup
  1600. *------------------------------------------*/
  1601. ACMD_FUNC(baselevelup)
  1602. {
  1603. int level=0, i=0, status_point=0;
  1604. nullpo_retr(-1, sd);
  1605. level = atoi(message);
  1606. if (!message || !*message || !level) {
  1607. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1608. return -1;
  1609. }
  1610. if (level > 0) {
  1611. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1612. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1613. return -1;
  1614. } // End Addition
  1615. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1616. level = pc_maxbaselv(sd) - sd->status.base_level;
  1617. for (i = 0; i < level; i++)
  1618. status_point += pc_gets_status_point(sd->status.base_level + i);
  1619. sd->status.status_point += status_point;
  1620. sd->status.base_level += (unsigned int)level;
  1621. status_percent_heal(&sd->bl, 100, 100);
  1622. clif_misceffect(&sd->bl, 0);
  1623. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1624. } else {
  1625. if (sd->status.base_level == 1) {
  1626. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1627. return -1;
  1628. }
  1629. level*=-1;
  1630. if ((unsigned int)level >= sd->status.base_level)
  1631. level = sd->status.base_level-1;
  1632. for (i = 0; i > -level; i--)
  1633. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1634. if (sd->status.status_point < status_point)
  1635. pc_resetstate(sd);
  1636. if (sd->status.status_point < status_point)
  1637. sd->status.status_point = 0;
  1638. else
  1639. sd->status.status_point -= status_point;
  1640. sd->status.base_level -= (unsigned int)level;
  1641. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1642. }
  1643. sd->status.base_exp = 0;
  1644. clif_updatestatus(sd, SP_STATUSPOINT);
  1645. clif_updatestatus(sd, SP_BASELEVEL);
  1646. clif_updatestatus(sd, SP_BASEEXP);
  1647. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1648. status_calc_pc(sd, 0);
  1649. if(sd->status.party_id)
  1650. party_send_levelup(sd);
  1651. return 0;
  1652. }
  1653. /*==========================================
  1654. *
  1655. *------------------------------------------*/
  1656. ACMD_FUNC(joblevelup)
  1657. {
  1658. int level=0;
  1659. nullpo_retr(-1, sd);
  1660. level = atoi(message);
  1661. if (!message || !*message || !level) {
  1662. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1663. return -1;
  1664. }
  1665. if (level > 0) {
  1666. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1667. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1668. return -1;
  1669. }
  1670. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1671. level = pc_maxjoblv(sd) - sd->status.job_level;
  1672. sd->status.job_level += (unsigned int)level;
  1673. sd->status.skill_point += level;
  1674. clif_misceffect(&sd->bl, 1);
  1675. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1676. } else {
  1677. if (sd->status.job_level == 1) {
  1678. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1679. return -1;
  1680. }
  1681. level *=-1;
  1682. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1683. level = sd->status.job_level-1;
  1684. sd->status.job_level -= (unsigned int)level;
  1685. if (sd->status.skill_point < level)
  1686. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1687. if (sd->status.skill_point < level)
  1688. sd->status.skill_point = 0;
  1689. else
  1690. sd->status.skill_point -= level;
  1691. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1692. }
  1693. sd->status.job_exp = 0;
  1694. clif_updatestatus(sd, SP_JOBLEVEL);
  1695. clif_updatestatus(sd, SP_JOBEXP);
  1696. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1697. clif_updatestatus(sd, SP_SKILLPOINT);
  1698. status_calc_pc(sd, 0);
  1699. return 0;
  1700. }
  1701. /*==========================================
  1702. * @help
  1703. *------------------------------------------*/
  1704. ACMD_FUNC(help)
  1705. {
  1706. char buf[2048], w1[2048], w2[2048];
  1707. int i, gm_level;
  1708. FILE* fp;
  1709. nullpo_retr(-1, sd);
  1710. memset(buf, '\0', sizeof(buf));
  1711. if ((fp = fopen(help_txt, "r")) != NULL) {
  1712. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1713. gm_level = pc_isGM(sd);
  1714. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1715. if (buf[0] == '/' && buf[1] == '/')
  1716. continue;
  1717. for (i = 0; buf[i] != '\0'; i++) {
  1718. if (buf[i] == '\r' || buf[i] == '\n') {
  1719. buf[i] = '\0';
  1720. break;
  1721. }
  1722. }
  1723. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1724. clif_displaymessage(fd, buf);
  1725. else if (gm_level >= atoi(w1))
  1726. clif_displaymessage(fd, w2);
  1727. }
  1728. fclose(fp);
  1729. } else {
  1730. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1731. return -1;
  1732. }
  1733. return 0;
  1734. }
  1735. /*==========================================
  1736. * @help2 - Char commands [Kayla]
  1737. *------------------------------------------*/
  1738. ACMD_FUNC(help2)
  1739. {
  1740. char buf[2048], w1[2048], w2[2048];
  1741. int i, gm_level;
  1742. FILE* fp;
  1743. nullpo_retr(-1, sd);
  1744. memset(buf, '\0', sizeof(buf));
  1745. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1746. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1747. gm_level = pc_isGM(sd);
  1748. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1749. if (buf[0] == '/' && buf[1] == '/')
  1750. continue;
  1751. for (i = 0; buf[i] != '\0'; i++) {
  1752. if (buf[i] == '\r' || buf[i] == '\n') {
  1753. buf[i] = '\0';
  1754. break;
  1755. }
  1756. }
  1757. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1758. clif_displaymessage(fd, buf);
  1759. else if (gm_level >= atoi(w1))
  1760. clif_displaymessage(fd, w2);
  1761. }
  1762. fclose(fp);
  1763. } else {
  1764. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1765. return -1;
  1766. }
  1767. return 0;
  1768. }
  1769. // helper function, used in foreach calls to stop auto-attack timers
  1770. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1771. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1772. {
  1773. struct unit_data *ud = unit_bl2ud(bl);
  1774. int id = va_arg(ap, int);
  1775. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1776. {
  1777. unit_stop_attack(bl);
  1778. return 1;
  1779. }
  1780. return 0;
  1781. }
  1782. /*==========================================
  1783. *
  1784. *------------------------------------------*/
  1785. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1786. {
  1787. TBL_PC* sd = (TBL_PC*)bl;
  1788. clif_pvpset(sd, 0, 0, 2);
  1789. if (sd->pvp_timer != INVALID_TIMER) {
  1790. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1791. sd->pvp_timer = INVALID_TIMER;
  1792. }
  1793. return 0;
  1794. }
  1795. ACMD_FUNC(pvpoff)
  1796. {
  1797. nullpo_retr(-1, sd);
  1798. if (!map[sd->bl.m].flag.pvp) {
  1799. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1800. return -1;
  1801. }
  1802. map[sd->bl.m].flag.pvp = 0;
  1803. if (!battle_config.pk_mode)
  1804. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1805. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1806. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1807. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1808. return 0;
  1809. }
  1810. /*==========================================
  1811. *
  1812. *------------------------------------------*/
  1813. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1814. {
  1815. TBL_PC* sd = (TBL_PC*)bl;
  1816. if (sd->pvp_timer == INVALID_TIMER) {
  1817. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1818. sd->pvp_rank = 0;
  1819. sd->pvp_lastusers = 0;
  1820. sd->pvp_point = 5;
  1821. sd->pvp_won = 0;
  1822. sd->pvp_lost = 0;
  1823. }
  1824. return 0;
  1825. }
  1826. ACMD_FUNC(pvpon)
  1827. {
  1828. nullpo_retr(-1, sd);
  1829. if (map[sd->bl.m].flag.pvp) {
  1830. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1831. return -1;
  1832. }
  1833. map[sd->bl.m].flag.pvp = 1;
  1834. if (!battle_config.pk_mode)
  1835. {// display pvp circle and rank
  1836. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1837. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1838. }
  1839. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1840. return 0;
  1841. }
  1842. /*==========================================
  1843. *
  1844. *------------------------------------------*/
  1845. ACMD_FUNC(gvgoff)
  1846. {
  1847. nullpo_retr(-1, sd);
  1848. if (!map[sd->bl.m].flag.gvg) {
  1849. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1850. return -1;
  1851. }
  1852. map[sd->bl.m].flag.gvg = 0;
  1853. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1854. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1855. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1856. return 0;
  1857. }
  1858. /*==========================================
  1859. *
  1860. *------------------------------------------*/
  1861. ACMD_FUNC(gvgon)
  1862. {
  1863. nullpo_retr(-1, sd);
  1864. if (map[sd->bl.m].flag.gvg) {
  1865. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1866. return -1;
  1867. }
  1868. map[sd->bl.m].flag.gvg = 1;
  1869. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1870. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1871. return 0;
  1872. }
  1873. /*==========================================
  1874. *
  1875. *------------------------------------------*/
  1876. ACMD_FUNC(model)
  1877. {
  1878. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1879. nullpo_retr(-1, sd);
  1880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1881. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1882. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1883. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1884. clif_displaymessage(fd, atcmd_output);
  1885. return -1;
  1886. }
  1887. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1888. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1889. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1890. pc_changelook(sd, LOOK_HAIR, hair_style);
  1891. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1892. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1893. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1894. } else {
  1895. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1896. return -1;
  1897. }
  1898. return 0;
  1899. }
  1900. /*==========================================
  1901. * @dye && @ccolor
  1902. *------------------------------------------*/
  1903. ACMD_FUNC(dye)
  1904. {
  1905. int cloth_color = 0;
  1906. nullpo_retr(-1, sd);
  1907. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1908. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1909. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1910. clif_displaymessage(fd, atcmd_output);
  1911. return -1;
  1912. }
  1913. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1914. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1915. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1916. } else {
  1917. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1918. return -1;
  1919. }
  1920. return 0;
  1921. }
  1922. /*==========================================
  1923. * @hairstyle && @hstyle
  1924. *------------------------------------------*/
  1925. ACMD_FUNC(hair_style)
  1926. {
  1927. int hair_style = 0;
  1928. nullpo_retr(-1, sd);
  1929. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1930. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1931. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1932. clif_displaymessage(fd, atcmd_output);
  1933. return -1;
  1934. }
  1935. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1936. pc_changelook(sd, LOOK_HAIR, hair_style);
  1937. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1938. } else {
  1939. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1940. return -1;
  1941. }
  1942. return 0;
  1943. }
  1944. /*==========================================
  1945. * @haircolor && @hcolor
  1946. *------------------------------------------*/
  1947. ACMD_FUNC(hair_color)
  1948. {
  1949. int hair_color = 0;
  1950. nullpo_retr(-1, sd);
  1951. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1952. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1953. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1954. clif_displaymessage(fd, atcmd_output);
  1955. return -1;
  1956. }
  1957. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1958. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1959. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1960. } else {
  1961. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1962. return -1;
  1963. }
  1964. return 0;
  1965. }
  1966. /*==========================================
  1967. * @go [city_number or city_name] - Updated by Harbin
  1968. *------------------------------------------*/
  1969. ACMD_FUNC(go)
  1970. {
  1971. int i;
  1972. int town;
  1973. char map_name[MAP_NAME_LENGTH];
  1974. int m;
  1975. const struct {
  1976. char map[MAP_NAME_LENGTH];
  1977. int x, y;
  1978. } data[] = {
  1979. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1980. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1981. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1982. { MAP_PAYON, 162, 233 }, // 3=Payon
  1983. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1984. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1985. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1986. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1987. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1988. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1989. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1990. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1991. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1992. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1993. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1994. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1995. { MAP_JAIL, 23, 61 }, // 16=Prison
  1996. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1997. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1998. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1999. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2000. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2001. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2002. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2003. { MAP_VEINS, 216, 123 }, // 24=Veins
  2004. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  2005. { MAP_BRASILIS, 182, 239 }, // 26=Brasilis
  2006. { MAP_MANUK, 282, 138 }, // 27=Manuk
  2007. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  2008. };
  2009. nullpo_retr(-1, sd);
  2010. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  2011. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2012. return 0;
  2013. }
  2014. memset(map_name, '\0', sizeof(map_name));
  2015. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2016. // get the number
  2017. town = atoi(message);
  2018. // if no value, display all value
  2019. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  2020. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  2021. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  2022. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2023. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2024. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2025. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  2026. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  2027. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2028. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2029. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2030. clif_displaymessage(fd, " 24=Veins 25=Moscovia 26=Brasilis");
  2031. clif_displaymessage(fd, " 27=Manuk 28=Splendide");
  2032. return -1;
  2033. }
  2034. // get possible name of the city
  2035. map_name[MAP_NAME_LENGTH-1] = '\0';
  2036. for (i = 0; map_name[i]; i++)
  2037. map_name[i] = TOLOWER(map_name[i]);
  2038. // try to identify the map name
  2039. if (strncmp(map_name, "prontera", 3) == 0) {
  2040. town = 0;
  2041. } else if (strncmp(map_name, "morocc", 3) == 0) {
  2042. town = 1;
  2043. } else if (strncmp(map_name, "geffen", 3) == 0) {
  2044. town = 2;
  2045. } else if (strncmp(map_name, "payon", 3) == 0 ||
  2046. strncmp(map_name, "paion", 3) == 0) {
  2047. town = 3;
  2048. } else if (strncmp(map_name, "alberta", 3) == 0) {
  2049. town = 4;
  2050. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  2051. strncmp(map_name, "islude", 3) == 0) {
  2052. town = 5;
  2053. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2054. strcmp(map_name, "al") == 0) {
  2055. town = 6;
  2056. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  2057. strcmp(map_name, "christmas") == 0 ||
  2058. strncmp(map_name, "xmas", 3) == 0 ||
  2059. strncmp(map_name, "x-mas", 3) == 0) {
  2060. town = 7;
  2061. } else if (strncmp(map_name, "comodo", 3) == 0) {
  2062. town = 8;
  2063. } else if (strncmp(map_name, "yuno", 3) == 0) {
  2064. town = 9;
  2065. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  2066. town = 10;
  2067. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  2068. town = 11;
  2069. } else if (strncmp(map_name, "umbala", 3) == 0) {
  2070. town = 12;
  2071. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  2072. town = 13;
  2073. } else if (strncmp(map_name, "louyang", 3) == 0) {
  2074. town = 14;
  2075. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  2076. strncmp(map_name, "startpoint", 3) == 0 ||
  2077. strncmp(map_name, "begining", 3) == 0) {
  2078. town = 15;
  2079. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2080. strncmp(map_name, "prison", 3) == 0 ||
  2081. strncmp(map_name, "jails", 3) == 0) {
  2082. town = 16;
  2083. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2084. strncmp(map_name, "jawai", 3) == 0) {
  2085. town = 17;
  2086. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2087. strncmp(map_name, "ayotaya", 3) == 0) {
  2088. town = 18;
  2089. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2090. strncmp(map_name, "ainbroch", 5) == 0) {
  2091. town = 19;
  2092. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2093. town = 20;
  2094. } else if (strncmp(map_name, "einbech", 3) == 0) {
  2095. town = 21;
  2096. } else if (strncmp(map_name, "hugel", 3) == 0) {
  2097. town = 22;
  2098. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2099. town = 23;
  2100. } else if (strncmp(map_name, "veins", 3) == 0) {
  2101. town = 24;
  2102. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  2103. town = 25;
  2104. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  2105. town = 26;
  2106. } else if (strncmp(map_name, "manuk", 3) == 0) {
  2107. town = 27;
  2108. } else if (strncmp(map_name, "splendide", 3) == 0) {
  2109. town = 28;
  2110. }
  2111. if (town >= 0 && town < ARRAYLENGTH(data))
  2112. {
  2113. m = map_mapname2mapid(data[town].map);
  2114. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2115. clif_displaymessage(fd, msg_txt(247));
  2116. return -1;
  2117. }
  2118. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2119. clif_displaymessage(fd, msg_txt(248));
  2120. return -1;
  2121. }
  2122. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  2123. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2124. } else {
  2125. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2126. return -1;
  2127. }
  2128. } else { // if you arrive here, you have an error in town variable when reading of names
  2129. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2130. return -1;
  2131. }
  2132. return 0;
  2133. }
  2134. /*==========================================
  2135. *
  2136. *------------------------------------------*/
  2137. ACMD_FUNC(monster)
  2138. {
  2139. char name[NAME_LENGTH];
  2140. char monster[NAME_LENGTH];
  2141. int mob_id;
  2142. int number = 0;
  2143. int count;
  2144. int i, k, range;
  2145. short mx, my;
  2146. nullpo_retr(-1, sd);
  2147. memset(name, '\0', sizeof(name));
  2148. memset(monster, '\0', sizeof(monster));
  2149. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2150. if (!message || !*message) {
  2151. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2152. return -1;
  2153. }
  2154. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2155. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2156. //All data can be left as it is.
  2157. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2158. //Here, it is possible name was not given and we are using monster for it.
  2159. if (count < 3) //Blank mob's name.
  2160. name[0] = '\0';
  2161. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2162. //All data can be left as it is.
  2163. } else if (sscanf(message, "%23s", monster) > 0) {
  2164. //As before, name may be already filled.
  2165. name[0] = '\0';
  2166. } else {
  2167. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2168. return -1;
  2169. }
  2170. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2171. mob_id = mobdb_checkid(atoi(monster));
  2172. if (mob_id == 0) {
  2173. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2174. return -1;
  2175. }
  2176. if (mob_id == MOBID_EMPERIUM) {
  2177. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2178. return -1;
  2179. }
  2180. if (number <= 0)
  2181. number = 1;
  2182. if( !name[0] )
  2183. strcpy(name, "--ja--");
  2184. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  2185. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2186. number = battle_config.atc_spawn_quantity_limit;
  2187. if (battle_config.etc_log)
  2188. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
  2189. count = 0;
  2190. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2191. for (i = 0; i < number; i++) {
  2192. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2193. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2194. count += (k != 0) ? 1 : 0;
  2195. }
  2196. if (count != 0)
  2197. if (number == count)
  2198. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2199. else {
  2200. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2201. clif_displaymessage(fd, atcmd_output);
  2202. }
  2203. else {
  2204. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2205. return -1;
  2206. }
  2207. return 0;
  2208. }
  2209. // small monster spawning [Valaris]
  2210. ACMD_FUNC(monstersmall)
  2211. {
  2212. char name[NAME_LENGTH] = "";
  2213. char monster[NAME_LENGTH] = "";
  2214. int mob_id = 0;
  2215. int number = 0;
  2216. int x = 0;
  2217. int y = 0;
  2218. int count;
  2219. int i;
  2220. nullpo_retr(-1, sd);
  2221. if (!message || !*message) {
  2222. clif_displaymessage(fd, "Give a monster name/id please.");
  2223. return -1;
  2224. }
  2225. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2226. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2227. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2228. clif_displaymessage(fd, "Give a monster name/id please.");
  2229. return -1;
  2230. }
  2231. // If monster identifier/name argument is a name
  2232. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2233. mob_id = atoi(monster);
  2234. if (mob_id == 0) {
  2235. clif_displaymessage(fd, msg_txt(40));
  2236. return -1;
  2237. }
  2238. if (mob_id == MOBID_EMPERIUM) {
  2239. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2240. return -1;
  2241. }
  2242. if (mobdb_checkid(mob_id) == 0) {
  2243. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2244. return -1;
  2245. }
  2246. if (number <= 0)
  2247. number = 1;
  2248. if( !name[0] )
  2249. strcpy(name, "--ja--");
  2250. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  2251. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2252. number = battle_config.atc_spawn_quantity_limit;
  2253. count = 0;
  2254. for (i = 0; i < number; i++) {
  2255. int mx, my;
  2256. if (x <= 0)
  2257. mx = sd->bl.x + (rand() % 11 - 5);
  2258. else
  2259. mx = x;
  2260. if (y <= 0)
  2261. my = sd->bl.y + (rand() % 11 - 5);
  2262. else
  2263. my = y;
  2264. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2265. }
  2266. if (count != 0)
  2267. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2268. else
  2269. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2270. return 0;
  2271. }
  2272. // big monster spawning [Valaris]
  2273. ACMD_FUNC(monsterbig)
  2274. {
  2275. char name[NAME_LENGTH] = "";
  2276. char monster[NAME_LENGTH] = "";
  2277. int mob_id = 0;
  2278. int number = 0;
  2279. int x = 0;
  2280. int y = 0;
  2281. int count;
  2282. int i;
  2283. nullpo_retr(-1, sd);
  2284. if (!message || !*message) {
  2285. clif_displaymessage(fd, "Give a monster name/id please.");
  2286. return -1;
  2287. }
  2288. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2289. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2290. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2291. clif_displaymessage(fd, "Give a monster name/id please.");
  2292. return -1;
  2293. }
  2294. // If monster identifier/name argument is a name
  2295. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2296. mob_id = atoi(monster);
  2297. if (mob_id == 0) {
  2298. clif_displaymessage(fd, msg_txt(40));
  2299. return -1;
  2300. }
  2301. if (mob_id == MOBID_EMPERIUM) {
  2302. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2303. return -1;
  2304. }
  2305. if (mobdb_checkid(mob_id) == 0) {
  2306. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2307. return -1;
  2308. }
  2309. if (number <= 0)
  2310. number = 1;
  2311. if( !name[0] )
  2312. strcpy(name, "--ja--");
  2313. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  2314. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2315. number = battle_config.atc_spawn_quantity_limit;
  2316. count = 0;
  2317. for (i = 0; i < number; i++) {
  2318. int mx, my;
  2319. if (x <= 0)
  2320. mx = sd->bl.x + (rand() % 11 - 5);
  2321. else
  2322. mx = x;
  2323. if (y <= 0)
  2324. my = sd->bl.y + (rand() % 11 - 5);
  2325. else
  2326. my = y;
  2327. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2328. }
  2329. if (count != 0)
  2330. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2331. else
  2332. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2333. return 0;
  2334. }
  2335. /*==========================================
  2336. *
  2337. *------------------------------------------*/
  2338. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2339. {
  2340. struct mob_data *md;
  2341. int flag;
  2342. nullpo_ret(md=(struct mob_data *)bl);
  2343. flag = va_arg(ap, int);
  2344. if (md->guardian_data)
  2345. return 0; //Do not touch WoE mobs!
  2346. if (flag)
  2347. status_zap(bl,md->status.hp, 0);
  2348. else
  2349. status_kill(bl);
  2350. return 1;
  2351. }
  2352. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2353. {
  2354. int map_id;
  2355. char map_name[MAP_NAME_LENGTH_EXT];
  2356. if (!sd) return;
  2357. memset(map_name, '\0', sizeof(map_name));
  2358. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2359. map_id = sd->bl.m;
  2360. else {
  2361. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2362. map_id = sd->bl.m;
  2363. }
  2364. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2365. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2366. return;
  2367. }
  2368. ACMD_FUNC(killmonster)
  2369. {
  2370. atcommand_killmonster_sub(fd, sd, message, 1);
  2371. return 0;
  2372. }
  2373. /*==========================================
  2374. *
  2375. *------------------------------------------*/
  2376. ACMD_FUNC(killmonster2)
  2377. {
  2378. atcommand_killmonster_sub(fd, sd, message, 0);
  2379. return 0;
  2380. }
  2381. /*==========================================
  2382. *
  2383. *------------------------------------------*/
  2384. ACMD_FUNC(refine)
  2385. {
  2386. int i,j, position = 0, refine = 0, current_position, final_refine;
  2387. int count;
  2388. nullpo_retr(-1, sd);
  2389. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2390. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2391. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2392. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2393. clif_displaymessage(fd, atcmd_output);
  2394. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2395. clif_displaymessage(fd, atcmd_output);
  2396. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2397. clif_displaymessage(fd, atcmd_output);
  2398. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2399. clif_displaymessage(fd, atcmd_output);
  2400. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2401. clif_displaymessage(fd, atcmd_output);
  2402. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2403. clif_displaymessage(fd, atcmd_output);
  2404. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2405. clif_displaymessage(fd, atcmd_output);
  2406. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2407. clif_displaymessage(fd, atcmd_output);
  2408. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2409. clif_displaymessage(fd, atcmd_output);
  2410. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2411. clif_displaymessage(fd, atcmd_output);
  2412. return -1;
  2413. }
  2414. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2415. count = 0;
  2416. for (j = 0; j < EQI_MAX-1; j++) {
  2417. if ((i = sd->equip_index[j]) < 0)
  2418. continue;
  2419. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2420. continue;
  2421. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2422. continue;
  2423. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2424. continue;
  2425. if(position && !(sd->status.inventory[i].equip & position))
  2426. continue;
  2427. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2428. if (sd->status.inventory[i].refine != final_refine) {
  2429. sd->status.inventory[i].refine = final_refine;
  2430. current_position = sd->status.inventory[i].equip;
  2431. pc_unequipitem(sd, i, 3);
  2432. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2433. clif_delitem(sd, i, 1, 3);
  2434. clif_additem(sd, i, 1, 0);
  2435. pc_equipitem(sd, i, current_position);
  2436. clif_misceffect(&sd->bl, 3);
  2437. count++;
  2438. }
  2439. }
  2440. if (count == 0)
  2441. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2442. else if (count == 1)
  2443. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2444. else {
  2445. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2446. clif_displaymessage(fd, atcmd_output);
  2447. }
  2448. return 0;
  2449. }
  2450. /*==========================================
  2451. *
  2452. *------------------------------------------*/
  2453. ACMD_FUNC(produce)
  2454. {
  2455. char item_name[100];
  2456. int item_id, attribute = 0, star = 0;
  2457. int flag = 0;
  2458. struct item_data *item_data;
  2459. struct item tmp_item;
  2460. nullpo_retr(-1, sd);
  2461. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2462. memset(item_name, '\0', sizeof(item_name));
  2463. if (!message || !*message || (
  2464. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2465. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2466. )) {
  2467. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2468. return -1;
  2469. }
  2470. item_id = 0;
  2471. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2472. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2473. {
  2474. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2475. return -1;
  2476. }
  2477. item_id = item_data->nameid;
  2478. if (itemdb_isequip2(item_data)) {
  2479. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2480. attribute = ATTRIBUTE_NORMAL;
  2481. if (star < MIN_STAR || star > MAX_STAR)
  2482. star = 0;
  2483. memset(&tmp_item, 0, sizeof tmp_item);
  2484. tmp_item.nameid = item_id;
  2485. tmp_item.amount = 1;
  2486. tmp_item.identify = 1;
  2487. tmp_item.card[0] = CARD0_FORGE;
  2488. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2489. ((star*5) << 8) + attribute:0;
  2490. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2491. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2492. clif_produceeffect(sd, 0, item_id);
  2493. clif_misceffect(&sd->bl, 3);
  2494. //Logs (A)dmins items [Lupus]
  2495. log_pick_pc(sd, LOG_TYPE_COMMAND, tmp_item.nameid, 1, &tmp_item);
  2496. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2497. clif_additem(sd, 0, 0, flag);
  2498. } else {
  2499. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2500. clif_displaymessage(fd, atcmd_output);
  2501. return -1;
  2502. }
  2503. return 0;
  2504. }
  2505. /*==========================================
  2506. *
  2507. *------------------------------------------*/
  2508. ACMD_FUNC(memo)
  2509. {
  2510. int position = 0;
  2511. nullpo_retr(-1, sd);
  2512. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2513. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2514. {
  2515. int i;
  2516. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2517. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2518. {
  2519. if( sd->status.memo_point[i].map )
  2520. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  2521. else
  2522. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2523. clif_displaymessage(sd->fd, atcmd_output);
  2524. }
  2525. return 0;
  2526. }
  2527. if( position < 0 || position >= MAX_MEMOPOINTS )
  2528. {
  2529. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2530. clif_displaymessage(fd, atcmd_output);
  2531. return -1;
  2532. }
  2533. pc_memo(sd, position);
  2534. return 0;
  2535. }
  2536. /*==========================================
  2537. *
  2538. *------------------------------------------*/
  2539. ACMD_FUNC(gat)
  2540. {
  2541. int y;
  2542. nullpo_retr(-1, sd);
  2543. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2544. for (y = 2; y >= -2; y--) {
  2545. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2546. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2547. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2548. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2549. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2550. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2551. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2552. clif_displaymessage(fd, atcmd_output);
  2553. }
  2554. return 0;
  2555. }
  2556. /*==========================================
  2557. *
  2558. *------------------------------------------*/
  2559. ACMD_FUNC(displaystatus)
  2560. {
  2561. int i, type, flag, tick;
  2562. nullpo_retr(-1, sd);
  2563. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2564. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2565. return -1;
  2566. }
  2567. if (i < 2) flag = 1;
  2568. if (i < 3) tick = 0;
  2569. clif_status_change(&sd->bl, type, flag, tick, 0, 0, 0);
  2570. return 0;
  2571. }
  2572. /*==========================================
  2573. * @stpoint (Rewritten by [Yor])
  2574. *------------------------------------------*/
  2575. ACMD_FUNC(statuspoint)
  2576. {
  2577. int point;
  2578. unsigned int new_status_point;
  2579. if (!message || !*message || (point = atoi(message)) == 0) {
  2580. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2581. return -1;
  2582. }
  2583. if(point < 0)
  2584. {
  2585. if(sd->status.status_point < (unsigned int)(-point))
  2586. {
  2587. new_status_point = 0;
  2588. }
  2589. else
  2590. {
  2591. new_status_point = sd->status.status_point + point;
  2592. }
  2593. }
  2594. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2595. {
  2596. new_status_point = UINT_MAX;
  2597. }
  2598. else
  2599. {
  2600. new_status_point = sd->status.status_point + point;
  2601. }
  2602. if (new_status_point != sd->status.status_point) {
  2603. sd->status.status_point = new_status_point;
  2604. clif_updatestatus(sd, SP_STATUSPOINT);
  2605. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2606. } else {
  2607. if (point < 0)
  2608. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2609. else
  2610. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2611. return -1;
  2612. }
  2613. return 0;
  2614. }
  2615. /*==========================================
  2616. * @skpoint (Rewritten by [Yor])
  2617. *------------------------------------------*/
  2618. ACMD_FUNC(skillpoint)
  2619. {
  2620. int point;
  2621. unsigned int new_skill_point;
  2622. nullpo_retr(-1, sd);
  2623. if (!message || !*message || (point = atoi(message)) == 0) {
  2624. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2625. return -1;
  2626. }
  2627. if(point < 0)
  2628. {
  2629. if(sd->status.skill_point < (unsigned int)(-point))
  2630. {
  2631. new_skill_point = 0;
  2632. }
  2633. else
  2634. {
  2635. new_skill_point = sd->status.skill_point + point;
  2636. }
  2637. }
  2638. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2639. {
  2640. new_skill_point = UINT_MAX;
  2641. }
  2642. else
  2643. {
  2644. new_skill_point = sd->status.skill_point + point;
  2645. }
  2646. if (new_skill_point != sd->status.skill_point) {
  2647. sd->status.skill_point = new_skill_point;
  2648. clif_updatestatus(sd, SP_SKILLPOINT);
  2649. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2650. } else {
  2651. if (point < 0)
  2652. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2653. else
  2654. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2655. return -1;
  2656. }
  2657. return 0;
  2658. }
  2659. /*==========================================
  2660. * @zeny (Rewritten by [Yor])
  2661. *------------------------------------------*/
  2662. ACMD_FUNC(zeny)
  2663. {
  2664. int zeny, new_zeny;
  2665. nullpo_retr(-1, sd);
  2666. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2667. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2668. return -1;
  2669. }
  2670. new_zeny = sd->status.zeny + zeny;
  2671. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2672. new_zeny = MAX_ZENY;
  2673. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2674. new_zeny = 0;
  2675. if (new_zeny != sd->status.zeny) {
  2676. sd->status.zeny = new_zeny;
  2677. clif_updatestatus(sd, SP_ZENY);
  2678. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2679. } else {
  2680. if (zeny < 0)
  2681. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2682. else
  2683. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2684. return -1;
  2685. }
  2686. return 0;
  2687. }
  2688. /*==========================================
  2689. *
  2690. *------------------------------------------*/
  2691. ACMD_FUNC(param)
  2692. {
  2693. int i, value = 0, new_value, max;
  2694. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2695. short* status[6];
  2696. //we don't use direct initialization because it isn't part of the c standard.
  2697. nullpo_retr(-1, sd);
  2698. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2699. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2700. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2701. clif_displaymessage(fd, atcmd_output);
  2702. return -1;
  2703. }
  2704. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2705. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2706. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2707. clif_displaymessage(fd, atcmd_output);
  2708. return -1;
  2709. }
  2710. status[0] = &sd->status.str;
  2711. status[1] = &sd->status.agi;
  2712. status[2] = &sd->status.vit;
  2713. status[3] = &sd->status.int_;
  2714. status[4] = &sd->status.dex;
  2715. status[5] = &sd->status.luk;
  2716. if( battle_config.atcommand_max_stat_bypass )
  2717. max = SHRT_MAX;
  2718. else
  2719. max = pc_maxparameter(sd);
  2720. if(value < 0 && *status[i] <= -value) {
  2721. new_value = 1;
  2722. } else if(max - *status[i] < value) {
  2723. new_value = max;
  2724. } else {
  2725. new_value = *status[i] + value;
  2726. }
  2727. if (new_value != *status[i]) {
  2728. *status[i] = new_value;
  2729. clif_updatestatus(sd, SP_STR + i);
  2730. clif_updatestatus(sd, SP_USTR + i);
  2731. status_calc_pc(sd, 0);
  2732. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2733. } else {
  2734. if (value < 0)
  2735. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2736. else
  2737. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2738. return -1;
  2739. }
  2740. return 0;
  2741. }
  2742. /*==========================================
  2743. * Stat all by fritz (rewritten by [Yor])
  2744. *------------------------------------------*/
  2745. ACMD_FUNC(stat_all)
  2746. {
  2747. int index, count, value, max, new_value;
  2748. short* status[6];
  2749. //we don't use direct initialization because it isn't part of the c standard.
  2750. nullpo_retr(-1, sd);
  2751. status[0] = &sd->status.str;
  2752. status[1] = &sd->status.agi;
  2753. status[2] = &sd->status.vit;
  2754. status[3] = &sd->status.int_;
  2755. status[4] = &sd->status.dex;
  2756. status[5] = &sd->status.luk;
  2757. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2758. value = pc_maxparameter(sd);
  2759. max = pc_maxparameter(sd);
  2760. } else {
  2761. if( battle_config.atcommand_max_stat_bypass )
  2762. max = SHRT_MAX;
  2763. else
  2764. max = pc_maxparameter(sd);
  2765. }
  2766. count = 0;
  2767. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2768. if (value > 0 && *status[index] > max - value)
  2769. new_value = max;
  2770. else if (value < 0 && *status[index] <= -value)
  2771. new_value = 1;
  2772. else
  2773. new_value = *status[index] +value;
  2774. if (new_value != (int)*status[index]) {
  2775. *status[index] = new_value;
  2776. clif_updatestatus(sd, SP_STR + index);
  2777. clif_updatestatus(sd, SP_USTR + index);
  2778. count++;
  2779. }
  2780. }
  2781. if (count > 0) { // if at least 1 stat modified
  2782. status_calc_pc(sd, 0);
  2783. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2784. } else {
  2785. if (value < 0)
  2786. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2787. else
  2788. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2789. return -1;
  2790. }
  2791. return 0;
  2792. }
  2793. /*==========================================
  2794. *
  2795. *------------------------------------------*/
  2796. ACMD_FUNC(guildlevelup)
  2797. {
  2798. int level = 0;
  2799. short added_level;
  2800. struct guild *guild_info;
  2801. nullpo_retr(-1, sd);
  2802. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2803. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2804. return -1;
  2805. }
  2806. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2807. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2808. return -1;
  2809. }
  2810. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2811. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2812. // return -1;
  2813. //}
  2814. added_level = (short)level;
  2815. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2816. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2817. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2818. added_level = 1 - guild_info->guild_lv;
  2819. if (added_level != 0) {
  2820. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2821. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2822. } else {
  2823. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2824. return -1;
  2825. }
  2826. return 0;
  2827. }
  2828. /*==========================================
  2829. *
  2830. *------------------------------------------*/
  2831. ACMD_FUNC(makeegg)
  2832. {
  2833. struct item_data *item_data;
  2834. int id, pet_id;
  2835. nullpo_retr(-1, sd);
  2836. if (!message || !*message) {
  2837. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2838. return -1;
  2839. }
  2840. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2841. id = item_data->nameid;
  2842. else
  2843. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2844. ;
  2845. else
  2846. id = atoi(message);
  2847. pet_id = search_petDB_index(id, PET_CLASS);
  2848. if (pet_id < 0)
  2849. pet_id = search_petDB_index(id, PET_EGG);
  2850. if (pet_id >= 0) {
  2851. sd->catch_target_class = pet_db[pet_id].class_;
  2852. intif_create_pet(
  2853. sd->status.account_id, sd->status.char_id,
  2854. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2855. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2856. 100, 0, 1, pet_db[pet_id].jname);
  2857. } else {
  2858. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2859. return -1;
  2860. }
  2861. return 0;
  2862. }
  2863. /*==========================================
  2864. *
  2865. *------------------------------------------*/
  2866. ACMD_FUNC(hatch)
  2867. {
  2868. nullpo_retr(-1, sd);
  2869. if (sd->status.pet_id <= 0)
  2870. clif_sendegg(sd);
  2871. else {
  2872. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2873. return -1;
  2874. }
  2875. return 0;
  2876. }
  2877. /*==========================================
  2878. *
  2879. *------------------------------------------*/
  2880. ACMD_FUNC(petfriendly)
  2881. {
  2882. int friendly;
  2883. struct pet_data *pd;
  2884. nullpo_retr(-1, sd);
  2885. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2886. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2887. return -1;
  2888. }
  2889. pd = sd->pd;
  2890. if (!pd) {
  2891. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2892. return -1;
  2893. }
  2894. if (friendly < 0 || friendly > 1000)
  2895. {
  2896. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2897. return -1;
  2898. }
  2899. if (friendly == pd->pet.intimate) {
  2900. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2901. return -1;
  2902. }
  2903. pet_set_intimate(pd, friendly);
  2904. clif_send_petstatus(sd);
  2905. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2906. return 0;
  2907. }
  2908. /*==========================================
  2909. *
  2910. *------------------------------------------*/
  2911. ACMD_FUNC(pethungry)
  2912. {
  2913. int hungry;
  2914. struct pet_data *pd;
  2915. nullpo_retr(-1, sd);
  2916. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2917. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2918. return -1;
  2919. }
  2920. pd = sd->pd;
  2921. if (!sd->status.pet_id || !pd) {
  2922. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2923. return -1;
  2924. }
  2925. if (hungry < 0 || hungry > 100) {
  2926. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2927. return -1;
  2928. }
  2929. if (hungry == pd->pet.hungry) {
  2930. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2931. return -1;
  2932. }
  2933. pd->pet.hungry = hungry;
  2934. clif_send_petstatus(sd);
  2935. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2936. return 0;
  2937. }
  2938. /*==========================================
  2939. *
  2940. *------------------------------------------*/
  2941. ACMD_FUNC(petrename)
  2942. {
  2943. struct pet_data *pd;
  2944. nullpo_retr(-1, sd);
  2945. if (!sd->status.pet_id || !sd->pd) {
  2946. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2947. return -1;
  2948. }
  2949. pd = sd->pd;
  2950. if (!pd->pet.rename_flag) {
  2951. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2952. return -1;
  2953. }
  2954. pd->pet.rename_flag = 0;
  2955. intif_save_petdata(sd->status.account_id, &pd->pet);
  2956. clif_send_petstatus(sd);
  2957. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2958. return 0;
  2959. }
  2960. /*==========================================
  2961. *
  2962. *------------------------------------------*/
  2963. ACMD_FUNC(recall)
  2964. {
  2965. struct map_session_data *pl_sd = NULL;
  2966. nullpo_retr(-1, sd);
  2967. if (!message || !*message) {
  2968. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2969. return -1;
  2970. }
  2971. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2972. {
  2973. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2974. return -1;
  2975. }
  2976. if (pl_sd == sd)
  2977. {
  2978. clif_displaymessage(fd, "You are already where you are...");
  2979. return -1;
  2980. }
  2981. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2982. {
  2983. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2984. return -1;
  2985. }
  2986. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2987. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  2988. return -1;
  2989. }
  2990. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2991. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2992. return -1;
  2993. }
  2994. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2995. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2996. clif_displaymessage(fd, atcmd_output);
  2997. return 0;
  2998. }
  2999. /*==========================================
  3000. * charblock command (usage: charblock <player_name>)
  3001. * This command do a definitiv ban on a player
  3002. *------------------------------------------*/
  3003. ACMD_FUNC(char_block)
  3004. {
  3005. nullpo_retr(-1, sd);
  3006. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3007. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3008. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3009. return -1;
  3010. }
  3011. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3012. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3013. return 0;
  3014. }
  3015. /*==========================================
  3016. * charban command (usage: charban <time> <player_name>)
  3017. * This command do a limited ban on a player
  3018. * Time is done as follows:
  3019. * Adjustment value (-1, 1, +1, etc...)
  3020. * Modified element:
  3021. * a or y: year
  3022. * m: month
  3023. * j or d: day
  3024. * h: hour
  3025. * mn: minute
  3026. * s: second
  3027. * <example> @ban +1m-2mn1s-6y test_player
  3028. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3029. *------------------------------------------*/
  3030. ACMD_FUNC(char_ban)
  3031. {
  3032. char * modif_p;
  3033. int year, month, day, hour, minute, second, value;
  3034. nullpo_retr(-1, sd);
  3035. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3036. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3037. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3038. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3039. return -1;
  3040. }
  3041. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3042. modif_p = atcmd_output;
  3043. year = month = day = hour = minute = second = 0;
  3044. while (modif_p[0] != '\0') {
  3045. value = atoi(modif_p);
  3046. if (value == 0)
  3047. modif_p++;
  3048. else {
  3049. if (modif_p[0] == '-' || modif_p[0] == '+')
  3050. modif_p++;
  3051. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3052. modif_p++;
  3053. if (modif_p[0] == 's') {
  3054. second = value;
  3055. modif_p++;
  3056. } else if (modif_p[0] == 'n') {
  3057. minute = value;
  3058. modif_p++;
  3059. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3060. minute = value;
  3061. modif_p = modif_p + 2;
  3062. } else if (modif_p[0] == 'h') {
  3063. hour = value;
  3064. modif_p++;
  3065. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3066. day = value;
  3067. modif_p++;
  3068. } else if (modif_p[0] == 'm') {
  3069. month = value;
  3070. modif_p++;
  3071. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3072. year = value;
  3073. modif_p++;
  3074. } else if (modif_p[0] != '\0') {
  3075. modif_p++;
  3076. }
  3077. }
  3078. }
  3079. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3080. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3081. return -1;
  3082. }
  3083. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3084. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3085. return 0;
  3086. }
  3087. /*==========================================
  3088. * charunblock command (usage: charunblock <player_name>)
  3089. *------------------------------------------*/
  3090. ACMD_FUNC(char_unblock)
  3091. {
  3092. nullpo_retr(-1, sd);
  3093. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3094. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3095. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3096. return -1;
  3097. }
  3098. // send answer to login server via char-server
  3099. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3100. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3101. return 0;
  3102. }
  3103. /*==========================================
  3104. * charunban command (usage: charunban <player_name>)
  3105. *------------------------------------------*/
  3106. ACMD_FUNC(char_unban)
  3107. {
  3108. nullpo_retr(-1, sd);
  3109. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3110. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3111. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3112. return -1;
  3113. }
  3114. // send answer to login server via char-server
  3115. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3116. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3117. return 0;
  3118. }
  3119. /*==========================================
  3120. *
  3121. *------------------------------------------*/
  3122. ACMD_FUNC(night)
  3123. {
  3124. nullpo_retr(-1, sd);
  3125. if (night_flag != 1) {
  3126. map_night_timer(night_timer_tid, 0, 0, 1);
  3127. } else {
  3128. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  3129. return -1;
  3130. }
  3131. return 0;
  3132. }
  3133. /*==========================================
  3134. *
  3135. *------------------------------------------*/
  3136. ACMD_FUNC(day)
  3137. {
  3138. nullpo_retr(-1, sd);
  3139. if (night_flag != 0) {
  3140. map_day_timer(day_timer_tid, 0, 0, 1);
  3141. } else {
  3142. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  3143. return -1;
  3144. }
  3145. return 0;
  3146. }
  3147. /*==========================================
  3148. *
  3149. *------------------------------------------*/
  3150. ACMD_FUNC(doom)
  3151. {
  3152. struct map_session_data* pl_sd;
  3153. struct s_mapiterator* iter;
  3154. nullpo_retr(-1, sd);
  3155. iter = mapit_getallusers();
  3156. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3157. {
  3158. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3159. {
  3160. status_kill(&pl_sd->bl);
  3161. clif_specialeffect(&pl_sd->bl,450,AREA);
  3162. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3163. }
  3164. }
  3165. mapit_free(iter);
  3166. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3167. return 0;
  3168. }
  3169. /*==========================================
  3170. *
  3171. *------------------------------------------*/
  3172. ACMD_FUNC(doommap)
  3173. {
  3174. struct map_session_data* pl_sd;
  3175. struct s_mapiterator* iter;
  3176. nullpo_retr(-1, sd);
  3177. iter = mapit_getallusers();
  3178. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3179. {
  3180. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3181. {
  3182. status_kill(&pl_sd->bl);
  3183. clif_specialeffect(&pl_sd->bl,450,AREA);
  3184. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3185. }
  3186. }
  3187. mapit_free(iter);
  3188. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3189. return 0;
  3190. }
  3191. /*==========================================
  3192. *
  3193. *------------------------------------------*/
  3194. static void atcommand_raise_sub(struct map_session_data* sd)
  3195. {
  3196. if (!status_isdead(&sd->bl))
  3197. return;
  3198. if(!status_revive(&sd->bl, 100, 100))
  3199. return;
  3200. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3201. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3202. }
  3203. /*==========================================
  3204. *
  3205. *------------------------------------------*/
  3206. ACMD_FUNC(raise)
  3207. {
  3208. struct map_session_data* pl_sd;
  3209. struct s_mapiterator* iter;
  3210. nullpo_retr(-1, sd);
  3211. iter = mapit_getallusers();
  3212. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3213. atcommand_raise_sub(pl_sd);
  3214. mapit_free(iter);
  3215. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3216. return 0;
  3217. }
  3218. /*==========================================
  3219. *
  3220. *------------------------------------------*/
  3221. ACMD_FUNC(raisemap)
  3222. {
  3223. struct map_session_data* pl_sd;
  3224. struct s_mapiterator* iter;
  3225. nullpo_retr(-1, sd);
  3226. iter = mapit_getallusers();
  3227. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3228. if (sd->bl.m == pl_sd->bl.m)
  3229. atcommand_raise_sub(pl_sd);
  3230. mapit_free(iter);
  3231. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3232. return 0;
  3233. }
  3234. /*==========================================
  3235. *
  3236. *------------------------------------------*/
  3237. ACMD_FUNC(kick)
  3238. {
  3239. struct map_session_data *pl_sd;
  3240. nullpo_retr(-1, sd);
  3241. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3242. if (!message || !*message) {
  3243. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3244. return -1;
  3245. }
  3246. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3247. {
  3248. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3249. return -1;
  3250. }
  3251. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3252. {
  3253. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3254. return -1;
  3255. }
  3256. clif_GM_kick(sd, pl_sd);
  3257. return 0;
  3258. }
  3259. /*==========================================
  3260. *
  3261. *------------------------------------------*/
  3262. ACMD_FUNC(kickall)
  3263. {
  3264. struct map_session_data* pl_sd;
  3265. struct s_mapiterator* iter;
  3266. nullpo_retr(-1, sd);
  3267. iter = mapit_getallusers();
  3268. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3269. {
  3270. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3271. if (sd->status.account_id != pl_sd->status.account_id)
  3272. clif_GM_kick(NULL, pl_sd);
  3273. }
  3274. }
  3275. mapit_free(iter);
  3276. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3277. return 0;
  3278. }
  3279. /*==========================================
  3280. *
  3281. *------------------------------------------*/
  3282. ACMD_FUNC(allskill)
  3283. {
  3284. nullpo_retr(-1, sd);
  3285. pc_allskillup(sd); // all skills
  3286. sd->status.skill_point = 0; // 0 skill points
  3287. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3288. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3289. return 0;
  3290. }
  3291. /*==========================================
  3292. *
  3293. *------------------------------------------*/
  3294. ACMD_FUNC(questskill)
  3295. {
  3296. int skill_id;
  3297. nullpo_retr(-1, sd);
  3298. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3299. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3300. return -1;
  3301. }
  3302. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3303. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3304. return -1;
  3305. }
  3306. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3307. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3308. return -1;
  3309. }
  3310. if (pc_checkskill(sd, skill_id) > 0) {
  3311. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3312. return -1;
  3313. }
  3314. pc_skill(sd, skill_id, 1, 0);
  3315. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3316. return 0;
  3317. }
  3318. /*==========================================
  3319. *
  3320. *------------------------------------------*/
  3321. ACMD_FUNC(lostskill)
  3322. {
  3323. int skill_id;
  3324. nullpo_retr(-1, sd);
  3325. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3326. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3327. return -1;
  3328. }
  3329. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3330. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3331. return -1;
  3332. }
  3333. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3334. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3335. return -1;
  3336. }
  3337. if (pc_checkskill(sd, skill_id) == 0) {
  3338. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3339. return -1;
  3340. }
  3341. sd->status.skill[skill_id].lv = 0;
  3342. sd->status.skill[skill_id].flag = 0;
  3343. clif_deleteskill(sd,skill_id);
  3344. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3345. return 0;
  3346. }
  3347. /*==========================================
  3348. *
  3349. *------------------------------------------*/
  3350. ACMD_FUNC(spiritball)
  3351. {
  3352. int max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3353. int number;
  3354. nullpo_retr(-1, sd);
  3355. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3356. {
  3357. char msg[CHAT_SIZE_MAX];
  3358. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3359. clif_displaymessage(fd, msg);
  3360. return -1;
  3361. }
  3362. if( sd->spiritball > 0 )
  3363. pc_delspiritball(sd, sd->spiritball, 1);
  3364. sd->spiritball = number;
  3365. clif_spiritball(sd);
  3366. // no message, player can look the difference
  3367. return 0;
  3368. }
  3369. /*==========================================
  3370. *
  3371. *------------------------------------------*/
  3372. ACMD_FUNC(party)
  3373. {
  3374. char party[NAME_LENGTH];
  3375. nullpo_retr(-1, sd);
  3376. memset(party, '\0', sizeof(party));
  3377. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3378. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3379. return -1;
  3380. }
  3381. party_create(sd, party, 0, 0);
  3382. return 0;
  3383. }
  3384. /*==========================================
  3385. *
  3386. *------------------------------------------*/
  3387. ACMD_FUNC(guild)
  3388. {
  3389. char guild[NAME_LENGTH];
  3390. int prev;
  3391. nullpo_retr(-1, sd);
  3392. memset(guild, '\0', sizeof(guild));
  3393. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3394. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3395. return -1;
  3396. }
  3397. prev = battle_config.guild_emperium_check;
  3398. battle_config.guild_emperium_check = 0;
  3399. guild_create(sd, guild);
  3400. battle_config.guild_emperium_check = prev;
  3401. return 0;
  3402. }
  3403. /*==========================================
  3404. *
  3405. *------------------------------------------*/
  3406. ACMD_FUNC(agitstart)
  3407. {
  3408. nullpo_retr(-1, sd);
  3409. if (agit_flag == 1) {
  3410. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3411. return -1;
  3412. }
  3413. agit_flag = 1;
  3414. guild_agit_start();
  3415. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3416. return 0;
  3417. }
  3418. /*==========================================
  3419. *
  3420. *------------------------------------------*/
  3421. ACMD_FUNC(agitstart2)
  3422. {
  3423. nullpo_retr(-1, sd);
  3424. if (agit2_flag == 1) {
  3425. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3426. return -1;
  3427. }
  3428. agit2_flag = 1;
  3429. guild_agit2_start();
  3430. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3431. return 0;
  3432. }
  3433. /*==========================================
  3434. *
  3435. *------------------------------------------*/
  3436. ACMD_FUNC(agitend)
  3437. {
  3438. nullpo_retr(-1, sd);
  3439. if (agit_flag == 0) {
  3440. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3441. return -1;
  3442. }
  3443. agit_flag = 0;
  3444. guild_agit_end();
  3445. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3446. return 0;
  3447. }
  3448. /*==========================================
  3449. *
  3450. *------------------------------------------*/
  3451. ACMD_FUNC(agitend2)
  3452. {
  3453. nullpo_retr(-1, sd);
  3454. if (agit2_flag == 0) {
  3455. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3456. return -1;
  3457. }
  3458. agit2_flag = 0;
  3459. guild_agit2_end();
  3460. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3461. return 0;
  3462. }
  3463. /*==========================================
  3464. * @mapexit - shuts down the map server
  3465. *------------------------------------------*/
  3466. ACMD_FUNC(mapexit)
  3467. {
  3468. nullpo_retr(-1, sd);
  3469. do_shutdown();
  3470. return 0;
  3471. }
  3472. /*==========================================
  3473. * idsearch <part_of_name>: revrited by [Yor]
  3474. *------------------------------------------*/
  3475. ACMD_FUNC(idsearch)
  3476. {
  3477. char item_name[100];
  3478. unsigned int i, match;
  3479. struct item_data *item_array[MAX_SEARCH];
  3480. nullpo_retr(-1, sd);
  3481. memset(item_name, '\0', sizeof(item_name));
  3482. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3483. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3484. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3485. return -1;
  3486. }
  3487. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3488. clif_displaymessage(fd, atcmd_output);
  3489. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3490. if (match > MAX_SEARCH) {
  3491. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3492. clif_displaymessage(fd, atcmd_output);
  3493. match = MAX_SEARCH;
  3494. }
  3495. for(i = 0; i < match; i++) {
  3496. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3497. clif_displaymessage(fd, atcmd_output);
  3498. }
  3499. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3500. clif_displaymessage(fd, atcmd_output);
  3501. return 0;
  3502. }
  3503. /*==========================================
  3504. * Recall All Characters Online To Your Location
  3505. *------------------------------------------*/
  3506. ACMD_FUNC(recallall)
  3507. {
  3508. struct map_session_data* pl_sd;
  3509. struct s_mapiterator* iter;
  3510. int count;
  3511. nullpo_retr(-1, sd);
  3512. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3513. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3514. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3515. return -1;
  3516. }
  3517. count = 0;
  3518. iter = mapit_getallusers();
  3519. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3520. {
  3521. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3522. {
  3523. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3524. count++;
  3525. else {
  3526. if (pc_isdead(pl_sd)) { //Wake them up
  3527. pc_setstand(pl_sd);
  3528. pc_setrestartvalue(pl_sd,1);
  3529. }
  3530. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3531. }
  3532. }
  3533. }
  3534. mapit_free(iter);
  3535. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3536. if (count) {
  3537. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3538. clif_displaymessage(fd, atcmd_output);
  3539. }
  3540. return 0;
  3541. }
  3542. /*==========================================
  3543. * Recall online characters of a guild to your location
  3544. *------------------------------------------*/
  3545. ACMD_FUNC(guildrecall)
  3546. {
  3547. struct map_session_data* pl_sd;
  3548. struct s_mapiterator* iter;
  3549. int count;
  3550. char guild_name[NAME_LENGTH];
  3551. struct guild *g;
  3552. nullpo_retr(-1, sd);
  3553. memset(guild_name, '\0', sizeof(guild_name));
  3554. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3555. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3556. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3557. return -1;
  3558. }
  3559. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3560. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3561. return -1;
  3562. }
  3563. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3564. (g = guild_search(atoi(message))) == NULL)
  3565. {
  3566. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3567. return -1;
  3568. }
  3569. count = 0;
  3570. iter = mapit_getallusers();
  3571. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3572. {
  3573. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3574. {
  3575. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3576. continue; //Skip GMs greater than you.
  3577. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3578. count++;
  3579. else
  3580. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3581. }
  3582. }
  3583. mapit_free(iter);
  3584. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3585. clif_displaymessage(fd, atcmd_output);
  3586. if (count) {
  3587. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3588. clif_displaymessage(fd, atcmd_output);
  3589. }
  3590. return 0;
  3591. }
  3592. /*==========================================
  3593. * Recall online characters of a party to your location
  3594. *------------------------------------------*/
  3595. ACMD_FUNC(partyrecall)
  3596. {
  3597. struct map_session_data* pl_sd;
  3598. struct s_mapiterator* iter;
  3599. char party_name[NAME_LENGTH];
  3600. struct party_data *p;
  3601. int count;
  3602. nullpo_retr(-1, sd);
  3603. memset(party_name, '\0', sizeof(party_name));
  3604. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3605. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3606. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3607. return -1;
  3608. }
  3609. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3610. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3611. return -1;
  3612. }
  3613. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3614. (p = party_search(atoi(message))) == NULL)
  3615. {
  3616. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3617. return -1;
  3618. }
  3619. count = 0;
  3620. iter = mapit_getallusers();
  3621. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3622. {
  3623. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3624. {
  3625. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3626. continue; //Skip GMs greater than you.
  3627. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3628. count++;
  3629. else
  3630. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3631. }
  3632. }
  3633. mapit_free(iter);
  3634. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3635. clif_displaymessage(fd, atcmd_output);
  3636. if (count) {
  3637. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3638. clif_displaymessage(fd, atcmd_output);
  3639. }
  3640. return 0;
  3641. }
  3642. /*==========================================
  3643. *
  3644. *------------------------------------------*/
  3645. ACMD_FUNC(reloaditemdb)
  3646. {
  3647. nullpo_retr(-1, sd);
  3648. itemdb_reload();
  3649. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3650. return 0;
  3651. }
  3652. /*==========================================
  3653. *
  3654. *------------------------------------------*/
  3655. ACMD_FUNC(reloadmobdb)
  3656. {
  3657. nullpo_retr(-1, sd);
  3658. mob_reload();
  3659. read_petdb();
  3660. merc_reload();
  3661. read_mercenarydb();
  3662. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3663. return 0;
  3664. }
  3665. /*==========================================
  3666. *
  3667. *------------------------------------------*/
  3668. ACMD_FUNC(reloadskilldb)
  3669. {
  3670. nullpo_retr(-1, sd);
  3671. skill_reload();
  3672. merc_skill_reload();
  3673. read_mercenary_skilldb();
  3674. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3675. return 0;
  3676. }
  3677. /*==========================================
  3678. * @reloadatcommand - reloads atcommand_athena.conf
  3679. *------------------------------------------*/
  3680. ACMD_FUNC(reloadatcommand)
  3681. {
  3682. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  3683. clif_displaymessage(fd, msg_txt(254));
  3684. return 0;
  3685. }
  3686. /*==========================================
  3687. * @reloadbattleconf - reloads battle_athena.conf
  3688. *------------------------------------------*/
  3689. ACMD_FUNC(reloadbattleconf)
  3690. {
  3691. struct Battle_Config prev_config;
  3692. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3693. battle_config_read(BATTLE_CONF_FILENAME);
  3694. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3695. || prev_config.item_rate_common != battle_config.item_rate_common
  3696. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3697. || prev_config.item_rate_card != battle_config.item_rate_card
  3698. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3699. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3700. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3701. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3702. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3703. || prev_config.item_rate_use != battle_config.item_rate_use
  3704. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3705. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3706. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3707. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3708. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3709. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3710. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3711. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3712. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3713. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3714. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3715. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3716. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3717. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3718. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3719. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3720. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3721. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3722. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3723. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3724. )
  3725. { // Exp or Drop rates changed.
  3726. mob_reload(); //Needed as well so rate changes take effect.
  3727. #ifndef TXT_ONLY
  3728. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3729. #endif
  3730. }
  3731. clif_displaymessage(fd, msg_txt(255));
  3732. return 0;
  3733. }
  3734. /*==========================================
  3735. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3736. *------------------------------------------*/
  3737. ACMD_FUNC(reloadstatusdb)
  3738. {
  3739. status_readdb();
  3740. clif_displaymessage(fd, msg_txt(256));
  3741. return 0;
  3742. }
  3743. /*==========================================
  3744. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3745. *------------------------------------------*/
  3746. ACMD_FUNC(reloadpcdb)
  3747. {
  3748. pc_readdb();
  3749. clif_displaymessage(fd, msg_txt(257));
  3750. return 0;
  3751. }
  3752. /*==========================================
  3753. * @reloadmotd - reloads motd.txt
  3754. *------------------------------------------*/
  3755. ACMD_FUNC(reloadmotd)
  3756. {
  3757. pc_read_motd();
  3758. clif_displaymessage(fd, msg_txt(268));
  3759. return 0;
  3760. }
  3761. /*==========================================
  3762. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3763. *------------------------------------------*/
  3764. ACMD_FUNC(reloadscript)
  3765. {
  3766. nullpo_retr(-1, sd);
  3767. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3768. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3769. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3770. flush_fifos();
  3771. script_reload();
  3772. npc_reload();
  3773. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3774. return 0;
  3775. }
  3776. /*==========================================
  3777. * @mapinfo [0-3] <map name> by MC_Cameri
  3778. * => Shows information about the map [map name]
  3779. * 0 = no additional information
  3780. * 1 = Show users in that map and their location
  3781. * 2 = Shows NPCs in that map
  3782. * 3 = Shows the shops/chats in that map (not implemented)
  3783. *------------------------------------------*/
  3784. ACMD_FUNC(mapinfo)
  3785. {
  3786. struct map_session_data* pl_sd;
  3787. struct s_mapiterator* iter;
  3788. struct npc_data *nd = NULL;
  3789. struct chat_data *cd = NULL;
  3790. char direction[12];
  3791. int i, m_id, chat_num, list = 0;
  3792. unsigned short m_index;
  3793. char mapname[24];
  3794. nullpo_retr(-1, sd);
  3795. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3796. memset(mapname, '\0', sizeof(mapname));
  3797. memset(direction, '\0', sizeof(direction));
  3798. sscanf(message, "%d %23[^\n]", &list, mapname);
  3799. if (list < 0 || list > 3) {
  3800. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3801. return -1;
  3802. }
  3803. if (mapname[0] == '\0') {
  3804. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3805. m_id = map_mapindex2mapid(sd->mapindex);
  3806. } else {
  3807. m_id = map_mapname2mapid(mapname);
  3808. }
  3809. if (m_id < 0) {
  3810. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3811. return -1;
  3812. }
  3813. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3814. clif_displaymessage(fd, "------ Map Info ------");
  3815. // count chats (for initial message)
  3816. chat_num = 0;
  3817. iter = mapit_getallusers();
  3818. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3819. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3820. chat_num++;
  3821. mapit_free(iter);
  3822. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
  3823. clif_displaymessage(fd, atcmd_output);
  3824. clif_displaymessage(fd, "------ Map Flags ------");
  3825. if (map[m_id].flag.town)
  3826. clif_displaymessage(fd, "Town Map");
  3827. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3828. clif_displaymessage(fd, "Autotrade Enabled");
  3829. else
  3830. clif_displaymessage(fd, "Autotrade Disabled");
  3831. if (map[m_id].flag.battleground)
  3832. clif_displaymessage(fd, "Battlegrounds ON");
  3833. strcpy(atcmd_output,"PvP Flags: ");
  3834. if (map[m_id].flag.pvp)
  3835. strcat(atcmd_output, "Pvp ON | ");
  3836. if (map[m_id].flag.pvp_noguild)
  3837. strcat(atcmd_output, "NoGuild | ");
  3838. if (map[m_id].flag.pvp_noparty)
  3839. strcat(atcmd_output, "NoParty | ");
  3840. if (map[m_id].flag.pvp_nightmaredrop)
  3841. strcat(atcmd_output, "NightmareDrop | ");
  3842. if (map[m_id].flag.pvp_nocalcrank)
  3843. strcat(atcmd_output, "NoCalcRank | ");
  3844. clif_displaymessage(fd, atcmd_output);
  3845. strcpy(atcmd_output,"GvG Flags: ");
  3846. if (map[m_id].flag.gvg)
  3847. strcat(atcmd_output, "GvG ON | ");
  3848. if (map[m_id].flag.gvg_dungeon)
  3849. strcat(atcmd_output, "GvG Dungeon | ");
  3850. if (map[m_id].flag.gvg_castle)
  3851. strcat(atcmd_output, "GvG Castle | ");
  3852. if (map[m_id].flag.gvg_noparty)
  3853. strcat(atcmd_output, "NoParty | ");
  3854. clif_displaymessage(fd, atcmd_output);
  3855. strcpy(atcmd_output,"Teleport Flags: ");
  3856. if (map[m_id].flag.noteleport)
  3857. strcat(atcmd_output, "NoTeleport | ");
  3858. if (map[m_id].flag.monster_noteleport)
  3859. strcat(atcmd_output, "Monster NoTeleport | ");
  3860. if (map[m_id].flag.nowarp)
  3861. strcat(atcmd_output, "NoWarp | ");
  3862. if (map[m_id].flag.nowarpto)
  3863. strcat(atcmd_output, "NoWarpTo | ");
  3864. if (map[m_id].flag.noreturn)
  3865. strcat(atcmd_output, "NoReturn | ");
  3866. if (map[m_id].flag.nogo)
  3867. strcat(atcmd_output, "NoGo | ");
  3868. if (map[m_id].flag.nomemo)
  3869. strcat(atcmd_output, "NoMemo | ");
  3870. clif_displaymessage(fd, atcmd_output);
  3871. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  3872. clif_displaymessage(fd, atcmd_output);
  3873. if (map[m_id].flag.nosave) {
  3874. if (!map[m_id].save.map)
  3875. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3876. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3877. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3878. else
  3879. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3880. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3881. clif_displaymessage(fd, atcmd_output);
  3882. }
  3883. strcpy(atcmd_output,"Weather Flags: ");
  3884. if (map[m_id].flag.snow)
  3885. strcat(atcmd_output, "Snow | ");
  3886. if (map[m_id].flag.fog)
  3887. strcat(atcmd_output, "Fog | ");
  3888. if (map[m_id].flag.sakura)
  3889. strcat(atcmd_output, "Sakura | ");
  3890. if (map[m_id].flag.clouds)
  3891. strcat(atcmd_output, "Clouds | ");
  3892. if (map[m_id].flag.clouds2)
  3893. strcat(atcmd_output, "Clouds2 | ");
  3894. if (map[m_id].flag.fireworks)
  3895. strcat(atcmd_output, "Fireworks | ");
  3896. if (map[m_id].flag.leaves)
  3897. strcat(atcmd_output, "Leaves | ");
  3898. /**
  3899. * No longer available, keeping here just in case it's back someday. [Ind]
  3900. **/
  3901. //if (map[m_id].flag.rain)
  3902. // strcat(atcmd_output, "Rain | ");
  3903. if (map[m_id].flag.nightenabled)
  3904. strcat(atcmd_output, "Displays Night | ");
  3905. clif_displaymessage(fd, atcmd_output);
  3906. strcpy(atcmd_output,"Other Flags: ");
  3907. if (map[m_id].flag.nobranch)
  3908. strcat(atcmd_output, "NoBranch | ");
  3909. if (map[m_id].flag.notrade)
  3910. strcat(atcmd_output, "NoTrade | ");
  3911. if (map[m_id].flag.novending)
  3912. strcat(atcmd_output, "NoVending | ");
  3913. if (map[m_id].flag.nodrop)
  3914. strcat(atcmd_output, "NoDrop | ");
  3915. if (map[m_id].flag.noskill)
  3916. strcat(atcmd_output, "NoSkill | ");
  3917. if (map[m_id].flag.noicewall)
  3918. strcat(atcmd_output, "NoIcewall | ");
  3919. if (map[m_id].flag.allowks)
  3920. strcat(atcmd_output, "AllowKS | ");
  3921. if (map[m_id].flag.reset)
  3922. strcat(atcmd_output, "Reset | ");
  3923. clif_displaymessage(fd, atcmd_output);
  3924. strcpy(atcmd_output,"Other Flags: ");
  3925. if (map[m_id].nocommand)
  3926. strcat(atcmd_output, "NoCommand | ");
  3927. if (map[m_id].flag.nobaseexp)
  3928. strcat(atcmd_output, "NoBaseEXP | ");
  3929. if (map[m_id].flag.nojobexp)
  3930. strcat(atcmd_output, "NoJobEXP | ");
  3931. if (map[m_id].flag.nomobloot)
  3932. strcat(atcmd_output, "NoMobLoot | ");
  3933. if (map[m_id].flag.nomvploot)
  3934. strcat(atcmd_output, "NoMVPLoot | ");
  3935. if (map[m_id].flag.partylock)
  3936. strcat(atcmd_output, "PartyLock | ");
  3937. if (map[m_id].flag.guildlock)
  3938. strcat(atcmd_output, "GuildLock | ");
  3939. clif_displaymessage(fd, atcmd_output);
  3940. switch (list) {
  3941. case 0:
  3942. // Do nothing. It's list 0, no additional display.
  3943. break;
  3944. case 1:
  3945. clif_displaymessage(fd, "----- Players in Map -----");
  3946. iter = mapit_getallusers();
  3947. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3948. {
  3949. if (pl_sd->mapindex == m_index) {
  3950. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3951. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3952. clif_displaymessage(fd, atcmd_output);
  3953. }
  3954. }
  3955. mapit_free(iter);
  3956. break;
  3957. case 2:
  3958. clif_displaymessage(fd, "----- NPCs in Map -----");
  3959. for (i = 0; i < map[m_id].npc_num;)
  3960. {
  3961. nd = map[m_id].npc[i];
  3962. switch(nd->ud.dir) {
  3963. case 0: strcpy(direction, "North"); break;
  3964. case 1: strcpy(direction, "North West"); break;
  3965. case 2: strcpy(direction, "West"); break;
  3966. case 3: strcpy(direction, "South West"); break;
  3967. case 4: strcpy(direction, "South"); break;
  3968. case 5: strcpy(direction, "South East"); break;
  3969. case 6: strcpy(direction, "East"); break;
  3970. case 7: strcpy(direction, "North East"); break;
  3971. case 9: strcpy(direction, "North"); break;
  3972. default: strcpy(direction, "Unknown"); break;
  3973. }
  3974. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3975. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3976. clif_displaymessage(fd, atcmd_output);
  3977. }
  3978. break;
  3979. case 3:
  3980. clif_displaymessage(fd, "----- Chats in Map -----");
  3981. iter = mapit_getallusers();
  3982. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3983. {
  3984. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3985. pl_sd->mapindex == m_index &&
  3986. cd->usersd[0] == pl_sd)
  3987. {
  3988. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  3989. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3990. clif_displaymessage(fd, atcmd_output);
  3991. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3992. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3993. clif_displaymessage(fd, atcmd_output);
  3994. }
  3995. }
  3996. mapit_free(iter);
  3997. break;
  3998. default: // normally impossible to arrive here
  3999. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4000. return -1;
  4001. break;
  4002. }
  4003. return 0;
  4004. }
  4005. /*==========================================
  4006. *
  4007. *------------------------------------------*/
  4008. ACMD_FUNC(mount_peco)
  4009. {
  4010. nullpo_retr(-1, sd);
  4011. if( pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4012. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  4013. clif_displaymessage(sd->fd,"You have mounted your Dragon");
  4014. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  4015. } else {
  4016. clif_displaymessage(sd->fd,"You have released your Dragon");
  4017. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  4018. }
  4019. return 0;
  4020. }
  4021. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4022. if( !(sd->sc.option&OPTION_MADOGEAR) ) {
  4023. clif_displaymessage(sd->fd,"You have mounted your Mado Gear");
  4024. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  4025. } else {
  4026. clif_displaymessage(sd->fd,"You have released your Mado Gear");
  4027. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  4028. }
  4029. return 0;
  4030. }
  4031. if (!pc_isriding(sd)) { // if actually no peco
  4032. if (!pc_checkskill(sd, KN_RIDING))
  4033. {
  4034. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  4035. return -1;
  4036. }
  4037. if (sd->disguise)
  4038. {
  4039. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  4040. return -1;
  4041. }
  4042. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4043. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  4044. } else { //Dismount
  4045. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4046. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  4047. }
  4048. return 0;
  4049. }
  4050. /*==========================================
  4051. *Spy Commands by Syrus22
  4052. *------------------------------------------*/
  4053. ACMD_FUNC(guildspy)
  4054. {
  4055. char guild_name[NAME_LENGTH];
  4056. struct guild *g;
  4057. nullpo_retr(-1, sd);
  4058. memset(guild_name, '\0', sizeof(guild_name));
  4059. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4060. if (!enable_spy)
  4061. {
  4062. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4063. return -1;
  4064. }
  4065. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4066. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4067. return -1;
  4068. }
  4069. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4070. (g = guild_search(atoi(message))) != NULL) {
  4071. if (sd->guildspy == g->guild_id) {
  4072. sd->guildspy = 0;
  4073. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4074. clif_displaymessage(fd, atcmd_output);
  4075. } else {
  4076. sd->guildspy = g->guild_id;
  4077. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4078. clif_displaymessage(fd, atcmd_output);
  4079. }
  4080. } else {
  4081. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  4082. return -1;
  4083. }
  4084. return 0;
  4085. }
  4086. /*==========================================
  4087. *
  4088. *------------------------------------------*/
  4089. ACMD_FUNC(partyspy)
  4090. {
  4091. char party_name[NAME_LENGTH];
  4092. struct party_data *p;
  4093. nullpo_retr(-1, sd);
  4094. memset(party_name, '\0', sizeof(party_name));
  4095. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4096. if (!enable_spy)
  4097. {
  4098. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4099. return -1;
  4100. }
  4101. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4102. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4103. return -1;
  4104. }
  4105. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4106. (p = party_search(atoi(message))) != NULL) {
  4107. if (sd->partyspy == p->party.party_id) {
  4108. sd->partyspy = 0;
  4109. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4110. clif_displaymessage(fd, atcmd_output);
  4111. } else {
  4112. sd->partyspy = p->party.party_id;
  4113. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4114. clif_displaymessage(fd, atcmd_output);
  4115. }
  4116. } else {
  4117. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  4118. return -1;
  4119. }
  4120. return 0;
  4121. }
  4122. /*==========================================
  4123. * @repairall [Valaris]
  4124. *------------------------------------------*/
  4125. ACMD_FUNC(repairall)
  4126. {
  4127. int count, i;
  4128. nullpo_retr(-1, sd);
  4129. count = 0;
  4130. for (i = 0; i < MAX_INVENTORY; i++) {
  4131. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4132. sd->status.inventory[i].attribute = 0;
  4133. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4134. count++;
  4135. }
  4136. }
  4137. if (count > 0) {
  4138. clif_misceffect(&sd->bl, 3);
  4139. clif_equiplist(sd);
  4140. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4141. } else {
  4142. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4143. return -1;
  4144. }
  4145. return 0;
  4146. }
  4147. /*==========================================
  4148. * @nuke [Valaris]
  4149. *------------------------------------------*/
  4150. ACMD_FUNC(nuke)
  4151. {
  4152. struct map_session_data *pl_sd;
  4153. nullpo_retr(-1, sd);
  4154. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4155. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4156. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4157. return -1;
  4158. }
  4159. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4160. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4161. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4162. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4163. } else {
  4164. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4165. return -1;
  4166. }
  4167. } else {
  4168. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4169. return -1;
  4170. }
  4171. return 0;
  4172. }
  4173. /*==========================================
  4174. * @tonpc
  4175. *------------------------------------------*/
  4176. ACMD_FUNC(tonpc)
  4177. {
  4178. char npcname[NAME_LENGTH+1];
  4179. struct npc_data *nd;
  4180. nullpo_retr(-1, sd);
  4181. memset(npcname, 0, sizeof(npcname));
  4182. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4183. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4184. return -1;
  4185. }
  4186. if ((nd = npc_name2id(npcname)) != NULL) {
  4187. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4188. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4189. else
  4190. return -1;
  4191. } else {
  4192. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4193. return -1;
  4194. }
  4195. return 0;
  4196. }
  4197. /*==========================================
  4198. *
  4199. *------------------------------------------*/
  4200. ACMD_FUNC(shownpc)
  4201. {
  4202. char NPCname[NAME_LENGTH+1];
  4203. nullpo_retr(-1, sd);
  4204. memset(NPCname, '\0', sizeof(NPCname));
  4205. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4206. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4207. return -1;
  4208. }
  4209. if (npc_name2id(NPCname) != NULL) {
  4210. npc_enable(NPCname, 1);
  4211. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4212. } else {
  4213. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4214. return -1;
  4215. }
  4216. return 0;
  4217. }
  4218. /*==========================================
  4219. *
  4220. *------------------------------------------*/
  4221. ACMD_FUNC(hidenpc)
  4222. {
  4223. char NPCname[NAME_LENGTH+1];
  4224. nullpo_retr(-1, sd);
  4225. memset(NPCname, '\0', sizeof(NPCname));
  4226. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4227. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4228. return -1;
  4229. }
  4230. if (npc_name2id(NPCname) == NULL) {
  4231. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4232. return -1;
  4233. }
  4234. npc_enable(NPCname, 0);
  4235. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4236. return 0;
  4237. }
  4238. ACMD_FUNC(loadnpc)
  4239. {
  4240. FILE *fp;
  4241. if (!message || !*message) {
  4242. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4243. return -1;
  4244. }
  4245. // check if script file exists
  4246. if ((fp = fopen(message, "r")) == NULL) {
  4247. clif_displaymessage(fd, msg_txt(261));
  4248. return -1;
  4249. }
  4250. fclose(fp);
  4251. // add to list of script sources and run it
  4252. npc_addsrcfile(message);
  4253. npc_parsesrcfile(message);
  4254. npc_read_event_script();
  4255. clif_displaymessage(fd, msg_txt(262));
  4256. return 0;
  4257. }
  4258. ACMD_FUNC(unloadnpc)
  4259. {
  4260. struct npc_data *nd;
  4261. char NPCname[NAME_LENGTH+1];
  4262. nullpo_retr(-1, sd);
  4263. memset(NPCname, '\0', sizeof(NPCname));
  4264. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4265. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4266. return -1;
  4267. }
  4268. if ((nd = npc_name2id(NPCname)) == NULL) {
  4269. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4270. return -1;
  4271. }
  4272. npc_unload_duplicates(nd);
  4273. npc_unload(nd);
  4274. npc_read_event_script();
  4275. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4276. return 0;
  4277. }
  4278. /*==========================================
  4279. * time in txt for time command (by [Yor])
  4280. *------------------------------------------*/
  4281. char* txt_time(unsigned int duration)
  4282. {
  4283. int days, hours, minutes, seconds;
  4284. char temp[CHAT_SIZE_MAX];
  4285. static char temp1[CHAT_SIZE_MAX];
  4286. memset(temp, '\0', sizeof(temp));
  4287. memset(temp1, '\0', sizeof(temp1));
  4288. days = duration / (60 * 60 * 24);
  4289. duration = duration - (60 * 60 * 24 * days);
  4290. hours = duration / (60 * 60);
  4291. duration = duration - (60 * 60 * hours);
  4292. minutes = duration / 60;
  4293. seconds = duration - (60 * minutes);
  4294. if (days < 2)
  4295. sprintf(temp, msg_txt(219), days); // %d day
  4296. else
  4297. sprintf(temp, msg_txt(220), days); // %d days
  4298. if (hours < 2)
  4299. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4300. else
  4301. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4302. if (minutes < 2)
  4303. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4304. else
  4305. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4306. if (seconds < 2)
  4307. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4308. else
  4309. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4310. return temp1;
  4311. }
  4312. /*==========================================
  4313. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4314. * Calculation management of GM modification (@day/@night GM commands) is done
  4315. *------------------------------------------*/
  4316. ACMD_FUNC(servertime)
  4317. {
  4318. const struct TimerData * timer_data;
  4319. const struct TimerData * timer_data2;
  4320. time_t time_server; // variable for number of seconds (used with time() function)
  4321. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4322. char temp[CHAT_SIZE_MAX];
  4323. nullpo_retr(-1, sd);
  4324. memset(temp, '\0', sizeof(temp));
  4325. time(&time_server); // get time in seconds since 1/1/1970
  4326. datetime = localtime(&time_server); // convert seconds in structure
  4327. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4328. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4329. clif_displaymessage(fd, temp);
  4330. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4331. if (night_flag == 0)
  4332. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4333. else
  4334. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4335. } else if (battle_config.night_duration == 0)
  4336. if (night_flag == 1) { // we start with night
  4337. timer_data = get_timer(day_timer_tid);
  4338. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4339. clif_displaymessage(fd, temp);
  4340. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4341. } else
  4342. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4343. else if (battle_config.day_duration == 0)
  4344. if (night_flag == 0) { // we start with day
  4345. timer_data = get_timer(night_timer_tid);
  4346. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4347. clif_displaymessage(fd, temp);
  4348. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4349. } else
  4350. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4351. else {
  4352. if (night_flag == 0) {
  4353. timer_data = get_timer(night_timer_tid);
  4354. timer_data2 = get_timer(day_timer_tid);
  4355. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4356. clif_displaymessage(fd, temp);
  4357. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4358. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  4359. else
  4360. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4361. clif_displaymessage(fd, temp);
  4362. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4363. clif_displaymessage(fd, temp);
  4364. } else {
  4365. timer_data = get_timer(day_timer_tid);
  4366. timer_data2 = get_timer(night_timer_tid);
  4367. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4368. clif_displaymessage(fd, temp);
  4369. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4370. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  4371. else
  4372. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4373. clif_displaymessage(fd, temp);
  4374. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4375. clif_displaymessage(fd, temp);
  4376. }
  4377. }
  4378. return 0;
  4379. }
  4380. //Added by Coltaro
  4381. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  4382. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4383. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4384. {
  4385. const int factor_year = 518400; //12*30*24*60 = 518400
  4386. const int factor_month = 43200; //30*24*60 = 43200
  4387. const int factor_day = 1440; //24*60 = 1440
  4388. const int factor_hour = 60;
  4389. *year = jailtime/factor_year;
  4390. jailtime -= *year*factor_year;
  4391. *month = jailtime/factor_month;
  4392. jailtime -= *month*factor_month;
  4393. *day = jailtime/factor_day;
  4394. jailtime -= *day*factor_day;
  4395. *hour = jailtime/factor_hour;
  4396. jailtime -= *hour*factor_hour;
  4397. *minute = jailtime;
  4398. *year = *year > 0? *year : 0;
  4399. *month = *month > 0? *month : 0;
  4400. *day = *day > 0? *day : 0;
  4401. *hour = *hour > 0? *hour : 0;
  4402. *minute = *minute > 0? *minute : 0;
  4403. return;
  4404. }
  4405. /*==========================================
  4406. * @jail <char_name> by [Yor]
  4407. * Special warp! No check with nowarp and nowarpto flag
  4408. *------------------------------------------*/
  4409. ACMD_FUNC(jail)
  4410. {
  4411. struct map_session_data *pl_sd;
  4412. int x, y;
  4413. unsigned short m_index;
  4414. nullpo_retr(-1, sd);
  4415. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4416. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4417. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4418. return -1;
  4419. }
  4420. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4421. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4422. return -1;
  4423. }
  4424. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4425. { // you can jail only lower or same GM
  4426. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4427. return -1;
  4428. }
  4429. if (pl_sd->sc.data[SC_JAILED])
  4430. {
  4431. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4432. return -1;
  4433. }
  4434. switch(rand() % 2) { //Jail Locations
  4435. case 0:
  4436. m_index = mapindex_name2id(MAP_JAIL);
  4437. x = 24;
  4438. y = 75;
  4439. break;
  4440. default:
  4441. m_index = mapindex_name2id(MAP_JAIL);
  4442. x = 49;
  4443. y = 75;
  4444. break;
  4445. }
  4446. //Duration of INT_MAX to specify infinity.
  4447. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4448. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4449. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4450. return 0;
  4451. }
  4452. /*==========================================
  4453. * @unjail/@discharge <char_name> by [Yor]
  4454. * Special warp! No check with nowarp and nowarpto flag
  4455. *------------------------------------------*/
  4456. ACMD_FUNC(unjail)
  4457. {
  4458. struct map_session_data *pl_sd;
  4459. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4460. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4461. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4462. return -1;
  4463. }
  4464. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4465. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4466. return -1;
  4467. }
  4468. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4469. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4470. return -1;
  4471. }
  4472. if (!pl_sd->sc.data[SC_JAILED])
  4473. {
  4474. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4475. return -1;
  4476. }
  4477. //Reset jail time to 1 sec.
  4478. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4479. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4480. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4481. return 0;
  4482. }
  4483. ACMD_FUNC(jailfor)
  4484. {
  4485. struct map_session_data *pl_sd = NULL;
  4486. int year, month, day, hour, minute, value;
  4487. char * modif_p;
  4488. int jailtime = 0,x,y;
  4489. short m_index = 0;
  4490. nullpo_retr(-1, sd);
  4491. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4492. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4493. return -1;
  4494. }
  4495. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4496. modif_p = atcmd_output;
  4497. year = month = day = hour = minute = 0;
  4498. while (modif_p[0] != '\0') {
  4499. value = atoi(modif_p);
  4500. if (value == 0)
  4501. modif_p++;
  4502. else {
  4503. if (modif_p[0] == '-' || modif_p[0] == '+')
  4504. modif_p++;
  4505. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4506. modif_p++;
  4507. if (modif_p[0] == 'n') {
  4508. minute = value;
  4509. modif_p++;
  4510. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4511. minute = value;
  4512. modif_p = modif_p + 2;
  4513. } else if (modif_p[0] == 'h') {
  4514. hour = value;
  4515. modif_p++;
  4516. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4517. day = value;
  4518. modif_p++;
  4519. } else if (modif_p[0] == 'm') {
  4520. month = value;
  4521. modif_p++;
  4522. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4523. year = value;
  4524. modif_p++;
  4525. } else if (modif_p[0] != '\0') {
  4526. modif_p++;
  4527. }
  4528. }
  4529. }
  4530. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4531. clif_displaymessage(fd, "Invalid time for jail command.");
  4532. return -1;
  4533. }
  4534. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4535. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4536. return -1;
  4537. }
  4538. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4539. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4540. return -1;
  4541. }
  4542. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4543. if(jailtime==0) {
  4544. clif_displaymessage(fd, "Invalid time for jail command.");
  4545. return -1;
  4546. }
  4547. //Added by Coltaro
  4548. if(pl_sd->sc.data[SC_JAILED] &&
  4549. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4550. { //Update the player's jail time
  4551. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4552. if (jailtime <= 0) {
  4553. jailtime = 0;
  4554. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4555. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4556. } else {
  4557. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4558. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4559. clif_displaymessage(pl_sd->fd, atcmd_output);
  4560. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4561. clif_displaymessage(fd, atcmd_output);
  4562. }
  4563. } else if (jailtime < 0) {
  4564. clif_displaymessage(fd, "Invalid time for jail command.");
  4565. return -1;
  4566. }
  4567. //Jail locations, add more as you wish.
  4568. switch(rand()%2)
  4569. {
  4570. case 1: //Jail #1
  4571. m_index = mapindex_name2id(MAP_JAIL);
  4572. x = 49; y = 75;
  4573. break;
  4574. default: //Default Jail
  4575. m_index = mapindex_name2id(MAP_JAIL);
  4576. x = 24; y = 75;
  4577. break;
  4578. }
  4579. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  4580. return 0;
  4581. }
  4582. //By Coltaro
  4583. ACMD_FUNC(jailtime)
  4584. {
  4585. int year, month, day, hour, minute;
  4586. nullpo_retr(-1, sd);
  4587. if (!sd->sc.data[SC_JAILED]) {
  4588. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4589. return -1;
  4590. }
  4591. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4592. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4593. return 0;
  4594. }
  4595. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4596. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4597. return -1;
  4598. }
  4599. //Get remaining jail time
  4600. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4601. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4602. clif_displaymessage(fd, atcmd_output);
  4603. return 0;
  4604. }
  4605. /*==========================================
  4606. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4607. *------------------------------------------*/
  4608. ACMD_FUNC(disguise)
  4609. {
  4610. int id = 0;
  4611. nullpo_retr(-1, sd);
  4612. if (!message || !*message) {
  4613. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4614. return -1;
  4615. }
  4616. if ((id = atoi(message)) > 0)
  4617. { //Acquired an ID
  4618. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4619. id = 0; //Invalid id for either mobs or npcs.
  4620. } else { //Acquired a Name
  4621. if ((id = mobdb_searchname(message)) == 0)
  4622. {
  4623. struct npc_data* nd = npc_name2id(message);
  4624. if (nd != NULL)
  4625. id = nd->class_;
  4626. }
  4627. }
  4628. if (id == 0)
  4629. {
  4630. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4631. return -1;
  4632. }
  4633. if(pc_isriding(sd))
  4634. {
  4635. //FIXME: wrong message [ultramage]
  4636. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4637. return -1;
  4638. }
  4639. pc_disguise(sd, id);
  4640. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4641. return 0;
  4642. }
  4643. /*==========================================
  4644. * DisguiseAll
  4645. *------------------------------------------*/
  4646. ACMD_FUNC(disguiseall)
  4647. {
  4648. int mob_id=0;
  4649. struct map_session_data *pl_sd;
  4650. struct s_mapiterator* iter;
  4651. nullpo_retr(-1, sd);
  4652. if (!message || !*message) {
  4653. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4654. return -1;
  4655. }
  4656. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4657. mob_id = atoi(message);
  4658. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4659. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4660. return -1;
  4661. }
  4662. iter = mapit_getallusers();
  4663. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4664. pc_disguise(pl_sd, mob_id);
  4665. mapit_free(iter);
  4666. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4667. return 0;
  4668. }
  4669. /*==========================================
  4670. * @undisguise by [Yor]
  4671. *------------------------------------------*/
  4672. ACMD_FUNC(undisguise)
  4673. {
  4674. nullpo_retr(-1, sd);
  4675. if (sd->disguise) {
  4676. pc_disguise(sd, 0);
  4677. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4678. } else {
  4679. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4680. return -1;
  4681. }
  4682. return 0;
  4683. }
  4684. /*==========================================
  4685. * UndisguiseAll
  4686. *------------------------------------------*/
  4687. ACMD_FUNC(undisguiseall)
  4688. {
  4689. struct map_session_data *pl_sd;
  4690. struct s_mapiterator* iter;
  4691. nullpo_retr(-1, sd);
  4692. iter = mapit_getallusers();
  4693. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4694. if( pl_sd->disguise )
  4695. pc_disguise(pl_sd, 0);
  4696. mapit_free(iter);
  4697. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4698. return 0;
  4699. }
  4700. /*==========================================
  4701. * @exp by [Skotlex]
  4702. *------------------------------------------*/
  4703. ACMD_FUNC(exp)
  4704. {
  4705. char output[CHAT_SIZE_MAX];
  4706. double nextb, nextj;
  4707. nullpo_retr(-1, sd);
  4708. memset(output, '\0', sizeof(output));
  4709. nextb = pc_nextbaseexp(sd);
  4710. if (nextb)
  4711. nextb = sd->status.base_exp*100.0/nextb;
  4712. nextj = pc_nextjobexp(sd);
  4713. if (nextj)
  4714. nextj = sd->status.job_exp*100.0/nextj;
  4715. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4716. clif_displaymessage(fd, output);
  4717. return 0;
  4718. }
  4719. /*==========================================
  4720. * @broadcast by [Valaris]
  4721. *------------------------------------------*/
  4722. ACMD_FUNC(broadcast)
  4723. {
  4724. nullpo_retr(-1, sd);
  4725. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4726. if (!message || !*message) {
  4727. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4728. return -1;
  4729. }
  4730. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4731. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4732. return 0;
  4733. }
  4734. /*==========================================
  4735. * @localbroadcast by [Valaris]
  4736. *------------------------------------------*/
  4737. ACMD_FUNC(localbroadcast)
  4738. {
  4739. nullpo_retr(-1, sd);
  4740. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4741. if (!message || !*message) {
  4742. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4743. return -1;
  4744. }
  4745. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4746. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4747. return 0;
  4748. }
  4749. /*==========================================
  4750. * @email <actual@email> <new@email> by [Yor]
  4751. *------------------------------------------*/
  4752. ACMD_FUNC(email)
  4753. {
  4754. char actual_email[100];
  4755. char new_email[100];
  4756. nullpo_retr(-1, sd);
  4757. memset(actual_email, '\0', sizeof(actual_email));
  4758. memset(new_email, '\0', sizeof(new_email));
  4759. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4760. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4761. return -1;
  4762. }
  4763. if (e_mail_check(actual_email) == 0) {
  4764. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4765. return -1;
  4766. } else if (e_mail_check(new_email) == 0) {
  4767. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4768. return -1;
  4769. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4770. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4771. return -1;
  4772. } else if (strcmpi(actual_email, new_email) == 0) {
  4773. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4774. return -1;
  4775. }
  4776. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4777. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4778. return 0;
  4779. }
  4780. /*==========================================
  4781. *@effect
  4782. *------------------------------------------*/
  4783. ACMD_FUNC(effect)
  4784. {
  4785. int type = 0, flag = 0;
  4786. nullpo_retr(-1, sd);
  4787. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4788. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4789. return -1;
  4790. }
  4791. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4792. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4793. return 0;
  4794. }
  4795. /*==========================================
  4796. * @killer by MouseJstr
  4797. * enable killing players even when not in pvp
  4798. *------------------------------------------*/
  4799. ACMD_FUNC(killer)
  4800. {
  4801. nullpo_retr(-1, sd);
  4802. sd->state.killer = !sd->state.killer;
  4803. if(sd->state.killer)
  4804. clif_displaymessage(fd, msg_txt(241));
  4805. else {
  4806. clif_displaymessage(fd, msg_txt(287));
  4807. pc_stop_attack(sd);
  4808. }
  4809. return 0;
  4810. }
  4811. /*==========================================
  4812. * @killable by MouseJstr
  4813. * enable other people killing you
  4814. *------------------------------------------*/
  4815. ACMD_FUNC(killable)
  4816. {
  4817. nullpo_retr(-1, sd);
  4818. sd->state.killable = !sd->state.killable;
  4819. if(sd->state.killable)
  4820. clif_displaymessage(fd, msg_txt(242));
  4821. else {
  4822. clif_displaymessage(fd, msg_txt(288));
  4823. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4824. }
  4825. return 0;
  4826. }
  4827. /*==========================================
  4828. * @skillon by MouseJstr
  4829. * turn skills on for the map
  4830. *------------------------------------------*/
  4831. ACMD_FUNC(skillon)
  4832. {
  4833. nullpo_retr(-1, sd);
  4834. map[sd->bl.m].flag.noskill = 0;
  4835. clif_displaymessage(fd, msg_txt(244));
  4836. return 0;
  4837. }
  4838. /*==========================================
  4839. * @skilloff by MouseJstr
  4840. * Turn skills off on the map
  4841. *------------------------------------------*/
  4842. ACMD_FUNC(skilloff)
  4843. {
  4844. nullpo_retr(-1, sd);
  4845. map[sd->bl.m].flag.noskill = 1;
  4846. clif_displaymessage(fd, msg_txt(243));
  4847. return 0;
  4848. }
  4849. /*==========================================
  4850. * @npcmove by MouseJstr
  4851. * move a npc
  4852. *------------------------------------------*/
  4853. ACMD_FUNC(npcmove)
  4854. {
  4855. int x = 0, y = 0, m;
  4856. struct npc_data *nd = 0;
  4857. nullpo_retr(-1, sd);
  4858. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4859. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4860. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4861. return -1;
  4862. }
  4863. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4864. {
  4865. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4866. return -1;
  4867. }
  4868. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4869. {
  4870. clif_displaymessage(fd, "NPC is not on this map.");
  4871. return -1; //Not on a map.
  4872. }
  4873. x = cap_value(x, 0, map[m].xs-1);
  4874. y = cap_value(y, 0, map[m].ys-1);
  4875. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4876. map_moveblock(&nd->bl, x, y, gettick());
  4877. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4878. clif_displaymessage(fd, "NPC moved.");
  4879. return 0;
  4880. }
  4881. /*==========================================
  4882. * @addwarp by MouseJstr
  4883. * Create a new static warp point.
  4884. *------------------------------------------*/
  4885. ACMD_FUNC(addwarp)
  4886. {
  4887. char mapname[32];
  4888. int x,y;
  4889. unsigned short m;
  4890. struct npc_data* nd;
  4891. nullpo_retr(-1, sd);
  4892. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4893. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4894. return -1;
  4895. }
  4896. m = mapindex_name2id(mapname);
  4897. if( m == 0 )
  4898. {
  4899. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4900. clif_displaymessage(fd, atcmd_output);
  4901. return -1;
  4902. }
  4903. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4904. if( nd == NULL )
  4905. return -1;
  4906. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4907. clif_displaymessage(fd, atcmd_output);
  4908. return 0;
  4909. }
  4910. /*==========================================
  4911. * @follow by [MouseJstr]
  4912. * Follow a player .. staying no more then 5 spaces away
  4913. *------------------------------------------*/
  4914. ACMD_FUNC(follow)
  4915. {
  4916. struct map_session_data *pl_sd = NULL;
  4917. nullpo_retr(-1, sd);
  4918. if (!message || !*message) {
  4919. if (sd->followtarget == -1)
  4920. return -1;
  4921. pc_stop_following (sd);
  4922. clif_displaymessage(fd, "Follow mode OFF.");
  4923. return 0;
  4924. }
  4925. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4926. {
  4927. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4928. return -1;
  4929. }
  4930. if (sd->followtarget == pl_sd->bl.id) {
  4931. pc_stop_following (sd);
  4932. clif_displaymessage(fd, "Follow mode OFF.");
  4933. } else {
  4934. pc_follow(sd, pl_sd->bl.id);
  4935. clif_displaymessage(fd, "Follow mode ON.");
  4936. }
  4937. return 0;
  4938. }
  4939. /*==========================================
  4940. * @dropall by [MouseJstr]
  4941. * Drop all your possession on the ground
  4942. *------------------------------------------*/
  4943. ACMD_FUNC(dropall)
  4944. {
  4945. int i;
  4946. nullpo_retr(-1, sd);
  4947. for (i = 0; i < MAX_INVENTORY; i++) {
  4948. if (sd->status.inventory[i].amount) {
  4949. if(sd->status.inventory[i].equip != 0)
  4950. pc_unequipitem(sd, i, 3);
  4951. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4952. }
  4953. }
  4954. return 0;
  4955. }
  4956. /*==========================================
  4957. * @storeall by [MouseJstr]
  4958. * Put everything into storage
  4959. *------------------------------------------*/
  4960. ACMD_FUNC(storeall)
  4961. {
  4962. int i;
  4963. nullpo_retr(-1, sd);
  4964. if (sd->state.storage_flag != 1)
  4965. { //Open storage.
  4966. if( storage_storageopen(sd) == 1 ) {
  4967. clif_displaymessage(fd, "You can't open the storage currently.");
  4968. return -1;
  4969. }
  4970. }
  4971. for (i = 0; i < MAX_INVENTORY; i++) {
  4972. if (sd->status.inventory[i].amount) {
  4973. if(sd->status.inventory[i].equip != 0)
  4974. pc_unequipitem(sd, i, 3);
  4975. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4976. }
  4977. }
  4978. storage_storageclose(sd);
  4979. clif_displaymessage(fd, "It is done");
  4980. return 0;
  4981. }
  4982. /*==========================================
  4983. * @skillid by [MouseJstr]
  4984. * lookup a skill by name
  4985. *------------------------------------------*/
  4986. ACMD_FUNC(skillid)
  4987. {
  4988. int skillen, idx;
  4989. nullpo_retr(-1, sd);
  4990. if (!message || !*message)
  4991. {
  4992. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4993. return -1;
  4994. }
  4995. skillen = strlen(message);
  4996. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4997. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4998. {
  4999. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5000. clif_displaymessage(fd, atcmd_output);
  5001. }
  5002. }
  5003. return 0;
  5004. }
  5005. /*==========================================
  5006. * @useskill by [MouseJstr]
  5007. * A way of using skills without having to find them in the skills menu
  5008. *------------------------------------------*/
  5009. ACMD_FUNC(useskill)
  5010. {
  5011. struct map_session_data *pl_sd = NULL;
  5012. struct block_list *bl;
  5013. int skillnum;
  5014. int skilllv;
  5015. char target[100];
  5016. nullpo_retr(-1, sd);
  5017. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5018. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5019. return -1;
  5020. }
  5021. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5022. {
  5023. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5024. return -1;
  5025. }
  5026. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5027. {
  5028. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5029. return -1;
  5030. }
  5031. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  5032. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5033. bl = &sd->hd->bl;
  5034. else
  5035. bl = &sd->bl;
  5036. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5037. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5038. else
  5039. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5040. return 0;
  5041. }
  5042. /*==========================================
  5043. * @displayskill by [Skotlex]
  5044. * Debug command to locate new skill IDs. It sends the
  5045. * three possible skill-effect packets to the area.
  5046. *------------------------------------------*/
  5047. ACMD_FUNC(displayskill)
  5048. {
  5049. struct status_data * status;
  5050. unsigned int tick;
  5051. int skillnum;
  5052. int skilllv = 1;
  5053. nullpo_retr(-1, sd);
  5054. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5055. {
  5056. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5057. return -1;
  5058. }
  5059. status = status_get_status_data(&sd->bl);
  5060. tick = gettick();
  5061. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  5062. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5063. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5064. return 0;
  5065. }
  5066. /*==========================================
  5067. * @skilltree by [MouseJstr]
  5068. * prints the skill tree for a player required to get to a skill
  5069. *------------------------------------------*/
  5070. ACMD_FUNC(skilltree)
  5071. {
  5072. struct map_session_data *pl_sd = NULL;
  5073. int skillnum;
  5074. int meets, j, c=0;
  5075. char target[NAME_LENGTH];
  5076. struct skill_tree_entry *ent;
  5077. nullpo_retr(-1, sd);
  5078. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5079. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5080. return -1;
  5081. }
  5082. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5083. {
  5084. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5085. return -1;
  5086. }
  5087. c = pc_calc_skilltree_normalize_job(pl_sd);
  5088. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5089. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, 1));
  5090. clif_displaymessage(fd, atcmd_output);
  5091. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  5092. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5093. {
  5094. sprintf(atcmd_output, "I do not believe the player can use that skill");
  5095. clif_displaymessage(fd, atcmd_output);
  5096. return 0;
  5097. }
  5098. ent = &skill_tree[c][j];
  5099. meets = 1;
  5100. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5101. {
  5102. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5103. {
  5104. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  5105. clif_displaymessage(fd, atcmd_output);
  5106. meets = 0;
  5107. }
  5108. }
  5109. if (meets == 1) {
  5110. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5111. clif_displaymessage(fd, atcmd_output);
  5112. }
  5113. return 0;
  5114. }
  5115. // Hand a ring with partners name on it to this char
  5116. void getring (struct map_session_data* sd)
  5117. {
  5118. int flag, item_id;
  5119. struct item item_tmp;
  5120. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5121. memset(&item_tmp, 0, sizeof(item_tmp));
  5122. item_tmp.nameid = item_id;
  5123. item_tmp.identify = 1;
  5124. item_tmp.card[0] = 255;
  5125. item_tmp.card[2] = sd->status.partner_id;
  5126. item_tmp.card[3] = sd->status.partner_id >> 16;
  5127. //Logs (A)dmins items [Lupus]
  5128. log_pick_pc(sd, LOG_TYPE_COMMAND, item_id, 1, &item_tmp);
  5129. if((flag = pc_additem(sd,&item_tmp,1))) {
  5130. clif_additem(sd,0,0,flag);
  5131. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5132. }
  5133. }
  5134. /*==========================================
  5135. * @marry by [MouseJstr], fixed by Lupus
  5136. * Marry two players
  5137. *------------------------------------------*/
  5138. ACMD_FUNC(marry)
  5139. {
  5140. struct map_session_data *pl_sd1 = NULL;
  5141. struct map_session_data *pl_sd2 = NULL;
  5142. char player1[128], player2[128]; //Length used for return error msgs
  5143. nullpo_retr(-1, sd);
  5144. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5145. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5146. return -1;
  5147. }
  5148. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5149. sprintf(player2, "Cannot find player '%s' online", player1);
  5150. clif_displaymessage(fd, player2);
  5151. return -1;
  5152. }
  5153. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5154. sprintf(player1, "Cannot find player '%s' online", player2);
  5155. clif_displaymessage(fd, player1);
  5156. return -1;
  5157. }
  5158. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5159. clif_displaymessage(fd, "They are married.. wish them well");
  5160. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5161. // Auto-give named rings (Aru)
  5162. getring (pl_sd1);
  5163. getring (pl_sd2);
  5164. return 0;
  5165. }
  5166. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5167. return -1;
  5168. }
  5169. /*==========================================
  5170. * @divorce by [MouseJstr], fixed by [Lupus]
  5171. * divorce two players
  5172. *------------------------------------------*/
  5173. ACMD_FUNC(divorce)
  5174. {
  5175. struct map_session_data *pl_sd = NULL;
  5176. nullpo_retr(-1, sd);
  5177. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5178. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5179. return -1;
  5180. }
  5181. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5182. {
  5183. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5184. return -1;
  5185. }
  5186. if (pc_divorce(pl_sd) != 0) {
  5187. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5188. clif_displaymessage(fd, atcmd_output);
  5189. return -1;
  5190. }
  5191. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5192. clif_displaymessage(fd, atcmd_output);
  5193. return 0;
  5194. }
  5195. /*==========================================
  5196. * @changelook by [Celest]
  5197. *------------------------------------------*/
  5198. ACMD_FUNC(changelook)
  5199. {
  5200. int i, j = 0, k = 0;
  5201. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5202. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5203. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5204. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5205. return -1;
  5206. } else if (i == 2) {
  5207. if (j < 1) j = 1;
  5208. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5209. j = pos[j - 1];
  5210. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5211. k = j; // swap
  5212. j = LOOK_HEAD_TOP;
  5213. }
  5214. clif_changelook(&sd->bl,j,k);
  5215. return 0;
  5216. }
  5217. /*==========================================
  5218. * @autotrade by durf [Lupus] [Paradox924X]
  5219. * Turns on/off Autotrade for a specific player
  5220. *------------------------------------------*/
  5221. ACMD_FUNC(autotrade)
  5222. {
  5223. nullpo_retr(-1, sd);
  5224. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5225. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5226. return -1;
  5227. }
  5228. if( pc_isdead(sd) ) {
  5229. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  5230. return -1;
  5231. }
  5232. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5233. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  5234. return -1;
  5235. }
  5236. sd->state.autotrade = 1;
  5237. if( battle_config.at_timeout )
  5238. {
  5239. int timeout = atoi(message);
  5240. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  5241. }
  5242. clif_authfail_fd(fd, 15);
  5243. return 0;
  5244. }
  5245. /*==========================================
  5246. * @changegm by durf (changed by Lupus)
  5247. * Changes Master of your Guild to a specified guild member
  5248. *------------------------------------------*/
  5249. ACMD_FUNC(changegm)
  5250. {
  5251. struct guild *g;
  5252. struct map_session_data *pl_sd;
  5253. nullpo_retr(-1, sd);
  5254. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5255. {
  5256. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5257. return -1;
  5258. }
  5259. if( map[sd->bl.m].flag.guildlock )
  5260. {
  5261. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5262. return -1;
  5263. }
  5264. if( !message[0] )
  5265. {
  5266. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5267. return -1;
  5268. }
  5269. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5270. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5271. return -1;
  5272. }
  5273. guild_gm_change(sd->status.guild_id, pl_sd);
  5274. return 0;
  5275. }
  5276. /*==========================================
  5277. * @changeleader by Skotlex
  5278. * Changes the leader of a party.
  5279. *------------------------------------------*/
  5280. ACMD_FUNC(changeleader)
  5281. {
  5282. nullpo_retr(-1, sd);
  5283. if( !message[0] )
  5284. {
  5285. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5286. return -1;
  5287. }
  5288. if (party_changeleader(sd, map_nick2sd((char *) message)))
  5289. return 0;
  5290. return -1;
  5291. }
  5292. /*==========================================
  5293. * @partyoption by Skotlex
  5294. * Used to change the item share setting of a party.
  5295. *------------------------------------------*/
  5296. ACMD_FUNC(partyoption)
  5297. {
  5298. struct party_data *p;
  5299. int mi, option;
  5300. char w1[16], w2[16];
  5301. nullpo_retr(-1, sd);
  5302. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5303. {
  5304. clif_displaymessage(fd, msg_txt(282));
  5305. return -1;
  5306. }
  5307. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5308. if (mi == MAX_PARTY)
  5309. return -1; //Shouldn't happen
  5310. if (!p->party.member[mi].leader)
  5311. {
  5312. clif_displaymessage(fd, msg_txt(282));
  5313. return -1;
  5314. }
  5315. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5316. {
  5317. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5318. return -1;
  5319. }
  5320. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5321. //Change item share type.
  5322. if (option != p->party.item)
  5323. party_changeoption(sd, p->party.exp, option);
  5324. else
  5325. clif_displaymessage(fd, msg_txt(286));
  5326. return 0;
  5327. }
  5328. /*==========================================
  5329. * @autoloot by Upa-Kun
  5330. * Turns on/off AutoLoot for a specific player
  5331. *------------------------------------------*/
  5332. ACMD_FUNC(autoloot)
  5333. {
  5334. int rate;
  5335. double drate;
  5336. nullpo_retr(-1, sd);
  5337. // autoloot command without value
  5338. if(!message || !*message)
  5339. {
  5340. if (sd->state.autoloot)
  5341. rate = 0;
  5342. else
  5343. rate = 10000;
  5344. } else {
  5345. drate = atof(message);
  5346. rate = (int)(drate*100);
  5347. }
  5348. if (rate < 0) rate = 0;
  5349. if (rate > 10000) rate = 10000;
  5350. sd->state.autoloot = rate;
  5351. if (sd->state.autoloot) {
  5352. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5353. clif_displaymessage(fd, atcmd_output);
  5354. }else
  5355. clif_displaymessage(fd, "Autoloot is now off.");
  5356. return 0;
  5357. }
  5358. /*==========================================
  5359. * @alootid
  5360. *------------------------------------------*/
  5361. ACMD_FUNC(autolootitem)
  5362. {
  5363. struct item_data *item_data = NULL;
  5364. if (!message || !*message) {
  5365. if (sd->state.autolootid) {
  5366. sd->state.autolootid = 0;
  5367. clif_displaymessage(fd, "Autolootitem has been turned OFF.");
  5368. } else
  5369. clif_displaymessage(fd, "Please, enter item name or it's ID (usage: @alootid <item_name_or_ID>).");
  5370. return -1;
  5371. }
  5372. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5373. item_data = itemdb_searchname(message);
  5374. if (!item_data) {
  5375. // No items founds in the DB with Id or Name
  5376. clif_displaymessage(fd, "Item not found.");
  5377. return -1;
  5378. }
  5379. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  5380. sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d)",
  5381. item_data->name, item_data->jname, item_data->nameid);
  5382. clif_displaymessage(fd, atcmd_output);
  5383. return 0;
  5384. }
  5385. /**
  5386. * No longer available, keeping here just in case it's back someday. [Ind]
  5387. **/
  5388. /*==========================================
  5389. * It is made to rain.
  5390. *------------------------------------------*/
  5391. //ACMD_FUNC(rain)
  5392. //{
  5393. // nullpo_retr(-1, sd);
  5394. // if (map[sd->bl.m].flag.rain) {
  5395. // map[sd->bl.m].flag.rain=0;
  5396. // clif_weather(sd->bl.m);
  5397. // clif_displaymessage(fd, "The rain has stopped.");
  5398. // } else {
  5399. // map[sd->bl.m].flag.rain=1;
  5400. // clif_weather(sd->bl.m);
  5401. // clif_displaymessage(fd, "It is made to rain.");
  5402. // }
  5403. // return 0;
  5404. //}
  5405. /*==========================================
  5406. * It is made to snow.
  5407. *------------------------------------------*/
  5408. ACMD_FUNC(snow)
  5409. {
  5410. nullpo_retr(-1, sd);
  5411. if (map[sd->bl.m].flag.snow) {
  5412. map[sd->bl.m].flag.snow=0;
  5413. clif_weather(sd->bl.m);
  5414. clif_displaymessage(fd, "Snow has stopped falling.");
  5415. } else {
  5416. map[sd->bl.m].flag.snow=1;
  5417. clif_weather(sd->bl.m);
  5418. clif_displaymessage(fd, "It is made to snow.");
  5419. }
  5420. return 0;
  5421. }
  5422. /*==========================================
  5423. * Cherry tree snowstorm is made to fall. (Sakura)
  5424. *------------------------------------------*/
  5425. ACMD_FUNC(sakura)
  5426. {
  5427. nullpo_retr(-1, sd);
  5428. if (map[sd->bl.m].flag.sakura) {
  5429. map[sd->bl.m].flag.sakura=0;
  5430. clif_weather(sd->bl.m);
  5431. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5432. } else {
  5433. map[sd->bl.m].flag.sakura=1;
  5434. clif_weather(sd->bl.m);
  5435. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5436. }
  5437. return 0;
  5438. }
  5439. /*==========================================
  5440. * Clouds appear.
  5441. *------------------------------------------*/
  5442. ACMD_FUNC(clouds)
  5443. {
  5444. nullpo_retr(-1, sd);
  5445. if (map[sd->bl.m].flag.clouds) {
  5446. map[sd->bl.m].flag.clouds=0;
  5447. clif_weather(sd->bl.m);
  5448. clif_displaymessage(fd, "The clouds has disappear.");
  5449. } else {
  5450. map[sd->bl.m].flag.clouds=1;
  5451. clif_weather(sd->bl.m);
  5452. clif_displaymessage(fd, "Clouds appear.");
  5453. }
  5454. return 0;
  5455. }
  5456. /*==========================================
  5457. * Different type of clouds using effect 516
  5458. *------------------------------------------*/
  5459. ACMD_FUNC(clouds2)
  5460. {
  5461. nullpo_retr(-1, sd);
  5462. if (map[sd->bl.m].flag.clouds2) {
  5463. map[sd->bl.m].flag.clouds2=0;
  5464. clif_weather(sd->bl.m);
  5465. clif_displaymessage(fd, "The alternative clouds disappear.");
  5466. } else {
  5467. map[sd->bl.m].flag.clouds2=1;
  5468. clif_weather(sd->bl.m);
  5469. clif_displaymessage(fd, "Alternative clouds appear.");
  5470. }
  5471. return 0;
  5472. }
  5473. /*==========================================
  5474. * Fog hangs over.
  5475. *------------------------------------------*/
  5476. ACMD_FUNC(fog)
  5477. {
  5478. nullpo_retr(-1, sd);
  5479. if (map[sd->bl.m].flag.fog) {
  5480. map[sd->bl.m].flag.fog=0;
  5481. clif_weather(sd->bl.m);
  5482. clif_displaymessage(fd, "The fog has gone.");
  5483. } else {
  5484. map[sd->bl.m].flag.fog=1;
  5485. clif_weather(sd->bl.m);
  5486. clif_displaymessage(fd, "Fog hangs over.");
  5487. }
  5488. return 0;
  5489. }
  5490. /*==========================================
  5491. * Fallen leaves fall.
  5492. *------------------------------------------*/
  5493. ACMD_FUNC(leaves)
  5494. {
  5495. nullpo_retr(-1, sd);
  5496. if (map[sd->bl.m].flag.leaves) {
  5497. map[sd->bl.m].flag.leaves=0;
  5498. clif_weather(sd->bl.m);
  5499. clif_displaymessage(fd, "Leaves no longer fall.");
  5500. } else {
  5501. map[sd->bl.m].flag.leaves=1;
  5502. clif_weather(sd->bl.m);
  5503. clif_displaymessage(fd, "Fallen leaves fall.");
  5504. }
  5505. return 0;
  5506. }
  5507. /*==========================================
  5508. * Fireworks appear.
  5509. *------------------------------------------*/
  5510. ACMD_FUNC(fireworks)
  5511. {
  5512. nullpo_retr(-1, sd);
  5513. if (map[sd->bl.m].flag.fireworks) {
  5514. map[sd->bl.m].flag.fireworks=0;
  5515. clif_weather(sd->bl.m);
  5516. clif_displaymessage(fd, "Fireworks are ended.");
  5517. } else {
  5518. map[sd->bl.m].flag.fireworks=1;
  5519. clif_weather(sd->bl.m);
  5520. clif_displaymessage(fd, "Fireworks are launched.");
  5521. }
  5522. return 0;
  5523. }
  5524. /*==========================================
  5525. * Clearing Weather Effects by Dexity
  5526. *------------------------------------------*/
  5527. ACMD_FUNC(clearweather)
  5528. {
  5529. nullpo_retr(-1, sd);
  5530. /**
  5531. * No longer available, keeping here just in case it's back someday. [Ind]
  5532. **/
  5533. //map[sd->bl.m].flag.rain=0;
  5534. map[sd->bl.m].flag.snow=0;
  5535. map[sd->bl.m].flag.sakura=0;
  5536. map[sd->bl.m].flag.clouds=0;
  5537. map[sd->bl.m].flag.clouds2=0;
  5538. map[sd->bl.m].flag.fog=0;
  5539. map[sd->bl.m].flag.fireworks=0;
  5540. map[sd->bl.m].flag.leaves=0;
  5541. clif_weather(sd->bl.m);
  5542. clif_displaymessage(fd, msg_txt(291));
  5543. return 0;
  5544. }
  5545. /*===============================================================
  5546. * Sound Command - plays a sound for everyone around! [Codemaster]
  5547. *---------------------------------------------------------------*/
  5548. ACMD_FUNC(sound)
  5549. {
  5550. char sound_file[100];
  5551. memset(sound_file, '\0', sizeof(sound_file));
  5552. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5553. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5554. return -1;
  5555. }
  5556. if(strstr(sound_file, ".wav") == NULL)
  5557. strcat(sound_file, ".wav");
  5558. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5559. return 0;
  5560. }
  5561. /*==========================================
  5562. * MOB Search
  5563. *------------------------------------------*/
  5564. ACMD_FUNC(mobsearch)
  5565. {
  5566. char mob_name[100];
  5567. int mob_id;
  5568. int number = 0;
  5569. struct s_mapiterator* it;
  5570. nullpo_retr(-1, sd);
  5571. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5572. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5573. return -1;
  5574. }
  5575. if ((mob_id = atoi(mob_name)) == 0)
  5576. mob_id = mobdb_searchname(mob_name);
  5577. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5578. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5579. clif_displaymessage(fd, atcmd_output);
  5580. return -1;
  5581. }
  5582. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5583. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5584. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5585. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5586. clif_displaymessage(fd, atcmd_output);
  5587. it = mapit_geteachmob();
  5588. for(;;)
  5589. {
  5590. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5591. if( md == NULL )
  5592. break;// no more mobs
  5593. if( md->bl.m != sd->bl.m )
  5594. continue;
  5595. if( mob_id != -1 && md->class_ != mob_id )
  5596. continue;
  5597. ++number;
  5598. if( md->spawn_timer == INVALID_TIMER )
  5599. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5600. else
  5601. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5602. clif_displaymessage(fd, atcmd_output);
  5603. }
  5604. mapit_free(it);
  5605. return 0;
  5606. }
  5607. /*==========================================
  5608. * @cleanmap - cleans items on the ground
  5609. *------------------------------------------*/
  5610. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5611. {
  5612. nullpo_ret(bl);
  5613. map_clearflooritem(bl->id);
  5614. return 0;
  5615. }
  5616. ACMD_FUNC(cleanmap)
  5617. {
  5618. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5619. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5620. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5621. BL_ITEM);
  5622. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5623. return 0;
  5624. }
  5625. /*==========================================
  5626. * make a NPC/PET talk
  5627. * @npctalkc [SnakeDrak]
  5628. *------------------------------------------*/
  5629. ACMD_FUNC(npctalk)
  5630. {
  5631. char name[NAME_LENGTH],mes[100],temp[100];
  5632. struct npc_data *nd;
  5633. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5634. unsigned long color=0;
  5635. if (sd->sc.count && //no "chatting" while muted.
  5636. (sd->sc.data[SC_BERSERK] ||
  5637. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5638. return -1;
  5639. if(!ifcolor) {
  5640. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5641. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5642. return -1;
  5643. }
  5644. }
  5645. else {
  5646. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5647. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  5648. return -1;
  5649. }
  5650. }
  5651. if (!(nd = npc_name2id(name))) {
  5652. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5653. return -1;
  5654. }
  5655. strtok(name, "#"); // discard extra name identifier if present
  5656. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5657. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5658. else clif_message(&nd->bl, temp);
  5659. return 0;
  5660. }
  5661. ACMD_FUNC(pettalk)
  5662. {
  5663. char mes[100],temp[100];
  5664. struct pet_data *pd;
  5665. nullpo_retr(-1, sd);
  5666. if(!sd->status.pet_id || !(pd=sd->pd))
  5667. {
  5668. clif_displaymessage(fd, msg_txt(184));
  5669. return -1;
  5670. }
  5671. if (sd->sc.count && //no "chatting" while muted.
  5672. (sd->sc.data[SC_BERSERK] ||
  5673. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5674. return -1;
  5675. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5676. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5677. return -1;
  5678. }
  5679. if (message[0] == '/')
  5680. {// pet emotion processing
  5681. const char* emo[] = {
  5682. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5683. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5684. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5685. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5686. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5687. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5688. };
  5689. int i;
  5690. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5691. if( i < ARRAYLENGTH(emo) )
  5692. {
  5693. clif_emotion(&pd->bl, i);
  5694. return 0;
  5695. }
  5696. }
  5697. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5698. clif_message(&pd->bl, temp);
  5699. return 0;
  5700. }
  5701. /// @users - displays the number of players present on each map (and percentage)
  5702. /// #users displays on the target user instead of self
  5703. ACMD_FUNC(users)
  5704. {
  5705. char buf[CHAT_SIZE_MAX];
  5706. int i;
  5707. int users[MAX_MAPINDEX];
  5708. int users_all;
  5709. struct s_mapiterator* iter;
  5710. memset(users, 0, sizeof(users));
  5711. users_all = 0;
  5712. // count users on each map
  5713. iter = mapit_getallusers();
  5714. for(;;)
  5715. {
  5716. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5717. if( sd2 == NULL )
  5718. break;// no more users
  5719. if( sd2->mapindex >= MAX_MAPINDEX )
  5720. continue;// invalid mapindex
  5721. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5722. if( users_all < INT_MAX ) ++users_all;
  5723. }
  5724. mapit_free(iter);
  5725. // display results for each map
  5726. for( i = 0; i < MAX_MAPINDEX; ++i )
  5727. {
  5728. if( users[i] == 0 )
  5729. continue;// empty
  5730. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5731. clif_displaymessage(sd->fd, buf);
  5732. }
  5733. // display overall count
  5734. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5735. clif_displaymessage(sd->fd, buf);
  5736. return 0;
  5737. }
  5738. /*==========================================
  5739. *
  5740. *------------------------------------------*/
  5741. ACMD_FUNC(reset)
  5742. {
  5743. pc_resetstate(sd);
  5744. pc_resetskill(sd,1);
  5745. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5746. clif_displaymessage(fd, atcmd_output);
  5747. return 0;
  5748. }
  5749. /*==========================================
  5750. *
  5751. *------------------------------------------*/
  5752. ACMD_FUNC(summon)
  5753. {
  5754. char name[NAME_LENGTH];
  5755. int mob_id = 0;
  5756. int duration = 0;
  5757. struct mob_data *md;
  5758. unsigned int tick=gettick();
  5759. nullpo_retr(-1, sd);
  5760. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5761. {
  5762. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5763. return -1;
  5764. }
  5765. if (duration < 1)
  5766. duration =1;
  5767. else if (duration > 60)
  5768. duration =60;
  5769. if ((mob_id = atoi(name)) == 0)
  5770. mob_id = mobdb_searchname(name);
  5771. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5772. {
  5773. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5774. return -1;
  5775. }
  5776. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5777. if(!md)
  5778. return -1;
  5779. md->master_id=sd->bl.id;
  5780. md->special_state.ai=1;
  5781. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5782. clif_specialeffect(&md->bl,344,AREA);
  5783. mob_spawn(md);
  5784. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5785. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5786. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5787. return 0;
  5788. }
  5789. /*==========================================
  5790. * @adjcmdlvl by [MouseJstr]
  5791. *
  5792. * Temp adjust the GM level required to use a GM command
  5793. * Useful during beta testing to allow players to use GM commands for short periods of time
  5794. *------------------------------------------*/
  5795. ACMD_FUNC(adjcmdlvl)
  5796. {
  5797. int newlev, newremotelev;
  5798. char name[100];
  5799. AtCommandInfo* cmd;
  5800. nullpo_retr(-1, sd);
  5801. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  5802. {
  5803. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  5804. return -1;
  5805. }
  5806. cmd = get_atcommandinfo_byname(name);
  5807. if (cmd == NULL)
  5808. {
  5809. clif_displaymessage(fd, "@command not found.");
  5810. return -1;
  5811. }
  5812. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  5813. {
  5814. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5815. return -1;
  5816. }
  5817. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  5818. {
  5819. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5820. return -1;
  5821. }
  5822. else
  5823. {
  5824. cmd->level = newlev;
  5825. cmd->level2 = newremotelev;
  5826. clif_displaymessage(fd, "@command level changed.");
  5827. return 0;
  5828. }
  5829. }
  5830. /*==========================================
  5831. * @adjgmlvl by [MouseJstr]
  5832. * Create a temp GM
  5833. * Useful during beta testing to allow players to use GM commands for short periods of time
  5834. *------------------------------------------*/
  5835. ACMD_FUNC(adjgmlvl)
  5836. {
  5837. int newlev;
  5838. char user[NAME_LENGTH];
  5839. struct map_session_data *pl_sd;
  5840. nullpo_retr(-1, sd);
  5841. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5842. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5843. return -1;
  5844. }
  5845. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5846. {
  5847. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5848. return -1;
  5849. }
  5850. pl_sd->gmlevel = newlev;
  5851. return 0;
  5852. }
  5853. /*==========================================
  5854. * @trade by [MouseJstr]
  5855. * Open a trade window with a remote player
  5856. *------------------------------------------*/
  5857. ACMD_FUNC(trade)
  5858. {
  5859. struct map_session_data *pl_sd = NULL;
  5860. nullpo_retr(-1, sd);
  5861. if (!message || !*message) {
  5862. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5863. return -1;
  5864. }
  5865. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5866. {
  5867. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5868. return -1;
  5869. }
  5870. trade_traderequest(sd, pl_sd);
  5871. return 0;
  5872. }
  5873. /*==========================================
  5874. * @setbattleflag by [MouseJstr]
  5875. * set a battle_config flag without having to reboot
  5876. *------------------------------------------*/
  5877. ACMD_FUNC(setbattleflag)
  5878. {
  5879. char flag[128], value[128];
  5880. nullpo_retr(-1, sd);
  5881. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5882. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5883. return -1;
  5884. }
  5885. if (battle_set_value(flag, value) == 0)
  5886. {
  5887. clif_displaymessage(fd, "unknown battle_config flag");
  5888. return -1;
  5889. }
  5890. clif_displaymessage(fd, "battle_config set as requested");
  5891. return 0;
  5892. }
  5893. /*==========================================
  5894. * @unmute [Valaris]
  5895. *------------------------------------------*/
  5896. ACMD_FUNC(unmute)
  5897. {
  5898. struct map_session_data *pl_sd = NULL;
  5899. nullpo_retr(-1, sd);
  5900. if (!message || !*message) {
  5901. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5902. return -1;
  5903. }
  5904. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5905. {
  5906. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5907. return -1;
  5908. }
  5909. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5910. clif_displaymessage(sd->fd,"Player is not muted");
  5911. return -1;
  5912. }
  5913. pl_sd->status.manner = 0;
  5914. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5915. clif_displaymessage(sd->fd,"Player unmuted");
  5916. return 0;
  5917. }
  5918. /*==========================================
  5919. * @uptime by MC Cameri
  5920. *------------------------------------------*/
  5921. ACMD_FUNC(uptime)
  5922. {
  5923. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5924. minute = 60, days = 0, hours = 0, minutes = 0;
  5925. nullpo_retr(-1, sd);
  5926. seconds = get_uptime();
  5927. days = seconds/day;
  5928. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5929. hours = seconds/hour;
  5930. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5931. minutes = seconds/minute;
  5932. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5933. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5934. clif_displaymessage(fd, atcmd_output);
  5935. return 0;
  5936. }
  5937. /*==========================================
  5938. * @changesex <sex>
  5939. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5940. *------------------------------------------*/
  5941. ACMD_FUNC(changesex)
  5942. {
  5943. nullpo_retr(-1, sd);
  5944. chrif_changesex(sd);
  5945. return 0;
  5946. }
  5947. /*================================================
  5948. * @mute - Mutes a player for a set amount of time
  5949. *------------------------------------------------*/
  5950. ACMD_FUNC(mute)
  5951. {
  5952. struct map_session_data *pl_sd = NULL;
  5953. int manner;
  5954. nullpo_retr(-1, sd);
  5955. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5956. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5957. return -1;
  5958. }
  5959. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5960. {
  5961. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5962. return -1;
  5963. }
  5964. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5965. {
  5966. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5967. return -1;
  5968. }
  5969. clif_manner_message(sd, 0);
  5970. clif_manner_message(pl_sd, 5);
  5971. if( pl_sd->status.manner < manner ) {
  5972. pl_sd->status.manner -= manner;
  5973. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5974. } else {
  5975. pl_sd->status.manner = 0;
  5976. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5977. }
  5978. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5979. return 0;
  5980. }
  5981. /*==========================================
  5982. * @refresh (like @jumpto <<yourself>>)
  5983. *------------------------------------------*/
  5984. ACMD_FUNC(refresh)
  5985. {
  5986. nullpo_retr(-1, sd);
  5987. clif_refresh(sd);
  5988. return 0;
  5989. }
  5990. /*==========================================
  5991. * @identify
  5992. * => GM's magnifier.
  5993. *------------------------------------------*/
  5994. ACMD_FUNC(identify)
  5995. {
  5996. int i,num;
  5997. nullpo_retr(-1, sd);
  5998. for(i=num=0;i<MAX_INVENTORY;i++){
  5999. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6000. num++;
  6001. }
  6002. }
  6003. if (num > 0) {
  6004. clif_item_identify_list(sd);
  6005. } else {
  6006. clif_displaymessage(fd,"There are no items to appraise.");
  6007. }
  6008. return 0;
  6009. }
  6010. /*==========================================
  6011. * @gmotd (Global MOTD)
  6012. * by davidsiaw :P
  6013. *------------------------------------------*/
  6014. ACMD_FUNC(gmotd)
  6015. {
  6016. char buf[CHAT_SIZE_MAX];
  6017. size_t len;
  6018. FILE* fp;
  6019. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6020. {
  6021. while( fgets(buf, sizeof(buf), fp) )
  6022. {
  6023. if( buf[0] == '/' && buf[1] == '/' )
  6024. {
  6025. continue;
  6026. }
  6027. len = strlen(buf);
  6028. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6029. {// strip trailing EOL characters
  6030. len--;
  6031. }
  6032. if( len )
  6033. {
  6034. buf[len] = 0;
  6035. intif_broadcast(buf, len+1, 0);
  6036. }
  6037. }
  6038. fclose(fp);
  6039. }
  6040. return 0;
  6041. }
  6042. ACMD_FUNC(misceffect)
  6043. {
  6044. int effect = 0;
  6045. nullpo_retr(-1, sd);
  6046. if (!message || !*message)
  6047. return -1;
  6048. if (sscanf(message, "%d", &effect) < 1)
  6049. return -1;
  6050. clif_misceffect(&sd->bl,effect);
  6051. return 0;
  6052. }
  6053. /*==========================================
  6054. * MAIL SYSTEM
  6055. *------------------------------------------*/
  6056. ACMD_FUNC(mail)
  6057. {
  6058. nullpo_ret(sd);
  6059. #ifndef TXT_ONLY
  6060. mail_openmail(sd);
  6061. #endif
  6062. return 0;
  6063. }
  6064. /*==========================================
  6065. * Show Monster DB Info v 1.0
  6066. * originally by [Lupus] eAthena
  6067. *------------------------------------------*/
  6068. ACMD_FUNC(mobinfo)
  6069. {
  6070. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  6071. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  6072. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  6073. char atcmd_output2[CHAT_SIZE_MAX];
  6074. struct item_data *item_data;
  6075. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6076. int count;
  6077. int i, j, k;
  6078. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6079. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6080. if (!message || !*message) {
  6081. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  6082. return -1;
  6083. }
  6084. // If monster identifier/name argument is a name
  6085. if ((i = mobdb_checkid(atoi(message))))
  6086. {
  6087. mob_array[0] = mob_db(i);
  6088. count = 1;
  6089. } else
  6090. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6091. if (!count) {
  6092. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6093. return -1;
  6094. }
  6095. if (count > MAX_SEARCH) {
  6096. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6097. clif_displaymessage(fd, atcmd_output);
  6098. count = MAX_SEARCH;
  6099. }
  6100. for (k = 0; k < count; k++) {
  6101. mob = mob_array[k];
  6102. // stats
  6103. if (mob->mexp)
  6104. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6105. else
  6106. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6107. clif_displaymessage(fd, atcmd_output);
  6108. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  6109. clif_displaymessage(fd, atcmd_output);
  6110. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  6111. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  6112. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6113. clif_displaymessage(fd, atcmd_output);
  6114. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  6115. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6116. mob->range2 , mob->range3, msize[mob->status.size],
  6117. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6118. clif_displaymessage(fd, atcmd_output);
  6119. // drops
  6120. clif_displaymessage(fd, " Drops:");
  6121. strcpy(atcmd_output, " ");
  6122. j = 0;
  6123. for (i = 0; i < MAX_MOB_DROP; i++) {
  6124. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6125. continue;
  6126. if (item_data->slot)
  6127. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  6128. else
  6129. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  6130. strcat(atcmd_output, atcmd_output2);
  6131. if (++j % 3 == 0) {
  6132. clif_displaymessage(fd, atcmd_output);
  6133. strcpy(atcmd_output, " ");
  6134. }
  6135. }
  6136. if (j == 0)
  6137. clif_displaymessage(fd, "This monster has no drops.");
  6138. else if (j % 3 != 0)
  6139. clif_displaymessage(fd, atcmd_output);
  6140. // mvp
  6141. if (mob->mexp) {
  6142. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  6143. clif_displaymessage(fd, atcmd_output);
  6144. strcpy(atcmd_output, " MVP Items:");
  6145. j = 0;
  6146. for (i = 0; i < 3; i++) {
  6147. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6148. continue;
  6149. if (mob->mvpitem[i].p > 0) {
  6150. j++;
  6151. if (j == 1)
  6152. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6153. else
  6154. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6155. strcat(atcmd_output, atcmd_output2);
  6156. }
  6157. }
  6158. if (j == 0)
  6159. clif_displaymessage(fd, "This monster has no MVP prizes.");
  6160. else
  6161. clif_displaymessage(fd, atcmd_output);
  6162. }
  6163. }
  6164. return 0;
  6165. }
  6166. /*=========================================
  6167. * @showmobs by KarLaeda
  6168. * => For 5 sec displays the mobs on minimap
  6169. *------------------------------------------*/
  6170. int atshowmobs_timer(int tid, unsigned int tick, int id, intptr_t data)
  6171. {
  6172. struct map_session_data* sd = map_id2sd(id);
  6173. if( sd == NULL )
  6174. return 0;
  6175. // remove indicator
  6176. clif_viewpoint(sd, 1, 2, 0, 0, (int)data, 0xFFFFFF);
  6177. return 1;
  6178. }
  6179. ACMD_FUNC(showmobs)
  6180. {
  6181. char mob_name[100];
  6182. int mob_id;
  6183. int number = 0;
  6184. struct s_mapiterator* it;
  6185. nullpo_retr(-1, sd);
  6186. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6187. return -1;
  6188. if((mob_id = atoi(mob_name)) == 0)
  6189. mob_id = mobdb_searchname(mob_name);
  6190. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6191. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6192. clif_displaymessage(fd, atcmd_output);
  6193. return 0;
  6194. }
  6195. // Uncomment the following line to show mini-bosses & MVP.
  6196. //#define SHOW_MVP
  6197. #ifndef SHOW_MVP
  6198. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6199. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6200. clif_displaymessage(fd, atcmd_output);
  6201. return 0;
  6202. }
  6203. #endif
  6204. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6205. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6206. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6207. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6208. mob_name, mapindex_id2name(sd->mapindex));
  6209. clif_displaymessage(fd, atcmd_output);
  6210. it = mapit_geteachmob();
  6211. for(;;)
  6212. {
  6213. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6214. if( md == NULL )
  6215. break;// no more mobs
  6216. if( md->bl.m != sd->bl.m )
  6217. continue;
  6218. if( mob_id != -1 && md->class_ != mob_id )
  6219. continue;
  6220. if( md->special_state.ai || md->master_id )
  6221. continue; // hide slaves and player summoned mobs
  6222. if( md->spawn_timer != INVALID_TIMER )
  6223. continue; // hide mobs waiting for respawn
  6224. ++number;
  6225. clif_viewpoint(sd, 1, 1, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6226. add_timer(gettick()+5000, atshowmobs_timer, sd->bl.id, number);
  6227. }
  6228. mapit_free(it);
  6229. return 0;
  6230. }
  6231. /*==========================================
  6232. * homunculus level up [orn]
  6233. *------------------------------------------*/
  6234. ACMD_FUNC(homlevel)
  6235. {
  6236. TBL_HOM * hd;
  6237. int level = 0, i = 0;
  6238. nullpo_retr(-1, sd);
  6239. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6240. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  6241. return -1;
  6242. }
  6243. if ( !merc_is_hom_active(sd->hd) ) {
  6244. clif_displaymessage(fd, "You do not have a homunculus.");
  6245. return -1;
  6246. }
  6247. hd = sd->hd;
  6248. for (i = 1; i <= level && hd->exp_next; i++){
  6249. hd->homunculus.exp += hd->exp_next;
  6250. merc_hom_levelup(hd);
  6251. }
  6252. status_calc_homunculus(hd,0);
  6253. status_percent_heal(&hd->bl, 100, 100);
  6254. clif_specialeffect(&hd->bl,568,AREA);
  6255. return 0;
  6256. }
  6257. /*==========================================
  6258. * homunculus evolution H [orn]
  6259. *------------------------------------------*/
  6260. ACMD_FUNC(homevolution)
  6261. {
  6262. nullpo_retr(-1, sd);
  6263. if ( !merc_is_hom_active(sd->hd) ) {
  6264. clif_displaymessage(fd, "You do not have a homunculus.");
  6265. return -1;
  6266. }
  6267. if ( !merc_hom_evolution(sd->hd) ) {
  6268. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6269. return -1;
  6270. }
  6271. return 0;
  6272. }
  6273. /*==========================================
  6274. * call choosen homunculus [orn]
  6275. *------------------------------------------*/
  6276. ACMD_FUNC(makehomun)
  6277. {
  6278. int homunid;
  6279. nullpo_retr(-1, sd);
  6280. if ( sd->status.hom_id ) {
  6281. clif_displaymessage(fd, msg_txt(450));
  6282. return -1;
  6283. }
  6284. if (!message || !*message) {
  6285. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6286. return -1;
  6287. }
  6288. homunid = atoi(message);
  6289. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6290. {
  6291. clif_displaymessage(fd, "Invalid Homunculus id.");
  6292. return -1;
  6293. }
  6294. merc_create_homunculus_request(sd,homunid);
  6295. return 0;
  6296. }
  6297. /*==========================================
  6298. * modify homunculus intimacy [orn]
  6299. *------------------------------------------*/
  6300. ACMD_FUNC(homfriendly)
  6301. {
  6302. int friendly = 0;
  6303. nullpo_retr(-1, sd);
  6304. if ( !merc_is_hom_active(sd->hd) ) {
  6305. clif_displaymessage(fd, "You do not have a homunculus.");
  6306. return -1;
  6307. }
  6308. if (!message || !*message) {
  6309. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6310. return -1;
  6311. }
  6312. friendly = atoi(message);
  6313. friendly = cap_value(friendly, 0, 1000);
  6314. sd->hd->homunculus.intimacy = friendly * 100 ;
  6315. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6316. return 0;
  6317. }
  6318. /*==========================================
  6319. * modify homunculus hunger [orn]
  6320. *------------------------------------------*/
  6321. ACMD_FUNC(homhungry)
  6322. {
  6323. int hungry = 0;
  6324. nullpo_retr(-1, sd);
  6325. if ( !merc_is_hom_active(sd->hd) ) {
  6326. clif_displaymessage(fd, "You do not have a homunculus.");
  6327. return -1;
  6328. }
  6329. if (!message || !*message) {
  6330. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6331. return -1;
  6332. }
  6333. hungry = atoi(message);
  6334. hungry = cap_value(hungry, 0, 100);
  6335. sd->hd->homunculus.hunger = hungry;
  6336. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6337. return 0;
  6338. }
  6339. /*==========================================
  6340. * make the homunculus speak [orn]
  6341. *------------------------------------------*/
  6342. ACMD_FUNC(homtalk)
  6343. {
  6344. char mes[100],temp[100];
  6345. nullpo_retr(-1, sd);
  6346. if (sd->sc.count && //no "chatting" while muted.
  6347. (sd->sc.data[SC_BERSERK] ||
  6348. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6349. return -1;
  6350. if ( !merc_is_hom_active(sd->hd) ) {
  6351. clif_displaymessage(fd, "You do not have a homunculus.");
  6352. return -1;
  6353. }
  6354. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6355. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6356. return -1;
  6357. }
  6358. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6359. clif_message(&sd->hd->bl, temp);
  6360. return 0;
  6361. }
  6362. /*==========================================
  6363. * Show homunculus stats
  6364. *------------------------------------------*/
  6365. ACMD_FUNC(hominfo)
  6366. {
  6367. struct homun_data *hd;
  6368. struct status_data *status;
  6369. nullpo_retr(-1, sd);
  6370. if ( !merc_is_hom_active(sd->hd) ) {
  6371. clif_displaymessage(fd, "You do not have a homunculus.");
  6372. return -1;
  6373. }
  6374. hd = sd->hd;
  6375. status = status_get_status_data(&hd->bl);
  6376. clif_displaymessage(fd, "Homunculus stats :");
  6377. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6378. status->hp, status->max_hp, status->sp, status->max_sp);
  6379. clif_displaymessage(fd, atcmd_output);
  6380. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6381. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6382. clif_displaymessage(fd, atcmd_output);
  6383. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6384. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6385. clif_displaymessage(fd, atcmd_output);
  6386. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6387. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6388. status->str, status->agi, status->vit,
  6389. status->int_, status->dex, status->luk);
  6390. clif_displaymessage(fd, atcmd_output);
  6391. return 0;
  6392. }
  6393. ACMD_FUNC(homstats)
  6394. {
  6395. struct homun_data *hd;
  6396. struct s_homunculus_db *db;
  6397. struct s_homunculus *hom;
  6398. int lv, min, max, evo;
  6399. nullpo_retr(-1, sd);
  6400. if ( !merc_is_hom_active(sd->hd) ) {
  6401. clif_displaymessage(fd, "You do not have a homunculus.");
  6402. return -1;
  6403. }
  6404. hd = sd->hd;
  6405. hom = &hd->homunculus;
  6406. db = hd->homunculusDB;
  6407. lv = hom->level;
  6408. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6409. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6410. clif_displaymessage(fd, atcmd_output);
  6411. lv--; //Since the first increase is at level 2.
  6412. evo = (hom->class_ == db->evo_class);
  6413. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6414. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6415. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6416. clif_displaymessage(fd, atcmd_output);
  6417. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6418. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6419. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6420. clif_displaymessage(fd, atcmd_output);
  6421. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6422. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6423. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6424. clif_displaymessage(fd, atcmd_output);
  6425. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6426. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6427. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6428. clif_displaymessage(fd, atcmd_output);
  6429. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6430. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6431. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6432. clif_displaymessage(fd, atcmd_output);
  6433. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6434. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6435. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6436. clif_displaymessage(fd, atcmd_output);
  6437. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6438. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6439. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6440. clif_displaymessage(fd, atcmd_output);
  6441. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6442. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6443. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6444. clif_displaymessage(fd, atcmd_output);
  6445. return 0;
  6446. }
  6447. ACMD_FUNC(homshuffle)
  6448. {
  6449. nullpo_retr(-1, sd);
  6450. if(!sd->hd)
  6451. return -1; // nothing to do
  6452. if(!merc_hom_shuffle(sd->hd))
  6453. return -1;
  6454. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6455. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6456. return 0;
  6457. }
  6458. /*==========================================
  6459. * Show Items DB Info v 1.0
  6460. * originally by [Lupus] eAthena
  6461. *------------------------------------------*/
  6462. ACMD_FUNC(iteminfo)
  6463. {
  6464. struct item_data *item_data, *item_array[MAX_SEARCH];
  6465. int i, count = 1;
  6466. if (!message || !*message) {
  6467. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6468. return -1;
  6469. }
  6470. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6471. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6472. if (!count) {
  6473. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6474. return -1;
  6475. }
  6476. if (count > MAX_SEARCH) {
  6477. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6478. clif_displaymessage(fd, atcmd_output);
  6479. count = MAX_SEARCH;
  6480. }
  6481. for (i = 0; i < count; i++) {
  6482. item_data = item_array[i];
  6483. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6484. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6485. itemdb_typename(item_data->type),
  6486. (item_data->script==NULL)? "None" : "With script"
  6487. );
  6488. clif_displaymessage(fd, atcmd_output);
  6489. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  6490. clif_displaymessage(fd, atcmd_output);
  6491. if (item_data->maxchance == -1)
  6492. strcpy(atcmd_output, " - Available in the shops only.");
  6493. else if (item_data->maxchance)
  6494. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6495. else
  6496. strcpy(atcmd_output, " - Monsters don't drop this item.");
  6497. clif_displaymessage(fd, atcmd_output);
  6498. }
  6499. return 0;
  6500. }
  6501. /*==========================================
  6502. * Show who drops the item.
  6503. *------------------------------------------*/
  6504. ACMD_FUNC(whodrops)
  6505. {
  6506. struct item_data *item_data, *item_array[MAX_SEARCH];
  6507. int i,j, count = 1;
  6508. if (!message || !*message) {
  6509. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6510. return -1;
  6511. }
  6512. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6513. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6514. if (!count) {
  6515. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6516. return -1;
  6517. }
  6518. if (count > MAX_SEARCH) {
  6519. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6520. clif_displaymessage(fd, atcmd_output);
  6521. count = MAX_SEARCH;
  6522. }
  6523. for (i = 0; i < count; i++) {
  6524. item_data = item_array[i];
  6525. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6526. clif_displaymessage(fd, atcmd_output);
  6527. if (item_data->mob[0].chance == 0) {
  6528. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6529. clif_displaymessage(fd, atcmd_output);
  6530. } else {
  6531. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6532. clif_displaymessage(fd, atcmd_output);
  6533. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6534. {
  6535. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6536. clif_displaymessage(fd, atcmd_output);
  6537. }
  6538. }
  6539. }
  6540. return 0;
  6541. }
  6542. ACMD_FUNC(whereis)
  6543. {
  6544. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6545. int count;
  6546. int i, j, k;
  6547. if (!message || !*message) {
  6548. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6549. return -1;
  6550. }
  6551. // If monster identifier/name argument is a name
  6552. if ((i = mobdb_checkid(atoi(message))))
  6553. {
  6554. mob_array[0] = mob_db(i);
  6555. count = 1;
  6556. } else
  6557. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6558. if (!count) {
  6559. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6560. return -1;
  6561. }
  6562. if (count > MAX_SEARCH) {
  6563. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6564. clif_displaymessage(fd, atcmd_output);
  6565. count = MAX_SEARCH;
  6566. }
  6567. for (k = 0; k < count; k++) {
  6568. mob = mob_array[k];
  6569. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6570. clif_displaymessage(fd, atcmd_output);
  6571. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6572. {
  6573. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6574. if (j < 0) continue;
  6575. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6576. clif_displaymessage(fd, atcmd_output);
  6577. }
  6578. if (i == 0)
  6579. clif_displaymessage(fd, "This monster does not spawn normally.");
  6580. }
  6581. return 0;
  6582. }
  6583. /*==========================================
  6584. * @adopt by [Veider]
  6585. * adopt a novice
  6586. *------------------------------------------*/
  6587. ACMD_FUNC(adopt)
  6588. {
  6589. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6590. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6591. char output[CHAT_SIZE_MAX];
  6592. nullpo_retr(-1, sd);
  6593. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6594. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6595. return -1;
  6596. }
  6597. if (battle_config.etc_log)
  6598. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6599. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6600. sprintf(output, "Cannot find player %s online", player1);
  6601. clif_displaymessage(fd, output);
  6602. return -1;
  6603. }
  6604. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6605. sprintf(output, "Cannot find player %s online", player2);
  6606. clif_displaymessage(fd, output);
  6607. return -1;
  6608. }
  6609. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6610. sprintf(output, "Cannot find player %s online", player3);
  6611. clif_displaymessage(fd, output);
  6612. return -1;
  6613. }
  6614. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6615. return -1;
  6616. }
  6617. clif_displaymessage(fd, "They are family... wish them luck");
  6618. return 0;
  6619. }
  6620. ACMD_FUNC(version)
  6621. {
  6622. const char * revision;
  6623. if ((revision = get_svn_revision()) != 0) {
  6624. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6625. clif_displaymessage(fd,atcmd_output);
  6626. } else
  6627. clif_displaymessage(fd,"Cannot determine SVN revision");
  6628. return 0;
  6629. }
  6630. /*==========================================
  6631. * @mutearea by MouseJstr
  6632. *------------------------------------------*/
  6633. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6634. {
  6635. int time, id;
  6636. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6637. if (pl_sd == NULL)
  6638. return 0;
  6639. id = va_arg(ap, int);
  6640. time = va_arg(ap, int);
  6641. if (id != bl->id && !pc_isGM(pl_sd)) {
  6642. pl_sd->status.manner -= time;
  6643. if (pl_sd->status.manner < 0)
  6644. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6645. else
  6646. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6647. }
  6648. return 0;
  6649. }
  6650. ACMD_FUNC(mutearea)
  6651. {
  6652. int time;
  6653. nullpo_ret(sd);
  6654. if (!message || !*message) {
  6655. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6656. return -1;
  6657. }
  6658. time = atoi(message);
  6659. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6660. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6661. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6662. return 0;
  6663. }
  6664. ACMD_FUNC(rates)
  6665. {
  6666. char buf[CHAT_SIZE_MAX];
  6667. nullpo_ret(sd);
  6668. memset(buf, '\0', sizeof(buf));
  6669. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  6670. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6671. clif_displaymessage(fd, buf);
  6672. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6673. battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
  6674. clif_displaymessage(fd, buf);
  6675. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6676. battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
  6677. clif_displaymessage(fd, buf);
  6678. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  6679. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6680. clif_displaymessage(fd, buf);
  6681. return 0;
  6682. }
  6683. /*==========================================
  6684. * @me by lordalfa
  6685. * => Displays the OUTPUT string on top of the Visible players Heads.
  6686. *------------------------------------------*/
  6687. ACMD_FUNC(me)
  6688. {
  6689. char tempmes[CHAT_SIZE_MAX];
  6690. nullpo_retr(-1, sd);
  6691. memset(tempmes, '\0', sizeof(tempmes));
  6692. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6693. if (sd->sc.count && //no "chatting" while muted.
  6694. (sd->sc.data[SC_BERSERK] ||
  6695. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6696. return -1;
  6697. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6698. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6699. return -1;
  6700. }
  6701. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6702. clif_disp_overhead(sd, atcmd_output);
  6703. return 0;
  6704. }
  6705. /*==========================================
  6706. * @size
  6707. * => Resize your character sprite. [Valaris]
  6708. *------------------------------------------*/
  6709. ACMD_FUNC(size)
  6710. {
  6711. int size=0;
  6712. nullpo_retr(-1, sd);
  6713. size = atoi(message);
  6714. if(sd->state.size) {
  6715. sd->state.size=0;
  6716. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6717. }
  6718. if(size==1) {
  6719. sd->state.size=1;
  6720. clif_specialeffect(&sd->bl,420,AREA);
  6721. } else if(size==2) {
  6722. sd->state.size=2;
  6723. clif_specialeffect(&sd->bl,422,AREA);
  6724. }
  6725. return 0;
  6726. }
  6727. /*==========================================
  6728. * @monsterignore
  6729. * => Makes monsters ignore you. [Valaris]
  6730. *------------------------------------------*/
  6731. ACMD_FUNC(monsterignore)
  6732. {
  6733. nullpo_retr(-1, sd);
  6734. if (!sd->state.monster_ignore) {
  6735. sd->state.monster_ignore = 1;
  6736. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6737. } else {
  6738. sd->state.monster_ignore = 0;
  6739. clif_displaymessage(sd->fd, "Returned to normal state.");
  6740. }
  6741. return 0;
  6742. }
  6743. /*==========================================
  6744. * @fakename
  6745. * => Gives your character a fake name. [Valaris]
  6746. *------------------------------------------*/
  6747. ACMD_FUNC(fakename)
  6748. {
  6749. nullpo_retr(-1, sd);
  6750. if( !message || !*message )
  6751. {
  6752. if( sd->fakename[0] )
  6753. {
  6754. sd->fakename[0] = '\0';
  6755. clif_charnameack(0, &sd->bl);
  6756. clif_displaymessage(sd->fd, "Returned to real name.");
  6757. return 0;
  6758. }
  6759. clif_displaymessage(sd->fd, "You must enter a name.");
  6760. return -1;
  6761. }
  6762. if( strlen(message) < 2 )
  6763. {
  6764. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  6765. return -1;
  6766. }
  6767. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6768. clif_charnameack(0, &sd->bl);
  6769. clif_displaymessage(sd->fd, "Fake name enabled.");
  6770. return 0;
  6771. }
  6772. /*==========================================
  6773. * Ragnarok Resources
  6774. *------------------------------------------*/
  6775. ACMD_FUNC(mapflag) {
  6776. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6777. #define setflag( cmd ) \
  6778. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6779. map[ sd->bl.m ].flag.cmd = flag;\
  6780. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6781. clif_displaymessage(sd->fd,atcmd_output);\
  6782. return 0;\
  6783. }
  6784. unsigned char flag_name[100];
  6785. int flag=9,i;
  6786. nullpo_retr(-1, sd);
  6787. memset(flag_name, '\0', sizeof(flag_name));
  6788. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6789. clif_displaymessage(sd->fd,"Enabled Mapflags in this map:");
  6790. clif_displaymessage(sd->fd,"----------------------------------");
  6791. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6792. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6793. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6794. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6795. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6796. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6797. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6798. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6799. checkflag(nogo); checkflag(nobaseexp);
  6800. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6801. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6802. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6803. clif_displaymessage(sd->fd," ");
  6804. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off 1=On)");
  6805. clif_displaymessage(sd->fd,"Use: \"@mapflag available\" to list the available mapflags");
  6806. return 1;
  6807. }
  6808. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6809. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6810. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6811. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6812. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6813. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6814. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6815. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6816. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6817. setflag(nogo); setflag(nobaseexp);
  6818. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6819. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6820. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6821. clif_displaymessage(sd->fd,"Invalid flag name or flag");
  6822. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off | 1=On)");
  6823. clif_displaymessage(sd->fd,"Available Flags:");
  6824. clif_displaymessage(sd->fd,"----------------------------------");
  6825. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6826. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6827. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6828. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6829. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6830. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6831. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6832. #undef checkflag
  6833. #undef setflag
  6834. return 0;
  6835. }
  6836. /*===================================
  6837. * Remove some messages
  6838. *-----------------------------------*/
  6839. ACMD_FUNC(showexp)
  6840. {
  6841. if (sd->state.showexp) {
  6842. sd->state.showexp = 0;
  6843. clif_displaymessage(fd, "Gained exp will not be shown.");
  6844. return 0;
  6845. }
  6846. sd->state.showexp = 1;
  6847. clif_displaymessage(fd, "Gained exp is now shown");
  6848. return 0;
  6849. }
  6850. ACMD_FUNC(showzeny)
  6851. {
  6852. if (sd->state.showzeny) {
  6853. sd->state.showzeny = 0;
  6854. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6855. return 0;
  6856. }
  6857. sd->state.showzeny = 1;
  6858. clif_displaymessage(fd, "Gained zeny is now shown");
  6859. return 0;
  6860. }
  6861. ACMD_FUNC(showdelay)
  6862. {
  6863. if (sd->state.showdelay) {
  6864. sd->state.showdelay = 0;
  6865. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6866. return 0;
  6867. }
  6868. sd->state.showdelay = 1;
  6869. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6870. return 0;
  6871. }
  6872. /*==========================================
  6873. * Duel organizing functions [LuzZza]
  6874. *
  6875. * @duel [limit|nick] - create a duel
  6876. * @invite <nick> - invite player
  6877. * @accept - accept invitation
  6878. * @reject - reject invitation
  6879. * @leave - leave duel
  6880. *------------------------------------------*/
  6881. ACMD_FUNC(invite)
  6882. {
  6883. unsigned int did = sd->duel_group;
  6884. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6885. if(did <= 0) {
  6886. // "Duel: @invite without @duel."
  6887. clif_displaymessage(fd, msg_txt(350));
  6888. return 0;
  6889. }
  6890. if(duel_list[did].max_players_limit > 0 &&
  6891. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6892. // "Duel: Limit of players is reached."
  6893. clif_displaymessage(fd, msg_txt(351));
  6894. return 0;
  6895. }
  6896. if(target_sd == NULL) {
  6897. // "Duel: Player not found."
  6898. clif_displaymessage(fd, msg_txt(352));
  6899. return 0;
  6900. }
  6901. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6902. // "Duel: Player already in duel."
  6903. clif_displaymessage(fd, msg_txt(353));
  6904. return 0;
  6905. }
  6906. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6907. {
  6908. sprintf(atcmd_output, msg_txt(364), message);
  6909. clif_displaymessage(fd, atcmd_output);
  6910. return 0;
  6911. }
  6912. duel_invite(did, sd, target_sd);
  6913. // "Duel: Invitation has been sent."
  6914. clif_displaymessage(fd, msg_txt(354));
  6915. return 0;
  6916. }
  6917. ACMD_FUNC(duel)
  6918. {
  6919. char output[CHAT_SIZE_MAX];
  6920. unsigned int maxpl=0, newduel;
  6921. struct map_session_data *target_sd;
  6922. if(sd->duel_group > 0) {
  6923. duel_showinfo(sd->duel_group, sd);
  6924. return 0;
  6925. }
  6926. if(sd->duel_invite > 0) {
  6927. // "Duel: @duel without @reject."
  6928. clif_displaymessage(fd, msg_txt(355));
  6929. return 0;
  6930. }
  6931. if(!duel_checktime(sd)) {
  6932. // "Duel: You can take part in duel only one time per %d minutes."
  6933. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6934. clif_displaymessage(fd, output);
  6935. return 0;
  6936. }
  6937. if( message[0] ) {
  6938. if(sscanf(message, "%d", &maxpl) >= 1) {
  6939. if(maxpl < 2 || maxpl > 65535) {
  6940. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6941. return 0;
  6942. }
  6943. duel_create(sd, maxpl);
  6944. } else {
  6945. target_sd = map_nick2sd((char *)message);
  6946. if(target_sd != NULL) {
  6947. if((newduel = duel_create(sd, 2)) != -1) {
  6948. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6949. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6950. return 0;
  6951. }
  6952. duel_invite(newduel, sd, target_sd);
  6953. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6954. }
  6955. } else {
  6956. // "Duel: Player not found."
  6957. clif_displaymessage(fd, msg_txt(352));
  6958. return 0;
  6959. }
  6960. }
  6961. } else
  6962. duel_create(sd, 0);
  6963. return 0;
  6964. }
  6965. ACMD_FUNC(leave)
  6966. {
  6967. if(sd->duel_group <= 0) {
  6968. // "Duel: @leave without @duel."
  6969. clif_displaymessage(fd, msg_txt(358));
  6970. return 0;
  6971. }
  6972. duel_leave(sd->duel_group, sd);
  6973. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6974. return 0;
  6975. }
  6976. ACMD_FUNC(accept)
  6977. {
  6978. char output[CHAT_SIZE_MAX];
  6979. if(!duel_checktime(sd)) {
  6980. // "Duel: You can take part in duel only one time per %d minutes."
  6981. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6982. clif_displaymessage(fd, output);
  6983. return 0;
  6984. }
  6985. if(sd->duel_invite <= 0) {
  6986. // "Duel: @accept without invititation."
  6987. clif_displaymessage(fd, msg_txt(360));
  6988. return 0;
  6989. }
  6990. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  6991. {
  6992. // "Duel: Limit of players is reached."
  6993. clif_displaymessage(fd, msg_txt(351));
  6994. return 0;
  6995. }
  6996. duel_accept(sd->duel_invite, sd);
  6997. // "Duel: Invitation has been accepted."
  6998. clif_displaymessage(fd, msg_txt(361));
  6999. return 0;
  7000. }
  7001. ACMD_FUNC(reject)
  7002. {
  7003. if(sd->duel_invite <= 0) {
  7004. // "Duel: @reject without invititation."
  7005. clif_displaymessage(fd, msg_txt(362));
  7006. return 0;
  7007. }
  7008. duel_reject(sd->duel_invite, sd);
  7009. // "Duel: Invitation has been rejected."
  7010. clif_displaymessage(fd, msg_txt(363));
  7011. return 0;
  7012. }
  7013. /*===================================
  7014. * Cash Points
  7015. *-----------------------------------*/
  7016. ACMD_FUNC(cash)
  7017. {
  7018. char output[128];
  7019. int value;
  7020. nullpo_retr(-1, sd);
  7021. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7022. clif_displaymessage(fd, "Please, enter an amount.");
  7023. return -1;
  7024. }
  7025. if( !strcmpi(command+1,"cash") )
  7026. {
  7027. if( value > 0 ) {
  7028. pc_getcash(sd, value, 0);
  7029. sprintf(output, msg_txt(505), value, sd->cashPoints);
  7030. clif_disp_onlyself(sd, output, strlen(output));
  7031. } else {
  7032. pc_paycash(sd, -value, 0);
  7033. sprintf(output, msg_txt(410), value, sd->cashPoints);
  7034. clif_disp_onlyself(sd, output, strlen(output));
  7035. }
  7036. }
  7037. else
  7038. { // @points
  7039. if( value > 0 ) {
  7040. pc_getcash(sd, 0, value);
  7041. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  7042. clif_disp_onlyself(sd, output, strlen(output));
  7043. } else {
  7044. pc_paycash(sd, -value, -value);
  7045. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  7046. clif_disp_onlyself(sd, output, strlen(output));
  7047. }
  7048. }
  7049. return 0;
  7050. }
  7051. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7052. ACMD_FUNC(clone)
  7053. {
  7054. int x=0,y=0,flag=0,master=0,i=0;
  7055. struct map_session_data *pl_sd=NULL;
  7056. if (!message || !*message) {
  7057. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  7058. return 0;
  7059. }
  7060. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7061. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7062. return 0;
  7063. }
  7064. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  7065. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  7066. return 0;
  7067. }
  7068. if (strcmpi(command+1, "clone") == 0)
  7069. flag = 1;
  7070. else if (strcmpi(command+1, "slaveclone") == 0) {
  7071. flag = 2;
  7072. master = sd->bl.id;
  7073. if (battle_config.atc_slave_clone_limit
  7074. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7075. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  7076. return 0;
  7077. }
  7078. }
  7079. do {
  7080. x = sd->bl.x + (rand() % 10 - 5);
  7081. y = sd->bl.y + (rand() % 10 - 5);
  7082. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7083. if (i >= 10) {
  7084. x = sd->bl.x;
  7085. y = sd->bl.y;
  7086. }
  7087. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7088. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7089. return 0;
  7090. }
  7091. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7092. return 0;
  7093. }
  7094. /*===================================
  7095. * Main chat [LuzZza]
  7096. * Usage: @main <on|off|message>
  7097. *-----------------------------------*/
  7098. ACMD_FUNC(main)
  7099. {
  7100. if( message[0] ) {
  7101. if(strcmpi(message, "on") == 0) {
  7102. if(!sd->state.mainchat) {
  7103. sd->state.mainchat = 1;
  7104. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7105. } else {
  7106. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  7107. }
  7108. } else if(strcmpi(message, "off") == 0) {
  7109. if(sd->state.mainchat) {
  7110. sd->state.mainchat = 0;
  7111. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  7112. } else {
  7113. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  7114. }
  7115. } else {
  7116. if(!sd->state.mainchat) {
  7117. sd->state.mainchat = 1;
  7118. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7119. }
  7120. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  7121. clif_displaymessage(fd, msg_txt(387));
  7122. return -1;
  7123. }
  7124. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  7125. // I use 0xFE000000 color for signalizing that this message is
  7126. // main chat message. 0xFE000000 is invalid color, same using
  7127. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  7128. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
  7129. // Chat logging type 'M' / Main Chat
  7130. log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  7131. }
  7132. } else {
  7133. if(sd->state.mainchat)
  7134. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  7135. else
  7136. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  7137. }
  7138. return 0;
  7139. }
  7140. /*=====================================
  7141. * Autorejecting Invites/Deals [LuzZza]
  7142. * Usage: @noask
  7143. *-------------------------------------*/
  7144. ACMD_FUNC(noask)
  7145. {
  7146. if(sd->state.noask) {
  7147. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  7148. sd->state.noask = 0;
  7149. } else {
  7150. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  7151. sd->state.noask = 1;
  7152. }
  7153. return 0;
  7154. }
  7155. /*=====================================
  7156. * Send a @request message to all GMs of lowest_gm_level.
  7157. * Usage: @request <petition>
  7158. *-------------------------------------*/
  7159. ACMD_FUNC(request)
  7160. {
  7161. if (!message || !*message) {
  7162. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  7163. return -1;
  7164. }
  7165. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  7166. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  7167. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7168. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  7169. return 0;
  7170. }
  7171. /*==========================================
  7172. * Feel (SG save map) Reset [HiddenDragon]
  7173. *------------------------------------------*/
  7174. ACMD_FUNC(feelreset)
  7175. {
  7176. pc_resetfeel(sd);
  7177. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  7178. return 0;
  7179. }
  7180. /*==========================================
  7181. * AUCTION SYSTEM
  7182. *------------------------------------------*/
  7183. ACMD_FUNC(auction)
  7184. {
  7185. nullpo_ret(sd);
  7186. #ifndef TXT_ONLY
  7187. clif_Auction_openwindow(sd);
  7188. #endif
  7189. return 0;
  7190. }
  7191. /*==========================================
  7192. * Kill Steal Protection
  7193. *------------------------------------------*/
  7194. ACMD_FUNC(ksprotection)
  7195. {
  7196. nullpo_retr(-1,sd);
  7197. if( sd->state.noks ) {
  7198. sd->state.noks = 0;
  7199. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  7200. }
  7201. else
  7202. {
  7203. if( !message || !*message || !strcmpi(message, "party") )
  7204. { // Default is Party
  7205. sd->state.noks = 2;
  7206. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7207. }
  7208. else if( !strcmpi(message, "self") )
  7209. {
  7210. sd->state.noks = 1;
  7211. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7212. }
  7213. else if( !strcmpi(message, "guild") )
  7214. {
  7215. sd->state.noks = 3;
  7216. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7217. }
  7218. else
  7219. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  7220. }
  7221. clif_displaymessage(fd, atcmd_output);
  7222. return 0;
  7223. }
  7224. /*==========================================
  7225. * Map Kill Steal Protection Setting
  7226. *------------------------------------------*/
  7227. ACMD_FUNC(allowks)
  7228. {
  7229. nullpo_retr(-1,sd);
  7230. if( map[sd->bl.m].flag.allowks ) {
  7231. map[sd->bl.m].flag.allowks = 0;
  7232. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7233. } else {
  7234. map[sd->bl.m].flag.allowks = 1;
  7235. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7236. }
  7237. clif_displaymessage(fd, atcmd_output);
  7238. return 0;
  7239. }
  7240. ACMD_FUNC(resetstat)
  7241. {
  7242. nullpo_retr(-1, sd);
  7243. pc_resetstate(sd);
  7244. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  7245. clif_displaymessage(fd, atcmd_output);
  7246. return 0;
  7247. }
  7248. ACMD_FUNC(resetskill)
  7249. {
  7250. nullpo_retr(-1,sd);
  7251. pc_resetskill(sd,1);
  7252. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  7253. clif_displaymessage(fd, atcmd_output);
  7254. return 0;
  7255. }
  7256. /*==========================================
  7257. * #storagelist: Displays the items list of a player's storage.
  7258. * #cartlist: Displays contents of target's cart.
  7259. * #itemlist: Displays contents of target's inventory.
  7260. *------------------------------------------*/
  7261. ACMD_FUNC(itemlist)
  7262. {
  7263. int i, j, count, counter;
  7264. const char* location;
  7265. const struct item* items;
  7266. int size;
  7267. StringBuf buf;
  7268. nullpo_retr(-1, sd);
  7269. if( strcmp(command+1, "storagelist") == 0 )
  7270. {
  7271. location = "storage";
  7272. items = sd->status.storage.items;
  7273. size = MAX_STORAGE;
  7274. }
  7275. else
  7276. if( strcmp(command+1, "cartlist") == 0 )
  7277. {
  7278. location = "cart";
  7279. items = sd->status.cart;
  7280. size = MAX_CART;
  7281. }
  7282. else
  7283. if( strcmp(command+1, "itemlist") == 0 )
  7284. {
  7285. location = "inventory";
  7286. items = sd->status.inventory;
  7287. size = MAX_INVENTORY;
  7288. }
  7289. else
  7290. return 1;
  7291. StringBuf_Init(&buf);
  7292. count = 0; // total slots occupied
  7293. counter = 0; // total items found
  7294. for( i = 0; i < size; ++i )
  7295. {
  7296. const struct item* it = &items[i];
  7297. struct item_data* itd;
  7298. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7299. continue;
  7300. counter += it->amount;
  7301. count++;
  7302. if( count == 1 )
  7303. {
  7304. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  7305. clif_displaymessage(fd, StringBuf_Value(&buf));
  7306. StringBuf_Clear(&buf);
  7307. }
  7308. if( it->refine )
  7309. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7310. else
  7311. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7312. if( it->equip )
  7313. {
  7314. char equipstr[CHAT_SIZE_MAX];
  7315. strcpy(equipstr, " | equipped: ");
  7316. if( it->equip & EQP_GARMENT )
  7317. strcat(equipstr, "garment, ");
  7318. if( it->equip & EQP_ACC_L )
  7319. strcat(equipstr, "left accessory, ");
  7320. if( it->equip & EQP_ARMOR )
  7321. strcat(equipstr, "body/armor, ");
  7322. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7323. strcat(equipstr, "right hand, ");
  7324. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7325. strcat(equipstr, "left hand, ");
  7326. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7327. strcat(equipstr, "both hands, ");
  7328. if( it->equip & EQP_SHOES )
  7329. strcat(equipstr, "feet, ");
  7330. if( it->equip & EQP_ACC_R )
  7331. strcat(equipstr, "right accessory, ");
  7332. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7333. strcat(equipstr, "lower head, ");
  7334. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7335. strcat(equipstr, "top head, ");
  7336. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7337. strcat(equipstr, "lower/top head, ");
  7338. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7339. strcat(equipstr, "mid head, ");
  7340. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7341. strcat(equipstr, "lower/mid head, ");
  7342. if( (it->equip & EQP_HELM) == EQP_HELM )
  7343. strcat(equipstr, "lower/mid/top head, ");
  7344. // remove final ', '
  7345. equipstr[strlen(equipstr) - 2] = '\0';
  7346. StringBuf_AppendStr(&buf, equipstr);
  7347. }
  7348. clif_displaymessage(fd, StringBuf_Value(&buf));
  7349. StringBuf_Clear(&buf);
  7350. if( it->card[0] == CARD0_PET )
  7351. {// pet egg
  7352. if (it->card[3])
  7353. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7354. else
  7355. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7356. }
  7357. else
  7358. if(it->card[0] == CARD0_FORGE)
  7359. {// forged item
  7360. StringBuf_Printf(&buf, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f);
  7361. }
  7362. else
  7363. if(it->card[0] == CARD0_CREATE)
  7364. {// created item
  7365. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  7366. }
  7367. else
  7368. {// normal item
  7369. int counter2 = 0;
  7370. for( j = 0; j < itd->slot; ++j )
  7371. {
  7372. struct item_data* card;
  7373. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7374. continue;
  7375. counter2++;
  7376. if( counter2 == 1 )
  7377. StringBuf_AppendStr(&buf, " -> (card(s): ");
  7378. if( counter2 != 1 )
  7379. StringBuf_AppendStr(&buf, ", ");
  7380. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7381. }
  7382. if( counter2 > 0 )
  7383. StringBuf_AppendStr(&buf, ")");
  7384. }
  7385. if( StringBuf_Length(&buf) > 0 )
  7386. clif_displaymessage(fd, StringBuf_Value(&buf));
  7387. StringBuf_Clear(&buf);
  7388. }
  7389. if( count == 0 )
  7390. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  7391. else
  7392. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  7393. clif_displaymessage(fd, StringBuf_Value(&buf));
  7394. StringBuf_Destroy(&buf);
  7395. return 0;
  7396. }
  7397. ACMD_FUNC(stats)
  7398. {
  7399. char job_jobname[100];
  7400. char output[CHAT_SIZE_MAX];
  7401. int i;
  7402. struct {
  7403. const char* format;
  7404. int value;
  7405. } output_table[] = {
  7406. { "Base Level - %d", 0 },
  7407. { NULL, 0 },
  7408. { "Hp - %d", 0 },
  7409. { "MaxHp - %d", 0 },
  7410. { "Sp - %d", 0 },
  7411. { "MaxSp - %d", 0 },
  7412. { "Str - %3d", 0 },
  7413. { "Agi - %3d", 0 },
  7414. { "Vit - %3d", 0 },
  7415. { "Int - %3d", 0 },
  7416. { "Dex - %3d", 0 },
  7417. { "Luk - %3d", 0 },
  7418. { "Zeny - %d", 0 },
  7419. { "Free SK Points - %d", 0 },
  7420. { "JobChangeLvl - %d", 0 },
  7421. { NULL, 0 }
  7422. };
  7423. memset(job_jobname, '\0', sizeof(job_jobname));
  7424. memset(output, '\0', sizeof(output));
  7425. //direct array initialization with variables is not standard C compliant.
  7426. output_table[0].value = sd->status.base_level;
  7427. output_table[1].format = job_jobname;
  7428. output_table[1].value = sd->status.job_level;
  7429. output_table[2].value = sd->status.hp;
  7430. output_table[3].value = sd->status.max_hp;
  7431. output_table[4].value = sd->status.sp;
  7432. output_table[5].value = sd->status.max_sp;
  7433. output_table[6].value = sd->status.str;
  7434. output_table[7].value = sd->status.agi;
  7435. output_table[8].value = sd->status.vit;
  7436. output_table[9].value = sd->status.int_;
  7437. output_table[10].value = sd->status.dex;
  7438. output_table[11].value = sd->status.luk;
  7439. output_table[12].value = sd->status.zeny;
  7440. output_table[13].value = sd->status.skill_point;
  7441. output_table[14].value = sd->change_level;
  7442. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7443. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7444. clif_displaymessage(fd, output);
  7445. for (i = 0; output_table[i].format != NULL; i++) {
  7446. sprintf(output, output_table[i].format, output_table[i].value);
  7447. clif_displaymessage(fd, output);
  7448. }
  7449. return 0;
  7450. }
  7451. ACMD_FUNC(delitem)
  7452. {
  7453. char item_name[100];
  7454. int nameid, amount = 0, total, idx;
  7455. struct item_data* id;
  7456. nullpo_retr(-1, sd);
  7457. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7458. {
  7459. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  7460. return -1;
  7461. }
  7462. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7463. {
  7464. nameid = id->nameid;
  7465. }
  7466. else
  7467. {
  7468. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7469. return -1;
  7470. }
  7471. total = amount;
  7472. // delete items
  7473. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7474. {
  7475. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7476. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7477. {// delete pet
  7478. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7479. }
  7480. //Logs (A)dmins items [Lupus]
  7481. log_pick_pc(sd, LOG_TYPE_COMMAND, nameid, -delamount, &sd->status.inventory[idx]);
  7482. pc_delitem(sd, idx, delamount, 0, 0);
  7483. amount-= delamount;
  7484. }
  7485. // notify target
  7486. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7487. clif_displaymessage(sd->fd, atcmd_output);
  7488. // notify source
  7489. if( amount == total )
  7490. {
  7491. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7492. }
  7493. else if( amount )
  7494. {
  7495. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7496. clif_displaymessage(fd, atcmd_output);
  7497. }
  7498. else
  7499. {
  7500. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7501. clif_displaymessage(fd, atcmd_output);
  7502. }
  7503. return 0;
  7504. }
  7505. /*==========================================
  7506. * Custom Fonts
  7507. *------------------------------------------*/
  7508. ACMD_FUNC(font)
  7509. {
  7510. int font_id;
  7511. nullpo_retr(-1,sd);
  7512. font_id = atoi(message);
  7513. if( font_id == 0 )
  7514. {
  7515. if( sd->user_font )
  7516. {
  7517. sd->user_font = 0;
  7518. clif_displaymessage(fd, "Returning to normal font.");
  7519. clif_font(sd);
  7520. }
  7521. else
  7522. {
  7523. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  7524. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  7525. }
  7526. }
  7527. else if( font_id < 0 || font_id > 9 )
  7528. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  7529. else if( font_id != sd->user_font )
  7530. {
  7531. sd->user_font = font_id;
  7532. clif_font(sd);
  7533. clif_displaymessage(fd, "Font changed.");
  7534. }
  7535. else
  7536. clif_displaymessage(fd, "Already using this font.");
  7537. return 0;
  7538. }
  7539. ACMD_FUNC(new_mount) {
  7540. clif_displaymessage(sd->fd,"NOTICE: If you crash with mount your LUA is outdated");
  7541. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7542. clif_displaymessage(sd->fd,"You have mounted.");
  7543. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7544. } else {
  7545. clif_displaymessage(sd->fd,"You have released your mount");
  7546. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7547. }
  7548. return 0;
  7549. }
  7550. /*==========================================
  7551. * atcommand_info[] structure definition
  7552. *------------------------------------------*/
  7553. AtCommandInfo atcommand_info[] = {
  7554. { "rura", 40,40, atcommand_mapmove },
  7555. { "warp", 40,40, atcommand_mapmove },
  7556. { "mapmove", 40,40, atcommand_mapmove }, // + /mm
  7557. { "where", 1,1, atcommand_where },
  7558. { "jumpto", 20,20, atcommand_jumpto }, // + /shift
  7559. { "warpto", 20,20, atcommand_jumpto },
  7560. { "goto", 20,20, atcommand_jumpto },
  7561. { "jump", 40,40, atcommand_jump },
  7562. { "who", 20,20, atcommand_who },
  7563. { "whois", 20,20, atcommand_who },
  7564. { "who2", 20,20, atcommand_who2 },
  7565. { "who3", 20,20, atcommand_who3 },
  7566. { "whomap", 20,20, atcommand_whomap },
  7567. { "whomap2", 20,20, atcommand_whomap2 },
  7568. { "whomap3", 20,20, atcommand_whomap3 },
  7569. { "whogm", 20,20, atcommand_whogm },
  7570. { "save", 40,40, atcommand_save },
  7571. { "return", 40,40, atcommand_load },
  7572. { "load", 40,40, atcommand_load },
  7573. { "speed", 40,40, atcommand_speed },
  7574. { "storage", 1,1, atcommand_storage },
  7575. { "gstorage", 50,50, atcommand_guildstorage },
  7576. { "option", 40,40, atcommand_option },
  7577. { "hide", 40,40, atcommand_hide }, // + /hide
  7578. { "jobchange", 40,40, atcommand_jobchange },
  7579. { "job", 40,40, atcommand_jobchange },
  7580. { "die", 1,1, atcommand_die },
  7581. { "kill", 60,60, atcommand_kill },
  7582. { "alive", 60,60, atcommand_alive },
  7583. { "kami", 40,40, atcommand_kami },
  7584. { "kamib", 40,40, atcommand_kami },
  7585. { "kamic", 40,40, atcommand_kami },
  7586. { "heal", 40,60, atcommand_heal },
  7587. { "item", 60,60, atcommand_item },
  7588. { "item2", 60,60, atcommand_item2 },
  7589. { "itemreset", 40,40, atcommand_itemreset },
  7590. { "blvl", 60,60, atcommand_baselevelup },
  7591. { "lvup", 60,60, atcommand_baselevelup },
  7592. { "blevel", 60,60, atcommand_baselevelup },
  7593. { "baselvl", 60,60, atcommand_baselevelup },
  7594. { "baselvup", 60,60, atcommand_baselevelup },
  7595. { "baselevel", 60,60, atcommand_baselevelup },
  7596. { "baselvlup", 60,60, atcommand_baselevelup },
  7597. { "jlvl", 60,60, atcommand_joblevelup },
  7598. { "jlevel", 60,60, atcommand_joblevelup },
  7599. { "joblvl", 60,60, atcommand_joblevelup },
  7600. { "joblevel", 60,60, atcommand_joblevelup },
  7601. { "joblvup", 60,60, atcommand_joblevelup },
  7602. { "joblvlup", 60,60, atcommand_joblevelup },
  7603. { "h", 20,20, atcommand_help },
  7604. { "help", 20,20, atcommand_help },
  7605. { "h2", 20,20, atcommand_help2 },
  7606. { "help2", 20,20, atcommand_help2 },
  7607. { "pvpoff", 40,40, atcommand_pvpoff },
  7608. { "pvpon", 40,40, atcommand_pvpon },
  7609. { "gvgoff", 40,40, atcommand_gvgoff },
  7610. { "gpvpoff", 40,40, atcommand_gvgoff },
  7611. { "gvgon", 40,40, atcommand_gvgon },
  7612. { "gpvpon", 40,40, atcommand_gvgon },
  7613. { "model", 20,20, atcommand_model },
  7614. { "go", 10,10, atcommand_go },
  7615. { "monster", 50,50, atcommand_monster },
  7616. { "spawn", 50,50, atcommand_monster },
  7617. { "monstersmall", 50,50, atcommand_monstersmall },
  7618. { "monsterbig", 50,50, atcommand_monsterbig },
  7619. { "killmonster", 60,60, atcommand_killmonster },
  7620. { "killmonster2", 40,40, atcommand_killmonster2 },
  7621. { "refine", 60,60, atcommand_refine },
  7622. { "produce", 60,60, atcommand_produce },
  7623. { "memo", 40,40, atcommand_memo },
  7624. { "gat", 99,99, atcommand_gat },
  7625. { "displaystatus", 99,99, atcommand_displaystatus },
  7626. { "stpoint", 60,60, atcommand_statuspoint },
  7627. { "skpoint", 60,60, atcommand_skillpoint },
  7628. { "zeny", 60,60, atcommand_zeny },
  7629. { "str", 60,60, atcommand_param },
  7630. { "agi", 60,60, atcommand_param },
  7631. { "vit", 60,60, atcommand_param },
  7632. { "int", 60,60, atcommand_param },
  7633. { "dex", 60,60, atcommand_param },
  7634. { "luk", 60,60, atcommand_param },
  7635. { "glvl", 60,60, atcommand_guildlevelup },
  7636. { "glevel", 60,60, atcommand_guildlevelup },
  7637. { "guildlvl", 60,60, atcommand_guildlevelup },
  7638. { "guildlvup", 60,60, atcommand_guildlevelup },
  7639. { "guildlevel", 60,60, atcommand_guildlevelup },
  7640. { "guildlvlup", 60,60, atcommand_guildlevelup },
  7641. { "makeegg", 60,60, atcommand_makeegg },
  7642. { "hatch", 60,60, atcommand_hatch },
  7643. { "petfriendly", 40,40, atcommand_petfriendly },
  7644. { "pethungry", 40,40, atcommand_pethungry },
  7645. { "petrename", 1,1, atcommand_petrename },
  7646. { "recall", 60,60, atcommand_recall }, // + /recall
  7647. { "night", 80,80, atcommand_night },
  7648. { "day", 80,80, atcommand_day },
  7649. { "doom", 80,80, atcommand_doom },
  7650. { "doommap", 80,80, atcommand_doommap },
  7651. { "raise", 80,80, atcommand_raise },
  7652. { "raisemap", 80,80, atcommand_raisemap },
  7653. { "kick", 20,20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7654. { "kickall", 99,99, atcommand_kickall },
  7655. { "allskill", 60,60, atcommand_allskill },
  7656. { "allskills", 60,60, atcommand_allskill },
  7657. { "skillall", 60,60, atcommand_allskill },
  7658. { "skillsall", 60,60, atcommand_allskill },
  7659. { "questskill", 40,40, atcommand_questskill },
  7660. { "lostskill", 40,40, atcommand_lostskill },
  7661. { "spiritball", 40,40, atcommand_spiritball },
  7662. { "party", 1,1, atcommand_party },
  7663. { "guild", 50,50, atcommand_guild },
  7664. { "agitstart", 60,60, atcommand_agitstart },
  7665. { "agitend", 60,60, atcommand_agitend },
  7666. { "mapexit", 99,99, atcommand_mapexit },
  7667. { "idsearch", 60,60, atcommand_idsearch },
  7668. { "broadcast", 40,40, atcommand_broadcast }, // + /b and /nb
  7669. { "localbroadcast", 40,40, atcommand_localbroadcast }, // + /lb and /nlb
  7670. { "recallall", 80,80, atcommand_recallall },
  7671. { "reloaditemdb", 99,99, atcommand_reloaditemdb },
  7672. { "reloadmobdb", 99,99, atcommand_reloadmobdb },
  7673. { "reloadskilldb", 99,99, atcommand_reloadskilldb },
  7674. { "reloadscript", 99,99, atcommand_reloadscript },
  7675. { "reloadatcommand", 99,99, atcommand_reloadatcommand },
  7676. { "reloadbattleconf", 99,99, atcommand_reloadbattleconf },
  7677. { "reloadstatusdb", 99,99, atcommand_reloadstatusdb },
  7678. { "reloadpcdb", 99,99, atcommand_reloadpcdb },
  7679. { "reloadmotd", 99,99, atcommand_reloadmotd },
  7680. { "mapinfo", 99,99, atcommand_mapinfo },
  7681. { "dye", 40,40, atcommand_dye },
  7682. { "ccolor", 40,40, atcommand_dye },
  7683. { "hairstyle", 40,40, atcommand_hair_style },
  7684. { "hstyle", 40,40, atcommand_hair_style },
  7685. { "haircolor", 40,40, atcommand_hair_color },
  7686. { "hcolor", 40,40, atcommand_hair_color },
  7687. { "statall", 60,60, atcommand_stat_all },
  7688. { "statsall", 60,60, atcommand_stat_all },
  7689. { "allstats", 60,60, atcommand_stat_all },
  7690. { "allstat", 60,60, atcommand_stat_all },
  7691. { "block", 60,60, atcommand_char_block },
  7692. { "charblock", 60,60, atcommand_char_block },
  7693. { "ban", 60,60, atcommand_char_ban },
  7694. { "banish", 60,60, atcommand_char_ban },
  7695. { "charban", 60,60, atcommand_char_ban },
  7696. { "charbanish", 60,60, atcommand_char_ban },
  7697. { "unblock", 60,60, atcommand_char_unblock },
  7698. { "charunblock", 60,60, atcommand_char_unblock },
  7699. { "unban", 60,60, atcommand_char_unban },
  7700. { "unbanish", 60,60, atcommand_char_unban },
  7701. { "charunban", 60,60, atcommand_char_unban },
  7702. { "charunbanish", 60,60, atcommand_char_unban },
  7703. { "mount", 20,20, atcommand_mount_peco },
  7704. { "mountpeco", 20,20, atcommand_mount_peco },
  7705. { "guildspy", 60,60, atcommand_guildspy },
  7706. { "partyspy", 60,60, atcommand_partyspy },
  7707. { "repairall", 60,60, atcommand_repairall },
  7708. { "guildrecall", 60,60, atcommand_guildrecall },
  7709. { "partyrecall", 60,60, atcommand_partyrecall },
  7710. { "nuke", 60,60, atcommand_nuke },
  7711. { "shownpc", 80,80, atcommand_shownpc },
  7712. { "hidenpc", 80,80, atcommand_hidenpc },
  7713. { "loadnpc", 80,80, atcommand_loadnpc },
  7714. { "unloadnpc", 80,80, atcommand_unloadnpc },
  7715. { "time", 1,1, atcommand_servertime },
  7716. { "date", 1,1, atcommand_servertime },
  7717. { "serverdate", 1,1, atcommand_servertime },
  7718. { "servertime", 1,1, atcommand_servertime },
  7719. { "jail", 60,60, atcommand_jail },
  7720. { "unjail", 60,60, atcommand_unjail },
  7721. { "discharge", 60,60, atcommand_unjail },
  7722. { "jailfor", 60,60, atcommand_jailfor },
  7723. { "jailtime", 1,1, atcommand_jailtime },
  7724. { "disguise", 20,20, atcommand_disguise },
  7725. { "undisguise", 20,20, atcommand_undisguise },
  7726. { "email", 1,1, atcommand_email },
  7727. { "effect", 40,40, atcommand_effect },
  7728. { "follow", 20,20, atcommand_follow },
  7729. { "addwarp", 60,60, atcommand_addwarp },
  7730. { "skillon", 80,80, atcommand_skillon },
  7731. { "skilloff", 80,80, atcommand_skilloff },
  7732. { "killer", 60,60, atcommand_killer },
  7733. { "npcmove", 80,80, atcommand_npcmove },
  7734. { "killable", 40,40, atcommand_killable },
  7735. { "dropall", 40,40, atcommand_dropall },
  7736. { "storeall", 40,40, atcommand_storeall },
  7737. { "skillid", 40,40, atcommand_skillid },
  7738. { "useskill", 40,40, atcommand_useskill },
  7739. { "displayskill", 99,99, atcommand_displayskill },
  7740. { "snow", 99,99, atcommand_snow },
  7741. { "sakura", 99,99, atcommand_sakura },
  7742. { "clouds", 99,99, atcommand_clouds },
  7743. { "clouds2", 99,99, atcommand_clouds2 },
  7744. { "fog", 99,99, atcommand_fog },
  7745. { "fireworks", 99,99, atcommand_fireworks },
  7746. { "leaves", 99,99, atcommand_leaves },
  7747. { "summon", 60,60, atcommand_summon },
  7748. { "adjgmlvl", 99,99, atcommand_adjgmlvl },
  7749. { "adjcmdlvl", 99,99, atcommand_adjcmdlvl },
  7750. { "trade", 60,60, atcommand_trade },
  7751. { "send", 99,99, atcommand_send },
  7752. { "setbattleflag", 99,99, atcommand_setbattleflag },
  7753. { "unmute", 80,80, atcommand_unmute },
  7754. { "clearweather", 99,99, atcommand_clearweather },
  7755. { "uptime", 1,1, atcommand_uptime },
  7756. { "changesex", 60,60, atcommand_changesex },
  7757. { "mute", 80,80, atcommand_mute },
  7758. { "refresh", 1,1, atcommand_refresh },
  7759. { "identify", 40,40, atcommand_identify },
  7760. { "gmotd", 20,20, atcommand_gmotd },
  7761. { "misceffect", 50,50, atcommand_misceffect },
  7762. { "mobsearch", 10,10, atcommand_mobsearch },
  7763. { "cleanmap", 40,40, atcommand_cleanmap },
  7764. { "npctalk", 20,20, atcommand_npctalk },
  7765. { "npctalkc", 20,20, atcommand_npctalk },
  7766. { "pettalk", 10,10, atcommand_pettalk },
  7767. { "users", 40,40, atcommand_users },
  7768. { "reset", 40,40, atcommand_reset },
  7769. { "skilltree", 40,40, atcommand_skilltree },
  7770. { "marry", 40,40, atcommand_marry },
  7771. { "divorce", 40,40, atcommand_divorce },
  7772. { "sound", 40,40, atcommand_sound },
  7773. { "undisguiseall", 99,99, atcommand_undisguiseall },
  7774. { "disguiseall", 99,99, atcommand_disguiseall },
  7775. { "changelook", 60,60, atcommand_changelook },
  7776. { "autoloot", 10,10, atcommand_autoloot },
  7777. { "alootid", 10,10, atcommand_autolootitem },
  7778. { "mobinfo", 1,1, atcommand_mobinfo },
  7779. { "monsterinfo", 1,1, atcommand_mobinfo },
  7780. { "mi", 1,1, atcommand_mobinfo },
  7781. { "exp", 1,1, atcommand_exp },
  7782. { "adopt", 40,40, atcommand_adopt },
  7783. { "version", 1,1, atcommand_version },
  7784. { "mutearea", 99,99, atcommand_mutearea },
  7785. { "stfu", 99,99, atcommand_mutearea },
  7786. { "rates", 1,1, atcommand_rates },
  7787. { "iteminfo", 1,1, atcommand_iteminfo },
  7788. { "ii", 1,1, atcommand_iteminfo },
  7789. { "whodrops", 1,1, atcommand_whodrops },
  7790. { "whereis", 10,10, atcommand_whereis },
  7791. { "mapflag", 99,99, atcommand_mapflag },
  7792. { "me", 20,20, atcommand_me },
  7793. { "monsterignore", 99,99, atcommand_monsterignore },
  7794. { "battleignore", 99,99, atcommand_monsterignore },
  7795. { "fakename", 20,20, atcommand_fakename },
  7796. { "size", 20,20, atcommand_size },
  7797. { "showexp", 10,10, atcommand_showexp},
  7798. { "showzeny", 10,10, atcommand_showzeny},
  7799. { "showdelay", 1,1, atcommand_showdelay},
  7800. { "autotrade", 10,10, atcommand_autotrade },
  7801. { "at", 10,10, atcommand_autotrade },
  7802. { "changegm", 10,10, atcommand_changegm },
  7803. { "changeleader", 10,10, atcommand_changeleader },
  7804. { "partyoption", 10,10, atcommand_partyoption},
  7805. { "invite", 1,1, atcommand_invite },
  7806. { "duel", 1,1, atcommand_duel },
  7807. { "leave", 1,1, atcommand_leave },
  7808. { "accept", 1,1, atcommand_accept },
  7809. { "reject", 1,1, atcommand_reject },
  7810. { "main", 1,1, atcommand_main },
  7811. { "clone", 50,50, atcommand_clone },
  7812. { "slaveclone", 50,50, atcommand_clone },
  7813. { "evilclone", 50,50, atcommand_clone },
  7814. { "tonpc", 40,40, atcommand_tonpc },
  7815. { "commands", 1,1, atcommand_commands },
  7816. { "noask", 1,1, atcommand_noask },
  7817. { "request", 20,20, atcommand_request },
  7818. { "hlvl", 60,60, atcommand_homlevel },
  7819. { "hlevel", 60,60, atcommand_homlevel },
  7820. { "homlvl", 60,60, atcommand_homlevel },
  7821. { "homlvup", 60,60, atcommand_homlevel },
  7822. { "homlevel", 60,60, atcommand_homlevel },
  7823. { "homevolve", 60,60, atcommand_homevolution },
  7824. { "homevolution", 60,60, atcommand_homevolution },
  7825. { "makehomun", 60,60, atcommand_makehomun },
  7826. { "homfriendly", 60,60, atcommand_homfriendly },
  7827. { "homhungry", 60,60, atcommand_homhungry },
  7828. { "homtalk", 10,10, atcommand_homtalk },
  7829. { "hominfo", 1,1, atcommand_hominfo },
  7830. { "homstats", 1,1, atcommand_homstats },
  7831. { "homshuffle", 60,60, atcommand_homshuffle },
  7832. { "showmobs", 10,10, atcommand_showmobs },
  7833. { "feelreset", 10,10, atcommand_feelreset },
  7834. { "auction", 1,1, atcommand_auction },
  7835. { "mail", 1,1, atcommand_mail },
  7836. { "noks", 1,1, atcommand_ksprotection },
  7837. { "allowks", 40,40, atcommand_allowks },
  7838. { "cash", 60,60, atcommand_cash },
  7839. { "points", 60,60, atcommand_cash },
  7840. { "agitstart2", 60,60, atcommand_agitstart2 },
  7841. { "agitend2", 60,60, atcommand_agitend2 },
  7842. { "skreset", 60,60, atcommand_resetskill },
  7843. { "streset", 60,60, atcommand_resetstat },
  7844. { "storagelist", 40,40, atcommand_itemlist },
  7845. { "cartlist", 40,40, atcommand_itemlist },
  7846. { "itemlist", 40,40, atcommand_itemlist },
  7847. { "stats", 40,40, atcommand_stats },
  7848. { "delitem", 60,60, atcommand_delitem },
  7849. { "charcommands", 1,1, atcommand_commands },
  7850. { "font", 1,1, atcommand_font },
  7851. /**
  7852. * For Testing Purposes, not going to be here after we're done.
  7853. **/
  7854. { "newmount", 0,99, atcommand_new_mount },
  7855. };
  7856. /*==========================================
  7857. * Command lookup functions
  7858. *------------------------------------------*/
  7859. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  7860. {
  7861. int i;
  7862. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  7863. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  7864. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7865. }
  7866. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  7867. {
  7868. int i;
  7869. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  7870. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7871. }
  7872. /*==========================================
  7873. * Retrieve the command's required gm level
  7874. *------------------------------------------*/
  7875. int get_atcommand_level(const AtCommandFunc func)
  7876. {
  7877. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  7878. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7879. }
  7880. /// Executes an at-command.
  7881. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7882. {
  7883. char charname[NAME_LENGTH], params[100];
  7884. char charname2[NAME_LENGTH], params2[100];
  7885. char command[100];
  7886. char output[CHAT_SIZE_MAX];
  7887. int x, y, z;
  7888. int lv = 0;
  7889. //Reconstructed message
  7890. char atcmd_msg[CHAT_SIZE_MAX];
  7891. TBL_PC * ssd = NULL; //sd for target
  7892. AtCommandInfo * info;
  7893. nullpo_retr(false, sd);
  7894. //Shouldn't happen
  7895. if( !message || !*message )
  7896. return false;
  7897. //Block NOCHAT but do not display it as a normal message
  7898. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7899. return true;
  7900. // skip 10/11-langtype's codepage indicator, if detected
  7901. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7902. message += 3;
  7903. //Should display as a normal message
  7904. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7905. return false;
  7906. // type value 0 = server invoked: bypass restrictions
  7907. // 1 = player invoked
  7908. if( type )
  7909. {
  7910. //Commands are disabled on maps flagged as 'nocommand'
  7911. if( map[sd->bl.m].nocommand && pc_isGM(sd) < map[sd->bl.m].nocommand )
  7912. {
  7913. clif_displaymessage(fd, msg_txt(143));
  7914. return false;
  7915. }
  7916. //Displays as a normal message for Non-GMs
  7917. if( battle_config.atc_gmonly != 0 && pc_isGM(sd) == 0 )
  7918. return false;
  7919. }
  7920. while (*message == charcommand_symbol)
  7921. {
  7922. //Checks to see if #command has a name or a name + parameters.
  7923. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7924. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7925. //z always has the value of the scan that was successful
  7926. z = ( x > 1 ) ? x : y;
  7927. if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) )
  7928. {
  7929. sprintf(output, "%s failed. Player not found.", command);
  7930. clif_displaymessage(fd, output);
  7931. return true;
  7932. }
  7933. //#command + name means the sufficient target was used and anything else after
  7934. //can be looked at by the actual command function since most scan to see if the
  7935. //right parameters are used.
  7936. if ( x > 2 ) {
  7937. sprintf(atcmd_msg, "%s %s", command, params);
  7938. break;
  7939. }
  7940. else if ( y > 2 ) {
  7941. sprintf(atcmd_msg, "%s %s", command, params2);
  7942. break;
  7943. }
  7944. //Regardless of what style the #command is used, if it's correct, it will always have
  7945. //this value if there is no parameter. Send it as just the #command
  7946. else if ( z == 2 ) {
  7947. sprintf(atcmd_msg, "%s", command);
  7948. break;
  7949. }
  7950. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7951. clif_displaymessage(fd, output);
  7952. return true;
  7953. }
  7954. if (*message == atcommand_symbol) {
  7955. //atcmd_msg is constructed above differently for charcommands
  7956. //it's copied from message if not a charcommand so it can
  7957. //pass through the rest of the code compatible with both symbols
  7958. sprintf(atcmd_msg, "%s", message);
  7959. }
  7960. //Clearing these to be used once more.
  7961. memset(command, '\0', sizeof(command));
  7962. memset(params, '\0', sizeof(params));
  7963. //check to see if any params exist within this command
  7964. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7965. params[0] = '\0';
  7966. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7967. info = get_atcommandinfo_byname(command);
  7968. if( info == NULL || info->func == NULL || ( type && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2)) ) )
  7969. {
  7970. if( pc_isGM(sd) ) {
  7971. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7972. clif_displaymessage(fd, output);
  7973. return true;
  7974. } else
  7975. return false;
  7976. }
  7977. //Log atcommands
  7978. if( *atcmd_msg == atcommand_symbol )
  7979. log_atcommand(sd, info->level, atcmd_msg);
  7980. //Log Charcommands
  7981. if( *atcmd_msg == charcommand_symbol && ssd != NULL )
  7982. log_atcommand(sd, info->level2, message);
  7983. //Attempt to use the command
  7984. if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
  7985. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  7986. {
  7987. sprintf(output,msg_txt(154), command); // %s failed.
  7988. clif_displaymessage(fd, output);
  7989. }
  7990. if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
  7991. return true;
  7992. }
  7993. /*==========================================
  7994. *
  7995. *------------------------------------------*/
  7996. int atcommand_config_read(const char* cfgName)
  7997. {
  7998. char line[1024], w1[1024], w2[1024], w3[1024];
  7999. AtCommandInfo* p;
  8000. FILE* fp;
  8001. if( (fp = fopen(cfgName, "r")) == NULL )
  8002. {
  8003. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  8004. return 1;
  8005. }
  8006. while( fgets(line, sizeof(line), fp) )
  8007. {
  8008. if( line[0] == '/' && line[1] == '/' )
  8009. continue;
  8010. if( (sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3)) != 3 && ( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2
  8011. && strcmpi(w1, "import") != 0 ) && strcmpi(w1, "command_symbol") != 0 && strcmpi(w1, "char_symbol") != 0 )
  8012. continue;
  8013. p = get_atcommandinfo_byname(w1);
  8014. if( p != NULL )
  8015. {
  8016. p->level = atoi(w2);
  8017. p->level = cap_value(p->level, 0, 100);
  8018. if( (sscanf(line, "%1023[^:]:%1023s", w1, w2) == 2) && (sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3)) != 3 )
  8019. {
  8020. ShowWarning("atcommand_conf: setting %s:%d is deprecated! Please see atcommand_athena.conf for the new setting format.\n",w1,atoi(w2));
  8021. ShowWarning("atcommand_conf: defaulting %s charcommand level to %d.\n",w1,atoi(w2));
  8022. p->level2 = atoi(w2);
  8023. }
  8024. else {
  8025. p->level2 = atoi(w3);
  8026. }
  8027. p->level2 = cap_value(p->level2, 0, 100);
  8028. }
  8029. else
  8030. if( strcmpi(w1, "import") == 0 )
  8031. atcommand_config_read(w2);
  8032. else
  8033. if( strcmpi(w1, "command_symbol") == 0 &&
  8034. w2[0] > 31 && // control characters
  8035. w2[0] != '/' && // symbol of standard ragnarok GM commands
  8036. w2[0] != '%' && // symbol of party chat speaking
  8037. w2[0] != '$' && // symbol of guild chat speaking
  8038. w2[0] != '#' ) // remote symbol
  8039. atcommand_symbol = w2[0];
  8040. else
  8041. if( strcmpi(w1, "char_symbol") == 0 &&
  8042. w2[0] > 31 &&
  8043. w2[0] != '/' &&
  8044. w2[0] != '%' &&
  8045. w2[0] != '$' &&
  8046. w2[0] != '@' )
  8047. charcommand_symbol = w2[0];
  8048. else
  8049. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  8050. }
  8051. fclose(fp);
  8052. return 0;
  8053. }
  8054. void do_init_atcommand()
  8055. {
  8056. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  8057. return;
  8058. }
  8059. void do_final_atcommand()
  8060. {
  8061. }
  8062. // commands that need to go _after_ the commands table
  8063. /*==========================================
  8064. * @commands Lists available @ commands to you
  8065. *------------------------------------------*/
  8066. ACMD_FUNC(commands)
  8067. {
  8068. char line_buff[CHATBOX_SIZE];
  8069. int i, gm_lvl = pc_isGM(sd), count = 0;
  8070. char* cur = line_buff;
  8071. memset(line_buff,' ',CHATBOX_SIZE);
  8072. line_buff[CHATBOX_SIZE-1] = 0;
  8073. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  8074. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  8075. {
  8076. unsigned int slen;
  8077. if( gm_lvl < atcommand_info[i].level && stristr(command,"commands") )
  8078. continue;
  8079. if( gm_lvl < atcommand_info[i].level2 && stristr(command,"charcommands") )
  8080. continue;
  8081. slen = strlen(atcommand_info[i].command);
  8082. // flush the text buffer if this command won't fit into it
  8083. if( slen + cur - line_buff >= CHATBOX_SIZE )
  8084. {
  8085. clif_displaymessage(fd,line_buff);
  8086. cur = line_buff;
  8087. memset(line_buff,' ',CHATBOX_SIZE);
  8088. line_buff[CHATBOX_SIZE-1] = 0;
  8089. }
  8090. memcpy(cur,atcommand_info[i].command,slen);
  8091. cur += slen+(10-slen%10);
  8092. count++;
  8093. }
  8094. clif_displaymessage(fd,line_buff);
  8095. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  8096. clif_displaymessage(fd, atcmd_output);
  8097. return 0;
  8098. }