atcommand.c 255 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891
  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/random.h"
  11. #include "../common/socket.h"
  12. #include "../common/strlib.h"
  13. #include "../common/utils.h"
  14. #include "../common/conf.h"
  15. #include "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "clif.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "intif.h"
  22. #include "itemdb.h"
  23. #include "log.h"
  24. #include "map.h"
  25. #include "pc.h"
  26. #include "pc_groups.h" // groupid2name
  27. #include "status.h"
  28. #include "skill.h"
  29. #include "mob.h"
  30. #include "npc.h"
  31. #include "pet.h"
  32. #include "homunculus.h"
  33. #include "mail.h"
  34. #include "mercenary.h"
  35. #include "party.h"
  36. #include "guild.h"
  37. #include "script.h"
  38. #include "storage.h"
  39. #include "trade.h"
  40. #include "unit.h"
  41. #include <stdio.h>
  42. #include <stdlib.h>
  43. #include <string.h>
  44. #include <math.h>
  45. #define ATCOMMAND_LENGTH 50
  46. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  47. #define MAX_MSG 1000
  48. typedef struct AtCommandInfo AtCommandInfo;
  49. typedef struct AliasInfo AliasInfo;
  50. struct AtCommandInfo {
  51. char command[ATCOMMAND_LENGTH];
  52. AtCommandFunc func;
  53. };
  54. struct AliasInfo {
  55. AtCommandInfo *command;
  56. char alias[ATCOMMAND_LENGTH];
  57. };
  58. char atcommand_symbol = '@'; // first char of the commands
  59. char charcommand_symbol = '#';
  60. static char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  61. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  62. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  63. static config_t atcommand_config;
  64. static char atcmd_output[CHAT_SIZE_MAX];
  65. static char atcmd_player_name[NAME_LENGTH];
  66. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  67. static const char* atcommand_checkalias(const char *aliasname); // @help
  68. //-----------------------------------------------------------
  69. // Return the message string of the specified number by [Yor]
  70. //-----------------------------------------------------------
  71. const char* msg_txt(int msg_number)
  72. {
  73. if (msg_number >= 0 && msg_number < MAX_MSG &&
  74. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  75. return msg_table[msg_number];
  76. return "??";
  77. }
  78. /*==========================================
  79. * Read Message Data
  80. *------------------------------------------*/
  81. int msg_config_read(const char* cfgName)
  82. {
  83. int msg_number;
  84. char line[1024], w1[1024], w2[1024];
  85. FILE *fp;
  86. static int called = 1;
  87. if ((fp = fopen(cfgName, "r")) == NULL) {
  88. ShowError("Messages file not found: %s\n", cfgName);
  89. return 1;
  90. }
  91. if ((--called) == 0)
  92. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  93. while(fgets(line, sizeof(line), fp))
  94. {
  95. if (line[0] == '/' && line[1] == '/')
  96. continue;
  97. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  98. continue;
  99. if (strcmpi(w1, "import") == 0)
  100. msg_config_read(w2);
  101. else
  102. {
  103. msg_number = atoi(w1);
  104. if (msg_number >= 0 && msg_number < MAX_MSG)
  105. {
  106. if (msg_table[msg_number] != NULL)
  107. aFree(msg_table[msg_number]);
  108. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  109. strcpy(msg_table[msg_number],w2);
  110. }
  111. }
  112. }
  113. fclose(fp);
  114. return 0;
  115. }
  116. /*==========================================
  117. * Cleanup Message Data
  118. *------------------------------------------*/
  119. void do_final_msg(void)
  120. {
  121. int i;
  122. for (i = 0; i < MAX_MSG; i++)
  123. aFree(msg_table[i]);
  124. }
  125. /*==========================================
  126. * @send (used for testing packet sends from the client)
  127. *------------------------------------------*/
  128. ACMD_FUNC(send)
  129. {
  130. int len=0,off,end,type;
  131. long num;
  132. // read message type as hex number (without the 0x)
  133. if(!message || !*message ||
  134. !((sscanf(message, "len %x", &type)==1 && (len=1))
  135. || sscanf(message, "%x", &type)==1) )
  136. {
  137. clif_displaymessage(fd, "Usage:");
  138. clif_displaymessage(fd, " @send len <packet hex number>");
  139. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  140. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  141. return -1;
  142. }
  143. #define PARSE_ERROR(error,p) \
  144. {\
  145. clif_displaymessage(fd, (error));\
  146. sprintf(atcmd_output, ">%s", (p));\
  147. clif_displaymessage(fd, atcmd_output);\
  148. }
  149. //define PARSE_ERROR
  150. #define CHECK_EOS(p) \
  151. if(*(p) == 0){\
  152. clif_displaymessage(fd, "Unexpected end of string");\
  153. return -1;\
  154. }
  155. //define CHECK_EOS
  156. #define SKIP_VALUE(p) \
  157. {\
  158. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  159. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  160. }
  161. //define SKIP_VALUE
  162. #define GET_VALUE(p,num) \
  163. {\
  164. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  165. PARSE_ERROR("Invalid number in:",(p));\
  166. return -1;\
  167. }\
  168. }
  169. //define GET_VALUE
  170. if (type > 0 && type < MAX_PACKET_DB) {
  171. if(len)
  172. {// show packet length
  173. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  174. clif_displaymessage(fd, atcmd_output);
  175. return 0;
  176. }
  177. len=packet_db[sd->packet_ver][type].len;
  178. off=2;
  179. if(len == 0)
  180. {// unknown packet - ERROR
  181. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  182. clif_displaymessage(fd, atcmd_output);
  183. return -1;
  184. } else if(len == -1)
  185. {// dynamic packet
  186. len=SHRT_MAX-4; // maximum length
  187. off=4;
  188. }
  189. WFIFOHEAD(fd, len);
  190. WFIFOW(fd,0)=TOW(type);
  191. // parse packet contents
  192. SKIP_VALUE(message);
  193. while(*message != 0 && off < len){
  194. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  195. {// default (byte)
  196. GET_VALUE(message,num);
  197. WFIFOB(fd,off)=TOB(num);
  198. ++off;
  199. } else if(TOUPPER(*message) == 'B')
  200. {// byte
  201. ++message;
  202. GET_VALUE(message,num);
  203. WFIFOB(fd,off)=TOB(num);
  204. ++off;
  205. } else if(TOUPPER(*message) == 'W')
  206. {// word (2 bytes)
  207. ++message;
  208. GET_VALUE(message,num);
  209. WFIFOW(fd,off)=TOW(num);
  210. off+=2;
  211. } else if(TOUPPER(*message) == 'L')
  212. {// long word (4 bytes)
  213. ++message;
  214. GET_VALUE(message,num);
  215. WFIFOL(fd,off)=TOL(num);
  216. off+=4;
  217. } else if(TOUPPER(*message) == 'S')
  218. {// string - escapes are valid
  219. // get string length - num <= 0 means not fixed length (default)
  220. ++message;
  221. if(*message == '"'){
  222. num=0;
  223. } else {
  224. GET_VALUE(message,num);
  225. while(*message != '"')
  226. {// find start of string
  227. if(*message == 0 || ISSPACE(*message)){
  228. PARSE_ERROR("Not a string:",message);
  229. return -1;
  230. }
  231. ++message;
  232. }
  233. }
  234. // parse string
  235. ++message;
  236. CHECK_EOS(message);
  237. end=(num<=0? 0: min(off+((int)num),len));
  238. for(; *message != '"' && (off < end || end == 0); ++off){
  239. if(*message == '\\'){
  240. ++message;
  241. CHECK_EOS(message);
  242. switch(*message){
  243. case 'a': num=0x07; break; // Bell
  244. case 'b': num=0x08; break; // Backspace
  245. case 't': num=0x09; break; // Horizontal tab
  246. case 'n': num=0x0A; break; // Line feed
  247. case 'v': num=0x0B; break; // Vertical tab
  248. case 'f': num=0x0C; break; // Form feed
  249. case 'r': num=0x0D; break; // Carriage return
  250. case 'e': num=0x1B; break; // Escape
  251. default: num=*message; break;
  252. case 'x': // Hexadecimal
  253. {
  254. ++message;
  255. CHECK_EOS(message);
  256. if(!ISXDIGIT(*message)){
  257. PARSE_ERROR("Not a hexadecimal digit:",message);
  258. return -1;
  259. }
  260. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  261. if(ISXDIGIT(*message)){
  262. ++message;
  263. CHECK_EOS(message);
  264. num<<=8;
  265. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  266. }
  267. WFIFOB(fd,off)=TOB(num);
  268. ++message;
  269. CHECK_EOS(message);
  270. continue;
  271. }
  272. case '0':
  273. case '1':
  274. case '2':
  275. case '3':
  276. case '4':
  277. case '5':
  278. case '6':
  279. case '7': // Octal
  280. {
  281. num=*message-'0'; // 1st octal digit
  282. ++message;
  283. CHECK_EOS(message);
  284. if(ISDIGIT(*message) && *message < '8'){
  285. num<<=3;
  286. num+=*message-'0'; // 2nd octal digit
  287. ++message;
  288. CHECK_EOS(message);
  289. if(ISDIGIT(*message) && *message < '8'){
  290. num<<=3;
  291. num+=*message-'0'; // 3rd octal digit
  292. ++message;
  293. CHECK_EOS(message);
  294. }
  295. }
  296. WFIFOB(fd,off)=TOB(num);
  297. continue;
  298. }
  299. }
  300. } else
  301. num=*message;
  302. WFIFOB(fd,off)=TOB(num);
  303. ++message;
  304. CHECK_EOS(message);
  305. }//for
  306. while(*message != '"')
  307. {// ignore extra characters
  308. ++message;
  309. CHECK_EOS(message);
  310. }
  311. // terminate the string
  312. if(off < end)
  313. {// fill the rest with 0's
  314. memset(WFIFOP(fd,off),0,end-off);
  315. off=end;
  316. }
  317. } else
  318. {// unknown
  319. PARSE_ERROR("Unknown type of value in:",message);
  320. return -1;
  321. }
  322. SKIP_VALUE(message);
  323. }
  324. if(packet_db[sd->packet_ver][type].len == -1)
  325. {// send dynamic packet
  326. WFIFOW(fd,2)=TOW(off);
  327. WFIFOSET(fd,off);
  328. } else
  329. {// send static packet
  330. if(off < len)
  331. memset(WFIFOP(fd,off),0,len-off);
  332. WFIFOSET(fd,len);
  333. }
  334. } else {
  335. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  336. return -1;
  337. }
  338. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  339. clif_displaymessage(fd, atcmd_output);
  340. return 0;
  341. #undef PARSE_ERROR
  342. #undef CHECK_EOS
  343. #undef SKIP_VALUE
  344. #undef GET_VALUE
  345. }
  346. /*==========================================
  347. * @rura, @warp, @mapmove
  348. *------------------------------------------*/
  349. ACMD_FUNC(mapmove)
  350. {
  351. char map_name[MAP_NAME_LENGTH_EXT];
  352. unsigned short mapindex;
  353. short x = 0, y = 0;
  354. int m = -1;
  355. nullpo_retr(-1, sd);
  356. memset(map_name, '\0', sizeof(map_name));
  357. if (!message || !*message ||
  358. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  359. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  360. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  361. return -1;
  362. }
  363. mapindex = mapindex_name2id(map_name);
  364. if (mapindex)
  365. m = map_mapindex2mapid(mapindex);
  366. if (!mapindex) { // m < 0 means on different server! [Kevin]
  367. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  368. return -1;
  369. }
  370. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  371. { //This is to prevent the pc_setpos call from printing an error.
  372. clif_displaymessage(fd, msg_txt(2));
  373. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  374. x = y = 0; //Invalid cell, use random spot.
  375. }
  376. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  377. clif_displaymessage(fd, msg_txt(247));
  378. return -1;
  379. }
  380. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  381. clif_displaymessage(fd, msg_txt(248));
  382. return -1;
  383. }
  384. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  385. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  386. return -1;
  387. }
  388. clif_displaymessage(fd, msg_txt(0)); // Warped.
  389. return 0;
  390. }
  391. /*==========================================
  392. * Displays where a character is. Corrected version by Silent. [Skotlex]
  393. *------------------------------------------*/
  394. ACMD_FUNC(where)
  395. {
  396. struct map_session_data* pl_sd;
  397. nullpo_retr(-1, sd);
  398. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  399. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  400. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  401. return -1;
  402. }
  403. pl_sd = map_nick2sd(atcmd_player_name);
  404. if (pl_sd == NULL ||
  405. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  406. (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  407. ) {
  408. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  409. return -1;
  410. }
  411. 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);
  412. clif_displaymessage(fd, atcmd_output);
  413. return 0;
  414. }
  415. /*==========================================
  416. *
  417. *------------------------------------------*/
  418. ACMD_FUNC(jumpto)
  419. {
  420. struct map_session_data *pl_sd = NULL;
  421. nullpo_retr(-1, sd);
  422. if (!message || !*message) {
  423. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  424. return -1;
  425. }
  426. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  427. {
  428. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  429. return -1;
  430. }
  431. if (pl_sd == sd)
  432. {
  433. clif_displaymessage(fd, "But you are already where you are...");
  434. return -1;
  435. }
  436. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  437. {
  438. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  439. return -1;
  440. }
  441. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  442. {
  443. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  444. return -1;
  445. }
  446. if( pc_isdead(sd) )
  447. {
  448. clif_displaymessage(fd, "You cannot use this command when dead.");
  449. return -1;
  450. }
  451. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  452. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  453. clif_displaymessage(fd, atcmd_output);
  454. return 0;
  455. }
  456. /*==========================================
  457. *
  458. *------------------------------------------*/
  459. ACMD_FUNC(jump)
  460. {
  461. short x = 0, y = 0;
  462. nullpo_retr(-1, sd);
  463. memset(atcmd_output, '\0', sizeof(atcmd_output));
  464. sscanf(message, "%hd %hd", &x, &y);
  465. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  466. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  467. return -1;
  468. }
  469. if( pc_isdead(sd) )
  470. {
  471. clif_displaymessage(fd, "You cannot use this command when dead.");
  472. return -1;
  473. }
  474. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  475. { //This is to prevent the pc_setpos call from printing an error.
  476. clif_displaymessage(fd, msg_txt(2));
  477. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  478. x = y = 0; //Invalid cell, use random spot.
  479. }
  480. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  481. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  482. clif_displaymessage(fd, atcmd_output);
  483. return 0;
  484. }
  485. /*==========================================
  486. * Display list of online characters with
  487. * various info.
  488. *------------------------------------------*/
  489. ACMD_FUNC(who)
  490. {
  491. struct map_session_data *pl_sd = NULL;
  492. struct s_mapiterator *iter = NULL;
  493. char map_name[MAP_NAME_LENGTH_EXT] = "";
  494. char player_name[NAME_LENGTH] = "";
  495. int count = 0;
  496. int level = 0;
  497. StringBuf buf;
  498. /**
  499. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  500. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  501. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  502. */
  503. int display_type = 1;
  504. int map_id = -1;
  505. nullpo_retr(-1, sd);
  506. if (strstr(command, "map") != NULL) {
  507. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  508. map_id = sd->bl.m;
  509. } else {
  510. sscanf(message, "%23s", player_name);
  511. }
  512. if (strstr(command, "2") != NULL)
  513. display_type = 2;
  514. else if (strstr(command, "3") != NULL)
  515. display_type = 3;
  516. level = pc_get_group_level(sd);
  517. StringBuf_Init(&buf);
  518. iter = mapit_getallusers();
  519. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  520. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  521. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  522. || (map_id >= 0 && pl_sd->bl.m != map_id))
  523. continue;
  524. switch (display_type) {
  525. case 2: {
  526. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  527. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  528. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  529. StringBuf_Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level,
  530. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  531. break;
  532. }
  533. case 3: {
  534. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  535. StringBuf_Printf(&buf, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  536. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  537. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  538. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  539. StringBuf_Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  540. break;
  541. }
  542. default: {
  543. struct party_data *p = party_search(pl_sd->status.party_id);
  544. struct guild *g = guild_search(pl_sd->status.guild_id);
  545. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  546. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  547. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  548. if (p != NULL)
  549. StringBuf_Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'"
  550. if (g != NULL)
  551. StringBuf_Printf(&buf, msg_txt(346), g->name); // " | Guild: '%s'"
  552. break;
  553. }
  554. }
  555. clif_displaymessage(fd, StringBuf_Value(&buf));
  556. StringBuf_Clear(&buf);
  557. count++;
  558. }
  559. }
  560. mapit_free(iter);
  561. if (map_id < 0) {
  562. if (count == 0)
  563. StringBuf_Printf(&buf, msg_txt(28)); // No player found.
  564. else if (count == 1)
  565. StringBuf_Printf(&buf, msg_txt(29)); // 1 player found.
  566. else
  567. StringBuf_Printf(&buf, msg_txt(30), count); // %d players found.
  568. } else {
  569. if (count == 0)
  570. StringBuf_Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  571. else if (count == 1)
  572. StringBuf_Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  573. else
  574. StringBuf_Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  575. }
  576. clif_displaymessage(fd, StringBuf_Value(&buf));
  577. StringBuf_Destroy(&buf);
  578. return 0;
  579. }
  580. /*==========================================
  581. *
  582. *------------------------------------------*/
  583. ACMD_FUNC(whogm)
  584. {
  585. struct map_session_data* pl_sd;
  586. struct s_mapiterator* iter;
  587. int j, count;
  588. int pl_level, level;
  589. char match_text[CHAT_SIZE_MAX];
  590. char player_name[NAME_LENGTH];
  591. struct guild *g;
  592. struct party_data *p;
  593. nullpo_retr(-1, sd);
  594. memset(atcmd_output, '\0', sizeof(atcmd_output));
  595. memset(match_text, '\0', sizeof(match_text));
  596. memset(player_name, '\0', sizeof(player_name));
  597. if (sscanf(message, "%199[^\n]", match_text) < 1)
  598. strcpy(match_text, "");
  599. for (j = 0; match_text[j]; j++)
  600. match_text[j] = TOLOWER(match_text[j]);
  601. count = 0;
  602. level = pc_get_group_level(sd);
  603. iter = mapit_getallusers();
  604. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  605. {
  606. pl_level = pc_get_group_level(pl_sd);
  607. if (!pl_level)
  608. continue;
  609. if (match_text[0])
  610. {
  611. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  612. for (j = 0; player_name[j]; j++)
  613. player_name[j] = TOLOWER(player_name[j]);
  614. // search with no case sensitive
  615. if (strstr(player_name, match_text) == NULL)
  616. continue;
  617. }
  618. if (pl_level > level) {
  619. if (pl_sd->sc.option & OPTION_INVISIBLE)
  620. continue;
  621. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  622. clif_displaymessage(fd, atcmd_output);
  623. count++;
  624. continue;
  625. }
  626. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  627. pl_sd->status.name, pl_level,
  628. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  629. clif_displaymessage(fd, atcmd_output);
  630. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  631. pl_sd->status.base_level,
  632. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  633. clif_displaymessage(fd, atcmd_output);
  634. p = party_search(pl_sd->status.party_id);
  635. g = guild_search(pl_sd->status.guild_id);
  636. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  637. p?p->party.name:"None", g?g->name:"None");
  638. clif_displaymessage(fd, atcmd_output);
  639. count++;
  640. }
  641. mapit_free(iter);
  642. if (count == 0)
  643. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  644. else if (count == 1)
  645. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  646. else {
  647. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  648. clif_displaymessage(fd, atcmd_output);
  649. }
  650. return 0;
  651. }
  652. /*==========================================
  653. *
  654. *------------------------------------------*/
  655. ACMD_FUNC(save)
  656. {
  657. nullpo_retr(-1, sd);
  658. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  659. if (sd->status.pet_id > 0 && sd->pd)
  660. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  661. chrif_save(sd,0);
  662. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  663. return 0;
  664. }
  665. /*==========================================
  666. *
  667. *------------------------------------------*/
  668. ACMD_FUNC(load)
  669. {
  670. int m;
  671. nullpo_retr(-1, sd);
  672. m = map_mapindex2mapid(sd->status.save_point.map);
  673. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  674. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  675. return -1;
  676. }
  677. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  678. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  679. return -1;
  680. }
  681. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  682. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  683. return 0;
  684. }
  685. /*==========================================
  686. *
  687. *------------------------------------------*/
  688. ACMD_FUNC(speed)
  689. {
  690. int speed;
  691. nullpo_retr(-1, sd);
  692. memset(atcmd_output, '\0', sizeof(atcmd_output));
  693. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  694. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  695. clif_displaymessage(fd, atcmd_output);
  696. return -1;
  697. }
  698. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  699. status_calc_bl(&sd->bl, SCB_SPEED);
  700. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  701. return 0;
  702. }
  703. /*==========================================
  704. *
  705. *------------------------------------------*/
  706. ACMD_FUNC(storage)
  707. {
  708. nullpo_retr(-1, sd);
  709. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  710. return -1;
  711. if (storage_storageopen(sd) == 1)
  712. { //Already open.
  713. clif_displaymessage(fd, msg_txt(250));
  714. return -1;
  715. }
  716. clif_displaymessage(fd, "Storage opened.");
  717. return 0;
  718. }
  719. /*==========================================
  720. *
  721. *------------------------------------------*/
  722. ACMD_FUNC(guildstorage)
  723. {
  724. nullpo_retr(-1, sd);
  725. if (!sd->status.guild_id) {
  726. clif_displaymessage(fd, msg_txt(252));
  727. return -1;
  728. }
  729. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  730. return -1;
  731. if (sd->state.storage_flag == 1) {
  732. clif_displaymessage(fd, msg_txt(250));
  733. return -1;
  734. }
  735. if (sd->state.storage_flag == 2) {
  736. clif_displaymessage(fd, msg_txt(251));
  737. return -1;
  738. }
  739. storage_guild_storageopen(sd);
  740. clif_displaymessage(fd, "Guild storage opened.");
  741. return 0;
  742. }
  743. /*==========================================
  744. *
  745. *------------------------------------------*/
  746. ACMD_FUNC(option)
  747. {
  748. int param1 = 0, param2 = 0, param3 = 0;
  749. nullpo_retr(-1, sd);
  750. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  751. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  752. return -1;
  753. }
  754. sd->sc.opt1 = param1;
  755. sd->sc.opt2 = param2;
  756. pc_setoption(sd, param3);
  757. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  758. return 0;
  759. }
  760. /*==========================================
  761. *
  762. *------------------------------------------*/
  763. ACMD_FUNC(hide)
  764. {
  765. nullpo_retr(-1, sd);
  766. if (sd->sc.option & OPTION_INVISIBLE) {
  767. sd->sc.option &= ~OPTION_INVISIBLE;
  768. if (sd->disguise)
  769. status_set_viewdata(&sd->bl, sd->disguise);
  770. else
  771. status_set_viewdata(&sd->bl, sd->status.class_);
  772. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  773. // increment the number of pvp players on the map
  774. map[sd->bl.m].users_pvp++;
  775. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  776. {// register the player for ranking calculations
  777. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  778. }
  779. //bugreport:2266
  780. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  781. } else {
  782. sd->sc.option |= OPTION_INVISIBLE;
  783. sd->vd.class_ = INVISIBLE_CLASS;
  784. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  785. // decrement the number of pvp players on the map
  786. map[sd->bl.m].users_pvp--;
  787. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  788. {// unregister the player for ranking
  789. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  790. sd->pvp_timer = INVALID_TIMER;
  791. }
  792. }
  793. clif_changeoption(&sd->bl);
  794. return 0;
  795. }
  796. /*==========================================
  797. * Changes a character's class
  798. *------------------------------------------*/
  799. ACMD_FUNC(jobchange)
  800. {
  801. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  802. int job = 0, upper = 0;
  803. nullpo_retr(-1, sd);
  804. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  805. {
  806. int i, found = 0;
  807. const struct { char name[24]; int id; } jobs[] = {
  808. { "novice", 0 },
  809. { "swordsman", 1 },
  810. { "mage", 2 },
  811. { "archer", 3 },
  812. { "acolyte", 4 },
  813. { "merchant", 5 },
  814. { "thief", 6 },
  815. { "knight", 7 },
  816. { "priest", 8 },
  817. { "priestess", 8 },
  818. { "wizard", 9 },
  819. { "blacksmith", 10 },
  820. { "hunter", 11 },
  821. { "assassin", 12 },
  822. { "crusader", 14 },
  823. { "monk", 15 },
  824. { "sage", 16 },
  825. { "rogue", 17 },
  826. { "alchemist", 18 },
  827. { "bard", 19 },
  828. { "dancer", 20 },
  829. { "super novice", 23 },
  830. { "supernovice", 23 },
  831. { "gunslinger", 24 },
  832. { "gunner", 24 },
  833. { "ninja", 25 },
  834. { "high novice", 4001 },
  835. { "swordsman high", 4002 },
  836. { "mage high", 4003 },
  837. { "archer high", 4004 },
  838. { "acolyte high", 4005 },
  839. { "merchant high", 4006 },
  840. { "thief high", 4007 },
  841. { "lord knight", 4008 },
  842. { "high priest", 4009 },
  843. { "high priestess", 4009 },
  844. { "high wizard", 4010 },
  845. { "whitesmith", 4011 },
  846. { "sniper", 4012 },
  847. { "assassin cross", 4013 },
  848. { "paladin", 4015 },
  849. { "champion", 4016 },
  850. { "professor", 4017 },
  851. { "stalker", 4018 },
  852. { "creator", 4019 },
  853. { "clown", 4020 },
  854. { "gypsy", 4021 },
  855. { "baby novice", 4023 },
  856. { "baby swordsman", 4024 },
  857. { "baby mage", 4025 },
  858. { "baby archer", 4026 },
  859. { "baby acolyte", 4027 },
  860. { "baby merchant", 4028 },
  861. { "baby thief", 4029 },
  862. { "baby knight", 4030 },
  863. { "baby priest", 4031 },
  864. { "baby priestess", 4031 },
  865. { "baby wizard", 4032 },
  866. { "baby blacksmith",4033 },
  867. { "baby hunter", 4034 },
  868. { "baby assassin", 4035 },
  869. { "baby crusader", 4037 },
  870. { "baby monk", 4038 },
  871. { "baby sage", 4039 },
  872. { "baby rogue", 4040 },
  873. { "baby alchemist", 4041 },
  874. { "baby bard", 4042 },
  875. { "baby dancer", 4043 },
  876. { "super baby", 4045 },
  877. { "taekwon", 4046 },
  878. { "taekwon boy", 4046 },
  879. { "taekwon girl", 4046 },
  880. { "star gladiator", 4047 },
  881. { "soul linker", 4049 },
  882. { "rune knight", 4054 },
  883. { "warlock", 4055 },
  884. { "ranger", 4056 },
  885. { "arch bishop", 4057 },
  886. { "mechanic", 4058 },
  887. { "guillotine", 4059 },
  888. { "rune knight (Trans)", 4060 },
  889. { "warlock (Trans)", 4061 },
  890. { "ranger (Trans)", 4062 },
  891. { "arch bishop (Trans)", 4063 },
  892. { "mechanic (Trans)", 4064 },
  893. { "guillotine (Trans)", 4065 },
  894. { "royal guard", 4066 },
  895. { "sorcerer", 4067 },
  896. { "minstrel", 4068 },
  897. { "wanderer", 4069 },
  898. { "sura", 4070 },
  899. { "genetic", 4071 },
  900. { "shadow chaser", 4072 },
  901. { "royal guard (Trans)", 4073 },
  902. { "sorcerer (Trans)", 4074 },
  903. { "minstrel (Trans)", 4075 },
  904. { "wanderer (Trans)", 4076 },
  905. { "sura (Trans)", 4077 },
  906. { "genetic (Trans)", 4078 },
  907. { "shadow chaser (Trans)", 4079 },
  908. };
  909. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  910. if (strncmpi(message, jobs[i].name, 16) == 0) {
  911. job = jobs[i].id;
  912. upper = 0;
  913. found = 1;
  914. break;
  915. }
  916. }
  917. if (!found) {
  918. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  919. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  920. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  921. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  922. clif_displaymessage(fd, "----- 2nd Class -----");
  923. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  924. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  925. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  926. clif_displaymessage(fd, " 20 Dancer");
  927. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  928. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  929. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  930. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  931. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  932. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  933. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  934. clif_displaymessage(fd, "4021 Gypsy");
  935. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  936. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  937. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  938. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  939. clif_displaymessage(fd, "4072 Shadow Chaser");
  940. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  941. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  942. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  943. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  944. clif_displaymessage(fd, "4079 Shadow Chaser");
  945. clif_displaymessage(fd, "----- Expanded Class -----");
  946. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  947. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  948. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  949. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  950. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  951. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  952. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  953. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  954. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  955. clif_displaymessage(fd, "4045 Super Baby");
  956. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  957. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  958. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  959. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  960. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  961. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  962. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  963. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  964. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  965. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  966. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  967. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  968. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  969. return -1;
  970. }
  971. }
  972. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27
  973. || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  974. ) // Deny direct transformation into dummy jobs
  975. return 0;
  976. if (pcdb_checkid(job))
  977. {
  978. if (pc_jobchange(sd, job, upper) == 0)
  979. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  980. else {
  981. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  982. return -1;
  983. }
  984. } else {
  985. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  986. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  987. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  988. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  989. clif_displaymessage(fd, "----- 2nd Class -----");
  990. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  991. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  992. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  993. clif_displaymessage(fd, " 20 Dancer");
  994. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  995. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  996. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  997. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  998. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  999. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1000. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1001. clif_displaymessage(fd, "4021 Gypsy");
  1002. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1003. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1004. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1005. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1006. clif_displaymessage(fd, "4072 Shadow Chaser");
  1007. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1008. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1009. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1010. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1011. clif_displaymessage(fd, "4079 Shadow Chaser");
  1012. clif_displaymessage(fd, "----- Expanded Class -----");
  1013. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1014. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1015. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1016. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1017. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1018. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1019. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1020. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1021. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1022. clif_displaymessage(fd, "4045 Super Baby");
  1023. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1024. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1025. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1026. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1027. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1028. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1029. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1030. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1031. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1032. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1033. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1034. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1035. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1036. return -1;
  1037. }
  1038. return 0;
  1039. }
  1040. /*==========================================
  1041. *
  1042. *------------------------------------------*/
  1043. ACMD_FUNC(kill)
  1044. {
  1045. nullpo_retr(-1, sd);
  1046. status_kill(&sd->bl);
  1047. clif_displaymessage(sd->fd, msg_txt(13)); // A pity! You've died.
  1048. if (fd != sd->fd)
  1049. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1050. return 0;
  1051. }
  1052. /*==========================================
  1053. *
  1054. *------------------------------------------*/
  1055. ACMD_FUNC(alive)
  1056. {
  1057. nullpo_retr(-1, sd);
  1058. if (!status_revive(&sd->bl, 100, 100))
  1059. {
  1060. clif_displaymessage(fd, "You're not dead.");
  1061. return -1;
  1062. }
  1063. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1064. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1065. return 0;
  1066. }
  1067. /*==========================================
  1068. * +kamic [LuzZza]
  1069. *------------------------------------------*/
  1070. ACMD_FUNC(kami)
  1071. {
  1072. unsigned long color=0;
  1073. nullpo_retr(-1, sd);
  1074. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1075. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1076. if (!message || !*message) {
  1077. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1078. return -1;
  1079. }
  1080. sscanf(message, "%199[^\n]", atcmd_output);
  1081. if (strstr(command, "l") != NULL)
  1082. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  1083. else
  1084. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1085. } else {
  1086. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1087. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1088. return -1;
  1089. }
  1090. if(color > 0xFFFFFF) {
  1091. clif_displaymessage(fd, "Invalid color.");
  1092. return -1;
  1093. }
  1094. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1095. }
  1096. return 0;
  1097. }
  1098. /*==========================================
  1099. *
  1100. *------------------------------------------*/
  1101. ACMD_FUNC(heal)
  1102. {
  1103. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1104. nullpo_retr(-1, sd);
  1105. sscanf(message, "%d %d", &hp, &sp);
  1106. // some overflow checks
  1107. if( hp == INT_MIN ) hp++;
  1108. if( sp == INT_MIN ) sp++;
  1109. if ( hp == 0 && sp == 0 ) {
  1110. if (!status_percent_heal(&sd->bl, 100, 100))
  1111. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1112. else
  1113. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1114. return 0;
  1115. }
  1116. if ( hp > 0 && sp >= 0 ) {
  1117. if(!status_heal(&sd->bl, hp, sp, 0))
  1118. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1119. else
  1120. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1121. return 0;
  1122. }
  1123. if ( hp < 0 && sp <= 0 ) {
  1124. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1125. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1126. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1127. return 0;
  1128. }
  1129. //Opposing signs.
  1130. if ( hp ) {
  1131. if (hp > 0)
  1132. status_heal(&sd->bl, hp, 0, 0);
  1133. else {
  1134. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1135. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1136. }
  1137. }
  1138. if ( sp ) {
  1139. if (sp > 0)
  1140. status_heal(&sd->bl, 0, sp, 0);
  1141. else
  1142. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1143. }
  1144. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1145. return 0;
  1146. }
  1147. /*==========================================
  1148. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1149. *------------------------------------------*/
  1150. ACMD_FUNC(item)
  1151. {
  1152. char item_name[100];
  1153. int number = 0, item_id, flag;
  1154. struct item item_tmp;
  1155. struct item_data *item_data;
  1156. int get_count, i;
  1157. nullpo_retr(-1, sd);
  1158. memset(item_name, '\0', sizeof(item_name));
  1159. if (!message || !*message || (
  1160. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1161. sscanf(message, "%99s %d", item_name, &number) < 1
  1162. )) {
  1163. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1164. return -1;
  1165. }
  1166. if (number <= 0)
  1167. number = 1;
  1168. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1169. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1170. {
  1171. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1172. return -1;
  1173. }
  1174. item_id = item_data->nameid;
  1175. get_count = number;
  1176. //Check if it's stackable.
  1177. if (!itemdb_isstackable2(item_data))
  1178. get_count = 1;
  1179. for (i = 0; i < number; i += get_count) {
  1180. // if not pet egg
  1181. if (!pet_create_egg(sd, item_id)) {
  1182. memset(&item_tmp, 0, sizeof(item_tmp));
  1183. item_tmp.nameid = item_id;
  1184. item_tmp.identify = 1;
  1185. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1186. clif_additem(sd, 0, 0, flag);
  1187. }
  1188. }
  1189. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1190. return 0;
  1191. }
  1192. /*==========================================
  1193. *
  1194. *------------------------------------------*/
  1195. ACMD_FUNC(item2)
  1196. {
  1197. struct item item_tmp;
  1198. struct item_data *item_data;
  1199. char item_name[100];
  1200. int item_id, number = 0;
  1201. int identify = 0, refine = 0, attr = 0;
  1202. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1203. int flag;
  1204. int loop, get_count, i;
  1205. nullpo_retr(-1, sd);
  1206. memset(item_name, '\0', sizeof(item_name));
  1207. if (!message || !*message || (
  1208. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1209. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1210. )) {
  1211. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1212. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1213. return -1;
  1214. }
  1215. if (number <= 0)
  1216. number = 1;
  1217. item_id = 0;
  1218. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1219. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1220. item_id = item_data->nameid;
  1221. if (item_id > 500) {
  1222. loop = 1;
  1223. get_count = number;
  1224. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1225. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1226. loop = number;
  1227. get_count = 1;
  1228. if (item_data->type == IT_PETEGG) {
  1229. identify = 1;
  1230. refine = 0;
  1231. }
  1232. if (item_data->type == IT_PETARMOR)
  1233. refine = 0;
  1234. if (refine > MAX_REFINE)
  1235. refine = MAX_REFINE;
  1236. } else {
  1237. identify = 1;
  1238. refine = attr = 0;
  1239. }
  1240. for (i = 0; i < loop; i++) {
  1241. memset(&item_tmp, 0, sizeof(item_tmp));
  1242. item_tmp.nameid = item_id;
  1243. item_tmp.identify = identify;
  1244. item_tmp.refine = refine;
  1245. item_tmp.attribute = attr;
  1246. item_tmp.card[0] = c1;
  1247. item_tmp.card[1] = c2;
  1248. item_tmp.card[2] = c3;
  1249. item_tmp.card[3] = c4;
  1250. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1251. clif_additem(sd, 0, 0, flag);
  1252. }
  1253. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1254. } else {
  1255. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1256. return -1;
  1257. }
  1258. return 0;
  1259. }
  1260. /*==========================================
  1261. *
  1262. *------------------------------------------*/
  1263. ACMD_FUNC(itemreset)
  1264. {
  1265. int i;
  1266. nullpo_retr(-1, sd);
  1267. for (i = 0; i < MAX_INVENTORY; i++) {
  1268. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1269. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1270. }
  1271. }
  1272. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1273. return 0;
  1274. }
  1275. /*==========================================
  1276. * Atcommand @lvlup
  1277. *------------------------------------------*/
  1278. ACMD_FUNC(baselevelup)
  1279. {
  1280. int level=0, i=0, status_point=0;
  1281. nullpo_retr(-1, sd);
  1282. level = atoi(message);
  1283. if (!message || !*message || !level) {
  1284. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1285. return -1;
  1286. }
  1287. if (level > 0) {
  1288. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1289. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1290. return -1;
  1291. } // End Addition
  1292. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1293. level = pc_maxbaselv(sd) - sd->status.base_level;
  1294. for (i = 0; i < level; i++)
  1295. status_point += pc_gets_status_point(sd->status.base_level + i);
  1296. sd->status.status_point += status_point;
  1297. sd->status.base_level += (unsigned int)level;
  1298. status_percent_heal(&sd->bl, 100, 100);
  1299. clif_misceffect(&sd->bl, 0);
  1300. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1301. } else {
  1302. if (sd->status.base_level == 1) {
  1303. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1304. return -1;
  1305. }
  1306. level*=-1;
  1307. if ((unsigned int)level >= sd->status.base_level)
  1308. level = sd->status.base_level-1;
  1309. for (i = 0; i > -level; i--)
  1310. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1311. if (sd->status.status_point < status_point)
  1312. pc_resetstate(sd);
  1313. if (sd->status.status_point < status_point)
  1314. sd->status.status_point = 0;
  1315. else
  1316. sd->status.status_point -= status_point;
  1317. sd->status.base_level -= (unsigned int)level;
  1318. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1319. }
  1320. sd->status.base_exp = 0;
  1321. clif_updatestatus(sd, SP_STATUSPOINT);
  1322. clif_updatestatus(sd, SP_BASELEVEL);
  1323. clif_updatestatus(sd, SP_BASEEXP);
  1324. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1325. status_calc_pc(sd, 0);
  1326. if(sd->status.party_id)
  1327. party_send_levelup(sd);
  1328. return 0;
  1329. }
  1330. /*==========================================
  1331. *
  1332. *------------------------------------------*/
  1333. ACMD_FUNC(joblevelup)
  1334. {
  1335. int level=0;
  1336. nullpo_retr(-1, sd);
  1337. level = atoi(message);
  1338. if (!message || !*message || !level) {
  1339. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1340. return -1;
  1341. }
  1342. if (level > 0) {
  1343. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1344. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1345. return -1;
  1346. }
  1347. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1348. level = pc_maxjoblv(sd) - sd->status.job_level;
  1349. sd->status.job_level += (unsigned int)level;
  1350. sd->status.skill_point += level;
  1351. clif_misceffect(&sd->bl, 1);
  1352. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1353. } else {
  1354. if (sd->status.job_level == 1) {
  1355. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1356. return -1;
  1357. }
  1358. level *=-1;
  1359. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1360. level = sd->status.job_level-1;
  1361. sd->status.job_level -= (unsigned int)level;
  1362. if (sd->status.skill_point < level)
  1363. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1364. if (sd->status.skill_point < level)
  1365. sd->status.skill_point = 0;
  1366. else
  1367. sd->status.skill_point -= level;
  1368. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1369. }
  1370. sd->status.job_exp = 0;
  1371. clif_updatestatus(sd, SP_JOBLEVEL);
  1372. clif_updatestatus(sd, SP_JOBEXP);
  1373. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1374. clif_updatestatus(sd, SP_SKILLPOINT);
  1375. status_calc_pc(sd, 0);
  1376. return 0;
  1377. }
  1378. /*==========================================
  1379. * @help
  1380. *------------------------------------------*/
  1381. ACMD_FUNC(help)
  1382. {
  1383. config_setting_t *help;
  1384. const char *text = NULL;
  1385. const char *command_name = NULL;
  1386. char *default_command = "help";
  1387. nullpo_retr(-1, sd);
  1388. help = config_lookup(&atcommand_config, "help");
  1389. if (help == NULL) {
  1390. clif_displaymessage(fd, msg_txt(27)); // "Commands help is not available."
  1391. return -1;
  1392. }
  1393. if (!message || !*message) {
  1394. command_name = default_command; // If no command_name specified, display help for @help.
  1395. } else {
  1396. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1397. ++message;
  1398. command_name = atcommand_checkalias(message);
  1399. }
  1400. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1401. sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command"
  1402. clif_displaymessage(fd, atcmd_output);
  1403. return -1;
  1404. }
  1405. if (!config_setting_lookup_string(help, command_name, &text)) {
  1406. clif_displaymessage(fd, "There is no help for this command_name.");
  1407. return -1;
  1408. }
  1409. sprintf(atcmd_output, "Help for command %c%s:", atcommand_symbol, command_name);
  1410. clif_displaymessage(fd, atcmd_output);
  1411. { // Display aliases
  1412. DBIterator* iter;
  1413. AtCommandInfo *command_info;
  1414. AliasInfo *alias_info = NULL;
  1415. StringBuf buf;
  1416. bool has_aliases = false;
  1417. StringBuf_Init(&buf);
  1418. StringBuf_AppendStr(&buf, "Available aliases:");
  1419. command_info = get_atcommandinfo_byname(command_name);
  1420. iter = db_iterator(atcommand_alias_db);
  1421. for (alias_info = (AliasInfo*)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo*)dbi_next(iter)) {
  1422. if (alias_info->command == command_info) {
  1423. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1424. has_aliases = true;
  1425. }
  1426. }
  1427. iter->destroy(iter);
  1428. if (has_aliases)
  1429. clif_displaymessage(fd, StringBuf_Value(&buf));
  1430. StringBuf_Destroy(&buf);
  1431. }
  1432. // Display help contents
  1433. clif_displaymessage(fd, text);
  1434. return 0;
  1435. }
  1436. // helper function, used in foreach calls to stop auto-attack timers
  1437. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1438. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1439. {
  1440. struct unit_data *ud = unit_bl2ud(bl);
  1441. int id = va_arg(ap, int);
  1442. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1443. {
  1444. unit_stop_attack(bl);
  1445. return 1;
  1446. }
  1447. return 0;
  1448. }
  1449. /*==========================================
  1450. *
  1451. *------------------------------------------*/
  1452. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1453. {
  1454. TBL_PC* sd = (TBL_PC*)bl;
  1455. clif_pvpset(sd, 0, 0, 2);
  1456. if (sd->pvp_timer != INVALID_TIMER) {
  1457. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1458. sd->pvp_timer = INVALID_TIMER;
  1459. }
  1460. return 0;
  1461. }
  1462. ACMD_FUNC(pvpoff)
  1463. {
  1464. nullpo_retr(-1, sd);
  1465. if (!map[sd->bl.m].flag.pvp) {
  1466. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1467. return -1;
  1468. }
  1469. map[sd->bl.m].flag.pvp = 0;
  1470. if (!battle_config.pk_mode)
  1471. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1472. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1473. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1474. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1475. return 0;
  1476. }
  1477. /*==========================================
  1478. *
  1479. *------------------------------------------*/
  1480. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1481. {
  1482. TBL_PC* sd = (TBL_PC*)bl;
  1483. if (sd->pvp_timer == INVALID_TIMER) {
  1484. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1485. sd->pvp_rank = 0;
  1486. sd->pvp_lastusers = 0;
  1487. sd->pvp_point = 5;
  1488. sd->pvp_won = 0;
  1489. sd->pvp_lost = 0;
  1490. }
  1491. return 0;
  1492. }
  1493. ACMD_FUNC(pvpon)
  1494. {
  1495. nullpo_retr(-1, sd);
  1496. if (map[sd->bl.m].flag.pvp) {
  1497. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1498. return -1;
  1499. }
  1500. map[sd->bl.m].flag.pvp = 1;
  1501. if (!battle_config.pk_mode)
  1502. {// display pvp circle and rank
  1503. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1504. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1505. }
  1506. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1507. return 0;
  1508. }
  1509. /*==========================================
  1510. *
  1511. *------------------------------------------*/
  1512. ACMD_FUNC(gvgoff)
  1513. {
  1514. nullpo_retr(-1, sd);
  1515. if (!map[sd->bl.m].flag.gvg) {
  1516. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1517. return -1;
  1518. }
  1519. map[sd->bl.m].flag.gvg = 0;
  1520. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1521. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1522. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1523. return 0;
  1524. }
  1525. /*==========================================
  1526. *
  1527. *------------------------------------------*/
  1528. ACMD_FUNC(gvgon)
  1529. {
  1530. nullpo_retr(-1, sd);
  1531. if (map[sd->bl.m].flag.gvg) {
  1532. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1533. return -1;
  1534. }
  1535. map[sd->bl.m].flag.gvg = 1;
  1536. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1537. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1538. return 0;
  1539. }
  1540. /*==========================================
  1541. *
  1542. *------------------------------------------*/
  1543. ACMD_FUNC(model)
  1544. {
  1545. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1546. nullpo_retr(-1, sd);
  1547. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1548. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1549. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1550. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1551. clif_displaymessage(fd, atcmd_output);
  1552. return -1;
  1553. }
  1554. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1555. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1556. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1557. pc_changelook(sd, LOOK_HAIR, hair_style);
  1558. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1559. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1560. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1561. } else {
  1562. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1563. return -1;
  1564. }
  1565. return 0;
  1566. }
  1567. /*==========================================
  1568. * @dye && @ccolor
  1569. *------------------------------------------*/
  1570. ACMD_FUNC(dye)
  1571. {
  1572. int cloth_color = 0;
  1573. nullpo_retr(-1, sd);
  1574. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1575. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1576. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1577. clif_displaymessage(fd, atcmd_output);
  1578. return -1;
  1579. }
  1580. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1581. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1582. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1583. } else {
  1584. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1585. return -1;
  1586. }
  1587. return 0;
  1588. }
  1589. /*==========================================
  1590. * @hairstyle && @hstyle
  1591. *------------------------------------------*/
  1592. ACMD_FUNC(hair_style)
  1593. {
  1594. int hair_style = 0;
  1595. nullpo_retr(-1, sd);
  1596. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1597. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1598. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1599. clif_displaymessage(fd, atcmd_output);
  1600. return -1;
  1601. }
  1602. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1603. pc_changelook(sd, LOOK_HAIR, hair_style);
  1604. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1605. } else {
  1606. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1607. return -1;
  1608. }
  1609. return 0;
  1610. }
  1611. /*==========================================
  1612. * @haircolor && @hcolor
  1613. *------------------------------------------*/
  1614. ACMD_FUNC(hair_color)
  1615. {
  1616. int hair_color = 0;
  1617. nullpo_retr(-1, sd);
  1618. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1619. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1620. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1621. clif_displaymessage(fd, atcmd_output);
  1622. return -1;
  1623. }
  1624. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1625. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1626. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1627. } else {
  1628. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1629. return -1;
  1630. }
  1631. return 0;
  1632. }
  1633. /*==========================================
  1634. * @go [city_number or city_name] - Updated by Harbin
  1635. *------------------------------------------*/
  1636. ACMD_FUNC(go)
  1637. {
  1638. int i;
  1639. int town;
  1640. char map_name[MAP_NAME_LENGTH];
  1641. int m;
  1642. const struct {
  1643. char map[MAP_NAME_LENGTH];
  1644. int x, y;
  1645. } data[] = {
  1646. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1647. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1648. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1649. { MAP_PAYON, 162, 233 }, // 3=Payon
  1650. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1651. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1652. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1653. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1654. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1655. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1656. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1657. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1658. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1659. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1660. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1661. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1662. { MAP_JAIL, 23, 61 }, // 16=Prison
  1663. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1664. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1665. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1666. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1667. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1668. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1669. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1670. { MAP_VEINS, 216, 123 }, // 24=Veins
  1671. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1672. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1673. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1674. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  1675. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1676. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1677. { MAP_MORA, 44, 151 }, // 31=Mora
  1678. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1679. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1680. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1681. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1682. };
  1683. nullpo_retr(-1, sd);
  1684. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1685. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1686. return 0;
  1687. }
  1688. memset(map_name, '\0', sizeof(map_name));
  1689. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1690. // get the number
  1691. town = atoi(message);
  1692. // if no value, display all value
  1693. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1694. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  1695. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  1696. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1697. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1698. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1699. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1700. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1701. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1702. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1703. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  1704. clif_displaymessage(fd, " 24=Veins 25=Moscovia 26=Midgard Camp");
  1705. clif_displaymessage(fd, " 27=Manuk 28=Splendide 29=Brasilis");
  1706. clif_displaymessage(fd, " 30=El Dicastes 31=Mora 32=Dewata");
  1707. clif_displaymessage(fd, " 33=Malangdo Island 34=Malaya Port 35=Eclage");
  1708. return -1;
  1709. }
  1710. // get possible name of the city
  1711. map_name[MAP_NAME_LENGTH-1] = '\0';
  1712. for (i = 0; map_name[i]; i++)
  1713. map_name[i] = TOLOWER(map_name[i]);
  1714. // try to identify the map name
  1715. if (strncmp(map_name, "prontera", 3) == 0) {
  1716. town = 0;
  1717. } else if (strncmp(map_name, "morocc", 3) == 0) {
  1718. town = 1;
  1719. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1720. town = 2;
  1721. } else if (strncmp(map_name, "payon", 3) == 0 ||
  1722. strncmp(map_name, "paion", 3) == 0) {
  1723. town = 3;
  1724. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1725. town = 4;
  1726. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  1727. strncmp(map_name, "islude", 3) == 0) {
  1728. town = 5;
  1729. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  1730. strcmp(map_name, "al") == 0) {
  1731. town = 6;
  1732. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1733. strcmp(map_name, "christmas") == 0 ||
  1734. strncmp(map_name, "xmas", 3) == 0 ||
  1735. strncmp(map_name, "x-mas", 3) == 0) {
  1736. town = 7;
  1737. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1738. town = 8;
  1739. } else if (strncmp(map_name, "yuno", 3) == 0) {
  1740. town = 9;
  1741. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1742. town = 10;
  1743. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  1744. town = 11;
  1745. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1746. town = 12;
  1747. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1748. town = 13;
  1749. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1750. town = 14;
  1751. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1752. strncmp(map_name, "startpoint", 3) == 0 ||
  1753. strncmp(map_name, "begining", 3) == 0) {
  1754. town = 15;
  1755. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1756. strncmp(map_name, "prison", 3) == 0 ||
  1757. strncmp(map_name, "jails", 3) == 0) {
  1758. town = 16;
  1759. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  1760. strncmp(map_name, "jawai", 3) == 0) {
  1761. town = 17;
  1762. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  1763. strncmp(map_name, "ayotaya", 3) == 0) {
  1764. town = 18;
  1765. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  1766. strncmp(map_name, "ainbroch", 5) == 0) {
  1767. town = 19;
  1768. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1769. town = 20;
  1770. } else if (strncmp(map_name, "einbech", 3) == 0) {
  1771. town = 21;
  1772. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1773. town = 22;
  1774. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1775. town = 23;
  1776. } else if (strncmp(map_name, "veins", 3) == 0) {
  1777. town = 24;
  1778. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1779. town = 25;
  1780. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1781. town = 26;
  1782. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1783. town = 27;
  1784. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1785. town = 28;
  1786. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1787. town = 29;
  1788. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1789. town = 30;
  1790. } else if (strncmp(map_name, "mora", 3) == 0) {
  1791. town = 31;
  1792. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1793. town = 32;
  1794. } else if (strncmp(map_name, "malangdo", 3) == 0) {
  1795. town = 33;
  1796. } else if (strncmp(map_name, "malaya", 3) == 0) {
  1797. town = 34;
  1798. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1799. town = 35;
  1800. }
  1801. if (town >= 0 && town < ARRAYLENGTH(data))
  1802. {
  1803. m = map_mapname2mapid(data[town].map);
  1804. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1805. clif_displaymessage(fd, msg_txt(247));
  1806. return -1;
  1807. }
  1808. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1809. clif_displaymessage(fd, msg_txt(248));
  1810. return -1;
  1811. }
  1812. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1813. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1814. } else {
  1815. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1816. return -1;
  1817. }
  1818. } else { // if you arrive here, you have an error in town variable when reading of names
  1819. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1820. return -1;
  1821. }
  1822. return 0;
  1823. }
  1824. /*==========================================
  1825. *
  1826. *------------------------------------------*/
  1827. ACMD_FUNC(monster)
  1828. {
  1829. char name[NAME_LENGTH];
  1830. char monster[NAME_LENGTH];
  1831. char eventname[EVENT_NAME_LENGTH] = "";
  1832. int mob_id;
  1833. int number = 0;
  1834. int count;
  1835. int i, k, range;
  1836. short mx, my;
  1837. nullpo_retr(-1, sd);
  1838. memset(name, '\0', sizeof(name));
  1839. memset(monster, '\0', sizeof(monster));
  1840. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1841. if (!message || !*message) {
  1842. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  1843. return -1;
  1844. }
  1845. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1846. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1847. //All data can be left as it is.
  1848. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1849. //Here, it is possible name was not given and we are using monster for it.
  1850. if (count < 3) //Blank mob's name.
  1851. name[0] = '\0';
  1852. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1853. //All data can be left as it is.
  1854. } else if (sscanf(message, "%23s", monster) > 0) {
  1855. //As before, name may be already filled.
  1856. name[0] = '\0';
  1857. } else {
  1858. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  1859. return -1;
  1860. }
  1861. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1862. mob_id = mobdb_checkid(atoi(monster));
  1863. if (mob_id == 0) {
  1864. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1865. return -1;
  1866. }
  1867. if (mob_id == MOBID_EMPERIUM) {
  1868. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  1869. return -1;
  1870. }
  1871. if (number <= 0)
  1872. number = 1;
  1873. if( !name[0] )
  1874. strcpy(name, "--ja--");
  1875. // 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
  1876. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1877. number = battle_config.atc_spawn_quantity_limit;
  1878. if (strcmp(command+1, "monstersmall") == 0)
  1879. strcpy(eventname, "2");
  1880. else if (strcmp(command+1, "monsterbig") == 0)
  1881. strcpy(eventname, "4");
  1882. if (battle_config.etc_log)
  1883. 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);
  1884. count = 0;
  1885. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1886. for (i = 0; i < number; i++) {
  1887. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1888. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname);
  1889. count += (k != 0) ? 1 : 0;
  1890. }
  1891. if (count != 0)
  1892. if (number == count)
  1893. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  1894. else {
  1895. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  1896. clif_displaymessage(fd, atcmd_output);
  1897. }
  1898. else {
  1899. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1900. return -1;
  1901. }
  1902. return 0;
  1903. }
  1904. /*==========================================
  1905. *
  1906. *------------------------------------------*/
  1907. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1908. {
  1909. struct mob_data *md;
  1910. int flag;
  1911. nullpo_ret(md=(struct mob_data *)bl);
  1912. flag = va_arg(ap, int);
  1913. if (md->guardian_data)
  1914. return 0; //Do not touch WoE mobs!
  1915. if (flag)
  1916. status_zap(bl,md->status.hp, 0);
  1917. else
  1918. status_kill(bl);
  1919. return 1;
  1920. }
  1921. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  1922. {
  1923. int map_id;
  1924. char map_name[MAP_NAME_LENGTH_EXT];
  1925. if (!sd) return;
  1926. memset(map_name, '\0', sizeof(map_name));
  1927. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1928. map_id = sd->bl.m;
  1929. else {
  1930. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1931. map_id = sd->bl.m;
  1932. }
  1933. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  1934. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  1935. return;
  1936. }
  1937. ACMD_FUNC(killmonster)
  1938. {
  1939. atcommand_killmonster_sub(fd, sd, message, 1);
  1940. return 0;
  1941. }
  1942. /*==========================================
  1943. *
  1944. *------------------------------------------*/
  1945. ACMD_FUNC(killmonster2)
  1946. {
  1947. atcommand_killmonster_sub(fd, sd, message, 0);
  1948. return 0;
  1949. }
  1950. /*==========================================
  1951. *
  1952. *------------------------------------------*/
  1953. ACMD_FUNC(refine)
  1954. {
  1955. int i,j, position = 0, refine = 0, current_position, final_refine;
  1956. int count;
  1957. nullpo_retr(-1, sd);
  1958. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1959. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1960. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  1961. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  1962. clif_displaymessage(fd, atcmd_output);
  1963. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  1964. clif_displaymessage(fd, atcmd_output);
  1965. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  1966. clif_displaymessage(fd, atcmd_output);
  1967. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  1968. clif_displaymessage(fd, atcmd_output);
  1969. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  1970. clif_displaymessage(fd, atcmd_output);
  1971. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  1972. clif_displaymessage(fd, atcmd_output);
  1973. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  1974. clif_displaymessage(fd, atcmd_output);
  1975. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  1976. clif_displaymessage(fd, atcmd_output);
  1977. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  1978. clif_displaymessage(fd, atcmd_output);
  1979. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  1980. clif_displaymessage(fd, atcmd_output);
  1981. return -1;
  1982. }
  1983. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1984. count = 0;
  1985. for (j = 0; j < EQI_MAX-1; j++) {
  1986. if ((i = sd->equip_index[j]) < 0)
  1987. continue;
  1988. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1989. continue;
  1990. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1991. continue;
  1992. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1993. continue;
  1994. if(position && !(sd->status.inventory[i].equip & position))
  1995. continue;
  1996. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1997. if (sd->status.inventory[i].refine != final_refine) {
  1998. sd->status.inventory[i].refine = final_refine;
  1999. current_position = sd->status.inventory[i].equip;
  2000. pc_unequipitem(sd, i, 3);
  2001. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2002. clif_delitem(sd, i, 1, 3);
  2003. clif_additem(sd, i, 1, 0);
  2004. pc_equipitem(sd, i, current_position);
  2005. clif_misceffect(&sd->bl, 3);
  2006. count++;
  2007. }
  2008. }
  2009. if (count == 0)
  2010. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2011. else if (count == 1)
  2012. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2013. else {
  2014. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2015. clif_displaymessage(fd, atcmd_output);
  2016. }
  2017. return 0;
  2018. }
  2019. /*==========================================
  2020. *
  2021. *------------------------------------------*/
  2022. ACMD_FUNC(produce)
  2023. {
  2024. char item_name[100];
  2025. int item_id, attribute = 0, star = 0;
  2026. int flag = 0;
  2027. struct item_data *item_data;
  2028. struct item tmp_item;
  2029. nullpo_retr(-1, sd);
  2030. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2031. memset(item_name, '\0', sizeof(item_name));
  2032. if (!message || !*message || (
  2033. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2034. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2035. )) {
  2036. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2037. return -1;
  2038. }
  2039. item_id = 0;
  2040. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2041. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2042. {
  2043. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2044. return -1;
  2045. }
  2046. item_id = item_data->nameid;
  2047. if (itemdb_isequip2(item_data)) {
  2048. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2049. attribute = ATTRIBUTE_NORMAL;
  2050. if (star < MIN_STAR || star > MAX_STAR)
  2051. star = 0;
  2052. memset(&tmp_item, 0, sizeof tmp_item);
  2053. tmp_item.nameid = item_id;
  2054. tmp_item.amount = 1;
  2055. tmp_item.identify = 1;
  2056. tmp_item.card[0] = CARD0_FORGE;
  2057. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2058. ((star*5) << 8) + attribute:0;
  2059. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2060. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2061. clif_produceeffect(sd, 0, item_id);
  2062. clif_misceffect(&sd->bl, 3);
  2063. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2064. clif_additem(sd, 0, 0, flag);
  2065. } else {
  2066. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2067. clif_displaymessage(fd, atcmd_output);
  2068. return -1;
  2069. }
  2070. return 0;
  2071. }
  2072. /*==========================================
  2073. *
  2074. *------------------------------------------*/
  2075. ACMD_FUNC(memo)
  2076. {
  2077. int position = 0;
  2078. nullpo_retr(-1, sd);
  2079. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2080. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2081. {
  2082. int i;
  2083. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2084. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2085. {
  2086. if( sd->status.memo_point[i].map )
  2087. 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);
  2088. else
  2089. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2090. clif_displaymessage(sd->fd, atcmd_output);
  2091. }
  2092. return 0;
  2093. }
  2094. if( position < 0 || position >= MAX_MEMOPOINTS )
  2095. {
  2096. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2097. clif_displaymessage(fd, atcmd_output);
  2098. return -1;
  2099. }
  2100. pc_memo(sd, position);
  2101. return 0;
  2102. }
  2103. /*==========================================
  2104. *
  2105. *------------------------------------------*/
  2106. ACMD_FUNC(gat)
  2107. {
  2108. int y;
  2109. nullpo_retr(-1, sd);
  2110. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2111. for (y = 2; y >= -2; y--) {
  2112. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2113. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2114. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2115. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2116. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2117. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2118. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2119. clif_displaymessage(fd, atcmd_output);
  2120. }
  2121. return 0;
  2122. }
  2123. /*==========================================
  2124. *
  2125. *------------------------------------------*/
  2126. ACMD_FUNC(displaystatus)
  2127. {
  2128. int i, type, flag, tick;
  2129. nullpo_retr(-1, sd);
  2130. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2131. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2132. return -1;
  2133. }
  2134. if (i < 2) flag = 1;
  2135. if (i < 3) tick = 0;
  2136. clif_status_change(&sd->bl, type, flag, tick, 0, 0, 0);
  2137. return 0;
  2138. }
  2139. /*==========================================
  2140. * @stpoint (Rewritten by [Yor])
  2141. *------------------------------------------*/
  2142. ACMD_FUNC(statuspoint)
  2143. {
  2144. int point;
  2145. unsigned int new_status_point;
  2146. if (!message || !*message || (point = atoi(message)) == 0) {
  2147. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2148. return -1;
  2149. }
  2150. if(point < 0)
  2151. {
  2152. if(sd->status.status_point < (unsigned int)(-point))
  2153. {
  2154. new_status_point = 0;
  2155. }
  2156. else
  2157. {
  2158. new_status_point = sd->status.status_point + point;
  2159. }
  2160. }
  2161. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2162. {
  2163. new_status_point = UINT_MAX;
  2164. }
  2165. else
  2166. {
  2167. new_status_point = sd->status.status_point + point;
  2168. }
  2169. if (new_status_point != sd->status.status_point) {
  2170. sd->status.status_point = new_status_point;
  2171. clif_updatestatus(sd, SP_STATUSPOINT);
  2172. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2173. } else {
  2174. if (point < 0)
  2175. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2176. else
  2177. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2178. return -1;
  2179. }
  2180. return 0;
  2181. }
  2182. /*==========================================
  2183. * @skpoint (Rewritten by [Yor])
  2184. *------------------------------------------*/
  2185. ACMD_FUNC(skillpoint)
  2186. {
  2187. int point;
  2188. unsigned int new_skill_point;
  2189. nullpo_retr(-1, sd);
  2190. if (!message || !*message || (point = atoi(message)) == 0) {
  2191. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2192. return -1;
  2193. }
  2194. if(point < 0)
  2195. {
  2196. if(sd->status.skill_point < (unsigned int)(-point))
  2197. {
  2198. new_skill_point = 0;
  2199. }
  2200. else
  2201. {
  2202. new_skill_point = sd->status.skill_point + point;
  2203. }
  2204. }
  2205. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2206. {
  2207. new_skill_point = UINT_MAX;
  2208. }
  2209. else
  2210. {
  2211. new_skill_point = sd->status.skill_point + point;
  2212. }
  2213. if (new_skill_point != sd->status.skill_point) {
  2214. sd->status.skill_point = new_skill_point;
  2215. clif_updatestatus(sd, SP_SKILLPOINT);
  2216. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2217. } else {
  2218. if (point < 0)
  2219. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2220. else
  2221. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2222. return -1;
  2223. }
  2224. return 0;
  2225. }
  2226. /*==========================================
  2227. * @zeny (Rewritten by [Yor])
  2228. *------------------------------------------*/
  2229. ACMD_FUNC(zeny)
  2230. {
  2231. int zeny, new_zeny;
  2232. nullpo_retr(-1, sd);
  2233. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2234. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2235. return -1;
  2236. }
  2237. new_zeny = sd->status.zeny + zeny;
  2238. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2239. new_zeny = MAX_ZENY;
  2240. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2241. new_zeny = 0;
  2242. if (new_zeny != sd->status.zeny) {
  2243. sd->status.zeny = new_zeny;
  2244. clif_updatestatus(sd, SP_ZENY);
  2245. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2246. } else {
  2247. if (zeny < 0)
  2248. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2249. else
  2250. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2251. return -1;
  2252. }
  2253. return 0;
  2254. }
  2255. /*==========================================
  2256. *
  2257. *------------------------------------------*/
  2258. ACMD_FUNC(param)
  2259. {
  2260. int i, value = 0, new_value, max;
  2261. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2262. short* status[6];
  2263. //we don't use direct initialization because it isn't part of the c standard.
  2264. nullpo_retr(-1, sd);
  2265. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2266. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2267. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2268. clif_displaymessage(fd, atcmd_output);
  2269. return -1;
  2270. }
  2271. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2272. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2273. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2274. clif_displaymessage(fd, atcmd_output);
  2275. return -1;
  2276. }
  2277. status[0] = &sd->status.str;
  2278. status[1] = &sd->status.agi;
  2279. status[2] = &sd->status.vit;
  2280. status[3] = &sd->status.int_;
  2281. status[4] = &sd->status.dex;
  2282. status[5] = &sd->status.luk;
  2283. if( battle_config.atcommand_max_stat_bypass )
  2284. max = SHRT_MAX;
  2285. else
  2286. max = pc_maxparameter(sd);
  2287. if(value < 0 && *status[i] <= -value) {
  2288. new_value = 1;
  2289. } else if(max - *status[i] < value) {
  2290. new_value = max;
  2291. } else {
  2292. new_value = *status[i] + value;
  2293. }
  2294. if (new_value != *status[i]) {
  2295. *status[i] = new_value;
  2296. clif_updatestatus(sd, SP_STR + i);
  2297. clif_updatestatus(sd, SP_USTR + i);
  2298. status_calc_pc(sd, 0);
  2299. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2300. } else {
  2301. if (value < 0)
  2302. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2303. else
  2304. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2305. return -1;
  2306. }
  2307. return 0;
  2308. }
  2309. /*==========================================
  2310. * Stat all by fritz (rewritten by [Yor])
  2311. *------------------------------------------*/
  2312. ACMD_FUNC(stat_all)
  2313. {
  2314. int index, count, value, max, new_value;
  2315. short* status[6];
  2316. //we don't use direct initialization because it isn't part of the c standard.
  2317. nullpo_retr(-1, sd);
  2318. status[0] = &sd->status.str;
  2319. status[1] = &sd->status.agi;
  2320. status[2] = &sd->status.vit;
  2321. status[3] = &sd->status.int_;
  2322. status[4] = &sd->status.dex;
  2323. status[5] = &sd->status.luk;
  2324. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2325. value = pc_maxparameter(sd);
  2326. max = pc_maxparameter(sd);
  2327. } else {
  2328. if( battle_config.atcommand_max_stat_bypass )
  2329. max = SHRT_MAX;
  2330. else
  2331. max = pc_maxparameter(sd);
  2332. }
  2333. count = 0;
  2334. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2335. if (value > 0 && *status[index] > max - value)
  2336. new_value = max;
  2337. else if (value < 0 && *status[index] <= -value)
  2338. new_value = 1;
  2339. else
  2340. new_value = *status[index] +value;
  2341. if (new_value != (int)*status[index]) {
  2342. *status[index] = new_value;
  2343. clif_updatestatus(sd, SP_STR + index);
  2344. clif_updatestatus(sd, SP_USTR + index);
  2345. count++;
  2346. }
  2347. }
  2348. if (count > 0) { // if at least 1 stat modified
  2349. status_calc_pc(sd, 0);
  2350. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2351. } else {
  2352. if (value < 0)
  2353. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2354. else
  2355. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2356. return -1;
  2357. }
  2358. return 0;
  2359. }
  2360. /*==========================================
  2361. *
  2362. *------------------------------------------*/
  2363. ACMD_FUNC(guildlevelup)
  2364. {
  2365. int level = 0;
  2366. short added_level;
  2367. struct guild *guild_info;
  2368. nullpo_retr(-1, sd);
  2369. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2370. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2371. return -1;
  2372. }
  2373. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2374. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2375. return -1;
  2376. }
  2377. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2378. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2379. // return -1;
  2380. //}
  2381. added_level = (short)level;
  2382. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2383. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2384. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2385. added_level = 1 - guild_info->guild_lv;
  2386. if (added_level != 0) {
  2387. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2388. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2389. } else {
  2390. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2391. return -1;
  2392. }
  2393. return 0;
  2394. }
  2395. /*==========================================
  2396. *
  2397. *------------------------------------------*/
  2398. ACMD_FUNC(makeegg)
  2399. {
  2400. struct item_data *item_data;
  2401. int id, pet_id;
  2402. nullpo_retr(-1, sd);
  2403. if (!message || !*message) {
  2404. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2405. return -1;
  2406. }
  2407. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2408. id = item_data->nameid;
  2409. else
  2410. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2411. ;
  2412. else
  2413. id = atoi(message);
  2414. pet_id = search_petDB_index(id, PET_CLASS);
  2415. if (pet_id < 0)
  2416. pet_id = search_petDB_index(id, PET_EGG);
  2417. if (pet_id >= 0) {
  2418. sd->catch_target_class = pet_db[pet_id].class_;
  2419. intif_create_pet(
  2420. sd->status.account_id, sd->status.char_id,
  2421. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2422. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2423. 100, 0, 1, pet_db[pet_id].jname);
  2424. } else {
  2425. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2426. return -1;
  2427. }
  2428. return 0;
  2429. }
  2430. /*==========================================
  2431. *
  2432. *------------------------------------------*/
  2433. ACMD_FUNC(hatch)
  2434. {
  2435. nullpo_retr(-1, sd);
  2436. if (sd->status.pet_id <= 0)
  2437. clif_sendegg(sd);
  2438. else {
  2439. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2440. return -1;
  2441. }
  2442. return 0;
  2443. }
  2444. /*==========================================
  2445. *
  2446. *------------------------------------------*/
  2447. ACMD_FUNC(petfriendly)
  2448. {
  2449. int friendly;
  2450. struct pet_data *pd;
  2451. nullpo_retr(-1, sd);
  2452. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2453. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2454. return -1;
  2455. }
  2456. pd = sd->pd;
  2457. if (!pd) {
  2458. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2459. return -1;
  2460. }
  2461. if (friendly < 0 || friendly > 1000)
  2462. {
  2463. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2464. return -1;
  2465. }
  2466. if (friendly == pd->pet.intimate) {
  2467. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2468. return -1;
  2469. }
  2470. pet_set_intimate(pd, friendly);
  2471. clif_send_petstatus(sd);
  2472. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2473. return 0;
  2474. }
  2475. /*==========================================
  2476. *
  2477. *------------------------------------------*/
  2478. ACMD_FUNC(pethungry)
  2479. {
  2480. int hungry;
  2481. struct pet_data *pd;
  2482. nullpo_retr(-1, sd);
  2483. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2484. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2485. return -1;
  2486. }
  2487. pd = sd->pd;
  2488. if (!sd->status.pet_id || !pd) {
  2489. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2490. return -1;
  2491. }
  2492. if (hungry < 0 || hungry > 100) {
  2493. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2494. return -1;
  2495. }
  2496. if (hungry == pd->pet.hungry) {
  2497. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2498. return -1;
  2499. }
  2500. pd->pet.hungry = hungry;
  2501. clif_send_petstatus(sd);
  2502. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2503. return 0;
  2504. }
  2505. /*==========================================
  2506. *
  2507. *------------------------------------------*/
  2508. ACMD_FUNC(petrename)
  2509. {
  2510. struct pet_data *pd;
  2511. nullpo_retr(-1, sd);
  2512. if (!sd->status.pet_id || !sd->pd) {
  2513. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2514. return -1;
  2515. }
  2516. pd = sd->pd;
  2517. if (!pd->pet.rename_flag) {
  2518. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2519. return -1;
  2520. }
  2521. pd->pet.rename_flag = 0;
  2522. intif_save_petdata(sd->status.account_id, &pd->pet);
  2523. clif_send_petstatus(sd);
  2524. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2525. return 0;
  2526. }
  2527. /*==========================================
  2528. *
  2529. *------------------------------------------*/
  2530. ACMD_FUNC(recall)
  2531. {
  2532. struct map_session_data *pl_sd = NULL;
  2533. nullpo_retr(-1, sd);
  2534. if (!message || !*message) {
  2535. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2536. return -1;
  2537. }
  2538. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2539. {
  2540. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2541. return -1;
  2542. }
  2543. if (pl_sd == sd)
  2544. {
  2545. clif_displaymessage(fd, "You are already where you are...");
  2546. return -1;
  2547. }
  2548. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2549. {
  2550. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2551. return -1;
  2552. }
  2553. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2554. clif_displaymessage(fd, "You are not authorised to warp someone to your actual map.");
  2555. return -1;
  2556. }
  2557. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2558. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2559. return -1;
  2560. }
  2561. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2562. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2563. clif_displaymessage(fd, atcmd_output);
  2564. return 0;
  2565. }
  2566. /*==========================================
  2567. * charblock command (usage: charblock <player_name>)
  2568. * This command do a definitiv ban on a player
  2569. *------------------------------------------*/
  2570. ACMD_FUNC(char_block)
  2571. {
  2572. nullpo_retr(-1, sd);
  2573. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2574. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2575. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2576. return -1;
  2577. }
  2578. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2579. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2580. return 0;
  2581. }
  2582. /*==========================================
  2583. * charban command (usage: charban <time> <player_name>)
  2584. * This command do a limited ban on a player
  2585. * Time is done as follows:
  2586. * Adjustment value (-1, 1, +1, etc...)
  2587. * Modified element:
  2588. * a or y: year
  2589. * m: month
  2590. * j or d: day
  2591. * h: hour
  2592. * mn: minute
  2593. * s: second
  2594. * <example> @ban +1m-2mn1s-6y test_player
  2595. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2596. *------------------------------------------*/
  2597. ACMD_FUNC(char_ban)
  2598. {
  2599. char * modif_p;
  2600. int year, month, day, hour, minute, second, value;
  2601. time_t timestamp;
  2602. struct tm *tmtime;
  2603. nullpo_retr(-1, sd);
  2604. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2605. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2606. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2607. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2608. return -1;
  2609. }
  2610. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2611. modif_p = atcmd_output;
  2612. year = month = day = hour = minute = second = 0;
  2613. while (modif_p[0] != '\0') {
  2614. value = atoi(modif_p);
  2615. if (value == 0)
  2616. modif_p++;
  2617. else {
  2618. if (modif_p[0] == '-' || modif_p[0] == '+')
  2619. modif_p++;
  2620. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2621. modif_p++;
  2622. if (modif_p[0] == 's') {
  2623. second = value;
  2624. modif_p++;
  2625. } else if (modif_p[0] == 'n') {
  2626. minute = value;
  2627. modif_p++;
  2628. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2629. minute = value;
  2630. modif_p = modif_p + 2;
  2631. } else if (modif_p[0] == 'h') {
  2632. hour = value;
  2633. modif_p++;
  2634. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2635. day = value;
  2636. modif_p++;
  2637. } else if (modif_p[0] == 'm') {
  2638. month = value;
  2639. modif_p++;
  2640. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2641. year = value;
  2642. modif_p++;
  2643. } else if (modif_p[0] != '\0') {
  2644. modif_p++;
  2645. }
  2646. }
  2647. }
  2648. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2649. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2650. return -1;
  2651. }
  2652. /**
  2653. * We now check if you can adjust the ban to negative (and if this is the case)
  2654. **/
  2655. timestamp = time(NULL);
  2656. tmtime = localtime(&timestamp);
  2657. tmtime->tm_year = tmtime->tm_year + year;
  2658. tmtime->tm_mon = tmtime->tm_mon + month;
  2659. tmtime->tm_mday = tmtime->tm_mday + day;
  2660. tmtime->tm_hour = tmtime->tm_hour + hour;
  2661. tmtime->tm_min = tmtime->tm_min + minute;
  2662. tmtime->tm_sec = tmtime->tm_sec + second;
  2663. timestamp = mktime(tmtime);
  2664. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2665. clif_displaymessage(fd,"You are not allowed to reduce the length of a ban");
  2666. return -1;
  2667. }
  2668. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2669. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2670. return 0;
  2671. }
  2672. /*==========================================
  2673. * charunblock command (usage: charunblock <player_name>)
  2674. *------------------------------------------*/
  2675. ACMD_FUNC(char_unblock)
  2676. {
  2677. nullpo_retr(-1, sd);
  2678. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2679. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2680. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  2681. return -1;
  2682. }
  2683. // send answer to login server via char-server
  2684. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2685. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2686. return 0;
  2687. }
  2688. /*==========================================
  2689. * charunban command (usage: charunban <player_name>)
  2690. *------------------------------------------*/
  2691. ACMD_FUNC(char_unban)
  2692. {
  2693. nullpo_retr(-1, sd);
  2694. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2695. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2696. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  2697. return -1;
  2698. }
  2699. // send answer to login server via char-server
  2700. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2701. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2702. return 0;
  2703. }
  2704. /*==========================================
  2705. *
  2706. *------------------------------------------*/
  2707. ACMD_FUNC(night)
  2708. {
  2709. nullpo_retr(-1, sd);
  2710. if (night_flag != 1) {
  2711. map_night_timer(night_timer_tid, 0, 0, 1);
  2712. } else {
  2713. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  2714. return -1;
  2715. }
  2716. return 0;
  2717. }
  2718. /*==========================================
  2719. *
  2720. *------------------------------------------*/
  2721. ACMD_FUNC(day)
  2722. {
  2723. nullpo_retr(-1, sd);
  2724. if (night_flag != 0) {
  2725. map_day_timer(day_timer_tid, 0, 0, 1);
  2726. } else {
  2727. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  2728. return -1;
  2729. }
  2730. return 0;
  2731. }
  2732. /*==========================================
  2733. *
  2734. *------------------------------------------*/
  2735. ACMD_FUNC(doom)
  2736. {
  2737. struct map_session_data* pl_sd;
  2738. struct s_mapiterator* iter;
  2739. nullpo_retr(-1, sd);
  2740. iter = mapit_getallusers();
  2741. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2742. {
  2743. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2744. {
  2745. status_kill(&pl_sd->bl);
  2746. clif_specialeffect(&pl_sd->bl,450,AREA);
  2747. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2748. }
  2749. }
  2750. mapit_free(iter);
  2751. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2752. return 0;
  2753. }
  2754. /*==========================================
  2755. *
  2756. *------------------------------------------*/
  2757. ACMD_FUNC(doommap)
  2758. {
  2759. struct map_session_data* pl_sd;
  2760. struct s_mapiterator* iter;
  2761. nullpo_retr(-1, sd);
  2762. iter = mapit_getallusers();
  2763. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2764. {
  2765. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2766. {
  2767. status_kill(&pl_sd->bl);
  2768. clif_specialeffect(&pl_sd->bl,450,AREA);
  2769. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2770. }
  2771. }
  2772. mapit_free(iter);
  2773. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2774. return 0;
  2775. }
  2776. /*==========================================
  2777. *
  2778. *------------------------------------------*/
  2779. static void atcommand_raise_sub(struct map_session_data* sd)
  2780. {
  2781. if (!status_isdead(&sd->bl))
  2782. return;
  2783. if(!status_revive(&sd->bl, 100, 100))
  2784. return;
  2785. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2786. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  2787. }
  2788. /*==========================================
  2789. *
  2790. *------------------------------------------*/
  2791. ACMD_FUNC(raise)
  2792. {
  2793. struct map_session_data* pl_sd;
  2794. struct s_mapiterator* iter;
  2795. nullpo_retr(-1, sd);
  2796. iter = mapit_getallusers();
  2797. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2798. atcommand_raise_sub(pl_sd);
  2799. mapit_free(iter);
  2800. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2801. return 0;
  2802. }
  2803. /*==========================================
  2804. *
  2805. *------------------------------------------*/
  2806. ACMD_FUNC(raisemap)
  2807. {
  2808. struct map_session_data* pl_sd;
  2809. struct s_mapiterator* iter;
  2810. nullpo_retr(-1, sd);
  2811. iter = mapit_getallusers();
  2812. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2813. if (sd->bl.m == pl_sd->bl.m)
  2814. atcommand_raise_sub(pl_sd);
  2815. mapit_free(iter);
  2816. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2817. return 0;
  2818. }
  2819. /*==========================================
  2820. *
  2821. *------------------------------------------*/
  2822. ACMD_FUNC(kick)
  2823. {
  2824. struct map_session_data *pl_sd;
  2825. nullpo_retr(-1, sd);
  2826. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2827. if (!message || !*message) {
  2828. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  2829. return -1;
  2830. }
  2831. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2832. {
  2833. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2834. return -1;
  2835. }
  2836. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2837. {
  2838. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2839. return -1;
  2840. }
  2841. clif_GM_kick(sd, pl_sd);
  2842. return 0;
  2843. }
  2844. /*==========================================
  2845. *
  2846. *------------------------------------------*/
  2847. ACMD_FUNC(kickall)
  2848. {
  2849. struct map_session_data* pl_sd;
  2850. struct s_mapiterator* iter;
  2851. nullpo_retr(-1, sd);
  2852. iter = mapit_getallusers();
  2853. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2854. {
  2855. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2856. if (sd->status.account_id != pl_sd->status.account_id)
  2857. clif_GM_kick(NULL, pl_sd);
  2858. }
  2859. }
  2860. mapit_free(iter);
  2861. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  2862. return 0;
  2863. }
  2864. /*==========================================
  2865. *
  2866. *------------------------------------------*/
  2867. ACMD_FUNC(allskill)
  2868. {
  2869. nullpo_retr(-1, sd);
  2870. pc_allskillup(sd); // all skills
  2871. sd->status.skill_point = 0; // 0 skill points
  2872. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2873. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  2874. return 0;
  2875. }
  2876. /*==========================================
  2877. *
  2878. *------------------------------------------*/
  2879. ACMD_FUNC(questskill)
  2880. {
  2881. int skill_id;
  2882. nullpo_retr(-1, sd);
  2883. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  2884. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  2885. return -1;
  2886. }
  2887. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  2888. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2889. return -1;
  2890. }
  2891. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2892. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2893. return -1;
  2894. }
  2895. if (pc_checkskill(sd, skill_id) > 0) {
  2896. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  2897. return -1;
  2898. }
  2899. pc_skill(sd, skill_id, 1, 0);
  2900. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  2901. return 0;
  2902. }
  2903. /*==========================================
  2904. *
  2905. *------------------------------------------*/
  2906. ACMD_FUNC(lostskill)
  2907. {
  2908. int skill_id;
  2909. nullpo_retr(-1, sd);
  2910. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  2911. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  2912. return -1;
  2913. }
  2914. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  2915. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2916. return -1;
  2917. }
  2918. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2919. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2920. return -1;
  2921. }
  2922. if (pc_checkskill(sd, skill_id) == 0) {
  2923. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  2924. return -1;
  2925. }
  2926. sd->status.skill[skill_id].lv = 0;
  2927. sd->status.skill[skill_id].flag = 0;
  2928. clif_deleteskill(sd,skill_id);
  2929. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  2930. return 0;
  2931. }
  2932. /*==========================================
  2933. *
  2934. *------------------------------------------*/
  2935. ACMD_FUNC(spiritball)
  2936. {
  2937. int max_spiritballs;
  2938. int number;
  2939. nullpo_retr(-1, sd);
  2940. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2941. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2942. {
  2943. char msg[CHAT_SIZE_MAX];
  2944. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  2945. clif_displaymessage(fd, msg);
  2946. return -1;
  2947. }
  2948. if( sd->spiritball > 0 )
  2949. pc_delspiritball(sd, sd->spiritball, 1);
  2950. sd->spiritball = number;
  2951. clif_spiritball(sd);
  2952. // no message, player can look the difference
  2953. return 0;
  2954. }
  2955. /*==========================================
  2956. *
  2957. *------------------------------------------*/
  2958. ACMD_FUNC(party)
  2959. {
  2960. char party[NAME_LENGTH];
  2961. nullpo_retr(-1, sd);
  2962. memset(party, '\0', sizeof(party));
  2963. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2964. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  2965. return -1;
  2966. }
  2967. party_create(sd, party, 0, 0);
  2968. return 0;
  2969. }
  2970. /*==========================================
  2971. *
  2972. *------------------------------------------*/
  2973. ACMD_FUNC(guild)
  2974. {
  2975. char guild[NAME_LENGTH];
  2976. int prev;
  2977. nullpo_retr(-1, sd);
  2978. memset(guild, '\0', sizeof(guild));
  2979. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2980. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  2981. return -1;
  2982. }
  2983. prev = battle_config.guild_emperium_check;
  2984. battle_config.guild_emperium_check = 0;
  2985. guild_create(sd, guild);
  2986. battle_config.guild_emperium_check = prev;
  2987. return 0;
  2988. }
  2989. /*==========================================
  2990. *
  2991. *------------------------------------------*/
  2992. ACMD_FUNC(agitstart)
  2993. {
  2994. nullpo_retr(-1, sd);
  2995. if (agit_flag == 1) {
  2996. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  2997. return -1;
  2998. }
  2999. agit_flag = 1;
  3000. guild_agit_start();
  3001. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3002. return 0;
  3003. }
  3004. /*==========================================
  3005. *
  3006. *------------------------------------------*/
  3007. ACMD_FUNC(agitstart2)
  3008. {
  3009. nullpo_retr(-1, sd);
  3010. if (agit2_flag == 1) {
  3011. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3012. return -1;
  3013. }
  3014. agit2_flag = 1;
  3015. guild_agit2_start();
  3016. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3017. return 0;
  3018. }
  3019. /*==========================================
  3020. *
  3021. *------------------------------------------*/
  3022. ACMD_FUNC(agitend)
  3023. {
  3024. nullpo_retr(-1, sd);
  3025. if (agit_flag == 0) {
  3026. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3027. return -1;
  3028. }
  3029. agit_flag = 0;
  3030. guild_agit_end();
  3031. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3032. return 0;
  3033. }
  3034. /*==========================================
  3035. *
  3036. *------------------------------------------*/
  3037. ACMD_FUNC(agitend2)
  3038. {
  3039. nullpo_retr(-1, sd);
  3040. if (agit2_flag == 0) {
  3041. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3042. return -1;
  3043. }
  3044. agit2_flag = 0;
  3045. guild_agit2_end();
  3046. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3047. return 0;
  3048. }
  3049. /*==========================================
  3050. * @mapexit - shuts down the map server
  3051. *------------------------------------------*/
  3052. ACMD_FUNC(mapexit)
  3053. {
  3054. nullpo_retr(-1, sd);
  3055. do_shutdown();
  3056. return 0;
  3057. }
  3058. /*==========================================
  3059. * idsearch <part_of_name>: revrited by [Yor]
  3060. *------------------------------------------*/
  3061. ACMD_FUNC(idsearch)
  3062. {
  3063. char item_name[100];
  3064. unsigned int i, match;
  3065. struct item_data *item_array[MAX_SEARCH];
  3066. nullpo_retr(-1, sd);
  3067. memset(item_name, '\0', sizeof(item_name));
  3068. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3069. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3070. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3071. return -1;
  3072. }
  3073. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3074. clif_displaymessage(fd, atcmd_output);
  3075. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3076. if (match > MAX_SEARCH) {
  3077. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3078. clif_displaymessage(fd, atcmd_output);
  3079. match = MAX_SEARCH;
  3080. }
  3081. for(i = 0; i < match; i++) {
  3082. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3083. clif_displaymessage(fd, atcmd_output);
  3084. }
  3085. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3086. clif_displaymessage(fd, atcmd_output);
  3087. return 0;
  3088. }
  3089. /*==========================================
  3090. * Recall All Characters Online To Your Location
  3091. *------------------------------------------*/
  3092. ACMD_FUNC(recallall)
  3093. {
  3094. struct map_session_data* pl_sd;
  3095. struct s_mapiterator* iter;
  3096. int count;
  3097. nullpo_retr(-1, sd);
  3098. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3099. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3100. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3101. return -1;
  3102. }
  3103. count = 0;
  3104. iter = mapit_getallusers();
  3105. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3106. {
  3107. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3108. {
  3109. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3110. count++;
  3111. else {
  3112. if (pc_isdead(pl_sd)) { //Wake them up
  3113. pc_setstand(pl_sd);
  3114. pc_setrestartvalue(pl_sd,1);
  3115. }
  3116. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3117. }
  3118. }
  3119. }
  3120. mapit_free(iter);
  3121. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3122. if (count) {
  3123. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3124. clif_displaymessage(fd, atcmd_output);
  3125. }
  3126. return 0;
  3127. }
  3128. /*==========================================
  3129. * Recall online characters of a guild to your location
  3130. *------------------------------------------*/
  3131. ACMD_FUNC(guildrecall)
  3132. {
  3133. struct map_session_data* pl_sd;
  3134. struct s_mapiterator* iter;
  3135. int count;
  3136. char guild_name[NAME_LENGTH];
  3137. struct guild *g;
  3138. nullpo_retr(-1, sd);
  3139. memset(guild_name, '\0', sizeof(guild_name));
  3140. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3141. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3142. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3143. return -1;
  3144. }
  3145. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3146. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3147. return -1;
  3148. }
  3149. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3150. (g = guild_search(atoi(message))) == NULL)
  3151. {
  3152. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3153. return -1;
  3154. }
  3155. count = 0;
  3156. iter = mapit_getallusers();
  3157. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3158. {
  3159. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3160. {
  3161. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3162. continue; //Skip GMs greater than you.
  3163. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3164. count++;
  3165. else
  3166. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3167. }
  3168. }
  3169. mapit_free(iter);
  3170. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3171. clif_displaymessage(fd, atcmd_output);
  3172. if (count) {
  3173. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3174. clif_displaymessage(fd, atcmd_output);
  3175. }
  3176. return 0;
  3177. }
  3178. /*==========================================
  3179. * Recall online characters of a party to your location
  3180. *------------------------------------------*/
  3181. ACMD_FUNC(partyrecall)
  3182. {
  3183. struct map_session_data* pl_sd;
  3184. struct s_mapiterator* iter;
  3185. char party_name[NAME_LENGTH];
  3186. struct party_data *p;
  3187. int count;
  3188. nullpo_retr(-1, sd);
  3189. memset(party_name, '\0', sizeof(party_name));
  3190. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3191. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3192. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3193. return -1;
  3194. }
  3195. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3196. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3197. return -1;
  3198. }
  3199. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3200. (p = party_search(atoi(message))) == NULL)
  3201. {
  3202. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3203. return -1;
  3204. }
  3205. count = 0;
  3206. iter = mapit_getallusers();
  3207. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3208. {
  3209. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3210. {
  3211. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3212. continue; //Skip GMs greater than you.
  3213. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3214. count++;
  3215. else
  3216. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3217. }
  3218. }
  3219. mapit_free(iter);
  3220. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3221. clif_displaymessage(fd, atcmd_output);
  3222. if (count) {
  3223. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3224. clif_displaymessage(fd, atcmd_output);
  3225. }
  3226. return 0;
  3227. }
  3228. /*==========================================
  3229. *
  3230. *------------------------------------------*/
  3231. ACMD_FUNC(reloaditemdb)
  3232. {
  3233. nullpo_retr(-1, sd);
  3234. itemdb_reload();
  3235. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3236. return 0;
  3237. }
  3238. /*==========================================
  3239. *
  3240. *------------------------------------------*/
  3241. ACMD_FUNC(reloadmobdb)
  3242. {
  3243. nullpo_retr(-1, sd);
  3244. mob_reload();
  3245. read_petdb();
  3246. merc_reload();
  3247. read_mercenarydb();
  3248. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3249. return 0;
  3250. }
  3251. /*==========================================
  3252. *
  3253. *------------------------------------------*/
  3254. ACMD_FUNC(reloadskilldb)
  3255. {
  3256. nullpo_retr(-1, sd);
  3257. skill_reload();
  3258. merc_skill_reload();
  3259. read_mercenary_skilldb();
  3260. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3261. return 0;
  3262. }
  3263. /*==========================================
  3264. * @reloadatcommand - reloads atcommand_athena.conf groups.conf
  3265. *------------------------------------------*/
  3266. void atcommand_doload();
  3267. ACMD_FUNC(reloadatcommand) {
  3268. atcommand_doload();
  3269. pc_groups_reload();
  3270. clif_displaymessage(fd, msg_txt(254));
  3271. return 0;
  3272. }
  3273. /*==========================================
  3274. * @reloadbattleconf - reloads battle_athena.conf
  3275. *------------------------------------------*/
  3276. ACMD_FUNC(reloadbattleconf)
  3277. {
  3278. struct Battle_Config prev_config;
  3279. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3280. battle_config_read(BATTLE_CONF_FILENAME);
  3281. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3282. || prev_config.item_rate_common != battle_config.item_rate_common
  3283. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3284. || prev_config.item_rate_card != battle_config.item_rate_card
  3285. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3286. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3287. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3288. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3289. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3290. || prev_config.item_rate_use != battle_config.item_rate_use
  3291. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3292. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3293. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3294. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3295. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3296. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3297. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3298. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3299. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3300. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3301. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3302. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3303. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3304. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3305. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3306. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3307. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3308. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3309. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3310. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3311. )
  3312. { // Exp or Drop rates changed.
  3313. mob_reload(); //Needed as well so rate changes take effect.
  3314. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3315. }
  3316. clif_displaymessage(fd, msg_txt(255));
  3317. return 0;
  3318. }
  3319. /*==========================================
  3320. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3321. *------------------------------------------*/
  3322. ACMD_FUNC(reloadstatusdb)
  3323. {
  3324. status_readdb();
  3325. clif_displaymessage(fd, msg_txt(256));
  3326. return 0;
  3327. }
  3328. /*==========================================
  3329. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3330. *------------------------------------------*/
  3331. ACMD_FUNC(reloadpcdb)
  3332. {
  3333. pc_readdb();
  3334. clif_displaymessage(fd, msg_txt(257));
  3335. return 0;
  3336. }
  3337. /*==========================================
  3338. * @reloadmotd - reloads motd.txt
  3339. *------------------------------------------*/
  3340. ACMD_FUNC(reloadmotd)
  3341. {
  3342. pc_read_motd();
  3343. clif_displaymessage(fd, msg_txt(268));
  3344. return 0;
  3345. }
  3346. /*==========================================
  3347. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3348. *------------------------------------------*/
  3349. ACMD_FUNC(reloadscript)
  3350. {
  3351. nullpo_retr(-1, sd);
  3352. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3353. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3354. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3355. flush_fifos();
  3356. script_reload();
  3357. npc_reload();
  3358. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3359. return 0;
  3360. }
  3361. /*==========================================
  3362. * @mapinfo [0-3] <map name> by MC_Cameri
  3363. * => Shows information about the map [map name]
  3364. * 0 = no additional information
  3365. * 1 = Show users in that map and their location
  3366. * 2 = Shows NPCs in that map
  3367. * 3 = Shows the shops/chats in that map (not implemented)
  3368. *------------------------------------------*/
  3369. ACMD_FUNC(mapinfo)
  3370. {
  3371. struct map_session_data* pl_sd;
  3372. struct s_mapiterator* iter;
  3373. struct npc_data *nd = NULL;
  3374. struct chat_data *cd = NULL;
  3375. char direction[12];
  3376. int i, m_id, chat_num, list = 0;
  3377. unsigned short m_index;
  3378. char mapname[24];
  3379. nullpo_retr(-1, sd);
  3380. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3381. memset(mapname, '\0', sizeof(mapname));
  3382. memset(direction, '\0', sizeof(direction));
  3383. sscanf(message, "%d %23[^\n]", &list, mapname);
  3384. if (list < 0 || list > 3) {
  3385. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3386. return -1;
  3387. }
  3388. if (mapname[0] == '\0') {
  3389. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3390. m_id = map_mapindex2mapid(sd->mapindex);
  3391. } else {
  3392. m_id = map_mapname2mapid(mapname);
  3393. }
  3394. if (m_id < 0) {
  3395. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3396. return -1;
  3397. }
  3398. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3399. clif_displaymessage(fd, "------ Map Info ------");
  3400. // count chats (for initial message)
  3401. chat_num = 0;
  3402. iter = mapit_getallusers();
  3403. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3404. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3405. chat_num++;
  3406. mapit_free(iter);
  3407. 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);
  3408. clif_displaymessage(fd, atcmd_output);
  3409. clif_displaymessage(fd, "------ Map Flags ------");
  3410. if (map[m_id].flag.town)
  3411. clif_displaymessage(fd, "Town Map");
  3412. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3413. clif_displaymessage(fd, "Autotrade Enabled");
  3414. else
  3415. clif_displaymessage(fd, "Autotrade Disabled");
  3416. if (map[m_id].flag.battleground)
  3417. clif_displaymessage(fd, "Battlegrounds ON");
  3418. strcpy(atcmd_output,"PvP Flags: ");
  3419. if (map[m_id].flag.pvp)
  3420. strcat(atcmd_output, "Pvp ON | ");
  3421. if (map[m_id].flag.pvp_noguild)
  3422. strcat(atcmd_output, "NoGuild | ");
  3423. if (map[m_id].flag.pvp_noparty)
  3424. strcat(atcmd_output, "NoParty | ");
  3425. if (map[m_id].flag.pvp_nightmaredrop)
  3426. strcat(atcmd_output, "NightmareDrop | ");
  3427. if (map[m_id].flag.pvp_nocalcrank)
  3428. strcat(atcmd_output, "NoCalcRank | ");
  3429. clif_displaymessage(fd, atcmd_output);
  3430. strcpy(atcmd_output,"GvG Flags: ");
  3431. if (map[m_id].flag.gvg)
  3432. strcat(atcmd_output, "GvG ON | ");
  3433. if (map[m_id].flag.gvg_dungeon)
  3434. strcat(atcmd_output, "GvG Dungeon | ");
  3435. if (map[m_id].flag.gvg_castle)
  3436. strcat(atcmd_output, "GvG Castle | ");
  3437. if (map[m_id].flag.gvg_noparty)
  3438. strcat(atcmd_output, "NoParty | ");
  3439. clif_displaymessage(fd, atcmd_output);
  3440. strcpy(atcmd_output,"Teleport Flags: ");
  3441. if (map[m_id].flag.noteleport)
  3442. strcat(atcmd_output, "NoTeleport | ");
  3443. if (map[m_id].flag.monster_noteleport)
  3444. strcat(atcmd_output, "Monster NoTeleport | ");
  3445. if (map[m_id].flag.nowarp)
  3446. strcat(atcmd_output, "NoWarp | ");
  3447. if (map[m_id].flag.nowarpto)
  3448. strcat(atcmd_output, "NoWarpTo | ");
  3449. if (map[m_id].flag.noreturn)
  3450. strcat(atcmd_output, "NoReturn | ");
  3451. if (map[m_id].flag.nogo)
  3452. strcat(atcmd_output, "NoGo | ");
  3453. if (map[m_id].flag.nomemo)
  3454. strcat(atcmd_output, "NoMemo | ");
  3455. clif_displaymessage(fd, atcmd_output);
  3456. 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");
  3457. clif_displaymessage(fd, atcmd_output);
  3458. if (map[m_id].flag.nosave) {
  3459. if (!map[m_id].save.map)
  3460. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3461. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3462. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3463. else
  3464. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3465. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3466. clif_displaymessage(fd, atcmd_output);
  3467. }
  3468. strcpy(atcmd_output,"Weather Flags: ");
  3469. if (map[m_id].flag.snow)
  3470. strcat(atcmd_output, "Snow | ");
  3471. if (map[m_id].flag.fog)
  3472. strcat(atcmd_output, "Fog | ");
  3473. if (map[m_id].flag.sakura)
  3474. strcat(atcmd_output, "Sakura | ");
  3475. if (map[m_id].flag.clouds)
  3476. strcat(atcmd_output, "Clouds | ");
  3477. if (map[m_id].flag.clouds2)
  3478. strcat(atcmd_output, "Clouds2 | ");
  3479. if (map[m_id].flag.fireworks)
  3480. strcat(atcmd_output, "Fireworks | ");
  3481. if (map[m_id].flag.leaves)
  3482. strcat(atcmd_output, "Leaves | ");
  3483. /**
  3484. * No longer available, keeping here just in case it's back someday. [Ind]
  3485. **/
  3486. //if (map[m_id].flag.rain)
  3487. // strcat(atcmd_output, "Rain | ");
  3488. if (map[m_id].flag.nightenabled)
  3489. strcat(atcmd_output, "Displays Night | ");
  3490. clif_displaymessage(fd, atcmd_output);
  3491. strcpy(atcmd_output,"Other Flags: ");
  3492. if (map[m_id].flag.nobranch)
  3493. strcat(atcmd_output, "NoBranch | ");
  3494. if (map[m_id].flag.notrade)
  3495. strcat(atcmd_output, "NoTrade | ");
  3496. if (map[m_id].flag.novending)
  3497. strcat(atcmd_output, "NoVending | ");
  3498. if (map[m_id].flag.nodrop)
  3499. strcat(atcmd_output, "NoDrop | ");
  3500. if (map[m_id].flag.noskill)
  3501. strcat(atcmd_output, "NoSkill | ");
  3502. if (map[m_id].flag.noicewall)
  3503. strcat(atcmd_output, "NoIcewall | ");
  3504. if (map[m_id].flag.allowks)
  3505. strcat(atcmd_output, "AllowKS | ");
  3506. if (map[m_id].flag.reset)
  3507. strcat(atcmd_output, "Reset | ");
  3508. clif_displaymessage(fd, atcmd_output);
  3509. strcpy(atcmd_output,"Other Flags: ");
  3510. if (map[m_id].nocommand)
  3511. strcat(atcmd_output, "NoCommand | ");
  3512. if (map[m_id].flag.nobaseexp)
  3513. strcat(atcmd_output, "NoBaseEXP | ");
  3514. if (map[m_id].flag.nojobexp)
  3515. strcat(atcmd_output, "NoJobEXP | ");
  3516. if (map[m_id].flag.nomobloot)
  3517. strcat(atcmd_output, "NoMobLoot | ");
  3518. if (map[m_id].flag.nomvploot)
  3519. strcat(atcmd_output, "NoMVPLoot | ");
  3520. if (map[m_id].flag.partylock)
  3521. strcat(atcmd_output, "PartyLock | ");
  3522. if (map[m_id].flag.guildlock)
  3523. strcat(atcmd_output, "GuildLock | ");
  3524. clif_displaymessage(fd, atcmd_output);
  3525. switch (list) {
  3526. case 0:
  3527. // Do nothing. It's list 0, no additional display.
  3528. break;
  3529. case 1:
  3530. clif_displaymessage(fd, "----- Players in Map -----");
  3531. iter = mapit_getallusers();
  3532. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3533. {
  3534. if (pl_sd->mapindex == m_index) {
  3535. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3536. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3537. clif_displaymessage(fd, atcmd_output);
  3538. }
  3539. }
  3540. mapit_free(iter);
  3541. break;
  3542. case 2:
  3543. clif_displaymessage(fd, "----- NPCs in Map -----");
  3544. for (i = 0; i < map[m_id].npc_num;)
  3545. {
  3546. nd = map[m_id].npc[i];
  3547. switch(nd->ud.dir) {
  3548. case 0: strcpy(direction, "North"); break;
  3549. case 1: strcpy(direction, "North West"); break;
  3550. case 2: strcpy(direction, "West"); break;
  3551. case 3: strcpy(direction, "South West"); break;
  3552. case 4: strcpy(direction, "South"); break;
  3553. case 5: strcpy(direction, "South East"); break;
  3554. case 6: strcpy(direction, "East"); break;
  3555. case 7: strcpy(direction, "North East"); break;
  3556. case 9: strcpy(direction, "North"); break;
  3557. default: strcpy(direction, "Unknown"); break;
  3558. }
  3559. if(strcmp(nd->name,nd->exname) == 0)
  3560. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3561. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3562. else
  3563. sprintf(atcmd_output, "NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d",
  3564. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3565. clif_displaymessage(fd, atcmd_output);
  3566. }
  3567. break;
  3568. case 3:
  3569. clif_displaymessage(fd, "----- Chats in Map -----");
  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 ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3574. pl_sd->mapindex == m_index &&
  3575. cd->usersd[0] == pl_sd)
  3576. {
  3577. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  3578. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3579. clif_displaymessage(fd, atcmd_output);
  3580. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3581. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3582. clif_displaymessage(fd, atcmd_output);
  3583. }
  3584. }
  3585. mapit_free(iter);
  3586. break;
  3587. default: // normally impossible to arrive here
  3588. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3589. return -1;
  3590. break;
  3591. }
  3592. return 0;
  3593. }
  3594. /*==========================================
  3595. *
  3596. *------------------------------------------*/
  3597. ACMD_FUNC(mount_peco)
  3598. {
  3599. nullpo_retr(-1, sd);
  3600. if( pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3601. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3602. clif_displaymessage(sd->fd,"You have mounted your Dragon");
  3603. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3604. } else {
  3605. clif_displaymessage(sd->fd,"You have released your Dragon");
  3606. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3607. }
  3608. return 0;
  3609. }
  3610. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3611. if( !(sd->sc.option&OPTION_MADOGEAR) ) {
  3612. clif_displaymessage(sd->fd,"You have mounted your Mado Gear");
  3613. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3614. } else {
  3615. clif_displaymessage(sd->fd,"You have released your Mado Gear");
  3616. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3617. }
  3618. return 0;
  3619. }
  3620. if (!pc_isriding(sd)) { // if actually no peco
  3621. if (!pc_checkskill(sd, KN_RIDING))
  3622. {
  3623. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  3624. return -1;
  3625. }
  3626. if (sd->disguise)
  3627. {
  3628. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  3629. return -1;
  3630. }
  3631. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3632. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  3633. } else { //Dismount
  3634. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3635. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  3636. }
  3637. return 0;
  3638. }
  3639. /*==========================================
  3640. *Spy Commands by Syrus22
  3641. *------------------------------------------*/
  3642. ACMD_FUNC(guildspy)
  3643. {
  3644. char guild_name[NAME_LENGTH];
  3645. struct guild *g;
  3646. nullpo_retr(-1, sd);
  3647. memset(guild_name, '\0', sizeof(guild_name));
  3648. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3649. if (!enable_spy)
  3650. {
  3651. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3652. return -1;
  3653. }
  3654. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3655. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3656. return -1;
  3657. }
  3658. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3659. (g = guild_search(atoi(message))) != NULL) {
  3660. if (sd->guildspy == g->guild_id) {
  3661. sd->guildspy = 0;
  3662. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3663. clif_displaymessage(fd, atcmd_output);
  3664. } else {
  3665. sd->guildspy = g->guild_id;
  3666. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3667. clif_displaymessage(fd, atcmd_output);
  3668. }
  3669. } else {
  3670. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  3671. return -1;
  3672. }
  3673. return 0;
  3674. }
  3675. /*==========================================
  3676. *
  3677. *------------------------------------------*/
  3678. ACMD_FUNC(partyspy)
  3679. {
  3680. char party_name[NAME_LENGTH];
  3681. struct party_data *p;
  3682. nullpo_retr(-1, sd);
  3683. memset(party_name, '\0', sizeof(party_name));
  3684. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3685. if (!enable_spy)
  3686. {
  3687. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3688. return -1;
  3689. }
  3690. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3691. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3692. return -1;
  3693. }
  3694. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3695. (p = party_search(atoi(message))) != NULL) {
  3696. if (sd->partyspy == p->party.party_id) {
  3697. sd->partyspy = 0;
  3698. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3699. clif_displaymessage(fd, atcmd_output);
  3700. } else {
  3701. sd->partyspy = p->party.party_id;
  3702. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3703. clif_displaymessage(fd, atcmd_output);
  3704. }
  3705. } else {
  3706. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  3707. return -1;
  3708. }
  3709. return 0;
  3710. }
  3711. /*==========================================
  3712. * @repairall [Valaris]
  3713. *------------------------------------------*/
  3714. ACMD_FUNC(repairall)
  3715. {
  3716. int count, i;
  3717. nullpo_retr(-1, sd);
  3718. count = 0;
  3719. for (i = 0; i < MAX_INVENTORY; i++) {
  3720. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3721. sd->status.inventory[i].attribute = 0;
  3722. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3723. count++;
  3724. }
  3725. }
  3726. if (count > 0) {
  3727. clif_misceffect(&sd->bl, 3);
  3728. clif_equiplist(sd);
  3729. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3730. } else {
  3731. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3732. return -1;
  3733. }
  3734. return 0;
  3735. }
  3736. /*==========================================
  3737. * @nuke [Valaris]
  3738. *------------------------------------------*/
  3739. ACMD_FUNC(nuke)
  3740. {
  3741. struct map_session_data *pl_sd;
  3742. nullpo_retr(-1, sd);
  3743. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3744. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3745. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  3746. return -1;
  3747. }
  3748. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3749. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3750. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3751. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3752. } else {
  3753. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3754. return -1;
  3755. }
  3756. } else {
  3757. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3758. return -1;
  3759. }
  3760. return 0;
  3761. }
  3762. /*==========================================
  3763. * @tonpc
  3764. *------------------------------------------*/
  3765. ACMD_FUNC(tonpc)
  3766. {
  3767. char npcname[NAME_LENGTH+1];
  3768. struct npc_data *nd;
  3769. nullpo_retr(-1, sd);
  3770. memset(npcname, 0, sizeof(npcname));
  3771. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3772. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  3773. return -1;
  3774. }
  3775. if ((nd = npc_name2id(npcname)) != NULL) {
  3776. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3777. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3778. else
  3779. return -1;
  3780. } else {
  3781. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3782. return -1;
  3783. }
  3784. return 0;
  3785. }
  3786. /*==========================================
  3787. *
  3788. *------------------------------------------*/
  3789. ACMD_FUNC(shownpc)
  3790. {
  3791. char NPCname[NAME_LENGTH+1];
  3792. nullpo_retr(-1, sd);
  3793. memset(NPCname, '\0', sizeof(NPCname));
  3794. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3795. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  3796. return -1;
  3797. }
  3798. if (npc_name2id(NPCname) != NULL) {
  3799. npc_enable(NPCname, 1);
  3800. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  3801. } else {
  3802. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3803. return -1;
  3804. }
  3805. return 0;
  3806. }
  3807. /*==========================================
  3808. *
  3809. *------------------------------------------*/
  3810. ACMD_FUNC(hidenpc)
  3811. {
  3812. char NPCname[NAME_LENGTH+1];
  3813. nullpo_retr(-1, sd);
  3814. memset(NPCname, '\0', sizeof(NPCname));
  3815. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3816. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  3817. return -1;
  3818. }
  3819. if (npc_name2id(NPCname) == NULL) {
  3820. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3821. return -1;
  3822. }
  3823. npc_enable(NPCname, 0);
  3824. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3825. return 0;
  3826. }
  3827. ACMD_FUNC(loadnpc)
  3828. {
  3829. FILE *fp;
  3830. if (!message || !*message) {
  3831. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  3832. return -1;
  3833. }
  3834. // check if script file exists
  3835. if ((fp = fopen(message, "r")) == NULL) {
  3836. clif_displaymessage(fd, msg_txt(261));
  3837. return -1;
  3838. }
  3839. fclose(fp);
  3840. // add to list of script sources and run it
  3841. npc_addsrcfile(message);
  3842. npc_parsesrcfile(message);
  3843. npc_read_event_script();
  3844. clif_displaymessage(fd, msg_txt(262));
  3845. return 0;
  3846. }
  3847. ACMD_FUNC(unloadnpc)
  3848. {
  3849. struct npc_data *nd;
  3850. char NPCname[NAME_LENGTH+1];
  3851. nullpo_retr(-1, sd);
  3852. memset(NPCname, '\0', sizeof(NPCname));
  3853. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3854. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  3855. return -1;
  3856. }
  3857. if ((nd = npc_name2id(NPCname)) == NULL) {
  3858. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3859. return -1;
  3860. }
  3861. npc_unload_duplicates(nd);
  3862. npc_unload(nd);
  3863. npc_read_event_script();
  3864. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3865. return 0;
  3866. }
  3867. /*==========================================
  3868. * time in txt for time command (by [Yor])
  3869. *------------------------------------------*/
  3870. char* txt_time(unsigned int duration)
  3871. {
  3872. int days, hours, minutes, seconds;
  3873. char temp[CHAT_SIZE_MAX];
  3874. static char temp1[CHAT_SIZE_MAX];
  3875. memset(temp, '\0', sizeof(temp));
  3876. memset(temp1, '\0', sizeof(temp1));
  3877. days = duration / (60 * 60 * 24);
  3878. duration = duration - (60 * 60 * 24 * days);
  3879. hours = duration / (60 * 60);
  3880. duration = duration - (60 * 60 * hours);
  3881. minutes = duration / 60;
  3882. seconds = duration - (60 * minutes);
  3883. if (days < 2)
  3884. sprintf(temp, msg_txt(219), days); // %d day
  3885. else
  3886. sprintf(temp, msg_txt(220), days); // %d days
  3887. if (hours < 2)
  3888. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  3889. else
  3890. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  3891. if (minutes < 2)
  3892. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  3893. else
  3894. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  3895. if (seconds < 2)
  3896. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  3897. else
  3898. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  3899. return temp1;
  3900. }
  3901. /*==========================================
  3902. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3903. * Calculation management of GM modification (@day/@night GM commands) is done
  3904. *------------------------------------------*/
  3905. ACMD_FUNC(servertime)
  3906. {
  3907. const struct TimerData * timer_data;
  3908. const struct TimerData * timer_data2;
  3909. time_t time_server; // variable for number of seconds (used with time() function)
  3910. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3911. char temp[CHAT_SIZE_MAX];
  3912. nullpo_retr(-1, sd);
  3913. memset(temp, '\0', sizeof(temp));
  3914. time(&time_server); // get time in seconds since 1/1/1970
  3915. datetime = localtime(&time_server); // convert seconds in structure
  3916. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3917. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3918. clif_displaymessage(fd, temp);
  3919. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3920. if (night_flag == 0)
  3921. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3922. else
  3923. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3924. } else if (battle_config.night_duration == 0)
  3925. if (night_flag == 1) { // we start with night
  3926. timer_data = get_timer(day_timer_tid);
  3927. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  3928. clif_displaymessage(fd, temp);
  3929. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  3930. } else
  3931. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3932. else if (battle_config.day_duration == 0)
  3933. if (night_flag == 0) { // we start with day
  3934. timer_data = get_timer(night_timer_tid);
  3935. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3936. clif_displaymessage(fd, temp);
  3937. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  3938. } else
  3939. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3940. else {
  3941. if (night_flag == 0) {
  3942. timer_data = get_timer(night_timer_tid);
  3943. timer_data2 = get_timer(day_timer_tid);
  3944. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3945. clif_displaymessage(fd, temp);
  3946. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3947. 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.
  3948. else
  3949. 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.
  3950. clif_displaymessage(fd, temp);
  3951. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3952. clif_displaymessage(fd, temp);
  3953. } else {
  3954. timer_data = get_timer(day_timer_tid);
  3955. timer_data2 = get_timer(night_timer_tid);
  3956. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  3957. clif_displaymessage(fd, temp);
  3958. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3959. 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.
  3960. else
  3961. 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.
  3962. clif_displaymessage(fd, temp);
  3963. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3964. clif_displaymessage(fd, temp);
  3965. }
  3966. }
  3967. return 0;
  3968. }
  3969. //Added by Coltaro
  3970. //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...).
  3971. //Well, using time_t could still work but for some reason that looks like more coding x_x
  3972. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  3973. {
  3974. const int factor_year = 518400; //12*30*24*60 = 518400
  3975. const int factor_month = 43200; //30*24*60 = 43200
  3976. const int factor_day = 1440; //24*60 = 1440
  3977. const int factor_hour = 60;
  3978. *year = jailtime/factor_year;
  3979. jailtime -= *year*factor_year;
  3980. *month = jailtime/factor_month;
  3981. jailtime -= *month*factor_month;
  3982. *day = jailtime/factor_day;
  3983. jailtime -= *day*factor_day;
  3984. *hour = jailtime/factor_hour;
  3985. jailtime -= *hour*factor_hour;
  3986. *minute = jailtime;
  3987. *year = *year > 0? *year : 0;
  3988. *month = *month > 0? *month : 0;
  3989. *day = *day > 0? *day : 0;
  3990. *hour = *hour > 0? *hour : 0;
  3991. *minute = *minute > 0? *minute : 0;
  3992. return;
  3993. }
  3994. /*==========================================
  3995. * @jail <char_name> by [Yor]
  3996. * Special warp! No check with nowarp and nowarpto flag
  3997. *------------------------------------------*/
  3998. ACMD_FUNC(jail)
  3999. {
  4000. struct map_session_data *pl_sd;
  4001. int x, y;
  4002. unsigned short m_index;
  4003. nullpo_retr(-1, sd);
  4004. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4005. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4006. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4007. return -1;
  4008. }
  4009. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4010. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4011. return -1;
  4012. }
  4013. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  4014. { // you can jail only lower or same GM
  4015. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4016. return -1;
  4017. }
  4018. if (pl_sd->sc.data[SC_JAILED])
  4019. {
  4020. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4021. return -1;
  4022. }
  4023. switch(rnd() % 2) { //Jail Locations
  4024. case 0:
  4025. m_index = mapindex_name2id(MAP_JAIL);
  4026. x = 24;
  4027. y = 75;
  4028. break;
  4029. default:
  4030. m_index = mapindex_name2id(MAP_JAIL);
  4031. x = 49;
  4032. y = 75;
  4033. break;
  4034. }
  4035. //Duration of INT_MAX to specify infinity.
  4036. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4037. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4038. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4039. return 0;
  4040. }
  4041. /*==========================================
  4042. * @unjail/@discharge <char_name> by [Yor]
  4043. * Special warp! No check with nowarp and nowarpto flag
  4044. *------------------------------------------*/
  4045. ACMD_FUNC(unjail)
  4046. {
  4047. struct map_session_data *pl_sd;
  4048. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4049. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4050. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4051. return -1;
  4052. }
  4053. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4054. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4055. return -1;
  4056. }
  4057. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4058. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4059. return -1;
  4060. }
  4061. if (!pl_sd->sc.data[SC_JAILED])
  4062. {
  4063. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4064. return -1;
  4065. }
  4066. //Reset jail time to 1 sec.
  4067. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4068. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4069. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4070. return 0;
  4071. }
  4072. ACMD_FUNC(jailfor)
  4073. {
  4074. struct map_session_data *pl_sd = NULL;
  4075. int year, month, day, hour, minute, value;
  4076. char * modif_p;
  4077. int jailtime = 0,x,y;
  4078. short m_index = 0;
  4079. nullpo_retr(-1, sd);
  4080. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4081. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4082. return -1;
  4083. }
  4084. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4085. modif_p = atcmd_output;
  4086. year = month = day = hour = minute = 0;
  4087. while (modif_p[0] != '\0') {
  4088. value = atoi(modif_p);
  4089. if (value == 0)
  4090. modif_p++;
  4091. else {
  4092. if (modif_p[0] == '-' || modif_p[0] == '+')
  4093. modif_p++;
  4094. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4095. modif_p++;
  4096. if (modif_p[0] == 'n') {
  4097. minute = value;
  4098. modif_p++;
  4099. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4100. minute = value;
  4101. modif_p = modif_p + 2;
  4102. } else if (modif_p[0] == 'h') {
  4103. hour = value;
  4104. modif_p++;
  4105. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4106. day = value;
  4107. modif_p++;
  4108. } else if (modif_p[0] == 'm') {
  4109. month = value;
  4110. modif_p++;
  4111. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4112. year = value;
  4113. modif_p++;
  4114. } else if (modif_p[0] != '\0') {
  4115. modif_p++;
  4116. }
  4117. }
  4118. }
  4119. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4120. clif_displaymessage(fd, "Invalid time for jail command.");
  4121. return -1;
  4122. }
  4123. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4124. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4125. return -1;
  4126. }
  4127. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4128. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4129. return -1;
  4130. }
  4131. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4132. if(jailtime==0) {
  4133. clif_displaymessage(fd, "Invalid time for jail command.");
  4134. return -1;
  4135. }
  4136. //Added by Coltaro
  4137. if(pl_sd->sc.data[SC_JAILED] &&
  4138. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4139. { //Update the player's jail time
  4140. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4141. if (jailtime <= 0) {
  4142. jailtime = 0;
  4143. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4144. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4145. } else {
  4146. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4147. 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
  4148. clif_displaymessage(pl_sd->fd, atcmd_output);
  4149. 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
  4150. clif_displaymessage(fd, atcmd_output);
  4151. }
  4152. } else if (jailtime < 0) {
  4153. clif_displaymessage(fd, "Invalid time for jail command.");
  4154. return -1;
  4155. }
  4156. //Jail locations, add more as you wish.
  4157. switch(rnd()%2)
  4158. {
  4159. case 1: //Jail #1
  4160. m_index = mapindex_name2id(MAP_JAIL);
  4161. x = 49; y = 75;
  4162. break;
  4163. default: //Default Jail
  4164. m_index = mapindex_name2id(MAP_JAIL);
  4165. x = 24; y = 75;
  4166. break;
  4167. }
  4168. 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).
  4169. return 0;
  4170. }
  4171. //By Coltaro
  4172. ACMD_FUNC(jailtime)
  4173. {
  4174. int year, month, day, hour, minute;
  4175. nullpo_retr(-1, sd);
  4176. if (!sd->sc.data[SC_JAILED]) {
  4177. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4178. return -1;
  4179. }
  4180. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4181. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4182. return 0;
  4183. }
  4184. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4185. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4186. return -1;
  4187. }
  4188. //Get remaining jail time
  4189. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4190. 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
  4191. clif_displaymessage(fd, atcmd_output);
  4192. return 0;
  4193. }
  4194. /*==========================================
  4195. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4196. *------------------------------------------*/
  4197. ACMD_FUNC(disguise)
  4198. {
  4199. int id = 0;
  4200. nullpo_retr(-1, sd);
  4201. if (!message || !*message) {
  4202. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4203. return -1;
  4204. }
  4205. if ((id = atoi(message)) > 0)
  4206. { //Acquired an ID
  4207. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4208. id = 0; //Invalid id for either mobs or npcs.
  4209. } else { //Acquired a Name
  4210. if ((id = mobdb_searchname(message)) == 0)
  4211. {
  4212. struct npc_data* nd = npc_name2id(message);
  4213. if (nd != NULL)
  4214. id = nd->class_;
  4215. }
  4216. }
  4217. if (id == 0)
  4218. {
  4219. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4220. return -1;
  4221. }
  4222. if(pc_isriding(sd))
  4223. {
  4224. //FIXME: wrong message [ultramage]
  4225. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4226. return -1;
  4227. }
  4228. pc_disguise(sd, id);
  4229. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4230. return 0;
  4231. }
  4232. /*==========================================
  4233. * DisguiseAll
  4234. *------------------------------------------*/
  4235. ACMD_FUNC(disguiseall)
  4236. {
  4237. int mob_id=0;
  4238. struct map_session_data *pl_sd;
  4239. struct s_mapiterator* iter;
  4240. nullpo_retr(-1, sd);
  4241. if (!message || !*message) {
  4242. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4243. return -1;
  4244. }
  4245. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4246. mob_id = atoi(message);
  4247. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4248. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4249. return -1;
  4250. }
  4251. iter = mapit_getallusers();
  4252. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4253. pc_disguise(pl_sd, mob_id);
  4254. mapit_free(iter);
  4255. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4256. return 0;
  4257. }
  4258. /*==========================================
  4259. * @undisguise by [Yor]
  4260. *------------------------------------------*/
  4261. ACMD_FUNC(undisguise)
  4262. {
  4263. nullpo_retr(-1, sd);
  4264. if (sd->disguise) {
  4265. pc_disguise(sd, 0);
  4266. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4267. } else {
  4268. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4269. return -1;
  4270. }
  4271. return 0;
  4272. }
  4273. /*==========================================
  4274. * UndisguiseAll
  4275. *------------------------------------------*/
  4276. ACMD_FUNC(undisguiseall)
  4277. {
  4278. struct map_session_data *pl_sd;
  4279. struct s_mapiterator* iter;
  4280. nullpo_retr(-1, sd);
  4281. iter = mapit_getallusers();
  4282. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4283. if( pl_sd->disguise )
  4284. pc_disguise(pl_sd, 0);
  4285. mapit_free(iter);
  4286. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4287. return 0;
  4288. }
  4289. /*==========================================
  4290. * @exp by [Skotlex]
  4291. *------------------------------------------*/
  4292. ACMD_FUNC(exp)
  4293. {
  4294. char output[CHAT_SIZE_MAX];
  4295. double nextb, nextj;
  4296. nullpo_retr(-1, sd);
  4297. memset(output, '\0', sizeof(output));
  4298. nextb = pc_nextbaseexp(sd);
  4299. if (nextb)
  4300. nextb = sd->status.base_exp*100.0/nextb;
  4301. nextj = pc_nextjobexp(sd);
  4302. if (nextj)
  4303. nextj = sd->status.job_exp*100.0/nextj;
  4304. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4305. clif_displaymessage(fd, output);
  4306. return 0;
  4307. }
  4308. /*==========================================
  4309. * @broadcast by [Valaris]
  4310. *------------------------------------------*/
  4311. ACMD_FUNC(broadcast)
  4312. {
  4313. nullpo_retr(-1, sd);
  4314. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4315. if (!message || !*message) {
  4316. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4317. return -1;
  4318. }
  4319. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4320. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4321. return 0;
  4322. }
  4323. /*==========================================
  4324. * @localbroadcast by [Valaris]
  4325. *------------------------------------------*/
  4326. ACMD_FUNC(localbroadcast)
  4327. {
  4328. nullpo_retr(-1, sd);
  4329. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4330. if (!message || !*message) {
  4331. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4332. return -1;
  4333. }
  4334. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4335. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4336. return 0;
  4337. }
  4338. /*==========================================
  4339. * @email <actual@email> <new@email> by [Yor]
  4340. *------------------------------------------*/
  4341. ACMD_FUNC(email)
  4342. {
  4343. char actual_email[100];
  4344. char new_email[100];
  4345. nullpo_retr(-1, sd);
  4346. memset(actual_email, '\0', sizeof(actual_email));
  4347. memset(new_email, '\0', sizeof(new_email));
  4348. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4349. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4350. return -1;
  4351. }
  4352. if (e_mail_check(actual_email) == 0) {
  4353. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4354. return -1;
  4355. } else if (e_mail_check(new_email) == 0) {
  4356. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4357. return -1;
  4358. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4359. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4360. return -1;
  4361. } else if (strcmpi(actual_email, new_email) == 0) {
  4362. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4363. return -1;
  4364. }
  4365. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4366. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4367. return 0;
  4368. }
  4369. /*==========================================
  4370. *@effect
  4371. *------------------------------------------*/
  4372. ACMD_FUNC(effect)
  4373. {
  4374. int type = 0, flag = 0;
  4375. nullpo_retr(-1, sd);
  4376. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4377. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4378. return -1;
  4379. }
  4380. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4381. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4382. return 0;
  4383. }
  4384. /*==========================================
  4385. * @killer by MouseJstr
  4386. * enable killing players even when not in pvp
  4387. *------------------------------------------*/
  4388. ACMD_FUNC(killer)
  4389. {
  4390. nullpo_retr(-1, sd);
  4391. sd->state.killer = !sd->state.killer;
  4392. if(sd->state.killer)
  4393. clif_displaymessage(fd, msg_txt(241));
  4394. else {
  4395. clif_displaymessage(fd, msg_txt(287));
  4396. pc_stop_attack(sd);
  4397. }
  4398. return 0;
  4399. }
  4400. /*==========================================
  4401. * @killable by MouseJstr
  4402. * enable other people killing you
  4403. *------------------------------------------*/
  4404. ACMD_FUNC(killable)
  4405. {
  4406. nullpo_retr(-1, sd);
  4407. sd->state.killable = !sd->state.killable;
  4408. if(sd->state.killable)
  4409. clif_displaymessage(fd, msg_txt(242));
  4410. else {
  4411. clif_displaymessage(fd, msg_txt(288));
  4412. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4413. }
  4414. return 0;
  4415. }
  4416. /*==========================================
  4417. * @skillon by MouseJstr
  4418. * turn skills on for the map
  4419. *------------------------------------------*/
  4420. ACMD_FUNC(skillon)
  4421. {
  4422. nullpo_retr(-1, sd);
  4423. map[sd->bl.m].flag.noskill = 0;
  4424. clif_displaymessage(fd, msg_txt(244));
  4425. return 0;
  4426. }
  4427. /*==========================================
  4428. * @skilloff by MouseJstr
  4429. * Turn skills off on the map
  4430. *------------------------------------------*/
  4431. ACMD_FUNC(skilloff)
  4432. {
  4433. nullpo_retr(-1, sd);
  4434. map[sd->bl.m].flag.noskill = 1;
  4435. clif_displaymessage(fd, msg_txt(243));
  4436. return 0;
  4437. }
  4438. /*==========================================
  4439. * @npcmove by MouseJstr
  4440. * move a npc
  4441. *------------------------------------------*/
  4442. ACMD_FUNC(npcmove)
  4443. {
  4444. int x = 0, y = 0, m;
  4445. struct npc_data *nd = 0;
  4446. nullpo_retr(-1, sd);
  4447. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4448. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4449. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4450. return -1;
  4451. }
  4452. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4453. {
  4454. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4455. return -1;
  4456. }
  4457. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4458. {
  4459. clif_displaymessage(fd, "NPC is not on this map.");
  4460. return -1; //Not on a map.
  4461. }
  4462. x = cap_value(x, 0, map[m].xs-1);
  4463. y = cap_value(y, 0, map[m].ys-1);
  4464. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4465. map_moveblock(&nd->bl, x, y, gettick());
  4466. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4467. clif_displaymessage(fd, "NPC moved.");
  4468. return 0;
  4469. }
  4470. /*==========================================
  4471. * @addwarp by MouseJstr
  4472. * Create a new static warp point.
  4473. *------------------------------------------*/
  4474. ACMD_FUNC(addwarp)
  4475. {
  4476. char mapname[32];
  4477. int x,y;
  4478. unsigned short m;
  4479. struct npc_data* nd;
  4480. nullpo_retr(-1, sd);
  4481. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4482. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4483. return -1;
  4484. }
  4485. m = mapindex_name2id(mapname);
  4486. if( m == 0 )
  4487. {
  4488. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4489. clif_displaymessage(fd, atcmd_output);
  4490. return -1;
  4491. }
  4492. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4493. if( nd == NULL )
  4494. return -1;
  4495. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4496. clif_displaymessage(fd, atcmd_output);
  4497. return 0;
  4498. }
  4499. /*==========================================
  4500. * @follow by [MouseJstr]
  4501. * Follow a player .. staying no more then 5 spaces away
  4502. *------------------------------------------*/
  4503. ACMD_FUNC(follow)
  4504. {
  4505. struct map_session_data *pl_sd = NULL;
  4506. nullpo_retr(-1, sd);
  4507. if (!message || !*message) {
  4508. if (sd->followtarget == -1)
  4509. return -1;
  4510. pc_stop_following (sd);
  4511. clif_displaymessage(fd, "Follow mode OFF.");
  4512. return 0;
  4513. }
  4514. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4515. {
  4516. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4517. return -1;
  4518. }
  4519. if (sd->followtarget == pl_sd->bl.id) {
  4520. pc_stop_following (sd);
  4521. clif_displaymessage(fd, "Follow mode OFF.");
  4522. } else {
  4523. pc_follow(sd, pl_sd->bl.id);
  4524. clif_displaymessage(fd, "Follow mode ON.");
  4525. }
  4526. return 0;
  4527. }
  4528. /*==========================================
  4529. * @dropall by [MouseJstr]
  4530. * Drop all your possession on the ground
  4531. *------------------------------------------*/
  4532. ACMD_FUNC(dropall)
  4533. {
  4534. int i;
  4535. nullpo_retr(-1, sd);
  4536. for (i = 0; i < MAX_INVENTORY; i++) {
  4537. if (sd->status.inventory[i].amount) {
  4538. if(sd->status.inventory[i].equip != 0)
  4539. pc_unequipitem(sd, i, 3);
  4540. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4541. }
  4542. }
  4543. return 0;
  4544. }
  4545. /*==========================================
  4546. * @storeall by [MouseJstr]
  4547. * Put everything into storage
  4548. *------------------------------------------*/
  4549. ACMD_FUNC(storeall)
  4550. {
  4551. int i;
  4552. nullpo_retr(-1, sd);
  4553. if (sd->state.storage_flag != 1)
  4554. { //Open storage.
  4555. if( storage_storageopen(sd) == 1 ) {
  4556. clif_displaymessage(fd, "You can't open the storage currently.");
  4557. return -1;
  4558. }
  4559. }
  4560. for (i = 0; i < MAX_INVENTORY; i++) {
  4561. if (sd->status.inventory[i].amount) {
  4562. if(sd->status.inventory[i].equip != 0)
  4563. pc_unequipitem(sd, i, 3);
  4564. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4565. }
  4566. }
  4567. storage_storageclose(sd);
  4568. clif_displaymessage(fd, "It is done");
  4569. return 0;
  4570. }
  4571. /*==========================================
  4572. * @skillid by [MouseJstr]
  4573. * lookup a skill by name
  4574. *------------------------------------------*/
  4575. ACMD_FUNC(skillid)
  4576. {
  4577. int skillen, idx;
  4578. nullpo_retr(-1, sd);
  4579. if (!message || !*message)
  4580. {
  4581. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4582. return -1;
  4583. }
  4584. skillen = strlen(message);
  4585. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4586. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4587. {
  4588. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4589. clif_displaymessage(fd, atcmd_output);
  4590. }
  4591. }
  4592. return 0;
  4593. }
  4594. /*==========================================
  4595. * @useskill by [MouseJstr]
  4596. * A way of using skills without having to find them in the skills menu
  4597. *------------------------------------------*/
  4598. ACMD_FUNC(useskill)
  4599. {
  4600. struct map_session_data *pl_sd = NULL;
  4601. struct block_list *bl;
  4602. int skillnum;
  4603. int skilllv;
  4604. char target[100];
  4605. nullpo_retr(-1, sd);
  4606. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4607. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4608. return -1;
  4609. }
  4610. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4611. {
  4612. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4613. return -1;
  4614. }
  4615. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4616. {
  4617. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4618. return -1;
  4619. }
  4620. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4621. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4622. bl = &sd->hd->bl;
  4623. else
  4624. bl = &sd->bl;
  4625. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4626. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4627. else
  4628. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4629. return 0;
  4630. }
  4631. /*==========================================
  4632. * @displayskill by [Skotlex]
  4633. * Debug command to locate new skill IDs. It sends the
  4634. * three possible skill-effect packets to the area.
  4635. *------------------------------------------*/
  4636. ACMD_FUNC(displayskill)
  4637. {
  4638. struct status_data * status;
  4639. unsigned int tick;
  4640. int skillnum;
  4641. int skilllv = 1;
  4642. nullpo_retr(-1, sd);
  4643. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4644. {
  4645. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4646. return -1;
  4647. }
  4648. status = status_get_status_data(&sd->bl);
  4649. tick = gettick();
  4650. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4651. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4652. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4653. return 0;
  4654. }
  4655. /*==========================================
  4656. * @skilltree by [MouseJstr]
  4657. * prints the skill tree for a player required to get to a skill
  4658. *------------------------------------------*/
  4659. ACMD_FUNC(skilltree)
  4660. {
  4661. struct map_session_data *pl_sd = NULL;
  4662. int skillnum;
  4663. int meets, j, c=0;
  4664. char target[NAME_LENGTH];
  4665. struct skill_tree_entry *ent;
  4666. nullpo_retr(-1, sd);
  4667. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4668. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4669. return -1;
  4670. }
  4671. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4672. {
  4673. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4674. return -1;
  4675. }
  4676. c = pc_calc_skilltree_normalize_job(pl_sd);
  4677. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4678. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, 1));
  4679. clif_displaymessage(fd, atcmd_output);
  4680. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  4681. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4682. {
  4683. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4684. clif_displaymessage(fd, atcmd_output);
  4685. return 0;
  4686. }
  4687. ent = &skill_tree[c][j];
  4688. meets = 1;
  4689. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4690. {
  4691. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4692. {
  4693. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  4694. clif_displaymessage(fd, atcmd_output);
  4695. meets = 0;
  4696. }
  4697. }
  4698. if (meets == 1) {
  4699. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4700. clif_displaymessage(fd, atcmd_output);
  4701. }
  4702. return 0;
  4703. }
  4704. // Hand a ring with partners name on it to this char
  4705. void getring (struct map_session_data* sd)
  4706. {
  4707. int flag, item_id;
  4708. struct item item_tmp;
  4709. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4710. memset(&item_tmp, 0, sizeof(item_tmp));
  4711. item_tmp.nameid = item_id;
  4712. item_tmp.identify = 1;
  4713. item_tmp.card[0] = 255;
  4714. item_tmp.card[2] = sd->status.partner_id;
  4715. item_tmp.card[3] = sd->status.partner_id >> 16;
  4716. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4717. clif_additem(sd,0,0,flag);
  4718. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4719. }
  4720. }
  4721. /*==========================================
  4722. * @marry by [MouseJstr], fixed by Lupus
  4723. * Marry two players
  4724. *------------------------------------------*/
  4725. ACMD_FUNC(marry)
  4726. {
  4727. struct map_session_data *pl_sd = NULL;
  4728. char player_name[NAME_LENGTH] = "";
  4729. nullpo_retr(-1, sd);
  4730. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4731. clif_displaymessage(fd, "Usage: @marry <player name>");
  4732. return -1;
  4733. }
  4734. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4735. clif_displaymessage(fd, msg_txt(3));
  4736. return -1;
  4737. }
  4738. if (pc_marriage(sd, pl_sd) == 0) {
  4739. clif_displaymessage(fd, "They are married.. wish them well.");
  4740. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4741. getring(sd); // Auto-give named rings (Aru)
  4742. getring(pl_sd);
  4743. return 0;
  4744. }
  4745. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  4746. return -1;
  4747. }
  4748. /*==========================================
  4749. * @divorce by [MouseJstr], fixed by [Lupus]
  4750. * divorce two players
  4751. *------------------------------------------*/
  4752. ACMD_FUNC(divorce)
  4753. {
  4754. nullpo_retr(-1, sd);
  4755. if (pc_divorce(sd) != 0) {
  4756. sprintf(atcmd_output, "'%s' is not married.", sd->status.name);
  4757. clif_displaymessage(fd, atcmd_output);
  4758. return -1;
  4759. }
  4760. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", sd->status.name);
  4761. clif_displaymessage(fd, atcmd_output);
  4762. return 0;
  4763. }
  4764. /*==========================================
  4765. * @changelook by [Celest]
  4766. *------------------------------------------*/
  4767. ACMD_FUNC(changelook)
  4768. {
  4769. int i, j = 0, k = 0;
  4770. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  4771. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4772. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  4773. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  4774. return -1;
  4775. } else if (i == 2) {
  4776. if (j < 1) j = 1;
  4777. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  4778. j = pos[j - 1];
  4779. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  4780. k = j; // swap
  4781. j = LOOK_HEAD_TOP;
  4782. }
  4783. clif_changelook(&sd->bl,j,k);
  4784. return 0;
  4785. }
  4786. /*==========================================
  4787. * @autotrade by durf [Lupus] [Paradox924X]
  4788. * Turns on/off Autotrade for a specific player
  4789. *------------------------------------------*/
  4790. ACMD_FUNC(autotrade)
  4791. {
  4792. nullpo_retr(-1, sd);
  4793. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4794. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  4795. return -1;
  4796. }
  4797. if( pc_isdead(sd) ) {
  4798. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  4799. return -1;
  4800. }
  4801. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4802. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  4803. return -1;
  4804. }
  4805. sd->state.autotrade = 1;
  4806. if( battle_config.at_timeout )
  4807. {
  4808. int timeout = atoi(message);
  4809. 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);
  4810. }
  4811. clif_authfail_fd(fd, 15);
  4812. return 0;
  4813. }
  4814. /*==========================================
  4815. * @changegm by durf (changed by Lupus)
  4816. * Changes Master of your Guild to a specified guild member
  4817. *------------------------------------------*/
  4818. ACMD_FUNC(changegm)
  4819. {
  4820. struct guild *g;
  4821. struct map_session_data *pl_sd;
  4822. nullpo_retr(-1, sd);
  4823. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  4824. {
  4825. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  4826. return -1;
  4827. }
  4828. if( map[sd->bl.m].flag.guildlock )
  4829. {
  4830. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  4831. return -1;
  4832. }
  4833. if( !message[0] )
  4834. {
  4835. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  4836. return -1;
  4837. }
  4838. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4839. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  4840. return -1;
  4841. }
  4842. guild_gm_change(sd->status.guild_id, pl_sd);
  4843. return 0;
  4844. }
  4845. /*==========================================
  4846. * @changeleader by Skotlex
  4847. * Changes the leader of a party.
  4848. *------------------------------------------*/
  4849. ACMD_FUNC(changeleader)
  4850. {
  4851. nullpo_retr(-1, sd);
  4852. if( !message[0] )
  4853. {
  4854. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  4855. return -1;
  4856. }
  4857. if (party_changeleader(sd, map_nick2sd((char *) message)))
  4858. return 0;
  4859. return -1;
  4860. }
  4861. /*==========================================
  4862. * @partyoption by Skotlex
  4863. * Used to change the item share setting of a party.
  4864. *------------------------------------------*/
  4865. ACMD_FUNC(partyoption)
  4866. {
  4867. struct party_data *p;
  4868. int mi, option;
  4869. char w1[16], w2[16];
  4870. nullpo_retr(-1, sd);
  4871. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4872. {
  4873. clif_displaymessage(fd, msg_txt(282));
  4874. return -1;
  4875. }
  4876. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4877. if (mi == MAX_PARTY)
  4878. return -1; //Shouldn't happen
  4879. if (!p->party.member[mi].leader)
  4880. {
  4881. clif_displaymessage(fd, msg_txt(282));
  4882. return -1;
  4883. }
  4884. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4885. {
  4886. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  4887. return -1;
  4888. }
  4889. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4890. //Change item share type.
  4891. if (option != p->party.item)
  4892. party_changeoption(sd, p->party.exp, option);
  4893. else
  4894. clif_displaymessage(fd, msg_txt(286));
  4895. return 0;
  4896. }
  4897. /*==========================================
  4898. * @autoloot by Upa-Kun
  4899. * Turns on/off AutoLoot for a specific player
  4900. *------------------------------------------*/
  4901. ACMD_FUNC(autoloot)
  4902. {
  4903. int rate;
  4904. double drate;
  4905. nullpo_retr(-1, sd);
  4906. // autoloot command without value
  4907. if(!message || !*message)
  4908. {
  4909. if (sd->state.autoloot)
  4910. rate = 0;
  4911. else
  4912. rate = 10000;
  4913. } else {
  4914. drate = atof(message);
  4915. rate = (int)(drate*100);
  4916. }
  4917. if (rate < 0) rate = 0;
  4918. if (rate > 10000) rate = 10000;
  4919. sd->state.autoloot = rate;
  4920. if (sd->state.autoloot) {
  4921. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  4922. clif_displaymessage(fd, atcmd_output);
  4923. }else
  4924. clif_displaymessage(fd, "Autoloot is now off.");
  4925. return 0;
  4926. }
  4927. /*==========================================
  4928. * @alootid
  4929. *------------------------------------------*/
  4930. ACMD_FUNC(autolootitem)
  4931. {
  4932. struct item_data *item_data = NULL;
  4933. int i;
  4934. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4935. if (message && *message) {
  4936. if (message[0] == '+') {
  4937. message++;
  4938. action = 1;
  4939. }
  4940. else if (message[0] == '-') {
  4941. message++;
  4942. action = 2;
  4943. }
  4944. else if (!strcmp(message,"reset"))
  4945. action = 4;
  4946. }
  4947. if (action < 3) // add or remove
  4948. {
  4949. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  4950. item_data = itemdb_searchname(message);
  4951. if (!item_data) {
  4952. // No items founds in the DB with Id or Name
  4953. clif_displaymessage(fd, "Item not found.");
  4954. return -1;
  4955. }
  4956. }
  4957. switch(action) {
  4958. case 1:
  4959. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4960. if (i != AUTOLOOTITEM_SIZE) {
  4961. clif_displaymessage(fd, "You're already autolooting this item.");
  4962. return -1;
  4963. }
  4964. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  4965. if (i == AUTOLOOTITEM_SIZE) {
  4966. clif_displaymessage(fd, "Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.");
  4967. return -1;
  4968. }
  4969. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  4970. sprintf(atcmd_output, "Autolooting item: '%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  4971. clif_displaymessage(fd, atcmd_output);
  4972. sd->state.autolooting = 1;
  4973. break;
  4974. case 2:
  4975. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4976. if (i == AUTOLOOTITEM_SIZE) {
  4977. clif_displaymessage(fd, "You're currently not autolooting this item.");
  4978. return -1;
  4979. }
  4980. sd->state.autolootid[i] = 0;
  4981. sprintf(atcmd_output, "Removed item: '%s'/'%s' {%d} from your autolootitem list.", item_data->name, item_data->jname, item_data->nameid);
  4982. clif_displaymessage(fd, atcmd_output);
  4983. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4984. if (i == AUTOLOOTITEM_SIZE) {
  4985. sd->state.autolooting = 0;
  4986. }
  4987. break;
  4988. case 3:
  4989. sprintf(atcmd_output, "You can have %d items on your autolootitem list.", AUTOLOOTITEM_SIZE);
  4990. clif_displaymessage(fd, atcmd_output);
  4991. clif_displaymessage(fd, "To add item to the list, use \"@alootid +<item name or ID>\". To remove item use \"@alootid -<item name or ID>\".");
  4992. clif_displaymessage(fd, "\"@alootid reset\" will clear your autolootitem list.");
  4993. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4994. if (i == AUTOLOOTITEM_SIZE) {
  4995. clif_displaymessage(fd, "Your autolootitem list is empty.");
  4996. } else {
  4997. clif_displaymessage(fd, "Items on your autolootitem list:");
  4998. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  4999. {
  5000. if (sd->state.autolootid[i] == 0)
  5001. continue;
  5002. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5003. ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
  5004. continue;
  5005. }
  5006. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5007. clif_displaymessage(fd, atcmd_output);
  5008. }
  5009. }
  5010. break;
  5011. case 4:
  5012. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5013. clif_displaymessage(fd, "Your autolootitem list has been reset.");
  5014. sd->state.autolooting = 0;
  5015. break;
  5016. }
  5017. return 0;
  5018. }
  5019. /**
  5020. * No longer available, keeping here just in case it's back someday. [Ind]
  5021. **/
  5022. /*==========================================
  5023. * It is made to rain.
  5024. *------------------------------------------*/
  5025. //ACMD_FUNC(rain)
  5026. //{
  5027. // nullpo_retr(-1, sd);
  5028. // if (map[sd->bl.m].flag.rain) {
  5029. // map[sd->bl.m].flag.rain=0;
  5030. // clif_weather(sd->bl.m);
  5031. // clif_displaymessage(fd, "The rain has stopped.");
  5032. // } else {
  5033. // map[sd->bl.m].flag.rain=1;
  5034. // clif_weather(sd->bl.m);
  5035. // clif_displaymessage(fd, "It is made to rain.");
  5036. // }
  5037. // return 0;
  5038. //}
  5039. /*==========================================
  5040. * It is made to snow.
  5041. *------------------------------------------*/
  5042. ACMD_FUNC(snow)
  5043. {
  5044. nullpo_retr(-1, sd);
  5045. if (map[sd->bl.m].flag.snow) {
  5046. map[sd->bl.m].flag.snow=0;
  5047. clif_weather(sd->bl.m);
  5048. clif_displaymessage(fd, "Snow has stopped falling.");
  5049. } else {
  5050. map[sd->bl.m].flag.snow=1;
  5051. clif_weather(sd->bl.m);
  5052. clif_displaymessage(fd, "It is made to snow.");
  5053. }
  5054. return 0;
  5055. }
  5056. /*==========================================
  5057. * Cherry tree snowstorm is made to fall. (Sakura)
  5058. *------------------------------------------*/
  5059. ACMD_FUNC(sakura)
  5060. {
  5061. nullpo_retr(-1, sd);
  5062. if (map[sd->bl.m].flag.sakura) {
  5063. map[sd->bl.m].flag.sakura=0;
  5064. clif_weather(sd->bl.m);
  5065. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5066. } else {
  5067. map[sd->bl.m].flag.sakura=1;
  5068. clif_weather(sd->bl.m);
  5069. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5070. }
  5071. return 0;
  5072. }
  5073. /*==========================================
  5074. * Clouds appear.
  5075. *------------------------------------------*/
  5076. ACMD_FUNC(clouds)
  5077. {
  5078. nullpo_retr(-1, sd);
  5079. if (map[sd->bl.m].flag.clouds) {
  5080. map[sd->bl.m].flag.clouds=0;
  5081. clif_weather(sd->bl.m);
  5082. clif_displaymessage(fd, "The clouds has disappear.");
  5083. } else {
  5084. map[sd->bl.m].flag.clouds=1;
  5085. clif_weather(sd->bl.m);
  5086. clif_displaymessage(fd, "Clouds appear.");
  5087. }
  5088. return 0;
  5089. }
  5090. /*==========================================
  5091. * Different type of clouds using effect 516
  5092. *------------------------------------------*/
  5093. ACMD_FUNC(clouds2)
  5094. {
  5095. nullpo_retr(-1, sd);
  5096. if (map[sd->bl.m].flag.clouds2) {
  5097. map[sd->bl.m].flag.clouds2=0;
  5098. clif_weather(sd->bl.m);
  5099. clif_displaymessage(fd, "The alternative clouds disappear.");
  5100. } else {
  5101. map[sd->bl.m].flag.clouds2=1;
  5102. clif_weather(sd->bl.m);
  5103. clif_displaymessage(fd, "Alternative clouds appear.");
  5104. }
  5105. return 0;
  5106. }
  5107. /*==========================================
  5108. * Fog hangs over.
  5109. *------------------------------------------*/
  5110. ACMD_FUNC(fog)
  5111. {
  5112. nullpo_retr(-1, sd);
  5113. if (map[sd->bl.m].flag.fog) {
  5114. map[sd->bl.m].flag.fog=0;
  5115. clif_weather(sd->bl.m);
  5116. clif_displaymessage(fd, "The fog has gone.");
  5117. } else {
  5118. map[sd->bl.m].flag.fog=1;
  5119. clif_weather(sd->bl.m);
  5120. clif_displaymessage(fd, "Fog hangs over.");
  5121. }
  5122. return 0;
  5123. }
  5124. /*==========================================
  5125. * Fallen leaves fall.
  5126. *------------------------------------------*/
  5127. ACMD_FUNC(leaves)
  5128. {
  5129. nullpo_retr(-1, sd);
  5130. if (map[sd->bl.m].flag.leaves) {
  5131. map[sd->bl.m].flag.leaves=0;
  5132. clif_weather(sd->bl.m);
  5133. clif_displaymessage(fd, "Leaves no longer fall.");
  5134. } else {
  5135. map[sd->bl.m].flag.leaves=1;
  5136. clif_weather(sd->bl.m);
  5137. clif_displaymessage(fd, "Fallen leaves fall.");
  5138. }
  5139. return 0;
  5140. }
  5141. /*==========================================
  5142. * Fireworks appear.
  5143. *------------------------------------------*/
  5144. ACMD_FUNC(fireworks)
  5145. {
  5146. nullpo_retr(-1, sd);
  5147. if (map[sd->bl.m].flag.fireworks) {
  5148. map[sd->bl.m].flag.fireworks=0;
  5149. clif_weather(sd->bl.m);
  5150. clif_displaymessage(fd, "Fireworks are ended.");
  5151. } else {
  5152. map[sd->bl.m].flag.fireworks=1;
  5153. clif_weather(sd->bl.m);
  5154. clif_displaymessage(fd, "Fireworks are launched.");
  5155. }
  5156. return 0;
  5157. }
  5158. /*==========================================
  5159. * Clearing Weather Effects by Dexity
  5160. *------------------------------------------*/
  5161. ACMD_FUNC(clearweather)
  5162. {
  5163. nullpo_retr(-1, sd);
  5164. /**
  5165. * No longer available, keeping here just in case it's back someday. [Ind]
  5166. **/
  5167. //map[sd->bl.m].flag.rain=0;
  5168. map[sd->bl.m].flag.snow=0;
  5169. map[sd->bl.m].flag.sakura=0;
  5170. map[sd->bl.m].flag.clouds=0;
  5171. map[sd->bl.m].flag.clouds2=0;
  5172. map[sd->bl.m].flag.fog=0;
  5173. map[sd->bl.m].flag.fireworks=0;
  5174. map[sd->bl.m].flag.leaves=0;
  5175. clif_weather(sd->bl.m);
  5176. clif_displaymessage(fd, msg_txt(291));
  5177. return 0;
  5178. }
  5179. /*===============================================================
  5180. * Sound Command - plays a sound for everyone around! [Codemaster]
  5181. *---------------------------------------------------------------*/
  5182. ACMD_FUNC(sound)
  5183. {
  5184. char sound_file[100];
  5185. memset(sound_file, '\0', sizeof(sound_file));
  5186. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5187. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5188. return -1;
  5189. }
  5190. if(strstr(sound_file, ".wav") == NULL)
  5191. strcat(sound_file, ".wav");
  5192. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5193. return 0;
  5194. }
  5195. /*==========================================
  5196. * MOB Search
  5197. *------------------------------------------*/
  5198. ACMD_FUNC(mobsearch)
  5199. {
  5200. char mob_name[100];
  5201. int mob_id;
  5202. int number = 0;
  5203. struct s_mapiterator* it;
  5204. nullpo_retr(-1, sd);
  5205. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5206. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5207. return -1;
  5208. }
  5209. if ((mob_id = atoi(mob_name)) == 0)
  5210. mob_id = mobdb_searchname(mob_name);
  5211. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5212. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5213. clif_displaymessage(fd, atcmd_output);
  5214. return -1;
  5215. }
  5216. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5217. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5218. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5219. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5220. clif_displaymessage(fd, atcmd_output);
  5221. it = mapit_geteachmob();
  5222. for(;;)
  5223. {
  5224. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5225. if( md == NULL )
  5226. break;// no more mobs
  5227. if( md->bl.m != sd->bl.m )
  5228. continue;
  5229. if( mob_id != -1 && md->class_ != mob_id )
  5230. continue;
  5231. ++number;
  5232. if( md->spawn_timer == INVALID_TIMER )
  5233. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5234. else
  5235. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5236. clif_displaymessage(fd, atcmd_output);
  5237. }
  5238. mapit_free(it);
  5239. return 0;
  5240. }
  5241. /*==========================================
  5242. * @cleanmap - cleans items on the ground
  5243. *------------------------------------------*/
  5244. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5245. {
  5246. nullpo_ret(bl);
  5247. map_clearflooritem(bl->id);
  5248. return 0;
  5249. }
  5250. ACMD_FUNC(cleanmap)
  5251. {
  5252. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5253. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5254. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5255. BL_ITEM);
  5256. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5257. return 0;
  5258. }
  5259. /*==========================================
  5260. * make a NPC/PET talk
  5261. * @npctalkc [SnakeDrak]
  5262. *------------------------------------------*/
  5263. ACMD_FUNC(npctalk)
  5264. {
  5265. char name[NAME_LENGTH],mes[100],temp[100];
  5266. struct npc_data *nd;
  5267. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5268. unsigned long color=0;
  5269. if (sd->sc.count && //no "chatting" while muted.
  5270. (sd->sc.data[SC_BERSERK] ||
  5271. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5272. return -1;
  5273. if(!ifcolor) {
  5274. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5275. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5276. return -1;
  5277. }
  5278. }
  5279. else {
  5280. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5281. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  5282. return -1;
  5283. }
  5284. }
  5285. if (!(nd = npc_name2id(name))) {
  5286. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5287. return -1;
  5288. }
  5289. strtok(name, "#"); // discard extra name identifier if present
  5290. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5291. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5292. else clif_message(&nd->bl, temp);
  5293. return 0;
  5294. }
  5295. ACMD_FUNC(pettalk)
  5296. {
  5297. char mes[100],temp[100];
  5298. struct pet_data *pd;
  5299. nullpo_retr(-1, sd);
  5300. if(!sd->status.pet_id || !(pd=sd->pd))
  5301. {
  5302. clif_displaymessage(fd, msg_txt(184));
  5303. return -1;
  5304. }
  5305. if (sd->sc.count && //no "chatting" while muted.
  5306. (sd->sc.data[SC_BERSERK] ||
  5307. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5308. return -1;
  5309. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5310. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5311. return -1;
  5312. }
  5313. if (message[0] == '/')
  5314. {// pet emotion processing
  5315. const char* emo[] = {
  5316. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5317. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5318. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5319. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5320. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5321. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5322. };
  5323. int i;
  5324. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5325. if( i < ARRAYLENGTH(emo) )
  5326. {
  5327. clif_emotion(&pd->bl, i);
  5328. return 0;
  5329. }
  5330. }
  5331. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5332. clif_message(&pd->bl, temp);
  5333. return 0;
  5334. }
  5335. /// @users - displays the number of players present on each map (and percentage)
  5336. /// #users displays on the target user instead of self
  5337. ACMD_FUNC(users)
  5338. {
  5339. char buf[CHAT_SIZE_MAX];
  5340. int i;
  5341. int users[MAX_MAPINDEX];
  5342. int users_all;
  5343. struct s_mapiterator* iter;
  5344. memset(users, 0, sizeof(users));
  5345. users_all = 0;
  5346. // count users on each map
  5347. iter = mapit_getallusers();
  5348. for(;;)
  5349. {
  5350. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5351. if( sd2 == NULL )
  5352. break;// no more users
  5353. if( sd2->mapindex >= MAX_MAPINDEX )
  5354. continue;// invalid mapindex
  5355. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5356. if( users_all < INT_MAX ) ++users_all;
  5357. }
  5358. mapit_free(iter);
  5359. // display results for each map
  5360. for( i = 0; i < MAX_MAPINDEX; ++i )
  5361. {
  5362. if( users[i] == 0 )
  5363. continue;// empty
  5364. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5365. clif_displaymessage(sd->fd, buf);
  5366. }
  5367. // display overall count
  5368. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5369. clif_displaymessage(sd->fd, buf);
  5370. return 0;
  5371. }
  5372. /*==========================================
  5373. *
  5374. *------------------------------------------*/
  5375. ACMD_FUNC(reset)
  5376. {
  5377. pc_resetstate(sd);
  5378. pc_resetskill(sd,1);
  5379. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5380. clif_displaymessage(fd, atcmd_output);
  5381. return 0;
  5382. }
  5383. /*==========================================
  5384. *
  5385. *------------------------------------------*/
  5386. ACMD_FUNC(summon)
  5387. {
  5388. char name[NAME_LENGTH];
  5389. int mob_id = 0;
  5390. int duration = 0;
  5391. struct mob_data *md;
  5392. unsigned int tick=gettick();
  5393. nullpo_retr(-1, sd);
  5394. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5395. {
  5396. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5397. return -1;
  5398. }
  5399. if (duration < 1)
  5400. duration =1;
  5401. else if (duration > 60)
  5402. duration =60;
  5403. if ((mob_id = atoi(name)) == 0)
  5404. mob_id = mobdb_searchname(name);
  5405. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5406. {
  5407. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5408. return -1;
  5409. }
  5410. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5411. if(!md)
  5412. return -1;
  5413. md->master_id=sd->bl.id;
  5414. md->special_state.ai=1;
  5415. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5416. clif_specialeffect(&md->bl,344,AREA);
  5417. mob_spawn(md);
  5418. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5419. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5420. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5421. return 0;
  5422. }
  5423. /*==========================================
  5424. * @adjgroup
  5425. * Temporarily move player to another group
  5426. * Useful during beta testing to allow players to use GM commands for short periods of time
  5427. *------------------------------------------*/
  5428. ACMD_FUNC(adjgroup)
  5429. {
  5430. int new_group = 0;
  5431. nullpo_retr(-1, sd);
  5432. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5433. clif_displaymessage(fd, "Usage: @adjgroup <group_id>");
  5434. return -1;
  5435. }
  5436. if (!pc_group_exists(new_group)) {
  5437. clif_displaymessage(fd, "Specified group does not exists.");
  5438. return -1;
  5439. }
  5440. sd->group_id = new_group;
  5441. clif_displaymessage(fd, "Group changed successfully.");
  5442. clif_displaymessage(sd->fd, "Your group has changed.");
  5443. return 0;
  5444. }
  5445. /*==========================================
  5446. * @trade by [MouseJstr]
  5447. * Open a trade window with a remote player
  5448. *------------------------------------------*/
  5449. ACMD_FUNC(trade)
  5450. {
  5451. struct map_session_data *pl_sd = NULL;
  5452. nullpo_retr(-1, sd);
  5453. if (!message || !*message) {
  5454. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5455. return -1;
  5456. }
  5457. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5458. {
  5459. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5460. return -1;
  5461. }
  5462. trade_traderequest(sd, pl_sd);
  5463. return 0;
  5464. }
  5465. /*==========================================
  5466. * @setbattleflag by [MouseJstr]
  5467. * set a battle_config flag without having to reboot
  5468. *------------------------------------------*/
  5469. ACMD_FUNC(setbattleflag)
  5470. {
  5471. char flag[128], value[128];
  5472. nullpo_retr(-1, sd);
  5473. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5474. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5475. return -1;
  5476. }
  5477. if (battle_set_value(flag, value) == 0)
  5478. {
  5479. clif_displaymessage(fd, "unknown battle_config flag");
  5480. return -1;
  5481. }
  5482. clif_displaymessage(fd, "battle_config set as requested");
  5483. return 0;
  5484. }
  5485. /*==========================================
  5486. * @unmute [Valaris]
  5487. *------------------------------------------*/
  5488. ACMD_FUNC(unmute)
  5489. {
  5490. struct map_session_data *pl_sd = NULL;
  5491. nullpo_retr(-1, sd);
  5492. if (!message || !*message) {
  5493. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5494. return -1;
  5495. }
  5496. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5497. {
  5498. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5499. return -1;
  5500. }
  5501. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5502. clif_displaymessage(sd->fd,"Player is not muted");
  5503. return -1;
  5504. }
  5505. pl_sd->status.manner = 0;
  5506. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5507. clif_displaymessage(sd->fd,"Player unmuted");
  5508. return 0;
  5509. }
  5510. /*==========================================
  5511. * @uptime by MC Cameri
  5512. *------------------------------------------*/
  5513. ACMD_FUNC(uptime)
  5514. {
  5515. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5516. minute = 60, days = 0, hours = 0, minutes = 0;
  5517. nullpo_retr(-1, sd);
  5518. seconds = get_uptime();
  5519. days = seconds/day;
  5520. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5521. hours = seconds/hour;
  5522. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5523. minutes = seconds/minute;
  5524. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5525. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5526. clif_displaymessage(fd, atcmd_output);
  5527. return 0;
  5528. }
  5529. /*==========================================
  5530. * @changesex <sex>
  5531. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5532. *------------------------------------------*/
  5533. ACMD_FUNC(changesex)
  5534. {
  5535. nullpo_retr(-1, sd);
  5536. chrif_changesex(sd);
  5537. return 0;
  5538. }
  5539. /*================================================
  5540. * @mute - Mutes a player for a set amount of time
  5541. *------------------------------------------------*/
  5542. ACMD_FUNC(mute)
  5543. {
  5544. struct map_session_data *pl_sd = NULL;
  5545. int manner;
  5546. nullpo_retr(-1, sd);
  5547. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5548. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5549. return -1;
  5550. }
  5551. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5552. {
  5553. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5554. return -1;
  5555. }
  5556. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5557. {
  5558. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5559. return -1;
  5560. }
  5561. clif_manner_message(sd, 0);
  5562. clif_manner_message(pl_sd, 5);
  5563. if( pl_sd->status.manner < manner ) {
  5564. pl_sd->status.manner -= manner;
  5565. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5566. } else {
  5567. pl_sd->status.manner = 0;
  5568. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5569. }
  5570. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5571. return 0;
  5572. }
  5573. /*==========================================
  5574. * @refresh (like @jumpto <<yourself>>)
  5575. *------------------------------------------*/
  5576. ACMD_FUNC(refresh)
  5577. {
  5578. nullpo_retr(-1, sd);
  5579. clif_refresh(sd);
  5580. return 0;
  5581. }
  5582. /*==========================================
  5583. * @identify
  5584. * => GM's magnifier.
  5585. *------------------------------------------*/
  5586. ACMD_FUNC(identify)
  5587. {
  5588. int i,num;
  5589. nullpo_retr(-1, sd);
  5590. for(i=num=0;i<MAX_INVENTORY;i++){
  5591. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5592. num++;
  5593. }
  5594. }
  5595. if (num > 0) {
  5596. clif_item_identify_list(sd);
  5597. } else {
  5598. clif_displaymessage(fd,"There are no items to appraise.");
  5599. }
  5600. return 0;
  5601. }
  5602. /*==========================================
  5603. * @gmotd (Global MOTD)
  5604. * by davidsiaw :P
  5605. *------------------------------------------*/
  5606. ACMD_FUNC(gmotd)
  5607. {
  5608. char buf[CHAT_SIZE_MAX];
  5609. size_t len;
  5610. FILE* fp;
  5611. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5612. {
  5613. while( fgets(buf, sizeof(buf), fp) )
  5614. {
  5615. if( buf[0] == '/' && buf[1] == '/' )
  5616. {
  5617. continue;
  5618. }
  5619. len = strlen(buf);
  5620. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5621. {// strip trailing EOL characters
  5622. len--;
  5623. }
  5624. if( len )
  5625. {
  5626. buf[len] = 0;
  5627. intif_broadcast(buf, len+1, 0);
  5628. }
  5629. }
  5630. fclose(fp);
  5631. }
  5632. return 0;
  5633. }
  5634. ACMD_FUNC(misceffect)
  5635. {
  5636. int effect = 0;
  5637. nullpo_retr(-1, sd);
  5638. if (!message || !*message)
  5639. return -1;
  5640. if (sscanf(message, "%d", &effect) < 1)
  5641. return -1;
  5642. clif_misceffect(&sd->bl,effect);
  5643. return 0;
  5644. }
  5645. /*==========================================
  5646. * MAIL SYSTEM
  5647. *------------------------------------------*/
  5648. ACMD_FUNC(mail)
  5649. {
  5650. nullpo_ret(sd);
  5651. mail_openmail(sd);
  5652. return 0;
  5653. }
  5654. /*==========================================
  5655. * Show Monster DB Info v 1.0
  5656. * originally by [Lupus] eAthena
  5657. *------------------------------------------*/
  5658. ACMD_FUNC(mobinfo)
  5659. {
  5660. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5661. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5662. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5663. char atcmd_output2[CHAT_SIZE_MAX];
  5664. struct item_data *item_data;
  5665. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5666. int count;
  5667. int i, j, k;
  5668. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5669. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5670. if (!message || !*message) {
  5671. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5672. return -1;
  5673. }
  5674. // If monster identifier/name argument is a name
  5675. if ((i = mobdb_checkid(atoi(message))))
  5676. {
  5677. mob_array[0] = mob_db(i);
  5678. count = 1;
  5679. } else
  5680. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5681. if (!count) {
  5682. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5683. return -1;
  5684. }
  5685. if (count > MAX_SEARCH) {
  5686. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5687. clif_displaymessage(fd, atcmd_output);
  5688. count = MAX_SEARCH;
  5689. }
  5690. for (k = 0; k < count; k++) {
  5691. mob = mob_array[k];
  5692. // stats
  5693. if (mob->mexp)
  5694. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5695. else
  5696. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5697. clif_displaymessage(fd, atcmd_output);
  5698. 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);
  5699. clif_displaymessage(fd, atcmd_output);
  5700. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5701. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5702. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5703. clif_displaymessage(fd, atcmd_output);
  5704. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5705. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5706. mob->range2 , mob->range3, msize[mob->status.size],
  5707. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5708. clif_displaymessage(fd, atcmd_output);
  5709. // drops
  5710. clif_displaymessage(fd, " Drops:");
  5711. strcpy(atcmd_output, " ");
  5712. j = 0;
  5713. for (i = 0; i < MAX_MOB_DROP; i++) {
  5714. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5715. continue;
  5716. if (item_data->slot)
  5717. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5718. else
  5719. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5720. strcat(atcmd_output, atcmd_output2);
  5721. if (++j % 3 == 0) {
  5722. clif_displaymessage(fd, atcmd_output);
  5723. strcpy(atcmd_output, " ");
  5724. }
  5725. }
  5726. if (j == 0)
  5727. clif_displaymessage(fd, "This monster has no drops.");
  5728. else if (j % 3 != 0)
  5729. clif_displaymessage(fd, atcmd_output);
  5730. // mvp
  5731. if (mob->mexp) {
  5732. sprintf(atcmd_output, " MVP Bonus EXP:%u", mob->mexp);
  5733. clif_displaymessage(fd, atcmd_output);
  5734. strcpy(atcmd_output, " MVP Items:");
  5735. j = 0;
  5736. for (i = 0; i < MAX_MVP_DROP; i++) {
  5737. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5738. continue;
  5739. if (mob->mvpitem[i].p > 0) {
  5740. j++;
  5741. if (j == 1)
  5742. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5743. else
  5744. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5745. strcat(atcmd_output, atcmd_output2);
  5746. }
  5747. }
  5748. if (j == 0)
  5749. clif_displaymessage(fd, "This monster has no MVP prizes.");
  5750. else
  5751. clif_displaymessage(fd, atcmd_output);
  5752. }
  5753. }
  5754. return 0;
  5755. }
  5756. /*=========================================
  5757. * @showmobs by KarLaeda
  5758. * => For 15 sec displays the mobs on minimap
  5759. *------------------------------------------*/
  5760. ACMD_FUNC(showmobs)
  5761. {
  5762. char mob_name[100];
  5763. int mob_id;
  5764. int number = 0;
  5765. struct s_mapiterator* it;
  5766. nullpo_retr(-1, sd);
  5767. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5768. return -1;
  5769. if((mob_id = atoi(mob_name)) == 0)
  5770. mob_id = mobdb_searchname(mob_name);
  5771. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5772. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5773. clif_displaymessage(fd, atcmd_output);
  5774. return 0;
  5775. }
  5776. // Uncomment the following line to show mini-bosses & MVP.
  5777. //#define SHOW_MVP
  5778. #ifndef SHOW_MVP
  5779. if(mob_db(mob_id)->status.mode&MD_BOSS){
  5780. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  5781. clif_displaymessage(fd, atcmd_output);
  5782. return 0;
  5783. }
  5784. #endif
  5785. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5786. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5787. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5788. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  5789. mob_name, mapindex_id2name(sd->mapindex));
  5790. clif_displaymessage(fd, atcmd_output);
  5791. it = mapit_geteachmob();
  5792. for(;;)
  5793. {
  5794. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5795. if( md == NULL )
  5796. break;// no more mobs
  5797. if( md->bl.m != sd->bl.m )
  5798. continue;
  5799. if( mob_id != -1 && md->class_ != mob_id )
  5800. continue;
  5801. if( md->special_state.ai || md->master_id )
  5802. continue; // hide slaves and player summoned mobs
  5803. if( md->spawn_timer != INVALID_TIMER )
  5804. continue; // hide mobs waiting for respawn
  5805. ++number;
  5806. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5807. }
  5808. mapit_free(it);
  5809. return 0;
  5810. }
  5811. /*==========================================
  5812. * homunculus level up [orn]
  5813. *------------------------------------------*/
  5814. ACMD_FUNC(homlevel)
  5815. {
  5816. TBL_HOM * hd;
  5817. int level = 0, i = 0;
  5818. nullpo_retr(-1, sd);
  5819. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  5820. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  5821. return -1;
  5822. }
  5823. if ( !merc_is_hom_active(sd->hd) ) {
  5824. clif_displaymessage(fd, "You do not have a homunculus.");
  5825. return -1;
  5826. }
  5827. hd = sd->hd;
  5828. for (i = 1; i <= level && hd->exp_next; i++){
  5829. hd->homunculus.exp += hd->exp_next;
  5830. merc_hom_levelup(hd);
  5831. }
  5832. status_calc_homunculus(hd,0);
  5833. status_percent_heal(&hd->bl, 100, 100);
  5834. clif_specialeffect(&hd->bl,568,AREA);
  5835. return 0;
  5836. }
  5837. /*==========================================
  5838. * homunculus evolution H [orn]
  5839. *------------------------------------------*/
  5840. ACMD_FUNC(homevolution)
  5841. {
  5842. nullpo_retr(-1, sd);
  5843. if ( !merc_is_hom_active(sd->hd) ) {
  5844. clif_displaymessage(fd, "You do not have a homunculus.");
  5845. return -1;
  5846. }
  5847. if ( !merc_hom_evolution(sd->hd) ) {
  5848. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  5849. return -1;
  5850. }
  5851. clif_homskillinfoblock(sd);
  5852. return 0;
  5853. }
  5854. /*==========================================
  5855. * call choosen homunculus [orn]
  5856. *------------------------------------------*/
  5857. ACMD_FUNC(makehomun)
  5858. {
  5859. int homunid;
  5860. nullpo_retr(-1, sd);
  5861. if ( sd->status.hom_id ) {
  5862. clif_displaymessage(fd, msg_txt(450));
  5863. return -1;
  5864. }
  5865. if (!message || !*message) {
  5866. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  5867. return -1;
  5868. }
  5869. homunid = atoi(message);
  5870. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  5871. {
  5872. clif_displaymessage(fd, "Invalid Homunculus id.");
  5873. return -1;
  5874. }
  5875. merc_create_homunculus_request(sd,homunid);
  5876. return 0;
  5877. }
  5878. /*==========================================
  5879. * modify homunculus intimacy [orn]
  5880. *------------------------------------------*/
  5881. ACMD_FUNC(homfriendly)
  5882. {
  5883. int friendly = 0;
  5884. nullpo_retr(-1, sd);
  5885. if ( !merc_is_hom_active(sd->hd) ) {
  5886. clif_displaymessage(fd, "You do not have a homunculus.");
  5887. return -1;
  5888. }
  5889. if (!message || !*message) {
  5890. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  5891. return -1;
  5892. }
  5893. friendly = atoi(message);
  5894. friendly = cap_value(friendly, 0, 1000);
  5895. sd->hd->homunculus.intimacy = friendly * 100 ;
  5896. clif_send_homdata(sd,SP_INTIMATE,friendly);
  5897. return 0;
  5898. }
  5899. /*==========================================
  5900. * modify homunculus hunger [orn]
  5901. *------------------------------------------*/
  5902. ACMD_FUNC(homhungry)
  5903. {
  5904. int hungry = 0;
  5905. nullpo_retr(-1, sd);
  5906. if ( !merc_is_hom_active(sd->hd) ) {
  5907. clif_displaymessage(fd, "You do not have a homunculus.");
  5908. return -1;
  5909. }
  5910. if (!message || !*message) {
  5911. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  5912. return -1;
  5913. }
  5914. hungry = atoi(message);
  5915. hungry = cap_value(hungry, 0, 100);
  5916. sd->hd->homunculus.hunger = hungry;
  5917. clif_send_homdata(sd,SP_HUNGRY,hungry);
  5918. return 0;
  5919. }
  5920. /*==========================================
  5921. * make the homunculus speak [orn]
  5922. *------------------------------------------*/
  5923. ACMD_FUNC(homtalk)
  5924. {
  5925. char mes[100],temp[100];
  5926. nullpo_retr(-1, sd);
  5927. if (sd->sc.count && //no "chatting" while muted.
  5928. (sd->sc.data[SC_BERSERK] ||
  5929. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5930. return -1;
  5931. if ( !merc_is_hom_active(sd->hd) ) {
  5932. clif_displaymessage(fd, "You do not have a homunculus.");
  5933. return -1;
  5934. }
  5935. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5936. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  5937. return -1;
  5938. }
  5939. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  5940. clif_message(&sd->hd->bl, temp);
  5941. return 0;
  5942. }
  5943. /*==========================================
  5944. * Show homunculus stats
  5945. *------------------------------------------*/
  5946. ACMD_FUNC(hominfo)
  5947. {
  5948. struct homun_data *hd;
  5949. struct status_data *status;
  5950. nullpo_retr(-1, sd);
  5951. if ( !merc_is_hom_active(sd->hd) ) {
  5952. clif_displaymessage(fd, "You do not have a homunculus.");
  5953. return -1;
  5954. }
  5955. hd = sd->hd;
  5956. status = status_get_status_data(&hd->bl);
  5957. clif_displaymessage(fd, "Homunculus stats :");
  5958. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  5959. status->hp, status->max_hp, status->sp, status->max_sp);
  5960. clif_displaymessage(fd, atcmd_output);
  5961. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  5962. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  5963. clif_displaymessage(fd, atcmd_output);
  5964. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  5965. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  5966. clif_displaymessage(fd, atcmd_output);
  5967. snprintf(atcmd_output, sizeof(atcmd_output) ,
  5968. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  5969. status->str, status->agi, status->vit,
  5970. status->int_, status->dex, status->luk);
  5971. clif_displaymessage(fd, atcmd_output);
  5972. return 0;
  5973. }
  5974. ACMD_FUNC(homstats)
  5975. {
  5976. struct homun_data *hd;
  5977. struct s_homunculus_db *db;
  5978. struct s_homunculus *hom;
  5979. int lv, min, max, evo;
  5980. nullpo_retr(-1, sd);
  5981. if ( !merc_is_hom_active(sd->hd) ) {
  5982. clif_displaymessage(fd, "You do not have a homunculus.");
  5983. return -1;
  5984. }
  5985. hd = sd->hd;
  5986. hom = &hd->homunculus;
  5987. db = hd->homunculusDB;
  5988. lv = hom->level;
  5989. snprintf(atcmd_output, sizeof(atcmd_output) ,
  5990. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  5991. clif_displaymessage(fd, atcmd_output);
  5992. lv--; //Since the first increase is at level 2.
  5993. evo = (hom->class_ == db->evo_class);
  5994. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  5995. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  5996. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  5997. clif_displaymessage(fd, atcmd_output);
  5998. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  5999. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6000. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6001. clif_displaymessage(fd, atcmd_output);
  6002. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6003. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6004. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6005. clif_displaymessage(fd, atcmd_output);
  6006. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6007. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6008. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6009. clif_displaymessage(fd, atcmd_output);
  6010. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6011. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6012. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6013. clif_displaymessage(fd, atcmd_output);
  6014. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6015. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6016. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6017. clif_displaymessage(fd, atcmd_output);
  6018. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6019. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6020. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6021. clif_displaymessage(fd, atcmd_output);
  6022. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6023. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6024. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6025. clif_displaymessage(fd, atcmd_output);
  6026. return 0;
  6027. }
  6028. ACMD_FUNC(homshuffle)
  6029. {
  6030. nullpo_retr(-1, sd);
  6031. if(!sd->hd)
  6032. return -1; // nothing to do
  6033. if(!merc_hom_shuffle(sd->hd))
  6034. return -1;
  6035. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6036. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6037. return 0;
  6038. }
  6039. /*==========================================
  6040. * Show Items DB Info v 1.0
  6041. * originally by [Lupus] eAthena
  6042. *------------------------------------------*/
  6043. ACMD_FUNC(iteminfo)
  6044. {
  6045. struct item_data *item_data, *item_array[MAX_SEARCH];
  6046. int i, count = 1;
  6047. if (!message || !*message) {
  6048. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6049. return -1;
  6050. }
  6051. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6052. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6053. if (!count) {
  6054. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6055. return -1;
  6056. }
  6057. if (count > MAX_SEARCH) {
  6058. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6059. clif_displaymessage(fd, atcmd_output);
  6060. count = MAX_SEARCH;
  6061. }
  6062. for (i = 0; i < count; i++) {
  6063. item_data = item_array[i];
  6064. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6065. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6066. itemdb_typename(item_data->type),
  6067. (item_data->script==NULL)? "None" : "With script"
  6068. );
  6069. clif_displaymessage(fd, atcmd_output);
  6070. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  6071. clif_displaymessage(fd, atcmd_output);
  6072. if (item_data->maxchance == -1)
  6073. strcpy(atcmd_output, " - Available in the shops only.");
  6074. else if (item_data->maxchance)
  6075. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6076. else
  6077. strcpy(atcmd_output, " - Monsters don't drop this item.");
  6078. clif_displaymessage(fd, atcmd_output);
  6079. }
  6080. return 0;
  6081. }
  6082. /*==========================================
  6083. * Show who drops the item.
  6084. *------------------------------------------*/
  6085. ACMD_FUNC(whodrops)
  6086. {
  6087. struct item_data *item_data, *item_array[MAX_SEARCH];
  6088. int i,j, count = 1;
  6089. if (!message || !*message) {
  6090. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6091. return -1;
  6092. }
  6093. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6094. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6095. if (!count) {
  6096. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6097. return -1;
  6098. }
  6099. if (count > MAX_SEARCH) {
  6100. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6101. clif_displaymessage(fd, atcmd_output);
  6102. count = MAX_SEARCH;
  6103. }
  6104. for (i = 0; i < count; i++) {
  6105. item_data = item_array[i];
  6106. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6107. clif_displaymessage(fd, atcmd_output);
  6108. if (item_data->mob[0].chance == 0) {
  6109. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6110. clif_displaymessage(fd, atcmd_output);
  6111. } else {
  6112. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6113. clif_displaymessage(fd, atcmd_output);
  6114. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6115. {
  6116. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6117. clif_displaymessage(fd, atcmd_output);
  6118. }
  6119. }
  6120. }
  6121. return 0;
  6122. }
  6123. ACMD_FUNC(whereis)
  6124. {
  6125. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6126. int count;
  6127. int i, j, k;
  6128. if (!message || !*message) {
  6129. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6130. return -1;
  6131. }
  6132. // If monster identifier/name argument is a name
  6133. if ((i = mobdb_checkid(atoi(message))))
  6134. {
  6135. mob_array[0] = mob_db(i);
  6136. count = 1;
  6137. } else
  6138. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6139. if (!count) {
  6140. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6141. return -1;
  6142. }
  6143. if (count > MAX_SEARCH) {
  6144. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6145. clif_displaymessage(fd, atcmd_output);
  6146. count = MAX_SEARCH;
  6147. }
  6148. for (k = 0; k < count; k++) {
  6149. mob = mob_array[k];
  6150. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6151. clif_displaymessage(fd, atcmd_output);
  6152. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6153. {
  6154. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6155. if (j < 0) continue;
  6156. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6157. clif_displaymessage(fd, atcmd_output);
  6158. }
  6159. if (i == 0)
  6160. clif_displaymessage(fd, "This monster does not spawn normally.");
  6161. }
  6162. return 0;
  6163. }
  6164. /*==========================================
  6165. * @adopt by [Veider]
  6166. * adopt a novice
  6167. *------------------------------------------*/
  6168. ACMD_FUNC(adopt)
  6169. {
  6170. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6171. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6172. char output[CHAT_SIZE_MAX];
  6173. nullpo_retr(-1, sd);
  6174. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6175. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6176. return -1;
  6177. }
  6178. if (battle_config.etc_log)
  6179. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6180. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6181. sprintf(output, "Cannot find player %s online", player1);
  6182. clif_displaymessage(fd, output);
  6183. return -1;
  6184. }
  6185. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6186. sprintf(output, "Cannot find player %s online", player2);
  6187. clif_displaymessage(fd, output);
  6188. return -1;
  6189. }
  6190. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6191. sprintf(output, "Cannot find player %s online", player3);
  6192. clif_displaymessage(fd, output);
  6193. return -1;
  6194. }
  6195. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6196. return -1;
  6197. }
  6198. clif_displaymessage(fd, "They are family... wish them luck");
  6199. return 0;
  6200. }
  6201. ACMD_FUNC(version)
  6202. {
  6203. const char * revision;
  6204. if ((revision = get_svn_revision()) != 0) {
  6205. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6206. clif_displaymessage(fd,atcmd_output);
  6207. } else
  6208. clif_displaymessage(fd,"Cannot determine SVN revision");
  6209. return 0;
  6210. }
  6211. /*==========================================
  6212. * @mutearea by MouseJstr
  6213. *------------------------------------------*/
  6214. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6215. {
  6216. int time, id;
  6217. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6218. if (pl_sd == NULL)
  6219. return 0;
  6220. id = va_arg(ap, int);
  6221. time = va_arg(ap, int);
  6222. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6223. pl_sd->status.manner -= time;
  6224. if (pl_sd->status.manner < 0)
  6225. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6226. else
  6227. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6228. }
  6229. return 0;
  6230. }
  6231. ACMD_FUNC(mutearea)
  6232. {
  6233. int time;
  6234. nullpo_ret(sd);
  6235. if (!message || !*message) {
  6236. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6237. return -1;
  6238. }
  6239. time = atoi(message);
  6240. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6241. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6242. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6243. return 0;
  6244. }
  6245. ACMD_FUNC(rates)
  6246. {
  6247. char buf[CHAT_SIZE_MAX];
  6248. nullpo_ret(sd);
  6249. memset(buf, '\0', sizeof(buf));
  6250. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  6251. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6252. clif_displaymessage(fd, buf);
  6253. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6254. 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.);
  6255. clif_displaymessage(fd, buf);
  6256. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6257. 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.);
  6258. clif_displaymessage(fd, buf);
  6259. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  6260. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6261. clif_displaymessage(fd, buf);
  6262. return 0;
  6263. }
  6264. /*==========================================
  6265. * @me by lordalfa
  6266. * => Displays the OUTPUT string on top of the Visible players Heads.
  6267. *------------------------------------------*/
  6268. ACMD_FUNC(me)
  6269. {
  6270. char tempmes[CHAT_SIZE_MAX];
  6271. nullpo_retr(-1, sd);
  6272. memset(tempmes, '\0', sizeof(tempmes));
  6273. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6274. if (sd->sc.count && //no "chatting" while muted.
  6275. (sd->sc.data[SC_BERSERK] ||
  6276. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6277. return -1;
  6278. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6279. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6280. return -1;
  6281. }
  6282. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6283. clif_disp_overhead(sd, atcmd_output);
  6284. return 0;
  6285. }
  6286. /*==========================================
  6287. * @size
  6288. * => Resize your character sprite. [Valaris]
  6289. *------------------------------------------*/
  6290. ACMD_FUNC(size)
  6291. {
  6292. int size=0;
  6293. nullpo_retr(-1, sd);
  6294. size = atoi(message);
  6295. if(sd->state.size) {
  6296. sd->state.size=0;
  6297. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6298. }
  6299. if(size==1) {
  6300. sd->state.size=1;
  6301. clif_specialeffect(&sd->bl,420,AREA);
  6302. } else if(size==2) {
  6303. sd->state.size=2;
  6304. clif_specialeffect(&sd->bl,422,AREA);
  6305. }
  6306. return 0;
  6307. }
  6308. /*==========================================
  6309. * @monsterignore
  6310. * => Makes monsters ignore you. [Valaris]
  6311. *------------------------------------------*/
  6312. ACMD_FUNC(monsterignore)
  6313. {
  6314. nullpo_retr(-1, sd);
  6315. if (!sd->state.monster_ignore) {
  6316. sd->state.monster_ignore = 1;
  6317. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6318. } else {
  6319. sd->state.monster_ignore = 0;
  6320. clif_displaymessage(sd->fd, "Returned to normal state.");
  6321. }
  6322. return 0;
  6323. }
  6324. /*==========================================
  6325. * @fakename
  6326. * => Gives your character a fake name. [Valaris]
  6327. *------------------------------------------*/
  6328. ACMD_FUNC(fakename)
  6329. {
  6330. nullpo_retr(-1, sd);
  6331. if( !message || !*message )
  6332. {
  6333. if( sd->fakename[0] )
  6334. {
  6335. sd->fakename[0] = '\0';
  6336. clif_charnameack(0, &sd->bl);
  6337. clif_displaymessage(sd->fd, "Returned to real name.");
  6338. return 0;
  6339. }
  6340. clif_displaymessage(sd->fd, "You must enter a name.");
  6341. return -1;
  6342. }
  6343. if( strlen(message) < 2 )
  6344. {
  6345. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  6346. return -1;
  6347. }
  6348. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6349. clif_charnameack(0, &sd->bl);
  6350. clif_displaymessage(sd->fd, "Fake name enabled.");
  6351. return 0;
  6352. }
  6353. /*==========================================
  6354. * Ragnarok Resources
  6355. *------------------------------------------*/
  6356. ACMD_FUNC(mapflag) {
  6357. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6358. #define setflag( cmd ) \
  6359. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6360. map[ sd->bl.m ].flag.cmd = flag;\
  6361. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6362. clif_displaymessage(sd->fd,atcmd_output);\
  6363. return 0;\
  6364. }
  6365. unsigned char flag_name[100];
  6366. int flag=9,i;
  6367. nullpo_retr(-1, sd);
  6368. memset(flag_name, '\0', sizeof(flag_name));
  6369. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6370. clif_displaymessage(sd->fd,"Enabled Mapflags in this map:");
  6371. clif_displaymessage(sd->fd,"----------------------------------");
  6372. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6373. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6374. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6375. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6376. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6377. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6378. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6379. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6380. checkflag(nogo); checkflag(nobaseexp);
  6381. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6382. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6383. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6384. clif_displaymessage(sd->fd," ");
  6385. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off 1=On)");
  6386. clif_displaymessage(sd->fd,"Use: \"@mapflag available\" to list the available mapflags");
  6387. return 1;
  6388. }
  6389. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6390. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6391. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6392. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6393. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6394. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6395. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6396. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6397. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6398. setflag(nogo); setflag(nobaseexp);
  6399. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6400. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6401. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6402. clif_displaymessage(sd->fd,"Invalid flag name or flag");
  6403. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off | 1=On)");
  6404. clif_displaymessage(sd->fd,"Available Flags:");
  6405. clif_displaymessage(sd->fd,"----------------------------------");
  6406. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6407. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6408. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6409. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6410. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6411. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6412. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6413. #undef checkflag
  6414. #undef setflag
  6415. return 0;
  6416. }
  6417. /*===================================
  6418. * Remove some messages
  6419. *-----------------------------------*/
  6420. ACMD_FUNC(showexp)
  6421. {
  6422. if (sd->state.showexp) {
  6423. sd->state.showexp = 0;
  6424. clif_displaymessage(fd, "Gained exp will not be shown.");
  6425. return 0;
  6426. }
  6427. sd->state.showexp = 1;
  6428. clif_displaymessage(fd, "Gained exp is now shown");
  6429. return 0;
  6430. }
  6431. ACMD_FUNC(showzeny)
  6432. {
  6433. if (sd->state.showzeny) {
  6434. sd->state.showzeny = 0;
  6435. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6436. return 0;
  6437. }
  6438. sd->state.showzeny = 1;
  6439. clif_displaymessage(fd, "Gained zeny is now shown");
  6440. return 0;
  6441. }
  6442. ACMD_FUNC(showdelay)
  6443. {
  6444. if (sd->state.showdelay) {
  6445. sd->state.showdelay = 0;
  6446. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6447. return 0;
  6448. }
  6449. sd->state.showdelay = 1;
  6450. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6451. return 0;
  6452. }
  6453. /*==========================================
  6454. * Duel organizing functions [LuzZza]
  6455. *
  6456. * @duel [limit|nick] - create a duel
  6457. * @invite <nick> - invite player
  6458. * @accept - accept invitation
  6459. * @reject - reject invitation
  6460. * @leave - leave duel
  6461. *------------------------------------------*/
  6462. ACMD_FUNC(invite)
  6463. {
  6464. unsigned int did = sd->duel_group;
  6465. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6466. if(did <= 0) {
  6467. // "Duel: @invite without @duel."
  6468. clif_displaymessage(fd, msg_txt(350));
  6469. return 0;
  6470. }
  6471. if(duel_list[did].max_players_limit > 0 &&
  6472. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6473. // "Duel: Limit of players is reached."
  6474. clif_displaymessage(fd, msg_txt(351));
  6475. return 0;
  6476. }
  6477. if(target_sd == NULL) {
  6478. // "Duel: Player not found."
  6479. clif_displaymessage(fd, msg_txt(352));
  6480. return 0;
  6481. }
  6482. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6483. // "Duel: Player already in duel."
  6484. clif_displaymessage(fd, msg_txt(353));
  6485. return 0;
  6486. }
  6487. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6488. {
  6489. sprintf(atcmd_output, msg_txt(364), message);
  6490. clif_displaymessage(fd, atcmd_output);
  6491. return 0;
  6492. }
  6493. duel_invite(did, sd, target_sd);
  6494. // "Duel: Invitation has been sent."
  6495. clif_displaymessage(fd, msg_txt(354));
  6496. return 0;
  6497. }
  6498. ACMD_FUNC(duel)
  6499. {
  6500. char output[CHAT_SIZE_MAX];
  6501. unsigned int maxpl=0, newduel;
  6502. struct map_session_data *target_sd;
  6503. if(sd->duel_group > 0) {
  6504. duel_showinfo(sd->duel_group, sd);
  6505. return 0;
  6506. }
  6507. if(sd->duel_invite > 0) {
  6508. // "Duel: @duel without @reject."
  6509. clif_displaymessage(fd, msg_txt(355));
  6510. return 0;
  6511. }
  6512. if(!duel_checktime(sd)) {
  6513. // "Duel: You can take part in duel only one time per %d minutes."
  6514. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6515. clif_displaymessage(fd, output);
  6516. return 0;
  6517. }
  6518. if( message[0] ) {
  6519. if(sscanf(message, "%d", &maxpl) >= 1) {
  6520. if(maxpl < 2 || maxpl > 65535) {
  6521. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6522. return 0;
  6523. }
  6524. duel_create(sd, maxpl);
  6525. } else {
  6526. target_sd = map_nick2sd((char *)message);
  6527. if(target_sd != NULL) {
  6528. if((newduel = duel_create(sd, 2)) != -1) {
  6529. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6530. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6531. return 0;
  6532. }
  6533. duel_invite(newduel, sd, target_sd);
  6534. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6535. }
  6536. } else {
  6537. // "Duel: Player not found."
  6538. clif_displaymessage(fd, msg_txt(352));
  6539. return 0;
  6540. }
  6541. }
  6542. } else
  6543. duel_create(sd, 0);
  6544. return 0;
  6545. }
  6546. ACMD_FUNC(leave)
  6547. {
  6548. if(sd->duel_group <= 0) {
  6549. // "Duel: @leave without @duel."
  6550. clif_displaymessage(fd, msg_txt(358));
  6551. return 0;
  6552. }
  6553. duel_leave(sd->duel_group, sd);
  6554. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6555. return 0;
  6556. }
  6557. ACMD_FUNC(accept)
  6558. {
  6559. char output[CHAT_SIZE_MAX];
  6560. if(!duel_checktime(sd)) {
  6561. // "Duel: You can take part in duel only one time per %d minutes."
  6562. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6563. clif_displaymessage(fd, output);
  6564. return 0;
  6565. }
  6566. if(sd->duel_invite <= 0) {
  6567. // "Duel: @accept without invititation."
  6568. clif_displaymessage(fd, msg_txt(360));
  6569. return 0;
  6570. }
  6571. 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 )
  6572. {
  6573. // "Duel: Limit of players is reached."
  6574. clif_displaymessage(fd, msg_txt(351));
  6575. return 0;
  6576. }
  6577. duel_accept(sd->duel_invite, sd);
  6578. // "Duel: Invitation has been accepted."
  6579. clif_displaymessage(fd, msg_txt(361));
  6580. return 0;
  6581. }
  6582. ACMD_FUNC(reject)
  6583. {
  6584. if(sd->duel_invite <= 0) {
  6585. // "Duel: @reject without invititation."
  6586. clif_displaymessage(fd, msg_txt(362));
  6587. return 0;
  6588. }
  6589. duel_reject(sd->duel_invite, sd);
  6590. // "Duel: Invitation has been rejected."
  6591. clif_displaymessage(fd, msg_txt(363));
  6592. return 0;
  6593. }
  6594. /*===================================
  6595. * Cash Points
  6596. *-----------------------------------*/
  6597. ACMD_FUNC(cash)
  6598. {
  6599. char output[128];
  6600. int value;
  6601. nullpo_retr(-1, sd);
  6602. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6603. clif_displaymessage(fd, "Please, enter an amount.");
  6604. return -1;
  6605. }
  6606. if( !strcmpi(command+1,"cash") )
  6607. {
  6608. if( value > 0 ) {
  6609. pc_getcash(sd, value, 0);
  6610. sprintf(output, msg_txt(505), value, sd->cashPoints);
  6611. clif_disp_onlyself(sd, output, strlen(output));
  6612. } else {
  6613. pc_paycash(sd, -value, 0);
  6614. sprintf(output, msg_txt(410), value, sd->cashPoints);
  6615. clif_disp_onlyself(sd, output, strlen(output));
  6616. }
  6617. }
  6618. else
  6619. { // @points
  6620. if( value > 0 ) {
  6621. pc_getcash(sd, 0, value);
  6622. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  6623. clif_disp_onlyself(sd, output, strlen(output));
  6624. } else {
  6625. pc_paycash(sd, -value, -value);
  6626. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  6627. clif_disp_onlyself(sd, output, strlen(output));
  6628. }
  6629. }
  6630. return 0;
  6631. }
  6632. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6633. ACMD_FUNC(clone)
  6634. {
  6635. int x=0,y=0,flag=0,master=0,i=0;
  6636. struct map_session_data *pl_sd=NULL;
  6637. if (!message || !*message) {
  6638. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6639. return 0;
  6640. }
  6641. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6642. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6643. return 0;
  6644. }
  6645. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6646. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6647. return 0;
  6648. }
  6649. if (strcmpi(command+1, "clone") == 0)
  6650. flag = 1;
  6651. else if (strcmpi(command+1, "slaveclone") == 0) {
  6652. flag = 2;
  6653. master = sd->bl.id;
  6654. if (battle_config.atc_slave_clone_limit
  6655. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6656. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6657. return 0;
  6658. }
  6659. }
  6660. do {
  6661. x = sd->bl.x + (rnd() % 10 - 5);
  6662. y = sd->bl.y + (rnd() % 10 - 5);
  6663. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6664. if (i >= 10) {
  6665. x = sd->bl.x;
  6666. y = sd->bl.y;
  6667. }
  6668. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6669. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6670. return 0;
  6671. }
  6672. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6673. return 0;
  6674. }
  6675. /*===================================
  6676. * Main chat [LuzZza]
  6677. * Usage: @main <on|off|message>
  6678. *-----------------------------------*/
  6679. ACMD_FUNC(main)
  6680. {
  6681. if( message[0] ) {
  6682. if(strcmpi(message, "on") == 0) {
  6683. if(!sd->state.mainchat) {
  6684. sd->state.mainchat = 1;
  6685. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6686. } else {
  6687. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6688. }
  6689. } else if(strcmpi(message, "off") == 0) {
  6690. if(sd->state.mainchat) {
  6691. sd->state.mainchat = 0;
  6692. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6693. } else {
  6694. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6695. }
  6696. } else {
  6697. if(!sd->state.mainchat) {
  6698. sd->state.mainchat = 1;
  6699. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6700. }
  6701. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6702. clif_displaymessage(fd, msg_txt(387));
  6703. return -1;
  6704. }
  6705. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  6706. // I use 0xFE000000 color for signalizing that this message is
  6707. // main chat message. 0xFE000000 is invalid color, same using
  6708. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  6709. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
  6710. // Chat logging type 'M' / Main Chat
  6711. 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);
  6712. }
  6713. } else {
  6714. if(sd->state.mainchat)
  6715. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6716. else
  6717. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6718. }
  6719. return 0;
  6720. }
  6721. /*=====================================
  6722. * Autorejecting Invites/Deals [LuzZza]
  6723. * Usage: @noask
  6724. *-------------------------------------*/
  6725. ACMD_FUNC(noask)
  6726. {
  6727. if(sd->state.noask) {
  6728. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6729. sd->state.noask = 0;
  6730. } else {
  6731. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6732. sd->state.noask = 1;
  6733. }
  6734. return 0;
  6735. }
  6736. /*=====================================
  6737. * Send a @request message to all GMs of lowest_gm_level.
  6738. * Usage: @request <petition>
  6739. *-------------------------------------*/
  6740. ACMD_FUNC(request)
  6741. {
  6742. if (!message || !*message) {
  6743. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6744. return -1;
  6745. }
  6746. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6747. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6748. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6749. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6750. return 0;
  6751. }
  6752. /*==========================================
  6753. * Feel (SG save map) Reset [HiddenDragon]
  6754. *------------------------------------------*/
  6755. ACMD_FUNC(feelreset)
  6756. {
  6757. pc_resetfeel(sd);
  6758. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  6759. return 0;
  6760. }
  6761. /*==========================================
  6762. * AUCTION SYSTEM
  6763. *------------------------------------------*/
  6764. ACMD_FUNC(auction)
  6765. {
  6766. nullpo_ret(sd);
  6767. clif_Auction_openwindow(sd);
  6768. return 0;
  6769. }
  6770. /*==========================================
  6771. * Kill Steal Protection
  6772. *------------------------------------------*/
  6773. ACMD_FUNC(ksprotection)
  6774. {
  6775. nullpo_retr(-1,sd);
  6776. if( sd->state.noks ) {
  6777. sd->state.noks = 0;
  6778. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  6779. }
  6780. else
  6781. {
  6782. if( !message || !*message || !strcmpi(message, "party") )
  6783. { // Default is Party
  6784. sd->state.noks = 2;
  6785. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  6786. }
  6787. else if( !strcmpi(message, "self") )
  6788. {
  6789. sd->state.noks = 1;
  6790. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  6791. }
  6792. else if( !strcmpi(message, "guild") )
  6793. {
  6794. sd->state.noks = 3;
  6795. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  6796. }
  6797. else
  6798. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  6799. }
  6800. clif_displaymessage(fd, atcmd_output);
  6801. return 0;
  6802. }
  6803. /*==========================================
  6804. * Map Kill Steal Protection Setting
  6805. *------------------------------------------*/
  6806. ACMD_FUNC(allowks)
  6807. {
  6808. nullpo_retr(-1,sd);
  6809. if( map[sd->bl.m].flag.allowks ) {
  6810. map[sd->bl.m].flag.allowks = 0;
  6811. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  6812. } else {
  6813. map[sd->bl.m].flag.allowks = 1;
  6814. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  6815. }
  6816. clif_displaymessage(fd, atcmd_output);
  6817. return 0;
  6818. }
  6819. ACMD_FUNC(resetstat)
  6820. {
  6821. nullpo_retr(-1, sd);
  6822. pc_resetstate(sd);
  6823. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  6824. clif_displaymessage(fd, atcmd_output);
  6825. return 0;
  6826. }
  6827. ACMD_FUNC(resetskill)
  6828. {
  6829. nullpo_retr(-1,sd);
  6830. pc_resetskill(sd,1);
  6831. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  6832. clif_displaymessage(fd, atcmd_output);
  6833. return 0;
  6834. }
  6835. /*==========================================
  6836. * #storagelist: Displays the items list of a player's storage.
  6837. * #cartlist: Displays contents of target's cart.
  6838. * #itemlist: Displays contents of target's inventory.
  6839. *------------------------------------------*/
  6840. ACMD_FUNC(itemlist)
  6841. {
  6842. int i, j, count, counter;
  6843. const char* location;
  6844. const struct item* items;
  6845. int size;
  6846. StringBuf buf;
  6847. nullpo_retr(-1, sd);
  6848. if( strcmp(command+1, "storagelist") == 0 )
  6849. {
  6850. location = "storage";
  6851. items = sd->status.storage.items;
  6852. size = MAX_STORAGE;
  6853. }
  6854. else
  6855. if( strcmp(command+1, "cartlist") == 0 )
  6856. {
  6857. location = "cart";
  6858. items = sd->status.cart;
  6859. size = MAX_CART;
  6860. }
  6861. else
  6862. if( strcmp(command+1, "itemlist") == 0 )
  6863. {
  6864. location = "inventory";
  6865. items = sd->status.inventory;
  6866. size = MAX_INVENTORY;
  6867. }
  6868. else
  6869. return 1;
  6870. StringBuf_Init(&buf);
  6871. count = 0; // total slots occupied
  6872. counter = 0; // total items found
  6873. for( i = 0; i < size; ++i )
  6874. {
  6875. const struct item* it = &items[i];
  6876. struct item_data* itd;
  6877. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  6878. continue;
  6879. counter += it->amount;
  6880. count++;
  6881. if( count == 1 )
  6882. {
  6883. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  6884. clif_displaymessage(fd, StringBuf_Value(&buf));
  6885. StringBuf_Clear(&buf);
  6886. }
  6887. if( it->refine )
  6888. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  6889. else
  6890. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  6891. if( it->equip )
  6892. {
  6893. char equipstr[CHAT_SIZE_MAX];
  6894. strcpy(equipstr, " | equipped: ");
  6895. if( it->equip & EQP_GARMENT )
  6896. strcat(equipstr, "garment, ");
  6897. if( it->equip & EQP_ACC_L )
  6898. strcat(equipstr, "left accessory, ");
  6899. if( it->equip & EQP_ARMOR )
  6900. strcat(equipstr, "body/armor, ");
  6901. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  6902. strcat(equipstr, "right hand, ");
  6903. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  6904. strcat(equipstr, "left hand, ");
  6905. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  6906. strcat(equipstr, "both hands, ");
  6907. if( it->equip & EQP_SHOES )
  6908. strcat(equipstr, "feet, ");
  6909. if( it->equip & EQP_ACC_R )
  6910. strcat(equipstr, "right accessory, ");
  6911. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  6912. strcat(equipstr, "lower head, ");
  6913. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  6914. strcat(equipstr, "top head, ");
  6915. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  6916. strcat(equipstr, "lower/top head, ");
  6917. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  6918. strcat(equipstr, "mid head, ");
  6919. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  6920. strcat(equipstr, "lower/mid head, ");
  6921. if( (it->equip & EQP_HELM) == EQP_HELM )
  6922. strcat(equipstr, "lower/mid/top head, ");
  6923. // remove final ', '
  6924. equipstr[strlen(equipstr) - 2] = '\0';
  6925. StringBuf_AppendStr(&buf, equipstr);
  6926. }
  6927. clif_displaymessage(fd, StringBuf_Value(&buf));
  6928. StringBuf_Clear(&buf);
  6929. if( it->card[0] == CARD0_PET )
  6930. {// pet egg
  6931. if (it->card[3])
  6932. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  6933. else
  6934. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  6935. }
  6936. else
  6937. if(it->card[0] == CARD0_FORGE)
  6938. {// forged item
  6939. 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);
  6940. }
  6941. else
  6942. if(it->card[0] == CARD0_CREATE)
  6943. {// created item
  6944. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  6945. }
  6946. else
  6947. {// normal item
  6948. int counter2 = 0;
  6949. for( j = 0; j < itd->slot; ++j )
  6950. {
  6951. struct item_data* card;
  6952. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  6953. continue;
  6954. counter2++;
  6955. if( counter2 == 1 )
  6956. StringBuf_AppendStr(&buf, " -> (card(s): ");
  6957. if( counter2 != 1 )
  6958. StringBuf_AppendStr(&buf, ", ");
  6959. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  6960. }
  6961. if( counter2 > 0 )
  6962. StringBuf_AppendStr(&buf, ")");
  6963. }
  6964. if( StringBuf_Length(&buf) > 0 )
  6965. clif_displaymessage(fd, StringBuf_Value(&buf));
  6966. StringBuf_Clear(&buf);
  6967. }
  6968. if( count == 0 )
  6969. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  6970. else
  6971. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  6972. clif_displaymessage(fd, StringBuf_Value(&buf));
  6973. StringBuf_Destroy(&buf);
  6974. return 0;
  6975. }
  6976. ACMD_FUNC(stats)
  6977. {
  6978. char job_jobname[100];
  6979. char output[CHAT_SIZE_MAX];
  6980. int i;
  6981. struct {
  6982. const char* format;
  6983. int value;
  6984. } output_table[] = {
  6985. { "Base Level - %d", 0 },
  6986. { NULL, 0 },
  6987. { "Hp - %d", 0 },
  6988. { "MaxHp - %d", 0 },
  6989. { "Sp - %d", 0 },
  6990. { "MaxSp - %d", 0 },
  6991. { "Str - %3d", 0 },
  6992. { "Agi - %3d", 0 },
  6993. { "Vit - %3d", 0 },
  6994. { "Int - %3d", 0 },
  6995. { "Dex - %3d", 0 },
  6996. { "Luk - %3d", 0 },
  6997. { "Zeny - %d", 0 },
  6998. { "Free SK Points - %d", 0 },
  6999. { "JobChangeLvl - %d", 0 },
  7000. { NULL, 0 }
  7001. };
  7002. memset(job_jobname, '\0', sizeof(job_jobname));
  7003. memset(output, '\0', sizeof(output));
  7004. //direct array initialization with variables is not standard C compliant.
  7005. output_table[0].value = sd->status.base_level;
  7006. output_table[1].format = job_jobname;
  7007. output_table[1].value = sd->status.job_level;
  7008. output_table[2].value = sd->status.hp;
  7009. output_table[3].value = sd->status.max_hp;
  7010. output_table[4].value = sd->status.sp;
  7011. output_table[5].value = sd->status.max_sp;
  7012. output_table[6].value = sd->status.str;
  7013. output_table[7].value = sd->status.agi;
  7014. output_table[8].value = sd->status.vit;
  7015. output_table[9].value = sd->status.int_;
  7016. output_table[10].value = sd->status.dex;
  7017. output_table[11].value = sd->status.luk;
  7018. output_table[12].value = sd->status.zeny;
  7019. output_table[13].value = sd->status.skill_point;
  7020. output_table[14].value = sd->change_level;
  7021. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7022. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7023. clif_displaymessage(fd, output);
  7024. for (i = 0; output_table[i].format != NULL; i++) {
  7025. sprintf(output, output_table[i].format, output_table[i].value);
  7026. clif_displaymessage(fd, output);
  7027. }
  7028. return 0;
  7029. }
  7030. ACMD_FUNC(delitem)
  7031. {
  7032. char item_name[100];
  7033. int nameid, amount = 0, total, idx;
  7034. struct item_data* id;
  7035. nullpo_retr(-1, sd);
  7036. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7037. {
  7038. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  7039. return -1;
  7040. }
  7041. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7042. {
  7043. nameid = id->nameid;
  7044. }
  7045. else
  7046. {
  7047. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7048. return -1;
  7049. }
  7050. total = amount;
  7051. // delete items
  7052. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7053. {
  7054. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7055. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7056. {// delete pet
  7057. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7058. }
  7059. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7060. amount-= delamount;
  7061. }
  7062. // notify target
  7063. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7064. clif_displaymessage(sd->fd, atcmd_output);
  7065. // notify source
  7066. if( amount == total )
  7067. {
  7068. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7069. }
  7070. else if( amount )
  7071. {
  7072. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7073. clif_displaymessage(fd, atcmd_output);
  7074. }
  7075. else
  7076. {
  7077. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7078. clif_displaymessage(fd, atcmd_output);
  7079. }
  7080. return 0;
  7081. }
  7082. /*==========================================
  7083. * Custom Fonts
  7084. *------------------------------------------*/
  7085. ACMD_FUNC(font)
  7086. {
  7087. int font_id;
  7088. nullpo_retr(-1,sd);
  7089. font_id = atoi(message);
  7090. if( font_id == 0 )
  7091. {
  7092. if( sd->user_font )
  7093. {
  7094. sd->user_font = 0;
  7095. clif_displaymessage(fd, "Returning to normal font.");
  7096. clif_font(sd);
  7097. }
  7098. else
  7099. {
  7100. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  7101. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  7102. }
  7103. }
  7104. else if( font_id < 0 || font_id > 9 )
  7105. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  7106. else if( font_id != sd->user_font )
  7107. {
  7108. sd->user_font = font_id;
  7109. clif_font(sd);
  7110. clif_displaymessage(fd, "Font changed.");
  7111. }
  7112. else
  7113. clif_displaymessage(fd, "Already using this font.");
  7114. return 0;
  7115. }
  7116. /*==========================================
  7117. * type: 1 = commands (@), 2 = charcommands (#)
  7118. *------------------------------------------*/
  7119. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7120. {
  7121. char line_buff[CHATBOX_SIZE];
  7122. char* cur = line_buff;
  7123. AtCommandInfo* cmd;
  7124. DBIterator* iter = atcommand_db->iterator(atcommand_db);
  7125. int count = 0;
  7126. memset(line_buff,' ',CHATBOX_SIZE);
  7127. line_buff[CHATBOX_SIZE-1] = 0;
  7128. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7129. for (cmd = (AtCommandInfo*)iter->first(iter, NULL); iter->exists(iter); cmd = (AtCommandInfo*)iter->next(iter, NULL)) {
  7130. unsigned int slen = 0;
  7131. if (!pc_can_use_command(sd, cmd->command, type))
  7132. continue;
  7133. slen = strlen(cmd->command);
  7134. // flush the text buffer if this command won't fit into it
  7135. if ( slen + cur - line_buff >= CHATBOX_SIZE )
  7136. {
  7137. clif_displaymessage(fd,line_buff);
  7138. cur = line_buff;
  7139. memset(line_buff,' ',CHATBOX_SIZE);
  7140. line_buff[CHATBOX_SIZE-1] = 0;
  7141. }
  7142. memcpy(cur,cmd->command,slen);
  7143. cur += slen+(10-slen%10);
  7144. count++;
  7145. }
  7146. iter->destroy(iter);
  7147. clif_displaymessage(fd,line_buff);
  7148. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7149. clif_displaymessage(fd, atcmd_output);
  7150. return;
  7151. }
  7152. /*==========================================
  7153. * @commands Lists available @ commands to you
  7154. *------------------------------------------*/
  7155. ACMD_FUNC(commands)
  7156. {
  7157. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7158. return 0;
  7159. }
  7160. /*==========================================
  7161. * @charcommands Lists available # commands to you
  7162. *------------------------------------------*/
  7163. ACMD_FUNC(charcommands)
  7164. {
  7165. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7166. return 0;
  7167. }
  7168. ACMD_FUNC(new_mount) {
  7169. clif_displaymessage(sd->fd,"NOTICE: If you crash with mount your LUA is outdated");
  7170. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7171. clif_displaymessage(sd->fd,"You have mounted.");
  7172. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7173. } else {
  7174. clif_displaymessage(sd->fd,"You have released your mount");
  7175. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7176. }
  7177. return 0;
  7178. }
  7179. /**
  7180. * Fills the reference of available commands in atcommand DBMap
  7181. **/
  7182. #define ACMD_DEF(x) { #x, atcommand_ ## x }
  7183. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x }
  7184. void atcommand_basecommands(void) {
  7185. /**
  7186. * Command reference list, place the base of your commands here
  7187. **/
  7188. AtCommandInfo atcommand_base[] = {
  7189. ACMD_DEF2("warp", mapmove),
  7190. ACMD_DEF(where),
  7191. ACMD_DEF(jumpto),
  7192. ACMD_DEF(jump),
  7193. ACMD_DEF(who),
  7194. ACMD_DEF2("who2", who),
  7195. ACMD_DEF2("who3", who),
  7196. ACMD_DEF2("whomap", who),
  7197. ACMD_DEF2("whomap2", who),
  7198. ACMD_DEF2("whomap3", who),
  7199. ACMD_DEF(whogm),
  7200. ACMD_DEF(save),
  7201. ACMD_DEF(load),
  7202. ACMD_DEF(speed),
  7203. ACMD_DEF(storage),
  7204. ACMD_DEF(guildstorage),
  7205. ACMD_DEF(option),
  7206. ACMD_DEF(hide), // + /hide
  7207. ACMD_DEF(jobchange),
  7208. ACMD_DEF(kill),
  7209. ACMD_DEF(alive),
  7210. ACMD_DEF(kami),
  7211. ACMD_DEF2("kamib", kami),
  7212. ACMD_DEF2("kamic", kami),
  7213. ACMD_DEF2("lkami", kami),
  7214. ACMD_DEF(heal),
  7215. ACMD_DEF(item),
  7216. ACMD_DEF(item2),
  7217. ACMD_DEF(itemreset),
  7218. ACMD_DEF2("blvl", baselevelup),
  7219. ACMD_DEF2("jlvl", joblevelup),
  7220. ACMD_DEF(help),
  7221. ACMD_DEF(pvpoff),
  7222. ACMD_DEF(pvpon),
  7223. ACMD_DEF(gvgoff),
  7224. ACMD_DEF(gvgon),
  7225. ACMD_DEF(model),
  7226. ACMD_DEF(go),
  7227. ACMD_DEF(monster),
  7228. ACMD_DEF2("monstersmall", monster),
  7229. ACMD_DEF2("monsterbig", monster),
  7230. ACMD_DEF(killmonster),
  7231. ACMD_DEF(killmonster2),
  7232. ACMD_DEF(refine),
  7233. ACMD_DEF(produce),
  7234. ACMD_DEF(memo),
  7235. ACMD_DEF(gat),
  7236. ACMD_DEF(displaystatus),
  7237. ACMD_DEF2("stpoint", statuspoint),
  7238. ACMD_DEF2("skpoint", skillpoint),
  7239. ACMD_DEF(zeny),
  7240. ACMD_DEF2("str", param),
  7241. ACMD_DEF2("agi", param),
  7242. ACMD_DEF2("vit", param),
  7243. ACMD_DEF2("int", param),
  7244. ACMD_DEF2("dex", param),
  7245. ACMD_DEF2("luk", param),
  7246. ACMD_DEF2("glvl", guildlevelup),
  7247. ACMD_DEF(makeegg),
  7248. ACMD_DEF(hatch),
  7249. ACMD_DEF(petfriendly),
  7250. ACMD_DEF(pethungry),
  7251. ACMD_DEF(petrename),
  7252. ACMD_DEF(recall), // + /recall
  7253. ACMD_DEF(night),
  7254. ACMD_DEF(day),
  7255. ACMD_DEF(doom),
  7256. ACMD_DEF(doommap),
  7257. ACMD_DEF(raise),
  7258. ACMD_DEF(raisemap),
  7259. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  7260. ACMD_DEF(kickall),
  7261. ACMD_DEF(allskill),
  7262. ACMD_DEF(questskill),
  7263. ACMD_DEF(lostskill),
  7264. ACMD_DEF(spiritball),
  7265. ACMD_DEF(party),
  7266. ACMD_DEF(guild),
  7267. ACMD_DEF(agitstart),
  7268. ACMD_DEF(agitend),
  7269. ACMD_DEF(mapexit),
  7270. ACMD_DEF(idsearch),
  7271. ACMD_DEF(broadcast), // + /b and /nb
  7272. ACMD_DEF(localbroadcast), // + /lb and /nlb
  7273. ACMD_DEF(recallall),
  7274. ACMD_DEF(reloaditemdb),
  7275. ACMD_DEF(reloadmobdb),
  7276. ACMD_DEF(reloadskilldb),
  7277. ACMD_DEF(reloadscript),
  7278. ACMD_DEF(reloadatcommand),
  7279. ACMD_DEF(reloadbattleconf),
  7280. ACMD_DEF(reloadstatusdb),
  7281. ACMD_DEF(reloadpcdb),
  7282. ACMD_DEF(reloadmotd),
  7283. ACMD_DEF(mapinfo),
  7284. ACMD_DEF(dye),
  7285. ACMD_DEF2("hairstyle", hair_style),
  7286. ACMD_DEF2("haircolor", hair_color),
  7287. ACMD_DEF2("allstats", stat_all),
  7288. ACMD_DEF2("block", char_block),
  7289. ACMD_DEF2("ban", char_ban),
  7290. ACMD_DEF2("unblock", char_unblock),
  7291. ACMD_DEF2("unban", char_unban),
  7292. ACMD_DEF2("mount", mount_peco),
  7293. ACMD_DEF(guildspy),
  7294. ACMD_DEF(partyspy),
  7295. ACMD_DEF(repairall),
  7296. ACMD_DEF(guildrecall),
  7297. ACMD_DEF(partyrecall),
  7298. ACMD_DEF(nuke),
  7299. ACMD_DEF(shownpc),
  7300. ACMD_DEF(hidenpc),
  7301. ACMD_DEF(loadnpc),
  7302. ACMD_DEF(unloadnpc),
  7303. ACMD_DEF2("time", servertime),
  7304. ACMD_DEF(jail),
  7305. ACMD_DEF(unjail),
  7306. ACMD_DEF(jailfor),
  7307. ACMD_DEF(jailtime),
  7308. ACMD_DEF(disguise),
  7309. ACMD_DEF(undisguise),
  7310. ACMD_DEF(email),
  7311. ACMD_DEF(effect),
  7312. ACMD_DEF(follow),
  7313. ACMD_DEF(addwarp),
  7314. ACMD_DEF(skillon),
  7315. ACMD_DEF(skilloff),
  7316. ACMD_DEF(killer),
  7317. ACMD_DEF(npcmove),
  7318. ACMD_DEF(killable),
  7319. ACMD_DEF(dropall),
  7320. ACMD_DEF(storeall),
  7321. ACMD_DEF(skillid),
  7322. ACMD_DEF(useskill),
  7323. ACMD_DEF(displayskill),
  7324. ACMD_DEF(snow),
  7325. ACMD_DEF(sakura),
  7326. ACMD_DEF(clouds),
  7327. ACMD_DEF(clouds2),
  7328. ACMD_DEF(fog),
  7329. ACMD_DEF(fireworks),
  7330. ACMD_DEF(leaves),
  7331. ACMD_DEF(summon),
  7332. ACMD_DEF(adjgroup),
  7333. ACMD_DEF(trade),
  7334. ACMD_DEF(send),
  7335. ACMD_DEF(setbattleflag),
  7336. ACMD_DEF(unmute),
  7337. ACMD_DEF(clearweather),
  7338. ACMD_DEF(uptime),
  7339. ACMD_DEF(changesex),
  7340. ACMD_DEF(mute),
  7341. ACMD_DEF(refresh),
  7342. ACMD_DEF(identify),
  7343. ACMD_DEF(gmotd),
  7344. ACMD_DEF(misceffect),
  7345. ACMD_DEF(mobsearch),
  7346. ACMD_DEF(cleanmap),
  7347. ACMD_DEF(npctalk),
  7348. ACMD_DEF(pettalk),
  7349. ACMD_DEF(users),
  7350. ACMD_DEF(reset),
  7351. ACMD_DEF(skilltree),
  7352. ACMD_DEF(marry),
  7353. ACMD_DEF(divorce),
  7354. ACMD_DEF(sound),
  7355. ACMD_DEF(undisguiseall),
  7356. ACMD_DEF(disguiseall),
  7357. ACMD_DEF(changelook),
  7358. ACMD_DEF(autoloot),
  7359. ACMD_DEF2("alootid", autolootitem),
  7360. ACMD_DEF(mobinfo),
  7361. ACMD_DEF(exp),
  7362. ACMD_DEF(adopt),
  7363. ACMD_DEF(version),
  7364. ACMD_DEF(mutearea),
  7365. ACMD_DEF(rates),
  7366. ACMD_DEF(iteminfo),
  7367. ACMD_DEF(whodrops),
  7368. ACMD_DEF(whereis),
  7369. ACMD_DEF(mapflag),
  7370. ACMD_DEF(me),
  7371. ACMD_DEF(monsterignore),
  7372. ACMD_DEF(fakename),
  7373. ACMD_DEF(size),
  7374. ACMD_DEF(showexp),
  7375. ACMD_DEF(showzeny),
  7376. ACMD_DEF(showdelay),
  7377. ACMD_DEF(autotrade),
  7378. ACMD_DEF(changegm),
  7379. ACMD_DEF(changeleader),
  7380. ACMD_DEF(partyoption),
  7381. ACMD_DEF(invite),
  7382. ACMD_DEF(duel),
  7383. ACMD_DEF(leave),
  7384. ACMD_DEF(accept),
  7385. ACMD_DEF(reject),
  7386. ACMD_DEF(main),
  7387. ACMD_DEF(clone),
  7388. ACMD_DEF2("slaveclone", clone),
  7389. ACMD_DEF2("evilclone", clone),
  7390. ACMD_DEF(tonpc),
  7391. ACMD_DEF(commands),
  7392. ACMD_DEF(noask),
  7393. ACMD_DEF(request),
  7394. ACMD_DEF(homlevel),
  7395. ACMD_DEF(homevolution),
  7396. ACMD_DEF(makehomun),
  7397. ACMD_DEF(homfriendly),
  7398. ACMD_DEF(homhungry),
  7399. ACMD_DEF(homtalk),
  7400. ACMD_DEF(hominfo),
  7401. ACMD_DEF(homstats),
  7402. ACMD_DEF(homshuffle),
  7403. ACMD_DEF(showmobs),
  7404. ACMD_DEF(feelreset),
  7405. ACMD_DEF(auction),
  7406. ACMD_DEF(mail),
  7407. ACMD_DEF2("noks", ksprotection),
  7408. ACMD_DEF(allowks),
  7409. ACMD_DEF(cash),
  7410. ACMD_DEF2("points", cash),
  7411. ACMD_DEF(agitstart2),
  7412. ACMD_DEF(agitend2),
  7413. ACMD_DEF2("skreset", resetskill),
  7414. ACMD_DEF2("streset", resetstat),
  7415. ACMD_DEF2("storagelist", itemlist),
  7416. ACMD_DEF2("cartlist", itemlist),
  7417. ACMD_DEF2("itemlist", itemlist),
  7418. ACMD_DEF(stats),
  7419. ACMD_DEF(delitem),
  7420. ACMD_DEF(charcommands),
  7421. ACMD_DEF(font),
  7422. /**
  7423. * For Testing Purposes, not going to be here after we're done.
  7424. **/
  7425. ACMD_DEF2("newmount", new_mount),
  7426. };
  7427. AtCommandInfo* atcommand;
  7428. int i;
  7429. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7430. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  7431. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  7432. continue;
  7433. }
  7434. CREATE(atcommand, AtCommandInfo, 1);
  7435. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  7436. atcommand->func = atcommand_base[i].func;
  7437. strdb_put(atcommand_db, atcommand->command, atcommand);
  7438. }
  7439. return;
  7440. }
  7441. /*==========================================
  7442. * Command lookup functions
  7443. *------------------------------------------*/
  7444. bool atcommand_exists(const char* name)
  7445. {
  7446. return strdb_exists(atcommand_db, name);
  7447. }
  7448. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  7449. {
  7450. if (strdb_exists(atcommand_db, name))
  7451. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7452. return NULL;
  7453. }
  7454. static const char* atcommand_checkalias(const char *aliasname)
  7455. {
  7456. AliasInfo *alias_info = NULL;
  7457. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  7458. return alias_info->command->command;
  7459. return aliasname;
  7460. }
  7461. /// Executes an at-command.
  7462. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7463. {
  7464. char charname[NAME_LENGTH], params[100];
  7465. char charname2[NAME_LENGTH], params2[100];
  7466. char command[100];
  7467. char output[CHAT_SIZE_MAX];
  7468. //Reconstructed message
  7469. char atcmd_msg[CHAT_SIZE_MAX];
  7470. TBL_PC * ssd = NULL; //sd for target
  7471. AtCommandInfo * info;
  7472. nullpo_retr(false, sd);
  7473. //Shouldn't happen
  7474. if ( !message || !*message )
  7475. return false;
  7476. //Block NOCHAT but do not display it as a normal message
  7477. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7478. return true;
  7479. // skip 10/11-langtype's codepage indicator, if detected
  7480. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7481. message += 3;
  7482. //Should display as a normal message
  7483. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7484. return false;
  7485. // type value 0 = server invoked: bypass restrictions
  7486. // 1 = player invoked
  7487. if ( type == 1) {
  7488. //Commands are disabled on maps flagged as 'nocommand'
  7489. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  7490. clif_displaymessage(fd, msg_txt(143));
  7491. return false;
  7492. }
  7493. }
  7494. if (*message == charcommand_symbol) {
  7495. do {
  7496. int x, y, z;
  7497. //Checks to see if #command has a name or a name + parameters.
  7498. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7499. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7500. //z always has the value of the scan that was successful
  7501. z = ( x > 1 ) ? x : y;
  7502. //#command + name means the sufficient target was used and anything else after
  7503. //can be looked at by the actual command function since most scan to see if the
  7504. //right parameters are used.
  7505. if ( x > 2 ) {
  7506. sprintf(atcmd_msg, "%s %s", command, params);
  7507. break;
  7508. }
  7509. else if ( y > 2 ) {
  7510. sprintf(atcmd_msg, "%s %s", command, params2);
  7511. break;
  7512. }
  7513. //Regardless of what style the #command is used, if it's correct, it will always have
  7514. //this value if there is no parameter. Send it as just the #command
  7515. else if ( z == 2 ) {
  7516. sprintf(atcmd_msg, "%s", command);
  7517. break;
  7518. }
  7519. sprintf(output, "Charcommand failed. Usage: %c<command> <char name> <params>.", charcommand_symbol);
  7520. clif_displaymessage(fd, output);
  7521. return true;
  7522. } while(0);
  7523. }
  7524. else if (*message == atcommand_symbol) {
  7525. //atcmd_msg is constructed above differently for charcommands
  7526. //it's copied from message if not a charcommand so it can
  7527. //pass through the rest of the code compatible with both symbols
  7528. sprintf(atcmd_msg, "%s", message);
  7529. }
  7530. //Clearing these to be used once more.
  7531. memset(command, '\0', sizeof(command));
  7532. memset(params, '\0', sizeof(params));
  7533. //check to see if any params exist within this command
  7534. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7535. params[0] = '\0';
  7536. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7537. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  7538. if (info == NULL)
  7539. {
  7540. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  7541. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7542. clif_displaymessage(fd, output);
  7543. return true;
  7544. } else
  7545. return false;
  7546. }
  7547. // type == 1 : player invoked
  7548. if (type == 1) {
  7549. if ((*command == atcommand_symbol && !pc_can_use_command(sd, atcommand_checkalias(command + 1), COMMAND_ATCOMMAND)) ||
  7550. (*command == charcommand_symbol && !pc_can_use_command(sd, atcommand_checkalias(command + 1), COMMAND_CHARCOMMAND))) {
  7551. return false;
  7552. }
  7553. }
  7554. // Check if target is valid only if confirmed that player can use command.
  7555. if (*message == charcommand_symbol &&
  7556. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  7557. sprintf(output, "%s failed. Player not found.", command);
  7558. clif_displaymessage(fd, output);
  7559. return true;
  7560. }
  7561. //Attempt to use the command
  7562. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  7563. {
  7564. sprintf(output,msg_txt(154), command); // %s failed.
  7565. clif_displaymessage(fd, output);
  7566. return true;
  7567. }
  7568. //Log only if successful.
  7569. if ( *atcmd_msg == atcommand_symbol )
  7570. log_atcommand(sd, atcmd_msg);
  7571. else if ( *atcmd_msg == charcommand_symbol )
  7572. log_atcommand(sd, message);
  7573. return true;
  7574. }
  7575. /*==========================================
  7576. *
  7577. *------------------------------------------*/
  7578. static void atcommand_config_read(const char* config_filename)
  7579. {
  7580. config_setting_t *aliases = NULL, *help = NULL;
  7581. const char *symbol = NULL;
  7582. int num_aliases = 0;
  7583. if (conf_read_file(&atcommand_config, config_filename))
  7584. return;
  7585. // Command symbols
  7586. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  7587. if (ISPRINT(*symbol) && // no control characters
  7588. *symbol != '/' && // symbol of client commands
  7589. *symbol != '%' && // symbol of party chat
  7590. *symbol != '$' && // symbol of guild chat
  7591. *symbol != charcommand_symbol)
  7592. atcommand_symbol = *symbol;
  7593. }
  7594. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  7595. if (ISPRINT(*symbol) && // no control characters
  7596. *symbol != '/' && // symbol of client commands
  7597. *symbol != '%' && // symbol of party chat
  7598. *symbol != '$' && // symbol of guild chat
  7599. *symbol != atcommand_symbol)
  7600. charcommand_symbol = *symbol;
  7601. }
  7602. // Command aliases
  7603. aliases = config_lookup(&atcommand_config, "aliases");
  7604. if (aliases != NULL) {
  7605. int i = 0;
  7606. int count = config_setting_length(aliases);
  7607. for (i = 0; i < count; ++i) {
  7608. config_setting_t *command = NULL;
  7609. const char *commandname = NULL;
  7610. int j = 0, alias_count = 0;
  7611. AtCommandInfo *commandinfo = NULL;
  7612. command = config_setting_get_elem(aliases, i);
  7613. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  7614. continue;
  7615. commandname = config_setting_name(command);
  7616. if (!atcommand_exists(commandname)) {
  7617. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  7618. continue;
  7619. }
  7620. commandinfo = get_atcommandinfo_byname(commandname);
  7621. alias_count = config_setting_length(command);
  7622. for (j = 0; j < alias_count; ++j) {
  7623. const char *alias = config_setting_get_string_elem(command, j);
  7624. if (alias != NULL) {
  7625. AliasInfo *alias_info;
  7626. if (strdb_exists(atcommand_alias_db, alias)) {
  7627. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  7628. continue;
  7629. }
  7630. CREATE(alias_info, AliasInfo, 1);
  7631. alias_info->command = commandinfo;
  7632. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  7633. strdb_put(atcommand_alias_db, alias, alias_info);
  7634. ++num_aliases;
  7635. }
  7636. }
  7637. }
  7638. }
  7639. // Commands help
  7640. // We only check if all commands exist
  7641. help = config_lookup(&atcommand_config, "help");
  7642. if (help != NULL) {
  7643. int count = config_setting_length(help);
  7644. int i;
  7645. for (i = 0; i < count; ++i) {
  7646. config_setting_t *command = NULL;
  7647. const char *commandname = NULL;
  7648. command = config_setting_get_elem(help, i);
  7649. commandname = config_setting_name(command);
  7650. if (!atcommand_exists(commandname))
  7651. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  7652. }
  7653. }
  7654. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  7655. return;
  7656. }
  7657. static int atcommand_db_free(DBKey key, void *data, va_list va)
  7658. {
  7659. aFree((AtCommandInfo*)data);
  7660. return 1;
  7661. }
  7662. static int atcommand_alias_db_free(DBKey key, void *data, va_list va)
  7663. {
  7664. aFree((AliasInfo*)data);
  7665. return 1;
  7666. }
  7667. void atcommand_db_clear(void)
  7668. {
  7669. if (atcommand_db != NULL)
  7670. atcommand_db->destroy(atcommand_db, atcommand_db_free);
  7671. if (atcommand_alias_db != NULL)
  7672. atcommand_alias_db->destroy(atcommand_alias_db, atcommand_alias_db_free);
  7673. }
  7674. void atcommand_doload(void)
  7675. {
  7676. atcommand_db_clear();
  7677. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY, ATCOMMAND_LENGTH);
  7678. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY, ATCOMMAND_LENGTH);
  7679. atcommand_basecommands(); //fills initial atcommand_db with known commands
  7680. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  7681. }
  7682. void do_init_atcommand(void)
  7683. {
  7684. atcommand_doload();
  7685. }
  7686. void do_final_atcommand(void)
  7687. {
  7688. atcommand_db_clear();
  7689. }