atcommand.c 269 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "atcommand.h"
  14. #include "battle.h"
  15. #include "clif.h"
  16. #include "chrif.h"
  17. #include "intif.h"
  18. #include "itemdb.h"
  19. #include "log.h"
  20. #include "map.h"
  21. #include "pc.h"
  22. #include "status.h"
  23. #include "skill.h"
  24. #include "mob.h"
  25. #include "npc.h"
  26. #include "pet.h"
  27. #include "mercenary.h"
  28. #include "party.h"
  29. #include "guild.h"
  30. #include "script.h"
  31. #include "trade.h"
  32. #include "unit.h"
  33. #ifndef TXT_ONLY
  34. #include "mail.h"
  35. #endif
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include <string.h>
  39. #include <math.h>
  40. // extern variables
  41. char atcommand_symbol = '@'; // first char of the commands
  42. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  43. // local declarations
  44. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  45. typedef struct AtCommandInfo
  46. {
  47. const char* command;
  48. int level;
  49. AtCommandFunc func;
  50. } AtCommandInfo;
  51. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  52. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  53. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message);
  54. /*=========================================
  55. * Generic variables
  56. *-----------------------------------------*/
  57. char atcmd_output[200];
  58. char atcmd_player_name[NAME_LENGTH];
  59. char atcmd_temp[100];
  60. // compare function for sorting high to lowest
  61. int hightolow_compare (const void * a, const void * b)
  62. {
  63. return ( *(int*)b - *(int*)a );
  64. }
  65. // compare function for sorting lowest to highest
  66. int lowtohigh_compare (const void * a, const void * b)
  67. {
  68. return ( *(int*)a - *(int*)b );
  69. }
  70. //-----------------------------------------------------------
  71. // Return the message string of the specified number by [Yor]
  72. //-----------------------------------------------------------
  73. char* msg_txt(int msg_number)
  74. {
  75. if (msg_number >= 0 && msg_number < MAX_MSG &&
  76. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  77. return msg_table[msg_number];
  78. return "??";
  79. }
  80. //-----------------------------------------------------------
  81. // Returns Players title (from msg_athena.conf) [Lupus]
  82. //-----------------------------------------------------------
  83. static char* player_title_txt(int level)
  84. {
  85. const char* format;
  86. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  87. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  88. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  89. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  90. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  91. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  92. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  93. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  94. : "";
  95. sprintf(atcmd_temp, format, level);
  96. return atcmd_temp;
  97. }
  98. /*==========================================
  99. * Read Message Data
  100. *------------------------------------------*/
  101. int msg_config_read(const char* cfgName)
  102. {
  103. int msg_number;
  104. char line[1024], w1[1024], w2[1024];
  105. FILE *fp;
  106. static int called = 1;
  107. if ((fp = fopen(cfgName, "r")) == NULL) {
  108. ShowError("Messages file not found: %s\n", cfgName);
  109. return 1;
  110. }
  111. if ((--called) == 0)
  112. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  113. while(fgets(line, sizeof(line), fp))
  114. {
  115. if (line[0] == '/' && line[1] == '/')
  116. continue;
  117. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  118. continue;
  119. if (strcmpi(w1, "import") == 0)
  120. msg_config_read(w2);
  121. else
  122. {
  123. msg_number = atoi(w1);
  124. if (msg_number >= 0 && msg_number < MAX_MSG)
  125. {
  126. if (msg_table[msg_number] != NULL)
  127. aFree(msg_table[msg_number]);
  128. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  129. strcpy(msg_table[msg_number],w2);
  130. }
  131. }
  132. }
  133. fclose(fp);
  134. return 0;
  135. }
  136. /*==========================================
  137. * Cleanup Message Data
  138. *------------------------------------------*/
  139. void do_final_msg(void)
  140. {
  141. int i;
  142. for (i = 0; i < MAX_MSG; i++)
  143. aFree(msg_table[i]);
  144. }
  145. /*==========================================
  146. * @send (used for testing packet sends from the client)
  147. *------------------------------------------*/
  148. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  149. {
  150. int len=0,off,end,type;
  151. long num;
  152. (void)command; // not used
  153. // read message type as hex number (without the 0x)
  154. if(!message || !*message ||
  155. !((sscanf(message, "len %x", &type)==1 && (len=1))
  156. || sscanf(message, "%x", &type)==1) )
  157. {
  158. clif_displaymessage(fd, "Usage:");
  159. clif_displaymessage(fd, " @send len <packet hex number>");
  160. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  161. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  162. return -1;
  163. }
  164. #define PARSE_ERROR(error,p) \
  165. {\
  166. clif_displaymessage(fd, (error));\
  167. sprintf(atcmd_output, ">%s", (p));\
  168. clif_displaymessage(fd, atcmd_output);\
  169. }
  170. //define PARSE_ERROR
  171. #define CHECK_EOS(p) \
  172. if(*(p) == 0){\
  173. clif_displaymessage(fd, "Unexpected end of string");\
  174. return -1;\
  175. }
  176. //define CHECK_EOS
  177. #define SKIP_VALUE(p) \
  178. {\
  179. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  180. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  181. }
  182. //define SKIP_VALUE
  183. #define GET_VALUE(p,num) \
  184. {\
  185. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  186. PARSE_ERROR("Invalid number in:",(p));\
  187. return -1;\
  188. }\
  189. }
  190. //define GET_VALUE
  191. if (type > 0 && type < MAX_PACKET_DB) {
  192. if(len)
  193. {// show packet length
  194. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  195. clif_displaymessage(fd, atcmd_output);
  196. return 0;
  197. }
  198. len=packet_db[sd->packet_ver][type].len;
  199. off=2;
  200. if(len == 0)
  201. {// unknown packet - ERROR
  202. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  203. clif_displaymessage(fd, atcmd_output);
  204. return -1;
  205. } else if(len == -1)
  206. {// dynamic packet
  207. len=SHRT_MAX-4; // maximum length
  208. off=4;
  209. }
  210. WFIFOHEAD(fd, len);
  211. WFIFOW(fd,0)=TOW(type);
  212. // parse packet contents
  213. SKIP_VALUE(message);
  214. while(*message != 0 && off < len){
  215. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  216. {// default (byte)
  217. GET_VALUE(message,num);
  218. WFIFOB(fd,off)=TOB(num);
  219. ++off;
  220. } else if(TOUPPER(*message) == 'B')
  221. {// byte
  222. ++message;
  223. GET_VALUE(message,num);
  224. WFIFOB(fd,off)=TOB(num);
  225. ++off;
  226. } else if(TOUPPER(*message) == 'W')
  227. {// word (2 bytes)
  228. ++message;
  229. GET_VALUE(message,num);
  230. WFIFOW(fd,off)=TOW(num);
  231. off+=2;
  232. } else if(TOUPPER(*message) == 'L')
  233. {// long word (4 bytes)
  234. ++message;
  235. GET_VALUE(message,num);
  236. WFIFOL(fd,off)=TOL(num);
  237. off+=4;
  238. } else if(TOUPPER(*message) == 'S')
  239. {// string - escapes are valid
  240. // get string length - num <= 0 means not fixed length (default)
  241. ++message;
  242. if(*message == '"'){
  243. num=0;
  244. } else {
  245. GET_VALUE(message,num);
  246. while(*message != '"')
  247. {// find start of string
  248. if(*message == 0 || ISSPACE(*message)){
  249. PARSE_ERROR("Not a string:",message);
  250. return -1;
  251. }
  252. ++message;
  253. }
  254. }
  255. // parse string
  256. ++message;
  257. CHECK_EOS(message);
  258. end=(num<=0? 0: min(off+((int)num),len));
  259. for(; *message != '"' && (off < end || end == 0); ++off){
  260. if(*message == '\\'){
  261. ++message;
  262. CHECK_EOS(message);
  263. switch(*message){
  264. case 'a': num=0x07; break; // Bell
  265. case 'b': num=0x08; break; // Backspace
  266. case 't': num=0x09; break; // Horizontal tab
  267. case 'n': num=0x0A; break; // Line feed
  268. case 'v': num=0x0B; break; // Vertical tab
  269. case 'f': num=0x0C; break; // Form feed
  270. case 'r': num=0x0D; break; // Carriage return
  271. case 'e': num=0x1B; break; // Escape
  272. default: num=*message; break;
  273. case 'x': // Hexadecimal
  274. {
  275. ++message;
  276. CHECK_EOS(message);
  277. if(!ISXDIGIT(*message)){
  278. PARSE_ERROR("Not a hexadecimal digit:",message);
  279. return -1;
  280. }
  281. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  282. if(ISXDIGIT(*message)){
  283. ++message;
  284. CHECK_EOS(message);
  285. num<<=8;
  286. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  287. }
  288. WFIFOB(fd,off)=TOB(num);
  289. ++message;
  290. CHECK_EOS(message);
  291. continue;
  292. }
  293. case '0':
  294. case '1':
  295. case '2':
  296. case '3':
  297. case '4':
  298. case '5':
  299. case '6':
  300. case '7': // Octal
  301. {
  302. num=*message-'0'; // 1st octal digit
  303. ++message;
  304. CHECK_EOS(message);
  305. if(ISDIGIT(*message) && *message < '8'){
  306. num<<=3;
  307. num+=*message-'0'; // 2nd octal digit
  308. ++message;
  309. CHECK_EOS(message);
  310. if(ISDIGIT(*message) && *message < '8'){
  311. num<<=3;
  312. num+=*message-'0'; // 3rd octal digit
  313. ++message;
  314. CHECK_EOS(message);
  315. }
  316. }
  317. WFIFOB(fd,off)=TOB(num);
  318. continue;
  319. }
  320. }
  321. } else
  322. num=*message;
  323. WFIFOB(fd,off)=TOB(num);
  324. ++message;
  325. CHECK_EOS(message);
  326. }//for
  327. while(*message != '"')
  328. {// ignore extra characters
  329. ++message;
  330. CHECK_EOS(message);
  331. }
  332. // terminate the string
  333. if(off < end)
  334. {// fill the rest with 0's
  335. memset(WFIFOP(fd,off),0,end-off);
  336. off=end;
  337. }
  338. } else
  339. {// unknown
  340. PARSE_ERROR("Unknown type of value in:",message);
  341. return -1;
  342. }
  343. SKIP_VALUE(message);
  344. }
  345. if(packet_db[sd->packet_ver][type].len == -1)
  346. {// send dynamic packet
  347. WFIFOW(fd,2)=TOW(off);
  348. WFIFOSET(fd,off);
  349. } else
  350. {// send static packet
  351. if(off < len)
  352. memset(WFIFOP(fd,off),0,len-off);
  353. WFIFOSET(fd,len);
  354. }
  355. } else {
  356. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  357. return -1;
  358. }
  359. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  360. clif_displaymessage(fd, atcmd_output);
  361. return 0;
  362. #undef PARSE_ERROR
  363. #undef CHECK_EOS
  364. #undef SKIP_VALUE
  365. #undef GET_VALUE
  366. }
  367. /*==========================================
  368. * @rura, @warp, @mapmove
  369. *------------------------------------------*/
  370. int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  371. {
  372. char map_name[MAP_NAME_LENGTH_EXT];
  373. unsigned short mapindex;
  374. int x = 0, y = 0;
  375. int m = -1;
  376. nullpo_retr(-1, sd);
  377. memset(map_name, '\0', sizeof(map_name));
  378. if (!message || !*message ||
  379. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  380. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  381. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  382. return -1;
  383. }
  384. mapindex = mapindex_name2id(map_name);
  385. if (mapindex)
  386. m = map_mapindex2mapid(mapindex);
  387. if (!mapindex || m < 0) {
  388. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  389. return -1;
  390. }
  391. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  392. { //This is to prevent the pc_setpos call from printing an error.
  393. clif_displaymessage(fd, msg_txt(2));
  394. x = y = 0; //Invalid cell, use random spot.
  395. }
  396. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  397. clif_displaymessage(fd, msg_txt(247));
  398. return -1;
  399. }
  400. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  401. clif_displaymessage(fd, msg_txt(248));
  402. return -1;
  403. }
  404. if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
  405. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  406. return -1;
  407. }
  408. clif_displaymessage(fd, msg_txt(0)); // Warped.
  409. return 0;
  410. }
  411. /*==========================================
  412. * Displays where a character is. Corrected version by Silent. [Skotlex]
  413. *------------------------------------------*/
  414. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  415. {
  416. struct map_session_data* pl_sd;
  417. nullpo_retr(-1, sd);
  418. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  419. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  420. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  421. return -1;
  422. }
  423. pl_sd = map_nick2sd(atcmd_player_name);
  424. if( pl_sd == NULL
  425. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  426. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  427. ) {
  428. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  429. return -1;
  430. }
  431. 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);
  432. clif_displaymessage(fd, atcmd_output);
  433. return 0;
  434. }
  435. /*==========================================
  436. *
  437. *------------------------------------------*/
  438. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  439. {
  440. struct map_session_data *pl_sd = NULL;
  441. nullpo_retr(-1, sd);
  442. if (!message || !*message) {
  443. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  444. return -1;
  445. }
  446. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  447. {
  448. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  449. return -1;
  450. }
  451. if (pl_sd == sd)
  452. {
  453. clif_displaymessage(fd, "But you are already where you are...");
  454. return -1;
  455. }
  456. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  457. {
  458. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  459. return -1;
  460. }
  461. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  462. {
  463. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  464. return -1;
  465. }
  466. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  467. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  468. clif_displaymessage(fd, atcmd_output);
  469. return 0;
  470. }
  471. /*==========================================
  472. *
  473. *------------------------------------------*/
  474. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  475. {
  476. int x = 0, y = 0;
  477. nullpo_retr(-1, sd);
  478. memset(atcmd_output, '\0', sizeof(atcmd_output));
  479. sscanf(message, "%d %d", &x, &y);
  480. if (x <= 0) //If coordinates are 'wrong', random jump.
  481. x = -1;
  482. if (y <= 0)
  483. y = -1;
  484. if (sd->bl.m >= 0 && map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  485. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  486. return -1;
  487. }
  488. pc_setpos(sd, sd->mapindex, x, y, 3);
  489. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  490. clif_displaymessage(fd, atcmd_output);
  491. return 0;
  492. }
  493. /*==========================================
  494. * @who3 = Player name, his location
  495. *------------------------------------------*/
  496. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  497. {
  498. char temp0[100];
  499. struct map_session_data *pl_sd;
  500. struct s_mapiterator* iter;
  501. int j, count;
  502. int pl_GM_level, GM_level;
  503. char match_text[100];
  504. char player_name[NAME_LENGTH];
  505. nullpo_retr(-1, sd);
  506. memset(atcmd_output, '\0', sizeof(atcmd_output));
  507. memset(match_text, '\0', sizeof(match_text));
  508. memset(player_name, '\0', sizeof(player_name));
  509. if (sscanf(message, "%99[^\n]", match_text) < 1)
  510. strcpy(match_text, "");
  511. for (j = 0; match_text[j]; j++)
  512. match_text[j] = TOLOWER(match_text[j]);
  513. count = 0;
  514. GM_level = pc_isGM(sd);
  515. iter = mapit_getallusers();
  516. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  517. {
  518. pl_GM_level = pc_isGM(pl_sd);
  519. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  520. {// you can look only lower or same level
  521. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  522. for (j = 0; player_name[j]; j++)
  523. player_name[j] = TOLOWER(player_name[j]);
  524. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  525. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  526. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  527. } else {
  528. atcmd_output[0]=0;
  529. }
  530. //Player name
  531. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  532. strcat(atcmd_output,temp0);
  533. //Player title, if exists
  534. if (pl_GM_level > 0) {
  535. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  536. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  537. strcat(atcmd_output,temp0);
  538. }
  539. //Players Location: map x y
  540. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  541. strcat(atcmd_output,temp0);
  542. clif_displaymessage(fd, atcmd_output);
  543. count++;
  544. }
  545. }
  546. }
  547. mapit_free(iter);
  548. if (count == 0)
  549. clif_displaymessage(fd, msg_txt(28)); // No player found.
  550. else if (count == 1)
  551. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  552. else {
  553. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  554. clif_displaymessage(fd, atcmd_output);
  555. }
  556. return 0;
  557. }
  558. /*==========================================
  559. * Player name, BLevel, Job,
  560. *------------------------------------------*/
  561. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  562. {
  563. char temp0[100];
  564. struct map_session_data *pl_sd;
  565. struct s_mapiterator* iter;
  566. int j, count;
  567. int pl_GM_level, GM_level;
  568. char match_text[100];
  569. char player_name[NAME_LENGTH];
  570. nullpo_retr(-1, sd);
  571. memset(atcmd_output, '\0', sizeof(atcmd_output));
  572. memset(match_text, '\0', sizeof(match_text));
  573. memset(player_name, '\0', sizeof(player_name));
  574. if (sscanf(message, "%99[^\n]", match_text) < 1)
  575. strcpy(match_text, "");
  576. for (j = 0; match_text[j]; j++)
  577. match_text[j] = TOLOWER(match_text[j]);
  578. count = 0;
  579. GM_level = pc_isGM(sd);
  580. iter = mapit_getallusers();
  581. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  582. {
  583. pl_GM_level = pc_isGM(pl_sd);
  584. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  585. {// you can look only lower or same level
  586. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  587. for (j = 0; player_name[j]; j++)
  588. player_name[j] = TOLOWER(player_name[j]);
  589. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  590. //Players Name
  591. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  592. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  593. //Player title, if exists
  594. if (pl_GM_level > 0) {
  595. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  596. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  597. strcat(atcmd_output,temp0);
  598. }
  599. //Players Base Level / Job name
  600. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  601. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  602. strcat(atcmd_output,temp0);
  603. clif_displaymessage(fd, atcmd_output);
  604. count++;
  605. }
  606. }
  607. }
  608. mapit_free(iter);
  609. if (count == 0)
  610. clif_displaymessage(fd, msg_txt(28)); // No player found.
  611. else if (count == 1)
  612. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  613. else {
  614. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  615. clif_displaymessage(fd, atcmd_output);
  616. }
  617. return 0;
  618. }
  619. /*==========================================
  620. * Player name, Playrs Party / Guild name
  621. *------------------------------------------*/
  622. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  623. {
  624. char temp0[100];
  625. struct map_session_data *pl_sd;
  626. struct s_mapiterator* iter;
  627. int j, count;
  628. int pl_GM_level, GM_level;
  629. char match_text[100];
  630. char player_name[NAME_LENGTH];
  631. struct guild *g;
  632. struct party_data *p;
  633. nullpo_retr(-1, sd);
  634. memset(temp0, '\0', sizeof(temp0));
  635. memset(atcmd_output, '\0', sizeof(atcmd_output));
  636. memset(match_text, '\0', sizeof(match_text));
  637. memset(player_name, '\0', sizeof(player_name));
  638. if (sscanf(message, "%99[^\n]", match_text) < 1)
  639. strcpy(match_text, "");
  640. for (j = 0; match_text[j]; j++)
  641. match_text[j] = TOLOWER(match_text[j]);
  642. count = 0;
  643. GM_level = pc_isGM(sd);
  644. iter = mapit_getallusers();
  645. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  646. {
  647. pl_GM_level = pc_isGM(pl_sd);
  648. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  649. {// you can look only lower or same level
  650. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  651. for (j = 0; player_name[j]; j++)
  652. player_name[j] = TOLOWER(player_name[j]);
  653. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  654. g = guild_search(pl_sd->status.guild_id);
  655. p = party_search(pl_sd->status.party_id);
  656. //Players Name
  657. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  658. //Player title, if exists
  659. if (pl_GM_level > 0) {
  660. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  661. strcat(atcmd_output,temp0);
  662. }
  663. //Players Party if exists
  664. if (p != NULL) {
  665. //sprintf(temp0," | Party: '%s'", p->name);
  666. sprintf(temp0, msg_txt(335), p->party.name);
  667. strcat(atcmd_output,temp0);
  668. }
  669. //Players Guild if exists
  670. if (g != NULL) {
  671. //sprintf(temp0," | Guild: '%s'", g->name);
  672. sprintf(temp0, msg_txt(336), g->name);
  673. strcat(atcmd_output,temp0);
  674. }
  675. clif_displaymessage(fd, atcmd_output);
  676. count++;
  677. }
  678. }
  679. }
  680. mapit_free(iter);
  681. if (count == 0)
  682. clif_displaymessage(fd, msg_txt(28)); // No player found.
  683. else if (count == 1)
  684. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  685. else {
  686. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  687. clif_displaymessage(fd, atcmd_output);
  688. }
  689. return 0;
  690. }
  691. /*==========================================
  692. *
  693. *------------------------------------------*/
  694. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  695. {
  696. struct map_session_data *pl_sd;
  697. struct s_mapiterator* iter;
  698. int count;
  699. int pl_GM_level, GM_level;
  700. int map_id;
  701. char map_name[MAP_NAME_LENGTH_EXT];
  702. memset(atcmd_output, '\0', sizeof(atcmd_output));
  703. memset(map_name, '\0', sizeof(map_name));
  704. if (!message || !*message)
  705. map_id = sd->bl.m;
  706. else {
  707. sscanf(message, "%15s", map_name);
  708. if ((map_id = map_mapname2mapid(map_name)) < 0)
  709. map_id = sd->bl.m;
  710. }
  711. count = 0;
  712. GM_level = pc_isGM(sd);
  713. iter = mapit_getallusers();
  714. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  715. {
  716. pl_GM_level = pc_isGM(pl_sd);
  717. if( pl_sd->bl.m != map_id )
  718. continue;
  719. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  720. continue;
  721. if (pl_GM_level > 0)
  722. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  723. else
  724. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  725. clif_displaymessage(fd, atcmd_output);
  726. count++;
  727. }
  728. mapit_free(iter);
  729. if (count == 0)
  730. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  731. else if (count == 1)
  732. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  733. else {
  734. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  735. }
  736. clif_displaymessage(fd, atcmd_output);
  737. return 0;
  738. }
  739. /*==========================================
  740. *
  741. *------------------------------------------*/
  742. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  743. {
  744. struct map_session_data *pl_sd;
  745. struct s_mapiterator* iter;
  746. int count;
  747. int pl_GM_level, GM_level;
  748. int map_id = 0;
  749. char map_name[MAP_NAME_LENGTH_EXT];
  750. nullpo_retr(-1, sd);
  751. memset(atcmd_output, '\0', sizeof(atcmd_output));
  752. memset(map_name, '\0', sizeof(map_name));
  753. if (!message || !*message)
  754. map_id = sd->bl.m;
  755. else {
  756. sscanf(message, "%15s", map_name);
  757. if ((map_id = map_mapname2mapid(map_name)) < 0)
  758. map_id = sd->bl.m;
  759. }
  760. count = 0;
  761. GM_level = pc_isGM(sd);
  762. iter = mapit_getallusers();
  763. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  764. {
  765. pl_GM_level = pc_isGM(pl_sd);
  766. if( pl_sd->bl.m != map_id )
  767. continue;
  768. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  769. continue;
  770. if (pl_GM_level > 0)
  771. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  772. else
  773. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  774. clif_displaymessage(fd, atcmd_output);
  775. count++;
  776. }
  777. mapit_free(iter);
  778. if (count == 0)
  779. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  780. else if (count == 1)
  781. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  782. else {
  783. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  784. }
  785. clif_displaymessage(fd, atcmd_output);
  786. return 0;
  787. }
  788. /*==========================================
  789. *
  790. *------------------------------------------*/
  791. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  792. {
  793. char temp0[100];
  794. char temp1[100];
  795. struct map_session_data *pl_sd;
  796. struct s_mapiterator* iter;
  797. int count;
  798. int pl_GM_level, GM_level;
  799. int map_id = 0;
  800. char map_name[MAP_NAME_LENGTH_EXT];
  801. struct guild *g;
  802. struct party_data *p;
  803. nullpo_retr(-1, sd);
  804. memset(temp0, '\0', sizeof(temp0));
  805. memset(temp1, '\0', sizeof(temp1));
  806. memset(atcmd_output, '\0', sizeof(atcmd_output));
  807. memset(map_name, '\0', sizeof(map_name));
  808. if (!message || !*message)
  809. map_id = sd->bl.m;
  810. else {
  811. sscanf(message, "%15s", map_name);
  812. if ((map_id = map_mapname2mapid(map_name)) < 0)
  813. map_id = sd->bl.m;
  814. }
  815. count = 0;
  816. GM_level = pc_isGM(sd);
  817. iter = mapit_getallusers();
  818. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  819. {
  820. pl_GM_level = pc_isGM(pl_sd);
  821. if( pl_sd->bl.m != map_id )
  822. continue;
  823. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  824. continue;
  825. g = guild_search(pl_sd->status.guild_id);
  826. if (g == NULL)
  827. sprintf(temp1, "None");
  828. else
  829. sprintf(temp1, "%s", g->name);
  830. p = party_search(pl_sd->status.party_id);
  831. if (p == NULL)
  832. sprintf(temp0, "None");
  833. else
  834. sprintf(temp0, "%s", p->party.name);
  835. if (pl_GM_level > 0)
  836. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  837. else
  838. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  839. clif_displaymessage(fd, atcmd_output);
  840. count++;
  841. }
  842. mapit_free(iter);
  843. if (count == 0)
  844. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  845. else if (count == 1)
  846. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  847. else {
  848. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  849. }
  850. clif_displaymessage(fd, atcmd_output);
  851. return 0;
  852. }
  853. /*==========================================
  854. *
  855. *------------------------------------------*/
  856. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  857. {
  858. struct map_session_data* pl_sd;
  859. struct s_mapiterator* iter;
  860. int j, count;
  861. int pl_GM_level, GM_level;
  862. char match_text[200];
  863. char player_name[NAME_LENGTH];
  864. struct guild *g;
  865. struct party_data *p;
  866. nullpo_retr(-1, sd);
  867. memset(atcmd_output, '\0', sizeof(atcmd_output));
  868. memset(match_text, '\0', sizeof(match_text));
  869. memset(player_name, '\0', sizeof(player_name));
  870. if (sscanf(message, "%199[^\n]", match_text) < 1)
  871. strcpy(match_text, "");
  872. for (j = 0; match_text[j]; j++)
  873. match_text[j] = TOLOWER(match_text[j]);
  874. count = 0;
  875. GM_level = pc_isGM(sd);
  876. iter = mapit_getallusers();
  877. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  878. {
  879. pl_GM_level = pc_isGM(pl_sd);
  880. if (!pl_GM_level)
  881. continue;
  882. if (match_text[0])
  883. {
  884. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  885. for (j = 0; player_name[j]; j++)
  886. player_name[j] = TOLOWER(player_name[j]);
  887. // search with no case sensitive
  888. if (strstr(player_name, match_text) == NULL)
  889. continue;
  890. }
  891. if (pl_GM_level > GM_level) {
  892. if (pl_sd->sc.option & OPTION_INVISIBLE)
  893. continue;
  894. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  895. clif_displaymessage(fd, atcmd_output);
  896. count++;
  897. continue;
  898. }
  899. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  900. pl_sd->status.name, pl_GM_level,
  901. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  902. clif_displaymessage(fd, atcmd_output);
  903. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  904. pl_sd->status.base_level,
  905. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  906. clif_displaymessage(fd, atcmd_output);
  907. p = party_search(pl_sd->status.party_id);
  908. g = guild_search(pl_sd->status.guild_id);
  909. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  910. p?p->party.name:"None", g?g->name:"None");
  911. clif_displaymessage(fd, atcmd_output);
  912. count++;
  913. }
  914. mapit_free(iter);
  915. if (count == 0)
  916. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  917. else if (count == 1)
  918. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  919. else {
  920. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  921. clif_displaymessage(fd, atcmd_output);
  922. }
  923. return 0;
  924. }
  925. /*==========================================
  926. *
  927. *------------------------------------------*/
  928. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  929. {
  930. nullpo_retr(-1, sd);
  931. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  932. if (sd->status.pet_id > 0 && sd->pd)
  933. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  934. chrif_save(sd,0);
  935. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  936. return 0;
  937. }
  938. /*==========================================
  939. *
  940. *------------------------------------------*/
  941. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  942. {
  943. int m;
  944. nullpo_retr(-1, sd);
  945. m = map_mapindex2mapid(sd->status.save_point.map);
  946. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  947. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  948. return -1;
  949. }
  950. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  951. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  952. return -1;
  953. }
  954. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  955. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  956. return 0;
  957. }
  958. /*==========================================
  959. *
  960. *------------------------------------------*/
  961. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  962. {
  963. int speed;
  964. nullpo_retr(-1, sd);
  965. memset(atcmd_output, '\0', sizeof(atcmd_output));
  966. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  967. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  968. clif_displaymessage(fd, atcmd_output);
  969. return -1;
  970. }
  971. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  972. status_calc_bl(&sd->bl, SCB_SPEED);
  973. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  974. return 0;
  975. }
  976. /*==========================================
  977. *
  978. *------------------------------------------*/
  979. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  980. {
  981. nullpo_retr(-1, sd);
  982. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  983. return -1;
  984. if (storage_storageopen(sd) == 1)
  985. { //Already open.
  986. clif_displaymessage(fd, msg_txt(250));
  987. return -1;
  988. }
  989. clif_displaymessage(fd, "Storage opened.");
  990. return 0;
  991. }
  992. /*==========================================
  993. *
  994. *------------------------------------------*/
  995. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  996. {
  997. struct storage *stor; //changes from Freya/Yor
  998. nullpo_retr(-1, sd);
  999. if (!sd->status.guild_id) {
  1000. clif_displaymessage(fd, msg_txt(252));
  1001. return -1;
  1002. }
  1003. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1004. return -1;
  1005. if (sd->state.storage_flag) {
  1006. clif_displaymessage(fd, msg_txt(251));
  1007. return -1;
  1008. }
  1009. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1010. clif_displaymessage(fd, msg_txt(251));
  1011. return -1;
  1012. }
  1013. storage_guild_storageopen(sd);
  1014. clif_displaymessage(fd, "Guild storage opened.");
  1015. return 0;
  1016. }
  1017. /*==========================================
  1018. *
  1019. *------------------------------------------*/
  1020. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1021. {
  1022. int param1 = 0, param2 = 0, param3 = 0;
  1023. nullpo_retr(-1, sd);
  1024. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1025. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1026. return -1;
  1027. }
  1028. sd->sc.opt1 = param1;
  1029. sd->sc.opt2 = param2;
  1030. pc_setoption(sd, param3);
  1031. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1032. return 0;
  1033. }
  1034. /*==========================================
  1035. *
  1036. *------------------------------------------*/
  1037. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1038. {
  1039. nullpo_retr(-1, sd);
  1040. if (sd->sc.option & OPTION_INVISIBLE) {
  1041. sd->sc.option &= ~OPTION_INVISIBLE;
  1042. if (sd->disguise)
  1043. status_set_viewdata(&sd->bl, sd->disguise);
  1044. else
  1045. status_set_viewdata(&sd->bl, sd->status.class_);
  1046. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1047. } else {
  1048. sd->sc.option |= OPTION_INVISIBLE;
  1049. sd->vd.class_ = INVISIBLE_CLASS;
  1050. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1051. }
  1052. clif_changeoption(&sd->bl);
  1053. return 0;
  1054. }
  1055. /*==========================================
  1056. * Changes a character's class
  1057. *------------------------------------------*/
  1058. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1059. {
  1060. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1061. int job = 0, upper = 0;
  1062. nullpo_retr(-1, sd);
  1063. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1064. {
  1065. int i, found = 0;
  1066. const struct { char name[16]; int id; } jobs[] = {
  1067. { "novice", 0 },
  1068. { "swordsman", 1 },
  1069. { "mage", 2 },
  1070. { "archer", 3 },
  1071. { "acolyte", 4 },
  1072. { "merchant", 5 },
  1073. { "thief", 6 },
  1074. { "knight", 7 },
  1075. { "priest", 8 },
  1076. { "priestess", 8 },
  1077. { "wizard", 9 },
  1078. { "blacksmith", 10 },
  1079. { "hunter", 11 },
  1080. { "assassin", 12 },
  1081. { "crusader", 14 },
  1082. { "monk", 15 },
  1083. { "sage", 16 },
  1084. { "rogue", 17 },
  1085. { "alchemist", 18 },
  1086. { "bard", 19 },
  1087. { "dancer", 20 },
  1088. { "super novice", 23 },
  1089. { "supernovice", 23 },
  1090. { "gunslinger", 24 },
  1091. { "gunner", 24 },
  1092. { "ninja", 25 },
  1093. { "high novice", 4001 },
  1094. { "swordsman high", 4002 },
  1095. { "mage high", 4003 },
  1096. { "archer high", 4004 },
  1097. { "acolyte high", 4005 },
  1098. { "merchant high", 4006 },
  1099. { "thief high", 4007 },
  1100. { "lord knight", 4008 },
  1101. { "high priest", 4009 },
  1102. { "high priestess", 4009 },
  1103. { "high wizard", 4010 },
  1104. { "whitesmith", 4011 },
  1105. { "sniper", 4012 },
  1106. { "assassin cross", 4013 },
  1107. { "paladin", 4015 },
  1108. { "champion", 4016 },
  1109. { "professor", 4017 },
  1110. { "stalker", 4018 },
  1111. { "creator", 4019 },
  1112. { "clown", 4020 },
  1113. { "gypsy", 4021 },
  1114. { "baby novice", 4023 },
  1115. { "baby swordsman", 4024 },
  1116. { "baby mage", 4025 },
  1117. { "baby archer", 4026 },
  1118. { "baby acolyte", 4027 },
  1119. { "baby merchant", 4028 },
  1120. { "baby thief", 4029 },
  1121. { "baby knight", 4030 },
  1122. { "baby priest", 4031 },
  1123. { "baby priestess", 4031 },
  1124. { "baby wizard", 4032 },
  1125. { "baby blacksmith",4033 },
  1126. { "baby hunter", 4034 },
  1127. { "baby assassin", 4035 },
  1128. { "baby crusader", 4037 },
  1129. { "baby monk", 4038 },
  1130. { "baby sage", 4039 },
  1131. { "baby rogue", 4040 },
  1132. { "baby alchemist", 4041 },
  1133. { "baby bard", 4042 },
  1134. { "baby dancer", 4043 },
  1135. { "super baby", 4045 },
  1136. { "taekwon", 4046 },
  1137. { "taekwon boy", 4046 },
  1138. { "taekwon girl", 4046 },
  1139. { "star gladiator", 4047 },
  1140. { "soul linker", 4049 },
  1141. };
  1142. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1143. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1144. job = jobs[i].id;
  1145. upper = 0;
  1146. found = 1;
  1147. break;
  1148. }
  1149. }
  1150. if (!found) {
  1151. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1152. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1153. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1154. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1155. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1156. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1157. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1158. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1159. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1160. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1161. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1162. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1163. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1164. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1165. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1166. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1167. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1168. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1169. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1170. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1171. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1172. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1173. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1174. return -1;
  1175. }
  1176. }
  1177. if (job == 37 ||job == 45)
  1178. return 0;
  1179. if (pcdb_checkid(job))
  1180. {
  1181. if (pc_jobchange(sd, job, upper) == 0)
  1182. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1183. else {
  1184. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  1185. return -1;
  1186. }
  1187. } else {
  1188. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1189. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1190. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1191. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1192. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1193. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1194. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1195. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1196. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1197. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1198. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1199. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1200. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1201. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1202. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1203. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1204. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1205. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1206. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1207. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1208. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1209. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1210. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1211. return -1;
  1212. }
  1213. return 0;
  1214. }
  1215. /*==========================================
  1216. *
  1217. *------------------------------------------*/
  1218. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1219. {
  1220. nullpo_retr(-1, sd);
  1221. clif_specialeffect(&sd->bl,450,SELF);
  1222. status_kill(&sd->bl);
  1223. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1224. return 0;
  1225. }
  1226. /*==========================================
  1227. *
  1228. *------------------------------------------*/
  1229. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1230. {
  1231. struct map_session_data *pl_sd;
  1232. nullpo_retr(-1, sd);
  1233. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1234. if (!message || !*message) {
  1235. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1236. return -1;
  1237. }
  1238. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1239. {
  1240. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1241. return -1;
  1242. }
  1243. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1244. { // you can kill only lower or same level
  1245. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1246. return -1;
  1247. }
  1248. status_kill(&pl_sd->bl);
  1249. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1250. if (fd != pl_sd->fd)
  1251. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1252. return 0;
  1253. }
  1254. /*==========================================
  1255. *
  1256. *------------------------------------------*/
  1257. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1258. {
  1259. nullpo_retr(-1, sd);
  1260. if (!status_revive(&sd->bl, 100, 100))
  1261. {
  1262. clif_displaymessage(fd, "You're not dead.");
  1263. return -1;
  1264. }
  1265. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1266. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1267. return 0;
  1268. }
  1269. /*==========================================
  1270. * +kamic [LuzZza]
  1271. *------------------------------------------*/
  1272. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1273. {
  1274. unsigned long color=0;
  1275. nullpo_retr(-1, sd);
  1276. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1277. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1278. if (!message || !*message) {
  1279. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1280. return -1;
  1281. }
  1282. sscanf(message, "%199[^\n]", atcmd_output);
  1283. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1284. } else {
  1285. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1286. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1287. return -1;
  1288. }
  1289. if(color > 0xFFFFFF) {
  1290. clif_displaymessage(fd, "Invalid color.");
  1291. return -1;
  1292. }
  1293. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  1294. }
  1295. return 0;
  1296. }
  1297. /*==========================================
  1298. *
  1299. *------------------------------------------*/
  1300. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1301. {
  1302. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1303. nullpo_retr(-1, sd);
  1304. sscanf(message, "%d %d", &hp, &sp);
  1305. if (hp == 0 && sp == 0) {
  1306. if (!status_percent_heal(&sd->bl, 100, 100))
  1307. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1308. else
  1309. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1310. return 0;
  1311. }
  1312. if(hp > 0 && sp >= 0) {
  1313. if(!status_heal(&sd->bl, hp, sp, 0))
  1314. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1315. else
  1316. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1317. return 0;
  1318. }
  1319. if(hp < 0 && sp <= 0) {
  1320. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1321. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1322. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1323. return 0;
  1324. }
  1325. //Opposing signs.
  1326. if (hp) {
  1327. if (hp > 0)
  1328. status_heal(&sd->bl, hp, 0, 0);
  1329. else {
  1330. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1331. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1332. }
  1333. }
  1334. if (sp) {
  1335. if (sp > 0)
  1336. status_heal(&sd->bl, 0, sp, 0);
  1337. else
  1338. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1339. }
  1340. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1341. return 0;
  1342. }
  1343. /*==========================================
  1344. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1345. *------------------------------------------*/
  1346. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1347. {
  1348. char item_name[100];
  1349. int number = 0, item_id, flag;
  1350. struct item item_tmp;
  1351. struct item_data *item_data;
  1352. int get_count, i;
  1353. nullpo_retr(-1, sd);
  1354. memset(item_name, '\0', sizeof(item_name));
  1355. if (!message || !*message || (
  1356. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1357. sscanf(message, "%99s %d", item_name, &number) < 1
  1358. )) {
  1359. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1360. return -1;
  1361. }
  1362. if (number <= 0)
  1363. number = 1;
  1364. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1365. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1366. {
  1367. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1368. return -1;
  1369. }
  1370. item_id = item_data->nameid;
  1371. get_count = number;
  1372. //Check if it's stackable.
  1373. if (!itemdb_isstackable2(item_data))
  1374. get_count = 1;
  1375. for (i = 0; i < number; i += get_count) {
  1376. // if not pet egg
  1377. if (!pet_create_egg(sd, item_id)) {
  1378. memset(&item_tmp, 0, sizeof(item_tmp));
  1379. item_tmp.nameid = item_id;
  1380. item_tmp.identify = 1;
  1381. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1382. clif_additem(sd, 0, 0, flag);
  1383. }
  1384. }
  1385. //Logs (A)dmins items [Lupus]
  1386. if(log_config.enable_logs&0x400)
  1387. log_pick_pc(sd, "A", item_id, number, NULL);
  1388. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1389. return 0;
  1390. }
  1391. /*==========================================
  1392. *
  1393. *------------------------------------------*/
  1394. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1395. {
  1396. struct item item_tmp;
  1397. struct item_data *item_data;
  1398. char item_name[100];
  1399. int item_id, number = 0;
  1400. int identify = 0, refine = 0, attr = 0;
  1401. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1402. int flag;
  1403. int loop, get_count, i;
  1404. nullpo_retr(-1, sd);
  1405. memset(item_name, '\0', sizeof(item_name));
  1406. if (!message || !*message || (
  1407. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1408. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1409. )) {
  1410. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1411. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1412. return -1;
  1413. }
  1414. if (number <= 0)
  1415. number = 1;
  1416. item_id = 0;
  1417. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1418. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1419. item_id = item_data->nameid;
  1420. if (item_id > 500) {
  1421. loop = 1;
  1422. get_count = number;
  1423. if (item_data->type == 4 || item_data->type == 5 ||
  1424. item_data->type == 7 || item_data->type == 8) {
  1425. loop = number;
  1426. get_count = 1;
  1427. if (item_data->type == 7) {
  1428. identify = 1;
  1429. refine = 0;
  1430. }
  1431. if (item_data->type == 8)
  1432. refine = 0;
  1433. if (refine > 10)
  1434. refine = 10;
  1435. } else {
  1436. identify = 1;
  1437. refine = attr = 0;
  1438. }
  1439. for (i = 0; i < loop; i++) {
  1440. memset(&item_tmp, 0, sizeof(item_tmp));
  1441. item_tmp.nameid = item_id;
  1442. item_tmp.identify = identify;
  1443. item_tmp.refine = refine;
  1444. item_tmp.attribute = attr;
  1445. item_tmp.card[0] = c1;
  1446. item_tmp.card[1] = c2;
  1447. item_tmp.card[2] = c3;
  1448. item_tmp.card[3] = c4;
  1449. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1450. clif_additem(sd, 0, 0, flag);
  1451. }
  1452. //Logs (A)dmins items [Lupus]
  1453. if(log_config.enable_logs&0x400)
  1454. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  1455. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1456. } else {
  1457. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1458. return -1;
  1459. }
  1460. return 0;
  1461. }
  1462. /*==========================================
  1463. *
  1464. *------------------------------------------*/
  1465. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1466. {
  1467. int i;
  1468. nullpo_retr(-1, sd);
  1469. for (i = 0; i < MAX_INVENTORY; i++) {
  1470. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1471. //Logs (A)dmins items [Lupus]
  1472. if(log_config.enable_logs&0x400)
  1473. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1474. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  1475. }
  1476. }
  1477. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1478. return 0;
  1479. }
  1480. /*==========================================
  1481. * Atcommand @lvlup
  1482. *------------------------------------------*/
  1483. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1484. {
  1485. int level=0, i=0, status_point=0;
  1486. nullpo_retr(-1, sd);
  1487. level = atoi(message);
  1488. if (!message || !*message || !level) {
  1489. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1490. return -1;
  1491. }
  1492. if (level > 0) {
  1493. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1494. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1495. return -1;
  1496. } // End Addition
  1497. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1498. level = pc_maxbaselv(sd) - sd->status.base_level;
  1499. for (i = 1; i <= level; i++)
  1500. status_point += (sd->status.base_level + i + 14) / 5;
  1501. if (sd->status.status_point > USHRT_MAX - status_point)
  1502. sd->status.status_point = USHRT_MAX;
  1503. else
  1504. sd->status.status_point += status_point;
  1505. sd->status.base_level += (unsigned int)level;
  1506. status_percent_heal(&sd->bl, 100, 100);
  1507. clif_misceffect(&sd->bl, 0);
  1508. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1509. } else {
  1510. if (sd->status.base_level == 1) {
  1511. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1512. return -1;
  1513. }
  1514. level*=-1;
  1515. if ((unsigned int)level >= sd->status.base_level)
  1516. level = sd->status.base_level-1;
  1517. for (i = 0; i > -level; i--)
  1518. status_point += (sd->status.base_level + i + 14) / 5;
  1519. if (sd->status.status_point < status_point)
  1520. pc_resetstate(sd);
  1521. if (sd->status.status_point < status_point)
  1522. sd->status.status_point = 0;
  1523. else
  1524. sd->status.status_point -= status_point;
  1525. sd->status.base_level -= (unsigned int)level;
  1526. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1527. }
  1528. clif_updatestatus(sd, SP_STATUSPOINT);
  1529. clif_updatestatus(sd, SP_BASELEVEL);
  1530. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1531. status_calc_pc(sd, 0);
  1532. if(sd->status.party_id)
  1533. party_send_levelup(sd);
  1534. return 0;
  1535. }
  1536. /*==========================================
  1537. *
  1538. *------------------------------------------*/
  1539. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1540. {
  1541. int level=0;
  1542. nullpo_retr(-1, sd);
  1543. level = atoi(message);
  1544. if (!message || !*message || !level) {
  1545. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1546. return -1;
  1547. }
  1548. if (level > 0) {
  1549. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1550. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1551. return -1;
  1552. }
  1553. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1554. level = pc_maxjoblv(sd) - sd->status.job_level;
  1555. sd->status.job_level += (unsigned int)level;
  1556. clif_updatestatus(sd, SP_JOBLEVEL);
  1557. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1558. if (sd->status.skill_point > USHRT_MAX - level)
  1559. sd->status.skill_point = USHRT_MAX;
  1560. else
  1561. sd->status.skill_point += level;
  1562. clif_updatestatus(sd, SP_SKILLPOINT);
  1563. status_calc_pc(sd, 0);
  1564. clif_misceffect(&sd->bl, 1);
  1565. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1566. } else {
  1567. if (sd->status.job_level == 1) {
  1568. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1569. return -1;
  1570. }
  1571. level *=-1;
  1572. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1573. level = sd->status.job_level-1;
  1574. sd->status.job_level -= (unsigned int)level;
  1575. clif_updatestatus(sd, SP_JOBLEVEL);
  1576. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1577. if (sd->status.skill_point < level)
  1578. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1579. if (sd->status.skill_point < level)
  1580. sd->status.skill_point = 0;
  1581. else
  1582. sd->status.skill_point -= level;
  1583. clif_updatestatus(sd, SP_SKILLPOINT);
  1584. status_calc_pc(sd, 0);
  1585. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1586. }
  1587. return 0;
  1588. }
  1589. /*==========================================
  1590. * @help
  1591. *------------------------------------------*/
  1592. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1593. {
  1594. char buf[2048], w1[2048], w2[2048];
  1595. int i, gm_level;
  1596. FILE* fp;
  1597. nullpo_retr(-1, sd);
  1598. memset(buf, '\0', sizeof(buf));
  1599. if ((fp = fopen(help_txt, "r")) != NULL) {
  1600. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1601. gm_level = pc_isGM(sd);
  1602. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1603. if (buf[0] == '/' && buf[1] == '/')
  1604. continue;
  1605. for (i = 0; buf[i] != '\0'; i++) {
  1606. if (buf[i] == '\r' || buf[i] == '\n') {
  1607. buf[i] = '\0';
  1608. break;
  1609. }
  1610. }
  1611. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1612. clif_displaymessage(fd, buf);
  1613. else if (gm_level >= atoi(w1))
  1614. clif_displaymessage(fd, w2);
  1615. }
  1616. fclose(fp);
  1617. } else {
  1618. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1619. return -1;
  1620. }
  1621. return 0;
  1622. }
  1623. /*==========================================
  1624. * @help2 - Char commands [Kayla]
  1625. *------------------------------------------*/
  1626. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1627. {
  1628. char buf[2048], w1[2048], w2[2048];
  1629. int i, gm_level;
  1630. FILE* fp;
  1631. nullpo_retr(-1, sd);
  1632. memset(buf, '\0', sizeof(buf));
  1633. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1634. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1635. gm_level = pc_isGM(sd);
  1636. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1637. if (buf[0] == '/' && buf[1] == '/')
  1638. continue;
  1639. for (i = 0; buf[i] != '\0'; i++) {
  1640. if (buf[i] == '\r' || buf[i] == '\n') {
  1641. buf[i] = '\0';
  1642. break;
  1643. }
  1644. }
  1645. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1646. clif_displaymessage(fd, buf);
  1647. else if (gm_level >= atoi(w1))
  1648. clif_displaymessage(fd, w2);
  1649. }
  1650. fclose(fp);
  1651. } else {
  1652. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1653. return -1;
  1654. }
  1655. return 0;
  1656. }
  1657. /*==========================================
  1658. * @gm
  1659. *------------------------------------------*/
  1660. int atcommand_gm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1661. {
  1662. char password[100];
  1663. nullpo_retr(-1, sd);
  1664. memset(password, '\0', sizeof(password));
  1665. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  1666. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  1667. return -1;
  1668. }
  1669. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  1670. clif_displaymessage(fd, msg_txt(50)); // You already have some GM powers.
  1671. return -1;
  1672. } else
  1673. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  1674. return 0;
  1675. }
  1676. // helper function, used in foreach calls to stop auto-attack timers
  1677. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1678. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1679. {
  1680. struct unit_data *ud = unit_bl2ud(bl);
  1681. int id = va_arg(ap, int);
  1682. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1683. {
  1684. unit_stop_attack(bl);
  1685. return 1;
  1686. }
  1687. return 0;
  1688. }
  1689. /*==========================================
  1690. *
  1691. *------------------------------------------*/
  1692. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1693. {
  1694. TBL_PC* sd = (TBL_PC*)bl;
  1695. clif_pvpset(sd, 0, 0, 2);
  1696. if (sd->pvp_timer != -1) {
  1697. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1698. sd->pvp_timer = -1;
  1699. }
  1700. return 0;
  1701. }
  1702. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1703. {
  1704. nullpo_retr(-1, sd);
  1705. if (!map[sd->bl.m].flag.pvp) {
  1706. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1707. return -1;
  1708. }
  1709. map[sd->bl.m].flag.pvp = 0;
  1710. if (!battle_config.pk_mode)
  1711. clif_send0199(sd->bl.m, 0);
  1712. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1713. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1714. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1715. return 0;
  1716. }
  1717. /*==========================================
  1718. *
  1719. *------------------------------------------*/
  1720. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1721. {
  1722. TBL_PC* sd = (TBL_PC*)bl;
  1723. if (sd->pvp_timer == -1) {
  1724. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1725. sd->pvp_rank = 0;
  1726. sd->pvp_lastusers = 0;
  1727. sd->pvp_point = 5;
  1728. sd->pvp_won = 0;
  1729. sd->pvp_lost = 0;
  1730. }
  1731. return 0;
  1732. }
  1733. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1734. {
  1735. nullpo_retr(-1, sd);
  1736. if (map[sd->bl.m].flag.pvp) {
  1737. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1738. return -1;
  1739. }
  1740. map[sd->bl.m].flag.pvp = 1;
  1741. if (!battle_config.pk_mode)
  1742. {// display pvp circle and rank
  1743. clif_send0199(sd->bl.m, 1);
  1744. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1745. }
  1746. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1747. return 0;
  1748. }
  1749. /*==========================================
  1750. *
  1751. *------------------------------------------*/
  1752. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1753. {
  1754. nullpo_retr(-1, sd);
  1755. if (!map[sd->bl.m].flag.gvg) {
  1756. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1757. return -1;
  1758. }
  1759. map[sd->bl.m].flag.gvg = 0;
  1760. clif_send0199(sd->bl.m, 0);
  1761. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1762. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1763. return 0;
  1764. }
  1765. /*==========================================
  1766. *
  1767. *------------------------------------------*/
  1768. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1769. {
  1770. nullpo_retr(-1, sd);
  1771. if (map[sd->bl.m].flag.gvg) {
  1772. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1773. return -1;
  1774. }
  1775. map[sd->bl.m].flag.gvg = 1;
  1776. clif_send0199(sd->bl.m, 3);
  1777. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1778. return 0;
  1779. }
  1780. /*==========================================
  1781. *
  1782. *------------------------------------------*/
  1783. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1784. {
  1785. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1786. nullpo_retr(-1, sd);
  1787. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1788. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1789. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1790. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1791. clif_displaymessage(fd, atcmd_output);
  1792. return -1;
  1793. }
  1794. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1795. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1796. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1797. pc_changelook(sd, LOOK_HAIR, hair_style);
  1798. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1799. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1800. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1801. } else {
  1802. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1803. return -1;
  1804. }
  1805. return 0;
  1806. }
  1807. /*==========================================
  1808. * @dye && @ccolor
  1809. *------------------------------------------*/
  1810. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1811. {
  1812. int cloth_color = 0;
  1813. nullpo_retr(-1, sd);
  1814. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1815. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1816. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1817. clif_displaymessage(fd, atcmd_output);
  1818. return -1;
  1819. }
  1820. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1821. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1822. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1823. } else {
  1824. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1825. return -1;
  1826. }
  1827. return 0;
  1828. }
  1829. /*==========================================
  1830. * @hairstyle && @hstyle
  1831. *------------------------------------------*/
  1832. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1833. {
  1834. int hair_style = 0;
  1835. nullpo_retr(-1, sd);
  1836. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1837. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1838. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1839. clif_displaymessage(fd, atcmd_output);
  1840. return -1;
  1841. }
  1842. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1843. pc_changelook(sd, LOOK_HAIR, hair_style);
  1844. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1845. } else {
  1846. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1847. return -1;
  1848. }
  1849. return 0;
  1850. }
  1851. /*==========================================
  1852. * @haircolor && @hcolor
  1853. *------------------------------------------*/
  1854. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1855. {
  1856. int hair_color = 0;
  1857. nullpo_retr(-1, sd);
  1858. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1859. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1860. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1861. clif_displaymessage(fd, atcmd_output);
  1862. return -1;
  1863. }
  1864. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1865. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1866. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1867. } else {
  1868. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1869. return -1;
  1870. }
  1871. return 0;
  1872. }
  1873. /*==========================================
  1874. * @go [city_number or city_name] - Updated by Harbin
  1875. *------------------------------------------*/
  1876. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1877. {
  1878. int i;
  1879. int town;
  1880. char map_name[MAP_NAME_LENGTH];
  1881. int m;
  1882. const struct {
  1883. char map[MAP_NAME_LENGTH];
  1884. int x, y;
  1885. } data[] = {
  1886. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1887. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1888. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1889. { MAP_PAYON, 162, 233 }, // 3=Payon
  1890. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1891. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1892. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1893. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1894. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1895. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1896. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1897. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1898. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1899. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1900. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1901. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1902. { MAP_JAIL, 23, 61 }, // 16=Prison
  1903. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1904. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1905. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1906. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1907. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1908. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1909. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1910. { MAP_VEINS, 216, 123 }, // 24=Veins
  1911. };
  1912. nullpo_retr(-1, sd);
  1913. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  1914. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1915. return 0;
  1916. }
  1917. memset(map_name, '\0', sizeof(map_name));
  1918. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1919. // get the number
  1920. town = atoi(message);
  1921. // if no value, display all value
  1922. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1923. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1924. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  1925. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1926. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1927. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1928. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1929. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1930. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1931. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1932. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  1933. clif_displaymessage(fd, " 24=Veins");
  1934. return -1;
  1935. }
  1936. // get possible name of the city
  1937. map_name[MAP_NAME_LENGTH-1] = '\0';
  1938. for (i = 0; map_name[i]; i++)
  1939. map_name[i] = TOLOWER(map_name[i]);
  1940. // try to identify the map name
  1941. if (strncmp(map_name, "prontera", 3) == 0) {
  1942. town = 0;
  1943. } else if (strncmp(map_name, "morocc", 3) == 0) {
  1944. town = 1;
  1945. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1946. town = 2;
  1947. } else if (strncmp(map_name, "payon", 3) == 0 ||
  1948. strncmp(map_name, "paion", 3) == 0) {
  1949. town = 3;
  1950. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1951. town = 4;
  1952. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  1953. strncmp(map_name, "islude", 3) == 0) {
  1954. town = 5;
  1955. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  1956. strcmp(map_name, "al") == 0) {
  1957. town = 6;
  1958. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1959. strcmp(map_name, "christmas") == 0 ||
  1960. strncmp(map_name, "xmas", 3) == 0 ||
  1961. strncmp(map_name, "x-mas", 3) == 0) {
  1962. town = 7;
  1963. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1964. town = 8;
  1965. } else if (strncmp(map_name, "yuno", 3) == 0) {
  1966. town = 9;
  1967. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1968. town = 10;
  1969. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  1970. town = 11;
  1971. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1972. town = 12;
  1973. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1974. town = 13;
  1975. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1976. town = 14;
  1977. } else if (strncmp(map_name, "new_zone01", 3) == 0 ||
  1978. strncmp(map_name, "startpoint", 3) == 0 ||
  1979. strncmp(map_name, "begining", 3) == 0) {
  1980. town = 15;
  1981. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1982. strncmp(map_name, "prison", 3) == 0 ||
  1983. strncmp(map_name, "jails", 3) == 0) {
  1984. town = 16;
  1985. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  1986. strncmp(map_name, "jawai", 3) == 0) {
  1987. town = 17;
  1988. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  1989. strncmp(map_name, "ayotaya", 3) == 0) {
  1990. town = 18;
  1991. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  1992. strncmp(map_name, "ainbroch", 5) == 0) {
  1993. town = 19;
  1994. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1995. town = 20;
  1996. } else if (strncmp(map_name, "einbech", 3) == 0) {
  1997. town = 21;
  1998. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1999. town = 22;
  2000. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2001. town = 23;
  2002. } else if (strncmp(map_name, "veins", 3) == 0) {
  2003. town = 24;
  2004. }
  2005. if (town >= 0 && town < ARRAYLENGTH(data))
  2006. {
  2007. m = map_mapname2mapid(data[town].map);
  2008. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2009. clif_displaymessage(fd, msg_txt(247));
  2010. return -1;
  2011. }
  2012. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2013. clif_displaymessage(fd, msg_txt(248));
  2014. return -1;
  2015. }
  2016. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
  2017. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2018. } else {
  2019. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2020. return -1;
  2021. }
  2022. } else { // if you arrive here, you have an error in town variable when reading of names
  2023. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2024. return -1;
  2025. }
  2026. return 0;
  2027. }
  2028. /*==========================================
  2029. *
  2030. *------------------------------------------*/
  2031. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2032. {
  2033. char name[NAME_LENGTH];
  2034. char monster[NAME_LENGTH];
  2035. int mob_id;
  2036. int number = 0;
  2037. int count;
  2038. int i, k, range;
  2039. short mx, my;
  2040. nullpo_retr(-1, sd);
  2041. memset(name, '\0', sizeof(name));
  2042. memset(monster, '\0', sizeof(monster));
  2043. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2044. if (!message || !*message) {
  2045. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2046. return -1;
  2047. }
  2048. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2049. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2050. //All data can be left as it is.
  2051. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2052. //Here, it is possible name was not given and we are using monster for it.
  2053. if (count < 3) //Blank mob's name.
  2054. name[0] = '\0';
  2055. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2056. //All data can be left as it is.
  2057. } else if (sscanf(message, "%23s", monster) > 0) {
  2058. //As before, name may be already filled.
  2059. name[0] = '\0';
  2060. } else {
  2061. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2062. return -1;
  2063. }
  2064. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2065. mob_id = mobdb_checkid(atoi(monster));
  2066. if (mob_id == 0) {
  2067. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2068. return -1;
  2069. }
  2070. if (mob_id == MOBID_EMPERIUM) {
  2071. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  2072. return -1;
  2073. }
  2074. if (number <= 0)
  2075. number = 1;
  2076. if (strlen(name) < 1)
  2077. strcpy(name, "--ja--");
  2078. // 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
  2079. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2080. number = battle_config.atc_spawn_quantity_limit;
  2081. if (battle_config.etc_log)
  2082. 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);
  2083. count = 0;
  2084. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  2085. for (i = 0; i < number; i++) {
  2086. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2087. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2088. count += (k != 0) ? 1 : 0;
  2089. }
  2090. if (count != 0)
  2091. if (number == count)
  2092. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2093. else {
  2094. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2095. clif_displaymessage(fd, atcmd_output);
  2096. }
  2097. else {
  2098. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2099. return -1;
  2100. }
  2101. return 0;
  2102. }
  2103. // small monster spawning [Valaris]
  2104. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2105. {
  2106. char name[NAME_LENGTH] = "";
  2107. char monster[NAME_LENGTH] = "";
  2108. int mob_id = 0;
  2109. int number = 0;
  2110. int x = 0;
  2111. int y = 0;
  2112. int count;
  2113. int i;
  2114. nullpo_retr(-1, sd);
  2115. if (!message || !*message) {
  2116. clif_displaymessage(fd, "Give a monster name/id please.");
  2117. return -1;
  2118. }
  2119. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2120. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2121. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2122. clif_displaymessage(fd, "Give a monster name/id please.");
  2123. return -1;
  2124. }
  2125. // If monster identifier/name argument is a name
  2126. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2127. mob_id = atoi(monster);
  2128. if (mob_id == 0) {
  2129. clif_displaymessage(fd, msg_txt(40));
  2130. return -1;
  2131. }
  2132. if (mob_id == MOBID_EMPERIUM) {
  2133. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2134. return -1;
  2135. }
  2136. if (mobdb_checkid(mob_id) == 0) {
  2137. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2138. return -1;
  2139. }
  2140. if (number <= 0)
  2141. number = 1;
  2142. if (strlen(name) < 1)
  2143. strcpy(name, "--ja--");
  2144. // 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
  2145. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2146. number = battle_config.atc_spawn_quantity_limit;
  2147. count = 0;
  2148. for (i = 0; i < number; i++) {
  2149. int mx, my;
  2150. if (x <= 0)
  2151. mx = sd->bl.x + (rand() % 11 - 5);
  2152. else
  2153. mx = x;
  2154. if (y <= 0)
  2155. my = sd->bl.y + (rand() % 11 - 5);
  2156. else
  2157. my = y;
  2158. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2159. }
  2160. if (count != 0)
  2161. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2162. else
  2163. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2164. return 0;
  2165. }
  2166. // big monster spawning [Valaris]
  2167. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2168. {
  2169. char name[NAME_LENGTH] = "";
  2170. char monster[NAME_LENGTH] = "";
  2171. int mob_id = 0;
  2172. int number = 0;
  2173. int x = 0;
  2174. int y = 0;
  2175. int count;
  2176. int i;
  2177. nullpo_retr(-1, sd);
  2178. if (!message || !*message) {
  2179. clif_displaymessage(fd, "Give a monster name/id please.");
  2180. return -1;
  2181. }
  2182. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2183. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2184. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2185. clif_displaymessage(fd, "Give a monster name/id please.");
  2186. return -1;
  2187. }
  2188. // If monster identifier/name argument is a name
  2189. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2190. mob_id = atoi(monster);
  2191. if (mob_id == 0) {
  2192. clif_displaymessage(fd, msg_txt(40));
  2193. return -1;
  2194. }
  2195. if (mob_id == MOBID_EMPERIUM) {
  2196. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2197. return -1;
  2198. }
  2199. if (mobdb_checkid(mob_id) == 0) {
  2200. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2201. return -1;
  2202. }
  2203. if (number <= 0)
  2204. number = 1;
  2205. if (strlen(name) < 1)
  2206. strcpy(name, "--ja--");
  2207. // 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
  2208. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2209. number = battle_config.atc_spawn_quantity_limit;
  2210. count = 0;
  2211. for (i = 0; i < number; i++) {
  2212. int mx, my;
  2213. if (x <= 0)
  2214. mx = sd->bl.x + (rand() % 11 - 5);
  2215. else
  2216. mx = x;
  2217. if (y <= 0)
  2218. my = sd->bl.y + (rand() % 11 - 5);
  2219. else
  2220. my = y;
  2221. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2222. }
  2223. if (count != 0)
  2224. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2225. else
  2226. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2227. return 0;
  2228. }
  2229. /*==========================================
  2230. *
  2231. *------------------------------------------*/
  2232. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2233. {
  2234. struct mob_data *md;
  2235. int flag;
  2236. nullpo_retr(0, ap);
  2237. nullpo_retr(0, md=(struct mob_data *)bl);
  2238. flag = va_arg(ap, int);
  2239. if (md->guardian_data)
  2240. return 0; //Do not touch WoE mobs!
  2241. if (flag)
  2242. status_zap(bl,md->status.hp, 0);
  2243. else
  2244. status_kill(bl);
  2245. return 1;
  2246. }
  2247. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2248. {
  2249. int map_id;
  2250. char map_name[MAP_NAME_LENGTH_EXT];
  2251. if (!sd) return;
  2252. memset(map_name, '\0', sizeof(map_name));
  2253. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2254. map_id = sd->bl.m;
  2255. else {
  2256. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2257. map_id = sd->bl.m;
  2258. }
  2259. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2260. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2261. return;
  2262. }
  2263. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2264. {
  2265. atcommand_killmonster_sub(fd, sd, message, 1);
  2266. return 0;
  2267. }
  2268. /*==========================================
  2269. *
  2270. *------------------------------------------*/
  2271. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2272. {
  2273. atcommand_killmonster_sub(fd, sd, message, 0);
  2274. return 0;
  2275. }
  2276. /*==========================================
  2277. *
  2278. *------------------------------------------*/
  2279. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2280. {
  2281. int i,j, position = 0, refine = 0, current_position, final_refine;
  2282. int count;
  2283. nullpo_retr(-1, sd);
  2284. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2285. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2286. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  2287. sprintf(atcmd_output, "%d: Left Accessory", EQI_ACC_L);
  2288. clif_displaymessage(fd, atcmd_output);
  2289. sprintf(atcmd_output, "%d: Right Accessory", EQI_ACC_R);
  2290. clif_displaymessage(fd, atcmd_output);
  2291. sprintf(atcmd_output, "%d: Shoes", EQI_SHOES);
  2292. clif_displaymessage(fd, atcmd_output);
  2293. sprintf(atcmd_output, "%d: Garment", EQI_GARMENT);
  2294. clif_displaymessage(fd, atcmd_output);
  2295. sprintf(atcmd_output, "%d: Lower Headgear", EQI_HEAD_LOW);
  2296. clif_displaymessage(fd, atcmd_output);
  2297. sprintf(atcmd_output, "%d: Mid Headgear", EQI_HEAD_MID);
  2298. clif_displaymessage(fd, atcmd_output);
  2299. sprintf(atcmd_output, "%d: Top Headgear", EQI_HEAD_TOP);
  2300. clif_displaymessage(fd, atcmd_output);
  2301. sprintf(atcmd_output, "%d: Body Armor", EQI_ARMOR);
  2302. clif_displaymessage(fd, atcmd_output);
  2303. sprintf(atcmd_output, "%d: Left Hand", EQI_HAND_L);
  2304. clif_displaymessage(fd, atcmd_output);
  2305. sprintf(atcmd_output, "%d: Right Hand", EQI_HAND_R);
  2306. clif_displaymessage(fd, atcmd_output);
  2307. return -1;
  2308. }
  2309. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2310. count = 0;
  2311. for (j = 0; j < EQI_MAX-1; j++) {
  2312. if ((i = sd->equip_index[j]) < 0)
  2313. continue;
  2314. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2315. continue;
  2316. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2317. continue;
  2318. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2319. continue;
  2320. if(position && !(sd->status.inventory[i].equip & position))
  2321. continue;
  2322. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2323. if (sd->status.inventory[i].refine != final_refine) {
  2324. sd->status.inventory[i].refine = final_refine;
  2325. current_position = sd->status.inventory[i].equip;
  2326. pc_unequipitem(sd, i, 3);
  2327. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2328. clif_delitem(sd, i, 1);
  2329. clif_additem(sd, i, 1, 0);
  2330. pc_equipitem(sd, i, current_position);
  2331. clif_misceffect(&sd->bl, 3);
  2332. count++;
  2333. }
  2334. }
  2335. if (count == 0)
  2336. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  2337. else if (count == 1)
  2338. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  2339. else {
  2340. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  2341. clif_displaymessage(fd, atcmd_output);
  2342. }
  2343. return 0;
  2344. }
  2345. /*==========================================
  2346. *
  2347. *------------------------------------------*/
  2348. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2349. {
  2350. char item_name[100];
  2351. int item_id, attribute = 0, star = 0;
  2352. int flag = 0;
  2353. struct item_data *item_data;
  2354. struct item tmp_item;
  2355. nullpo_retr(-1, sd);
  2356. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2357. memset(item_name, '\0', sizeof(item_name));
  2358. if (!message || !*message || (
  2359. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2360. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2361. )) {
  2362. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2363. return -1;
  2364. }
  2365. item_id = 0;
  2366. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2367. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2368. {
  2369. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  2370. clif_displaymessage(fd, atcmd_output);
  2371. return -1;
  2372. }
  2373. item_id = item_data->nameid;
  2374. if (itemdb_isequip2(item_data)) {
  2375. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2376. attribute = ATTRIBUTE_NORMAL;
  2377. if (star < MIN_STAR || star > MAX_STAR)
  2378. star = 0;
  2379. memset(&tmp_item, 0, sizeof tmp_item);
  2380. tmp_item.nameid = item_id;
  2381. tmp_item.amount = 1;
  2382. tmp_item.identify = 1;
  2383. tmp_item.card[0] = CARD0_FORGE;
  2384. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2385. ((star*5) << 8) + attribute:0;
  2386. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2387. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2388. clif_produceeffect(sd, 0, item_id);
  2389. clif_misceffect(&sd->bl, 3);
  2390. //Logs (A)dmins items [Lupus]
  2391. if(log_config.enable_logs&0x400)
  2392. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  2393. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2394. clif_additem(sd, 0, 0, flag);
  2395. } else {
  2396. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  2397. clif_displaymessage(fd, atcmd_output);
  2398. return -1;
  2399. }
  2400. return 0;
  2401. }
  2402. /*==========================================
  2403. *
  2404. *------------------------------------------*/
  2405. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2406. {
  2407. int position = 0;
  2408. nullpo_retr(-1, sd);
  2409. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2410. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2411. {
  2412. int i;
  2413. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2414. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2415. {
  2416. if( sd->status.memo_point[i].map )
  2417. 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);
  2418. else
  2419. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2420. clif_displaymessage(sd->fd, atcmd_output);
  2421. }
  2422. return 0;
  2423. }
  2424. if( position < 0 && position >= MAX_MEMOPOINTS )
  2425. {
  2426. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2427. clif_displaymessage(fd, atcmd_output);
  2428. return -1;
  2429. }
  2430. pc_memo(sd, position);
  2431. return 0;
  2432. }
  2433. /*==========================================
  2434. *
  2435. *------------------------------------------*/
  2436. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2437. {
  2438. int y;
  2439. nullpo_retr(-1, sd);
  2440. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2441. for (y = 2; y >= -2; y--) {
  2442. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2443. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2444. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2445. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2446. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2447. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2448. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2449. clif_displaymessage(fd, atcmd_output);
  2450. }
  2451. return 0;
  2452. }
  2453. /*==========================================
  2454. *
  2455. *------------------------------------------*/
  2456. int atcommand_displaystatus(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2457. {
  2458. int i, type, flag;
  2459. nullpo_retr(-1, sd);
  2460. if (!message || !*message || (i = sscanf(message, "%d %d", &type, &flag)) < 1) {
  2461. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag>).");
  2462. return -1;
  2463. }
  2464. if (i == 1) flag = 1;
  2465. clif_status_change(&sd->bl, type, flag);
  2466. return 0;
  2467. }
  2468. /*==========================================
  2469. * @stpoint (Rewritten by [Yor])
  2470. *------------------------------------------*/
  2471. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2472. {
  2473. int point, new_status_point;
  2474. if (!message || !*message || (point = atoi(message)) == 0) {
  2475. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2476. return -1;
  2477. }
  2478. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  2479. new_status_point = USHRT_MAX;
  2480. else
  2481. if (point < 0 && sd->status.status_point < -point)
  2482. new_status_point = 0;
  2483. else
  2484. new_status_point = sd->status.status_point + point;
  2485. if (new_status_point != (int)sd->status.status_point) {
  2486. sd->status.status_point = (unsigned short)new_status_point;
  2487. clif_updatestatus(sd, SP_STATUSPOINT);
  2488. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  2489. } else {
  2490. if (point < 0)
  2491. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2492. else
  2493. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2494. return -1;
  2495. }
  2496. return 0;
  2497. }
  2498. /*==========================================
  2499. * @skpoint (Rewritten by [Yor])
  2500. *------------------------------------------*/
  2501. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2502. {
  2503. int point, new_skill_point;
  2504. nullpo_retr(-1, sd);
  2505. if (!message || !*message || (point = atoi(message)) == 0) {
  2506. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2507. return -1;
  2508. }
  2509. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  2510. new_skill_point = USHRT_MAX;
  2511. else if (point < 0 && sd->status.skill_point < -point)
  2512. new_skill_point = 0;
  2513. else
  2514. new_skill_point = sd->status.skill_point + point;
  2515. if (new_skill_point != (int)sd->status.skill_point) {
  2516. sd->status.skill_point = (unsigned short)new_skill_point;
  2517. clif_updatestatus(sd, SP_SKILLPOINT);
  2518. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  2519. } else {
  2520. if (point < 0)
  2521. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2522. else
  2523. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2524. return -1;
  2525. }
  2526. return 0;
  2527. }
  2528. /*==========================================
  2529. * @zeny (Rewritten by [Yor])
  2530. *------------------------------------------*/
  2531. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2532. {
  2533. int zeny, new_zeny;
  2534. nullpo_retr(-1, sd);
  2535. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2536. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2537. return -1;
  2538. }
  2539. new_zeny = sd->status.zeny + zeny;
  2540. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2541. new_zeny = MAX_ZENY;
  2542. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2543. new_zeny = 0;
  2544. if (new_zeny != sd->status.zeny) {
  2545. sd->status.zeny = new_zeny;
  2546. clif_updatestatus(sd, SP_ZENY);
  2547. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  2548. } else {
  2549. if (zeny < 0)
  2550. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2551. else
  2552. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2553. return -1;
  2554. }
  2555. return 0;
  2556. }
  2557. /*==========================================
  2558. *
  2559. *------------------------------------------*/
  2560. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2561. {
  2562. int i, value = 0, new_value, max;
  2563. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  2564. short* status[6];
  2565. //we don't use direct initialization because it isn't part of the c standard.
  2566. nullpo_retr(-1, sd);
  2567. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2568. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2569. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2570. clif_displaymessage(fd, atcmd_output);
  2571. return -1;
  2572. }
  2573. for (i = 0; param[i] != NULL; i++)
  2574. if (strcmpi(command, param[i]) == 0)
  2575. break;
  2576. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  2577. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2578. clif_displaymessage(fd, atcmd_output);
  2579. return -1;
  2580. }
  2581. status[0] = &sd->status.str;
  2582. status[1] = &sd->status.agi;
  2583. status[2] = &sd->status.vit;
  2584. status[3] = &sd->status.int_;
  2585. status[4] = &sd->status.dex;
  2586. status[5] = &sd->status.luk;
  2587. max = SHRT_MAX;
  2588. new_value = cap_value(*status[i] + value, 1, max);
  2589. if (new_value != (int)*status[i]) {
  2590. *status[i] = new_value;
  2591. clif_updatestatus(sd, SP_STR + i);
  2592. clif_updatestatus(sd, SP_USTR + i);
  2593. status_calc_pc(sd, 0);
  2594. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2595. } else {
  2596. if (value < 0)
  2597. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2598. else
  2599. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2600. return -1;
  2601. }
  2602. return 0;
  2603. }
  2604. /*==========================================
  2605. * Stat all by fritz (rewritten by [Yor])
  2606. *------------------------------------------*/
  2607. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2608. {
  2609. int index, count, value, max, new_value;
  2610. short* status[6];
  2611. //we don't use direct initialization because it isn't part of the c standard.
  2612. nullpo_retr(-1, sd);
  2613. status[0] = &sd->status.str;
  2614. status[1] = &sd->status.agi;
  2615. status[2] = &sd->status.vit;
  2616. status[3] = &sd->status.int_;
  2617. status[4] = &sd->status.dex;
  2618. status[5] = &sd->status.luk;
  2619. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2620. value = pc_maxparameter(sd);
  2621. max = pc_maxparameter(sd);
  2622. } else {
  2623. max = SHRT_MAX;
  2624. }
  2625. count = 0;
  2626. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2627. if (value > 0 && *status[index] > max - value)
  2628. new_value = max;
  2629. else if (value < 0 && *status[index] <= -value)
  2630. new_value = 1;
  2631. else
  2632. new_value = *status[index] +value;
  2633. if (new_value != (int)*status[index]) {
  2634. *status[index] = new_value;
  2635. clif_updatestatus(sd, SP_STR + index);
  2636. clif_updatestatus(sd, SP_USTR + index);
  2637. count++;
  2638. }
  2639. }
  2640. if (count > 0) { // if at least 1 stat modified
  2641. status_calc_pc(sd, 0);
  2642. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2643. } else {
  2644. if (value < 0)
  2645. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  2646. else
  2647. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  2648. return -1;
  2649. }
  2650. return 0;
  2651. }
  2652. /*==========================================
  2653. *
  2654. *------------------------------------------*/
  2655. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2656. {
  2657. int level = 0;
  2658. short added_level;
  2659. struct guild *guild_info;
  2660. nullpo_retr(-1, sd);
  2661. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2662. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2663. return -1;
  2664. }
  2665. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2666. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2667. return -1;
  2668. }
  2669. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2670. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2671. // return -1;
  2672. //}
  2673. added_level = (short)level;
  2674. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2675. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2676. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2677. added_level = 1 - guild_info->guild_lv;
  2678. if (added_level != 0) {
  2679. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  2680. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2681. } else {
  2682. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2683. return -1;
  2684. }
  2685. return 0;
  2686. }
  2687. /*==========================================
  2688. *
  2689. *------------------------------------------*/
  2690. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2691. {
  2692. struct item_data *item_data;
  2693. int id, pet_id;
  2694. nullpo_retr(-1, sd);
  2695. if (!message || !*message) {
  2696. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2697. return -1;
  2698. }
  2699. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2700. id = item_data->nameid;
  2701. else
  2702. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2703. ;
  2704. else
  2705. id = atoi(message);
  2706. pet_id = search_petDB_index(id, PET_CLASS);
  2707. if (pet_id < 0)
  2708. pet_id = search_petDB_index(id, PET_EGG);
  2709. if (pet_id >= 0) {
  2710. sd->catch_target_class = pet_db[pet_id].class_;
  2711. intif_create_pet(
  2712. sd->status.account_id, sd->status.char_id,
  2713. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2714. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2715. 100, 0, 1, pet_db[pet_id].jname);
  2716. } else {
  2717. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2718. return -1;
  2719. }
  2720. return 0;
  2721. }
  2722. /*==========================================
  2723. *
  2724. *------------------------------------------*/
  2725. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2726. {
  2727. nullpo_retr(-1, sd);
  2728. if (sd->status.pet_id <= 0)
  2729. clif_sendegg(sd);
  2730. else {
  2731. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2732. return -1;
  2733. }
  2734. return 0;
  2735. }
  2736. /*==========================================
  2737. *
  2738. *------------------------------------------*/
  2739. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2740. {
  2741. int friendly;
  2742. struct pet_data *pd;
  2743. nullpo_retr(-1, sd);
  2744. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2745. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2746. return -1;
  2747. }
  2748. pd = sd->pd;
  2749. if (!pd) {
  2750. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2751. return -1;
  2752. }
  2753. if (friendly < 0 || friendly > 1000)
  2754. {
  2755. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2756. return -1;
  2757. }
  2758. if (friendly == pd->pet.intimate) {
  2759. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  2760. return -1;
  2761. }
  2762. pd->pet.intimate = friendly;
  2763. clif_send_petstatus(sd);
  2764. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  2765. return 0;
  2766. }
  2767. /*==========================================
  2768. *
  2769. *------------------------------------------*/
  2770. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2771. {
  2772. int hungry;
  2773. struct pet_data *pd;
  2774. nullpo_retr(-1, sd);
  2775. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2776. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2777. return -1;
  2778. }
  2779. pd = sd->pd;
  2780. if (!sd->status.pet_id || !pd) {
  2781. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2782. return -1;
  2783. }
  2784. if (hungry < 0 || hungry > 100) {
  2785. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2786. return -1;
  2787. }
  2788. if (hungry == pd->pet.hungry) {
  2789. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  2790. return -1;
  2791. }
  2792. pd->pet.hungry = hungry;
  2793. clif_send_petstatus(sd);
  2794. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  2795. return 0;
  2796. }
  2797. /*==========================================
  2798. *
  2799. *------------------------------------------*/
  2800. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2801. {
  2802. struct pet_data *pd;
  2803. nullpo_retr(-1, sd);
  2804. if (!sd->status.pet_id || !sd->pd) {
  2805. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2806. return -1;
  2807. }
  2808. pd = sd->pd;
  2809. if (!pd->pet.rename_flag) {
  2810. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2811. return -1;
  2812. }
  2813. pd->pet.rename_flag = 0;
  2814. intif_save_petdata(sd->status.account_id, &pd->pet);
  2815. clif_send_petstatus(sd);
  2816. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2817. return 0;
  2818. }
  2819. /*==========================================
  2820. *
  2821. *------------------------------------------*/
  2822. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2823. {
  2824. struct map_session_data *pl_sd = NULL;
  2825. nullpo_retr(-1, sd);
  2826. if (!message || !*message) {
  2827. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2828. return -1;
  2829. }
  2830. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2831. {
  2832. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2833. return -1;
  2834. }
  2835. if (pl_sd == sd)
  2836. {
  2837. clif_displaymessage(fd, "You are already where you are...");
  2838. return -1;
  2839. }
  2840. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2841. {
  2842. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2843. return -1;
  2844. }
  2845. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2846. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  2847. return -1;
  2848. }
  2849. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2850. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2851. return -1;
  2852. }
  2853. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  2854. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2855. clif_displaymessage(fd, atcmd_output);
  2856. return 0;
  2857. }
  2858. /*==========================================
  2859. * charblock command (usage: charblock <player_name>)
  2860. * This command do a definitiv ban on a player
  2861. *------------------------------------------*/
  2862. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2863. {
  2864. nullpo_retr(-1, sd);
  2865. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2866. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2867. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2868. return -1;
  2869. }
  2870. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2871. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2872. return 0;
  2873. }
  2874. /*==========================================
  2875. * charban command (usage: charban <time> <player_name>)
  2876. * This command do a limited ban on a player
  2877. * Time is done as follows:
  2878. * Adjustment value (-1, 1, +1, etc...)
  2879. * Modified element:
  2880. * a or y: year
  2881. * m: month
  2882. * j or d: day
  2883. * h: hour
  2884. * mn: minute
  2885. * s: second
  2886. * <example> @ban +1m-2mn1s-6y test_player
  2887. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2888. *------------------------------------------*/
  2889. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2890. {
  2891. char * modif_p;
  2892. int year, month, day, hour, minute, second, value;
  2893. nullpo_retr(-1, sd);
  2894. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2895. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2896. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2897. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2898. return -1;
  2899. }
  2900. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2901. modif_p = atcmd_output;
  2902. year = month = day = hour = minute = second = 0;
  2903. while (modif_p[0] != '\0') {
  2904. value = atoi(modif_p);
  2905. if (value == 0)
  2906. modif_p++;
  2907. else {
  2908. if (modif_p[0] == '-' || modif_p[0] == '+')
  2909. modif_p++;
  2910. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2911. modif_p++;
  2912. if (modif_p[0] == 's') {
  2913. second = value;
  2914. modif_p++;
  2915. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  2916. minute = value;
  2917. modif_p = modif_p + 2;
  2918. } else if (modif_p[0] == 'h') {
  2919. hour = value;
  2920. modif_p++;
  2921. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2922. day = value;
  2923. modif_p++;
  2924. } else if (modif_p[0] == 'm') {
  2925. month = value;
  2926. modif_p++;
  2927. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2928. year = value;
  2929. modif_p++;
  2930. } else if (modif_p[0] != '\0') {
  2931. modif_p++;
  2932. }
  2933. }
  2934. }
  2935. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2936. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2937. return -1;
  2938. }
  2939. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2940. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2941. return 0;
  2942. }
  2943. /*==========================================
  2944. * charunblock command (usage: charunblock <player_name>)
  2945. *------------------------------------------*/
  2946. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2947. {
  2948. nullpo_retr(-1, sd);
  2949. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2950. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2951. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  2952. return -1;
  2953. }
  2954. // send answer to login server via char-server
  2955. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2956. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2957. return 0;
  2958. }
  2959. /*==========================================
  2960. * charunban command (usage: charunban <player_name>)
  2961. *------------------------------------------*/
  2962. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2963. {
  2964. nullpo_retr(-1, sd);
  2965. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2966. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2967. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  2968. return -1;
  2969. }
  2970. // send answer to login server via char-server
  2971. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2972. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2973. return 0;
  2974. }
  2975. /*==========================================
  2976. *
  2977. *------------------------------------------*/
  2978. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2979. {
  2980. nullpo_retr(-1, sd);
  2981. if (night_flag != 1) {
  2982. map_night_timer(night_timer_tid, 0, 0, 1);
  2983. } else {
  2984. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  2985. return -1;
  2986. }
  2987. return 0;
  2988. }
  2989. /*==========================================
  2990. *
  2991. *------------------------------------------*/
  2992. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2993. {
  2994. nullpo_retr(-1, sd);
  2995. if (night_flag != 0) {
  2996. map_day_timer(day_timer_tid, 0, 0, 1);
  2997. } else {
  2998. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  2999. return -1;
  3000. }
  3001. return 0;
  3002. }
  3003. /*==========================================
  3004. *
  3005. *------------------------------------------*/
  3006. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3007. {
  3008. struct map_session_data* pl_sd;
  3009. struct s_mapiterator* iter;
  3010. nullpo_retr(-1, sd);
  3011. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  3012. iter = mapit_getallusers();
  3013. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3014. {
  3015. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3016. {
  3017. status_kill(&pl_sd->bl);
  3018. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3019. }
  3020. }
  3021. mapit_free(iter);
  3022. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3023. return 0;
  3024. }
  3025. /*==========================================
  3026. *
  3027. *------------------------------------------*/
  3028. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3029. {
  3030. struct map_session_data* pl_sd;
  3031. struct s_mapiterator* iter;
  3032. nullpo_retr(-1, sd);
  3033. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  3034. iter = mapit_getallusers();
  3035. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3036. {
  3037. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3038. {
  3039. status_kill(&pl_sd->bl);
  3040. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3041. }
  3042. }
  3043. mapit_free(iter);
  3044. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3045. return 0;
  3046. }
  3047. /*==========================================
  3048. *
  3049. *------------------------------------------*/
  3050. static void atcommand_raise_sub(struct map_session_data* sd)
  3051. {
  3052. if (!status_isdead(&sd->bl))
  3053. return;
  3054. if(!status_revive(&sd->bl, 100, 100))
  3055. return;
  3056. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3057. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3058. }
  3059. /*==========================================
  3060. *
  3061. *------------------------------------------*/
  3062. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3063. {
  3064. struct map_session_data* pl_sd;
  3065. struct s_mapiterator* iter;
  3066. nullpo_retr(-1, sd);
  3067. iter = mapit_getallusers();
  3068. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3069. atcommand_raise_sub(pl_sd);
  3070. mapit_free(iter);
  3071. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3072. return 0;
  3073. }
  3074. /*==========================================
  3075. *
  3076. *------------------------------------------*/
  3077. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3078. {
  3079. struct map_session_data* pl_sd;
  3080. struct s_mapiterator* iter;
  3081. nullpo_retr(-1, sd);
  3082. iter = mapit_getallusers();
  3083. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3084. if (sd->bl.m == pl_sd->bl.m)
  3085. atcommand_raise_sub(pl_sd);
  3086. mapit_free(iter);
  3087. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3088. return 0;
  3089. }
  3090. /*==========================================
  3091. *
  3092. *------------------------------------------*/
  3093. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3094. {
  3095. struct map_session_data *pl_sd;
  3096. nullpo_retr(-1, sd);
  3097. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3098. if (!message || !*message) {
  3099. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3100. return -1;
  3101. }
  3102. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3103. {
  3104. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3105. return -1;
  3106. }
  3107. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3108. {
  3109. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3110. return -1;
  3111. }
  3112. clif_GM_kick(sd, pl_sd);
  3113. return 0;
  3114. }
  3115. /*==========================================
  3116. *
  3117. *------------------------------------------*/
  3118. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3119. {
  3120. struct map_session_data* pl_sd;
  3121. struct s_mapiterator* iter;
  3122. nullpo_retr(-1, sd);
  3123. iter = mapit_getallusers();
  3124. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3125. {
  3126. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3127. if (sd->status.account_id != pl_sd->status.account_id)
  3128. clif_GM_kick(NULL, pl_sd);
  3129. }
  3130. }
  3131. mapit_free(iter);
  3132. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3133. return 0;
  3134. }
  3135. /*==========================================
  3136. *
  3137. *------------------------------------------*/
  3138. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3139. {
  3140. nullpo_retr(-1, sd);
  3141. pc_allskillup(sd); // all skills
  3142. sd->status.skill_point = 0; // 0 skill points
  3143. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3144. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  3145. return 0;
  3146. }
  3147. /*==========================================
  3148. *
  3149. *------------------------------------------*/
  3150. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3151. {
  3152. int skill_id;
  3153. nullpo_retr(-1, sd);
  3154. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3155. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3156. return -1;
  3157. }
  3158. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3159. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3160. return -1;
  3161. }
  3162. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3163. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3164. return -1;
  3165. }
  3166. if (pc_checkskill(sd, skill_id) > 0) {
  3167. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3168. return -1;
  3169. }
  3170. pc_skill(sd, skill_id, 1, 0);
  3171. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3172. return 0;
  3173. }
  3174. /*==========================================
  3175. *
  3176. *------------------------------------------*/
  3177. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3178. {
  3179. int skill_id;
  3180. nullpo_retr(-1, sd);
  3181. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3182. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3183. return -1;
  3184. }
  3185. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3186. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3187. return -1;
  3188. }
  3189. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3190. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3191. return -1;
  3192. }
  3193. if (pc_checkskill(sd, skill_id) == 0) {
  3194. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3195. return -1;
  3196. }
  3197. sd->status.skill[skill_id].lv = 0;
  3198. sd->status.skill[skill_id].flag = 0;
  3199. clif_skillinfoblock(sd);
  3200. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3201. return 0;
  3202. }
  3203. /*==========================================
  3204. *
  3205. *------------------------------------------*/
  3206. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3207. {
  3208. int number;
  3209. nullpo_retr(-1, sd);
  3210. if (!message || !*message || (number = atoi(message)) < 0) {
  3211. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  3212. return -1;
  3213. }
  3214. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  3215. if (number > 500)
  3216. number = 500;
  3217. if (number >= 0 && number <= 0x7FFF) {
  3218. if (sd->spiritball != number || number > 499) {
  3219. if (sd->spiritball > 0)
  3220. pc_delspiritball(sd, sd->spiritball, 1);
  3221. sd->spiritball = number;
  3222. clif_spiritball(sd);
  3223. // no message, player can look the difference
  3224. if (number > 1000)
  3225. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  3226. } else {
  3227. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  3228. return -1;
  3229. }
  3230. } else {
  3231. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3232. return -1;
  3233. }
  3234. return 0;
  3235. }
  3236. /*==========================================
  3237. *
  3238. *------------------------------------------*/
  3239. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3240. {
  3241. char party[NAME_LENGTH];
  3242. nullpo_retr(-1, sd);
  3243. memset(party, '\0', sizeof(party));
  3244. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3245. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3246. return -1;
  3247. }
  3248. party_create(sd, party, 0, 0);
  3249. return 0;
  3250. }
  3251. /*==========================================
  3252. *
  3253. *------------------------------------------*/
  3254. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3255. {
  3256. char guild[NAME_LENGTH];
  3257. int prev;
  3258. nullpo_retr(-1, sd);
  3259. memset(guild, '\0', sizeof(guild));
  3260. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3261. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3262. return -1;
  3263. }
  3264. prev = battle_config.guild_emperium_check;
  3265. battle_config.guild_emperium_check = 0;
  3266. guild_create(sd, guild);
  3267. battle_config.guild_emperium_check = prev;
  3268. return 0;
  3269. }
  3270. /*==========================================
  3271. *
  3272. *------------------------------------------*/
  3273. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3274. {
  3275. nullpo_retr(-1, sd);
  3276. if (agit_flag == 1) {
  3277. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  3278. return -1;
  3279. }
  3280. agit_flag = 1;
  3281. guild_agit_start();
  3282. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  3283. return 0;
  3284. }
  3285. /*==========================================
  3286. *
  3287. *------------------------------------------*/
  3288. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3289. {
  3290. nullpo_retr(-1, sd);
  3291. if (agit_flag == 0) {
  3292. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  3293. return -1;
  3294. }
  3295. agit_flag = 0;
  3296. guild_agit_end();
  3297. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  3298. return 0;
  3299. }
  3300. /*==========================================
  3301. * @mapexit - shuts down the map server
  3302. *------------------------------------------*/
  3303. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3304. {
  3305. struct map_session_data* pl_sd;
  3306. struct s_mapiterator* iter;
  3307. nullpo_retr(-1, sd);
  3308. iter = mapit_getallusers();
  3309. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3310. if (sd->status.account_id != pl_sd->status.account_id)
  3311. clif_GM_kick(NULL, pl_sd);
  3312. mapit_free(iter);
  3313. clif_GM_kick(NULL, sd);
  3314. flush_fifos();
  3315. runflag = 0;
  3316. return 0;
  3317. }
  3318. /*==========================================
  3319. * idsearch <part_of_name>: revrited by [Yor]
  3320. *------------------------------------------*/
  3321. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3322. {
  3323. char item_name[100];
  3324. unsigned int i, match;
  3325. struct item_data *item_array[MAX_SEARCH];
  3326. nullpo_retr(-1, sd);
  3327. memset(item_name, '\0', sizeof(item_name));
  3328. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3329. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3330. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3331. return -1;
  3332. }
  3333. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3334. clif_displaymessage(fd, atcmd_output);
  3335. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3336. if (match > MAX_SEARCH) {
  3337. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3338. clif_displaymessage(fd, atcmd_output);
  3339. match = MAX_SEARCH;
  3340. }
  3341. for(i = 0; i < match; i++) {
  3342. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3343. clif_displaymessage(fd, atcmd_output);
  3344. }
  3345. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3346. clif_displaymessage(fd, atcmd_output);
  3347. return 0;
  3348. }
  3349. /*==========================================
  3350. * Recall All Characters Online To Your Location
  3351. *------------------------------------------*/
  3352. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3353. {
  3354. struct map_session_data* pl_sd;
  3355. struct s_mapiterator* iter;
  3356. int count;
  3357. nullpo_retr(-1, sd);
  3358. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3359. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3360. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3361. return -1;
  3362. }
  3363. count = 0;
  3364. iter = mapit_getallusers();
  3365. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3366. {
  3367. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3368. {
  3369. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3370. count++;
  3371. else {
  3372. if (pc_isdead(pl_sd)) { //Wake them up
  3373. pc_setstand(pl_sd);
  3374. pc_setrestartvalue(pl_sd,1);
  3375. }
  3376. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3377. }
  3378. }
  3379. }
  3380. mapit_free(iter);
  3381. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3382. if (count) {
  3383. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3384. clif_displaymessage(fd, atcmd_output);
  3385. }
  3386. return 0;
  3387. }
  3388. /*==========================================
  3389. * Recall online characters of a guild to your location
  3390. *------------------------------------------*/
  3391. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3392. {
  3393. struct map_session_data* pl_sd;
  3394. struct s_mapiterator* iter;
  3395. int count;
  3396. char guild_name[NAME_LENGTH];
  3397. struct guild *g;
  3398. nullpo_retr(-1, sd);
  3399. memset(guild_name, '\0', sizeof(guild_name));
  3400. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3401. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3402. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3403. return -1;
  3404. }
  3405. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3406. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3407. return -1;
  3408. }
  3409. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3410. (g = guild_search(atoi(message))) == NULL)
  3411. {
  3412. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3413. return -1;
  3414. }
  3415. count = 0;
  3416. iter = mapit_getallusers();
  3417. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3418. {
  3419. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3420. {
  3421. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3422. continue; //Skip GMs greater than you.
  3423. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3424. count++;
  3425. else
  3426. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3427. }
  3428. }
  3429. mapit_free(iter);
  3430. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  3431. clif_displaymessage(fd, atcmd_output);
  3432. if (count) {
  3433. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3434. clif_displaymessage(fd, atcmd_output);
  3435. }
  3436. return 0;
  3437. }
  3438. /*==========================================
  3439. * Recall online characters of a party to your location
  3440. *------------------------------------------*/
  3441. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3442. {
  3443. struct map_session_data* pl_sd;
  3444. struct s_mapiterator* iter;
  3445. char party_name[NAME_LENGTH];
  3446. struct party_data *p;
  3447. int count;
  3448. nullpo_retr(-1, sd);
  3449. memset(party_name, '\0', sizeof(party_name));
  3450. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3451. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3452. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3453. return -1;
  3454. }
  3455. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3456. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3457. return -1;
  3458. }
  3459. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3460. (p = party_search(atoi(message))) == NULL)
  3461. {
  3462. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3463. return -1;
  3464. }
  3465. count = 0;
  3466. iter = mapit_getallusers();
  3467. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3468. {
  3469. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3470. {
  3471. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3472. continue; //Skip GMs greater than you.
  3473. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3474. count++;
  3475. else
  3476. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3477. }
  3478. }
  3479. mapit_free(iter);
  3480. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  3481. clif_displaymessage(fd, atcmd_output);
  3482. if (count) {
  3483. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3484. clif_displaymessage(fd, atcmd_output);
  3485. }
  3486. return 0;
  3487. }
  3488. /*==========================================
  3489. *
  3490. *------------------------------------------*/
  3491. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3492. {
  3493. nullpo_retr(-1, sd);
  3494. itemdb_reload();
  3495. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  3496. return 0;
  3497. }
  3498. /*==========================================
  3499. *
  3500. *------------------------------------------*/
  3501. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3502. {
  3503. nullpo_retr(-1, sd);
  3504. mob_reload();
  3505. read_petdb();
  3506. merc_reload();
  3507. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  3508. return 0;
  3509. }
  3510. /*==========================================
  3511. *
  3512. *------------------------------------------*/
  3513. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3514. {
  3515. nullpo_retr(-1, sd);
  3516. skill_reload();
  3517. merc_skill_reload();
  3518. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  3519. return 0;
  3520. }
  3521. /*==========================================
  3522. * @reloadatcommand - reloads atcommand_athena.conf
  3523. *------------------------------------------*/
  3524. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3525. {
  3526. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  3527. clif_displaymessage(fd, msg_txt(254));
  3528. return 0;
  3529. }
  3530. /*==========================================
  3531. * @reloadbattleconf - reloads battle_athena.conf
  3532. *------------------------------------------*/
  3533. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3534. {
  3535. struct Battle_Config prev_config;
  3536. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3537. battle_config_read(BATTLE_CONF_FILENAME);
  3538. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3539. || prev_config.item_rate_common != battle_config.item_rate_common
  3540. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3541. || prev_config.item_rate_card != battle_config.item_rate_card
  3542. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3543. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3544. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3545. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3546. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3547. || prev_config.item_rate_use != battle_config.item_rate_use
  3548. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3549. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3550. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3551. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3552. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3553. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3554. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3555. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3556. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3557. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3558. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3559. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3560. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3561. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3562. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3563. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3564. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3565. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3566. )
  3567. { //Drop rates changed.
  3568. mob_reload(); //Needed as well so rate changes take effect.
  3569. #ifndef TXT_ONLY
  3570. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3571. #endif
  3572. }
  3573. clif_displaymessage(fd, msg_txt(255));
  3574. return 0;
  3575. }
  3576. /*==========================================
  3577. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3578. *------------------------------------------*/
  3579. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3580. {
  3581. status_readdb();
  3582. clif_displaymessage(fd, msg_txt(256));
  3583. return 0;
  3584. }
  3585. /*==========================================
  3586. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3587. *------------------------------------------*/
  3588. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3589. {
  3590. pc_readdb();
  3591. clif_displaymessage(fd, msg_txt(257));
  3592. return 0;
  3593. }
  3594. /*==========================================
  3595. * @reloadmotd - reloads motd.txt
  3596. *------------------------------------------*/
  3597. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3598. {
  3599. pc_read_motd();
  3600. clif_displaymessage(fd, msg_txt(268));
  3601. return 0;
  3602. }
  3603. /*==========================================
  3604. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3605. *------------------------------------------*/
  3606. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3607. {
  3608. nullpo_retr(-1, sd);
  3609. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3610. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3611. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3612. flush_fifos();
  3613. script_reload();
  3614. npc_reload();
  3615. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  3616. return 0;
  3617. }
  3618. /*==========================================
  3619. * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database)
  3620. *------------------------------------------*/
  3621. int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3622. {
  3623. nullpo_retr(-1, sd);
  3624. chrif_reloadGMdb();
  3625. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  3626. return 0;
  3627. }
  3628. /*==========================================
  3629. * @mapinfo <map name> [0-3] by MC_Cameri
  3630. * => Shows information about the map [map name]
  3631. * 0 = no additional information
  3632. * 1 = Show users in that map and their location
  3633. * 2 = Shows NPCs in that map
  3634. * 3 = Shows the shops/chats in that map (not implemented)
  3635. *------------------------------------------*/
  3636. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3637. {
  3638. struct map_session_data* pl_sd;
  3639. struct s_mapiterator* iter;
  3640. struct npc_data *nd = NULL;
  3641. struct chat_data *cd = NULL;
  3642. char direction[12];
  3643. int i, m_id, chat_num, list = 0;
  3644. unsigned short m_index;
  3645. char mapname[24];
  3646. nullpo_retr(-1, sd);
  3647. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3648. memset(mapname, '\0', sizeof(mapname));
  3649. memset(direction, '\0', sizeof(direction));
  3650. sscanf(message, "%d %23[^\n]", &list, mapname);
  3651. if (list < 0 || list > 3) {
  3652. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3653. return -1;
  3654. }
  3655. if (mapname[0] == '\0') {
  3656. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3657. m_id = map_mapindex2mapid(sd->mapindex);
  3658. } else {
  3659. m_id = map_mapname2mapid(mapname);
  3660. }
  3661. if (m_id < 0) {
  3662. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3663. return -1;
  3664. }
  3665. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3666. clif_displaymessage(fd, "------ Map Info ------");
  3667. // count chats (for initial message)
  3668. chat_num = 0;
  3669. iter = mapit_getallusers();
  3670. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3671. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3672. chat_num++;
  3673. mapit_free(iter);
  3674. 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);
  3675. clif_displaymessage(fd, atcmd_output);
  3676. clif_displaymessage(fd, "------ Map Flags ------");
  3677. strcpy(atcmd_output,"PvP Flags: ");
  3678. if (map[m_id].flag.pvp)
  3679. strcat(atcmd_output, "Pvp ON | ");
  3680. if (map[m_id].flag.pvp_noguild)
  3681. strcat(atcmd_output, "NoGuild | ");
  3682. if (map[m_id].flag.pvp_noparty)
  3683. strcat(atcmd_output, "NoParty | ");
  3684. if (map[m_id].flag.pvp_nightmaredrop)
  3685. strcat(atcmd_output, "NightmareDrop | ");
  3686. if (map[m_id].flag.pvp_nocalcrank)
  3687. strcat(atcmd_output, "NoCalcRank | ");
  3688. clif_displaymessage(fd, atcmd_output);
  3689. strcpy(atcmd_output,"GvG Flags: ");
  3690. if (map[m_id].flag.gvg)
  3691. strcat(atcmd_output, "GvG ON | ");
  3692. if (map[m_id].flag.gvg_dungeon)
  3693. strcat(atcmd_output, "GvG Dungeon | ");
  3694. if (map[m_id].flag.gvg_castle)
  3695. strcat(atcmd_output, "GvG Castle | ");
  3696. if (map[m_id].flag.gvg_noparty)
  3697. strcat(atcmd_output, "NoParty | ");
  3698. clif_displaymessage(fd, atcmd_output);
  3699. strcpy(atcmd_output,"Teleport Flags: ");
  3700. if (map[m_id].flag.noteleport)
  3701. strcat(atcmd_output, "NoTeleport | ");
  3702. if (map[m_id].flag.monster_noteleport)
  3703. strcat(atcmd_output, "Monster NoTeleport | ");
  3704. if (map[m_id].flag.nowarp)
  3705. strcat(atcmd_output, "NoWarp | ");
  3706. if (map[m_id].flag.nowarpto)
  3707. strcat(atcmd_output, "NoWarpTo | ");
  3708. if (map[m_id].flag.noreturn)
  3709. strcat(atcmd_output, "NoReturn | ");
  3710. if (map[m_id].flag.nogo)
  3711. strcat(atcmd_output, "NoGo | ");
  3712. if (map[m_id].flag.nomemo)
  3713. strcat(atcmd_output, "NoMemo | ");
  3714. clif_displaymessage(fd, atcmd_output);
  3715. 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");
  3716. clif_displaymessage(fd, atcmd_output);
  3717. if (map[m_id].flag.nosave) {
  3718. if (!map[m_id].save.map)
  3719. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3720. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3721. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3722. else
  3723. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3724. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3725. clif_displaymessage(fd, atcmd_output);
  3726. }
  3727. strcpy(atcmd_output,"Weather Flags: ");
  3728. if (map[m_id].flag.snow)
  3729. strcat(atcmd_output, "Snow | ");
  3730. if (map[m_id].flag.fog)
  3731. strcat(atcmd_output, "Fog | ");
  3732. if (map[m_id].flag.sakura)
  3733. strcat(atcmd_output, "Sakura | ");
  3734. if (map[m_id].flag.clouds)
  3735. strcat(atcmd_output, "Clouds | ");
  3736. if (map[m_id].flag.clouds2)
  3737. strcat(atcmd_output, "Clouds2 | ");
  3738. if (map[m_id].flag.fireworks)
  3739. strcat(atcmd_output, "Fireworks | ");
  3740. if (map[m_id].flag.leaves)
  3741. strcat(atcmd_output, "Leaves | ");
  3742. if (map[m_id].flag.rain)
  3743. strcat(atcmd_output, "Rain | ");
  3744. if (map[m_id].flag.indoors)
  3745. strcat(atcmd_output, "Indoors | ");
  3746. if (map[m_id].flag.nightenabled)
  3747. strcat(atcmd_output, "Displays Night | ");
  3748. clif_displaymessage(fd, atcmd_output);
  3749. strcpy(atcmd_output,"Other Flags: ");
  3750. if (map[m_id].flag.nobranch)
  3751. strcat(atcmd_output, "NoBranch | ");
  3752. if (map[m_id].flag.notrade)
  3753. strcat(atcmd_output, "NoTrade | ");
  3754. if (map[m_id].flag.novending)
  3755. strcat(atcmd_output, "NoVending | ");
  3756. if (map[m_id].flag.nodrop)
  3757. strcat(atcmd_output, "NoDrop | ");
  3758. if (map[m_id].flag.noskill)
  3759. strcat(atcmd_output, "NoSkill | ");
  3760. if (map[m_id].flag.noicewall)
  3761. strcat(atcmd_output, "NoIcewall | ");
  3762. clif_displaymessage(fd, atcmd_output);
  3763. strcpy(atcmd_output,"Other Flags: ");
  3764. if (map[m_id].nocommand)
  3765. strcat(atcmd_output, "NoCommand | ");
  3766. if (map[m_id].flag.nobaseexp)
  3767. strcat(atcmd_output, "NoBaseEXP | ");
  3768. if (map[m_id].flag.nojobexp)
  3769. strcat(atcmd_output, "NoJobEXP | ");
  3770. if (map[m_id].flag.nomobloot)
  3771. strcat(atcmd_output, "NoMobLoot | ");
  3772. if (map[m_id].flag.nomvploot)
  3773. strcat(atcmd_output, "NoMVPLoot | ");
  3774. if (map[m_id].flag.partylock)
  3775. strcat(atcmd_output, "PartyLock | ");
  3776. if (map[m_id].flag.guildlock)
  3777. strcat(atcmd_output, "GuildLock | ");
  3778. clif_displaymessage(fd, atcmd_output);
  3779. switch (list) {
  3780. case 0:
  3781. // Do nothing. It's list 0, no additional display.
  3782. break;
  3783. case 1:
  3784. clif_displaymessage(fd, "----- Players in Map -----");
  3785. iter = mapit_getallusers();
  3786. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3787. {
  3788. if (pl_sd->mapindex == m_index) {
  3789. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3790. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3791. clif_displaymessage(fd, atcmd_output);
  3792. }
  3793. }
  3794. mapit_free(iter);
  3795. break;
  3796. case 2:
  3797. clif_displaymessage(fd, "----- NPCs in Map -----");
  3798. for (i = 0; i < map[m_id].npc_num;)
  3799. {
  3800. nd = map[m_id].npc[i];
  3801. switch(nd->ud.dir) {
  3802. case 0: strcpy(direction, "North"); break;
  3803. case 1: strcpy(direction, "North West"); break;
  3804. case 2: strcpy(direction, "West"); break;
  3805. case 3: strcpy(direction, "South West"); break;
  3806. case 4: strcpy(direction, "South"); break;
  3807. case 5: strcpy(direction, "South East"); break;
  3808. case 6: strcpy(direction, "East"); break;
  3809. case 7: strcpy(direction, "North East"); break;
  3810. case 9: strcpy(direction, "North"); break;
  3811. default: strcpy(direction, "Unknown"); break;
  3812. }
  3813. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3814. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3815. clif_displaymessage(fd, atcmd_output);
  3816. }
  3817. break;
  3818. case 3:
  3819. clif_displaymessage(fd, "----- Chats in Map -----");
  3820. iter = mapit_getallusers();
  3821. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3822. {
  3823. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3824. pl_sd->mapindex == m_index &&
  3825. cd->usersd[0] == pl_sd)
  3826. {
  3827. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  3828. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3829. clif_displaymessage(fd, atcmd_output);
  3830. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3831. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3832. clif_displaymessage(fd, atcmd_output);
  3833. }
  3834. }
  3835. mapit_free(iter);
  3836. break;
  3837. default: // normally impossible to arrive here
  3838. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3839. return -1;
  3840. break;
  3841. }
  3842. return 0;
  3843. }
  3844. /*==========================================
  3845. *
  3846. *------------------------------------------*/
  3847. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3848. {
  3849. nullpo_retr(-1, sd);
  3850. if (!pc_isriding(sd)) { // if actually no peco
  3851. if (!pc_checkskill(sd, KN_RIDING))
  3852. {
  3853. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  3854. return -1;
  3855. }
  3856. if (sd->disguise)
  3857. {
  3858. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco while in disguise.
  3859. return -1;
  3860. }
  3861. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3862. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  3863. } else { //Dismount
  3864. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3865. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  3866. }
  3867. return 0;
  3868. }
  3869. /*==========================================
  3870. *Spy Commands by Syrus22
  3871. *------------------------------------------*/
  3872. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3873. {
  3874. char guild_name[NAME_LENGTH];
  3875. struct guild *g;
  3876. nullpo_retr(-1, sd);
  3877. memset(guild_name, '\0', sizeof(guild_name));
  3878. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3879. if (!enable_spy)
  3880. {
  3881. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3882. return -1;
  3883. }
  3884. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3885. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3886. return -1;
  3887. }
  3888. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3889. (g = guild_search(atoi(message))) != NULL) {
  3890. if (sd->guildspy == g->guild_id) {
  3891. sd->guildspy = 0;
  3892. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3893. clif_displaymessage(fd, atcmd_output);
  3894. } else {
  3895. sd->guildspy = g->guild_id;
  3896. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3897. clif_displaymessage(fd, atcmd_output);
  3898. }
  3899. } else {
  3900. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3901. return -1;
  3902. }
  3903. return 0;
  3904. }
  3905. /*==========================================
  3906. *
  3907. *------------------------------------------*/
  3908. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3909. {
  3910. char party_name[NAME_LENGTH];
  3911. struct party_data *p;
  3912. nullpo_retr(-1, sd);
  3913. memset(party_name, '\0', sizeof(party_name));
  3914. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3915. if (!enable_spy)
  3916. {
  3917. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3918. return -1;
  3919. }
  3920. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3921. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3922. return -1;
  3923. }
  3924. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3925. (p = party_search(atoi(message))) != NULL) {
  3926. if (sd->partyspy == p->party.party_id) {
  3927. sd->partyspy = 0;
  3928. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3929. clif_displaymessage(fd, atcmd_output);
  3930. } else {
  3931. sd->partyspy = p->party.party_id;
  3932. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3933. clif_displaymessage(fd, atcmd_output);
  3934. }
  3935. } else {
  3936. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3937. return -1;
  3938. }
  3939. return 0;
  3940. }
  3941. /*==========================================
  3942. * @repairall [Valaris]
  3943. *------------------------------------------*/
  3944. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3945. {
  3946. int count, i;
  3947. nullpo_retr(-1, sd);
  3948. count = 0;
  3949. for (i = 0; i < MAX_INVENTORY; i++) {
  3950. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3951. sd->status.inventory[i].attribute = 0;
  3952. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3953. count++;
  3954. }
  3955. }
  3956. if (count > 0) {
  3957. clif_misceffect(&sd->bl, 3);
  3958. clif_equiplist(sd);
  3959. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3960. } else {
  3961. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3962. return -1;
  3963. }
  3964. return 0;
  3965. }
  3966. /*==========================================
  3967. * @nuke [Valaris]
  3968. *------------------------------------------*/
  3969. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3970. {
  3971. struct map_session_data *pl_sd;
  3972. nullpo_retr(-1, sd);
  3973. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3974. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3975. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  3976. return -1;
  3977. }
  3978. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3979. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  3980. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3981. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3982. } else {
  3983. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3984. return -1;
  3985. }
  3986. } else {
  3987. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3988. return -1;
  3989. }
  3990. return 0;
  3991. }
  3992. /*==========================================
  3993. * @tonpc
  3994. *------------------------------------------*/
  3995. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3996. {
  3997. char npcname[NAME_LENGTH];
  3998. struct npc_data *nd;
  3999. nullpo_retr(-1, sd);
  4000. memset(npcname, 0, sizeof(npcname));
  4001. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4002. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4003. return -1;
  4004. }
  4005. if ((nd = npc_name2id(npcname)) != NULL) {
  4006. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
  4007. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4008. else
  4009. return -1;
  4010. } else {
  4011. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4012. return -1;
  4013. }
  4014. return 0;
  4015. }
  4016. /*==========================================
  4017. *
  4018. *------------------------------------------*/
  4019. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4020. {
  4021. char NPCname[NAME_LENGTH];
  4022. nullpo_retr(-1, sd);
  4023. memset(NPCname, '\0', sizeof(NPCname));
  4024. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4025. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4026. return -1;
  4027. }
  4028. if (npc_name2id(NPCname) != NULL) {
  4029. npc_enable(NPCname, 1);
  4030. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4031. } else {
  4032. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4033. return -1;
  4034. }
  4035. return 0;
  4036. }
  4037. /*==========================================
  4038. *
  4039. *------------------------------------------*/
  4040. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4041. {
  4042. char NPCname[NAME_LENGTH];
  4043. nullpo_retr(-1, sd);
  4044. memset(NPCname, '\0', sizeof(NPCname));
  4045. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4046. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4047. return -1;
  4048. }
  4049. if (npc_name2id(NPCname) == NULL) {
  4050. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4051. return -1;
  4052. }
  4053. npc_enable(NPCname, 0);
  4054. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4055. return 0;
  4056. }
  4057. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4058. {
  4059. FILE *fp;
  4060. if (!message || !*message) {
  4061. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4062. return -1;
  4063. }
  4064. // check if script file exists
  4065. if ((fp = fopen(message, "r")) == NULL) {
  4066. clif_displaymessage(fd, msg_txt(261));
  4067. return -1;
  4068. }
  4069. fclose(fp);
  4070. // add to list of script sources and run it
  4071. npc_addsrcfile(message);
  4072. npc_parsesrcfile(message);
  4073. npc_read_event_script();
  4074. clif_displaymessage(fd, msg_txt(262));
  4075. return 0;
  4076. }
  4077. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4078. {
  4079. struct npc_data *nd;
  4080. char NPCname[NAME_LENGTH];
  4081. nullpo_retr(-1, sd);
  4082. memset(NPCname, '\0', sizeof(NPCname));
  4083. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4084. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4085. return -1;
  4086. }
  4087. if ((nd = npc_name2id(NPCname)) == NULL) {
  4088. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4089. return -1;
  4090. }
  4091. npc_unload_duplicates(nd);
  4092. npc_unload(nd);
  4093. npc_read_event_script();
  4094. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4095. return 0;
  4096. }
  4097. /*==========================================
  4098. * time in txt for time command (by [Yor])
  4099. *------------------------------------------*/
  4100. char* txt_time(unsigned int duration)
  4101. {
  4102. int days, hours, minutes, seconds;
  4103. char temp[256];
  4104. static char temp1[256];
  4105. memset(temp, '\0', sizeof(temp));
  4106. memset(temp1, '\0', sizeof(temp1));
  4107. days = duration / (60 * 60 * 24);
  4108. duration = duration - (60 * 60 * 24 * days);
  4109. hours = duration / (60 * 60);
  4110. duration = duration - (60 * 60 * hours);
  4111. minutes = duration / 60;
  4112. seconds = duration - (60 * minutes);
  4113. if (days < 2)
  4114. sprintf(temp, msg_txt(219), days); // %d day
  4115. else
  4116. sprintf(temp, msg_txt(220), days); // %d days
  4117. if (hours < 2)
  4118. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4119. else
  4120. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4121. if (minutes < 2)
  4122. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4123. else
  4124. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4125. if (seconds < 2)
  4126. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4127. else
  4128. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4129. return temp1;
  4130. }
  4131. /*==========================================
  4132. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4133. * Calculation management of GM modification (@day/@night GM commands) is done
  4134. *------------------------------------------*/
  4135. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4136. {
  4137. struct TimerData * timer_data;
  4138. struct TimerData * timer_data2;
  4139. time_t time_server; // variable for number of seconds (used with time() function)
  4140. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4141. char temp[256];
  4142. nullpo_retr(-1, sd);
  4143. memset(temp, '\0', sizeof(temp));
  4144. time(&time_server); // get time in seconds since 1/1/1970
  4145. datetime = localtime(&time_server); // convert seconds in structure
  4146. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4147. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4148. clif_displaymessage(fd, temp);
  4149. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4150. if (night_flag == 0)
  4151. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4152. else
  4153. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4154. } else if (battle_config.night_duration == 0)
  4155. if (night_flag == 1) { // we start with night
  4156. timer_data = get_timer(day_timer_tid);
  4157. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4158. clif_displaymessage(fd, temp);
  4159. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4160. } else
  4161. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4162. else if (battle_config.day_duration == 0)
  4163. if (night_flag == 0) { // we start with day
  4164. timer_data = get_timer(night_timer_tid);
  4165. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4166. clif_displaymessage(fd, temp);
  4167. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4168. } else
  4169. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4170. else {
  4171. if (night_flag == 0) {
  4172. timer_data = get_timer(night_timer_tid);
  4173. timer_data2 = get_timer(day_timer_tid);
  4174. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4175. clif_displaymessage(fd, temp);
  4176. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4177. 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.
  4178. else
  4179. 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.
  4180. clif_displaymessage(fd, temp);
  4181. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4182. clif_displaymessage(fd, temp);
  4183. } else {
  4184. timer_data = get_timer(day_timer_tid);
  4185. timer_data2 = get_timer(night_timer_tid);
  4186. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4187. clif_displaymessage(fd, temp);
  4188. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4189. 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.
  4190. else
  4191. 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.
  4192. clif_displaymessage(fd, temp);
  4193. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4194. clif_displaymessage(fd, temp);
  4195. }
  4196. }
  4197. return 0;
  4198. }
  4199. //Added by Coltaro
  4200. //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...).
  4201. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4202. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4203. {
  4204. const int factor_year = 518400; //12*30*24*60 = 518400
  4205. const int factor_month = 43200; //30*24*60 = 43200
  4206. const int factor_day = 1440; //24*60 = 1440
  4207. const int factor_hour = 60;
  4208. *year = jailtime/factor_year;
  4209. jailtime -= *year*factor_year;
  4210. *month = jailtime/factor_month;
  4211. jailtime -= *month*factor_month;
  4212. *day = jailtime/factor_day;
  4213. jailtime -= *day*factor_day;
  4214. *hour = jailtime/factor_hour;
  4215. jailtime -= *hour*factor_hour;
  4216. *minute = jailtime;
  4217. *year = *year > 0? *year : 0;
  4218. *month = *month > 0? *month : 0;
  4219. *day = *day > 0? *day : 0;
  4220. *hour = *hour > 0? *hour : 0;
  4221. *minute = *minute > 0? *minute : 0;
  4222. return;
  4223. }
  4224. /*==========================================
  4225. * @jail <char_name> by [Yor]
  4226. * Special warp! No check with nowarp and nowarpto flag
  4227. *------------------------------------------*/
  4228. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4229. {
  4230. struct map_session_data *pl_sd;
  4231. int x, y;
  4232. unsigned short m_index;
  4233. nullpo_retr(-1, sd);
  4234. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4235. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4236. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4237. return -1;
  4238. }
  4239. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4240. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4241. return -1;
  4242. }
  4243. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4244. { // you can jail only lower or same GM
  4245. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4246. return -1;
  4247. }
  4248. if (pl_sd->sc.data[SC_JAILED])
  4249. {
  4250. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4251. return -1;
  4252. }
  4253. switch(rand() % 2) { //Jail Locations
  4254. case 0:
  4255. m_index = mapindex_name2id(MAP_JAIL);
  4256. x = 24;
  4257. y = 75;
  4258. break;
  4259. default:
  4260. m_index = mapindex_name2id(MAP_JAIL);
  4261. x = 49;
  4262. y = 75;
  4263. break;
  4264. }
  4265. //Duration of INT_MAX to specify infinity.
  4266. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4267. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4268. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4269. return 0;
  4270. }
  4271. /*==========================================
  4272. * @unjail/@discharge <char_name> by [Yor]
  4273. * Special warp! No check with nowarp and nowarpto flag
  4274. *------------------------------------------*/
  4275. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4276. {
  4277. struct map_session_data *pl_sd;
  4278. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4279. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4280. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4281. return -1;
  4282. }
  4283. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4284. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4285. return -1;
  4286. }
  4287. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4288. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4289. return -1;
  4290. }
  4291. if (!pl_sd->sc.data[SC_JAILED])
  4292. {
  4293. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4294. return -1;
  4295. }
  4296. //Reset jail time to 1 sec.
  4297. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4298. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4299. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4300. return 0;
  4301. }
  4302. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4303. {
  4304. struct map_session_data *pl_sd = NULL;
  4305. int year, month, day, hour, minute, value;
  4306. char * modif_p;
  4307. int jailtime = 0,x,y;
  4308. short m_index = 0;
  4309. nullpo_retr(-1, sd);
  4310. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4311. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4312. return -1;
  4313. }
  4314. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4315. modif_p = atcmd_output;
  4316. year = month = day = hour = minute = 0;
  4317. while (modif_p[0] != '\0') {
  4318. value = atoi(modif_p);
  4319. if (value == 0)
  4320. modif_p++;
  4321. else {
  4322. if (modif_p[0] == '-' || modif_p[0] == '+')
  4323. modif_p++;
  4324. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4325. modif_p++;
  4326. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4327. minute = value;
  4328. modif_p = modif_p + 2;
  4329. } else if (modif_p[0] == 'h') {
  4330. hour = value;
  4331. modif_p++;
  4332. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4333. day = value;
  4334. modif_p++;
  4335. } else if (modif_p[0] == 'm') {
  4336. month = value;
  4337. modif_p++;
  4338. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4339. year = value;
  4340. modif_p++;
  4341. } else if (modif_p[0] != '\0') {
  4342. modif_p++;
  4343. }
  4344. }
  4345. }
  4346. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4347. clif_displaymessage(fd, "Invalid time for jail command.");
  4348. return -1;
  4349. }
  4350. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4351. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4352. return -1;
  4353. }
  4354. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4355. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4356. return -1;
  4357. }
  4358. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4359. if(jailtime==0) {
  4360. clif_displaymessage(fd, "Invalid time for jail command.");
  4361. return -1;
  4362. }
  4363. //Added by Coltaro
  4364. if(pl_sd->sc.data[SC_JAILED] &&
  4365. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4366. { //Update the player's jail time
  4367. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4368. if (jailtime <= 0) {
  4369. jailtime = 0;
  4370. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4371. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4372. } else {
  4373. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4374. 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
  4375. clif_displaymessage(pl_sd->fd, atcmd_output);
  4376. 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
  4377. clif_displaymessage(fd, atcmd_output);
  4378. }
  4379. } else if (jailtime < 0) {
  4380. clif_displaymessage(fd, "Invalid time for jail command.");
  4381. return -1;
  4382. }
  4383. //Jail locations, add more as you wish.
  4384. switch(rand()%2)
  4385. {
  4386. case 1: //Jail #1
  4387. m_index = mapindex_name2id(MAP_JAIL);
  4388. x = 49; y = 75;
  4389. break;
  4390. default: //Default Jail
  4391. m_index = mapindex_name2id(MAP_JAIL);
  4392. x = 24; y = 75;
  4393. break;
  4394. }
  4395. 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).
  4396. return 0;
  4397. }
  4398. //By Coltaro
  4399. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4400. {
  4401. int year, month, day, hour, minute;
  4402. nullpo_retr(-1, sd);
  4403. if (!sd->sc.data[SC_JAILED]) {
  4404. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4405. return -1;
  4406. }
  4407. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4408. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4409. return 0;
  4410. }
  4411. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4412. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4413. return -1;
  4414. }
  4415. //Get remaining jail time
  4416. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4417. 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
  4418. clif_displaymessage(fd, atcmd_output);
  4419. return 0;
  4420. }
  4421. /*==========================================
  4422. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4423. *------------------------------------------*/
  4424. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4425. {
  4426. int id = 0;
  4427. nullpo_retr(-1, sd);
  4428. if (!message || !*message) {
  4429. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4430. return -1;
  4431. }
  4432. if ((id = atoi(message)) > 0)
  4433. { //Acquired an ID
  4434. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4435. id = 0; //Invalid id for either mobs or npcs.
  4436. } else { //Acquired a Name
  4437. if ((id = mobdb_searchname(message)) == 0)
  4438. {
  4439. struct npc_data* nd = npc_name2id(message);
  4440. if (nd != NULL)
  4441. id = nd->class_;
  4442. }
  4443. }
  4444. if (id == 0)
  4445. {
  4446. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4447. return -1;
  4448. }
  4449. if(pc_isriding(sd))
  4450. {
  4451. //FIXME: wrong message [ultramage]
  4452. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4453. return -1;
  4454. }
  4455. pc_disguise(sd, id);
  4456. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4457. return 0;
  4458. }
  4459. /*==========================================
  4460. * DisguiseAll
  4461. *------------------------------------------*/
  4462. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4463. {
  4464. int mob_id=0;
  4465. struct map_session_data *pl_sd;
  4466. struct s_mapiterator* iter;
  4467. nullpo_retr(-1, sd);
  4468. if (!message || !*message) {
  4469. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4470. return -1;
  4471. }
  4472. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4473. mob_id = atoi(message);
  4474. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4475. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4476. return -1;
  4477. }
  4478. iter = mapit_getallusers();
  4479. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4480. pc_disguise(pl_sd, mob_id);
  4481. mapit_free(iter);
  4482. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4483. return 0;
  4484. }
  4485. /*==========================================
  4486. * @undisguise by [Yor]
  4487. *------------------------------------------*/
  4488. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4489. {
  4490. nullpo_retr(-1, sd);
  4491. if (sd->disguise) {
  4492. pc_disguise(sd, 0);
  4493. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4494. } else {
  4495. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4496. return -1;
  4497. }
  4498. return 0;
  4499. }
  4500. /*==========================================
  4501. * UndisguiseAll
  4502. *------------------------------------------*/
  4503. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4504. {
  4505. struct map_session_data *pl_sd;
  4506. struct s_mapiterator* iter;
  4507. nullpo_retr(-1, sd);
  4508. iter = mapit_getallusers();
  4509. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4510. if( pl_sd->disguise )
  4511. pc_disguise(pl_sd, 0);
  4512. mapit_free(iter);
  4513. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4514. return 0;
  4515. }
  4516. /*==========================================
  4517. * @exp by [Skotlex]
  4518. *------------------------------------------*/
  4519. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4520. {
  4521. char output[200];
  4522. double nextb, nextj;
  4523. nullpo_retr(-1, sd);
  4524. memset(output, '\0', sizeof(output));
  4525. nextb = pc_nextbaseexp(sd);
  4526. if (nextb)
  4527. nextb = sd->status.base_exp*100.0/nextb;
  4528. nextj = pc_nextjobexp(sd);
  4529. if (nextj)
  4530. nextj = sd->status.job_exp*100.0/nextj;
  4531. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4532. clif_displaymessage(fd, output);
  4533. return 0;
  4534. }
  4535. /*==========================================
  4536. * @broadcast by [Valaris]
  4537. *------------------------------------------*/
  4538. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4539. {
  4540. nullpo_retr(-1, sd);
  4541. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4542. if (!message || !*message) {
  4543. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4544. return -1;
  4545. }
  4546. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4547. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  4548. return 0;
  4549. }
  4550. /*==========================================
  4551. * @localbroadcast by [Valaris]
  4552. *------------------------------------------*/
  4553. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4554. {
  4555. nullpo_retr(-1, sd);
  4556. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4557. if (!message || !*message) {
  4558. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4559. return -1;
  4560. }
  4561. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4562. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  4563. return 0;
  4564. }
  4565. /*==========================================
  4566. * @email <actual@email> <new@email> by [Yor]
  4567. *------------------------------------------*/
  4568. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4569. {
  4570. char actual_email[100];
  4571. char new_email[100];
  4572. nullpo_retr(-1, sd);
  4573. memset(actual_email, '\0', sizeof(actual_email));
  4574. memset(new_email, '\0', sizeof(new_email));
  4575. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4576. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4577. return -1;
  4578. }
  4579. if (e_mail_check(actual_email) == 0) {
  4580. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4581. return -1;
  4582. } else if (e_mail_check(new_email) == 0) {
  4583. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4584. return -1;
  4585. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4586. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4587. return -1;
  4588. } else if (strcmpi(actual_email, new_email) == 0) {
  4589. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4590. return -1;
  4591. }
  4592. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4593. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4594. return 0;
  4595. }
  4596. /*==========================================
  4597. *@effect
  4598. *------------------------------------------*/
  4599. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4600. {
  4601. int type = 0, flag = 0;
  4602. nullpo_retr(-1, sd);
  4603. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4604. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4605. return -1;
  4606. }
  4607. clif_specialeffect(&sd->bl, type, flag);
  4608. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4609. return 0;
  4610. }
  4611. /*==========================================
  4612. * @killer by MouseJstr
  4613. * enable killing players even when not in pvp
  4614. *------------------------------------------*/
  4615. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4616. {
  4617. nullpo_retr(-1, sd);
  4618. sd->state.killer = !sd->state.killer;
  4619. if(sd->state.killer)
  4620. clif_displaymessage(fd, msg_txt(241));
  4621. else {
  4622. clif_displaymessage(fd, msg_txt(287));
  4623. pc_stop_attack(sd);
  4624. }
  4625. return 0;
  4626. }
  4627. /*==========================================
  4628. * @killable by MouseJstr
  4629. * enable other people killing you
  4630. *------------------------------------------*/
  4631. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4632. {
  4633. nullpo_retr(-1, sd);
  4634. sd->state.killable = !sd->state.killable;
  4635. if(sd->state.killable)
  4636. clif_displaymessage(fd, msg_txt(242));
  4637. else {
  4638. clif_displaymessage(fd, msg_txt(288));
  4639. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4640. }
  4641. return 0;
  4642. }
  4643. /*==========================================
  4644. * @skillon by MouseJstr
  4645. * turn skills on for the map
  4646. *------------------------------------------*/
  4647. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4648. {
  4649. nullpo_retr(-1, sd);
  4650. map[sd->bl.m].flag.noskill = 0;
  4651. clif_displaymessage(fd, msg_txt(244));
  4652. return 0;
  4653. }
  4654. /*==========================================
  4655. * @skilloff by MouseJstr
  4656. * Turn skills off on the map
  4657. *------------------------------------------*/
  4658. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4659. {
  4660. nullpo_retr(-1, sd);
  4661. map[sd->bl.m].flag.noskill = 1;
  4662. clif_displaymessage(fd, msg_txt(243));
  4663. return 0;
  4664. }
  4665. /*==========================================
  4666. * @npcmove by MouseJstr
  4667. * move a npc
  4668. *------------------------------------------*/
  4669. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4670. {
  4671. int x = 0, y = 0, m;
  4672. struct npc_data *nd = 0;
  4673. nullpo_retr(-1, sd);
  4674. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4675. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4676. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4677. return -1;
  4678. }
  4679. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4680. {
  4681. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4682. return -1;
  4683. }
  4684. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4685. {
  4686. clif_displaymessage(fd, "NPC is not on this map.");
  4687. return -1; //Not on a map.
  4688. }
  4689. x = cap_value(x, 0, map[m].xs-1);
  4690. y = cap_value(y, 0, map[m].ys-1);
  4691. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4692. map_moveblock(&nd->bl, x, y, gettick());
  4693. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4694. clif_displaymessage(fd, "NPC moved.");
  4695. return 0;
  4696. }
  4697. /*==========================================
  4698. * @addwarp by MouseJstr
  4699. * Create a new static warp point.
  4700. *------------------------------------------*/
  4701. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4702. {
  4703. char mapname[32];
  4704. int x,y;
  4705. unsigned short m;
  4706. struct npc_data* nd;
  4707. nullpo_retr(-1, sd);
  4708. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4709. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4710. return -1;
  4711. }
  4712. m = mapindex_name2id(mapname);
  4713. if( m == 0 )
  4714. {
  4715. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4716. clif_displaymessage(fd, atcmd_output);
  4717. return -1;
  4718. }
  4719. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4720. if( nd == NULL )
  4721. return -1;
  4722. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4723. clif_displaymessage(fd, atcmd_output);
  4724. return 0;
  4725. }
  4726. /*==========================================
  4727. * @follow by [MouseJstr]
  4728. * Follow a player .. staying no more then 5 spaces away
  4729. *------------------------------------------*/
  4730. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4731. {
  4732. struct map_session_data *pl_sd = NULL;
  4733. nullpo_retr(-1, sd);
  4734. if (!message || !*message) {
  4735. if (sd->followtarget == -1)
  4736. return -1;
  4737. pc_stop_following (sd);
  4738. clif_displaymessage(fd, "Follow mode OFF.");
  4739. return 0;
  4740. }
  4741. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4742. {
  4743. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4744. return -1;
  4745. }
  4746. if (sd->followtarget == pl_sd->bl.id) {
  4747. pc_stop_following (sd);
  4748. clif_displaymessage(fd, "Follow mode OFF.");
  4749. } else {
  4750. pc_follow(sd, pl_sd->bl.id);
  4751. clif_displaymessage(fd, "Follow mode ON.");
  4752. }
  4753. return 0;
  4754. }
  4755. /*==========================================
  4756. * @dropall by [MouseJstr]
  4757. * Drop all your possession on the ground
  4758. *------------------------------------------*/
  4759. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4760. {
  4761. int i;
  4762. nullpo_retr(-1, sd);
  4763. for (i = 0; i < MAX_INVENTORY; i++) {
  4764. if (sd->status.inventory[i].amount) {
  4765. if(sd->status.inventory[i].equip != 0)
  4766. pc_unequipitem(sd, i, 3);
  4767. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4768. }
  4769. }
  4770. return 0;
  4771. }
  4772. /*==========================================
  4773. * @storeall by [MouseJstr]
  4774. * Put everything into storage
  4775. *------------------------------------------*/
  4776. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4777. {
  4778. int i;
  4779. nullpo_retr(-1, sd);
  4780. if (sd->state.storage_flag != 1)
  4781. { //Open storage.
  4782. switch (storage_storageopen(sd)) {
  4783. case 2: //Try again
  4784. clif_displaymessage(fd, "run this command again..");
  4785. return 0;
  4786. case 1: //Failure
  4787. clif_displaymessage(fd, "You can't open the storage currently.");
  4788. return -1;
  4789. }
  4790. }
  4791. for (i = 0; i < MAX_INVENTORY; i++) {
  4792. if (sd->status.inventory[i].amount) {
  4793. if(sd->status.inventory[i].equip != 0)
  4794. pc_unequipitem(sd, i, 3);
  4795. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4796. }
  4797. }
  4798. storage_storageclose(sd);
  4799. clif_displaymessage(fd, "It is done");
  4800. return 0;
  4801. }
  4802. /*==========================================
  4803. * @skillid by [MouseJstr]
  4804. * lookup a skill by name
  4805. *------------------------------------------*/
  4806. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4807. {
  4808. int skillen, idx;
  4809. nullpo_retr(-1, sd);
  4810. if (!message || !*message)
  4811. {
  4812. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4813. return -1;
  4814. }
  4815. skillen = strlen(message);
  4816. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4817. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4818. {
  4819. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4820. clif_displaymessage(fd, atcmd_output);
  4821. }
  4822. }
  4823. return 0;
  4824. }
  4825. /*==========================================
  4826. * @useskill by [MouseJstr]
  4827. * A way of using skills without having to find them in the skills menu
  4828. *------------------------------------------*/
  4829. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4830. {
  4831. struct map_session_data *pl_sd = NULL;
  4832. struct block_list *bl;
  4833. int skillnum;
  4834. int skilllv;
  4835. char target[100];
  4836. nullpo_retr(-1, sd);
  4837. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4838. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4839. return -1;
  4840. }
  4841. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4842. {
  4843. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4844. return -1;
  4845. }
  4846. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  4847. {
  4848. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4849. return -1;
  4850. }
  4851. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4852. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4853. bl = &sd->hd->bl;
  4854. else
  4855. bl = &sd->bl;
  4856. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4857. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4858. else
  4859. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4860. return 0;
  4861. }
  4862. /*==========================================
  4863. * @displayskill by [Skotlex]
  4864. * Debug command to locate new skill IDs. It sends the
  4865. * three possible skill-effect packets to the area.
  4866. *------------------------------------------*/
  4867. int atcommand_displayskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4868. {
  4869. struct status_data * status;
  4870. unsigned int tick;
  4871. int skillnum;
  4872. int skilllv = 1;
  4873. nullpo_retr(-1, sd);
  4874. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4875. {
  4876. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4877. return -1;
  4878. }
  4879. status = status_get_status_data(&sd->bl);
  4880. tick = gettick();
  4881. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4882. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4883. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4884. return 0;
  4885. }
  4886. /*==========================================
  4887. * @skilltree by [MouseJstr]
  4888. * prints the skill tree for a player required to get to a skill
  4889. *------------------------------------------*/
  4890. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4891. {
  4892. struct map_session_data *pl_sd = NULL;
  4893. int skillnum, skillidx = -1;
  4894. int meets = 1, j, c=0;
  4895. char target[NAME_LENGTH], *tbl;
  4896. struct skill_tree_entry *ent;
  4897. nullpo_retr(-1, sd);
  4898. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4899. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4900. return -1;
  4901. }
  4902. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4903. {
  4904. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4905. return -1;
  4906. }
  4907. c = pc_calc_skilltree_normalize_job(pl_sd);
  4908. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4909. tbl = job_name(c);
  4910. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  4911. tbl, pc_checkskill(pl_sd, 1));
  4912. clif_displaymessage(fd, atcmd_output);
  4913. for (j = 0; skill_tree[c][j].id != 0; j++) {
  4914. if (skill_tree[c][j].id == skillnum) {
  4915. skillidx = j;
  4916. break;
  4917. }
  4918. }
  4919. if (skillidx == -1) {
  4920. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4921. clif_displaymessage(fd, atcmd_output);
  4922. return 0;
  4923. }
  4924. ent = &skill_tree[c][skillidx];
  4925. for(j=0;j<5;j++)
  4926. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4927. {
  4928. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  4929. clif_displaymessage(fd, atcmd_output);
  4930. meets = 0;
  4931. }
  4932. if (meets == 1) {
  4933. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4934. clif_displaymessage(fd, atcmd_output);
  4935. }
  4936. return 0;
  4937. }
  4938. // Hand a ring with partners name on it to this char
  4939. void getring (struct map_session_data* sd)
  4940. {
  4941. int flag, item_id;
  4942. struct item item_tmp;
  4943. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4944. memset(&item_tmp, 0, sizeof(item_tmp));
  4945. item_tmp.nameid = item_id;
  4946. item_tmp.identify = 1;
  4947. item_tmp.card[0] = 255;
  4948. item_tmp.card[2] = sd->status.partner_id;
  4949. item_tmp.card[3] = sd->status.partner_id >> 16;
  4950. //Logs (A)dmins items [Lupus]
  4951. if(log_config.enable_logs&0x400)
  4952. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  4953. if((flag = pc_additem(sd,&item_tmp,1))) {
  4954. clif_additem(sd,0,0,flag);
  4955. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4956. }
  4957. }
  4958. /*==========================================
  4959. * @marry by [MouseJstr], fixed by Lupus
  4960. * Marry two players
  4961. *------------------------------------------*/
  4962. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4963. {
  4964. struct map_session_data *pl_sd1 = NULL;
  4965. struct map_session_data *pl_sd2 = NULL;
  4966. char player1[128], player2[128]; //Length used for return error msgs
  4967. nullpo_retr(-1, sd);
  4968. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  4969. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  4970. return -1;
  4971. }
  4972. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  4973. sprintf(player2, "Cannot find player '%s' online", player1);
  4974. clif_displaymessage(fd, player2);
  4975. return -1;
  4976. }
  4977. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  4978. sprintf(player1, "Cannot find player '%s' online", player2);
  4979. clif_displaymessage(fd, player1);
  4980. return -1;
  4981. }
  4982. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  4983. clif_displaymessage(fd, "They are married.. wish them well");
  4984. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  4985. // Auto-give named rings (Aru)
  4986. getring (pl_sd1);
  4987. getring (pl_sd2);
  4988. return 0;
  4989. }
  4990. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  4991. return -1;
  4992. }
  4993. /*==========================================
  4994. * @divorce by [MouseJstr], fixed by [Lupus]
  4995. * divorce two players
  4996. *------------------------------------------*/
  4997. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4998. {
  4999. struct map_session_data *pl_sd = NULL;
  5000. nullpo_retr(-1, sd);
  5001. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5002. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5003. return -1;
  5004. }
  5005. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5006. {
  5007. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5008. return -1;
  5009. }
  5010. if (pc_divorce(pl_sd) != 0) {
  5011. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5012. clif_displaymessage(fd, atcmd_output);
  5013. return -1;
  5014. }
  5015. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5016. clif_displaymessage(fd, atcmd_output);
  5017. return 0;
  5018. }
  5019. /*==========================================
  5020. * @changelook by [Celest]
  5021. *------------------------------------------*/
  5022. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5023. {
  5024. int i, j = 0, k = 0;
  5025. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5026. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5027. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5028. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5029. return -1;
  5030. } else if (i == 2) {
  5031. if (j < 1) j = 1;
  5032. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5033. j = pos[j - 1];
  5034. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5035. k = j; // swap
  5036. j = LOOK_HEAD_TOP;
  5037. }
  5038. clif_changelook(&sd->bl,j,k);
  5039. return 0;
  5040. }
  5041. /*==========================================
  5042. * @autotrade by durf (changed by Lupus)
  5043. * Turns on/off Autotrade for a specific player
  5044. *------------------------------------------*/
  5045. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5046. {
  5047. nullpo_retr(-1, sd);
  5048. if( sd->vender_id ) //check if player's vending
  5049. {
  5050. if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
  5051. {
  5052. sd->state.autotrade = 1;
  5053. if( battle_config.at_timeout )
  5054. {
  5055. int timeout = atoi(message);
  5056. 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);
  5057. }
  5058. clif_authfail_fd(fd, 15);
  5059. } else
  5060. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5061. }
  5062. else
  5063. clif_displaymessage(fd, msg_txt(549)); // You should be vending to use @Autotrade.
  5064. return 0;
  5065. }
  5066. /*==========================================
  5067. * @changegm by durf (changed by Lupus)
  5068. * Changes Master of your Guild to a specified guild member
  5069. *------------------------------------------*/
  5070. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5071. {
  5072. struct guild *g;
  5073. struct map_session_data *pl_sd;
  5074. nullpo_retr(-1, sd);
  5075. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5076. {
  5077. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5078. return -1;
  5079. }
  5080. if (strlen(message)==0)
  5081. {
  5082. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5083. return -1;
  5084. }
  5085. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5086. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5087. return -1;
  5088. }
  5089. guild_gm_change(sd->status.guild_id, pl_sd);
  5090. return 0;
  5091. }
  5092. /*==========================================
  5093. * @changeleader by Skotlex
  5094. * Changes the leader of a party.
  5095. *------------------------------------------*/
  5096. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5097. {
  5098. struct party_data *p;
  5099. struct map_session_data *pl_sd;
  5100. int mi, pl_mi;
  5101. nullpo_retr(-1, sd);
  5102. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5103. { //Need to be a party leader.
  5104. clif_displaymessage(fd, msg_txt(282));
  5105. return -1;
  5106. }
  5107. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  5108. if (mi == MAX_PARTY)
  5109. return -1; //Shouldn't happen
  5110. if (!p->party.member[mi].leader)
  5111. { //Need to be a party leader.
  5112. clif_displaymessage(fd, msg_txt(282));
  5113. return -1;
  5114. }
  5115. if (strlen(message)==0)
  5116. {
  5117. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5118. return -1;
  5119. }
  5120. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  5121. clif_displaymessage(fd, msg_txt(283));
  5122. return -1;
  5123. }
  5124. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  5125. if (pl_mi == MAX_PARTY)
  5126. return -1; //Shouldn't happen
  5127. //Change leadership.
  5128. p->party.member[mi].leader = 0;
  5129. if (p->data[mi].sd->fd)
  5130. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  5131. p->party.member[pl_mi].leader = 1;
  5132. if (p->data[pl_mi].sd->fd)
  5133. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  5134. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  5135. //Update info.
  5136. clif_party_info(p,NULL);
  5137. return 0;
  5138. }
  5139. /*==========================================
  5140. * @partyoption by Skotlex
  5141. * Used to change the item share setting of a party.
  5142. *------------------------------------------*/
  5143. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5144. {
  5145. struct party_data *p;
  5146. int mi, option;
  5147. char w1[16], w2[16];
  5148. nullpo_retr(-1, sd);
  5149. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5150. {
  5151. clif_displaymessage(fd, msg_txt(282));
  5152. return -1;
  5153. }
  5154. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5155. if (mi == MAX_PARTY)
  5156. return -1; //Shouldn't happen
  5157. if (!p->party.member[mi].leader)
  5158. {
  5159. clif_displaymessage(fd, msg_txt(282));
  5160. return -1;
  5161. }
  5162. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5163. {
  5164. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5165. return -1;
  5166. }
  5167. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5168. //Change item share type.
  5169. if (option != p->party.item)
  5170. party_changeoption(sd, p->party.exp, option);
  5171. else
  5172. clif_displaymessage(fd, msg_txt(286));
  5173. return 0;
  5174. }
  5175. /*==========================================
  5176. * @autoloot by Upa-Kun
  5177. * Turns on/off AutoLoot for a specific player
  5178. *------------------------------------------*/
  5179. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5180. {
  5181. int rate;
  5182. double drate;
  5183. nullpo_retr(-1, sd);
  5184. // autoloot command without value
  5185. if(!message || !*message)
  5186. {
  5187. if (sd->state.autoloot)
  5188. rate = 0;
  5189. else
  5190. rate = 10000;
  5191. } else {
  5192. drate = atof(message);
  5193. rate = (int)(drate*100);
  5194. }
  5195. if (rate < 0) rate = 0;
  5196. if (rate > 10000) rate = 10000;
  5197. sd->state.autoloot = rate;
  5198. if (sd->state.autoloot) {
  5199. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5200. clif_displaymessage(fd, atcmd_output);
  5201. }else
  5202. clif_displaymessage(fd, "Autoloot is now off.");
  5203. if (sd->state.autoloot && sd->state.autolootid) {
  5204. // Autolootitem should be turned off
  5205. sd->state.autolootid = 0;
  5206. clif_displaymessage(fd, "Autolootitem is now off.");
  5207. }
  5208. return 0;
  5209. }
  5210. /*==========================================
  5211. * @autolootitem
  5212. *------------------------------------------*/
  5213. int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5214. {
  5215. struct item_data *item_data = NULL;
  5216. if (!message || !*message) {
  5217. if (sd->state.autolootid) {
  5218. sd->state.autolootid = 0;
  5219. clif_displaymessage(fd, "Autolootitem have been turned OFF.");
  5220. } else
  5221. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>).");
  5222. return -1;
  5223. }
  5224. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5225. item_data = itemdb_searchname(message);
  5226. if (!item_data) {
  5227. // No items founds in the DB with Id or Name
  5228. clif_displaymessage(fd, "Item not found.");
  5229. return -1;
  5230. }
  5231. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  5232. sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
  5233. item_data->name, item_data->jname, item_data->nameid);
  5234. clif_displaymessage(fd, atcmd_output);
  5235. if (sd->state.autolootid && sd->state.autoloot) {
  5236. // Autoloot should be turned off
  5237. sd->state.autoloot = 0;
  5238. clif_displaymessage(fd, "Autoloot is now off (cannot be actitaved together).");
  5239. }
  5240. return 0;
  5241. }
  5242. /*==========================================
  5243. * It is made to rain.
  5244. *------------------------------------------*/
  5245. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5246. {
  5247. nullpo_retr(-1, sd);
  5248. if (map[sd->bl.m].flag.rain) {
  5249. map[sd->bl.m].flag.rain=0;
  5250. clif_weather(sd->bl.m);
  5251. clif_displaymessage(fd, "The rain has stopped.");
  5252. } else {
  5253. map[sd->bl.m].flag.rain=1;
  5254. clif_weather(sd->bl.m);
  5255. clif_displaymessage(fd, "It is made to rain.");
  5256. }
  5257. return 0;
  5258. }
  5259. /*==========================================
  5260. * It is made to snow.
  5261. *------------------------------------------*/
  5262. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5263. {
  5264. nullpo_retr(-1, sd);
  5265. if (map[sd->bl.m].flag.snow) {
  5266. map[sd->bl.m].flag.snow=0;
  5267. clif_weather(sd->bl.m);
  5268. clif_displaymessage(fd, "Snow has stopped falling.");
  5269. } else {
  5270. map[sd->bl.m].flag.snow=1;
  5271. clif_weather(sd->bl.m);
  5272. clif_displaymessage(fd, "It is made to snow.");
  5273. }
  5274. return 0;
  5275. }
  5276. /*==========================================
  5277. * Cherry tree snowstorm is made to fall. (Sakura)
  5278. *------------------------------------------*/
  5279. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5280. {
  5281. nullpo_retr(-1, sd);
  5282. if (map[sd->bl.m].flag.sakura) {
  5283. map[sd->bl.m].flag.sakura=0;
  5284. clif_weather(sd->bl.m);
  5285. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5286. } else {
  5287. map[sd->bl.m].flag.sakura=1;
  5288. clif_weather(sd->bl.m);
  5289. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5290. }
  5291. return 0;
  5292. }
  5293. /*==========================================
  5294. * Clouds appear.
  5295. *------------------------------------------*/
  5296. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5297. {
  5298. nullpo_retr(-1, sd);
  5299. if (map[sd->bl.m].flag.clouds) {
  5300. map[sd->bl.m].flag.clouds=0;
  5301. clif_weather(sd->bl.m);
  5302. clif_displaymessage(fd, "The clouds has disappear.");
  5303. } else {
  5304. map[sd->bl.m].flag.clouds=1;
  5305. clif_weather(sd->bl.m);
  5306. clif_displaymessage(fd, "Clouds appear.");
  5307. }
  5308. return 0;
  5309. }
  5310. /*==========================================
  5311. * Different type of clouds using effect 516
  5312. *------------------------------------------*/
  5313. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5314. {
  5315. nullpo_retr(-1, sd);
  5316. if (map[sd->bl.m].flag.clouds2) {
  5317. map[sd->bl.m].flag.clouds2=0;
  5318. clif_weather(sd->bl.m);
  5319. clif_displaymessage(fd, "The alternative clouds disappear.");
  5320. } else {
  5321. map[sd->bl.m].flag.clouds2=1;
  5322. clif_weather(sd->bl.m);
  5323. clif_displaymessage(fd, "Alternative clouds appear.");
  5324. }
  5325. return 0;
  5326. }
  5327. /*==========================================
  5328. * Fog hangs over.
  5329. *------------------------------------------*/
  5330. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5331. {
  5332. nullpo_retr(-1, sd);
  5333. if (map[sd->bl.m].flag.fog) {
  5334. map[sd->bl.m].flag.fog=0;
  5335. clif_weather(sd->bl.m);
  5336. clif_displaymessage(fd, "The fog has gone.");
  5337. } else {
  5338. map[sd->bl.m].flag.fog=1;
  5339. clif_weather(sd->bl.m);
  5340. clif_displaymessage(fd, "Fog hangs over.");
  5341. }
  5342. return 0;
  5343. }
  5344. /*==========================================
  5345. * Fallen leaves fall.
  5346. *------------------------------------------*/
  5347. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5348. {
  5349. nullpo_retr(-1, sd);
  5350. if (map[sd->bl.m].flag.leaves) {
  5351. map[sd->bl.m].flag.leaves=0;
  5352. clif_weather(sd->bl.m);
  5353. clif_displaymessage(fd, "Leaves no longer fall.");
  5354. } else {
  5355. map[sd->bl.m].flag.leaves=1;
  5356. clif_weather(sd->bl.m);
  5357. clif_displaymessage(fd, "Fallen leaves fall.");
  5358. }
  5359. return 0;
  5360. }
  5361. /*==========================================
  5362. * Fireworks appear.
  5363. *------------------------------------------*/
  5364. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5365. {
  5366. nullpo_retr(-1, sd);
  5367. if (map[sd->bl.m].flag.fireworks) {
  5368. map[sd->bl.m].flag.fireworks=0;
  5369. clif_weather(sd->bl.m);
  5370. clif_displaymessage(fd, "Fireworks are ended.");
  5371. } else {
  5372. map[sd->bl.m].flag.fireworks=1;
  5373. clif_weather(sd->bl.m);
  5374. clif_displaymessage(fd, "Fireworks are launched.");
  5375. }
  5376. return 0;
  5377. }
  5378. /*==========================================
  5379. * Clearing Weather Effects by Dexity
  5380. *------------------------------------------*/
  5381. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5382. {
  5383. nullpo_retr(-1, sd);
  5384. map[sd->bl.m].flag.rain=0;
  5385. map[sd->bl.m].flag.snow=0;
  5386. map[sd->bl.m].flag.sakura=0;
  5387. map[sd->bl.m].flag.clouds=0;
  5388. map[sd->bl.m].flag.clouds2=0;
  5389. map[sd->bl.m].flag.fog=0;
  5390. map[sd->bl.m].flag.fireworks=0;
  5391. map[sd->bl.m].flag.leaves=0;
  5392. clif_weather(sd->bl.m);
  5393. clif_displaymessage(fd, msg_txt(291));
  5394. return 0;
  5395. }
  5396. /*===============================================================
  5397. * Sound Command - plays a sound for everyone around! [Codemaster]
  5398. *---------------------------------------------------------------*/
  5399. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  5400. {
  5401. char sound_file[100];
  5402. memset(sound_file, '\0', sizeof(sound_file));
  5403. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5404. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5405. return -1;
  5406. }
  5407. if(strstr(sound_file, ".wav") == NULL)
  5408. strcat(sound_file, ".wav");
  5409. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5410. return 0;
  5411. }
  5412. /*==========================================
  5413. * MOB Search
  5414. *------------------------------------------*/
  5415. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  5416. {
  5417. int mob_id,fd;
  5418. static int number=0;
  5419. struct mob_data *md;
  5420. nullpo_retr(0, bl);
  5421. if(!ap){
  5422. number=0;
  5423. return 0;
  5424. }
  5425. mob_id = va_arg(ap,int);
  5426. fd = va_arg(ap,int);
  5427. md = (struct mob_data *)bl;
  5428. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  5429. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  5430. ++number,bl->x, bl->y,md->name);
  5431. clif_displaymessage(fd, atcmd_output);
  5432. }
  5433. return 0;
  5434. }
  5435. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5436. {
  5437. char mob_name[100];
  5438. int mob_id,map_id = 0;
  5439. nullpo_retr(-1, sd);
  5440. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5441. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5442. return -1;
  5443. }
  5444. if ((mob_id = atoi(mob_name)) == 0)
  5445. mob_id = mobdb_searchname(mob_name);
  5446. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5447. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5448. clif_displaymessage(fd, atcmd_output);
  5449. return -1;
  5450. }
  5451. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5452. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5453. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5454. map_id = sd->bl.m;
  5455. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5456. clif_displaymessage(fd, atcmd_output);
  5457. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  5458. atmobsearch_sub(&sd->bl,0); // reset the counter
  5459. return 0;
  5460. }
  5461. /*==========================================
  5462. * @cleanmap - cleans items on the ground
  5463. *------------------------------------------*/
  5464. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5465. {
  5466. nullpo_retr(0, bl);
  5467. map_clearflooritem(bl->id);
  5468. return 0;
  5469. }
  5470. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5471. {
  5472. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5473. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5474. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5475. BL_ITEM);
  5476. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5477. return 0;
  5478. }
  5479. /*==========================================
  5480. * make a NPC/PET talk
  5481. *------------------------------------------*/
  5482. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5483. {
  5484. char name[NAME_LENGTH],mes[100],temp[100];
  5485. struct npc_data *nd;
  5486. if (sd->sc.count && //no "chatting" while muted.
  5487. (sd->sc.data[SC_BERSERK] ||
  5488. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5489. return -1;
  5490. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5491. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5492. return -1;
  5493. }
  5494. if (!(nd = npc_name2id(name))) {
  5495. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5496. return -1;
  5497. }
  5498. strtok(name, "#"); // discard extra name identifier if present
  5499. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5500. clif_message(&nd->bl, temp);
  5501. return 0;
  5502. }
  5503. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5504. {
  5505. char mes[100],temp[100];
  5506. struct pet_data *pd;
  5507. nullpo_retr(-1, sd);
  5508. if(!sd->status.pet_id || !(pd=sd->pd))
  5509. {
  5510. clif_displaymessage(fd, msg_txt(184));
  5511. return -1;
  5512. }
  5513. if (sd->sc.count && //no "chatting" while muted.
  5514. (sd->sc.data[SC_BERSERK] ||
  5515. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5516. return -1;
  5517. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5518. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5519. return -1;
  5520. }
  5521. if (message[0] == '/')
  5522. {// pet emotion processing
  5523. const char* emo[] = {
  5524. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5525. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5526. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5527. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5528. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5529. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5530. };
  5531. int i;
  5532. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5533. if( i < ARRAYLENGTH(emo) )
  5534. {
  5535. clif_emotion(&pd->bl, i);
  5536. return 0;
  5537. }
  5538. }
  5539. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5540. clif_message(&pd->bl, temp);
  5541. return 0;
  5542. }
  5543. /*==========================================
  5544. * @users - displays the number of players present on each map (percentage)
  5545. *------------------------------------------*/
  5546. static DBMap* users_db = NULL; // unsigned int mapindex -> int users
  5547. static int users_all;
  5548. static int atcommand_users_sub1(struct map_session_data* sd,va_list va)
  5549. {
  5550. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  5551. users_all++;
  5552. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  5553. return 0;
  5554. }
  5555. static int atcommand_users_sub2(DBKey key,void* val,va_list va)
  5556. {
  5557. char buf[256];
  5558. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  5559. sprintf(buf,"%s: %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  5560. clif_displaymessage(sd->fd,buf);
  5561. return 0;
  5562. }
  5563. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5564. {
  5565. char buf[256];
  5566. users_all = 0;
  5567. users_db->clear(users_db, NULL);
  5568. clif_foreachclient(atcommand_users_sub1);
  5569. users_db->foreach(users_db,atcommand_users_sub2,sd);
  5570. sprintf(buf,"all: %d",users_all);
  5571. clif_displaymessage(fd,buf);
  5572. return 0;
  5573. }
  5574. /*==========================================
  5575. *
  5576. *------------------------------------------*/
  5577. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5578. {
  5579. pc_resetstate(sd);
  5580. pc_resetskill(sd,1);
  5581. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5582. clif_displaymessage(fd, atcmd_output);
  5583. return 0;
  5584. }
  5585. /*==========================================
  5586. *
  5587. *------------------------------------------*/
  5588. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5589. {
  5590. char name[NAME_LENGTH];
  5591. int mob_id = 0;
  5592. int duration = 0;
  5593. struct mob_data *md;
  5594. unsigned int tick=gettick();
  5595. nullpo_retr(-1, sd);
  5596. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5597. {
  5598. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5599. return -1;
  5600. }
  5601. if (duration < 1)
  5602. duration =1;
  5603. else if (duration > 60)
  5604. duration =60;
  5605. if ((mob_id = atoi(name)) == 0)
  5606. mob_id = mobdb_searchname(name);
  5607. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5608. {
  5609. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5610. return -1;
  5611. }
  5612. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5613. if(!md)
  5614. return -1;
  5615. md->master_id=sd->bl.id;
  5616. md->special_state.ai=1;
  5617. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5618. clif_misceffect2(&md->bl,344);
  5619. mob_spawn(md);
  5620. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5621. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5622. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5623. return 0;
  5624. }
  5625. /*==========================================
  5626. * @adjcmdlvl by [MouseJstr]
  5627. *
  5628. * Temp adjust the GM level required to use a GM command
  5629. * Useful during beta testing to allow players to use GM commands for short periods of time
  5630. *------------------------------------------*/
  5631. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5632. {
  5633. int newlev;
  5634. char name[100];
  5635. AtCommandInfo* cmd;
  5636. nullpo_retr(-1, sd);
  5637. if (!message || !*message || sscanf(message, "%d %99s", &newlev, name) != 2)
  5638. {
  5639. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  5640. return -1;
  5641. }
  5642. cmd = get_atcommandinfo_byname(name);
  5643. if (cmd == NULL)
  5644. {
  5645. clif_displaymessage(fd, "@command not found.");
  5646. return -1;
  5647. }
  5648. else if (newlev > pc_isGM(sd))
  5649. {
  5650. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5651. return -1;
  5652. }
  5653. else if (cmd->level > pc_isGM(sd))
  5654. {
  5655. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5656. return -1;
  5657. }
  5658. else
  5659. {
  5660. cmd->level = newlev;
  5661. clif_displaymessage(fd, "@command level changed.");
  5662. return 0;
  5663. }
  5664. }
  5665. /*==========================================
  5666. * @adjgmlvl by [MouseJstr]
  5667. * Create a temp GM
  5668. * Useful during beta testing to allow players to use GM commands for short periods of time
  5669. *------------------------------------------*/
  5670. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5671. {
  5672. int newlev;
  5673. char user[NAME_LENGTH];
  5674. struct map_session_data *pl_sd;
  5675. nullpo_retr(-1, sd);
  5676. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5677. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5678. return -1;
  5679. }
  5680. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5681. {
  5682. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5683. return -1;
  5684. }
  5685. pc_set_gm_level(pl_sd->status.account_id, newlev);
  5686. return 0;
  5687. }
  5688. /*==========================================
  5689. * @trade by [MouseJstr]
  5690. * Open a trade window with a remote player
  5691. *------------------------------------------*/
  5692. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5693. {
  5694. struct map_session_data *pl_sd = NULL;
  5695. nullpo_retr(-1, sd);
  5696. if (!message || !*message) {
  5697. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5698. return -1;
  5699. }
  5700. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5701. {
  5702. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5703. return -1;
  5704. }
  5705. trade_traderequest(sd, pl_sd);
  5706. return 0;
  5707. }
  5708. /*==========================================
  5709. * @setbattleflag by [MouseJstr]
  5710. * set a battle_config flag without having to reboot
  5711. *------------------------------------------*/
  5712. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5713. {
  5714. char flag[128], value[128];
  5715. nullpo_retr(-1, sd);
  5716. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5717. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5718. return -1;
  5719. }
  5720. if (battle_set_value(flag, value) == 0)
  5721. {
  5722. clif_displaymessage(fd, "unknown battle_config flag");
  5723. return -1;
  5724. }
  5725. clif_displaymessage(fd, "battle_config set as requested");
  5726. return 0;
  5727. }
  5728. /*==========================================
  5729. * @unmute [Valaris]
  5730. *------------------------------------------*/
  5731. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5732. {
  5733. struct map_session_data *pl_sd = NULL;
  5734. nullpo_retr(-1, sd);
  5735. if (!message || !*message) {
  5736. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5737. return -1;
  5738. }
  5739. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5740. {
  5741. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5742. return -1;
  5743. }
  5744. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5745. clif_displaymessage(sd->fd,"Player is not muted");
  5746. return -1;
  5747. }
  5748. pl_sd->status.manner = 0;
  5749. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5750. clif_displaymessage(sd->fd,"Player unmuted");
  5751. return 0;
  5752. }
  5753. /*==========================================
  5754. * @uptime by MC Cameri
  5755. *------------------------------------------*/
  5756. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5757. {
  5758. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5759. minute = 60, days = 0, hours = 0, minutes = 0;
  5760. nullpo_retr(-1, sd);
  5761. seconds = get_uptime();
  5762. days = seconds/day;
  5763. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5764. hours = seconds/hour;
  5765. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5766. minutes = seconds/minute;
  5767. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5768. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5769. clif_displaymessage(fd, atcmd_output);
  5770. return 0;
  5771. }
  5772. /*==========================================
  5773. * @changesex <sex>
  5774. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5775. *------------------------------------------*/
  5776. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5777. {
  5778. nullpo_retr(-1, sd);
  5779. chrif_changesex(sd);
  5780. return 0;
  5781. }
  5782. /*================================================
  5783. * @mute - Mutes a player for a set amount of time
  5784. *------------------------------------------------*/
  5785. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5786. {
  5787. struct map_session_data *pl_sd = NULL;
  5788. int manner;
  5789. nullpo_retr(-1, sd);
  5790. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5791. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5792. return -1;
  5793. }
  5794. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5795. {
  5796. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5797. return -1;
  5798. }
  5799. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5800. {
  5801. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5802. return -1;
  5803. }
  5804. clif_manner_message(sd, 0);
  5805. clif_manner_message(pl_sd, 5);
  5806. if( pl_sd->status.manner < manner ) {
  5807. pl_sd->status.manner -= manner;
  5808. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5809. } else {
  5810. pl_sd->status.manner = 0;
  5811. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5812. }
  5813. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5814. return 0;
  5815. }
  5816. /*==========================================
  5817. * @refresh (like @jumpto <<yourself>>)
  5818. *------------------------------------------*/
  5819. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5820. {
  5821. nullpo_retr(-1, sd);
  5822. clif_refresh(sd);
  5823. return 0;
  5824. }
  5825. /*==========================================
  5826. * @identify
  5827. * => GM's magnifier.
  5828. *------------------------------------------*/
  5829. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5830. {
  5831. int i,num;
  5832. nullpo_retr(-1, sd);
  5833. for(i=num=0;i<MAX_INVENTORY;i++){
  5834. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5835. num++;
  5836. }
  5837. }
  5838. if (num > 0) {
  5839. clif_item_identify_list(sd);
  5840. } else {
  5841. clif_displaymessage(fd,"There are no items to appraise.");
  5842. }
  5843. return 0;
  5844. }
  5845. /*==========================================
  5846. * @gmotd (Global MOTD)
  5847. * by davidsiaw :P
  5848. *------------------------------------------*/
  5849. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5850. {
  5851. char buf[256];
  5852. FILE *fp;
  5853. nullpo_retr(-1, sd);
  5854. if((fp = fopen(motd_txt, "r"))!=NULL){
  5855. while(fgets(buf, sizeof(buf), fp) != NULL)
  5856. {
  5857. int i;
  5858. if (buf[0] == '/' && buf[1] == '/')
  5859. continue;
  5860. for(i=0; buf[i]; i++){
  5861. if(buf[i]=='\r' || buf[i]=='\n'){
  5862. buf[i]=0;
  5863. break;
  5864. }
  5865. }
  5866. intif_GMmessage(buf,strlen(buf)+1,8);
  5867. }
  5868. fclose(fp);
  5869. }
  5870. return 0;
  5871. }
  5872. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5873. {
  5874. int effect = 0;
  5875. nullpo_retr(-1, sd);
  5876. if (!message || !*message)
  5877. return -1;
  5878. if (sscanf(message, "%d", &effect) < 1)
  5879. return -1;
  5880. clif_misceffect(&sd->bl,effect);
  5881. return 0;
  5882. }
  5883. /*==========================================
  5884. * MAIL SYSTEM
  5885. *------------------------------------------*/
  5886. int atcommand_mail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5887. {
  5888. nullpo_retr(0,sd);
  5889. #ifndef TXT_ONLY
  5890. mail_openmail(sd);
  5891. #endif
  5892. return 0;
  5893. }
  5894. /*==========================================
  5895. * Show Monster DB Info v 1.0
  5896. * originally by [Lupus] eAthena
  5897. *------------------------------------------*/
  5898. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5899. {
  5900. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5901. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5902. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5903. char atcmd_output2[200];
  5904. struct item_data *item_data;
  5905. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5906. int count;
  5907. int i, j, k;
  5908. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5909. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5910. if (!message || !*message) {
  5911. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5912. return -1;
  5913. }
  5914. // If monster identifier/name argument is a name
  5915. if ((i = mobdb_checkid(atoi(message))))
  5916. {
  5917. mob_array[0] = mob_db(i);
  5918. count = 1;
  5919. } else
  5920. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5921. if (!count) {
  5922. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5923. return -1;
  5924. }
  5925. if (count > MAX_SEARCH) {
  5926. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5927. clif_displaymessage(fd, atcmd_output);
  5928. count = MAX_SEARCH;
  5929. }
  5930. for (k = 0; k < count; k++) {
  5931. mob = mob_array[k];
  5932. // stats
  5933. if (mob->mexp)
  5934. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5935. else
  5936. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5937. clif_displaymessage(fd, atcmd_output);
  5938. 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);
  5939. clif_displaymessage(fd, atcmd_output);
  5940. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5941. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5942. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5943. clif_displaymessage(fd, atcmd_output);
  5944. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5945. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5946. mob->range2 , mob->range3, msize[mob->status.size],
  5947. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5948. clif_displaymessage(fd, atcmd_output);
  5949. // drops
  5950. clif_displaymessage(fd, " Drops:");
  5951. strcpy(atcmd_output, " ");
  5952. j = 0;
  5953. for (i = 0; i < MAX_MOB_DROP; i++) {
  5954. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  5955. continue;
  5956. if (item_data->slot)
  5957. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5958. else
  5959. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5960. strcat(atcmd_output, atcmd_output2);
  5961. if (++j % 3 == 0) {
  5962. clif_displaymessage(fd, atcmd_output);
  5963. strcpy(atcmd_output, " ");
  5964. }
  5965. }
  5966. if (j == 0)
  5967. clif_displaymessage(fd, "This monster has no drops.");
  5968. else if (j % 3 != 0)
  5969. clif_displaymessage(fd, atcmd_output);
  5970. // mvp
  5971. if (mob->mexp) {
  5972. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  5973. clif_displaymessage(fd, atcmd_output);
  5974. strcpy(atcmd_output, " MVP Items:");
  5975. j = 0;
  5976. for (i = 0; i < 3; i++) {
  5977. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  5978. continue;
  5979. if (mob->mvpitem[i].p > 0) {
  5980. j++;
  5981. if (j == 1)
  5982. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5983. else
  5984. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5985. strcat(atcmd_output, atcmd_output2);
  5986. }
  5987. }
  5988. if (j == 0)
  5989. clif_displaymessage(fd, "This monster has no MVP prizes.");
  5990. else
  5991. clif_displaymessage(fd, atcmd_output);
  5992. }
  5993. }
  5994. return 0;
  5995. }
  5996. /*=========================================
  5997. * @showmobs by KarLaeda
  5998. * => For 5 sec displays the mobs on minimap
  5999. *------------------------------------------*/
  6000. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  6001. {
  6002. struct map_session_data *sd;
  6003. if (!session[id] || (sd = session[id]->session_data) == NULL)
  6004. return 0;
  6005. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  6006. return 1;
  6007. }
  6008. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  6009. {
  6010. int mob_id,fd;
  6011. struct map_session_data* sd;
  6012. static int number=0;
  6013. struct mob_data *md;
  6014. if(!ap){
  6015. number=0;
  6016. return 0;
  6017. }
  6018. mob_id = va_arg(ap,int);
  6019. fd = va_arg(ap,int);
  6020. sd = va_arg(ap,struct map_session_data*);
  6021. md = (struct mob_data *)bl;
  6022. if(md->special_state.ai || md->master_id)
  6023. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  6024. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  6025. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  6026. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  6027. }
  6028. return 0;
  6029. }
  6030. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6031. {
  6032. char mob_name[100];
  6033. int mob_id,map_id = 0;
  6034. nullpo_retr(-1, sd);
  6035. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6036. return -1;
  6037. if ((mob_id = atoi(mob_name)) == 0)
  6038. mob_id = mobdb_searchname(mob_name);
  6039. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6040. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6041. clif_displaymessage(fd, atcmd_output);
  6042. return 0;
  6043. }
  6044. // Uncomment the following line to show mini-bosses & MVP.
  6045. //#define SHOW_MVP
  6046. #ifndef SHOW_MVP
  6047. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6048. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6049. clif_displaymessage(fd, atcmd_output);
  6050. return 0;
  6051. }
  6052. #endif
  6053. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6054. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6055. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6056. map_id = sd->bl.m;
  6057. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6058. mob_name, mapindex_id2name(sd->mapindex));
  6059. clif_displaymessage(fd, atcmd_output);
  6060. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  6061. atshowmobs_sub(&sd->bl,0);
  6062. return 0;
  6063. }
  6064. /*==========================================
  6065. * homunculus level up [orn]
  6066. *------------------------------------------*/
  6067. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6068. {
  6069. TBL_HOM * hd;
  6070. int level = 0, i = 0;
  6071. nullpo_retr(-1, sd);
  6072. if (!message || !*message) {
  6073. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <+/- # of levels>.");
  6074. return -1;
  6075. }
  6076. if ( !merc_is_hom_active(sd->hd) ) {
  6077. clif_displaymessage(fd, "You do not have a homunculus.");
  6078. return -1;
  6079. }
  6080. level = atoi(message);
  6081. hd = sd->hd;
  6082. for (i = 1; i <= level && hd->exp_next; i++){
  6083. hd->homunculus.exp += hd->exp_next;
  6084. merc_hom_levelup(hd);
  6085. }
  6086. status_calc_homunculus(hd,0);
  6087. status_percent_heal(&hd->bl, 100, 100);
  6088. clif_misceffect2(&hd->bl,568);
  6089. return 0;
  6090. }
  6091. /*==========================================
  6092. * homunculus evolution H [orn]
  6093. *------------------------------------------*/
  6094. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6095. {
  6096. nullpo_retr(-1, sd);
  6097. if ( !merc_is_hom_active(sd->hd) ) {
  6098. clif_displaymessage(fd, "You do not have a homunculus.");
  6099. return -1;
  6100. }
  6101. if ( !merc_hom_evolution(sd->hd) ) {
  6102. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6103. return -1;
  6104. }
  6105. return 0;
  6106. }
  6107. /*==========================================
  6108. * call choosen homunculus [orn]
  6109. *------------------------------------------*/
  6110. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6111. {
  6112. int homunid;
  6113. nullpo_retr(-1, sd);
  6114. if ( merc_is_hom_active(sd->hd) ) {
  6115. clif_displaymessage(fd, msg_txt(450));
  6116. return -1;
  6117. }
  6118. if (!message || !*message) {
  6119. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6120. return -1;
  6121. }
  6122. homunid = atoi(message);
  6123. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6124. {
  6125. clif_displaymessage(fd, "Invalid Homunculus id.");
  6126. return -1;
  6127. }
  6128. merc_create_homunculus_request(sd,homunid);
  6129. return 0;
  6130. }
  6131. /*==========================================
  6132. * modify homunculus intimacy [orn]
  6133. *------------------------------------------*/
  6134. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6135. {
  6136. int friendly = 0;
  6137. nullpo_retr(-1, sd);
  6138. if ( !merc_is_hom_active(sd->hd) ) {
  6139. clif_displaymessage(fd, "You do not have a homunculus.");
  6140. return -1;
  6141. }
  6142. if (!message || !*message) {
  6143. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6144. return -1;
  6145. }
  6146. friendly = atoi(message);
  6147. friendly = cap_value(friendly, 0, 1000);
  6148. sd->hd->homunculus.intimacy = friendly * 100 ;
  6149. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6150. return 0;
  6151. }
  6152. /*==========================================
  6153. * modify homunculus hunger [orn]
  6154. *------------------------------------------*/
  6155. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6156. {
  6157. int hungry = 0;
  6158. nullpo_retr(-1, sd);
  6159. if ( !merc_is_hom_active(sd->hd) ) {
  6160. clif_displaymessage(fd, "You do not have a homunculus.");
  6161. return -1;
  6162. }
  6163. if (!message || !*message) {
  6164. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6165. return -1;
  6166. }
  6167. hungry = atoi(message);
  6168. hungry = cap_value(hungry, 0, 100);
  6169. sd->hd->homunculus.hunger = hungry;
  6170. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6171. return 0;
  6172. }
  6173. /*==========================================
  6174. * make the homunculus speak [orn]
  6175. *------------------------------------------*/
  6176. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6177. {
  6178. char mes[100],temp[100];
  6179. nullpo_retr(-1, sd);
  6180. if (sd->sc.count && //no "chatting" while muted.
  6181. (sd->sc.data[SC_BERSERK] ||
  6182. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6183. return -1;
  6184. if ( !merc_is_hom_active(sd->hd) ) {
  6185. clif_displaymessage(fd, "You do not have a homunculus.");
  6186. return -1;
  6187. }
  6188. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6189. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6190. return -1;
  6191. }
  6192. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6193. clif_message(&sd->hd->bl, temp);
  6194. return 0;
  6195. }
  6196. /*==========================================
  6197. * Show homunculus stats
  6198. *------------------------------------------*/
  6199. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6200. {
  6201. struct homun_data *hd;
  6202. struct status_data *status;
  6203. nullpo_retr(-1, sd);
  6204. if ( !merc_is_hom_active(sd->hd) ) {
  6205. clif_displaymessage(fd, "You do not have a homunculus.");
  6206. return -1;
  6207. }
  6208. hd = sd->hd;
  6209. status = status_get_status_data(&hd->bl);
  6210. clif_displaymessage(fd, "Homunculus stats :");
  6211. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6212. status->hp, status->max_hp, status->sp, status->max_sp);
  6213. clif_displaymessage(fd, atcmd_output);
  6214. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6215. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6216. clif_displaymessage(fd, atcmd_output);
  6217. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6218. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6219. clif_displaymessage(fd, atcmd_output);
  6220. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6221. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6222. status->str, status->agi, status->vit,
  6223. status->int_, status->dex, status->luk);
  6224. clif_displaymessage(fd, atcmd_output);
  6225. return 0;
  6226. }
  6227. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6228. {
  6229. struct homun_data *hd;
  6230. struct s_homunculus_db *db;
  6231. struct s_homunculus *hom;
  6232. int lv, min, max, evo;
  6233. nullpo_retr(-1, sd);
  6234. if ( !merc_is_hom_active(sd->hd) ) {
  6235. clif_displaymessage(fd, "You do not have a homunculus.");
  6236. return -1;
  6237. }
  6238. hd = sd->hd;
  6239. hom = &hd->homunculus;
  6240. db = hd->homunculusDB;
  6241. lv = hom->level;
  6242. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6243. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6244. clif_displaymessage(fd, atcmd_output);
  6245. lv--; //Since the first increase is at level 2.
  6246. evo = (hom->class_ == db->evo_class);
  6247. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6248. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6249. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6250. clif_displaymessage(fd, atcmd_output);
  6251. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6252. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6253. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6254. clif_displaymessage(fd, atcmd_output);
  6255. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6256. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6257. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6258. clif_displaymessage(fd, atcmd_output);
  6259. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6260. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6261. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6262. clif_displaymessage(fd, atcmd_output);
  6263. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6264. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6265. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6266. clif_displaymessage(fd, atcmd_output);
  6267. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6268. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6269. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6270. clif_displaymessage(fd, atcmd_output);
  6271. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6272. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6273. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6274. clif_displaymessage(fd, atcmd_output);
  6275. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6276. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6277. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6278. clif_displaymessage(fd, atcmd_output);
  6279. return 0;
  6280. }
  6281. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6282. {
  6283. TBL_PC* tsd = sd;
  6284. nullpo_retr(-1, sd);
  6285. if ((!message || !*message) && !sd->hd)
  6286. {
  6287. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  6288. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  6289. return -1;
  6290. }
  6291. if (message && *message) {
  6292. tsd = map_nick2sd((char*)message);
  6293. if (!tsd) {
  6294. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6295. return -1;
  6296. }
  6297. if (pc_isGM(tsd) > pc_isGM(sd)) {
  6298. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6299. return -1;
  6300. }
  6301. }
  6302. if(!merc_hom_shuffle(tsd->hd))
  6303. return -1;
  6304. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6305. //Print out the new stats
  6306. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  6307. atcommand_homstats(fd, tsd, command, message);
  6308. return 0;
  6309. }
  6310. /*==========================================
  6311. * Show Items DB Info v 1.0
  6312. * originally by [Lupus] eAthena
  6313. *------------------------------------------*/
  6314. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6315. {
  6316. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  6317. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  6318. struct item_data *item_data, *item_array[MAX_SEARCH];
  6319. int i, count = 1;
  6320. if (!message || !*message) {
  6321. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6322. return -1;
  6323. }
  6324. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6325. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6326. if (!count) {
  6327. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6328. return -1;
  6329. }
  6330. if (count > MAX_SEARCH) {
  6331. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6332. clif_displaymessage(fd, atcmd_output);
  6333. count = MAX_SEARCH;
  6334. }
  6335. for (i = 0; i < count; i++) {
  6336. item_data = item_array[i];
  6337. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6338. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6339. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  6340. (item_data->script==NULL)? "None" : "With script"
  6341. );
  6342. clif_displaymessage(fd, atcmd_output);
  6343. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
  6344. clif_displaymessage(fd, atcmd_output);
  6345. if (item_data->maxchance == 10000)
  6346. strcpy(atcmd_output, " - Available in the shops only");
  6347. else if (item_data->maxchance)
  6348. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6349. else
  6350. strcpy(atcmd_output, " - Monsters don't drop this item");
  6351. clif_displaymessage(fd, atcmd_output);
  6352. }
  6353. return 0;
  6354. }
  6355. /*==========================================
  6356. * Show who drops the item.
  6357. *------------------------------------------*/
  6358. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6359. {
  6360. struct item_data *item_data, *item_array[MAX_SEARCH];
  6361. int i,j, count = 1;
  6362. if (!message || !*message) {
  6363. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6364. return -1;
  6365. }
  6366. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6367. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6368. if (!count) {
  6369. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6370. return -1;
  6371. }
  6372. if (count > MAX_SEARCH) {
  6373. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6374. clif_displaymessage(fd, atcmd_output);
  6375. count = MAX_SEARCH;
  6376. }
  6377. for (i = 0; i < count; i++) {
  6378. item_data = item_array[i];
  6379. sprintf(atcmd_output, "Item: '%s'[%d]",
  6380. item_data->jname,item_data->slot);
  6381. clif_displaymessage(fd, atcmd_output);
  6382. if (item_data->mob[0].chance == 0) {
  6383. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6384. clif_displaymessage(fd, atcmd_output);
  6385. } else {
  6386. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6387. clif_displaymessage(fd, atcmd_output);
  6388. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6389. {
  6390. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6391. clif_displaymessage(fd, atcmd_output);
  6392. }
  6393. }
  6394. }
  6395. return 0;
  6396. }
  6397. int atcommand_whereis(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6398. {
  6399. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6400. int count;
  6401. int i, j, k;
  6402. if (!message || !*message) {
  6403. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6404. return -1;
  6405. }
  6406. // If monster identifier/name argument is a name
  6407. if ((i = mobdb_checkid(atoi(message))))
  6408. {
  6409. mob_array[0] = mob_db(i);
  6410. count = 1;
  6411. } else
  6412. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6413. if (!count) {
  6414. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6415. return -1;
  6416. }
  6417. if (count > MAX_SEARCH) {
  6418. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6419. clif_displaymessage(fd, atcmd_output);
  6420. count = MAX_SEARCH;
  6421. }
  6422. for (k = 0; k < count; k++) {
  6423. mob = mob_array[k];
  6424. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6425. clif_displaymessage(fd, atcmd_output);
  6426. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6427. {
  6428. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6429. if (j < 0) continue;
  6430. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6431. clif_displaymessage(fd, atcmd_output);
  6432. }
  6433. if (i == 0)
  6434. clif_displaymessage(fd, "This monster does not spawn normally.");
  6435. }
  6436. return 0;
  6437. }
  6438. /*==========================================
  6439. * @adopt by [Veider]
  6440. * adopt a novice
  6441. *------------------------------------------*/
  6442. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6443. {
  6444. struct map_session_data *pl_sd1 = NULL;
  6445. struct map_session_data *pl_sd2 = NULL;
  6446. struct map_session_data *pl_sd3 = NULL;
  6447. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6448. char output[256];
  6449. nullpo_retr(-1, sd);
  6450. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6451. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6452. return -1;
  6453. }
  6454. if (battle_config.etc_log)
  6455. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6456. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6457. sprintf(output, "Cannot find player %s online", player1);
  6458. clif_displaymessage(fd, output);
  6459. return -1;
  6460. }
  6461. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6462. sprintf(output, "Cannot find player %s online", player2);
  6463. clif_displaymessage(fd, output);
  6464. return -1;
  6465. }
  6466. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6467. sprintf(output, "Cannot find player %s online", player3);
  6468. clif_displaymessage(fd, output);
  6469. return -1;
  6470. }
  6471. if( pc_adoption(pl_sd1, pl_sd2, pl_sd3) != 0 ) {
  6472. return -1;
  6473. }
  6474. clif_displaymessage(fd, "They are family... wish them luck");
  6475. return 0;
  6476. }
  6477. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6478. {
  6479. const char * revision;
  6480. if ((revision = get_svn_revision()) != 0) {
  6481. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6482. clif_displaymessage(fd,atcmd_output);
  6483. } else
  6484. clif_displaymessage(fd,"Cannot determine SVN revision");
  6485. return 0;
  6486. }
  6487. /*==========================================
  6488. * @mutearea by MouseJstr
  6489. *------------------------------------------*/
  6490. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6491. {
  6492. int time, id;
  6493. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6494. if (pl_sd == NULL)
  6495. return 0;
  6496. id = va_arg(ap, int);
  6497. time = va_arg(ap, int);
  6498. if (id != bl->id && !pc_isGM(pl_sd)) {
  6499. pl_sd->status.manner -= time;
  6500. if (pl_sd->status.manner < 0)
  6501. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6502. else if (pl_sd->sc.data[SC_NOCHAT])
  6503. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  6504. }
  6505. return 0;
  6506. }
  6507. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6508. {
  6509. int time;
  6510. nullpo_retr(0, sd);
  6511. if (!message || !*message) {
  6512. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6513. return -1;
  6514. }
  6515. time = atoi(message);
  6516. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6517. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6518. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6519. return 0;
  6520. }
  6521. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6522. {
  6523. char buf[255];
  6524. nullpo_retr(0, sd);
  6525. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  6526. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6527. clif_displaymessage(fd, buf);
  6528. return 0;
  6529. }
  6530. /*==========================================
  6531. * @me by lordalfa
  6532. * => Displays the OUTPUT string on top of the Visible players Heads.
  6533. *------------------------------------------*/
  6534. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6535. {
  6536. char tempmes[200];
  6537. nullpo_retr(-1, sd);
  6538. memset(tempmes, '\0', sizeof(tempmes));
  6539. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6540. if (sd->sc.count && //no "chatting" while muted.
  6541. (sd->sc.data[SC_BERSERK] ||
  6542. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6543. return -1;
  6544. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6545. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6546. return -1;
  6547. }
  6548. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6549. clif_disp_overhead(sd, atcmd_output);
  6550. return 0;
  6551. }
  6552. /*==========================================
  6553. * @size
  6554. * => Resize your character sprite. [Valaris]
  6555. *------------------------------------------*/
  6556. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6557. {
  6558. int size=0;
  6559. nullpo_retr(-1, sd);
  6560. size = atoi(message);
  6561. if(sd->state.size) {
  6562. sd->state.size=0;
  6563. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  6564. }
  6565. if(size==1) {
  6566. sd->state.size=1;
  6567. clif_specialeffect(&sd->bl,420,AREA);
  6568. } else if(size==2) {
  6569. sd->state.size=2;
  6570. clif_specialeffect(&sd->bl,422,AREA);
  6571. }
  6572. return 0;
  6573. }
  6574. /*==========================================
  6575. * @monsterignore
  6576. * => Makes monsters ignore you. [Valaris]
  6577. *------------------------------------------*/
  6578. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6579. {
  6580. nullpo_retr(-1, sd);
  6581. if (!sd->state.monster_ignore) {
  6582. sd->state.monster_ignore = 1;
  6583. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6584. } else {
  6585. sd->state.monster_ignore = 0;
  6586. clif_displaymessage(sd->fd, "Returned to normal state.");
  6587. }
  6588. return 0;
  6589. }
  6590. /*==========================================
  6591. * @fakename
  6592. * => Gives your character a fake name. [Valaris]
  6593. *------------------------------------------*/
  6594. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6595. {
  6596. char name[NAME_LENGTH];
  6597. nullpo_retr(-1, sd);
  6598. if((!message || !*message) && strlen(sd->fakename) > 1) {
  6599. sd->fakename[0]='\0';
  6600. clif_charnameack(0, &sd->bl);
  6601. clif_displaymessage(sd->fd,"Returned to real name.");
  6602. return 0;
  6603. }
  6604. if (!message || !*message || sscanf(message, "%23[^\n]", name) < 1) {
  6605. clif_displaymessage(sd->fd,"You must enter a name.");
  6606. return -1;
  6607. }
  6608. if(strlen(name) < 2) {
  6609. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  6610. return -1;
  6611. }
  6612. memcpy(sd->fakename,name,NAME_LENGTH);
  6613. sd->fakename[NAME_LENGTH-1] = '\0';
  6614. clif_charnameack(0, &sd->bl);
  6615. clif_displaymessage(sd->fd,"Fake name enabled.");
  6616. return 0;
  6617. }
  6618. /*==========================================
  6619. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  6620. * => Shows information about the map flags [map name]
  6621. * Also set flags
  6622. *------------------------------------------*/
  6623. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6624. {
  6625. // WIP
  6626. return 0;
  6627. }
  6628. /*===================================
  6629. * Remove some messages
  6630. *-----------------------------------*/
  6631. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6632. {
  6633. if (sd->state.showexp) {
  6634. sd->state.showexp = 0;
  6635. clif_displaymessage(fd, "Gained exp will not be shown.");
  6636. return 0;
  6637. }
  6638. sd->state.showexp = 1;
  6639. clif_displaymessage(fd, "Gained exp is now shown");
  6640. return 0;
  6641. }
  6642. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6643. {
  6644. if (sd->state.showzeny) {
  6645. sd->state.showzeny = 0;
  6646. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6647. return 0;
  6648. }
  6649. sd->state.showzeny = 1;
  6650. clif_displaymessage(fd, "Gained zeny is now shown");
  6651. return 0;
  6652. }
  6653. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6654. {
  6655. if (sd->state.showdelay) {
  6656. sd->state.showdelay = 0;
  6657. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6658. return 0;
  6659. }
  6660. sd->state.showdelay = 1;
  6661. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6662. return 0;
  6663. }
  6664. /*==========================================
  6665. * Duel organizing functions [LuzZza]
  6666. *
  6667. * @duel [limit|nick] - create a duel
  6668. * @invite <nick> - invite player
  6669. * @accept - accept invitation
  6670. * @reject - reject invitation
  6671. * @leave - leave duel
  6672. *------------------------------------------*/
  6673. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6674. {
  6675. unsigned int did = sd->duel_group;
  6676. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6677. if(did <= 0) {
  6678. // "Duel: @invite without @duel."
  6679. clif_displaymessage(fd, msg_txt(350));
  6680. return 0;
  6681. }
  6682. if(duel_list[did].max_players_limit > 0 &&
  6683. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6684. // "Duel: Limit of players is reached."
  6685. clif_displaymessage(fd, msg_txt(351));
  6686. return 0;
  6687. }
  6688. if(target_sd == NULL) {
  6689. // "Duel: Player not found."
  6690. clif_displaymessage(fd, msg_txt(352));
  6691. return 0;
  6692. }
  6693. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6694. // "Duel: Player already in duel."
  6695. clif_displaymessage(fd, msg_txt(353));
  6696. return 0;
  6697. }
  6698. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6699. {
  6700. sprintf(atcmd_output, msg_txt(364), message);
  6701. clif_displaymessage(fd, atcmd_output);
  6702. return 0;
  6703. }
  6704. duel_invite(did, sd, target_sd);
  6705. // "Duel: Invitation has been sent."
  6706. clif_displaymessage(fd, msg_txt(354));
  6707. return 0;
  6708. }
  6709. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6710. {
  6711. char output[256];
  6712. unsigned int maxpl=0, newduel;
  6713. struct map_session_data *target_sd;
  6714. if(sd->duel_group > 0) {
  6715. duel_showinfo(sd->duel_group, sd);
  6716. return 0;
  6717. }
  6718. if(sd->duel_invite > 0) {
  6719. // "Duel: @duel without @reject."
  6720. clif_displaymessage(fd, msg_txt(355));
  6721. return 0;
  6722. }
  6723. if(!duel_checktime(sd)) {
  6724. // "Duel: You can take part in duel only one time per %d minutes."
  6725. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6726. clif_displaymessage(fd, output);
  6727. return 0;
  6728. }
  6729. if(strlen(message) > 0) {
  6730. if(sscanf(message, "%d", &maxpl) >= 1) {
  6731. if(maxpl < 2 || maxpl > 65535) {
  6732. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6733. return 0;
  6734. }
  6735. duel_create(sd, maxpl);
  6736. } else {
  6737. target_sd = map_nick2sd((char *)message);
  6738. if(target_sd != NULL) {
  6739. if((newduel = duel_create(sd, 2)) != -1) {
  6740. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6741. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6742. return 0;
  6743. }
  6744. duel_invite(newduel, sd, target_sd);
  6745. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6746. }
  6747. } else {
  6748. // "Duel: Player not found."
  6749. clif_displaymessage(fd, msg_txt(352));
  6750. return 0;
  6751. }
  6752. }
  6753. } else
  6754. duel_create(sd, 0);
  6755. return 0;
  6756. }
  6757. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6758. {
  6759. if(sd->duel_group <= 0) {
  6760. // "Duel: @leave without @duel."
  6761. clif_displaymessage(fd, msg_txt(358));
  6762. return 0;
  6763. }
  6764. duel_leave(sd->duel_group, sd);
  6765. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6766. return 0;
  6767. }
  6768. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6769. {
  6770. char output[256];
  6771. if(!duel_checktime(sd)) {
  6772. // "Duel: You can take part in duel only one time per %d minutes."
  6773. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6774. clif_displaymessage(fd, output);
  6775. return 0;
  6776. }
  6777. if(sd->duel_invite <= 0) {
  6778. // "Duel: @accept without invititation."
  6779. clif_displaymessage(fd, msg_txt(360));
  6780. return 0;
  6781. }
  6782. duel_accept(sd->duel_invite, sd);
  6783. // "Duel: Invitation has been accepted."
  6784. clif_displaymessage(fd, msg_txt(361));
  6785. return 0;
  6786. }
  6787. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6788. {
  6789. if(sd->duel_invite <= 0) {
  6790. // "Duel: @reject without invititation."
  6791. clif_displaymessage(fd, msg_txt(362));
  6792. return 0;
  6793. }
  6794. duel_reject(sd->duel_invite, sd);
  6795. // "Duel: Invitation has been rejected."
  6796. clif_displaymessage(fd, msg_txt(363));
  6797. return 0;
  6798. }
  6799. /*===================================
  6800. * Cash Points
  6801. *-----------------------------------*/
  6802. int atcommand_cash(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6803. {
  6804. int value;
  6805. nullpo_retr(-1, sd);
  6806. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6807. clif_displaymessage(fd, "Please, enter an amount.");
  6808. return -1;
  6809. }
  6810. if( !strcmpi(command+1,"cash") )
  6811. {
  6812. if( value > 0 )
  6813. pc_getcash(sd, value, 0);
  6814. else
  6815. pc_paycash(sd, value, 0);
  6816. }
  6817. else
  6818. { // @points
  6819. if( value > 0 )
  6820. pc_getcash(sd, 0, value);
  6821. else
  6822. pc_paycash(sd, value, value);
  6823. }
  6824. return 0;
  6825. }
  6826. /*===================================
  6827. * Away message (@away, @aw) [LuzZza]
  6828. *-----------------------------------*/
  6829. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6830. {
  6831. if(strlen(message) > 0) {
  6832. if(strlen(message) > 128)
  6833. return -1;
  6834. strcpy(sd->away_message, message);
  6835. //"Away automessage has been activated."
  6836. clif_displaymessage(fd, msg_txt(546));
  6837. } else {
  6838. if(strlen(sd->away_message) > 0) {
  6839. sd->away_message[0] = 0;
  6840. //"Away automessage has been disabled."
  6841. clif_displaymessage(fd, msg_txt(547));
  6842. return 0;
  6843. }
  6844. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  6845. clif_displaymessage(fd, msg_txt(548));
  6846. }
  6847. return 0;
  6848. }
  6849. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6850. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6851. {
  6852. int x=0,y=0,flag=0,master=0,i=0;
  6853. struct map_session_data *pl_sd=NULL;
  6854. if (!message || !*message) {
  6855. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6856. return 0;
  6857. }
  6858. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6859. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6860. return 0;
  6861. }
  6862. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  6863. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6864. return 0;
  6865. }
  6866. if (strcmpi(command+1, "clone") == 0)
  6867. flag = 1;
  6868. else if (strcmpi(command+1, "slaveclone") == 0) {
  6869. flag = 2;
  6870. master = sd->bl.id;
  6871. if (battle_config.atc_slave_clone_limit
  6872. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6873. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6874. return 0;
  6875. }
  6876. }
  6877. do {
  6878. x = sd->bl.x + (rand() % 10 - 5);
  6879. y = sd->bl.y + (rand() % 10 - 5);
  6880. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6881. if (i >= 10) {
  6882. x = sd->bl.x;
  6883. y = sd->bl.y;
  6884. }
  6885. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6886. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6887. return 0;
  6888. }
  6889. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6890. return 0;
  6891. }
  6892. /*===================================
  6893. * Main chat [LuzZza]
  6894. * Usage: @main <on|off|message>
  6895. *-----------------------------------*/
  6896. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6897. {
  6898. if(strlen(message) > 0) {
  6899. if(strcmpi(message, "on") == 0) {
  6900. if(!sd->state.mainchat) {
  6901. sd->state.mainchat = 1;
  6902. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6903. } else {
  6904. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6905. }
  6906. } else if(strcmpi(message, "off") == 0) {
  6907. if(sd->state.mainchat) {
  6908. sd->state.mainchat = 0;
  6909. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6910. } else {
  6911. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6912. }
  6913. } else {
  6914. if(!sd->state.mainchat) {
  6915. sd->state.mainchat = 1;
  6916. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6917. }
  6918. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6919. clif_displaymessage(fd, msg_txt(387));
  6920. return -1;
  6921. }
  6922. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  6923. // I use 0xFE000000 color for signalizing that this message is
  6924. // main chat message. 0xFE000000 is invalid color, same using
  6925. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  6926. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  6927. // Chat logging type 'M' / Main Chat
  6928. if( log_config.chat&1 || (log_config.chat&32 && !(agit_flag && log_config.chat&64)) )
  6929. log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  6930. }
  6931. } else {
  6932. if(sd->state.mainchat)
  6933. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6934. else
  6935. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6936. }
  6937. return 0;
  6938. }
  6939. /*=====================================
  6940. * Autorejecting Invites/Deals [LuzZza]
  6941. * Usage: @noask
  6942. *-------------------------------------*/
  6943. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6944. {
  6945. if(sd->state.noask) {
  6946. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6947. sd->state.noask = 0;
  6948. } else {
  6949. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6950. sd->state.noask = 1;
  6951. }
  6952. return 0;
  6953. }
  6954. /*=====================================
  6955. * Send a @request message to all GMs of lowest_gm_level.
  6956. * Usage: @request <petition>
  6957. *-------------------------------------*/
  6958. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6959. {
  6960. if (!message || !*message) {
  6961. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6962. return -1;
  6963. }
  6964. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6965. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  6966. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6967. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6968. return 0;
  6969. }
  6970. /*==========================================
  6971. * Feel (SG save map) Reset [HiddenDragon]
  6972. *------------------------------------------*/
  6973. int atcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6974. {
  6975. pc_resetfeel(sd);
  6976. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  6977. return 0;
  6978. }
  6979. /*==========================================
  6980. * AUCTION SYSTEM
  6981. *------------------------------------------*/
  6982. int atcommand_auction(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6983. {
  6984. nullpo_retr(0,sd);
  6985. clif_Auction_openwindow(sd);
  6986. return 0;
  6987. }
  6988. /*==========================================
  6989. * Kill Steal Protection
  6990. *------------------------------------------*/
  6991. int atcommand_ksprotection(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6992. {
  6993. nullpo_retr(-1,sd);
  6994. if( sd->state.noks ) {
  6995. sd->state.noks = 0;
  6996. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  6997. }
  6998. else
  6999. {
  7000. if( !message || !*message || !strcmpi(message, "party") )
  7001. { // Default is Party
  7002. sd->state.noks = 2;
  7003. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7004. }
  7005. else if( !strcmpi(message, "self") )
  7006. {
  7007. sd->state.noks = 1;
  7008. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7009. }
  7010. else if( !strcmpi(message, "guild") )
  7011. {
  7012. sd->state.noks = 3;
  7013. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7014. }
  7015. }
  7016. clif_displaymessage(fd, atcmd_output);
  7017. return 0;
  7018. }
  7019. /*==========================================
  7020. * Map Kill Steal Protection Setting
  7021. *------------------------------------------*/
  7022. int atcommand_allowks(const int fd, struct map_session_data *sd, const char *command, const char *message)
  7023. {
  7024. nullpo_retr(-1,sd);
  7025. if( map[sd->bl.m].flag.allowks ) {
  7026. map[sd->bl.m].flag.allowks = 0;
  7027. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7028. } else {
  7029. map[sd->bl.m].flag.allowks = 1;
  7030. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7031. }
  7032. clif_displaymessage(fd, atcmd_output);
  7033. return 0;
  7034. }
  7035. /*==========================================
  7036. * atcommand_info[] structure definition
  7037. *------------------------------------------*/
  7038. AtCommandInfo atcommand_info[] = {
  7039. { "rura", 40, atcommand_mapmove },
  7040. { "warp", 40, atcommand_mapmove },
  7041. { "mapmove", 40, atcommand_mapmove }, // + /mm
  7042. { "where", 1, atcommand_where },
  7043. { "jumpto", 20, atcommand_jumpto }, // + /shift
  7044. { "warpto", 20, atcommand_jumpto },
  7045. { "goto", 20, atcommand_jumpto },
  7046. { "jump", 40, atcommand_jump },
  7047. { "who", 20, atcommand_who },
  7048. { "whois", 20, atcommand_who },
  7049. { "who2", 20, atcommand_who2 },
  7050. { "who3", 20, atcommand_who3 },
  7051. { "whomap", 20, atcommand_whomap },
  7052. { "whomap2", 20, atcommand_whomap2 },
  7053. { "whomap3", 20, atcommand_whomap3 },
  7054. { "whogm", 20, atcommand_whogm },
  7055. { "save", 40, atcommand_save },
  7056. { "return", 40, atcommand_load },
  7057. { "load", 40, atcommand_load },
  7058. { "speed", 40, atcommand_speed },
  7059. { "storage", 1, atcommand_storage },
  7060. { "gstorage", 50, atcommand_guildstorage },
  7061. { "option", 40, atcommand_option },
  7062. { "hide", 40, atcommand_hide }, // + /hide
  7063. { "jobchange", 40, atcommand_jobchange },
  7064. { "job", 40, atcommand_jobchange },
  7065. { "die", 1, atcommand_die },
  7066. { "kill", 60, atcommand_kill },
  7067. { "alive", 60, atcommand_alive },
  7068. { "kami", 40, atcommand_kami },
  7069. { "kamib", 40, atcommand_kami },
  7070. { "kamic", 40, atcommand_kami },
  7071. { "heal", 40, atcommand_heal },
  7072. { "item", 60, atcommand_item },
  7073. { "item2", 60, atcommand_item2 },
  7074. { "itemreset", 40, atcommand_itemreset },
  7075. { "blvl", 60, atcommand_baselevelup },
  7076. { "lvup", 60, atcommand_baselevelup },
  7077. { "blevel", 60, atcommand_baselevelup },
  7078. { "baselvl", 60, atcommand_baselevelup },
  7079. { "baselvup", 60, atcommand_baselevelup },
  7080. { "baselevel", 60, atcommand_baselevelup },
  7081. { "baselvlup", 60, atcommand_baselevelup },
  7082. { "jlvl", 60, atcommand_joblevelup },
  7083. { "jlevel", 60, atcommand_joblevelup },
  7084. { "joblvl", 60, atcommand_joblevelup },
  7085. { "joblevel", 60, atcommand_joblevelup },
  7086. { "joblvup", 60, atcommand_joblevelup },
  7087. { "joblvlup", 60, atcommand_joblevelup },
  7088. { "h", 20, atcommand_help },
  7089. { "help", 20, atcommand_help },
  7090. { "h2", 20, atcommand_help2 },
  7091. { "help2", 20, atcommand_help2 },
  7092. { "gm", 100, atcommand_gm },
  7093. { "pvpoff", 40, atcommand_pvpoff },
  7094. { "pvpon", 40, atcommand_pvpon },
  7095. { "gvgoff", 40, atcommand_gvgoff },
  7096. { "gpvpoff", 40, atcommand_gvgoff },
  7097. { "gvgon", 40, atcommand_gvgon },
  7098. { "gpvpon", 40, atcommand_gvgon },
  7099. { "model", 20, atcommand_model },
  7100. { "go", 10, atcommand_go },
  7101. { "monster", 50, atcommand_monster },
  7102. { "spawn", 50, atcommand_monster },
  7103. { "monstersmall", 50, atcommand_monstersmall },
  7104. { "monsterbig", 50, atcommand_monsterbig },
  7105. { "killmonster", 60, atcommand_killmonster },
  7106. { "killmonster2", 40, atcommand_killmonster2 },
  7107. { "refine", 60, atcommand_refine },
  7108. { "produce", 60, atcommand_produce },
  7109. { "memo", 40, atcommand_memo },
  7110. { "gat", 99, atcommand_gat },
  7111. { "displaystatus", 99, atcommand_displaystatus },
  7112. { "stpoint", 60, atcommand_statuspoint },
  7113. { "skpoint", 60, atcommand_skillpoint },
  7114. { "zeny", 60, atcommand_zeny },
  7115. { "str", 60, atcommand_param },
  7116. { "agi", 60, atcommand_param },
  7117. { "vit", 60, atcommand_param },
  7118. { "int", 60, atcommand_param },
  7119. { "dex", 60, atcommand_param },
  7120. { "luk", 60, atcommand_param },
  7121. { "glvl", 60, atcommand_guildlevelup },
  7122. { "glevel", 60, atcommand_guildlevelup },
  7123. { "guildlvl", 60, atcommand_guildlevelup },
  7124. { "guildlvup", 60, atcommand_guildlevelup },
  7125. { "guildlevel", 60, atcommand_guildlevelup },
  7126. { "guildlvlup", 60, atcommand_guildlevelup },
  7127. { "makeegg", 60, atcommand_makeegg },
  7128. { "hatch", 60, atcommand_hatch },
  7129. { "petfriendly", 40, atcommand_petfriendly },
  7130. { "pethungry", 40, atcommand_pethungry },
  7131. { "petrename", 1, atcommand_petrename },
  7132. { "recall", 60, atcommand_recall }, // + /recall
  7133. { "night", 80, atcommand_night },
  7134. { "day", 80, atcommand_day },
  7135. { "doom", 80, atcommand_doom },
  7136. { "doommap", 80, atcommand_doommap },
  7137. { "raise", 80, atcommand_raise },
  7138. { "raisemap", 80, atcommand_raisemap },
  7139. { "kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7140. { "kickall", 99, atcommand_kickall },
  7141. { "allskill", 60, atcommand_allskill },
  7142. { "allskills", 60, atcommand_allskill },
  7143. { "skillall", 60, atcommand_allskill },
  7144. { "skillsall", 60, atcommand_allskill },
  7145. { "questskill", 40, atcommand_questskill },
  7146. { "lostskill", 40, atcommand_lostskill },
  7147. { "spiritball", 40, atcommand_spiritball },
  7148. { "party", 1, atcommand_party },
  7149. { "guild", 50, atcommand_guild },
  7150. { "agitstart", 60, atcommand_agitstart },
  7151. { "agitend", 60, atcommand_agitend },
  7152. { "mapexit", 99, atcommand_mapexit },
  7153. { "idsearch", 60, atcommand_idsearch },
  7154. { "broadcast", 40, atcommand_broadcast }, // + /b and /nb
  7155. { "localbroadcast", 40, atcommand_localbroadcast }, // + /lb and /nlb
  7156. { "recallall", 80, atcommand_recallall },
  7157. { "reloaditemdb", 99, atcommand_reloaditemdb },
  7158. { "reloadmobdb", 99, atcommand_reloadmobdb },
  7159. { "reloadskilldb", 99, atcommand_reloadskilldb },
  7160. { "reloadscript", 99, atcommand_reloadscript },
  7161. { "reloadgmdb", 99, atcommand_reloadgmdb },
  7162. { "reloadatcommand", 99, atcommand_reloadatcommand },
  7163. { "reloadbattleconf", 99, atcommand_reloadbattleconf },
  7164. { "reloadstatusdb", 99, atcommand_reloadstatusdb },
  7165. { "reloadpcdb", 99, atcommand_reloadpcdb },
  7166. { "reloadmotd", 99, atcommand_reloadmotd },
  7167. { "mapinfo", 99, atcommand_mapinfo },
  7168. { "dye", 40, atcommand_dye },
  7169. { "ccolor", 40, atcommand_dye },
  7170. { "hairstyle", 40, atcommand_hair_style },
  7171. { "hstyle", 40, atcommand_hair_style },
  7172. { "haircolor", 40, atcommand_hair_color },
  7173. { "hcolor", 40, atcommand_hair_color },
  7174. { "statall", 60, atcommand_stat_all },
  7175. { "statsall", 60, atcommand_stat_all },
  7176. { "allstats", 60, atcommand_stat_all },
  7177. { "allstat", 60, atcommand_stat_all },
  7178. { "block", 60, atcommand_char_block },
  7179. { "charblock", 60, atcommand_char_block },
  7180. { "ban", 60, atcommand_char_ban },
  7181. { "banish", 60, atcommand_char_ban },
  7182. { "charban", 60, atcommand_char_ban },
  7183. { "charbanish", 60, atcommand_char_ban },
  7184. { "unblock", 60, atcommand_char_unblock },
  7185. { "charunblock", 60, atcommand_char_unblock },
  7186. { "unban", 60, atcommand_char_unban },
  7187. { "unbanish", 60, atcommand_char_unban },
  7188. { "charunban", 60, atcommand_char_unban },
  7189. { "charunbanish", 60, atcommand_char_unban },
  7190. { "mount", 20, atcommand_mount_peco },
  7191. { "mountpeco", 20, atcommand_mount_peco },
  7192. { "guildspy", 60, atcommand_guildspy },
  7193. { "partyspy", 60, atcommand_partyspy },
  7194. { "repairall", 60, atcommand_repairall },
  7195. { "guildrecall", 60, atcommand_guildrecall },
  7196. { "partyrecall", 60, atcommand_partyrecall },
  7197. { "nuke", 60, atcommand_nuke },
  7198. { "shownpc", 80, atcommand_shownpc },
  7199. { "hidenpc", 80, atcommand_hidenpc },
  7200. { "loadnpc", 80, atcommand_loadnpc },
  7201. { "unloadnpc", 80, atcommand_unloadnpc },
  7202. { "time", 1, atcommand_servertime },
  7203. { "date", 1, atcommand_servertime },
  7204. { "serverdate", 1, atcommand_servertime },
  7205. { "servertime", 1, atcommand_servertime },
  7206. { "jail", 60, atcommand_jail },
  7207. { "unjail", 60, atcommand_unjail },
  7208. { "discharge", 60, atcommand_unjail },
  7209. { "jailfor", 60, atcommand_jailfor },
  7210. { "jailtime", 1, atcommand_jailtime },
  7211. { "disguise", 20, atcommand_disguise },
  7212. { "undisguise", 20, atcommand_undisguise },
  7213. { "email", 1, atcommand_email },
  7214. { "effect", 40, atcommand_effect },
  7215. { "follow", 20, atcommand_follow },
  7216. { "addwarp", 60, atcommand_addwarp },
  7217. { "skillon", 80, atcommand_skillon },
  7218. { "skilloff", 80, atcommand_skilloff },
  7219. { "killer", 60, atcommand_killer },
  7220. { "npcmove", 80, atcommand_npcmove },
  7221. { "killable", 40, atcommand_killable },
  7222. { "dropall", 40, atcommand_dropall },
  7223. { "storeall", 40, atcommand_storeall },
  7224. { "skillid", 40, atcommand_skillid },
  7225. { "useskill", 40, atcommand_useskill },
  7226. { "displayskill", 99, atcommand_displayskill },
  7227. { "snow", 99, atcommand_snow },
  7228. { "sakura", 99, atcommand_sakura },
  7229. { "clouds", 99, atcommand_clouds },
  7230. { "clouds2", 99, atcommand_clouds2 },
  7231. { "fog", 99, atcommand_fog },
  7232. { "fireworks", 99, atcommand_fireworks },
  7233. { "leaves", 99, atcommand_leaves },
  7234. { "summon", 60, atcommand_summon },
  7235. { "adjgmlvl", 99, atcommand_adjgmlvl },
  7236. { "adjcmdlvl", 99, atcommand_adjcmdlvl },
  7237. { "trade", 60, atcommand_trade },
  7238. { "send", 99, atcommand_send },
  7239. { "setbattleflag", 99, atcommand_setbattleflag },
  7240. { "unmute", 80, atcommand_unmute },
  7241. { "clearweather", 99, atcommand_clearweather },
  7242. { "uptime", 1, atcommand_uptime },
  7243. { "changesex", 60, atcommand_changesex },
  7244. { "mute", 80, atcommand_mute },
  7245. { "refresh", 1, atcommand_refresh },
  7246. { "identify", 40, atcommand_identify },
  7247. { "gmotd", 20, atcommand_gmotd },
  7248. { "misceffect", 50, atcommand_misceffect },
  7249. { "mobsearch", 10, atcommand_mobsearch },
  7250. { "cleanmap", 40, atcommand_cleanmap },
  7251. { "npctalk", 20, atcommand_npctalk },
  7252. { "pettalk", 10, atcommand_pettalk },
  7253. { "users", 40, atcommand_users },
  7254. { "reset", 40, atcommand_reset },
  7255. { "skilltree", 40, atcommand_skilltree },
  7256. { "marry", 40, atcommand_marry },
  7257. { "divorce", 40, atcommand_divorce },
  7258. { "sound", 40, atcommand_sound },
  7259. { "undisguiseall", 99, atcommand_undisguiseall },
  7260. { "disguiseall", 99, atcommand_disguiseall },
  7261. { "changelook", 60, atcommand_changelook },
  7262. { "autoloot", 10, atcommand_autoloot },
  7263. { "alootid", 10, atcommand_autolootitem },
  7264. { "mobinfo", 1, atcommand_mobinfo },
  7265. { "monsterinfo", 1, atcommand_mobinfo },
  7266. { "mi", 1, atcommand_mobinfo },
  7267. { "exp", 1, atcommand_exp },
  7268. { "adopt", 40, atcommand_adopt },
  7269. { "version", 1, atcommand_version },
  7270. { "mutearea", 99, atcommand_mutearea },
  7271. { "stfu", 99, atcommand_mutearea },
  7272. { "rates", 1, atcommand_rates },
  7273. { "iteminfo", 1, atcommand_iteminfo },
  7274. { "ii", 1, atcommand_iteminfo },
  7275. { "whodrops", 1, atcommand_whodrops },
  7276. { "whereis", 10, atcommand_whereis },
  7277. { "mapflag", 99, atcommand_mapflag },
  7278. { "me", 20, atcommand_me },
  7279. { "monsterignore", 99, atcommand_monsterignore },
  7280. { "battleignore", 99, atcommand_monsterignore },
  7281. { "fakename", 20, atcommand_fakename },
  7282. { "size", 20, atcommand_size },
  7283. { "showexp", 10, atcommand_showexp},
  7284. { "showzeny", 10, atcommand_showzeny},
  7285. { "showdelay", 1, atcommand_showdelay},
  7286. { "autotrade", 10, atcommand_autotrade },
  7287. { "at", 10, atcommand_autotrade },
  7288. { "changegm", 10, atcommand_changegm },
  7289. { "changeleader", 10, atcommand_changeleader },
  7290. { "partyoption", 10, atcommand_partyoption},
  7291. { "invite", 1, atcommand_invite },
  7292. { "duel", 1, atcommand_duel },
  7293. { "leave", 1, atcommand_leave },
  7294. { "accept", 1, atcommand_accept },
  7295. { "reject", 1, atcommand_reject },
  7296. { "away", 1, atcommand_away },
  7297. { "aw", 1, atcommand_away },
  7298. { "main", 1, atcommand_main },
  7299. { "clone", 50, atcommand_clone },
  7300. { "slaveclone", 50, atcommand_clone },
  7301. { "evilclone", 50, atcommand_clone },
  7302. { "tonpc", 40, atcommand_tonpc },
  7303. { "commands", 1, atcommand_commands },
  7304. { "noask", 1, atcommand_noask },
  7305. { "request", 20, atcommand_request },
  7306. { "hlvl", 60, atcommand_homlevel },
  7307. { "hlevel", 60, atcommand_homlevel },
  7308. { "homlvl", 60, atcommand_homlevel },
  7309. { "homlvup", 60, atcommand_homlevel },
  7310. { "homlevel", 60, atcommand_homlevel },
  7311. { "homevolve", 60, atcommand_homevolution },
  7312. { "homevolution", 60, atcommand_homevolution },
  7313. { "makehomun", 60, atcommand_makehomun },
  7314. { "homfriendly", 60, atcommand_homfriendly },
  7315. { "homhungry", 60, atcommand_homhungry },
  7316. { "homtalk", 10, atcommand_homtalk },
  7317. { "hominfo", 1, atcommand_hominfo },
  7318. { "homstats", 1, atcommand_homstats },
  7319. { "homshuffle", 60, atcommand_homshuffle },
  7320. { "showmobs", 10, atcommand_showmobs },
  7321. { "feelreset", 10, atcommand_feelreset },
  7322. { "auction", 60, atcommand_auction },
  7323. { "mail", 1, atcommand_mail },
  7324. { "noks", 0, atcommand_ksprotection },
  7325. { "allowks", 6, atcommand_allowks },
  7326. { "cash", 60, atcommand_cash },
  7327. { "points", 60, atcommand_cash },
  7328. };
  7329. /*==========================================
  7330. * Command lookup functions
  7331. *------------------------------------------*/
  7332. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  7333. {
  7334. int i;
  7335. if( *name == atcommand_symbol ) name++; // for backwards compatibility
  7336. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  7337. return ( i != ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7338. }
  7339. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  7340. {
  7341. int i;
  7342. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  7343. return ( i != ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7344. }
  7345. /*==========================================
  7346. * Retrieve the command's required gm level
  7347. *------------------------------------------*/
  7348. int get_atcommand_level(const AtCommandFunc func)
  7349. {
  7350. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  7351. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7352. }
  7353. /// Executes an at-command.
  7354. /// To be called by internal server code (bypasses various restrictions).
  7355. bool is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  7356. {
  7357. AtCommandInfo* info;
  7358. char command[100];
  7359. char args[100];
  7360. char output[200];
  7361. if( !str || !*str )
  7362. return false;
  7363. if( *str != atcommand_symbol ) // check first char
  7364. return false;
  7365. if( sscanf(str, "%99s %99[^\n]", command, args) < 2 )
  7366. args[0] = '\0';
  7367. info = get_atcommandinfo_byname(command);
  7368. if( info == NULL || info->func == NULL || gmlvl < info->level )
  7369. {
  7370. if( gmlvl == 0 )
  7371. return false; // will just display as normal text
  7372. else
  7373. {
  7374. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7375. clif_displaymessage(fd, output);
  7376. return true;
  7377. }
  7378. }
  7379. if( log_config.gm && info->level >= log_config.gm )
  7380. log_atcommand(sd, str);
  7381. if( info->func(fd, sd, command, args) != 0 )
  7382. {
  7383. sprintf(output, msg_txt(154), command); // "%s failed."
  7384. clif_displaymessage(fd, output);
  7385. }
  7386. return true;
  7387. }
  7388. /// Executes an at-command.
  7389. /// To be used by player-invoked code (restrictions will be applied).
  7390. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  7391. {
  7392. int gmlvl = pc_isGM(sd);
  7393. nullpo_retr(false, sd);
  7394. if( !message || !*message )
  7395. return false; // shouldn't happen
  7396. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7397. return true; // so that it won't display as normal message
  7398. if( battle_config.atc_gmonly != 0 && gmlvl == 0 )
  7399. return false;
  7400. if( map[sd->bl.m].nocommand && gmlvl < map[sd->bl.m].nocommand )
  7401. {
  7402. clif_displaymessage(fd, msg_txt(143)); // "Commands are disabled on this map."
  7403. return false;
  7404. }
  7405. // skip 10/11-langtype's codepage indicator, if detected
  7406. if( message[0] == '|' && strlen(message) >= 4 && message[3] == atcommand_symbol )
  7407. message += 3;
  7408. return is_atcommand_sub(fd,sd,message,gmlvl);
  7409. }
  7410. /*==========================================
  7411. *
  7412. *------------------------------------------*/
  7413. int atcommand_config_read(const char* cfgName)
  7414. {
  7415. char line[1024], w1[1024], w2[1024];
  7416. AtCommandInfo* p;
  7417. FILE* fp;
  7418. if( (fp = fopen(cfgName, "r")) == NULL )
  7419. {
  7420. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  7421. return 1;
  7422. }
  7423. while( fgets(line, sizeof(line), fp) )
  7424. {
  7425. if( line[0] == '/' && line[1] == '/' )
  7426. continue;
  7427. if( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2 )
  7428. continue;
  7429. p = get_atcommandinfo_byname(w1);
  7430. if( p != NULL )
  7431. {
  7432. p->level = atoi(w2);
  7433. p->level = cap_value(p->level, 0, 100);
  7434. }
  7435. else
  7436. if( strcmpi(w1, "import") == 0 )
  7437. atcommand_config_read(w2);
  7438. else
  7439. if( strcmpi(w1, "command_symbol") == 0 &&
  7440. w2[0] > 31 && // control characters
  7441. w2[0] != '/' && // symbol of standard ragnarok GM commands
  7442. w2[0] != '%' && // symbol of party chat speaking
  7443. w2[0] != '$' && // symbol of guild chat speaking
  7444. w2[0] != '#' ) // symbol of charcommand
  7445. atcommand_symbol = w2[0];
  7446. else
  7447. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  7448. }
  7449. fclose(fp);
  7450. return 0;
  7451. }
  7452. void do_init_atcommand()
  7453. {
  7454. users_db = uidb_alloc(DB_OPT_BASE);
  7455. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  7456. return;
  7457. }
  7458. void do_final_atcommand()
  7459. {
  7460. users_db->destroy(users_db,NULL);
  7461. }
  7462. // commands that need to go _after_ the commands table
  7463. /*==========================================
  7464. * @commands Lists available @ commands to you
  7465. *------------------------------------------*/
  7466. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7467. {
  7468. char line_buff[CHATBOX_SIZE];
  7469. int i, gm_lvl = pc_isGM(sd), count = 0;
  7470. char* cur = line_buff;
  7471. memset(line_buff,' ',CHATBOX_SIZE);
  7472. line_buff[CHATBOX_SIZE-1] = 0;
  7473. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7474. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  7475. {
  7476. unsigned int slen;
  7477. if( gm_lvl < atcommand_info[i].level )
  7478. continue;
  7479. slen = (unsigned int)strlen(atcommand_info[i].command);
  7480. // flush the text buffer if this command won't fit into it
  7481. if( ((CHATBOX_SIZE-1+(int)line_buff)-(int)cur) < (int)slen )
  7482. {
  7483. clif_displaymessage(fd,line_buff);
  7484. cur = line_buff;
  7485. memset(line_buff,' ',CHATBOX_SIZE);
  7486. line_buff[CHATBOX_SIZE-1] = 0;
  7487. }
  7488. memcpy(cur,atcommand_info[i].command,slen);
  7489. cur += slen+(10-slen%10);
  7490. count++;
  7491. }
  7492. clif_displaymessage(fd,line_buff);
  7493. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7494. clif_displaymessage(fd, atcmd_output);
  7495. return 0;
  7496. }