atcommand.c 317 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include "../common/cbasetypes.h"
  9. #include "../common/mmo.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/core.h"
  13. #include "../common/showmsg.h"
  14. #include "../common/malloc.h"
  15. #include "../common/socket.h"
  16. #include "atcommand.h"
  17. #include "log.h"
  18. #include "clif.h"
  19. #include "chrif.h"
  20. #include "intif.h"
  21. #include "itemdb.h"
  22. #include "map.h"
  23. #include "pc.h"
  24. #include "status.h"
  25. #include "skill.h"
  26. #include "mob.h"
  27. #include "npc.h"
  28. #include "pet.h"
  29. #include "mercenary.h" //[orn]
  30. #include "battle.h"
  31. #include "party.h"
  32. #include "guild.h"
  33. #include "script.h"
  34. #include "npc.h"
  35. #include "trade.h"
  36. #include "unit.h"
  37. #ifndef TXT_ONLY
  38. #include "mail.h"
  39. #endif
  40. char atcommand_symbol = '@'; // first char of the commands (by [Yor])
  41. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  42. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  43. ACMD_FUNC(broadcast);
  44. ACMD_FUNC(localbroadcast);
  45. ACMD_FUNC(rura);
  46. ACMD_FUNC(where);
  47. ACMD_FUNC(jumpto);
  48. ACMD_FUNC(jump);
  49. ACMD_FUNC(who);
  50. ACMD_FUNC(who2);
  51. ACMD_FUNC(who3);
  52. ACMD_FUNC(whomap);
  53. ACMD_FUNC(whomap2);
  54. ACMD_FUNC(whomap3);
  55. ACMD_FUNC(whogm); // by Yor
  56. ACMD_FUNC(whozeny); // [Valaris]
  57. ACMD_FUNC(save);
  58. ACMD_FUNC(load);
  59. ACMD_FUNC(speed);
  60. ACMD_FUNC(charspeed);
  61. ACMD_FUNC(storage);
  62. ACMD_FUNC(guildstorage);
  63. ACMD_FUNC(option);
  64. ACMD_FUNC(hide);
  65. ACMD_FUNC(jobchange);
  66. ACMD_FUNC(die);
  67. ACMD_FUNC(kill);
  68. ACMD_FUNC(alive);
  69. ACMD_FUNC(kami);
  70. ACMD_FUNC(heal);
  71. ACMD_FUNC(item);
  72. ACMD_FUNC(item2);
  73. ACMD_FUNC(itemreset);
  74. ACMD_FUNC(baselevelup);
  75. ACMD_FUNC(joblevelup);
  76. ACMD_FUNC(help);
  77. ACMD_FUNC(help2);
  78. ACMD_FUNC(gm);
  79. ACMD_FUNC(pvpoff);
  80. ACMD_FUNC(pvpon);
  81. ACMD_FUNC(gvgoff);
  82. ACMD_FUNC(gvgon);
  83. ACMD_FUNC(model);
  84. ACMD_FUNC(go);
  85. ACMD_FUNC(monster);
  86. ACMD_FUNC(monstersmall);
  87. ACMD_FUNC(monsterbig);
  88. ACMD_FUNC(spawn);
  89. ACMD_FUNC(killmonster);
  90. ACMD_FUNC(killmonster2);
  91. ACMD_FUNC(refine);
  92. ACMD_FUNC(produce);
  93. ACMD_FUNC(memo);
  94. ACMD_FUNC(gat);
  95. ACMD_FUNC(packet);
  96. ACMD_FUNC(statuspoint);
  97. ACMD_FUNC(skillpoint);
  98. ACMD_FUNC(zeny);
  99. ACMD_FUNC(param);
  100. ACMD_FUNC(guildlevelup);
  101. ACMD_FUNC(makeegg);
  102. ACMD_FUNC(hatch);
  103. ACMD_FUNC(petfriendly);
  104. ACMD_FUNC(pethungry);
  105. ACMD_FUNC(petrename);
  106. ACMD_FUNC(recall);
  107. ACMD_FUNC(recallall);
  108. ACMD_FUNC(revive);
  109. ACMD_FUNC(night);
  110. ACMD_FUNC(day);
  111. ACMD_FUNC(doom);
  112. ACMD_FUNC(doommap);
  113. ACMD_FUNC(raise);
  114. ACMD_FUNC(raisemap);
  115. ACMD_FUNC(kick);
  116. ACMD_FUNC(kickall);
  117. ACMD_FUNC(allskill);
  118. ACMD_FUNC(questskill);
  119. ACMD_FUNC(lostskill);
  120. ACMD_FUNC(spiritball);
  121. ACMD_FUNC(party);
  122. ACMD_FUNC(guild);
  123. ACMD_FUNC(agitstart);
  124. ACMD_FUNC(agitend);
  125. ACMD_FUNC(reloaditemdb);
  126. ACMD_FUNC(reloadmobdb);
  127. ACMD_FUNC(reloadskilldb);
  128. ACMD_FUNC(reloadscript);
  129. ACMD_FUNC(reloadgmdb); // by Yor
  130. ACMD_FUNC(reloadatcommand);
  131. ACMD_FUNC(reloadbattleconf);
  132. ACMD_FUNC(reloadstatusdb);
  133. ACMD_FUNC(reloadpcdb);
  134. ACMD_FUNC(reloadmotd); // [Valaris]
  135. ACMD_FUNC(mapexit);
  136. ACMD_FUNC(idsearch);
  137. ACMD_FUNC(mapinfo);
  138. ACMD_FUNC(dye); //** by fritz
  139. ACMD_FUNC(hair_style); //** by fritz
  140. ACMD_FUNC(hair_color); //** by fritz
  141. ACMD_FUNC(stat_all); //** by fritz
  142. ACMD_FUNC(char_block); // by Yor
  143. ACMD_FUNC(char_ban); // by Yor
  144. ACMD_FUNC(char_unblock); // by Yor
  145. ACMD_FUNC(char_unban); // by Yor
  146. ACMD_FUNC(mount_peco); // by Valaris
  147. ACMD_FUNC(char_mount_peco); // by Yor
  148. ACMD_FUNC(guildspy); // [Syrus22]
  149. ACMD_FUNC(partyspy); // [Syrus22]
  150. ACMD_FUNC(repairall); // [Valaris]
  151. ACMD_FUNC(guildrecall); // by Yor
  152. ACMD_FUNC(partyrecall); // by Yor
  153. ACMD_FUNC(nuke); // [Valaris]
  154. ACMD_FUNC(shownpc);
  155. ACMD_FUNC(hidenpc);
  156. ACMD_FUNC(loadnpc);
  157. ACMD_FUNC(unloadnpc);
  158. ACMD_FUNC(servertime); // by Yor
  159. ACMD_FUNC(chardelitem); // by Yor
  160. ACMD_FUNC(jail); // by Yor
  161. ACMD_FUNC(unjail); // by Yor
  162. ACMD_FUNC(jailfor); // Alias Meruru
  163. ACMD_FUNC(jailtime); // Coltaro
  164. ACMD_FUNC(charjailtime); // Coltaro
  165. ACMD_FUNC(disguise); // [Valaris]
  166. ACMD_FUNC(undisguise); // by Yor
  167. ACMD_FUNC(chardisguise); // Kalaspuff
  168. ACMD_FUNC(charundisguise); // Kalaspuff
  169. ACMD_FUNC(email); // by Yor
  170. ACMD_FUNC(effect);//by Apple
  171. ACMD_FUNC(character_cart_list); // by Yor
  172. ACMD_FUNC(addwarp); // by MouseJstr
  173. ACMD_FUNC(follow); // by MouseJstr
  174. ACMD_FUNC(skillon); // by MouseJstr
  175. ACMD_FUNC(skilloff); // by MouseJstr
  176. ACMD_FUNC(killer); // by MouseJstr
  177. ACMD_FUNC(npcmove); // by MouseJstr
  178. ACMD_FUNC(killable); // by MouseJstr
  179. ACMD_FUNC(charkillable); // by MouseJstr
  180. ACMD_FUNC(dropall); // by MouseJstr
  181. ACMD_FUNC(chardropall); // by MouseJstr
  182. ACMD_FUNC(storeall); // by MouseJstr
  183. ACMD_FUNC(charstoreall); // by MouseJstr
  184. ACMD_FUNC(skillid); // by MouseJstr
  185. ACMD_FUNC(useskill); // by MouseJstr
  186. ACMD_FUNC(summon);
  187. ACMD_FUNC(rain);
  188. ACMD_FUNC(snow);
  189. ACMD_FUNC(sakura);
  190. ACMD_FUNC(clouds);
  191. ACMD_FUNC(clouds2); // [Valaris]
  192. ACMD_FUNC(fog);
  193. ACMD_FUNC(fireworks);
  194. ACMD_FUNC(leaves);
  195. ACMD_FUNC(adjgmlvl); // by MouseJstr
  196. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  197. ACMD_FUNC(trade); // by MouseJstr
  198. ACMD_FUNC(send); // by davidsiaw
  199. ACMD_FUNC(setbattleflag); // by MouseJstr
  200. ACMD_FUNC(unmute); // [Valaris]
  201. ACMD_FUNC(clearweather); // Dexity
  202. ACMD_FUNC(uptime); // by MC Cameri
  203. ACMD_FUNC(changesex); // by MC Cameri
  204. ACMD_FUNC(mute); // celest
  205. ACMD_FUNC(refresh); // by MC Cameri
  206. ACMD_FUNC(petid); // by MC Cameri
  207. ACMD_FUNC(identify); // by MC Cameri
  208. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  209. ACMD_FUNC(misceffect); // by MC Cameri
  210. ACMD_FUNC(mobsearch);
  211. ACMD_FUNC(cleanmap);
  212. ACMD_FUNC(npctalk);
  213. ACMD_FUNC(pettalk);
  214. ACMD_FUNC(users);
  215. ACMD_FUNC(reset);
  216. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  217. #ifndef TXT_ONLY
  218. ACMD_FUNC(checkmail); // [Valaris]
  219. ACMD_FUNC(listmail); // [Valaris]
  220. ACMD_FUNC(listnewmail); // [Valaris]
  221. ACMD_FUNC(readmail); // [Valaris]
  222. ACMD_FUNC(sendmail); // [Valaris]
  223. ACMD_FUNC(sendprioritymail); // [Valaris]
  224. ACMD_FUNC(deletemail); // [Valaris]
  225. ACMD_FUNC(refreshonline); // [Valaris]
  226. #endif /* TXT_ONLY */
  227. ACMD_FUNC(skilltree); // by MouseJstr
  228. ACMD_FUNC(marry); // by MouseJstr
  229. ACMD_FUNC(divorce); // by MouseJstr
  230. ACMD_FUNC(grind); // by MouseJstr
  231. ACMD_FUNC(grind2); // by MouseJstr
  232. #ifdef DMALLOC
  233. ACMD_FUNC(dmstart); // by MouseJstr
  234. ACMD_FUNC(dmtick); // by MouseJstr
  235. #endif
  236. ACMD_FUNC(jumptoid); // by Dino9021
  237. ACMD_FUNC(jumptoid2); // by Dino9021
  238. ACMD_FUNC(recallid); // by Dino9021
  239. ACMD_FUNC(recallid2); // by Dino9021
  240. ACMD_FUNC(kickid); // by Dino9021
  241. ACMD_FUNC(kickid2); // by Dino9021
  242. ACMD_FUNC(reviveid); // by Dino9021
  243. ACMD_FUNC(reviveid2); // by Dino9021
  244. ACMD_FUNC(killid); // by Dino9021
  245. ACMD_FUNC(killid2); // by Dino9021
  246. ACMD_FUNC(charkillableid); // by Dino9021
  247. ACMD_FUNC(charkillableid2); // by Dino9021
  248. ACMD_FUNC(sound);
  249. ACMD_FUNC(undisguiseall);
  250. ACMD_FUNC(disguiseall);
  251. ACMD_FUNC(changelook);
  252. ACMD_FUNC(mobinfo); //by Lupus
  253. ACMD_FUNC(exp); // by Skotlex
  254. ACMD_FUNC(adopt); // by Veider
  255. ACMD_FUNC(version); // by Ancyker
  256. ACMD_FUNC(mutearea); // by MouseJstr
  257. ACMD_FUNC(rates); // by MouseJstr
  258. ACMD_FUNC(iteminfo); // Lupus
  259. ACMD_FUNC(whodrops); //Skotlex
  260. ACMD_FUNC(mapflag); // Lupus
  261. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  262. ACMD_FUNC(monsterignore); // [Valaris]
  263. ACMD_FUNC(fakename); //[Valaris]
  264. ACMD_FUNC(size); //[Valaris]
  265. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  266. ACMD_FUNC(showzeny);
  267. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  268. ACMD_FUNC(autotrade);// durf
  269. ACMD_FUNC(changeleader);// [Skotlex]
  270. ACMD_FUNC(partyoption);// [Skotlex]
  271. ACMD_FUNC(changegm);// durf
  272. // Duel [LuzZza]
  273. ACMD_FUNC(invite);
  274. ACMD_FUNC(duel);
  275. ACMD_FUNC(leave);
  276. ACMD_FUNC(accept);
  277. ACMD_FUNC(reject);
  278. ACMD_FUNC(away); // LuzZza
  279. ACMD_FUNC(main); // LuzZza
  280. ACMD_FUNC(clone); // [Valaris]
  281. ACMD_FUNC(tonpc); // LuzZza
  282. ACMD_FUNC(commands); // [Skotlex]
  283. ACMD_FUNC(noask); //LuzZza
  284. ACMD_FUNC(request); //[Skotlex]
  285. ACMD_FUNC(homlevel); //[orn]
  286. ACMD_FUNC(homevolution); //[orn]
  287. ACMD_FUNC(makehomun); //[orn]
  288. ACMD_FUNC(homfriendly); //[orn]
  289. ACMD_FUNC(homhungry); //[orn]
  290. ACMD_FUNC(homtalk); //[orn]
  291. ACMD_FUNC(hominfo); //[Toms]
  292. ACMD_FUNC(homstats); //[Skotlex]
  293. ACMD_FUNC(homshuffle); //[Skotlex]
  294. ACMD_FUNC(showmobs); //KarLaeda
  295. /*==========================================
  296. *AtCommandInfo atcommand_info[] structure definition
  297. *------------------------------------------
  298. */
  299. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  300. // to set default level, read atcommand_athena.conf first please.
  301. static AtCommandInfo atcommand_info[] = {
  302. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  303. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  304. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  305. { AtCommand_Where, "@where", 1, atcommand_where },
  306. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  307. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  308. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  309. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  310. { AtCommand_Who, "@who", 20, atcommand_who },
  311. { AtCommand_Who, "@whois", 20, atcommand_who },
  312. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  313. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  314. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  315. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  316. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  317. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  318. { AtCommand_Save, "@save", 40, atcommand_save },
  319. { AtCommand_Load, "@return", 40, atcommand_load },
  320. { AtCommand_Load, "@load", 40, atcommand_load },
  321. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  322. { AtCommand_CharSpeed, "@charspeed", 40, atcommand_charspeed },
  323. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  324. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  325. { AtCommand_Option, "@option", 40, atcommand_option },
  326. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  327. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  328. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  329. { AtCommand_Die, "@die", 1, atcommand_die },
  330. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  331. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  332. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  333. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  334. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  335. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  336. { AtCommand_Item, "@item", 60, atcommand_item },
  337. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  338. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  339. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  340. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  341. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  342. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  343. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  344. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  345. { AtCommand_H, "@h", 20, atcommand_help },
  346. { AtCommand_Help, "@help", 20, atcommand_help },
  347. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  348. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  349. { AtCommand_GM, "@gm", 100, atcommand_gm },
  350. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  351. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  352. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  353. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  354. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  355. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  356. { AtCommand_Model, "@model", 20, atcommand_model },
  357. { AtCommand_Go, "@go", 10, atcommand_go },
  358. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  359. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  360. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  361. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  362. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  363. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  364. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  365. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  366. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  367. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  368. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  369. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  370. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  371. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  372. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  373. { AtCommand_Strength, "@str", 60, atcommand_param },
  374. { AtCommand_Agility, "@agi", 60, atcommand_param },
  375. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  376. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  377. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  378. { AtCommand_Luck, "@luk", 60, atcommand_param },
  379. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  380. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  381. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  382. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  383. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  384. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  385. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  386. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  387. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  388. { AtCommand_Night, "@night", 80, atcommand_night },
  389. { AtCommand_Day, "@day", 80, atcommand_day },
  390. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  391. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  392. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  393. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  394. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  395. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  396. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  397. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  398. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  399. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  400. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  401. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  402. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  403. { AtCommand_Party, "@party", 1, atcommand_party },
  404. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  405. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  406. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  407. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  408. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  409. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  410. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  411. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  412. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  413. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  414. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  415. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  416. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  417. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  418. { AtCommand_ReloadBattleConf, "@reloadbattleconf",99, atcommand_reloadbattleconf },
  419. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  420. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  421. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  422. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  423. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  424. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  425. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  426. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  427. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  428. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  429. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  430. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  431. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  432. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  433. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  434. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  435. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  436. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  437. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  438. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  439. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  440. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  441. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  442. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  443. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  444. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  445. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  446. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  447. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  448. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  449. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  450. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  451. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  452. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  453. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  454. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  455. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  456. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  457. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  458. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  459. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  460. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  461. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  462. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  463. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  464. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  465. { AtCommand_JailFor, "@jailfor", 60, atcommand_jailfor }, //Meruru
  466. { AtCommand_JailTime, "@jailtime", 1, atcommand_jailtime },
  467. { AtCommand_CharJailTime, "@charjailtime", 60, atcommand_charjailtime },
  468. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  469. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  470. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  471. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  472. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  473. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  474. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  475. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  476. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  477. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  478. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  479. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  480. { AtCommand_NpcMove, "@npcmove", 80, atcommand_npcmove }, // by MouseJstr
  481. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  482. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  483. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  484. { AtCommand_Chardropall, "@chardropall", 60, atcommand_chardropall }, // MouseJstr
  485. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  486. { AtCommand_Charstoreall, "@charstoreall", 60, atcommand_charstoreall }, // MouseJstr
  487. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  488. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  489. // { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
  490. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  491. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  492. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  493. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  494. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  495. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  496. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  497. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  498. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  499. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  500. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  501. { AtCommand_Send, "@send", 99, atcommand_send },
  502. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  503. { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
  504. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  505. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  506. { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri
  507. { AtCommand_Mute, "@mute", 80, atcommand_mute }, // [celest]
  508. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  509. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  510. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  511. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  512. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  513. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  514. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  515. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  516. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  517. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  518. { AtCommand_Users, "@users", 40, atcommand_users },
  519. { AtCommand_ResetState, "@reset", 40, atcommand_reset },
  520. #ifndef TXT_ONLY // sql-only commands
  521. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  522. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  523. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  524. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  525. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  526. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  527. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  528. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  529. #endif /* TXT_ONLY */
  530. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  531. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  532. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  533. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  534. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  535. #ifdef DMALLOC
  536. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  537. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  538. #endif
  539. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  540. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  541. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  542. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  543. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  544. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  545. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  546. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  547. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  548. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  549. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  550. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  551. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  552. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  553. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  554. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  555. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  556. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  557. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  558. { AtCommand_ChangeLook, "@changelook", 60, atcommand_changelook },
  559. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  560. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  561. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  562. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  563. { AtCommand_Exp, "@exp", 1, atcommand_exp }, // [Skotlex]
  564. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  565. { AtCommand_Version, "@version", 1, atcommand_version },
  566. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  567. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  568. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  569. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  570. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  571. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  572. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  573. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  574. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  575. { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
  576. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  577. { AtCommand_Size, "@size", 20, atcommand_size },
  578. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  579. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  580. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  581. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  582. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  583. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  584. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  585. { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
  586. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  587. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  588. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  589. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  590. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  591. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  592. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  593. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  594. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  595. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  596. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  597. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  598. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  599. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  600. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  601. { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
  602. { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
  603. { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
  604. { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
  605. { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
  606. { AtCommand_HomTalk, "@homtalk", 10, atcommand_homtalk },
  607. { AtCommand_HomInfo, "@hominfo", 1, atcommand_hominfo },
  608. { AtCommand_HomStats, "@homstats", 1, atcommand_homstats },
  609. { AtCommand_HomShuffle, "@homshuffle", 60, atcommand_homshuffle },
  610. { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
  611. // add new commands before this line
  612. { AtCommand_Unknown, NULL, 1, NULL }
  613. };
  614. /*=========================================
  615. * Generic variables
  616. *-----------------------------------------
  617. */
  618. char atcmd_output[200];
  619. char atcmd_player_name[100];
  620. char atcmd_temp[100];
  621. /*==========================================
  622. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  623. *------------------------------------------
  624. */
  625. char *estr_lower(char *str)
  626. {
  627. int i;
  628. for (i=0; str[i]; i++)
  629. if ((str[i] >= 65) && (str[i] <= 90))
  630. str[i] += 32;
  631. return str;
  632. }
  633. // compare function for sorting high to lowest
  634. int hightolow_compare (const void * a, const void * b)
  635. {
  636. return ( *(int*)b - *(int*)a );
  637. }
  638. // compare function for sorting lowest to highest
  639. int lowtohigh_compare (const void * a, const void * b)
  640. {
  641. return ( *(int*)a - *(int*)b );
  642. }
  643. //-----------------------------------------------------------
  644. // Return the message string of the specified number by [Yor]
  645. //-----------------------------------------------------------
  646. char * msg_txt(int msg_number)
  647. {
  648. if (msg_number >= 0 && msg_number < MAX_MSG &&
  649. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  650. return msg_table[msg_number];
  651. return "??";
  652. }
  653. //-----------------------------------------------------------
  654. // Returns Players title (from msg_athena.conf) [Lupus]
  655. //-----------------------------------------------------------
  656. char * player_title_txt(int level) {
  657. if (level < battle_config.title_lvl1)
  658. return ""; //w/o any titles
  659. if (level >= battle_config.title_lvl8)
  660. sprintf(atcmd_temp, msg_txt(332), level);
  661. else
  662. if (level >= battle_config.title_lvl7)
  663. sprintf(atcmd_temp, msg_txt(331), level);
  664. else
  665. if (level >= battle_config.title_lvl6)
  666. sprintf(atcmd_temp, msg_txt(330), level);
  667. else
  668. if (level >= battle_config.title_lvl5)
  669. sprintf(atcmd_temp, msg_txt(329), level);
  670. else
  671. if (level >= battle_config.title_lvl4)
  672. sprintf(atcmd_temp, msg_txt(328), level);
  673. else
  674. if (level >= battle_config.title_lvl3)
  675. sprintf(atcmd_temp, msg_txt(327), level);
  676. else
  677. if (level >= battle_config.title_lvl2)
  678. sprintf(atcmd_temp, msg_txt(326), level);
  679. else
  680. sprintf(atcmd_temp, msg_txt(325), level); //lvl1
  681. return atcmd_temp;
  682. }
  683. //------------------------------------------------------------
  684. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  685. //------------------------------------------------------------
  686. int e_mail_check(char *email)
  687. {
  688. char ch;
  689. char* last_arobas;
  690. // athena limits
  691. if (strlen(email) < 3 || strlen(email) > 39)
  692. return 0;
  693. // part of RFC limits (official reference of e-mail description)
  694. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  695. return 0;
  696. if (email[strlen(email)-1] == '.')
  697. return 0;
  698. last_arobas = strrchr(email, '@');
  699. if (strstr(last_arobas, "@.") != NULL ||
  700. strstr(last_arobas, "..") != NULL)
  701. return 0;
  702. for(ch = 1; ch < 32; ch++) {
  703. if (strchr(last_arobas, ch) != NULL) {
  704. return 0;
  705. break;
  706. }
  707. }
  708. if (strchr(last_arobas, ' ') != NULL ||
  709. strchr(last_arobas, ';') != NULL)
  710. return 0;
  711. // all correct
  712. return 1;
  713. }
  714. /*==========================================
  715. * Retrieve the atcommand's required gm level
  716. *------------------------------------------
  717. */
  718. int get_atcommand_level(const AtCommandType type)
  719. {
  720. int i;
  721. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  722. if (atcommand_info[i].type == type)
  723. return atcommand_info[i].level;
  724. return 100; // 100: command can not be used
  725. }
  726. AtCommandType is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  727. {
  728. AtCommandInfo info;
  729. AtCommandType type;
  730. memset(&info, 0, sizeof(info));
  731. type = atcommand(sd, gmlvl, str, &info);
  732. if (type != AtCommand_None) {
  733. char command[100];
  734. const char* p = str;
  735. if (map[sd->bl.m].nocommand &&
  736. gmlvl < map[sd->bl.m].nocommand)
  737. { //Command not allowed on this map.
  738. sprintf(atcmd_output, msg_txt(143));
  739. clif_displaymessage(fd, atcmd_output);
  740. return AtCommand_None;
  741. }
  742. memset(command, '\0', sizeof(command));
  743. memset(atcmd_output, '\0', sizeof(atcmd_output));
  744. while (*p && !isspace(*p))
  745. p++;
  746. if (p - str >= sizeof(command)) // too long
  747. return AtCommand_Unknown;
  748. strncpy(command, str, p - str);
  749. while (isspace(*p))
  750. p++;
  751. if (type == AtCommand_Unknown || info.proc == NULL) {
  752. sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
  753. clif_displaymessage(fd, atcmd_output);
  754. } else {
  755. if (info.proc(fd, sd, command, p) != 0) {
  756. // Command can not be executed
  757. sprintf(atcmd_output, msg_txt(154), command); // %s failed.
  758. clif_displaymessage(fd, atcmd_output);
  759. }
  760. }
  761. return info.type;
  762. }
  763. return AtCommand_None;
  764. }
  765. /*==========================================
  766. *
  767. *------------------------------------------
  768. */
  769. AtCommandType is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  770. {
  771. const char* str = message;
  772. int s_flag = 0;
  773. nullpo_retr(AtCommand_None, sd);
  774. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
  775. return AtCommand_Unknown;
  776. }
  777. if (!message || !*message)
  778. return AtCommand_None;
  779. str += strlen(sd->status.name);
  780. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  781. if (*str == ':')
  782. s_flag = 1;
  783. str++;
  784. }
  785. if (!*str)
  786. return AtCommand_None;
  787. if(str[0] == '|' && strlen(str) >= 4 && str[3] == atcommand_symbol)
  788. str += 3; // skip 10/11-langtype's codepage indicator, if detected
  789. return is_atcommand_sub(fd,sd,str,pc_isGM(sd));
  790. }
  791. /*==========================================
  792. *
  793. *------------------------------------------
  794. */
  795. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info)
  796. {
  797. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  798. if (!info)
  799. return AtCommand_None;
  800. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  801. return AtCommand_None;
  802. if (!p || !*p) {
  803. ShowError("at command message is empty\n");
  804. return AtCommand_None;
  805. }
  806. if (*p == atcommand_symbol) { // check first char
  807. char command[101];
  808. int i = 0;
  809. memset(info, 0, sizeof(AtCommandInfo));
  810. sscanf(p, "%100s", command);
  811. command[sizeof(command)-1] = '\0';
  812. while (atcommand_info[i].type != AtCommand_Unknown) {
  813. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  814. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  815. break;
  816. }
  817. i++;
  818. }
  819. if (atcommand_info[i].type == AtCommand_Unknown) {
  820. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  821. if (level == 0)
  822. return AtCommand_None;
  823. else
  824. return AtCommand_Unknown;
  825. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  826. log_atcommand(sd, message);
  827. }
  828. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  829. } else {
  830. return AtCommand_None;
  831. }
  832. return info->type;
  833. }
  834. /*==========================================
  835. * Read Message Data
  836. *------------------------------------------
  837. */
  838. int msg_config_read(const char *cfgName)
  839. {
  840. int msg_number;
  841. char line[1024], w1[1024], w2[1024];
  842. FILE *fp;
  843. static int called = 1;
  844. if ((fp = fopen(cfgName, "r")) == NULL) {
  845. ShowError("Messages file not found: %s\n", cfgName);
  846. return 1;
  847. }
  848. if ((--called) == 0)
  849. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  850. while(fgets(line, sizeof(line)-1, fp)) {
  851. if (line[0] == '/' && line[1] == '/')
  852. continue;
  853. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  854. if (strcmpi(w1, "import") == 0) {
  855. msg_config_read(w2);
  856. } else {
  857. msg_number = atoi(w1);
  858. if (msg_number >= 0 && msg_number < MAX_MSG) {
  859. if (msg_table[msg_number] != NULL)
  860. aFree(msg_table[msg_number]);
  861. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  862. strcpy(msg_table[msg_number],w2);
  863. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  864. }
  865. }
  866. }
  867. }
  868. fclose(fp);
  869. return 0;
  870. }
  871. /*==========================================
  872. * Cleanup Message Data
  873. *------------------------------------------
  874. */
  875. void do_final_msg (void)
  876. {
  877. int i;
  878. for (i = 0; i < MAX_MSG; i++)
  879. aFree(msg_table[i]);
  880. return;
  881. }
  882. /*==========================================
  883. *
  884. *------------------------------------------
  885. */
  886. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  887. {
  888. int i;
  889. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  890. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  891. return &atcommand_info[i];
  892. return NULL;
  893. }
  894. /*==========================================
  895. *
  896. *------------------------------------------
  897. */
  898. int atcommand_config_read(const char *cfgName)
  899. {
  900. char line[1024], w1[1024], w2[1024];
  901. AtCommandInfo* p;
  902. FILE* fp;
  903. if ((fp = fopen(cfgName, "r")) == NULL) {
  904. ShowError("At commands configuration file not found: %s\n", cfgName);
  905. return 1;
  906. }
  907. while (fgets(line, sizeof(line)-1, fp)) {
  908. if (line[0] == '/' && line[1] == '/')
  909. continue;
  910. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  911. continue;
  912. p = get_atcommandinfo_byname(w1);
  913. if (p != NULL) {
  914. p->level = atoi(w2);
  915. if (p->level > 100)
  916. p->level = 100;
  917. else if (p->level < 0)
  918. p->level = 0;
  919. }
  920. if (strcmpi(w1, "import") == 0)
  921. atcommand_config_read(w2);
  922. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  923. w2[0] != '/' && // symbol of standard ragnarok GM commands
  924. w2[0] != '%' && // symbol of party chat speaking
  925. w2[0] != '$' && // symbol of guild chat
  926. w2[0] != '#') // symbol of charcommand
  927. atcommand_symbol = w2[0];
  928. }
  929. fclose(fp);
  930. return 0;
  931. }
  932. /*==========================================
  933. // @ command processing functions
  934. *------------------------------------------
  935. */
  936. /*==========================================
  937. * @commands Lists available @ commands to you (code 98% from Meruru)
  938. *------------------------------------------
  939. */
  940. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  941. {
  942. char cz_line_buff[CHATBOX_SIZE+1];
  943. register char *lpcz_cur = cz_line_buff;
  944. register unsigned int ui_slen;
  945. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  946. memset(cz_line_buff,' ',CHATBOX_SIZE);
  947. cz_line_buff[CHATBOX_SIZE] = 0;
  948. clif_displaymessage(fd, msg_txt(273));
  949. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  950. {
  951. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  952. continue;
  953. count++;
  954. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  955. //remember not <= bc we need null terminator
  956. if(((CHATBOX_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  957. {
  958. clif_displaymessage(fd,(char*)cz_line_buff);
  959. lpcz_cur = cz_line_buff;
  960. memset(cz_line_buff,' ',CHATBOX_SIZE);
  961. cz_line_buff[CHATBOX_SIZE] = 0;
  962. }
  963. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  964. lpcz_cur += ui_slen+(10-ui_slen%10);
  965. }
  966. clif_displaymessage(fd,(char*)cz_line_buff);
  967. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  968. clif_displaymessage(fd, atcmd_output);
  969. return 0;
  970. }
  971. /*==========================================
  972. * @send (used for testing packet sends from the client)
  973. *------------------------------------------
  974. */
  975. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  976. {
  977. int len=0,off,end,type;
  978. long num;
  979. (void)command; // not used
  980. // read message type as hex number (without the 0x)
  981. if(!message || !*message ||
  982. !((sscanf(message, "len %x", &type)==1 && (len=1))
  983. || sscanf(message, "%x", &type)==1) )
  984. {
  985. clif_displaymessage(fd, "Usage:");
  986. clif_displaymessage(fd, " @send len <packet hex number>");
  987. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  988. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  989. return -1;
  990. }
  991. #define PARSE_ERROR(error,p) \
  992. {\
  993. clif_displaymessage(fd, (error));\
  994. sprintf(atcmd_output, ">%s", (p));\
  995. clif_displaymessage(fd, atcmd_output);\
  996. }
  997. //define PARSE_ERROR
  998. #define CHECK_EOS(p) \
  999. if(*(p) == 0){\
  1000. clif_displaymessage(fd, "Unexpected end of string");\
  1001. return -1;\
  1002. }
  1003. //define CHECK_EOS
  1004. #define SKIP_VALUE(p) \
  1005. {\
  1006. while(*(p) && !isspace(*(p))) ++(p); /* non-space */\
  1007. while(*(p) && isspace(*(p))) ++(p); /* space */\
  1008. }
  1009. //define SKIP_VALUE
  1010. #define GET_VALUE(p,num) \
  1011. {\
  1012. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  1013. PARSE_ERROR("Invalid number in:",(p));\
  1014. return -1;\
  1015. }\
  1016. }
  1017. //define GET_VALUE
  1018. if (type > 0 && type < MAX_PACKET_DB) {
  1019. if(len)
  1020. {// show packet length
  1021. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  1022. clif_displaymessage(fd, atcmd_output);
  1023. return 0;
  1024. }
  1025. len=packet_db[sd->packet_ver][type].len;
  1026. off=2;
  1027. if(len == 0)
  1028. {// unknown packet - ERROR
  1029. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  1030. clif_displaymessage(fd, atcmd_output);
  1031. return -1;
  1032. } else if(len == -1)
  1033. {// dynamic packet
  1034. len=SHRT_MAX-4; // maximum length
  1035. off=4;
  1036. }
  1037. WFIFOHEAD(fd, len);
  1038. WFIFOW(fd,0)=TOW(type);
  1039. // parse packet contents
  1040. SKIP_VALUE(message);
  1041. while(*message != 0 && off < len){
  1042. if(isdigit(*message) || *message == '-' || *message == '+')
  1043. {// default (byte)
  1044. GET_VALUE(message,num);
  1045. WFIFOB(fd,off)=TOB(num);
  1046. ++off;
  1047. } else if(toupper(*message) == 'B')
  1048. {// byte
  1049. ++message;
  1050. GET_VALUE(message,num);
  1051. WFIFOB(fd,off)=TOB(num);
  1052. ++off;
  1053. } else if(toupper(*message) == 'W')
  1054. {// word (2 bytes)
  1055. ++message;
  1056. GET_VALUE(message,num);
  1057. WFIFOW(fd,off)=TOW(num);
  1058. off+=2;
  1059. } else if(toupper(*message) == 'L')
  1060. {// long word (4 bytes)
  1061. ++message;
  1062. GET_VALUE(message,num);
  1063. WFIFOL(fd,off)=TOL(num);
  1064. off+=4;
  1065. } else if(toupper(*message) == 'S')
  1066. {// string - escapes are valid
  1067. // get string length - num <= 0 means not fixed length (default)
  1068. ++message;
  1069. if(*message == '"'){
  1070. num=0;
  1071. } else {
  1072. GET_VALUE(message,num);
  1073. while(*message != '"')
  1074. {// find start of string
  1075. if(*message == 0 || isspace(*message)){
  1076. PARSE_ERROR("Not a string:",message);
  1077. return -1;
  1078. }
  1079. ++message;
  1080. }
  1081. }
  1082. // parse string
  1083. ++message;
  1084. CHECK_EOS(message);
  1085. end=(num<=0? 0: min(off+((int)num),len));
  1086. for(; *message != '"' && (off < end || end == 0); ++off){
  1087. if(*message == '\\'){
  1088. ++message;
  1089. CHECK_EOS(message);
  1090. switch(*message){
  1091. case 'a': num=0x07; break; // Bell
  1092. case 'b': num=0x08; break; // Backspace
  1093. case 't': num=0x09; break; // Horizontal tab
  1094. case 'n': num=0x0A; break; // Line feed
  1095. case 'v': num=0x0B; break; // Vertical tab
  1096. case 'f': num=0x0C; break; // Form feed
  1097. case 'r': num=0x0D; break; // Carriage return
  1098. case 'e': num=0x1B; break; // Escape
  1099. default: num=*message; break;
  1100. case 'x': // Hexadecimal
  1101. {
  1102. ++message;
  1103. CHECK_EOS(message);
  1104. if(!isxdigit(*message)){
  1105. PARSE_ERROR("Not a hexadecimal digit:",message);
  1106. return -1;
  1107. }
  1108. num=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1109. if(isxdigit(*message)){
  1110. ++message;
  1111. CHECK_EOS(message);
  1112. num<<=8;
  1113. num+=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1114. }
  1115. WFIFOB(fd,off)=TOB(num);
  1116. ++message;
  1117. CHECK_EOS(message);
  1118. continue;
  1119. }
  1120. case '0':
  1121. case '1':
  1122. case '2':
  1123. case '3':
  1124. case '4':
  1125. case '5':
  1126. case '6':
  1127. case '7': // Octal
  1128. {
  1129. num=*message-'0'; // 1st octal digit
  1130. ++message;
  1131. CHECK_EOS(message);
  1132. if(isdigit(*message) && *message < '8'){
  1133. num<<=3;
  1134. num+=*message-'0'; // 2nd octal digit
  1135. ++message;
  1136. CHECK_EOS(message);
  1137. if(isdigit(*message) && *message < '8'){
  1138. num<<=3;
  1139. num+=*message-'0'; // 3rd octal digit
  1140. ++message;
  1141. CHECK_EOS(message);
  1142. }
  1143. }
  1144. WFIFOB(fd,off)=TOB(num);
  1145. continue;
  1146. }
  1147. }
  1148. } else
  1149. num=*message;
  1150. WFIFOB(fd,off)=TOB(num);
  1151. ++message;
  1152. CHECK_EOS(message);
  1153. }//for
  1154. while(*message != '"')
  1155. {// ignore extra characters
  1156. ++message;
  1157. CHECK_EOS(message);
  1158. }
  1159. // terminate the string
  1160. if(off < end)
  1161. {// fill the rest with 0's
  1162. memset(WFIFOP(fd,off),0,end-off);
  1163. off=end;
  1164. }
  1165. } else
  1166. {// unknown
  1167. PARSE_ERROR("Unknown type of value in:",message);
  1168. return -1;
  1169. }
  1170. SKIP_VALUE(message);
  1171. }
  1172. if(packet_db[sd->packet_ver][type].len == -1)
  1173. {// send dynamic packet
  1174. WFIFOW(fd,2)=TOW(off);
  1175. WFIFOSET(fd,off);
  1176. } else
  1177. {// send static packet
  1178. if(off < len)
  1179. memset(WFIFOP(fd,off),0,len-off);
  1180. WFIFOSET(fd,len);
  1181. }
  1182. } else {
  1183. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  1184. return -1;
  1185. }
  1186. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  1187. clif_displaymessage(fd, atcmd_output);
  1188. return 0;
  1189. #undef PARSE_ERROR
  1190. #undef CHECK_EOS
  1191. #undef SKIP_VALUE
  1192. #undef GET_VALUE
  1193. }
  1194. /*==========================================
  1195. * @rura
  1196. *------------------------------------------
  1197. */
  1198. int atcommand_rura( const int fd, struct map_session_data* sd, const char* command, const char* message)
  1199. {
  1200. char map_name[MAP_NAME_LENGTH];
  1201. unsigned short mapindex;
  1202. int x = 0, y = 0;
  1203. int m = -1;
  1204. nullpo_retr(-1, sd);
  1205. memset(map_name, '\0', sizeof(map_name));
  1206. if (!message || !*message ||
  1207. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1208. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1209. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1210. return -1;
  1211. }
  1212. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1213. strcat(map_name, ".gat");
  1214. mapindex = mapindex_name2id(map_name);
  1215. if (mapindex)
  1216. m = map_mapindex2mapid(mapindex);
  1217. if (!mapindex || m < 0) {
  1218. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1219. return -1;
  1220. }
  1221. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  1222. { //This is to prevent the pc_setpos call from printing an error.
  1223. clif_displaymessage(fd, msg_txt(2));
  1224. x = y = 0; //Invalid cell, use random spot.
  1225. }
  1226. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1227. clif_displaymessage(fd, msg_txt(247));
  1228. return -1;
  1229. }
  1230. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1231. clif_displaymessage(fd, msg_txt(248));
  1232. return -1;
  1233. }
  1234. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1235. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1236. else {
  1237. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1238. return -1;
  1239. }
  1240. return 0;
  1241. }
  1242. /*==========================================
  1243. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1244. *------------------------------------------
  1245. */
  1246. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1247. {
  1248. struct map_session_data *pl_sd = NULL;
  1249. int GM_level, pl_GM_level;
  1250. nullpo_retr(-1, sd);
  1251. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1252. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1253. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1254. return -1;
  1255. }
  1256. pl_sd = map_nick2sd(atcmd_player_name);
  1257. if (pl_sd == NULL)
  1258. return -1;
  1259. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1260. return -1;
  1261. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1262. pl_GM_level = pc_isGM(pl_sd);
  1263. if (battle_config.hide_GM_session) {
  1264. if(GM_level < pl_GM_level) {
  1265. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1266. return -1;
  1267. }
  1268. }
  1269. }
  1270. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1271. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1272. clif_displaymessage(fd, atcmd_output);
  1273. return 0;
  1274. }
  1275. /*==========================================
  1276. *
  1277. *------------------------------------------
  1278. */
  1279. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1280. {
  1281. struct map_session_data *pl_sd = NULL;
  1282. nullpo_retr(-1, sd);
  1283. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1284. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1285. return -1;
  1286. }
  1287. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1288. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1289. return -1;
  1290. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1291. return -1;
  1292. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1293. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1294. clif_displaymessage(fd, msg_txt(247));
  1295. return -1;
  1296. }
  1297. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1298. clif_displaymessage(fd, msg_txt(248));
  1299. return -1;
  1300. }
  1301. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1302. sprintf(atcmd_output, msg_txt(4), atcmd_player_name); // Jump to %s
  1303. clif_displaymessage(fd, atcmd_output);
  1304. } else {
  1305. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1306. return -1;
  1307. }
  1308. return 0;
  1309. }
  1310. /*==========================================
  1311. *
  1312. *------------------------------------------
  1313. */
  1314. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1315. {
  1316. int x = 0, y = 0;
  1317. nullpo_retr(-1, sd);
  1318. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1319. sscanf(message, "%d %d", &x, &y);
  1320. if (x <= 0) //If coordinates are 'wrong', random jump.
  1321. x = -1;
  1322. if (y <= 0)
  1323. y = -1;
  1324. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarp || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1325. clif_displaymessage(fd, msg_txt(248));
  1326. return -1;
  1327. }
  1328. pc_setpos(sd, sd->mapindex, x, y, 3);
  1329. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
  1330. clif_displaymessage(fd, atcmd_output);
  1331. return 0;
  1332. }
  1333. /*==========================================
  1334. * @who3 = Player name, his location
  1335. *------------------------------------------
  1336. */
  1337. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1338. {
  1339. char temp0[100];
  1340. struct map_session_data *pl_sd, **pl_allsd;
  1341. int i, j, count, users;
  1342. int pl_GM_level, GM_level;
  1343. char match_text[100];
  1344. char player_name[NAME_LENGTH];
  1345. nullpo_retr(-1, sd);
  1346. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1347. memset(match_text, '\0', sizeof(match_text));
  1348. memset(player_name, '\0', sizeof(player_name));
  1349. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1350. strcpy(match_text, "");
  1351. for (j = 0; match_text[j]; j++)
  1352. match_text[j] = tolower(match_text[j]);
  1353. count = 0;
  1354. GM_level = pc_isGM(sd);
  1355. pl_allsd = map_getallusers(&users);
  1356. for (i = 0; i < users; i++) {
  1357. if ((pl_sd = pl_allsd[i])) {
  1358. pl_GM_level = pc_isGM(pl_sd);
  1359. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1360. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1361. for (j = 0; player_name[j]; j++)
  1362. player_name[j] = tolower(player_name[j]);
  1363. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1364. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1365. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1366. } else {
  1367. atcmd_output[0]=0;
  1368. }
  1369. //Player name
  1370. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1371. strcat(atcmd_output,temp0);
  1372. //Player title, if exists
  1373. if (pl_GM_level > 0) {
  1374. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1375. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1376. strcat(atcmd_output,temp0);
  1377. }
  1378. //Players Location: map x y
  1379. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1380. strcat(atcmd_output,temp0);
  1381. clif_displaymessage(fd, atcmd_output);
  1382. count++;
  1383. }
  1384. }
  1385. }
  1386. }
  1387. if (count == 0)
  1388. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1389. else if (count == 1)
  1390. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1391. else {
  1392. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1393. clif_displaymessage(fd, atcmd_output);
  1394. }
  1395. return 0;
  1396. }
  1397. /*==========================================
  1398. * Player name, BLevel, Job,
  1399. *------------------------------------------
  1400. */
  1401. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1402. {
  1403. char temp0[100];
  1404. struct map_session_data *pl_sd, **pl_allsd;
  1405. int i, j, count, users;
  1406. int pl_GM_level, GM_level;
  1407. char match_text[100];
  1408. char player_name[NAME_LENGTH];
  1409. nullpo_retr(-1, sd);
  1410. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1411. memset(match_text, '\0', sizeof(match_text));
  1412. memset(player_name, '\0', sizeof(player_name));
  1413. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1414. strcpy(match_text, "");
  1415. for (j = 0; match_text[j]; j++)
  1416. match_text[j] = tolower(match_text[j]);
  1417. count = 0;
  1418. GM_level = pc_isGM(sd);
  1419. pl_allsd = map_getallusers(&users);
  1420. for (i = 0; i < users; i++) {
  1421. if ((pl_sd = pl_allsd[i])) {
  1422. pl_GM_level = pc_isGM(pl_sd);
  1423. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1424. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1425. for (j = 0; player_name[j]; j++)
  1426. player_name[j] = tolower(player_name[j]);
  1427. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1428. //Players Name
  1429. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1430. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1431. //Player title, if exists
  1432. if (pl_GM_level > 0) {
  1433. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1434. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1435. strcat(atcmd_output,temp0);
  1436. }
  1437. //Players Base Level / Job name
  1438. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1439. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1440. strcat(atcmd_output,temp0);
  1441. clif_displaymessage(fd, atcmd_output);
  1442. count++;
  1443. }
  1444. }
  1445. }
  1446. }
  1447. if (count == 0)
  1448. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1449. else if (count == 1)
  1450. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1451. else {
  1452. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1453. clif_displaymessage(fd, atcmd_output);
  1454. }
  1455. return 0;
  1456. }
  1457. /*==========================================
  1458. * Player name, Playrs Party / Guild name
  1459. *------------------------------------------
  1460. */
  1461. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1462. {
  1463. char temp0[100];
  1464. struct map_session_data *pl_sd, **pl_allsd;
  1465. int i, j, count, users;
  1466. int pl_GM_level, GM_level;
  1467. char match_text[100];
  1468. char player_name[NAME_LENGTH];
  1469. struct guild *g;
  1470. struct party_data *p;
  1471. nullpo_retr(-1, sd);
  1472. memset(temp0, '\0', sizeof(temp0));
  1473. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1474. memset(match_text, '\0', sizeof(match_text));
  1475. memset(player_name, '\0', sizeof(player_name));
  1476. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1477. strcpy(match_text, "");
  1478. for (j = 0; match_text[j]; j++)
  1479. match_text[j] = tolower(match_text[j]);
  1480. count = 0;
  1481. GM_level = pc_isGM(sd);
  1482. pl_allsd = map_getallusers(&users);
  1483. for (i = 0; i < users; i++) {
  1484. if ((pl_sd = pl_allsd[i])) {
  1485. pl_GM_level = pc_isGM(pl_sd);
  1486. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1487. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1488. for (j = 0; player_name[j]; j++)
  1489. player_name[j] = tolower(player_name[j]);
  1490. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1491. g = guild_search(pl_sd->status.guild_id);
  1492. p = party_search(pl_sd->status.party_id);
  1493. //Players Name
  1494. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1495. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1496. //Player title, if exists
  1497. if (pl_GM_level > 0) {
  1498. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1499. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1500. strcat(atcmd_output,temp0);
  1501. }
  1502. //Players Party if exists
  1503. if (p != NULL) {
  1504. //sprintf(temp0," | Party: '%s'", p->name);
  1505. sprintf(temp0, msg_txt(335), p->party.name);
  1506. strcat(atcmd_output,temp0);
  1507. }
  1508. //Players Guild if exists
  1509. if (g != NULL) {
  1510. //sprintf(temp0," | Guild: '%s'", g->name);
  1511. sprintf(temp0, msg_txt(336), g->name);
  1512. strcat(atcmd_output,temp0);
  1513. }
  1514. clif_displaymessage(fd, atcmd_output);
  1515. count++;
  1516. }
  1517. }
  1518. }
  1519. }
  1520. if (count == 0)
  1521. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1522. else if (count == 1)
  1523. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1524. else {
  1525. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1526. clif_displaymessage(fd, atcmd_output);
  1527. }
  1528. return 0;
  1529. }
  1530. /*==========================================
  1531. *
  1532. *------------------------------------------
  1533. */
  1534. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1535. {
  1536. struct map_session_data *pl_sd, **pl_allsd;
  1537. int i, count, users;
  1538. int pl_GM_level, GM_level;
  1539. int map_id;
  1540. char map_name[MAP_NAME_LENGTH];
  1541. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1542. memset(map_name, '\0', sizeof(map_name));
  1543. if (!message || !*message)
  1544. map_id = sd->bl.m;
  1545. else {
  1546. sscanf(message, "%15s", map_name);
  1547. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1548. strcat(map_name, ".gat");
  1549. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1550. map_id = sd->bl.m;
  1551. }
  1552. count = 0;
  1553. GM_level = pc_isGM(sd);
  1554. pl_allsd = map_getallusers(&users);
  1555. for (i = 0; i < users; i++) {
  1556. if ((pl_sd = pl_allsd[i])) {
  1557. pl_GM_level = pc_isGM(pl_sd);
  1558. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1559. if (pl_sd->bl.m == map_id) {
  1560. if (pl_GM_level > 0)
  1561. 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);
  1562. else
  1563. 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);
  1564. clif_displaymessage(fd, atcmd_output);
  1565. count++;
  1566. }
  1567. }
  1568. }
  1569. }
  1570. if (count == 0)
  1571. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1572. else if (count == 1)
  1573. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1574. else {
  1575. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1576. }
  1577. clif_displaymessage(fd, atcmd_output);
  1578. return 0;
  1579. }
  1580. /*==========================================
  1581. *
  1582. *------------------------------------------
  1583. */
  1584. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1585. {
  1586. struct map_session_data *pl_sd, **pl_allsd;
  1587. int i, count, users;
  1588. int pl_GM_level, GM_level;
  1589. int map_id = 0;
  1590. char map_name[MAP_NAME_LENGTH];
  1591. nullpo_retr(-1, sd);
  1592. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1593. memset(map_name, '\0', sizeof(map_name));
  1594. if (!message || !*message)
  1595. map_id = sd->bl.m;
  1596. else {
  1597. sscanf(message, "%15s", map_name);
  1598. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1599. strcat(map_name, ".gat");
  1600. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1601. map_id = sd->bl.m;
  1602. }
  1603. count = 0;
  1604. GM_level = pc_isGM(sd);
  1605. pl_allsd = map_getallusers(&users);
  1606. for (i = 0; i < users; i++) {
  1607. if ((pl_sd = pl_allsd[i])) {
  1608. pl_GM_level = pc_isGM(pl_sd);
  1609. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1610. if (pl_sd->bl.m == map_id) {
  1611. if (pl_GM_level > 0)
  1612. 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);
  1613. else
  1614. 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);
  1615. clif_displaymessage(fd, atcmd_output);
  1616. count++;
  1617. }
  1618. }
  1619. }
  1620. }
  1621. if (count == 0)
  1622. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1623. else if (count == 1)
  1624. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1625. else {
  1626. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1627. }
  1628. clif_displaymessage(fd, atcmd_output);
  1629. return 0;
  1630. }
  1631. /*==========================================
  1632. *
  1633. *------------------------------------------
  1634. */
  1635. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1636. {
  1637. char temp0[100];
  1638. char temp1[100];
  1639. struct map_session_data *pl_sd, **pl_allsd;
  1640. int i, count, users;
  1641. int pl_GM_level, GM_level;
  1642. int map_id = 0;
  1643. char map_name[MAP_NAME_LENGTH];
  1644. struct guild *g;
  1645. struct party_data *p;
  1646. nullpo_retr(-1, sd);
  1647. memset(temp0, '\0', sizeof(temp0));
  1648. memset(temp1, '\0', sizeof(temp1));
  1649. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1650. memset(map_name, '\0', sizeof(map_name));
  1651. if (!message || !*message)
  1652. map_id = sd->bl.m;
  1653. else {
  1654. sscanf(message, "%15s", map_name);
  1655. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1656. strcat(map_name, ".gat");
  1657. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1658. map_id = sd->bl.m;
  1659. }
  1660. count = 0;
  1661. GM_level = pc_isGM(sd);
  1662. pl_allsd = map_getallusers(&users);
  1663. for (i = 0; i < users; i++) {
  1664. if ((pl_sd = pl_allsd[i])) {
  1665. pl_GM_level = pc_isGM(pl_sd);
  1666. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1667. if (pl_sd->bl.m == map_id) {
  1668. g = guild_search(pl_sd->status.guild_id);
  1669. if (g == NULL)
  1670. sprintf(temp1, "None");
  1671. else
  1672. sprintf(temp1, "%s", g->name);
  1673. p = party_search(pl_sd->status.party_id);
  1674. if (p == NULL)
  1675. sprintf(temp0, "None");
  1676. else
  1677. sprintf(temp0, "%s", p->party.name);
  1678. if (pl_GM_level > 0)
  1679. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1680. else
  1681. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1682. clif_displaymessage(fd, atcmd_output);
  1683. count++;
  1684. }
  1685. }
  1686. }
  1687. }
  1688. if (count == 0)
  1689. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1690. else if (count == 1)
  1691. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1692. else {
  1693. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1694. }
  1695. clif_displaymessage(fd, atcmd_output);
  1696. return 0;
  1697. }
  1698. /*==========================================
  1699. *
  1700. *------------------------------------------
  1701. */
  1702. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1703. {
  1704. char temp0[100];
  1705. char temp1[100];
  1706. struct map_session_data *pl_sd, **pl_allsd;
  1707. int i, j, count, users;
  1708. int pl_GM_level, GM_level;
  1709. char match_text[100];
  1710. char player_name[NAME_LENGTH];
  1711. struct guild *g;
  1712. struct party_data *p;
  1713. nullpo_retr(-1, sd);
  1714. memset(temp0, '\0', sizeof(temp0));
  1715. memset(temp1, '\0', sizeof(temp1));
  1716. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1717. memset(match_text, '\0', sizeof(match_text));
  1718. memset(player_name, '\0', sizeof(player_name));
  1719. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1720. strcpy(match_text, "");
  1721. for (j = 0; match_text[j]; j++)
  1722. match_text[j] = tolower(match_text[j]);
  1723. count = 0;
  1724. GM_level = pc_isGM(sd);
  1725. pl_allsd = map_getallusers(&users);
  1726. for (i = 0; i < users; i++) {
  1727. if ((pl_sd = pl_allsd[i])) {
  1728. pl_GM_level = pc_isGM(pl_sd);
  1729. if (pl_GM_level > 0) {
  1730. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1731. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1732. for (j = 0; player_name[j]; j++)
  1733. player_name[j] = tolower(player_name[j]);
  1734. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1735. 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);
  1736. clif_displaymessage(fd, atcmd_output);
  1737. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1738. clif_displaymessage(fd, atcmd_output);
  1739. g = guild_search(pl_sd->status.guild_id);
  1740. if (g == NULL)
  1741. sprintf(temp1, "None");
  1742. else
  1743. sprintf(temp1, "%s", g->name);
  1744. p = party_search(pl_sd->status.party_id);
  1745. if (p == NULL)
  1746. sprintf(temp0, "None");
  1747. else
  1748. sprintf(temp0, "%s", p->party.name);
  1749. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1750. clif_displaymessage(fd, atcmd_output);
  1751. count++;
  1752. }
  1753. }
  1754. }
  1755. }
  1756. }
  1757. if (count == 0)
  1758. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1759. else if (count == 1)
  1760. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1761. else {
  1762. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1763. clif_displaymessage(fd, atcmd_output);
  1764. }
  1765. return 0;
  1766. }
  1767. int atcommand_whozeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1768. {
  1769. struct map_session_data *pl_sd, **pl_allsd;
  1770. int i, j, count,c, users;
  1771. char match_text[100];
  1772. char player_name[NAME_LENGTH];
  1773. int *zeny;
  1774. int *counted;
  1775. nullpo_retr(-1, sd);
  1776. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1777. memset(match_text, '\0', sizeof(match_text));
  1778. memset(player_name, '\0', sizeof(player_name));
  1779. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1780. strcpy(match_text, "");
  1781. for (j = 0; match_text[j]; j++)
  1782. match_text[j] = tolower(match_text[j]);
  1783. count = 0;
  1784. pl_allsd = map_getallusers(&users);
  1785. if (users < 1)
  1786. {
  1787. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1788. return 0;
  1789. }
  1790. zeny = (int *)aMallocA(users*sizeof(int));
  1791. counted = (int *)aMallocA(users*sizeof(int));
  1792. for (i = 0; i < users; i++) {
  1793. if ((pl_sd = pl_allsd[i])) {
  1794. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1795. for (j = 0; player_name[j]; j++)
  1796. player_name[j] = tolower(player_name[j]);
  1797. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1798. zeny[count]=pl_sd->status.zeny;
  1799. counted[i]=0;
  1800. count++;
  1801. }
  1802. }
  1803. }
  1804. qsort(zeny, count, sizeof(int), hightolow_compare);
  1805. for (c = 0; c < count && c < 50; c++) {
  1806. if(!zeny[c])
  1807. continue;
  1808. for (i = 0; i < users; i++) {
  1809. if(!zeny[c])
  1810. continue;
  1811. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1812. if(pl_sd->status.zeny==zeny[c]) {
  1813. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1814. clif_displaymessage(fd, atcmd_output);
  1815. zeny[c]=0;
  1816. counted[i]=1;
  1817. }
  1818. }
  1819. }
  1820. }
  1821. if (count == 0)
  1822. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1823. else if (count == 1)
  1824. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1825. else {
  1826. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1827. clif_displaymessage(fd, atcmd_output);
  1828. }
  1829. aFree(zeny);
  1830. aFree(counted);
  1831. return 0;
  1832. }
  1833. /*==========================================
  1834. *
  1835. *------------------------------------------
  1836. */
  1837. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1838. {
  1839. nullpo_retr(-1, sd);
  1840. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1841. if (sd->status.pet_id > 0 && sd->pd)
  1842. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1843. chrif_save(sd,0);
  1844. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  1845. return 0;
  1846. }
  1847. /*==========================================
  1848. *
  1849. *------------------------------------------
  1850. */
  1851. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1852. {
  1853. int m;
  1854. nullpo_retr(-1, sd);
  1855. m = map_mapindex2mapid(sd->status.save_point.map);
  1856. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1857. clif_displaymessage(fd, msg_txt(249));
  1858. return -1;
  1859. }
  1860. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1861. clif_displaymessage(fd, msg_txt(248));
  1862. return -1;
  1863. }
  1864. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1865. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1866. return 0;
  1867. }
  1868. /*==========================================
  1869. *
  1870. *------------------------------------------
  1871. */
  1872. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1873. {
  1874. int speed;
  1875. nullpo_retr(-1, sd);
  1876. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1877. if (!message || !*message) {
  1878. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1879. clif_displaymessage(fd, atcmd_output);
  1880. return -1;
  1881. }
  1882. speed = atoi(message);
  1883. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1884. sd->base_status.speed = speed;
  1885. status_calc_bl(&sd->bl, SCB_SPEED);
  1886. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1887. } else {
  1888. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1889. clif_displaymessage(fd, atcmd_output);
  1890. return -1;
  1891. }
  1892. return 0;
  1893. }
  1894. /*==========================================
  1895. *
  1896. *------------------------------------------
  1897. */
  1898. int atcommand_charspeed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1899. {
  1900. struct map_session_data *pl_sd;
  1901. int speed;
  1902. nullpo_retr(-1, sd);
  1903. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1904. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1905. if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
  1906. sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1907. clif_displaymessage(fd, atcmd_output);
  1908. return -1;
  1909. }
  1910. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  1911. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1912. return -1;
  1913. }
  1914. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1915. { //GM level check
  1916. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1917. return -1;
  1918. }
  1919. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1920. pl_sd->base_status.speed = speed;
  1921. status_calc_bl(&pl_sd->bl, SCB_SPEED);
  1922. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1923. if(pl_sd->fd)
  1924. clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
  1925. } else {
  1926. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1927. clif_displaymessage(fd, atcmd_output);
  1928. return -1;
  1929. }
  1930. return 0;
  1931. }
  1932. /*==========================================
  1933. *
  1934. *------------------------------------------
  1935. */
  1936. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1937. {
  1938. nullpo_retr(-1, sd);
  1939. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1940. return -1;
  1941. if (storage_storageopen(sd) == 1)
  1942. { //Already open.
  1943. clif_displaymessage(fd, msg_txt(250));
  1944. return -1;
  1945. }
  1946. return 0;
  1947. }
  1948. /*==========================================
  1949. *
  1950. *------------------------------------------
  1951. */
  1952. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1953. {
  1954. struct storage *stor; //changes from Freya/Yor
  1955. nullpo_retr(-1, sd);
  1956. if (!sd->status.guild_id) {
  1957. clif_displaymessage(fd, msg_txt(252));
  1958. return -1;
  1959. }
  1960. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1961. return -1;
  1962. if (sd->state.storage_flag) {
  1963. clif_displaymessage(fd, msg_txt(251));
  1964. return -1;
  1965. }
  1966. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1967. clif_displaymessage(fd, msg_txt(251));
  1968. return -1;
  1969. }
  1970. storage_guild_storageopen(sd);
  1971. return 0;
  1972. }
  1973. /*==========================================
  1974. *
  1975. *------------------------------------------
  1976. */
  1977. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1978. {
  1979. int param1 = 0, param2 = 0, param3 = 0;
  1980. nullpo_retr(-1, sd);
  1981. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1982. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1983. return -1;
  1984. }
  1985. sd->sc.opt1 = param1;
  1986. sd->sc.opt2 = param2;
  1987. pc_setoption(sd, param3);
  1988. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1989. return 0;
  1990. }
  1991. /*==========================================
  1992. *
  1993. *------------------------------------------
  1994. */
  1995. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1996. {
  1997. nullpo_retr(-1, sd);
  1998. if (sd->sc.option & OPTION_INVISIBLE) {
  1999. sd->sc.option &= ~OPTION_INVISIBLE;
  2000. if (sd->disguise)
  2001. status_set_viewdata(&sd->bl, sd->disguise);
  2002. else
  2003. status_set_viewdata(&sd->bl, sd->status.class_);
  2004. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  2005. } else {
  2006. sd->sc.option |= OPTION_INVISIBLE;
  2007. sd->vd.class_ = INVISIBLE_CLASS;
  2008. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  2009. }
  2010. clif_changeoption(&sd->bl);
  2011. return 0;
  2012. }
  2013. /*==========================================
  2014. * Changes a character's class
  2015. *------------------------------------------
  2016. */
  2017. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2018. {
  2019. int job = 0, upper = 0;
  2020. nullpo_retr(-1, sd);
  2021. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  2022. int i, found = 0;
  2023. const struct { char name[16]; int id; } jobs[] = {
  2024. { "novice", 0 },
  2025. { "swordsman", 1 },
  2026. { "mage", 2 },
  2027. { "archer", 3 },
  2028. { "acolyte", 4 },
  2029. { "merchant", 5 },
  2030. { "thief", 6 },
  2031. { "knight", 7 },
  2032. { "priest", 8 },
  2033. { "priestess", 8 },
  2034. { "wizard", 9 },
  2035. { "blacksmith", 10 },
  2036. { "hunter", 11 },
  2037. { "assassin", 12 },
  2038. { "crusader", 14 },
  2039. { "monk", 15 },
  2040. { "sage", 16 },
  2041. { "rogue", 17 },
  2042. { "alchemist", 18 },
  2043. { "bard", 19 },
  2044. { "dancer", 20 },
  2045. { "super novice", 23 },
  2046. { "supernovice", 23 },
  2047. { "gunslinger", 24 },
  2048. { "gunner", 24 },
  2049. { "ninja", 25 },
  2050. { "high novice", 4001 },
  2051. { "swordsman high", 4002 },
  2052. { "mage high", 4003 },
  2053. { "archer high", 4004 },
  2054. { "acolyte high", 4005 },
  2055. { "merchant high", 4006 },
  2056. { "thief high", 4007 },
  2057. { "lord knight", 4008 },
  2058. { "high priest", 4009 },
  2059. { "high priestess", 4009 },
  2060. { "high wizard", 4010 },
  2061. { "whitesmith", 4011 },
  2062. { "sniper", 4012 },
  2063. { "assassin cross", 4013 },
  2064. { "paladin", 4015 },
  2065. { "champion", 4016 },
  2066. { "professor", 4017 },
  2067. { "stalker", 4018 },
  2068. { "creator", 4019 },
  2069. { "clown", 4020 },
  2070. { "gypsy", 4021 },
  2071. { "baby novice", 4023 },
  2072. { "baby swordsman", 4024 },
  2073. { "baby mage", 4025 },
  2074. { "baby archer", 4026 },
  2075. { "baby acolyte", 4027 },
  2076. { "baby merchant", 4028 },
  2077. { "baby thief", 4029 },
  2078. { "baby knight", 4030 },
  2079. { "baby priest", 4031 },
  2080. { "baby priestess", 4031 },
  2081. { "baby wizard", 4032 },
  2082. { "baby blacksmith",4033 },
  2083. { "baby hunter", 4034 },
  2084. { "baby assassin", 4035 },
  2085. { "baby crusader", 4037 },
  2086. { "baby monk", 4038 },
  2087. { "baby sage", 4039 },
  2088. { "baby rogue", 4040 },
  2089. { "baby alchemist", 4041 },
  2090. { "baby bard", 4042 },
  2091. { "baby dancer", 4043 },
  2092. { "super baby", 4045 },
  2093. { "taekwon", 4046 },
  2094. { "taekwon boy", 4046 },
  2095. { "taekwon girl", 4046 },
  2096. { "star gladiator", 4047 },
  2097. { "soul linker", 4049 },
  2098. };
  2099. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2100. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2101. job = jobs[i].id;
  2102. upper = 0;
  2103. found = 1;
  2104. break;
  2105. }
  2106. }
  2107. if (!found) {
  2108. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2109. return -1;
  2110. }
  2111. }
  2112. if (job == 37 ||job == 45)
  2113. return 0;
  2114. if ((job >= 0 && job < MAX_PC_CLASS))
  2115. {
  2116. int j;
  2117. for (j=0; j < MAX_INVENTORY; j++) {
  2118. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2119. pc_unequipitem(sd, j, 3);
  2120. }
  2121. if (pc_jobchange(sd, job, upper) == 0)
  2122. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  2123. else {
  2124. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  2125. return -1;
  2126. }
  2127. } else {
  2128. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2129. return -1;
  2130. }
  2131. return 0;
  2132. }
  2133. /*==========================================
  2134. *
  2135. *------------------------------------------
  2136. */
  2137. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2138. {
  2139. nullpo_retr(-1, sd);
  2140. clif_specialeffect(&sd->bl,450,SELF);
  2141. status_kill(&sd->bl);
  2142. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  2143. return 0;
  2144. }
  2145. /*==========================================
  2146. *
  2147. *------------------------------------------
  2148. */
  2149. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2150. {
  2151. struct map_session_data *pl_sd;
  2152. nullpo_retr(-1, sd);
  2153. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2154. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2155. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2156. return -1;
  2157. }
  2158. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2159. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2160. status_kill(&pl_sd->bl);
  2161. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  2162. } else {
  2163. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2164. return -1;
  2165. }
  2166. } else {
  2167. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2168. return -1;
  2169. }
  2170. return 0;
  2171. }
  2172. /*==========================================
  2173. *
  2174. *------------------------------------------
  2175. */
  2176. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2177. {
  2178. nullpo_retr(-1, sd);
  2179. if (!status_revive(&sd->bl, 100, 100))
  2180. return -1;
  2181. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2182. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  2183. return 0;
  2184. }
  2185. /*==========================================
  2186. * +kamic [LuzZza]
  2187. *------------------------------------------
  2188. */
  2189. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2190. {
  2191. unsigned long color=0;
  2192. nullpo_retr(-1, sd);
  2193. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2194. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2195. if (!message || !*message) {
  2196. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2197. return -1;
  2198. }
  2199. sscanf(message, "%199[^\n]", atcmd_output);
  2200. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2201. } else {
  2202. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2203. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2204. return -1;
  2205. }
  2206. if(color > 0xFFFFFF) {
  2207. clif_displaymessage(fd, "Invalid color.");
  2208. return -1;
  2209. }
  2210. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2211. }
  2212. return 0;
  2213. }
  2214. /*==========================================
  2215. *
  2216. *------------------------------------------
  2217. */
  2218. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2219. {
  2220. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2221. nullpo_retr(-1, sd);
  2222. sscanf(message, "%d %d", &hp, &sp);
  2223. if (hp == 0 && sp == 0) {
  2224. if (!status_percent_heal(&sd->bl, 100, 100))
  2225. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2226. else
  2227. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2228. return 0;
  2229. }
  2230. if(hp > 0 && sp >= 0) {
  2231. if(!status_heal(&sd->bl, hp, sp, 0))
  2232. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2233. else
  2234. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2235. return 0;
  2236. }
  2237. if(hp < 0 && sp <= 0) {
  2238. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2239. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2240. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2241. return 0;
  2242. }
  2243. //Opposing signs.
  2244. if (hp) {
  2245. if (hp > 0)
  2246. status_heal(&sd->bl, hp, 0, 0);
  2247. else {
  2248. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2249. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2250. }
  2251. }
  2252. if (sp) {
  2253. if (sp > 0)
  2254. status_heal(&sd->bl, 0, sp, 0);
  2255. else
  2256. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2257. }
  2258. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2259. return 0;
  2260. }
  2261. /*==========================================
  2262. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2263. *------------------------------------------
  2264. */
  2265. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2266. {
  2267. char item_name[100];
  2268. int number = 0, item_id, flag;
  2269. struct item item_tmp;
  2270. struct item_data *item_data;
  2271. int get_count, i;
  2272. nullpo_retr(-1, sd);
  2273. memset(item_name, '\0', sizeof(item_name));
  2274. if (!message || !*message || (
  2275. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  2276. sscanf(message, "%99s %d", item_name, &number) < 1
  2277. )) {
  2278. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2279. return -1;
  2280. }
  2281. if (number <= 0)
  2282. number = 1;
  2283. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2284. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2285. {
  2286. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2287. return -1;
  2288. }
  2289. item_id = item_data->nameid;
  2290. get_count = number;
  2291. //Check if it's stackable.
  2292. if (!itemdb_isstackable2(item_data))
  2293. get_count = 1;
  2294. for (i = 0; i < number; i += get_count) {
  2295. // if not pet egg
  2296. if (!pet_create_egg(sd, item_id)) {
  2297. memset(&item_tmp, 0, sizeof(item_tmp));
  2298. item_tmp.nameid = item_id;
  2299. item_tmp.identify = 1;
  2300. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2301. clif_additem(sd, 0, 0, flag);
  2302. }
  2303. }
  2304. //Logs (A)dmins items [Lupus]
  2305. if(log_config.enable_logs&0x400)
  2306. log_pick_pc(sd, "A", item_id, number, NULL);
  2307. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2308. return 0;
  2309. }
  2310. /*==========================================
  2311. *
  2312. *------------------------------------------
  2313. */
  2314. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2315. {
  2316. struct item item_tmp;
  2317. struct item_data *item_data;
  2318. char item_name[100];
  2319. int item_id, number = 0;
  2320. int identify = 0, refine = 0, attr = 0;
  2321. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2322. int flag;
  2323. int loop, get_count, i;
  2324. nullpo_retr(-1, sd);
  2325. memset(item_name, '\0', sizeof(item_name));
  2326. if (!message || !*message || (
  2327. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  2328. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  2329. )) {
  2330. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2331. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2332. return -1;
  2333. }
  2334. if (number <= 0)
  2335. number = 1;
  2336. item_id = 0;
  2337. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2338. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2339. item_id = item_data->nameid;
  2340. if (item_id > 500) {
  2341. loop = 1;
  2342. get_count = number;
  2343. if (item_data->type == 4 || item_data->type == 5 ||
  2344. item_data->type == 7 || item_data->type == 8) {
  2345. loop = number;
  2346. get_count = 1;
  2347. if (item_data->type == 7) {
  2348. identify = 1;
  2349. refine = 0;
  2350. }
  2351. if (item_data->type == 8)
  2352. refine = 0;
  2353. if (refine > 10)
  2354. refine = 10;
  2355. } else {
  2356. identify = 1;
  2357. refine = attr = 0;
  2358. }
  2359. for (i = 0; i < loop; i++) {
  2360. memset(&item_tmp, 0, sizeof(item_tmp));
  2361. item_tmp.nameid = item_id;
  2362. item_tmp.identify = identify;
  2363. item_tmp.refine = refine;
  2364. item_tmp.attribute = attr;
  2365. item_tmp.card[0] = c1;
  2366. item_tmp.card[1] = c2;
  2367. item_tmp.card[2] = c3;
  2368. item_tmp.card[3] = c4;
  2369. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2370. clif_additem(sd, 0, 0, flag);
  2371. }
  2372. //Logs (A)dmins items [Lupus]
  2373. if(log_config.enable_logs&0x400)
  2374. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  2375. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2376. } else {
  2377. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2378. return -1;
  2379. }
  2380. return 0;
  2381. }
  2382. /*==========================================
  2383. *
  2384. *------------------------------------------
  2385. */
  2386. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2387. {
  2388. int i;
  2389. nullpo_retr(-1, sd);
  2390. for (i = 0; i < MAX_INVENTORY; i++) {
  2391. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2392. //Logs (A)dmins items [Lupus]
  2393. if(log_config.enable_logs&0x400)
  2394. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2395. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2396. }
  2397. }
  2398. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  2399. return 0;
  2400. }
  2401. /*==========================================
  2402. * Atcommand @lvlup
  2403. *------------------------------------------
  2404. */
  2405. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2406. {
  2407. int level=0, i=0, status_point=0;
  2408. nullpo_retr(-1, sd);
  2409. level = atoi(message);
  2410. if (!message || !*message || !level) {
  2411. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2412. return -1;
  2413. }
  2414. if (level > 0) {
  2415. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2416. clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
  2417. return -1;
  2418. } /* End Addition */
  2419. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2420. level = pc_maxbaselv(sd) - sd->status.base_level;
  2421. for (i = 1; i <= level; i++)
  2422. status_point += (sd->status.base_level + i + 14) / 5;
  2423. if (sd->status.status_point > USHRT_MAX - status_point)
  2424. sd->status.status_point = USHRT_MAX;
  2425. else
  2426. sd->status.status_point += status_point;
  2427. sd->status.base_level += (unsigned int)level;
  2428. status_percent_heal(&sd->bl, 100, 100);
  2429. clif_misceffect(&sd->bl, 0);
  2430. clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
  2431. } else {
  2432. if (sd->status.base_level == 1) {
  2433. clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
  2434. return -1;
  2435. }
  2436. level*=-1;
  2437. if ((unsigned int)level >= sd->status.base_level)
  2438. level = sd->status.base_level-1;
  2439. for (i = 0; i > -level; i--)
  2440. status_point += (sd->status.base_level + i + 14) / 5;
  2441. if (sd->status.status_point < status_point)
  2442. pc_resetstate(sd);
  2443. if (sd->status.status_point < status_point)
  2444. sd->status.status_point = 0;
  2445. else
  2446. sd->status.status_point -= status_point;
  2447. sd->status.base_level -= (unsigned int)level;
  2448. clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
  2449. }
  2450. clif_updatestatus(sd, SP_STATUSPOINT);
  2451. clif_updatestatus(sd, SP_BASELEVEL);
  2452. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2453. status_calc_pc(sd, 0);
  2454. if(sd->status.party_id)
  2455. party_send_levelup(sd);
  2456. return 0;
  2457. }
  2458. /*==========================================
  2459. *
  2460. *------------------------------------------
  2461. */
  2462. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2463. {
  2464. int level=0;
  2465. nullpo_retr(-1, sd);
  2466. level = atoi(message);
  2467. if (!message || !*message || !level) {
  2468. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2469. return -1;
  2470. }
  2471. if (level > 0) {
  2472. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2473. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  2474. return -1;
  2475. }
  2476. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2477. level = pc_maxjoblv(sd) - sd->status.job_level;
  2478. sd->status.job_level += (unsigned int)level;
  2479. clif_updatestatus(sd, SP_JOBLEVEL);
  2480. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2481. if (sd->status.skill_point > USHRT_MAX - level)
  2482. sd->status.skill_point = USHRT_MAX;
  2483. else
  2484. sd->status.skill_point += level;
  2485. clif_updatestatus(sd, SP_SKILLPOINT);
  2486. status_calc_pc(sd, 0);
  2487. clif_misceffect(&sd->bl, 1);
  2488. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  2489. } else {
  2490. if (sd->status.job_level == 1) {
  2491. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  2492. return -1;
  2493. }
  2494. level *=-1;
  2495. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2496. level = sd->status.job_level-1;
  2497. sd->status.job_level -= (unsigned int)level;
  2498. clif_updatestatus(sd, SP_JOBLEVEL);
  2499. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2500. if (sd->status.skill_point < level)
  2501. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2502. if (sd->status.skill_point < level)
  2503. sd->status.skill_point = 0;
  2504. else
  2505. sd->status.skill_point -= level;
  2506. clif_updatestatus(sd, SP_SKILLPOINT);
  2507. status_calc_pc(sd, 0);
  2508. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  2509. }
  2510. return 0;
  2511. }
  2512. /*==========================================
  2513. * @help
  2514. *------------------------------------------
  2515. */
  2516. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2517. {
  2518. char buf[2048], w1[2048], w2[2048];
  2519. int i, gm_level;
  2520. FILE* fp;
  2521. nullpo_retr(-1, sd);
  2522. memset(buf, '\0', sizeof(buf));
  2523. if ((fp = fopen(help_txt, "r")) != NULL) {
  2524. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2525. gm_level = pc_isGM(sd);
  2526. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2527. if (buf[0] == '/' && buf[1] == '/')
  2528. continue;
  2529. for (i = 0; buf[i] != '\0'; i++) {
  2530. if (buf[i] == '\r' || buf[i] == '\n') {
  2531. buf[i] = '\0';
  2532. break;
  2533. }
  2534. }
  2535. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2536. clif_displaymessage(fd, buf);
  2537. else if (gm_level >= atoi(w1))
  2538. clif_displaymessage(fd, w2);
  2539. }
  2540. fclose(fp);
  2541. } else {
  2542. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2543. return -1;
  2544. }
  2545. return 0;
  2546. }
  2547. /*==========================================
  2548. * @help2 - Char commands [Kayla]
  2549. *------------------------------------------
  2550. */
  2551. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2552. {
  2553. char buf[2048], w1[2048], w2[2048];
  2554. int i, gm_level;
  2555. FILE* fp;
  2556. nullpo_retr(-1, sd);
  2557. memset(buf, '\0', sizeof(buf));
  2558. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2559. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2560. gm_level = pc_isGM(sd);
  2561. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2562. if (buf[0] == '/' && buf[1] == '/')
  2563. continue;
  2564. for (i = 0; buf[i] != '\0'; i++) {
  2565. if (buf[i] == '\r' || buf[i] == '\n') {
  2566. buf[i] = '\0';
  2567. break;
  2568. }
  2569. }
  2570. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2571. clif_displaymessage(fd, buf);
  2572. else if (gm_level >= atoi(w1))
  2573. clif_displaymessage(fd, w2);
  2574. }
  2575. fclose(fp);
  2576. } else {
  2577. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2578. return -1;
  2579. }
  2580. return 0;
  2581. }
  2582. /*==========================================
  2583. * @gm
  2584. *------------------------------------------
  2585. */
  2586. int atcommand_gm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2587. {
  2588. char password[100];
  2589. nullpo_retr(-1, sd);
  2590. memset(password, '\0', sizeof(password));
  2591. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2592. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2593. return -1;
  2594. }
  2595. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2596. clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
  2597. return -1;
  2598. } else
  2599. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2600. return 0;
  2601. }
  2602. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  2603. {
  2604. struct unit_data *ud = unit_bl2ud(bl);
  2605. int id = va_arg(ap, int);
  2606. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  2607. {
  2608. unit_stop_attack(bl);
  2609. return 1;
  2610. }
  2611. return 0;
  2612. }
  2613. /*==========================================
  2614. *
  2615. *------------------------------------------
  2616. */
  2617. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) {
  2618. TBL_PC* sd = (TBL_PC*)bl;
  2619. clif_pvpset(sd, 0, 0, 2);
  2620. if (sd->pvp_timer != UINT_MAX) {
  2621. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  2622. sd->pvp_timer = UINT_MAX;
  2623. }
  2624. return 0;
  2625. }
  2626. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2627. {
  2628. nullpo_retr(-1, sd);
  2629. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2630. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2631. return -1;
  2632. }
  2633. if (!map[sd->bl.m].flag.pvp) {
  2634. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2635. return -1;
  2636. }
  2637. map[sd->bl.m].flag.pvp = 0;
  2638. clif_send0199(sd->bl.m, 0);
  2639. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  2640. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  2641. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2642. return 0;
  2643. }
  2644. /*==========================================
  2645. *
  2646. *------------------------------------------
  2647. */
  2648. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2649. {
  2650. struct map_session_data *pl_sd, **pl_allsd;
  2651. int i, users;
  2652. nullpo_retr(-1, sd);
  2653. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2654. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2655. return -1;
  2656. }
  2657. if (!map[sd->bl.m].flag.pvp) {
  2658. map[sd->bl.m].flag.pvp = 1;
  2659. clif_send0199(sd->bl.m, 1);
  2660. pl_allsd = map_getallusers(&users);
  2661. for (i = 0; i < users; i++) {
  2662. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2663. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2664. pl_sd->pvp_rank = 0;
  2665. pl_sd->pvp_lastusers = 0;
  2666. pl_sd->pvp_point = 5;
  2667. pl_sd->pvp_won = 0;
  2668. pl_sd->pvp_lost = 0;
  2669. }
  2670. }
  2671. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2672. } else {
  2673. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2674. return -1;
  2675. }
  2676. return 0;
  2677. }
  2678. /*==========================================
  2679. *
  2680. *------------------------------------------
  2681. */
  2682. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2683. {
  2684. nullpo_retr(-1, sd);
  2685. if (map[sd->bl.m].flag.gvg) {
  2686. map[sd->bl.m].flag.gvg = 0;
  2687. clif_send0199(sd->bl.m, 0);
  2688. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  2689. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2690. } else {
  2691. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2692. return -1;
  2693. }
  2694. return 0;
  2695. }
  2696. /*==========================================
  2697. *
  2698. *------------------------------------------
  2699. */
  2700. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2701. {
  2702. nullpo_retr(-1, sd);
  2703. if (!map[sd->bl.m].flag.gvg) {
  2704. map[sd->bl.m].flag.gvg = 1;
  2705. clif_send0199(sd->bl.m, 3);
  2706. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2707. } else {
  2708. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2709. return -1;
  2710. }
  2711. return 0;
  2712. }
  2713. /*==========================================
  2714. *
  2715. *------------------------------------------
  2716. */
  2717. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2718. {
  2719. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2720. nullpo_retr(-1, sd);
  2721. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2722. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2723. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2724. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2725. clif_displaymessage(fd, atcmd_output);
  2726. return -1;
  2727. }
  2728. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2729. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2730. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2731. /* Removed because this check is TOO strange. [Skotlex]
  2732. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2733. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2734. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2735. return -1;
  2736. } else {
  2737. */
  2738. pc_changelook(sd, LOOK_HAIR, hair_style);
  2739. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2740. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2741. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2742. // }
  2743. } else {
  2744. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2745. return -1;
  2746. }
  2747. return 0;
  2748. }
  2749. /*==========================================
  2750. * @dye && @ccolor
  2751. *------------------------------------------
  2752. */
  2753. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2754. {
  2755. int cloth_color = 0;
  2756. nullpo_retr(-1, sd);
  2757. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2758. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2759. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2760. clif_displaymessage(fd, atcmd_output);
  2761. return -1;
  2762. }
  2763. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2764. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2765. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2766. } else {
  2767. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2768. return -1;
  2769. }
  2770. return 0;
  2771. }
  2772. /*==========================================
  2773. * @hairstyle && @hstyle
  2774. *------------------------------------------
  2775. */
  2776. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2777. {
  2778. int hair_style = 0;
  2779. nullpo_retr(-1, sd);
  2780. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2781. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2782. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2783. clif_displaymessage(fd, atcmd_output);
  2784. return -1;
  2785. }
  2786. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2787. /* Removed because this check is TOO strange. [Skotlex]
  2788. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2789. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2790. return -1;
  2791. } else {
  2792. */
  2793. pc_changelook(sd, LOOK_HAIR, hair_style);
  2794. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2795. // }
  2796. } else {
  2797. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2798. return -1;
  2799. }
  2800. return 0;
  2801. }
  2802. /*==========================================
  2803. * @haircolor && @hcolor
  2804. *------------------------------------------
  2805. */
  2806. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2807. {
  2808. int hair_color = 0;
  2809. nullpo_retr(-1, sd);
  2810. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2811. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2812. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2813. clif_displaymessage(fd, atcmd_output);
  2814. return -1;
  2815. }
  2816. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2817. /* Removed for being such a strange check. [Skotlex]
  2818. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2819. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2820. return -1;
  2821. } else {
  2822. */
  2823. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2824. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2825. // }
  2826. } else {
  2827. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2828. return -1;
  2829. }
  2830. return 0;
  2831. }
  2832. /*==========================================
  2833. * @go [city_number or city_name] - Updated by Harbin
  2834. *------------------------------------------
  2835. */
  2836. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2837. {
  2838. int i;
  2839. int town;
  2840. char map_name[MAP_NAME_LENGTH];
  2841. int m;
  2842. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2843. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2844. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2845. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2846. { MAP_PAYON, 162, 233 }, // 3=Payon
  2847. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2848. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2849. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2850. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2851. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2852. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2853. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2854. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2855. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2856. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2857. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2858. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  2859. { MAP_JAIL, 23, 61 }, // 16=Prison
  2860. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2861. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2862. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2863. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2864. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2865. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2866. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2867. { MAP_VEINS, 216, 123 }, // 24=Veins
  2868. };
  2869. nullpo_retr(-1, sd);
  2870. if(map[sd->bl.m].flag.nogo) {
  2871. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2872. return 0;
  2873. }
  2874. memset(map_name, '\0', sizeof(map_name));
  2875. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2876. // get the number
  2877. town = atoi(message);
  2878. // if no value, display all value
  2879. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2880. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2881. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  2882. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2883. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2884. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2885. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2886. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2887. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2888. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2889. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2890. clif_displaymessage(fd, " 24=Veins");
  2891. return -1;
  2892. } else {
  2893. // get possible name of the city and add .gat if not in the name
  2894. map_name[MAP_NAME_LENGTH-1] = '\0';
  2895. for (i = 0; map_name[i]; i++)
  2896. map_name[i] = tolower(map_name[i]);
  2897. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2898. strcat(map_name, ".gat");
  2899. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2900. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2901. town = 0;
  2902. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2903. town = 1;
  2904. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2905. town = 2;
  2906. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2907. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2908. town = 3;
  2909. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2910. town = 4;
  2911. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2912. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2913. town = 5;
  2914. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2915. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2916. town = 6;
  2917. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2918. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2919. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2920. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2921. town = 7;
  2922. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2923. town = 8;
  2924. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2925. town = 9;
  2926. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2927. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2928. town = 10;
  2929. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2930. town = 11;
  2931. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2932. town = 12;
  2933. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2934. town = 13;
  2935. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2936. town = 14;
  2937. } else if (strncmp(map_name, "new_zone01.gat", 3) == 0 || // 3 first characters (or "newbies")
  2938. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2939. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2940. town = 15;
  2941. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2942. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2943. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2944. town = 16;
  2945. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2946. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2947. town = 17;
  2948. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2949. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2950. town = 18;
  2951. } else if (strncmp(map_name, "einbroch.gat", 5) == 0 || // 5 first characters
  2952. strncmp(map_name, "ainbroch.gat", 5) == 0) { // writing error (5 first characters)
  2953. town = 19;
  2954. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2955. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2956. town = 20;
  2957. } else if (strncmp(map_name, "einbech.gat", 3) == 0) { // 3 first characters
  2958. town = 21;
  2959. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2960. town = 22;
  2961. } else if (strncmp(map_name, "rachel.gat", 3) == 0) { // 3 first characters
  2962. town = 23;
  2963. } else if (strncmp(map_name, "veins.gat", 3) == 0) { // 3 first characters
  2964. town = 24;
  2965. }
  2966. if (town >= -3 && town <= -1) {
  2967. if (sd->status.memo_point[-town-1].map) {
  2968. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2969. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2970. clif_displaymessage(fd, msg_txt(247));
  2971. return -1;
  2972. }
  2973. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2974. clif_displaymessage(fd, msg_txt(248));
  2975. return -1;
  2976. }
  2977. if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
  2978. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2979. } else {
  2980. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2981. return -1;
  2982. }
  2983. } else {
  2984. sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
  2985. clif_displaymessage(fd, atcmd_output);
  2986. return -1;
  2987. }
  2988. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2989. m = map_mapname2mapid((char *)data[town].map);
  2990. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2991. clif_displaymessage(fd, msg_txt(247));
  2992. return -1;
  2993. }
  2994. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2995. clif_displaymessage(fd, msg_txt(248));
  2996. return -1;
  2997. }
  2998. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2999. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3000. } else {
  3001. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3002. return -1;
  3003. }
  3004. } else { // if you arrive here, you have an error in town variable when reading of names
  3005. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  3006. return -1;
  3007. }
  3008. }
  3009. return 0;
  3010. }
  3011. /*==========================================
  3012. *
  3013. *------------------------------------------
  3014. */
  3015. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3016. {
  3017. char name[NAME_LENGTH];
  3018. char monster[NAME_LENGTH];
  3019. int mob_id;
  3020. int number = 0;
  3021. int count;
  3022. int i, k, range;
  3023. short mx, my;
  3024. nullpo_retr(-1, sd);
  3025. memset(name, '\0', sizeof(name));
  3026. memset(monster, '\0', sizeof(monster));
  3027. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3028. if (!message || !*message) {
  3029. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3030. return -1;
  3031. }
  3032. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3033. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3034. //All data can be left as it is.
  3035. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3036. //Here, it is possible name was not given and we are using monster for it.
  3037. if (count < 3) //Blank mob's name.
  3038. name[0] = '\0';
  3039. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3040. //All data can be left as it is.
  3041. } else if (sscanf(message, "%23s", monster) > 0) {
  3042. //As before, name may be already filled.
  3043. name[0] = '\0';
  3044. } else {
  3045. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3046. return -1;
  3047. }
  3048. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3049. mob_id = mobdb_checkid(atoi(monster));
  3050. if (mob_id == 0) {
  3051. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3052. return -1;
  3053. }
  3054. if (mob_id == MOBID_EMPERIUM) {
  3055. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  3056. return -1;
  3057. }
  3058. if (number <= 0)
  3059. number = 1;
  3060. if (strlen(name) < 1)
  3061. strcpy(name, "--ja--");
  3062. // 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
  3063. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3064. number = battle_config.atc_spawn_quantity_limit;
  3065. if (battle_config.etc_log)
  3066. 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);
  3067. count = 0;
  3068. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3069. for (i = 0; i < number; i++) {
  3070. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3071. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3072. count += (k != 0) ? 1 : 0;
  3073. }
  3074. if (count != 0)
  3075. if (number == count)
  3076. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  3077. else {
  3078. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  3079. clif_displaymessage(fd, atcmd_output);
  3080. }
  3081. else {
  3082. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3083. return -1;
  3084. }
  3085. return 0;
  3086. }
  3087. // small monster spawning [Valaris]
  3088. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3089. {
  3090. char name[NAME_LENGTH] = "";
  3091. char monster[NAME_LENGTH] = "";
  3092. int mob_id = 0;
  3093. int number = 0;
  3094. int x = 0;
  3095. int y = 0;
  3096. int count;
  3097. int i;
  3098. nullpo_retr(-1, sd);
  3099. if (!message || !*message) {
  3100. clif_displaymessage(fd, "Give a monster name/id please.");
  3101. return -1;
  3102. }
  3103. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3104. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3105. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3106. clif_displaymessage(fd, "Give a monster name/id please.");
  3107. return -1;
  3108. }
  3109. // If monster identifier/name argument is a name
  3110. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3111. mob_id = atoi(monster);
  3112. if (mob_id == 0) {
  3113. clif_displaymessage(fd, msg_txt(40));
  3114. return -1;
  3115. }
  3116. if (mob_id == MOBID_EMPERIUM) {
  3117. clif_displaymessage(fd, msg_txt(83));
  3118. return -1;
  3119. }
  3120. if (mobdb_checkid(mob_id) == 0) {
  3121. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3122. return -1;
  3123. }
  3124. if (number <= 0)
  3125. number = 1;
  3126. if (strlen(name) < 1)
  3127. strcpy(name, "--ja--");
  3128. // 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
  3129. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3130. number = battle_config.atc_spawn_quantity_limit;
  3131. count = 0;
  3132. for (i = 0; i < number; i++) {
  3133. int mx, my;
  3134. if (x <= 0)
  3135. mx = sd->bl.x + (rand() % 11 - 5);
  3136. else
  3137. mx = x;
  3138. if (y <= 0)
  3139. my = sd->bl.y + (rand() % 11 - 5);
  3140. else
  3141. my = y;
  3142. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3143. }
  3144. if (count != 0)
  3145. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3146. else
  3147. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3148. return 0;
  3149. }
  3150. // big monster spawning [Valaris]
  3151. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3152. {
  3153. char name[NAME_LENGTH] = "";
  3154. char monster[NAME_LENGTH] = "";
  3155. int mob_id = 0;
  3156. int number = 0;
  3157. int x = 0;
  3158. int y = 0;
  3159. int count;
  3160. int i;
  3161. nullpo_retr(-1, sd);
  3162. if (!message || !*message) {
  3163. clif_displaymessage(fd, "Give a monster name/id please.");
  3164. return -1;
  3165. }
  3166. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3167. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3168. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3169. clif_displaymessage(fd, "Give a monster name/id please.");
  3170. return -1;
  3171. }
  3172. // If monster identifier/name argument is a name
  3173. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3174. mob_id = atoi(monster);
  3175. if (mob_id == 0) {
  3176. clif_displaymessage(fd, msg_txt(40));
  3177. return -1;
  3178. }
  3179. if (mob_id == MOBID_EMPERIUM) {
  3180. clif_displaymessage(fd, msg_txt(83));
  3181. return -1;
  3182. }
  3183. if (mobdb_checkid(mob_id) == 0) {
  3184. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3185. return -1;
  3186. }
  3187. if (number <= 0)
  3188. number = 1;
  3189. if (strlen(name) < 1)
  3190. strcpy(name, "--ja--");
  3191. // 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
  3192. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3193. number = battle_config.atc_spawn_quantity_limit;
  3194. count = 0;
  3195. for (i = 0; i < number; i++) {
  3196. int mx, my;
  3197. if (x <= 0)
  3198. mx = sd->bl.x + (rand() % 11 - 5);
  3199. else
  3200. mx = x;
  3201. if (y <= 0)
  3202. my = sd->bl.y + (rand() % 11 - 5);
  3203. else
  3204. my = y;
  3205. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3206. }
  3207. if (count != 0)
  3208. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3209. else
  3210. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3211. return 0;
  3212. }
  3213. /*==========================================
  3214. *
  3215. *------------------------------------------
  3216. */
  3217. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  3218. {
  3219. struct mob_data *md;
  3220. int flag;
  3221. nullpo_retr(0, ap);
  3222. nullpo_retr(0, md=(struct mob_data *)bl);
  3223. flag = va_arg(ap, int);
  3224. if (md->guardian_data)
  3225. return 0; //Do not touch WoE mobs!
  3226. if (flag)
  3227. status_zap(bl,md->status.hp, 0);
  3228. else
  3229. status_kill(bl);
  3230. return 1;
  3231. }
  3232. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  3233. {
  3234. int map_id;
  3235. char map_name[MAP_NAME_LENGTH];
  3236. if (!sd) return;
  3237. memset(map_name, '\0', sizeof(map_name));
  3238. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3239. map_id = sd->bl.m;
  3240. else {
  3241. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3242. strcat(map_name, ".gat");
  3243. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3244. map_id = sd->bl.m;
  3245. }
  3246. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3247. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  3248. return;
  3249. }
  3250. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3251. {
  3252. if (!sd) return 0;
  3253. atcommand_killmonster_sub(fd, sd, message, 1);
  3254. return 0;
  3255. }
  3256. /*==========================================
  3257. *
  3258. *------------------------------------------
  3259. */
  3260. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3261. {
  3262. if (!sd) return 0;
  3263. atcommand_killmonster_sub(fd, sd, message, 0);
  3264. return 0;
  3265. }
  3266. /*==========================================
  3267. *
  3268. *------------------------------------------
  3269. */
  3270. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3271. {
  3272. int i,j, position = 0, refine = 0, current_position, final_refine;
  3273. int count;
  3274. nullpo_retr(-1, sd);
  3275. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3276. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3277. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3278. return -1;
  3279. }
  3280. if (refine < -MAX_REFINE)
  3281. refine = -MAX_REFINE;
  3282. else if (refine > MAX_REFINE)
  3283. refine = MAX_REFINE;
  3284. else if (refine == 0)
  3285. refine = 1;
  3286. count = 0;
  3287. for (j = 0; j < EQI_MAX-1; j++) {
  3288. if ((i = sd->equip_index[j]) < 0)
  3289. continue;
  3290. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  3291. continue;
  3292. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  3293. continue;
  3294. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  3295. continue;
  3296. if(position && !(sd->status.inventory[i].equip & position))
  3297. continue;
  3298. final_refine = sd->status.inventory[i].refine + refine;
  3299. if (final_refine > MAX_REFINE)
  3300. final_refine = MAX_REFINE;
  3301. else if (final_refine < 0)
  3302. final_refine = 0;
  3303. if (sd->status.inventory[i].refine != final_refine) {
  3304. sd->status.inventory[i].refine = final_refine;
  3305. current_position = sd->status.inventory[i].equip;
  3306. pc_unequipitem(sd, i, 3);
  3307. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3308. clif_delitem(sd, i, 1);
  3309. clif_additem(sd, i, 1, 0);
  3310. pc_equipitem(sd, i, current_position);
  3311. clif_misceffect(&sd->bl, 3);
  3312. count++;
  3313. }
  3314. }
  3315. if (count == 0)
  3316. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  3317. else if (count == 1)
  3318. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  3319. else {
  3320. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  3321. clif_displaymessage(fd, atcmd_output);
  3322. }
  3323. return 0;
  3324. }
  3325. /*==========================================
  3326. *
  3327. *------------------------------------------
  3328. */
  3329. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3330. {
  3331. char item_name[100];
  3332. int item_id, attribute = 0, star = 0;
  3333. int flag = 0;
  3334. struct item_data *item_data;
  3335. struct item tmp_item;
  3336. nullpo_retr(-1, sd);
  3337. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3338. memset(item_name, '\0', sizeof(item_name));
  3339. if (!message || !*message || (
  3340. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  3341. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  3342. )) {
  3343. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3344. return -1;
  3345. }
  3346. item_id = 0;
  3347. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  3348. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  3349. {
  3350. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  3351. clif_displaymessage(fd, atcmd_output);
  3352. return -1;
  3353. }
  3354. item_id = item_data->nameid;
  3355. if (itemdb_isequip2(item_data)) {
  3356. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3357. attribute = ATTRIBUTE_NORMAL;
  3358. if (star < MIN_STAR || star > MAX_STAR)
  3359. star = 0;
  3360. memset(&tmp_item, 0, sizeof tmp_item);
  3361. tmp_item.nameid = item_id;
  3362. tmp_item.amount = 1;
  3363. tmp_item.identify = 1;
  3364. tmp_item.card[0] = CARD0_FORGE;
  3365. tmp_item.card[1] = item_data->type==IT_WEAPON?
  3366. ((star*5) << 8) + attribute:0;
  3367. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  3368. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  3369. clif_produceeffect(sd, 0, item_id);
  3370. clif_misceffect(&sd->bl, 3);
  3371. //Logs (A)dmins items [Lupus]
  3372. if(log_config.enable_logs&0x400)
  3373. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  3374. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3375. clif_additem(sd, 0, 0, flag);
  3376. } else {
  3377. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3378. clif_displaymessage(fd, atcmd_output);
  3379. return -1;
  3380. }
  3381. return 0;
  3382. }
  3383. /*==========================================
  3384. * Sub-function to display actual memo points
  3385. *------------------------------------------
  3386. */
  3387. void atcommand_memo_sub(struct map_session_data* sd)
  3388. {
  3389. int i;
  3390. if (!sd) return;
  3391. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3392. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3393. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3394. if (sd->status.memo_point[i].map)
  3395. 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);
  3396. else
  3397. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  3398. clif_displaymessage(sd->fd, atcmd_output);
  3399. }
  3400. return;
  3401. }
  3402. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3403. {
  3404. int position = 0;
  3405. nullpo_retr(-1, sd);
  3406. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3407. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3408. atcommand_memo_sub(sd);
  3409. else {
  3410. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3411. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3412. clif_displaymessage(fd, msg_txt(253));
  3413. return -1;
  3414. }
  3415. if (sd->status.memo_point[position].map) {
  3416. sprintf(atcmd_output, msg_txt(172), position, mapindex_id2name(sd->status.memo_point[position].map), sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
  3417. clif_displaymessage(fd, atcmd_output);
  3418. }
  3419. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3420. sd->status.memo_point[position].x = sd->bl.x;
  3421. sd->status.memo_point[position].y = sd->bl.y;
  3422. clif_skill_memo(sd, 0);
  3423. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3424. clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
  3425. atcommand_memo_sub(sd);
  3426. } else {
  3427. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3428. clif_displaymessage(fd, atcmd_output);
  3429. atcommand_memo_sub(sd);
  3430. return -1;
  3431. }
  3432. }
  3433. return 0;
  3434. }
  3435. /*==========================================
  3436. *
  3437. *------------------------------------------
  3438. */
  3439. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3440. {
  3441. int y;
  3442. nullpo_retr(-1, sd);
  3443. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3444. for (y = 2; y >= -2; y--) {
  3445. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3446. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3447. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3448. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3449. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3450. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3451. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3452. clif_displaymessage(fd, atcmd_output);
  3453. }
  3454. return 0;
  3455. }
  3456. /*==========================================
  3457. *
  3458. *------------------------------------------
  3459. */
  3460. int atcommand_packet(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3461. {
  3462. static int packet_mode = 0;
  3463. int i, x = 0, y = 0;
  3464. nullpo_retr(-1, sd);
  3465. if (strstr(command, "packetmode")) {
  3466. packet_mode = atoi(message);
  3467. clif_displaymessage(fd, "Packet mode changed.");
  3468. return 0;
  3469. }
  3470. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3471. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3472. return -1;
  3473. }
  3474. if (i == 1) y = 1;
  3475. switch (packet_mode)
  3476. {
  3477. case 0:
  3478. clif_status_change(&sd->bl, x, y);
  3479. break;
  3480. case 1:
  3481. sd->status.skill[sd->cloneskill_id].id=0;
  3482. sd->status.skill[sd->cloneskill_id].lv=0;
  3483. sd->status.skill[sd->cloneskill_id].flag=0;
  3484. sd->cloneskill_id = x;
  3485. sd->status.skill[x].id = x;
  3486. sd->status.skill[x].lv = skill_get_max(x);
  3487. sd->status.skill[x].flag = 13;//cloneskill flag
  3488. clif_skillinfoblock(sd);
  3489. break;
  3490. case 2:
  3491. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3492. case 3:
  3493. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3494. default:
  3495. break;
  3496. //added later
  3497. }
  3498. return 0;
  3499. }
  3500. /*==========================================
  3501. * @stpoint (Rewritten by [Yor])
  3502. *------------------------------------------
  3503. */
  3504. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3505. {
  3506. int point, new_status_point;
  3507. if (!message || !*message || (point = atoi(message)) == 0) {
  3508. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3509. return -1;
  3510. }
  3511. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3512. new_status_point = USHRT_MAX;
  3513. else
  3514. if (point < 0 && sd->status.status_point < -point)
  3515. new_status_point = 0;
  3516. else
  3517. new_status_point = sd->status.status_point + point;
  3518. if (new_status_point != (int)sd->status.status_point) {
  3519. sd->status.status_point = (unsigned short)new_status_point;
  3520. clif_updatestatus(sd, SP_STATUSPOINT);
  3521. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  3522. } else {
  3523. if (point < 0)
  3524. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3525. else
  3526. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3527. return -1;
  3528. }
  3529. return 0;
  3530. }
  3531. /*==========================================
  3532. * @skpoint (Rewritten by [Yor])
  3533. *------------------------------------------
  3534. */
  3535. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3536. {
  3537. int point, new_skill_point;
  3538. nullpo_retr(-1, sd);
  3539. if (!message || !*message || (point = atoi(message)) == 0) {
  3540. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3541. return -1;
  3542. }
  3543. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3544. new_skill_point = USHRT_MAX;
  3545. else if (point < 0 && sd->status.skill_point < -point)
  3546. new_skill_point = 0;
  3547. else
  3548. new_skill_point = sd->status.skill_point + point;
  3549. if (new_skill_point != (int)sd->status.skill_point) {
  3550. sd->status.skill_point = (unsigned short)new_skill_point;
  3551. clif_updatestatus(sd, SP_SKILLPOINT);
  3552. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  3553. } else {
  3554. if (point < 0)
  3555. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3556. else
  3557. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3558. return -1;
  3559. }
  3560. return 0;
  3561. }
  3562. /*==========================================
  3563. * @zeny (Rewritten by [Yor])
  3564. *------------------------------------------
  3565. */
  3566. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3567. {
  3568. int zeny, new_zeny;
  3569. nullpo_retr(-1, sd);
  3570. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3571. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3572. return -1;
  3573. }
  3574. new_zeny = sd->status.zeny + zeny;
  3575. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3576. new_zeny = MAX_ZENY;
  3577. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3578. new_zeny = 0;
  3579. if (new_zeny != sd->status.zeny) {
  3580. sd->status.zeny = new_zeny;
  3581. clif_updatestatus(sd, SP_ZENY);
  3582. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  3583. } else {
  3584. if (zeny < 0)
  3585. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3586. else
  3587. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3588. return -1;
  3589. }
  3590. return 0;
  3591. }
  3592. /*==========================================
  3593. *
  3594. *------------------------------------------
  3595. */
  3596. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3597. {
  3598. int i, value = 0, new_value, max;
  3599. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3600. short* status[6];
  3601. //we don't use direct initialization because it isn't part of the c standard.
  3602. nullpo_retr(-1, sd);
  3603. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3604. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3605. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3606. clif_displaymessage(fd, atcmd_output);
  3607. return -1;
  3608. }
  3609. for (i = 0; param[i] != NULL; i++)
  3610. if (strcmpi(command, param[i]) == 0)
  3611. break;
  3612. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  3613. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3614. clif_displaymessage(fd, atcmd_output);
  3615. return -1;
  3616. }
  3617. status[0] = &sd->status.str;
  3618. status[1] = &sd->status.agi;
  3619. status[2] = &sd->status.vit;
  3620. status[3] = &sd->status.int_;
  3621. status[4] = &sd->status.dex;
  3622. status[5] = &sd->status.luk;
  3623. max = pc_maxparameter(sd);
  3624. new_value = cap_value(*status[i] + value, 1, max);
  3625. if (new_value != (int)*status[i]) {
  3626. *status[i] = new_value;
  3627. clif_updatestatus(sd, SP_STR + i);
  3628. clif_updatestatus(sd, SP_USTR + i);
  3629. status_calc_pc(sd, 0);
  3630. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3631. } else {
  3632. if (value < 0)
  3633. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3634. else
  3635. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3636. return -1;
  3637. }
  3638. return 0;
  3639. }
  3640. /*==========================================
  3641. * Stat all by fritz (rewritten by [Yor])
  3642. *------------------------------------------
  3643. */
  3644. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3645. {
  3646. int index, count, value = 0, max, new_value;
  3647. short* status[6];
  3648. //we don't use direct initialization because it isn't part of the c standard.
  3649. nullpo_retr(-1, sd);
  3650. status[0] = &sd->status.str;
  3651. status[1] = &sd->status.agi;
  3652. status[2] = &sd->status.vit;
  3653. status[3] = &sd->status.int_;
  3654. status[4] = &sd->status.dex;
  3655. status[5] = &sd->status.luk;
  3656. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3657. value = pc_maxparameter(sd);
  3658. count = 0;
  3659. max = pc_maxparameter(sd);
  3660. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3661. if (value > 0 && *status[index] > max - value)
  3662. new_value = max;
  3663. else if (value < 0 && *status[index] <= -value)
  3664. new_value = 1;
  3665. else
  3666. new_value = *status[index] +value;
  3667. if (new_value != (int)*status[index]) {
  3668. *status[index] = new_value;
  3669. clif_updatestatus(sd, SP_STR + index);
  3670. clif_updatestatus(sd, SP_USTR + index);
  3671. count++;
  3672. }
  3673. }
  3674. if (count > 0) { // if at least 1 stat modified
  3675. status_calc_pc(sd, 0);
  3676. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3677. } else {
  3678. if (value < 0)
  3679. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  3680. else
  3681. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  3682. return -1;
  3683. }
  3684. return 0;
  3685. }
  3686. /*==========================================
  3687. *
  3688. *------------------------------------------
  3689. */
  3690. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3691. {
  3692. int level = 0;
  3693. short added_level;
  3694. struct guild *guild_info;
  3695. nullpo_retr(-1, sd);
  3696. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3697. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3698. return -1;
  3699. }
  3700. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3701. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3702. return -1;
  3703. }
  3704. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3705. clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3706. return -1;
  3707. }
  3708. added_level = (short)level;
  3709. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3710. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3711. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3712. added_level = 1 - guild_info->guild_lv;
  3713. if (added_level != 0) {
  3714. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3715. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3716. } else {
  3717. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3718. return -1;
  3719. }
  3720. return 0;
  3721. }
  3722. /*==========================================
  3723. *
  3724. *------------------------------------------
  3725. */
  3726. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3727. {
  3728. struct item_data *item_data;
  3729. int id, pet_id;
  3730. nullpo_retr(-1, sd);
  3731. if (!message || !*message) {
  3732. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3733. return -1;
  3734. }
  3735. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3736. id = item_data->nameid;
  3737. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3738. id = atoi(message);
  3739. pet_id = search_petDB_index(id, PET_CLASS);
  3740. if (pet_id < 0)
  3741. pet_id = search_petDB_index(id, PET_EGG);
  3742. if (pet_id >= 0) {
  3743. sd->catch_target_class = pet_db[pet_id].class_;
  3744. intif_create_pet(
  3745. sd->status.account_id, sd->status.char_id,
  3746. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3747. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3748. 100, 0, 1, pet_db[pet_id].jname);
  3749. } else {
  3750. clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
  3751. return -1;
  3752. }
  3753. return 0;
  3754. }
  3755. /*==========================================
  3756. *
  3757. *------------------------------------------
  3758. */
  3759. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3760. {
  3761. nullpo_retr(-1, sd);
  3762. if (sd->status.pet_id <= 0)
  3763. clif_sendegg(sd);
  3764. else {
  3765. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3766. return -1;
  3767. }
  3768. return 0;
  3769. }
  3770. /*==========================================
  3771. *
  3772. *------------------------------------------
  3773. */
  3774. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3775. {
  3776. int friendly;
  3777. struct pet_data *pd;
  3778. nullpo_retr(-1, sd);
  3779. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3780. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3781. return -1;
  3782. }
  3783. pd = sd->pd;
  3784. if (!pd) {
  3785. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3786. return -1;
  3787. }
  3788. if (friendly < 0 || friendly > 1000)
  3789. {
  3790. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3791. return -1;
  3792. }
  3793. if (friendly == pd->pet.intimate) {
  3794. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  3795. return -1;
  3796. }
  3797. pd->pet.intimate = friendly;
  3798. clif_send_petstatus(sd);
  3799. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  3800. return 0;
  3801. }
  3802. /*==========================================
  3803. *
  3804. *------------------------------------------
  3805. */
  3806. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3807. {
  3808. int hungry;
  3809. struct pet_data *pd;
  3810. nullpo_retr(-1, sd);
  3811. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3812. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3813. return -1;
  3814. }
  3815. pd = sd->pd;
  3816. if (!sd->status.pet_id || !pd) {
  3817. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3818. return -1;
  3819. }
  3820. if (hungry < 0 || hungry > 100) {
  3821. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3822. return -1;
  3823. }
  3824. if (hungry == pd->pet.hungry) {
  3825. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  3826. return -1;
  3827. }
  3828. pd->pet.hungry = hungry;
  3829. clif_send_petstatus(sd);
  3830. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  3831. return 0;
  3832. }
  3833. /*==========================================
  3834. *
  3835. *------------------------------------------
  3836. */
  3837. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3838. {
  3839. struct pet_data *pd;
  3840. nullpo_retr(-1, sd);
  3841. if (!sd->status.pet_id || !sd->pd) {
  3842. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3843. return -1;
  3844. }
  3845. pd = sd->pd;
  3846. if (!pd->pet.rename_flag) {
  3847. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  3848. return -1;
  3849. }
  3850. pd->pet.rename_flag = 0;
  3851. intif_save_petdata(sd->status.account_id, &pd->pet);
  3852. clif_send_petstatus(sd);
  3853. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  3854. return 0;
  3855. }
  3856. /*==========================================
  3857. *
  3858. *------------------------------------------
  3859. */
  3860. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3861. {
  3862. struct map_session_data *pl_sd = NULL;
  3863. nullpo_retr(-1, sd);
  3864. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3865. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3866. return -1;
  3867. }
  3868. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3869. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3870. return -1;
  3871. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3872. return -1;
  3873. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3874. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3875. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3876. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3877. return -1;
  3878. }
  3879. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3880. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3881. return -1;
  3882. }
  3883. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3884. sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
  3885. clif_displaymessage(fd, atcmd_output);
  3886. } else {
  3887. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3888. return -1;
  3889. }
  3890. } else {
  3891. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3892. return -1;
  3893. }
  3894. return 0;
  3895. }
  3896. /*==========================================
  3897. *
  3898. *------------------------------------------
  3899. */
  3900. int atcommand_revive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3901. {
  3902. struct map_session_data *pl_sd;
  3903. nullpo_retr(-1, sd);
  3904. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3905. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3906. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3907. return -1;
  3908. }
  3909. pl_sd = map_nick2sd(atcmd_player_name);
  3910. if (!pl_sd) {
  3911. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3912. return -1;
  3913. }
  3914. if (!status_revive(&pl_sd->bl, 100, 0))
  3915. return -1;
  3916. clif_skill_nodamage(&sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  3917. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  3918. return 0;
  3919. }
  3920. /*==========================================
  3921. * charblock command (usage: charblock <player_name>)
  3922. * This command do a definitiv ban on a player
  3923. *------------------------------------------
  3924. */
  3925. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3926. {
  3927. nullpo_retr(-1, sd);
  3928. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3929. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  3930. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3931. return -1;
  3932. }
  3933. // check player name
  3934. if (strlen(atcmd_player_name) < 4) {
  3935. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  3936. return -1;
  3937. } else if (strlen(atcmd_player_name) > 23) {
  3938. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  3939. return -1;
  3940. } else {
  3941. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3942. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  3943. }
  3944. return 0;
  3945. }
  3946. /*==========================================
  3947. * charban command (usage: charban <time> <player_name>)
  3948. * This command do a limited ban on a player
  3949. * Time is done as follows:
  3950. * Adjustment value (-1, 1, +1, etc...)
  3951. * Modified element:
  3952. * a or y: year
  3953. * m: month
  3954. * j or d: day
  3955. * h: hour
  3956. * mn: minute
  3957. * s: second
  3958. * <example> @ban +1m-2mn1s-6y test_player
  3959. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3960. *------------------------------------------
  3961. */
  3962. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3963. {
  3964. char * modif_p;
  3965. int year, month, day, hour, minute, second, value;
  3966. nullpo_retr(-1, sd);
  3967. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3968. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3969. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3970. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3971. return -1;
  3972. }
  3973. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3974. modif_p = atcmd_output;
  3975. year = month = day = hour = minute = second = 0;
  3976. while (modif_p[0] != '\0') {
  3977. value = atoi(modif_p);
  3978. if (value == 0)
  3979. modif_p++;
  3980. else {
  3981. if (modif_p[0] == '-' || modif_p[0] == '+')
  3982. modif_p++;
  3983. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3984. modif_p++;
  3985. if (modif_p[0] == 's') {
  3986. second = value;
  3987. modif_p++;
  3988. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  3989. minute = value;
  3990. modif_p = modif_p + 2;
  3991. } else if (modif_p[0] == 'h') {
  3992. hour = value;
  3993. modif_p++;
  3994. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3995. day = value;
  3996. modif_p++;
  3997. } else if (modif_p[0] == 'm') {
  3998. month = value;
  3999. modif_p++;
  4000. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4001. year = value;
  4002. modif_p++;
  4003. } else if (modif_p[0] != '\0') {
  4004. modif_p++;
  4005. }
  4006. }
  4007. }
  4008. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4009. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  4010. return -1;
  4011. }
  4012. // check player name
  4013. if (strlen(atcmd_player_name) < 4) {
  4014. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4015. return -1;
  4016. } else if (strlen(atcmd_player_name) > 23) {
  4017. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4018. return -1;
  4019. } else {
  4020. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4021. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4022. }
  4023. return 0;
  4024. }
  4025. /*==========================================
  4026. * charunblock command (usage: charunblock <player_name>)
  4027. *------------------------------------------
  4028. */
  4029. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4030. {
  4031. nullpo_retr(-1, sd);
  4032. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4033. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4034. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4035. return -1;
  4036. }
  4037. // check player name
  4038. if (strlen(atcmd_player_name) < 4) {
  4039. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4040. return -1;
  4041. } else if (strlen(atcmd_player_name) > 23) {
  4042. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4043. return -1;
  4044. } else {
  4045. // send answer to login server via char-server
  4046. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4047. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4048. }
  4049. return 0;
  4050. }
  4051. /*==========================================
  4052. * charunban command (usage: charunban <player_name>)
  4053. *------------------------------------------
  4054. */
  4055. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4056. {
  4057. nullpo_retr(-1, sd);
  4058. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4059. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4060. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4061. return -1;
  4062. }
  4063. // check player name
  4064. if (strlen(atcmd_player_name) < 4) {
  4065. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4066. return -1;
  4067. } else if (strlen(atcmd_player_name) > 23) {
  4068. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4069. return -1;
  4070. } else {
  4071. // send answer to login server via char-server
  4072. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4073. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4074. }
  4075. return 0;
  4076. }
  4077. /*==========================================
  4078. *
  4079. *------------------------------------------
  4080. */
  4081. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4082. {
  4083. nullpo_retr(-1, sd);
  4084. if (night_flag != 1) {
  4085. map_night_timer(night_timer_tid, 0, 0, 1);
  4086. } else {
  4087. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  4088. return -1;
  4089. }
  4090. return 0;
  4091. }
  4092. /*==========================================
  4093. *
  4094. *------------------------------------------
  4095. */
  4096. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4097. {
  4098. nullpo_retr(-1, sd);
  4099. if (night_flag != 0) {
  4100. map_day_timer(day_timer_tid, 0, 0, 1);
  4101. } else {
  4102. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  4103. return -1;
  4104. }
  4105. return 0;
  4106. }
  4107. /*==========================================
  4108. *
  4109. *------------------------------------------
  4110. */
  4111. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4112. {
  4113. struct map_session_data *pl_sd, **pl_allsd;
  4114. int i, users;
  4115. nullpo_retr(-1, sd);
  4116. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4117. pl_allsd = map_getallusers(&users);
  4118. for(i = 0; i < users; i++) {
  4119. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4120. status_kill(&pl_sd->bl);
  4121. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4122. }
  4123. }
  4124. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4125. return 0;
  4126. }
  4127. /*==========================================
  4128. *
  4129. *------------------------------------------
  4130. */
  4131. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4132. {
  4133. struct map_session_data *pl_sd, **pl_allsd;
  4134. int i, users;
  4135. nullpo_retr(-1, sd);
  4136. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4137. pl_allsd = map_getallusers(&users);
  4138. for (i = 0; i < users; i++) {
  4139. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4140. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4141. {
  4142. status_kill(&pl_sd->bl);
  4143. // clif_specialeffect(&pl_sd->bl,450,1);
  4144. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4145. }
  4146. }
  4147. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4148. return 0;
  4149. }
  4150. /*==========================================
  4151. *
  4152. *------------------------------------------
  4153. */
  4154. static void atcommand_raise_sub(struct map_session_data* sd)
  4155. {
  4156. if (!sd->state.auth || !status_isdead(&sd->bl))
  4157. return;
  4158. if(!status_revive(&sd->bl, 100, 100))
  4159. return;
  4160. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4161. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  4162. }
  4163. /*==========================================
  4164. *
  4165. *------------------------------------------
  4166. */
  4167. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4168. {
  4169. int i, users;
  4170. struct map_session_data **all_sd;
  4171. nullpo_retr(-1, sd);
  4172. all_sd = map_getallusers(&users);
  4173. for (i = 0; i < users; i++) {
  4174. atcommand_raise_sub(all_sd[i]);
  4175. }
  4176. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4177. return 0;
  4178. }
  4179. /*==========================================
  4180. *
  4181. *------------------------------------------
  4182. */
  4183. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4184. {
  4185. struct map_session_data **pl_allsd;
  4186. int i, users;
  4187. nullpo_retr(-1, sd);
  4188. pl_allsd = map_getallusers(&users);
  4189. for (i = 0; i < users; i++) {
  4190. if (sd->bl.m == pl_allsd[i]->bl.m)
  4191. atcommand_raise_sub(pl_allsd[i]);
  4192. }
  4193. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4194. return 0;
  4195. }
  4196. /*==========================================
  4197. *
  4198. *------------------------------------------
  4199. */
  4200. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4201. {
  4202. struct map_session_data *pl_sd;
  4203. nullpo_retr(-1, sd);
  4204. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4205. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4206. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4207. return -1;
  4208. }
  4209. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4210. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4211. clif_GM_kick(sd, pl_sd, 1);
  4212. else {
  4213. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4214. return -1;
  4215. }
  4216. } else {
  4217. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4218. return -1;
  4219. }
  4220. return 0;
  4221. }
  4222. /*==========================================
  4223. *
  4224. *------------------------------------------
  4225. */
  4226. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4227. {
  4228. struct map_session_data *pl_sd, **pl_allsd;
  4229. int i, users;
  4230. nullpo_retr(-1, sd);
  4231. pl_allsd = map_getallusers(&users);
  4232. for (i = 0; i < users; i++) {
  4233. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4234. if (sd->status.account_id != pl_sd->status.account_id)
  4235. clif_GM_kick(sd, pl_sd, 0);
  4236. }
  4237. }
  4238. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  4239. return 0;
  4240. }
  4241. /*==========================================
  4242. *
  4243. *------------------------------------------
  4244. */
  4245. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4246. {
  4247. nullpo_retr(-1, sd);
  4248. pc_allskillup(sd); // all skills
  4249. sd->status.skill_point = 0; // 0 skill points
  4250. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4251. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  4252. return 0;
  4253. }
  4254. /*==========================================
  4255. *
  4256. *------------------------------------------
  4257. */
  4258. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4259. {
  4260. int skill_id;
  4261. nullpo_retr(-1, sd);
  4262. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4263. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4264. return -1;
  4265. }
  4266. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4267. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4268. if (pc_checkskill(sd, skill_id) == 0) {
  4269. pc_skill(sd, skill_id, 1, 0);
  4270. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  4271. } else {
  4272. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  4273. return -1;
  4274. }
  4275. } else {
  4276. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4277. return -1;
  4278. }
  4279. } else {
  4280. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4281. return -1;
  4282. }
  4283. return 0;
  4284. }
  4285. /*==========================================
  4286. *
  4287. *------------------------------------------
  4288. */
  4289. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4290. {
  4291. int skill_id;
  4292. nullpo_retr(-1, sd);
  4293. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4294. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4295. return -1;
  4296. }
  4297. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4298. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4299. if (pc_checkskill(sd, skill_id) > 0) {
  4300. sd->status.skill[skill_id].lv = 0;
  4301. sd->status.skill[skill_id].flag = 0;
  4302. clif_skillinfoblock(sd);
  4303. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  4304. } else {
  4305. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  4306. return -1;
  4307. }
  4308. } else {
  4309. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4310. return -1;
  4311. }
  4312. } else {
  4313. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4314. return -1;
  4315. }
  4316. return 0;
  4317. }
  4318. /*==========================================
  4319. *
  4320. *------------------------------------------
  4321. */
  4322. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4323. {
  4324. int number;
  4325. nullpo_retr(-1, sd);
  4326. if (!message || !*message || (number = atoi(message)) < 0) {
  4327. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4328. return -1;
  4329. }
  4330. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4331. if (number > 500)
  4332. number = 500;
  4333. if (number >= 0 && number <= 0x7FFF) {
  4334. if (sd->spiritball != number || number > 499) {
  4335. if (sd->spiritball > 0)
  4336. pc_delspiritball(sd, sd->spiritball, 1);
  4337. sd->spiritball = number;
  4338. clif_spiritball(sd);
  4339. // no message, player can look the difference
  4340. if (number > 1000)
  4341. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4342. } else {
  4343. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  4344. return -1;
  4345. }
  4346. } else {
  4347. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4348. return -1;
  4349. }
  4350. return 0;
  4351. }
  4352. /*==========================================
  4353. *
  4354. *------------------------------------------
  4355. */
  4356. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4357. {
  4358. char party[NAME_LENGTH];
  4359. nullpo_retr(-1, sd);
  4360. memset(party, '\0', sizeof(party));
  4361. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4362. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4363. return -1;
  4364. }
  4365. party_create(sd, party, 0, 0);
  4366. return 0;
  4367. }
  4368. /*==========================================
  4369. *
  4370. *------------------------------------------
  4371. */
  4372. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4373. {
  4374. char guild[NAME_LENGTH];
  4375. int prev;
  4376. nullpo_retr(-1, sd);
  4377. memset(guild, '\0', sizeof(guild));
  4378. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4379. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4380. return -1;
  4381. }
  4382. prev = battle_config.guild_emperium_check;
  4383. battle_config.guild_emperium_check = 0;
  4384. guild_create(sd, guild);
  4385. battle_config.guild_emperium_check = prev;
  4386. return 0;
  4387. }
  4388. /*==========================================
  4389. *
  4390. *------------------------------------------
  4391. */
  4392. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4393. {
  4394. nullpo_retr(-1, sd);
  4395. if (agit_flag == 1) {
  4396. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  4397. return -1;
  4398. }
  4399. agit_flag = 1;
  4400. guild_agit_start();
  4401. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  4402. return 0;
  4403. }
  4404. /*==========================================
  4405. *
  4406. *------------------------------------------
  4407. */
  4408. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4409. {
  4410. nullpo_retr(-1, sd);
  4411. if (agit_flag == 0) {
  4412. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  4413. return -1;
  4414. }
  4415. agit_flag = 0;
  4416. guild_agit_end();
  4417. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  4418. return 0;
  4419. }
  4420. /*==========================================
  4421. * @mapexit - shuts down the map server
  4422. *------------------------------------------
  4423. */
  4424. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4425. {
  4426. struct map_session_data *pl_sd, **pl_allsd;
  4427. int i, users;
  4428. nullpo_retr(-1, sd);
  4429. pl_allsd = map_getallusers(&users);
  4430. for (i = 0; i < users; i++) {
  4431. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4432. clif_GM_kick(sd, pl_sd, 0);
  4433. }
  4434. clif_GM_kick(sd, sd, 0);
  4435. flush_fifos();
  4436. runflag = 0;
  4437. return 0;
  4438. }
  4439. /*==========================================
  4440. * idsearch <part_of_name>: revrited by [Yor]
  4441. *------------------------------------------
  4442. */
  4443. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4444. {
  4445. char item_name[100];
  4446. unsigned int i, match;
  4447. struct item_data *item_array[MAX_SEARCH];
  4448. nullpo_retr(-1, sd);
  4449. memset(item_name, '\0', sizeof(item_name));
  4450. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4451. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4452. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4453. return -1;
  4454. }
  4455. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  4456. clif_displaymessage(fd, atcmd_output);
  4457. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4458. if (match > MAX_SEARCH) {
  4459. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  4460. clif_displaymessage(fd, atcmd_output);
  4461. match = MAX_SEARCH;
  4462. }
  4463. for(i = 0; i < match; i++) {
  4464. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4465. clif_displaymessage(fd, atcmd_output);
  4466. }
  4467. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  4468. clif_displaymessage(fd, atcmd_output);
  4469. return 0;
  4470. }
  4471. /*==========================================
  4472. * Recall All Characters Online To Your Location
  4473. *------------------------------------------
  4474. */
  4475. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4476. {
  4477. struct map_session_data *pl_sd, **pl_allsd;
  4478. int i;
  4479. int count, users;
  4480. nullpo_retr(-1, sd);
  4481. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4482. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4483. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4484. return -1;
  4485. }
  4486. count = 0;
  4487. pl_allsd = map_getallusers(&users);
  4488. for (i = 0; i < users; i++) {
  4489. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4490. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4491. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4492. count++;
  4493. else {
  4494. if (pc_isdead(pl_sd)) { //Wake them up
  4495. pc_setstand(pl_sd);
  4496. pc_setrestartvalue(pl_sd,1);
  4497. }
  4498. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4499. }
  4500. }
  4501. }
  4502. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4503. if (count) {
  4504. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4505. clif_displaymessage(fd, atcmd_output);
  4506. }
  4507. return 0;
  4508. }
  4509. /*==========================================
  4510. * Recall online characters of a guild to your location
  4511. *------------------------------------------
  4512. */
  4513. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4514. {
  4515. struct map_session_data *pl_sd, **pl_allsd;
  4516. int i, users, count;
  4517. char guild_name[NAME_LENGTH];
  4518. struct guild *g;
  4519. nullpo_retr(-1, sd);
  4520. memset(guild_name, '\0', sizeof(guild_name));
  4521. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4522. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4523. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4524. return -1;
  4525. }
  4526. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4527. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4528. return -1;
  4529. }
  4530. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4531. (g = guild_search(atoi(message))) != NULL) {
  4532. count = 0;
  4533. pl_allsd = map_getallusers(&users);
  4534. for (i = 0; i < users; i++) {
  4535. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4536. pl_sd->status.guild_id == g->guild_id) {
  4537. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4538. continue; //Skip GMs greater than you.
  4539. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4540. count++;
  4541. else
  4542. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4543. }
  4544. }
  4545. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  4546. clif_displaymessage(fd, atcmd_output);
  4547. if (count) {
  4548. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4549. clif_displaymessage(fd, atcmd_output);
  4550. }
  4551. } else {
  4552. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4553. return -1;
  4554. }
  4555. return 0;
  4556. }
  4557. /*==========================================
  4558. * Recall online characters of a party to your location
  4559. *------------------------------------------
  4560. */
  4561. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4562. {
  4563. int i;
  4564. struct map_session_data *pl_sd, **pl_allsd;
  4565. char party_name[NAME_LENGTH];
  4566. struct party_data *p;
  4567. int count, users;
  4568. nullpo_retr(-1, sd);
  4569. memset(party_name, '\0', sizeof(party_name));
  4570. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4571. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4572. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4573. return -1;
  4574. }
  4575. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4576. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4577. return -1;
  4578. }
  4579. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4580. (p = party_search(atoi(message))) != NULL) {
  4581. count = 0;
  4582. pl_allsd = map_getallusers(&users);
  4583. for (i = 0; i < users; i++) {
  4584. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4585. pl_sd->status.party_id == p->party.party_id) {
  4586. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4587. continue; //Skip GMs greater than you.
  4588. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4589. count++;
  4590. else
  4591. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4592. }
  4593. }
  4594. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  4595. clif_displaymessage(fd, atcmd_output);
  4596. if (count) {
  4597. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4598. clif_displaymessage(fd, atcmd_output);
  4599. }
  4600. } else {
  4601. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4602. return -1;
  4603. }
  4604. return 0;
  4605. }
  4606. /*==========================================
  4607. *
  4608. *------------------------------------------
  4609. */
  4610. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4611. {
  4612. nullpo_retr(-1, sd);
  4613. itemdb_reload();
  4614. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  4615. return 0;
  4616. }
  4617. /*==========================================
  4618. *
  4619. *------------------------------------------
  4620. */
  4621. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4622. {
  4623. nullpo_retr(-1, sd);
  4624. mob_reload();
  4625. read_petdb();
  4626. merc_reload();
  4627. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  4628. return 0;
  4629. }
  4630. /*==========================================
  4631. *
  4632. *------------------------------------------
  4633. */
  4634. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4635. {
  4636. nullpo_retr(-1, sd);
  4637. skill_reload();
  4638. merc_skill_reload();
  4639. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  4640. return 0;
  4641. }
  4642. /*==========================================
  4643. * @reloadatcommand - reloads atcommand_athena.conf
  4644. *------------------------------------------
  4645. */
  4646. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4647. {
  4648. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4649. clif_displaymessage(fd, msg_txt(254));
  4650. return 0;
  4651. }
  4652. /*==========================================
  4653. * @reloadbattleconf - reloads battle_athena.conf
  4654. *------------------------------------------
  4655. */
  4656. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4657. {
  4658. struct Battle_Config prev_config;
  4659. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4660. battle_config_read(BATTLE_CONF_FILENAME);
  4661. if (memcmp(&prev_config.item_rate_mvp,
  4662. &battle_config.item_rate_mvp,
  4663. sizeof(battle_config.item_rate_mvp)+
  4664. sizeof(battle_config.item_rate_common)+
  4665. sizeof(battle_config.item_rate_common_boss)+
  4666. sizeof(battle_config.item_rate_card)+
  4667. sizeof(battle_config.item_rate_card_boss)+
  4668. sizeof(battle_config.item_rate_equip)+
  4669. sizeof(battle_config.item_rate_equip_boss)+
  4670. sizeof(battle_config.item_rate_heal)+
  4671. sizeof(battle_config.item_rate_heal_boss)+
  4672. sizeof(battle_config.item_rate_use)+
  4673. sizeof(battle_config.item_rate_use_boss)+
  4674. sizeof(battle_config.item_rate_treasure)+
  4675. sizeof(battle_config.item_rate_adddrop)+
  4676. sizeof(battle_config.logarithmic_drops)+
  4677. sizeof(battle_config.item_drop_common_min)+
  4678. sizeof(battle_config.item_drop_common_max)+
  4679. sizeof(battle_config.item_drop_card_min)+
  4680. sizeof(battle_config.item_drop_card_max)+
  4681. sizeof(battle_config.item_drop_equip_min)+
  4682. sizeof(battle_config.item_drop_equip_max)+
  4683. sizeof(battle_config.item_drop_mvp_min)+
  4684. sizeof(battle_config.item_drop_mvp_max)+
  4685. sizeof(battle_config.item_drop_heal_min)+
  4686. sizeof(battle_config.item_drop_heal_max)+
  4687. sizeof(battle_config.item_drop_use_min)+
  4688. sizeof(battle_config.item_drop_use_max)+
  4689. sizeof(battle_config.item_drop_treasure_min)+
  4690. sizeof(battle_config.item_drop_treasure_max)
  4691. ) != 0)
  4692. { //Drop rates changed.
  4693. mob_reload(); //Needed as well so rate changes take effect.
  4694. #ifndef TXT_ONLY
  4695. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4696. #endif
  4697. }
  4698. clif_displaymessage(fd, msg_txt(255));
  4699. return 0;
  4700. }
  4701. /*==========================================
  4702. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  4703. *------------------------------------------
  4704. */
  4705. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4706. {
  4707. status_readdb();
  4708. clif_displaymessage(fd, msg_txt(256));
  4709. return 0;
  4710. }
  4711. /*==========================================
  4712. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt
  4713. *------------------------------------------
  4714. */
  4715. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4716. {
  4717. pc_readdb();
  4718. clif_displaymessage(fd, msg_txt(257));
  4719. return 0;
  4720. }
  4721. /*==========================================
  4722. * @reloadmotd - reloads motd.txt
  4723. *------------------------------------------
  4724. */
  4725. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4726. {
  4727. pc_read_motd();
  4728. clif_displaymessage(fd, msg_txt(268));
  4729. return 0;
  4730. }
  4731. /*==========================================
  4732. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  4733. *------------------------------------------
  4734. */
  4735. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4736. {
  4737. nullpo_retr(-1, sd);
  4738. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4739. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4740. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4741. flush_fifos();
  4742. script_reload();
  4743. npc_reload();
  4744. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  4745. return 0;
  4746. }
  4747. /*==========================================
  4748. * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database)
  4749. *------------------------------------------
  4750. */
  4751. int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4752. {
  4753. nullpo_retr(-1, sd);
  4754. chrif_reloadGMdb();
  4755. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  4756. return 0;
  4757. }
  4758. /*==========================================
  4759. * @mapinfo <map name> [0-3] by MC_Cameri
  4760. * => Shows information about the map [map name]
  4761. * 0 = no additional information
  4762. * 1 = Show users in that map and their location
  4763. * 2 = Shows NPCs in that map
  4764. * 3 = Shows the shops/chats in that map (not implemented)
  4765. *------------------------------------------
  4766. */
  4767. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4768. {
  4769. struct map_session_data *pl_sd, **pl_allsd;
  4770. struct npc_data *nd = NULL;
  4771. struct chat_data *cd = NULL;
  4772. char direction[12];
  4773. int m_id, i, chat_num, users, list = 0;
  4774. unsigned short m_index;
  4775. nullpo_retr(-1, sd);
  4776. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4777. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4778. memset(direction, '\0', sizeof(direction));
  4779. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4780. if (list < 0 || list > 3) {
  4781. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4782. return -1;
  4783. }
  4784. if (atcmd_player_name[0] == '\0') {
  4785. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4786. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4787. m_id = map_mapindex2mapid(sd->mapindex);
  4788. } else {
  4789. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4790. strcat(atcmd_player_name, ".gat");
  4791. m_id = map_mapname2mapid(atcmd_player_name);
  4792. }
  4793. if (m_id < 0) {
  4794. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  4795. return -1;
  4796. }
  4797. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4798. clif_displaymessage(fd, "------ Map Info ------");
  4799. chat_num = 0;
  4800. pl_allsd = map_getallusers(&users);
  4801. for (i = 0; i < users; i++) {
  4802. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4803. chat_num++;
  4804. }
  4805. }
  4806. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
  4807. clif_displaymessage(fd, atcmd_output);
  4808. clif_displaymessage(fd, "------ Map Flags ------");
  4809. strcpy(atcmd_output,"PvP Flags: ");
  4810. if (map[m_id].flag.pvp)
  4811. strcat(atcmd_output, "Pvp ON | ");
  4812. if (map[m_id].flag.pvp_noguild)
  4813. strcat(atcmd_output, "NoGuild | ");
  4814. if (map[m_id].flag.pvp_noparty)
  4815. strcat(atcmd_output, "NoParty | ");
  4816. if (map[m_id].flag.pvp_nightmaredrop)
  4817. strcat(atcmd_output, "NightmareDrop | ");
  4818. if (map[m_id].flag.pvp_nocalcrank)
  4819. strcat(atcmd_output, "NoCalcRank | ");
  4820. clif_displaymessage(fd, atcmd_output);
  4821. strcpy(atcmd_output,"GvG Flags: ");
  4822. if (map[m_id].flag.gvg)
  4823. strcat(atcmd_output, "GvG ON | ");
  4824. if (map[m_id].flag.gvg_dungeon)
  4825. strcat(atcmd_output, "GvG Dungeon | ");
  4826. if (map[m_id].flag.gvg_castle)
  4827. strcat(atcmd_output, "GvG Castle | ");
  4828. if (map[m_id].flag.gvg_noparty)
  4829. strcat(atcmd_output, "NoParty | ");
  4830. clif_displaymessage(fd, atcmd_output);
  4831. strcpy(atcmd_output,"Teleport Flags: ");
  4832. if (map[m_id].flag.noteleport)
  4833. strcat(atcmd_output, "NoTeleport | ");
  4834. if (map[m_id].flag.monster_noteleport)
  4835. strcat(atcmd_output, "Monster NoTeleport | ");
  4836. if (map[m_id].flag.nowarp)
  4837. strcat(atcmd_output, "NoWarp | ");
  4838. if (map[m_id].flag.nowarpto)
  4839. strcat(atcmd_output, "NoWarpTo | ");
  4840. if (map[m_id].flag.noreturn)
  4841. strcat(atcmd_output, "NoReturn | ");
  4842. if (map[m_id].flag.nogo)
  4843. strcat(atcmd_output, "NoGo | ");
  4844. if (map[m_id].flag.nomemo)
  4845. strcat(atcmd_output, "NoMemo | ");
  4846. clif_displaymessage(fd, atcmd_output);
  4847. 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");
  4848. clif_displaymessage(fd, atcmd_output);
  4849. if (map[m_id].flag.nosave) {
  4850. if (!map[m_id].save.map)
  4851. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  4852. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4853. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4854. else
  4855. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4856. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4857. clif_displaymessage(fd, atcmd_output);
  4858. }
  4859. strcpy(atcmd_output,"Weather Flags: ");
  4860. if (map[m_id].flag.snow)
  4861. strcat(atcmd_output, "Snow | ");
  4862. if (map[m_id].flag.fog)
  4863. strcat(atcmd_output, "Fog | ");
  4864. if (map[m_id].flag.sakura)
  4865. strcat(atcmd_output, "Sakura | ");
  4866. if (map[m_id].flag.clouds)
  4867. strcat(atcmd_output, "Clouds | ");
  4868. if (map[m_id].flag.clouds2)
  4869. strcat(atcmd_output, "Clouds2 | ");
  4870. if (map[m_id].flag.fireworks)
  4871. strcat(atcmd_output, "Fireworks | ");
  4872. if (map[m_id].flag.leaves)
  4873. strcat(atcmd_output, "Leaves | ");
  4874. if (map[m_id].flag.rain)
  4875. strcat(atcmd_output, "Rain | ");
  4876. if (map[m_id].flag.indoors)
  4877. strcat(atcmd_output, "Indoors | ");
  4878. if (map[m_id].flag.nightenabled)
  4879. strcat(atcmd_output, "Displays Night | ");
  4880. clif_displaymessage(fd, atcmd_output);
  4881. strcpy(atcmd_output,"Other Flags: ");
  4882. if (map[m_id].flag.nobranch)
  4883. strcat(atcmd_output, "NoBranch | ");
  4884. if (map[m_id].flag.notrade)
  4885. strcat(atcmd_output, "NoTrade | ");
  4886. if (map[m_id].flag.novending)
  4887. strcat(atcmd_output, "NoVending | ");
  4888. if (map[m_id].flag.nodrop)
  4889. strcat(atcmd_output, "NoDrop | ");
  4890. if (map[m_id].flag.noskill)
  4891. strcat(atcmd_output, "NoSkill | ");
  4892. if (map[m_id].flag.noicewall)
  4893. strcat(atcmd_output, "NoIcewall | ");
  4894. clif_displaymessage(fd, atcmd_output);
  4895. strcpy(atcmd_output,"Other Flags: ");
  4896. if (map[m_id].nocommand)
  4897. strcat(atcmd_output, "NoCommand | ");
  4898. if (map[m_id].flag.nobaseexp)
  4899. strcat(atcmd_output, "NoBaseEXP | ");
  4900. if (map[m_id].flag.nojobexp)
  4901. strcat(atcmd_output, "NoJobEXP | ");
  4902. if (map[m_id].flag.nomobloot)
  4903. strcat(atcmd_output, "NoMobLoot | ");
  4904. if (map[m_id].flag.nomvploot)
  4905. strcat(atcmd_output, "NoMVPLoot | ");
  4906. if (map[m_id].flag.partylock)
  4907. strcat(atcmd_output, "PartyLock | ");
  4908. if (map[m_id].flag.guildlock)
  4909. strcat(atcmd_output, "GuildLock | ");
  4910. clif_displaymessage(fd, atcmd_output);
  4911. switch (list) {
  4912. case 0:
  4913. // Do nothing. It's list 0, no additional display.
  4914. break;
  4915. case 1:
  4916. clif_displaymessage(fd, "----- Players in Map -----");
  4917. for (i = 0; i < users; i++) {
  4918. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  4919. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  4920. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4921. clif_displaymessage(fd, atcmd_output);
  4922. }
  4923. }
  4924. break;
  4925. case 2:
  4926. clif_displaymessage(fd, "----- NPCs in Map -----");
  4927. for (i = 0; i < map[m_id].npc_num;) {
  4928. nd = map[m_id].npc[i];
  4929. switch(nd->ud.dir) {
  4930. case 0: strcpy(direction, "North"); break;
  4931. case 1: strcpy(direction, "North West"); break;
  4932. case 2: strcpy(direction, "West"); break;
  4933. case 3: strcpy(direction, "South West"); break;
  4934. case 4: strcpy(direction, "South"); break;
  4935. case 5: strcpy(direction, "South East"); break;
  4936. case 6: strcpy(direction, "East"); break;
  4937. case 7: strcpy(direction, "North East"); break;
  4938. case 9: strcpy(direction, "North"); break;
  4939. default: strcpy(direction, "Unknown"); break;
  4940. }
  4941. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  4942. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4943. clif_displaymessage(fd, atcmd_output);
  4944. }
  4945. break;
  4946. case 3:
  4947. clif_displaymessage(fd, "----- Chats in Map -----");
  4948. for (i = 0; i < users; i++) {
  4949. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  4950. pl_sd->mapindex == m_index &&
  4951. cd->usersd[0] == pl_sd) {
  4952. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  4953. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4954. clif_displaymessage(fd, atcmd_output);
  4955. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4956. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4957. clif_displaymessage(fd, atcmd_output);
  4958. }
  4959. }
  4960. break;
  4961. default: // normally impossible to arrive here
  4962. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4963. return -1;
  4964. break;
  4965. }
  4966. return 0;
  4967. }
  4968. /*==========================================
  4969. *
  4970. *------------------------------------------
  4971. */
  4972. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4973. {
  4974. nullpo_retr(-1, sd);
  4975. if (!pc_isriding(sd)) { // if actually no peco
  4976. if (pc_checkskill(sd, KN_RIDING)) {
  4977. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4978. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  4979. } else {
  4980. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  4981. return -1;
  4982. }
  4983. } else { //Dismount
  4984. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4985. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  4986. }
  4987. return 0;
  4988. }
  4989. /*==========================================
  4990. *
  4991. *------------------------------------------
  4992. */
  4993. int atcommand_char_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4994. {
  4995. struct map_session_data *pl_sd;
  4996. nullpo_retr(-1, sd);
  4997. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4998. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4999. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5000. return -1;
  5001. }
  5002. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5003. if (!pc_isriding(pl_sd)) { // if actually no peco
  5004. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5005. pc_setoption(pl_sd, pl_sd->sc.option | OPTION_RIDING);
  5006. clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
  5007. } else {
  5008. clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
  5009. return -1;
  5010. }
  5011. } else { //Dismount
  5012. pc_setoption(pl_sd, pl_sd->sc.option & ~OPTION_RIDING);
  5013. clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
  5014. }
  5015. } else {
  5016. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5017. return -1;
  5018. }
  5019. return 0;
  5020. }
  5021. /*==========================================
  5022. *Spy Commands by Syrus22
  5023. *------------------------------------------
  5024. */
  5025. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5026. {
  5027. char guild_name[NAME_LENGTH];
  5028. struct guild *g;
  5029. nullpo_retr(-1, sd);
  5030. memset(guild_name, '\0', sizeof(guild_name));
  5031. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5032. if (!enable_spy)
  5033. {
  5034. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5035. return -1;
  5036. }
  5037. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5038. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5039. return -1;
  5040. }
  5041. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5042. (g = guild_search(atoi(message))) != NULL) {
  5043. if (sd->guildspy == g->guild_id) {
  5044. sd->guildspy = 0;
  5045. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  5046. clif_displaymessage(fd, atcmd_output);
  5047. } else {
  5048. sd->guildspy = g->guild_id;
  5049. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  5050. clif_displaymessage(fd, atcmd_output);
  5051. }
  5052. } else {
  5053. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  5054. return -1;
  5055. }
  5056. return 0;
  5057. }
  5058. /*==========================================
  5059. *
  5060. *------------------------------------------
  5061. */
  5062. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5063. {
  5064. char party_name[NAME_LENGTH];
  5065. struct party_data *p;
  5066. nullpo_retr(-1, sd);
  5067. memset(party_name, '\0', sizeof(party_name));
  5068. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5069. if (!enable_spy)
  5070. {
  5071. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5072. return -1;
  5073. }
  5074. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5075. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5076. return -1;
  5077. }
  5078. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5079. (p = party_search(atoi(message))) != NULL) {
  5080. if (sd->partyspy == p->party.party_id) {
  5081. sd->partyspy = 0;
  5082. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  5083. clif_displaymessage(fd, atcmd_output);
  5084. } else {
  5085. sd->partyspy = p->party.party_id;
  5086. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  5087. clif_displaymessage(fd, atcmd_output);
  5088. }
  5089. } else {
  5090. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  5091. return -1;
  5092. }
  5093. return 0;
  5094. }
  5095. /*==========================================
  5096. * @repairall [Valaris]
  5097. *------------------------------------------
  5098. */
  5099. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5100. {
  5101. int count, i;
  5102. nullpo_retr(-1, sd);
  5103. count = 0;
  5104. for (i = 0; i < MAX_INVENTORY; i++) {
  5105. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5106. sd->status.inventory[i].attribute = 0;
  5107. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5108. count++;
  5109. }
  5110. }
  5111. if (count > 0) {
  5112. clif_misceffect(&sd->bl, 3);
  5113. clif_equiplist(sd);
  5114. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  5115. } else {
  5116. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  5117. return -1;
  5118. }
  5119. return 0;
  5120. }
  5121. /*==========================================
  5122. * @nuke [Valaris]
  5123. *------------------------------------------
  5124. */
  5125. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5126. {
  5127. struct map_session_data *pl_sd;
  5128. nullpo_retr(-1, sd);
  5129. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5130. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5131. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5132. return -1;
  5133. }
  5134. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5135. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5136. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5137. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  5138. } else {
  5139. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5140. return -1;
  5141. }
  5142. } else {
  5143. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5144. return -1;
  5145. }
  5146. return 0;
  5147. }
  5148. /*==========================================
  5149. * @tonpc
  5150. *------------------------------------------
  5151. */
  5152. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5153. {
  5154. char npcname[NAME_LENGTH];
  5155. struct npc_data *nd;
  5156. nullpo_retr(-1, sd);
  5157. memset(npcname, 0, sizeof(npcname));
  5158. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5159. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5160. return -1;
  5161. }
  5162. if ((nd = npc_name2id(npcname)) != NULL) {
  5163. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5164. clif_displaymessage(fd, msg_txt(0)); // Warped.
  5165. else
  5166. return -1;
  5167. } else {
  5168. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5169. return -1;
  5170. }
  5171. return 0;
  5172. }
  5173. /*==========================================
  5174. *
  5175. *------------------------------------------
  5176. */
  5177. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5178. {
  5179. char NPCname[NAME_LENGTH];
  5180. nullpo_retr(-1, sd);
  5181. memset(NPCname, '\0', sizeof(NPCname));
  5182. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5183. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5184. return -1;
  5185. }
  5186. if (npc_name2id(NPCname) != NULL) {
  5187. npc_enable(NPCname, 1);
  5188. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  5189. } else {
  5190. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5191. return -1;
  5192. }
  5193. return 0;
  5194. }
  5195. /*==========================================
  5196. *
  5197. *------------------------------------------
  5198. */
  5199. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5200. {
  5201. char NPCname[NAME_LENGTH];
  5202. nullpo_retr(-1, sd);
  5203. memset(NPCname, '\0', sizeof(NPCname));
  5204. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5205. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  5206. return -1;
  5207. }
  5208. if (npc_name2id(NPCname) != NULL) {
  5209. npc_enable(NPCname, 0);
  5210. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5211. } else {
  5212. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5213. return -1;
  5214. }
  5215. return 0;
  5216. }
  5217. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5218. {
  5219. FILE *fp;
  5220. if (!message || !*message) {
  5221. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5222. return -1;
  5223. }
  5224. // check if script file exists
  5225. if ((fp = fopen(message, "r")) == NULL) {
  5226. clif_displaymessage(fd, msg_txt(261));
  5227. return -1;
  5228. }
  5229. fclose(fp);
  5230. // add to list of script sources and run it
  5231. npc_addsrcfile((char *)message);
  5232. npc_parsesrcfile((char *)message);
  5233. npc_read_event_script();
  5234. clif_displaymessage(fd, msg_txt(262));
  5235. return 0;
  5236. }
  5237. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5238. {
  5239. struct npc_data *nd;
  5240. char NPCname[NAME_LENGTH];
  5241. nullpo_retr(-1, sd);
  5242. memset(NPCname, '\0', sizeof(NPCname));
  5243. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5244. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5245. return -1;
  5246. }
  5247. if ((nd = npc_name2id(NPCname)) != NULL) {
  5248. npc_unload_duplicates(nd);
  5249. npc_unload(nd);
  5250. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5251. } else {
  5252. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5253. return -1;
  5254. }
  5255. return 0;
  5256. }
  5257. /*==========================================
  5258. * time in txt for time command (by [Yor])
  5259. *------------------------------------------
  5260. */
  5261. char * txt_time(unsigned int duration)
  5262. {
  5263. int days, hours, minutes, seconds;
  5264. char temp[256];
  5265. static char temp1[256];
  5266. memset(temp, '\0', sizeof(temp));
  5267. memset(temp1, '\0', sizeof(temp1));
  5268. days = duration / (60 * 60 * 24);
  5269. duration = duration - (60 * 60 * 24 * days);
  5270. hours = duration / (60 * 60);
  5271. duration = duration - (60 * 60 * hours);
  5272. minutes = duration / 60;
  5273. seconds = duration - (60 * minutes);
  5274. if (days < 2)
  5275. sprintf(temp, msg_txt(219), days); // %d day
  5276. else
  5277. sprintf(temp, msg_txt(220), days); // %d days
  5278. if (hours < 2)
  5279. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  5280. else
  5281. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  5282. if (minutes < 2)
  5283. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  5284. else
  5285. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  5286. if (seconds < 2)
  5287. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  5288. else
  5289. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  5290. return temp1;
  5291. }
  5292. /*==========================================
  5293. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5294. * Calculation management of GM modification (@day/@night GM commands) is done
  5295. *------------------------------------------
  5296. */
  5297. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5298. {
  5299. struct TimerData * timer_data;
  5300. struct TimerData * timer_data2;
  5301. time_t time_server; // variable for number of seconds (used with time() function)
  5302. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5303. char temp[256];
  5304. nullpo_retr(-1, sd);
  5305. memset(temp, '\0', sizeof(temp));
  5306. time(&time_server); // get time in seconds since 1/1/1970
  5307. datetime = localtime(&time_server); // convert seconds in structure
  5308. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5309. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  5310. clif_displaymessage(fd, temp);
  5311. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5312. if (night_flag == 0)
  5313. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5314. else
  5315. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5316. } else if (battle_config.night_duration == 0)
  5317. if (night_flag == 1) { // we start with night
  5318. timer_data = get_timer(day_timer_tid);
  5319. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5320. clif_displaymessage(fd, temp);
  5321. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  5322. } else
  5323. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5324. else if (battle_config.day_duration == 0)
  5325. if (night_flag == 0) { // we start with day
  5326. timer_data = get_timer(night_timer_tid);
  5327. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5328. clif_displaymessage(fd, temp);
  5329. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  5330. } else
  5331. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5332. else {
  5333. if (night_flag == 0) {
  5334. timer_data = get_timer(night_timer_tid);
  5335. timer_data2 = get_timer(day_timer_tid);
  5336. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5337. clif_displaymessage(fd, temp);
  5338. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5339. 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.
  5340. else
  5341. 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.
  5342. clif_displaymessage(fd, temp);
  5343. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5344. clif_displaymessage(fd, temp);
  5345. } else {
  5346. timer_data = get_timer(day_timer_tid);
  5347. timer_data2 = get_timer(night_timer_tid);
  5348. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5349. clif_displaymessage(fd, temp);
  5350. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5351. 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.
  5352. else
  5353. 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.
  5354. clif_displaymessage(fd, temp);
  5355. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5356. clif_displaymessage(fd, temp);
  5357. }
  5358. }
  5359. return 0;
  5360. }
  5361. /*==========================================
  5362. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5363. * removes <quantity> item from a character
  5364. * item can be equiped or not.
  5365. * Inspired from a old command created by RoVeRT
  5366. *------------------------------------------
  5367. */
  5368. int atcommand_chardelitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5369. {
  5370. struct map_session_data *pl_sd;
  5371. char item_name[100];
  5372. int i, number = 0, item_id, item_position, count;
  5373. struct item_data *item_data;
  5374. nullpo_retr(-1, sd);
  5375. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5376. memset(item_name, '\0', sizeof(item_name));
  5377. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5378. if (!message || !*message || (
  5379. sscanf(message, "\"%99[^\"]\" %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 &&
  5380. sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3
  5381. ) || number < 1) {
  5382. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5383. return -1;
  5384. }
  5385. item_id = 0;
  5386. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5387. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5388. item_id = item_data->nameid;
  5389. if (item_id > 500) {
  5390. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5391. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5392. item_position = pc_search_inventory(pl_sd, item_id);
  5393. if (item_position >= 0) {
  5394. count = 0;
  5395. for(i = 0; i < number && item_position >= 0; i++) {
  5396. //Logs (A)dmins items [Lupus]
  5397. if(log_config.enable_logs&0x400)
  5398. log_pick_pc(pl_sd, "A", pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5399. pc_delitem(pl_sd, item_position, 1, 0);
  5400. count++;
  5401. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5402. }
  5403. sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
  5404. clif_displaymessage(pl_sd->fd, atcmd_output);
  5405. if (number == count)
  5406. sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
  5407. else
  5408. sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5409. clif_displaymessage(fd, atcmd_output);
  5410. } else {
  5411. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  5412. return -1;
  5413. }
  5414. } else {
  5415. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5416. return -1;
  5417. }
  5418. } else {
  5419. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5420. return -1;
  5421. }
  5422. } else {
  5423. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  5424. return -1;
  5425. }
  5426. return 0;
  5427. }
  5428. //Added by Coltaro
  5429. //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...).
  5430. //Well, using time_t could still work but for some reason that looks like more coding x_x
  5431. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  5432. {
  5433. const int factor_year = 518400; //12*30*24*60 = 518400
  5434. const int factor_month = 43200; //30*24*60 = 43200
  5435. const int factor_day = 1440; //24*60 = 1440
  5436. const int factor_hour = 60;
  5437. *year = jailtime/factor_year;
  5438. jailtime -= *year*factor_year;
  5439. *month = jailtime/factor_month;
  5440. jailtime -= *month*factor_month;
  5441. *day = jailtime/factor_day;
  5442. jailtime -= *day*factor_day;
  5443. *hour = jailtime/factor_hour;
  5444. jailtime -= *hour*factor_hour;
  5445. *minute = jailtime;
  5446. *year = *year > 0? *year : 0;
  5447. *month = *month > 0? *month : 0;
  5448. *day = *day > 0? *day : 0;
  5449. *hour = *hour > 0? *hour : 0;
  5450. *minute = *minute > 0? *minute : 0;
  5451. return;
  5452. }
  5453. /*==========================================
  5454. * @jail <char_name> by [Yor]
  5455. * Special warp! No check with nowarp and nowarpto flag
  5456. *------------------------------------------
  5457. */
  5458. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5459. {
  5460. struct map_session_data *pl_sd;
  5461. int x, y;
  5462. unsigned short m_index;
  5463. nullpo_retr(-1, sd);
  5464. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5465. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5466. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5467. return -1;
  5468. }
  5469. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5470. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5471. return -1;
  5472. }
  5473. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5474. { // you can jail only lower or same GM
  5475. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5476. return -1;
  5477. }
  5478. if (pl_sd->mapindex == mapindex_name2id(MAP_JAIL))
  5479. { //Already jailed
  5480. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5481. return -1;
  5482. }
  5483. switch(rand() % 2) { //Jail Locations
  5484. case 0:
  5485. m_index = mapindex_name2id(MAP_JAIL);
  5486. x = 24;
  5487. y = 75;
  5488. break;
  5489. default:
  5490. m_index = mapindex_name2id(MAP_JAIL);
  5491. x = 49;
  5492. y = 75;
  5493. break;
  5494. }
  5495. if (pc_setpos(pl_sd, m_index, x, y, 3)) {
  5496. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5497. return -1;
  5498. }
  5499. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5500. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5501. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5502. return 0;
  5503. }
  5504. /*==========================================
  5505. * @unjail/@discharge <char_name> by [Yor]
  5506. * Special warp! No check with nowarp and nowarpto flag
  5507. *------------------------------------------
  5508. */
  5509. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5510. {
  5511. struct map_session_data *pl_sd;
  5512. unsigned short m_index;
  5513. int x=0, y=0;
  5514. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5515. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5516. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5517. return -1;
  5518. }
  5519. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5520. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5521. return -1;
  5522. }
  5523. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5524. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5525. return -1;
  5526. }
  5527. if (pl_sd->mapindex != mapindex_name2id(MAP_JAIL)) {
  5528. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5529. return -1;
  5530. }
  5531. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5532. { //Retrieve return map.
  5533. m_index = pl_sd->sc.data[SC_JAILED].val3;
  5534. x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
  5535. y = pl_sd->sc.data[SC_JAILED].val4>>16;
  5536. status_change_end(&pl_sd->bl,SC_JAILED,-1);
  5537. } else
  5538. m_index = mapindex_name2id(MAP_PRONTERA);
  5539. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
  5540. pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
  5541. ) { //Send to Prontera is saved SC map fails.
  5542. pc_setsavepoint(pl_sd, m_index, x, y);
  5543. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5544. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5545. } else {
  5546. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5547. return -1;
  5548. }
  5549. return 0;
  5550. }
  5551. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5552. {
  5553. struct map_session_data *pl_sd = NULL;
  5554. int year, month, day, hour, minute, value;
  5555. char * modif_p;
  5556. int jailtime = 0,x,y;
  5557. short m_index = 0;
  5558. nullpo_retr(-1, sd);
  5559. if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5560. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5561. return -1;
  5562. }
  5563. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5564. modif_p = atcmd_output;
  5565. year = month = day = hour = minute = 0;
  5566. while (modif_p[0] != '\0') {
  5567. value = atoi(modif_p);
  5568. if (value == 0)
  5569. modif_p++;
  5570. else {
  5571. if (modif_p[0] == '-' || modif_p[0] == '+')
  5572. modif_p++;
  5573. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5574. modif_p++;
  5575. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  5576. minute = value;
  5577. modif_p = modif_p + 2;
  5578. } else if (modif_p[0] == 'h') {
  5579. hour = value;
  5580. modif_p++;
  5581. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5582. day = value;
  5583. modif_p++;
  5584. } else if (modif_p[0] == 'm') {
  5585. month = value;
  5586. modif_p++;
  5587. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5588. year = value;
  5589. modif_p++;
  5590. } else if (modif_p[0] != '\0') {
  5591. modif_p++;
  5592. }
  5593. }
  5594. }
  5595. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5596. clif_displaymessage(fd, "Invalid time for jail command.");
  5597. return -1;
  5598. }
  5599. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5600. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5601. return -1;
  5602. }
  5603. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5604. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5605. return -1;
  5606. }
  5607. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5608. if(jailtime==0) {
  5609. clif_displaymessage(fd, "Invalid time for jail command.");
  5610. return -1;
  5611. }
  5612. //Added by Coltaro
  5613. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5614. { //Update the player's jail time
  5615. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  5616. if (jailtime <= 0) {
  5617. jailtime = 0;
  5618. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5619. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5620. } else {
  5621. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5622. 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
  5623. clif_displaymessage(pl_sd->fd, atcmd_output);
  5624. 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
  5625. clif_displaymessage(fd, atcmd_output);
  5626. }
  5627. } else if (jailtime < 0) {
  5628. clif_displaymessage(fd, "Invalid time for jail command.");
  5629. return -1;
  5630. }
  5631. //Jail locations, add more as you wish.
  5632. switch(rand()%2)
  5633. {
  5634. case 1: //Jail #1
  5635. m_index = mapindex_name2id(MAP_JAIL);
  5636. x = 49; y = 75;
  5637. break;
  5638. default: //Default Jail
  5639. m_index = mapindex_name2id(MAP_JAIL);
  5640. x = 24; y = 75;
  5641. break;
  5642. }
  5643. 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).
  5644. return 0;
  5645. }
  5646. //By Coltaro
  5647. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5648. {
  5649. int year, month, day, hour, minute;
  5650. nullpo_retr(-1, sd);
  5651. if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5652. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5653. return -1;
  5654. }
  5655. if (!sd->sc.count || sd->sc.data[SC_JAILED].timer == -1 || sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  5656. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5657. return -1;
  5658. }
  5659. //Get remaining jail time
  5660. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5661. 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
  5662. clif_displaymessage(fd, atcmd_output);
  5663. return 0;
  5664. }
  5665. //By Coltaro
  5666. int atcommand_charjailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5667. {
  5668. struct map_session_data* pl_sd;
  5669. int year, month, day, hour, minute;
  5670. nullpo_retr(-1, sd);
  5671. if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
  5672. clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
  5673. return -1;
  5674. }
  5675. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5676. if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
  5677. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5678. clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
  5679. return -1;
  5680. }
  5681. if (!pl_sd->sc.count || pl_sd->sc.data[SC_JAILED].timer == -1 || pl_sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail?)
  5682. clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
  5683. return -1;
  5684. }
  5685. //Get remaining jail time
  5686. get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5687. sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
  5688. clif_displaymessage(fd, atcmd_output);
  5689. } else {
  5690. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
  5691. return -1;
  5692. }
  5693. } else {
  5694. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5695. return -1;
  5696. }
  5697. return 0;
  5698. }
  5699. /*==========================================
  5700. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5701. *------------------------------------------
  5702. */
  5703. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5704. {
  5705. int id = 0;
  5706. nullpo_retr(-1, sd);
  5707. if (!message || !*message) {
  5708. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5709. return -1;
  5710. }
  5711. if ((id = atoi(message)) > 0)
  5712. { //Acquired an ID
  5713. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5714. id = 0; //Invalid id for either mobs or npcs.
  5715. } else { //Acquired a Name
  5716. if ((id = mobdb_searchname(message)) == 0)
  5717. {
  5718. struct npc_data* nd = npc_name2id(message);
  5719. if (nd != NULL)
  5720. id = nd->n;
  5721. }
  5722. }
  5723. if (id == 0)
  5724. { // Monster/NPC name/id hasn't been found.
  5725. clif_displaymessage(fd, msg_txt(123));
  5726. return -1;
  5727. }
  5728. pc_disguise(sd, id);
  5729. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5730. return 0;
  5731. }
  5732. /*==========================================
  5733. * DisguiseAll
  5734. *------------------------------------------
  5735. */
  5736. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5737. {
  5738. int mob_id=0, i=0, users;
  5739. struct map_session_data *pl_sd, **pl_allsd;
  5740. nullpo_retr(-1, sd);
  5741. if (!message || !*message) {
  5742. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5743. return -1;
  5744. }
  5745. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5746. mob_id = atoi(message);
  5747. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5748. pl_allsd = map_getallusers(&users);
  5749. for(i=0; i < users; i++) {
  5750. if((pl_sd = pl_allsd[i]))
  5751. pc_disguise(pl_sd, mob_id);
  5752. }
  5753. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5754. } else {
  5755. return -1;
  5756. }
  5757. return 0;
  5758. }
  5759. /*==========================================
  5760. * @undisguise by [Yor]
  5761. *------------------------------------------
  5762. */
  5763. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5764. {
  5765. nullpo_retr(-1, sd);
  5766. if (sd->disguise) {
  5767. pc_disguise(sd, 0);
  5768. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5769. } else {
  5770. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  5771. return -1;
  5772. }
  5773. return 0;
  5774. }
  5775. /*==========================================
  5776. * UndisguiseAll
  5777. *------------------------------------------
  5778. */
  5779. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5780. {
  5781. struct map_session_data *pl_sd, **pl_allsd;
  5782. int i, users;
  5783. nullpo_retr(-1, sd);
  5784. pl_allsd = map_getallusers(&users);
  5785. for(i=0; i < users; i++) {
  5786. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5787. pc_disguise(pl_sd, 0);
  5788. }
  5789. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5790. return 0;
  5791. }
  5792. /*==========================================
  5793. * @exp by [Skotlex]
  5794. *------------------------------------------
  5795. */
  5796. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5797. {
  5798. char output[200];
  5799. double nextb, nextj;
  5800. nullpo_retr(-1, sd);
  5801. memset(output, '\0', sizeof(output));
  5802. nextb = pc_nextbaseexp(sd);
  5803. if (nextb)
  5804. nextb = sd->status.base_exp*100.0/nextb;
  5805. nextj = pc_nextjobexp(sd);
  5806. if (nextj)
  5807. nextj = sd->status.job_exp*100.0/nextj;
  5808. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5809. clif_displaymessage(fd, output);
  5810. return 0;
  5811. }
  5812. /*==========================================
  5813. * @broadcast by [Valaris]
  5814. *------------------------------------------
  5815. */
  5816. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5817. {
  5818. nullpo_retr(-1, sd);
  5819. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5820. if (!message || !*message) {
  5821. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5822. return -1;
  5823. }
  5824. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5825. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5826. return 0;
  5827. }
  5828. /*==========================================
  5829. * @localbroadcast by [Valaris]
  5830. *------------------------------------------
  5831. */
  5832. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5833. {
  5834. nullpo_retr(-1, sd);
  5835. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5836. if (!message || !*message) {
  5837. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5838. return -1;
  5839. }
  5840. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5841. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5842. return 0;
  5843. }
  5844. /*==========================================
  5845. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5846. *------------------------------------------
  5847. */
  5848. int atcommand_chardisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5849. {
  5850. int mob_id;
  5851. char mob_name[NAME_LENGTH];
  5852. struct map_session_data* pl_sd;
  5853. nullpo_retr(-1, sd);
  5854. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5855. memset(mob_name, '\0', sizeof(mob_name));
  5856. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5857. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5858. return -1;
  5859. }
  5860. if ((mob_id = atoi(mob_name)) > 0)
  5861. { //Acquired an ID
  5862. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5863. mob_id = 0; //Invalid id for either mobs or npcs.
  5864. } else { //Acquired a Name
  5865. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5866. {
  5867. struct npc_data* nd = npc_name2id(mob_name);
  5868. if (nd != NULL)
  5869. mob_id = nd->n;
  5870. }
  5871. }
  5872. if (mob_id == 0)
  5873. {
  5874. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  5875. return -1;
  5876. }
  5877. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5878. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5879. pc_disguise(pl_sd, mob_id);
  5880. clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
  5881. } else {
  5882. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5883. return -1;
  5884. }
  5885. } else {
  5886. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5887. return -1;
  5888. }
  5889. return 0;
  5890. }
  5891. /*==========================================
  5892. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5893. *------------------------------------------
  5894. */
  5895. int atcommand_charundisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5896. {
  5897. struct map_session_data* pl_sd;
  5898. nullpo_retr(-1, sd);
  5899. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5900. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5901. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5902. return -1;
  5903. }
  5904. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5905. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5906. if (pl_sd->disguise)
  5907. pc_disguise(pl_sd, 0);
  5908. else {
  5909. clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
  5910. return -1;
  5911. }
  5912. } else {
  5913. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5914. return -1;
  5915. }
  5916. } else {
  5917. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5918. return -1;
  5919. }
  5920. return 0;
  5921. }
  5922. /*==========================================
  5923. * @email <actual@email> <new@email> by [Yor]
  5924. *------------------------------------------
  5925. */
  5926. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5927. {
  5928. char actual_email[100];
  5929. char new_email[100];
  5930. nullpo_retr(-1, sd);
  5931. memset(actual_email, '\0', sizeof(actual_email));
  5932. memset(new_email, '\0', sizeof(new_email));
  5933. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5934. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5935. return -1;
  5936. }
  5937. if (e_mail_check(actual_email) == 0) {
  5938. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  5939. return -1;
  5940. } else if (e_mail_check(new_email) == 0) {
  5941. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  5942. return -1;
  5943. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5944. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  5945. return -1;
  5946. } else if (strcmpi(actual_email, new_email) == 0) {
  5947. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  5948. return -1;
  5949. } else {
  5950. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5951. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  5952. }
  5953. return 0;
  5954. }
  5955. /*==========================================
  5956. *@effect
  5957. *------------------------------------------
  5958. */
  5959. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5960. {
  5961. int type = 0, flag = 0;
  5962. nullpo_retr(-1, sd);
  5963. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5964. clif_displaymessage(fd, "Please, enter a type and a send flag (usage: @effect <type> <flag>).");
  5965. return -1;
  5966. }
  5967. clif_specialeffect(&sd->bl, type, flag);
  5968. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  5969. return 0;
  5970. }
  5971. /*==========================================
  5972. * @charcartlist <character>: Displays the items list of a player's cart.
  5973. *------------------------------------------
  5974. */
  5975. int atcommand_character_cart_list(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5976. {
  5977. char outputtmp[200];
  5978. struct map_session_data *pl_sd;
  5979. struct item_data *item_data, *item_temp;
  5980. int i, j, count, counter, counter2;
  5981. nullpo_retr(-1, sd);
  5982. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5983. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5984. memset(outputtmp, '\0', sizeof(outputtmp));
  5985. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5986. clif_displaymessage(fd, "Please, enter a player name (usage: @cartlist <char name>).");
  5987. return -1;
  5988. }
  5989. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5990. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5991. counter = 0;
  5992. count = 0;
  5993. for (i = 0; i < MAX_CART; i++) {
  5994. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5995. counter = counter + pl_sd->status.cart[i].amount;
  5996. count++;
  5997. if (count == 1) {
  5998. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  5999. clif_displaymessage(fd, atcmd_output);
  6000. }
  6001. if (pl_sd->status.cart[i].refine)
  6002. sprintf(atcmd_output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  6003. else
  6004. sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  6005. clif_displaymessage(fd, atcmd_output);
  6006. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6007. counter2 = 0;
  6008. for (j = 0; j < item_data->slot; j++) {
  6009. if (pl_sd->status.cart[i].card[j]) {
  6010. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6011. if (atcmd_output[0] == '\0')
  6012. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6013. else
  6014. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6015. strcat(atcmd_output, outputtmp);
  6016. }
  6017. }
  6018. }
  6019. if (atcmd_output[0] != '\0') {
  6020. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6021. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6022. clif_displaymessage(fd, atcmd_output);
  6023. }
  6024. }
  6025. }
  6026. if (count == 0)
  6027. clif_displaymessage(fd, "No item found in the cart of this player.");
  6028. else {
  6029. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6030. clif_displaymessage(fd, atcmd_output);
  6031. }
  6032. } else {
  6033. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6034. return -1;
  6035. }
  6036. } else {
  6037. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6038. return -1;
  6039. }
  6040. return 0;
  6041. }
  6042. /*==========================================
  6043. * @killer by MouseJstr
  6044. * enable killing players even when not in pvp
  6045. *------------------------------------------
  6046. */
  6047. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6048. {
  6049. nullpo_retr(-1, sd);
  6050. sd->state.killer = !sd->state.killer;
  6051. if(sd->state.killer)
  6052. clif_displaymessage(fd, msg_txt(241));
  6053. else {
  6054. clif_displaymessage(fd, msg_txt(287));
  6055. pc_stop_attack(sd);
  6056. }
  6057. return 0;
  6058. }
  6059. /*==========================================
  6060. * @killable by MouseJstr
  6061. * enable other people killing you
  6062. *------------------------------------------
  6063. */
  6064. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6065. {
  6066. nullpo_retr(-1, sd);
  6067. sd->state.killable = !sd->state.killable;
  6068. if(sd->state.killable)
  6069. clif_displaymessage(fd, msg_txt(242));
  6070. else {
  6071. clif_displaymessage(fd, msg_txt(288));
  6072. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  6073. }
  6074. return 0;
  6075. }
  6076. /*==========================================
  6077. * @charkillable by MouseJstr
  6078. * enable another player to be killed
  6079. *------------------------------------------
  6080. */
  6081. int atcommand_charkillable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6082. {
  6083. struct map_session_data *pl_sd = NULL;
  6084. nullpo_retr(-1, sd);
  6085. if (!message || !*message)
  6086. return -1;
  6087. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6088. return -1;
  6089. pl_sd->state.killable = !pl_sd->state.killable;
  6090. if(pl_sd->state.killable)
  6091. clif_displaymessage(fd, msg_txt(289));
  6092. else
  6093. clif_displaymessage(fd, msg_txt(290));
  6094. return 0;
  6095. }
  6096. /*==========================================
  6097. * @skillon by MouseJstr
  6098. * turn skills on for the map
  6099. *------------------------------------------
  6100. */
  6101. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6102. {
  6103. nullpo_retr(-1, sd);
  6104. map[sd->bl.m].flag.noskill = 0;
  6105. clif_displaymessage(fd, msg_txt(244));
  6106. return 0;
  6107. }
  6108. /*==========================================
  6109. * @skilloff by MouseJstr
  6110. * Turn skills off on the map
  6111. *------------------------------------------
  6112. */
  6113. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6114. {
  6115. nullpo_retr(-1, sd);
  6116. map[sd->bl.m].flag.noskill = 1;
  6117. clif_displaymessage(fd, msg_txt(243));
  6118. return 0;
  6119. }
  6120. /*==========================================
  6121. * @npcmove by MouseJstr
  6122. * move a npc
  6123. *------------------------------------------
  6124. */
  6125. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6126. {
  6127. int x = 0, y = 0, m;
  6128. struct npc_data *nd = 0;
  6129. nullpo_retr(-1, sd);
  6130. if (!message || !*message)
  6131. return -1;
  6132. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6133. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6134. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6135. return -1;
  6136. }
  6137. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6138. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6139. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6140. return -1;
  6141. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6142. return -1; //Not on a map.
  6143. if (x < 0) x = 0;
  6144. else if (x >= map[m].xs) x = map[m].xs-1;
  6145. if (y < 0) y = 0;
  6146. else if (y >= map[m].ys) y = map[m].ys-1;
  6147. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6148. map_moveblock(&nd->bl, x, y, gettick());
  6149. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6150. return 0;
  6151. }
  6152. /*==========================================
  6153. * @addwarp by MouseJstr
  6154. * Create a new static warp point.
  6155. *------------------------------------------
  6156. */
  6157. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6158. {
  6159. char w1[64], w3[64], w4[64];
  6160. int x,y,ret;
  6161. nullpo_retr(-1, sd);
  6162. if (!message || !*message)
  6163. return -1;
  6164. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6165. return -1;
  6166. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6167. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6168. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6169. ret = npc_parse_warp(w1, "warp", w3, w4);
  6170. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6171. clif_displaymessage(fd, atcmd_output);
  6172. return ret;
  6173. }
  6174. /*==========================================
  6175. * @follow by [MouseJstr]
  6176. * Follow a player .. staying no more then 5 spaces away
  6177. *------------------------------------------
  6178. */
  6179. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6180. {
  6181. struct map_session_data *pl_sd = NULL;
  6182. nullpo_retr(-1, sd);
  6183. if (!message || !*message) {
  6184. if (sd->followtarget == -1)
  6185. return -1;
  6186. pc_stop_following (sd);
  6187. clif_displaymessage(fd, "Follow mode OFF.");
  6188. return 0;
  6189. }
  6190. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6191. if (sd->followtarget == pl_sd->bl.id) {
  6192. pc_stop_following (sd);
  6193. clif_displaymessage(fd, "Follow mode OFF.");
  6194. } else {
  6195. pc_follow(sd, pl_sd->bl.id);
  6196. clif_displaymessage(fd, "Follow mode ON.");
  6197. }
  6198. return 0;
  6199. } else {
  6200. clif_displaymessage(fd, "Character not found.");
  6201. return -1;
  6202. }
  6203. return 1;
  6204. }
  6205. /*==========================================
  6206. * @dropall by [MouseJstr]
  6207. * Drop all your possession on the ground
  6208. *------------------------------------------
  6209. */
  6210. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6211. {
  6212. int i;
  6213. nullpo_retr(-1, sd);
  6214. for (i = 0; i < MAX_INVENTORY; i++) {
  6215. if (sd->status.inventory[i].amount) {
  6216. if(sd->status.inventory[i].equip != 0)
  6217. pc_unequipitem(sd, i, 3);
  6218. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6219. }
  6220. }
  6221. return 0;
  6222. }
  6223. /*==========================================
  6224. * @chardropall by [MouseJstr]
  6225. * Drop all of the target's possessions on the ground
  6226. *------------------------------------------
  6227. */
  6228. int atcommand_chardropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6229. {
  6230. int i;
  6231. struct map_session_data *pl_sd = NULL;
  6232. nullpo_retr(-1, sd);
  6233. if (!message || !*message)
  6234. return -1;
  6235. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6236. return -1;
  6237. for (i = 0; i < MAX_INVENTORY; i++) {
  6238. if (pl_sd->status.inventory[i].amount) {
  6239. if(pl_sd->status.inventory[i].equip != 0)
  6240. pc_unequipitem(pl_sd, i, 3);
  6241. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6242. }
  6243. }
  6244. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6245. clif_displaymessage(fd, "It is done");
  6246. return 0;
  6247. }
  6248. /*==========================================
  6249. * @storeall by [MouseJstr]
  6250. * Put everything into storage
  6251. *------------------------------------------
  6252. */
  6253. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6254. {
  6255. int i;
  6256. nullpo_retr(-1, sd);
  6257. if (sd->state.storage_flag != 1)
  6258. { //Open storage.
  6259. switch (storage_storageopen(sd)) {
  6260. case 2: //Try again
  6261. clif_displaymessage(fd, "run this command again..");
  6262. return 0;
  6263. case 1: //Failure
  6264. clif_displaymessage(fd, "You can't open the storage currently.");
  6265. return -1;
  6266. }
  6267. }
  6268. for (i = 0; i < MAX_INVENTORY; i++) {
  6269. if (sd->status.inventory[i].amount) {
  6270. if(sd->status.inventory[i].equip != 0)
  6271. pc_unequipitem(sd, i, 3);
  6272. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6273. }
  6274. }
  6275. storage_storageclose(sd);
  6276. clif_displaymessage(fd, "It is done");
  6277. return 0;
  6278. }
  6279. /*==========================================
  6280. * @charstoreall by [MouseJstr]
  6281. * A way to screw with players who piss you off
  6282. *------------------------------------------
  6283. */
  6284. int atcommand_charstoreall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6285. {
  6286. int i;
  6287. struct map_session_data *pl_sd = NULL;
  6288. nullpo_retr(-1, sd);
  6289. if (!message || !*message)
  6290. return -1;
  6291. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6292. return -1;
  6293. if (pl_sd->state.storage_flag != 1)
  6294. { //Open storage.
  6295. switch (storage_storageopen(pl_sd)) {
  6296. case 2: //Try again
  6297. clif_displaymessage(fd, "Had to open the characters storage window...");
  6298. clif_displaymessage(fd, "run this command again..");
  6299. return 0;
  6300. case 1: //Failure
  6301. clif_displaymessage(fd, "The character currently can't use the storage.");
  6302. return 1;
  6303. }
  6304. }
  6305. for (i = 0; i < MAX_INVENTORY; i++) {
  6306. if (pl_sd->status.inventory[i].amount) {
  6307. if(pl_sd->status.inventory[i].equip != 0)
  6308. pc_unequipitem(pl_sd, i, 3);
  6309. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6310. }
  6311. }
  6312. storage_storageclose(pl_sd);
  6313. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6314. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6315. clif_displaymessage(pl_sd->fd, " -- the management");
  6316. clif_displaymessage(fd, "It is done");
  6317. return 0;
  6318. }
  6319. /*==========================================
  6320. * @skillid by [MouseJstr]
  6321. * lookup a skill by name
  6322. *------------------------------------------
  6323. */
  6324. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6325. {
  6326. int skillen, idx;
  6327. nullpo_retr(-1, sd);
  6328. if (!message || !*message)
  6329. return -1;
  6330. skillen = strlen(message);
  6331. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6332. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6333. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6334. {
  6335. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6336. clif_displaymessage(fd, atcmd_output);
  6337. }
  6338. }
  6339. return 0;
  6340. }
  6341. /*==========================================
  6342. * @useskill by [MouseJstr]
  6343. * A way of using skills without having to find them in the skills menu
  6344. *------------------------------------------
  6345. */
  6346. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6347. {
  6348. struct map_session_data *pl_sd = NULL;
  6349. struct block_list *bl;
  6350. int skillnum;
  6351. int skilllv;
  6352. char target[255];
  6353. nullpo_retr(-1, sd);
  6354. if (!message || !*message)
  6355. return -1;
  6356. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6357. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6358. return -1;
  6359. }
  6360. if((pl_sd=map_nick2sd(target)) == NULL) {
  6361. return -1;
  6362. }
  6363. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  6364. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  6365. bl = &sd->hd->bl;
  6366. else
  6367. bl = &sd->bl;
  6368. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6369. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6370. else
  6371. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  6372. return 0;
  6373. }
  6374. /*==========================================
  6375. * @skilltree by [MouseJstr]
  6376. * prints the skill tree for a player required to get to a skill
  6377. *------------------------------------------
  6378. */
  6379. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6380. {
  6381. struct map_session_data *pl_sd = NULL;
  6382. int skillnum, skillidx = -1;
  6383. int meets = 1, j, c=0;
  6384. char target[NAME_LENGTH], *tbl;
  6385. struct skill_tree_entry *ent;
  6386. nullpo_retr(-1, sd);
  6387. if (!message || !*message)
  6388. return -1;
  6389. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6390. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6391. return -1;
  6392. }
  6393. if((pl_sd=map_nick2sd(target)) == NULL)
  6394. return -1;
  6395. c = pc_calc_skilltree_normalize_job(pl_sd);
  6396. c = pc_mapid2jobid(c, pl_sd->status.sex);
  6397. tbl = job_name(c);
  6398. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6399. tbl, pc_checkskill(pl_sd, 1));
  6400. clif_displaymessage(fd, atcmd_output);
  6401. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6402. if (skill_tree[c][j].id == skillnum) {
  6403. skillidx = j;
  6404. break;
  6405. }
  6406. }
  6407. if (skillidx == -1) {
  6408. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6409. clif_displaymessage(fd, atcmd_output);
  6410. return 0;
  6411. }
  6412. ent = &skill_tree[c][skillidx];
  6413. for(j=0;j<5;j++)
  6414. if( ent->need[j].id &&
  6415. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6416. {
  6417. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6418. sprintf(atcmd_output, "player requires level %d of skill %s",
  6419. ent->need[j].lv, desc);
  6420. clif_displaymessage(fd, atcmd_output);
  6421. meets = 0;
  6422. }
  6423. if (meets == 1) {
  6424. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6425. clif_displaymessage(fd, atcmd_output);
  6426. }
  6427. return 0;
  6428. }
  6429. // Hand a ring with partners name on it to this char
  6430. void getring (struct map_session_data *sd)
  6431. {
  6432. int flag,item_id = 0;
  6433. struct item item_tmp;
  6434. if(sd->status.sex==0)
  6435. item_id = 2635;
  6436. else
  6437. item_id = 2634;
  6438. memset(&item_tmp,0,sizeof(item_tmp));
  6439. item_tmp.nameid=item_id;
  6440. item_tmp.identify=1;
  6441. item_tmp.card[0]=255;
  6442. item_tmp.card[2]=sd->status.partner_id;
  6443. item_tmp.card[3]=sd->status.partner_id >> 16;
  6444. //Logs (A)dmins items [Lupus]
  6445. if(log_config.enable_logs&0x400)
  6446. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  6447. if((flag = pc_additem(sd,&item_tmp,1))) {
  6448. clif_additem(sd,0,0,flag);
  6449. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6450. }
  6451. }
  6452. /*==========================================
  6453. * @marry by [MouseJstr], fixed by Lupus
  6454. * Marry two players
  6455. *------------------------------------------
  6456. */
  6457. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6458. {
  6459. struct map_session_data *pl_sd1 = NULL;
  6460. struct map_session_data *pl_sd2 = NULL;
  6461. char player1[128], player2[128]; //Length used for return error msgs
  6462. nullpo_retr(-1, sd);
  6463. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  6464. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6465. return -1;
  6466. }
  6467. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6468. sprintf(player2, "Cannot find player '%s' online", player1);
  6469. clif_displaymessage(fd, player2);
  6470. return -1;
  6471. }
  6472. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6473. sprintf(player1, "Cannot find player '%s' online", player2);
  6474. clif_displaymessage(fd, player1);
  6475. return -1;
  6476. }
  6477. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6478. clif_displaymessage(fd, "They are married.. wish them well");
  6479. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6480. // Auto-give named rings (Aru)
  6481. getring (pl_sd1);
  6482. getring (pl_sd2);
  6483. return 0;
  6484. }
  6485. return -1;
  6486. }
  6487. /*==========================================
  6488. * @divorce by [MouseJstr], fixed by [Lupus]
  6489. * divorce two players
  6490. *------------------------------------------
  6491. */
  6492. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6493. {
  6494. struct map_session_data *pl_sd = NULL;
  6495. nullpo_retr(-1, sd);
  6496. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6497. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6498. return -1;
  6499. }
  6500. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6501. if (pc_divorce(pl_sd) != 0) {
  6502. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6503. clif_displaymessage(fd, atcmd_output);
  6504. return -1;
  6505. } else {
  6506. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6507. clif_displaymessage(fd, atcmd_output);
  6508. return 0;
  6509. }
  6510. }
  6511. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6512. clif_displaymessage(fd, atcmd_output);
  6513. return -1;
  6514. }
  6515. #ifdef DMALLOC
  6516. unsigned long dmark_;
  6517. int atcommand_dmstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6518. {
  6519. dmark_ = dmalloc_mark();
  6520. clif_displaymessage(fd, "debug mark set");
  6521. return 0;
  6522. }
  6523. int atcommand_dmtick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6524. {
  6525. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6526. dmark_ = dmalloc_mark();
  6527. clif_displaymessage(fd, "malloc changes logged");
  6528. return 0;
  6529. }
  6530. #endif
  6531. /*==========================================
  6532. * @grind by [MouseJstr]
  6533. *------------------------------------------
  6534. */
  6535. int atcommand_grind(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6536. {
  6537. struct map_session_data *pl_sd = NULL;
  6538. int skillnum;
  6539. int inf;
  6540. char target[NAME_LENGTH];
  6541. nullpo_retr(-1, sd);
  6542. if (!message || !*message)
  6543. return -1;
  6544. if(sscanf(message, "%23s", target) != 1) {
  6545. clif_displaymessage(fd, "Usage: @grind <target>");
  6546. return -1;
  6547. }
  6548. if((pl_sd=map_nick2sd(target)) == NULL)
  6549. return -1;
  6550. for (skillnum = 1; skillnum < 500; skillnum++) {
  6551. sd->status.sp = sd->status.max_sp;
  6552. atcommand_alive(fd, sd, command, message);
  6553. inf = skill_get_inf(skillnum);
  6554. if (inf & INF_GROUND_SKILL)
  6555. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6556. else if (!(inf & INF_SUPPORT_SKILL))
  6557. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6558. }
  6559. return 0;
  6560. }
  6561. /*==========================================
  6562. * @grind2 by [MouseJstr]
  6563. *------------------------------------------
  6564. */
  6565. int atcommand_grind2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6566. {
  6567. int i;
  6568. short x, y;
  6569. for (i = 1000; i < MAX_MOB_DB; i++) {
  6570. if (!mobdb_checkid(i))
  6571. continue;
  6572. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6573. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6574. }
  6575. return 0;
  6576. }
  6577. /*==========================================
  6578. * @changelook by [Celest]
  6579. *------------------------------------------
  6580. */
  6581. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6582. {
  6583. int i, j = 0, k = 0;
  6584. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6585. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6586. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6587. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6588. return -1;
  6589. } else if (i == 2) {
  6590. if (j < 1) j = 1;
  6591. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6592. j = pos[j - 1];
  6593. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6594. k = j; // swap
  6595. j = LOOK_HEAD_TOP;
  6596. }
  6597. clif_changelook(&sd->bl,j,k);
  6598. return 0;
  6599. }
  6600. /*==========================================
  6601. * @autotrade by durf (changed by Lupus)
  6602. * Turns on/off Autotrade for a specific player
  6603. *------------------------------------------
  6604. */
  6605. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6606. {
  6607. nullpo_retr(-1, sd);
  6608. if (sd->vender_id) //check if player's vending
  6609. {
  6610. sd->state.autotrade = 1;
  6611. clif_authfail_fd(fd, 15);
  6612. }
  6613. else
  6614. {
  6615. //"You should be vending to use @Autotrade."
  6616. clif_displaymessage(fd, msg_txt(549));
  6617. }
  6618. return 0;
  6619. }
  6620. /*==========================================
  6621. * @changegm by durf (changed by Lupus)
  6622. * Changes Master of your Guild to a specified guild member
  6623. *------------------------------------------
  6624. */
  6625. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6626. {
  6627. struct guild *g;
  6628. struct map_session_data *pl_sd;
  6629. nullpo_retr(-1, sd);
  6630. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6631. {
  6632. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6633. return -1;
  6634. }
  6635. if (strlen(message)==0)
  6636. {
  6637. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6638. return -1;
  6639. }
  6640. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6641. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6642. return -1;
  6643. }
  6644. guild_gm_change(sd->status.guild_id, pl_sd);
  6645. return 0;
  6646. }
  6647. /*==========================================
  6648. * @changeleader by Skotlex
  6649. * Changes the leader of a party.
  6650. *------------------------------------------
  6651. */
  6652. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6653. {
  6654. struct party_data *p;
  6655. struct map_session_data *pl_sd;
  6656. int mi, pl_mi;
  6657. nullpo_retr(-1, sd);
  6658. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6659. { //Need to be a party leader.
  6660. clif_displaymessage(fd, msg_txt(282));
  6661. return -1;
  6662. }
  6663. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6664. if (mi == MAX_PARTY)
  6665. return -1; //Shouldn't happen
  6666. if (!p->party.member[mi].leader)
  6667. { //Need to be a party leader.
  6668. clif_displaymessage(fd, msg_txt(282));
  6669. return -1;
  6670. }
  6671. if (strlen(message)==0)
  6672. {
  6673. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6674. return -1;
  6675. }
  6676. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6677. clif_displaymessage(fd, msg_txt(283));
  6678. return -1;
  6679. }
  6680. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  6681. if (pl_mi == MAX_PARTY)
  6682. return -1; //Shouldn't happen
  6683. //Change leadership.
  6684. p->party.member[mi].leader = 0;
  6685. if (p->data[mi].sd->fd)
  6686. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  6687. p->party.member[pl_mi].leader = 1;
  6688. if (p->data[pl_mi].sd->fd)
  6689. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  6690. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  6691. //Update info.
  6692. clif_party_info(p,NULL);
  6693. return 0;
  6694. }
  6695. /*==========================================
  6696. * @partyoption by Skotlex
  6697. * Used to change the item share setting of a party.
  6698. *------------------------------------------
  6699. */
  6700. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6701. {
  6702. struct party_data *p;
  6703. int mi, option;
  6704. char w1[15], w2[15];
  6705. nullpo_retr(-1, sd);
  6706. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6707. {
  6708. clif_displaymessage(fd, msg_txt(282));
  6709. return -1;
  6710. }
  6711. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6712. if (mi == MAX_PARTY)
  6713. return -1; //Shouldn't happen
  6714. if (!p->party.member[mi].leader)
  6715. {
  6716. clif_displaymessage(fd, msg_txt(282));
  6717. return -1;
  6718. }
  6719. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  6720. {
  6721. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  6722. return -1;
  6723. }
  6724. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  6725. option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
  6726. //Change item share type.
  6727. if (option != p->party.item)
  6728. party_changeoption(sd, p->party.exp, option);
  6729. else
  6730. clif_displaymessage(fd, msg_txt(286));
  6731. return 0;
  6732. }
  6733. /*==========================================
  6734. * @autoloot by Upa-Kun
  6735. * Turns on/off AutoLoot for a specific player
  6736. *------------------------------------------
  6737. */
  6738. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6739. {
  6740. int rate;
  6741. double drate;
  6742. nullpo_retr(-1, sd);
  6743. // autoloot command without value
  6744. if(!message || !*message)
  6745. {
  6746. if (sd->state.autoloot)
  6747. rate = 0;
  6748. else
  6749. rate = 10000;
  6750. } else {
  6751. drate = atof(message);
  6752. rate = (int)(drate*100);
  6753. }
  6754. if (rate < 0) rate = 0;
  6755. if (rate > 10000) rate = 10000;
  6756. sd->state.autoloot = rate;
  6757. if (sd->state.autoloot) {
  6758. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6759. clif_displaymessage(fd, atcmd_output);
  6760. }else
  6761. clif_displaymessage(fd, "Autoloot is now off.");
  6762. return 0;
  6763. }
  6764. /*==========================================
  6765. * It is made to rain.
  6766. *------------------------------------------
  6767. */
  6768. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6769. {
  6770. nullpo_retr(-1, sd);
  6771. if (map[sd->bl.m].flag.rain) {
  6772. map[sd->bl.m].flag.rain=0;
  6773. clif_weather(sd->bl.m);
  6774. clif_displaymessage(fd, "The rain has stopped.");
  6775. } else {
  6776. map[sd->bl.m].flag.rain=1;
  6777. clif_weather(sd->bl.m);
  6778. clif_displaymessage(fd, "It is made to rain.");
  6779. }
  6780. return 0;
  6781. }
  6782. /*==========================================
  6783. * It is made to snow.
  6784. *------------------------------------------
  6785. */
  6786. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6787. {
  6788. nullpo_retr(-1, sd);
  6789. if (map[sd->bl.m].flag.snow) {
  6790. map[sd->bl.m].flag.snow=0;
  6791. clif_weather(sd->bl.m);
  6792. clif_displaymessage(fd, "Snow has stopped falling.");
  6793. } else {
  6794. map[sd->bl.m].flag.snow=1;
  6795. clif_weather(sd->bl.m);
  6796. clif_displaymessage(fd, "It is made to snow.");
  6797. }
  6798. return 0;
  6799. }
  6800. /*==========================================
  6801. * Cherry tree snowstorm is made to fall. (Sakura)
  6802. *------------------------------------------
  6803. */
  6804. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6805. {
  6806. nullpo_retr(-1, sd);
  6807. if (map[sd->bl.m].flag.sakura) {
  6808. map[sd->bl.m].flag.sakura=0;
  6809. clif_weather(sd->bl.m);
  6810. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6811. } else {
  6812. map[sd->bl.m].flag.sakura=1;
  6813. clif_weather(sd->bl.m);
  6814. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6815. }
  6816. return 0;
  6817. }
  6818. /*==========================================
  6819. * Clouds appear.
  6820. *------------------------------------------
  6821. */
  6822. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6823. {
  6824. nullpo_retr(-1, sd);
  6825. if (map[sd->bl.m].flag.clouds) {
  6826. map[sd->bl.m].flag.clouds=0;
  6827. clif_weather(sd->bl.m);
  6828. clif_displaymessage(fd, "The clouds has disappear.");
  6829. } else {
  6830. map[sd->bl.m].flag.clouds=1;
  6831. clif_weather(sd->bl.m);
  6832. clif_displaymessage(fd, "Clouds appear.");
  6833. }
  6834. return 0;
  6835. }
  6836. /*==========================================
  6837. * Different type of clouds using effect 516
  6838. *------------------------------------------
  6839. */
  6840. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6841. {
  6842. nullpo_retr(-1, sd);
  6843. if (map[sd->bl.m].flag.clouds2) {
  6844. map[sd->bl.m].flag.clouds2=0;
  6845. clif_weather(sd->bl.m);
  6846. clif_displaymessage(fd, "The alternative clouds disappear.");
  6847. } else {
  6848. map[sd->bl.m].flag.clouds2=1;
  6849. clif_weather(sd->bl.m);
  6850. clif_displaymessage(fd, "Alternative clouds appear.");
  6851. }
  6852. return 0;
  6853. }
  6854. /*==========================================
  6855. * Fog hangs over.
  6856. *------------------------------------------
  6857. */
  6858. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6859. {
  6860. nullpo_retr(-1, sd);
  6861. if (map[sd->bl.m].flag.fog) {
  6862. map[sd->bl.m].flag.fog=0;
  6863. clif_weather(sd->bl.m);
  6864. clif_displaymessage(fd, "The fog has gone.");
  6865. } else {
  6866. map[sd->bl.m].flag.fog=1;
  6867. clif_weather(sd->bl.m);
  6868. clif_displaymessage(fd, "Fog hangs over.");
  6869. }
  6870. return 0;
  6871. }
  6872. /*==========================================
  6873. * Fallen leaves fall.
  6874. *------------------------------------------
  6875. */
  6876. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6877. {
  6878. nullpo_retr(-1, sd);
  6879. if (map[sd->bl.m].flag.leaves) {
  6880. map[sd->bl.m].flag.leaves=0;
  6881. clif_weather(sd->bl.m);
  6882. clif_displaymessage(fd, "Leaves no longer fall.");
  6883. } else {
  6884. map[sd->bl.m].flag.leaves=1;
  6885. clif_weather(sd->bl.m);
  6886. clif_displaymessage(fd, "Fallen leaves fall.");
  6887. }
  6888. return 0;
  6889. }
  6890. /*==========================================
  6891. * Fireworks appear.
  6892. *------------------------------------------
  6893. */
  6894. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6895. {
  6896. nullpo_retr(-1, sd);
  6897. if (map[sd->bl.m].flag.fireworks) {
  6898. map[sd->bl.m].flag.fireworks=0;
  6899. clif_weather(sd->bl.m);
  6900. clif_displaymessage(fd, "Fireworks are ended.");
  6901. } else {
  6902. map[sd->bl.m].flag.fireworks=1;
  6903. clif_weather(sd->bl.m);
  6904. clif_displaymessage(fd, "Fireworks are launched.");
  6905. }
  6906. return 0;
  6907. }
  6908. /*==========================================
  6909. * Clearing Weather Effects by Dexity
  6910. *------------------------------------------
  6911. */
  6912. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6913. {
  6914. nullpo_retr(-1, sd);
  6915. map[sd->bl.m].flag.rain=0;
  6916. map[sd->bl.m].flag.snow=0;
  6917. map[sd->bl.m].flag.sakura=0;
  6918. map[sd->bl.m].flag.clouds=0;
  6919. map[sd->bl.m].flag.clouds2=0;
  6920. map[sd->bl.m].flag.fog=0;
  6921. map[sd->bl.m].flag.fireworks=0;
  6922. map[sd->bl.m].flag.leaves=0;
  6923. clif_weather(sd->bl.m);
  6924. clif_displaymessage(fd, msg_txt(291));
  6925. return 0;
  6926. }
  6927. /*===============================================================
  6928. * Sound Command - plays a sound for everyone! [Codemaster]
  6929. *---------------------------------------------------------------
  6930. */
  6931. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6932. {
  6933. char sound_file[100];
  6934. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6935. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6936. return -1;
  6937. }
  6938. memset(sound_file, '\0', sizeof(sound_file));
  6939. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6940. return -1;
  6941. if(strstr(sound_file, ".wav") == NULL)
  6942. strcat(sound_file, ".wav");
  6943. clif_soundeffectall(&sd->bl, sound_file,0,2);
  6944. return 0;
  6945. }
  6946. /*==========================================
  6947. * MOB Search
  6948. *------------------------------------------
  6949. */
  6950. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  6951. {
  6952. int mob_id,fd;
  6953. static int number=0;
  6954. struct mob_data *md;
  6955. nullpo_retr(0, bl);
  6956. if(!ap){
  6957. number=0;
  6958. return 0;
  6959. }
  6960. mob_id = va_arg(ap,int);
  6961. fd = va_arg(ap,int);
  6962. md = (struct mob_data *)bl;
  6963. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  6964. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  6965. ++number,bl->x, bl->y,md->name);
  6966. clif_displaymessage(fd, atcmd_output);
  6967. }
  6968. return 0;
  6969. }
  6970. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6971. {
  6972. char mob_name[100];
  6973. int mob_id,map_id = 0;
  6974. nullpo_retr(-1, sd);
  6975. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6976. return -1;
  6977. if ((mob_id = atoi(mob_name)) == 0)
  6978. mob_id = mobdb_searchname(mob_name);
  6979. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6980. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6981. clif_displaymessage(fd, atcmd_output);
  6982. return 0;
  6983. }
  6984. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6985. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6986. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6987. map_id = sd->bl.m;
  6988. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  6989. clif_displaymessage(fd, atcmd_output);
  6990. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  6991. atmobsearch_sub(&sd->bl,0); // reset the counter
  6992. return 0;
  6993. }
  6994. /*==========================================
  6995. * @cleanmap - cleans items on the ground
  6996. *------------------------------------------
  6997. */
  6998. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  6999. {
  7000. nullpo_retr(0, bl);
  7001. map_clearflooritem(bl->id);
  7002. return 0;
  7003. }
  7004. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7005. {
  7006. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7007. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7008. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7009. BL_ITEM);
  7010. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7011. return 0;
  7012. }
  7013. /*==========================================
  7014. * make a NPC/PET talk
  7015. *------------------------------------------
  7016. */
  7017. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7018. {
  7019. char name[NAME_LENGTH],mes[100],temp[100];
  7020. struct npc_data *nd;
  7021. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7022. return -1;
  7023. if (!(nd = npc_name2id(name)))
  7024. return -1;
  7025. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7026. clif_message(&nd->bl, temp);
  7027. return 0;
  7028. }
  7029. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7030. {
  7031. char mes[100],temp[100];
  7032. struct pet_data *pd;
  7033. nullpo_retr(-1, sd);
  7034. if(!sd->status.pet_id || !(pd=sd->pd))
  7035. return -1;
  7036. if (sd->sc.count && //no "chatting" while muted.
  7037. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7038. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7039. return -1;
  7040. if (sscanf(message, "%99[^\n]", mes) < 1)
  7041. return -1;
  7042. snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
  7043. clif_message(&pd->bl, temp);
  7044. return 0;
  7045. }
  7046. /*==========================================
  7047. * @users - displays the number of players present on each map (percentage)
  7048. *------------------------------------------
  7049. */
  7050. static struct dbt *users_db = NULL;
  7051. static int users_all;
  7052. static int atcommand_users_sub1(struct map_session_data* sd,va_list va)
  7053. {
  7054. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7055. users_all++;
  7056. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7057. return 0;
  7058. }
  7059. static int atcommand_users_sub2(DBKey key,void* val,va_list va)
  7060. {
  7061. char buf[256];
  7062. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7063. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7064. clif_displaymessage(sd->fd,buf);
  7065. return 0;
  7066. }
  7067. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7068. {
  7069. char buf[256];
  7070. users_all = 0;
  7071. users_db->clear(users_db, NULL);
  7072. clif_foreachclient(atcommand_users_sub1);
  7073. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7074. sprintf(buf,"all : %d",users_all);
  7075. clif_displaymessage(fd,buf);
  7076. return 0;
  7077. }
  7078. /*==========================================
  7079. *
  7080. *------------------------------------------
  7081. */
  7082. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7083. {
  7084. pc_resetstate(sd);
  7085. pc_resetskill(sd,1);
  7086. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  7087. clif_displaymessage(fd, atcmd_output);
  7088. return 0;
  7089. }
  7090. /*==========================================
  7091. *
  7092. *------------------------------------------
  7093. */
  7094. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7095. {
  7096. char name[NAME_LENGTH];
  7097. int mob_id = 0;
  7098. int duration = 0;
  7099. struct mob_data *md;
  7100. unsigned int tick=gettick();
  7101. nullpo_retr(-1, sd);
  7102. if (!message || !*message)
  7103. return -1;
  7104. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7105. return -1;
  7106. if (duration < 1)
  7107. duration =1;
  7108. else if (duration > 60)
  7109. duration =60;
  7110. if ((mob_id = atoi(name)) == 0)
  7111. mob_id = mobdb_searchname(name);
  7112. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7113. return -1;
  7114. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7115. if(md){
  7116. md->master_id=sd->bl.id;
  7117. md->special_state.ai=1;
  7118. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  7119. clif_misceffect2(&md->bl,344);
  7120. mob_spawn(md);
  7121. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7122. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7123. }
  7124. return 0;
  7125. }
  7126. /*==========================================
  7127. * @adjcmdlvl by [MouseJstr]
  7128. *
  7129. * Temp adjust the GM level required to use a GM command
  7130. * Useful during beta testing to allow players to use GM commands for short periods of time
  7131. *------------------------------------------
  7132. */
  7133. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7134. {
  7135. int i, newlev;
  7136. char cmd[100];
  7137. nullpo_retr(-1, sd);
  7138. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7139. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7140. return -1;
  7141. }
  7142. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7143. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7144. atcommand_info[i].level = newlev;
  7145. clif_displaymessage(fd, "@command level changed.");
  7146. return 0;
  7147. }
  7148. clif_displaymessage(fd, "@command not found.");
  7149. return -1;
  7150. }
  7151. /*==========================================
  7152. * @adjgmlvl by [MouseJstr]
  7153. * Create a temp GM
  7154. * Useful during beta testing to allow players to use GM commands for short periods of time
  7155. *------------------------------------------
  7156. */
  7157. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7158. {
  7159. int newlev;
  7160. char user[NAME_LENGTH];
  7161. struct map_session_data *pl_sd;
  7162. nullpo_retr(-1, sd);
  7163. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7164. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7165. return -1;
  7166. }
  7167. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7168. return -1;
  7169. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7170. return 0;
  7171. }
  7172. /*==========================================
  7173. * @trade by [MouseJstr]
  7174. * Open a trade window with a remote player
  7175. *------------------------------------------
  7176. */
  7177. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7178. {
  7179. struct map_session_data *pl_sd = NULL;
  7180. nullpo_retr(-1, sd);
  7181. if (!message || !*message)
  7182. return -1;
  7183. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7184. trade_traderequest(sd, pl_sd);
  7185. return 0;
  7186. }
  7187. return -1;
  7188. }
  7189. /*==========================================
  7190. * @setbattleflag by [MouseJstr]
  7191. * set a battle_config flag without having to reboot
  7192. */
  7193. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7194. {
  7195. char flag[128], value[128];
  7196. nullpo_retr(-1, sd);
  7197. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7198. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7199. return -1;
  7200. }
  7201. if (battle_set_value(flag, value) == 0)
  7202. clif_displaymessage(fd, "unknown battle_config flag");
  7203. else
  7204. clif_displaymessage(fd, "battle_config set as requested");
  7205. return 0;
  7206. }
  7207. /*===========================
  7208. * @unmute [Valaris]
  7209. *===========================
  7210. */
  7211. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7212. {
  7213. struct map_session_data *pl_sd = NULL;
  7214. nullpo_retr(-1, sd);
  7215. if (!message || !*message)
  7216. return -1;
  7217. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7218. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7219. pl_sd->status.manner = 0;
  7220. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7221. clif_displaymessage(sd->fd,"Player unmuted");
  7222. }
  7223. else
  7224. clif_displaymessage(sd->fd,"Player is not muted");
  7225. }
  7226. return 0;
  7227. }
  7228. /*==========================================
  7229. * @uptime by MC Cameri
  7230. *------------------------------------------
  7231. */
  7232. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7233. {
  7234. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7235. minute = 60, days = 0, hours = 0, minutes = 0;
  7236. nullpo_retr(-1, sd);
  7237. seconds = get_uptime();
  7238. days = seconds/day;
  7239. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7240. hours = seconds/hour;
  7241. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7242. minutes = seconds/minute;
  7243. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7244. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  7245. clif_displaymessage(fd, atcmd_output);
  7246. return 0;
  7247. }
  7248. /*==========================================
  7249. * @changesex <sex>
  7250. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  7251. *------------------------------------------
  7252. */
  7253. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7254. {
  7255. nullpo_retr(-1, sd);
  7256. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7257. return 0;
  7258. }
  7259. /*================================================
  7260. * @mute - Mutes a player for a set amount of time
  7261. *------------------------------------------------
  7262. */
  7263. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7264. {
  7265. struct map_session_data *pl_sd = NULL;
  7266. int manner;
  7267. nullpo_retr(-1, sd);
  7268. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7269. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7270. return -1;
  7271. }
  7272. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7273. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7274. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7275. return -1;
  7276. }
  7277. clif_GM_silence(sd, pl_sd, 0);
  7278. pl_sd->status.manner -= manner;
  7279. if(pl_sd->status.manner < 0)
  7280. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7281. }
  7282. else {
  7283. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7284. return -1;
  7285. }
  7286. return 0;
  7287. }
  7288. /*==========================================
  7289. * @refresh (like @jumpto <<yourself>>)
  7290. *------------------------------------------
  7291. */
  7292. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7293. {
  7294. nullpo_retr(-1, sd);
  7295. clif_refresh(sd);
  7296. return 0;
  7297. }
  7298. /*==========================================
  7299. * @petid <part of pet name>
  7300. * => Displays a list of matching pets.
  7301. *------------------------------------------
  7302. */
  7303. int atcommand_petid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7304. {
  7305. char searchtext[100];
  7306. char temp0[100];
  7307. char temp1[100];
  7308. int cnt = 0, i = 0;
  7309. nullpo_retr(-1, sd);
  7310. if (!message || !*message)
  7311. return -1;
  7312. if (sscanf(message, "%99s", searchtext) < 1)
  7313. return -1;
  7314. estr_lower(searchtext);
  7315. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7316. clif_displaymessage(fd,temp0);
  7317. while (i < MAX_PET_DB) {
  7318. strcpy(temp1,pet_db[i].name);
  7319. strcpy(temp1, estr_lower(temp1));
  7320. strcpy(temp0,pet_db[i].jname);
  7321. strcpy(temp0, estr_lower(temp1));
  7322. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7323. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7324. pet_db[i].jname);
  7325. if (cnt >= 100) { // Only if there are custom pets
  7326. clif_displaymessage(fd, "Be more specific, can't send more than"
  7327. " 100 results.");
  7328. } else {
  7329. clif_displaymessage(fd, temp0);
  7330. }
  7331. cnt++;
  7332. }
  7333. i++;
  7334. }
  7335. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7336. clif_displaymessage(fd, temp0);
  7337. return 0;
  7338. }
  7339. /*==========================================
  7340. * @identify
  7341. * => GM's magnifier.
  7342. *------------------------------------------
  7343. */
  7344. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7345. {
  7346. int i,num;
  7347. nullpo_retr(-1, sd);
  7348. for(i=num=0;i<MAX_INVENTORY;i++){
  7349. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7350. num++;
  7351. }
  7352. }
  7353. if (num > 0) {
  7354. clif_item_identify_list(sd);
  7355. } else {
  7356. clif_displaymessage(fd,"There are no items to appraise.");
  7357. }
  7358. return 0;
  7359. }
  7360. /*==========================================
  7361. * @gmotd (Global MOTD)
  7362. * by davidsiaw :P
  7363. *------------------------------------------
  7364. */
  7365. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7366. {
  7367. char buf[256];
  7368. FILE *fp;
  7369. nullpo_retr(-1, sd);
  7370. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7371. while (fgets(buf, 250, fp) != NULL){
  7372. int i;
  7373. for( i=0; buf[i]; i++){
  7374. if( buf[i]=='\r' || buf[i]=='\n'){
  7375. buf[i]=0;
  7376. break;
  7377. }
  7378. }
  7379. intif_GMmessage(buf,strlen(buf)+1,8);
  7380. }
  7381. fclose(fp);
  7382. }
  7383. return 0;
  7384. }
  7385. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7386. {
  7387. int effect = 0;
  7388. nullpo_retr(-1, sd);
  7389. if (!message || !*message)
  7390. return -1;
  7391. if (sscanf(message, "%d", &effect) < 1)
  7392. return -1;
  7393. clif_misceffect(&sd->bl,effect);
  7394. return 0;
  7395. }
  7396. /*==========================================
  7397. * Jump to a player by PID number
  7398. * Original by Dino9021
  7399. * Added in by nsstrunks
  7400. *------------------------------------------
  7401. */
  7402. int atcommand_jumptoid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7403. {
  7404. int cid=0;
  7405. struct map_session_data *pl_sd;
  7406. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7407. if (!message || (cid = atoi(message)) == 0) {
  7408. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7409. return -1;
  7410. }
  7411. pl_sd = map_charid2sd(cid);
  7412. if (!pl_sd) {
  7413. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7414. return -1;
  7415. }
  7416. if (map[pl_sd->bl.m].flag.nowarpto &&
  7417. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7418. {
  7419. clif_displaymessage(fd, msg_txt(247));
  7420. return -1;
  7421. }
  7422. if (map[sd->bl.m].flag.nowarp &&
  7423. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7424. {
  7425. clif_displaymessage(fd, msg_txt(248));
  7426. return -1;
  7427. }
  7428. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7429. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7430. clif_displaymessage(fd, atcmd_output);
  7431. return 0;
  7432. }
  7433. /*==========================================
  7434. * Jump to a player by PID number
  7435. * Original by Dino9021
  7436. * Added in by nsstrunks
  7437. *------------------------------------------
  7438. */
  7439. int atcommand_jumptoid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7440. {
  7441. int aid=0;
  7442. struct map_session_data *pl_sd;
  7443. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7444. if (!message || (aid = atoi(message)) == 0) {
  7445. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7446. return -1;
  7447. }
  7448. pl_sd = map_id2sd(aid);
  7449. if (!pl_sd) {
  7450. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7451. return -1;
  7452. }
  7453. if (map[pl_sd->bl.m].flag.nowarpto &&
  7454. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7455. {
  7456. clif_displaymessage(fd, msg_txt(247));
  7457. return -1;
  7458. }
  7459. if (map[sd->bl.m].flag.nowarp &&
  7460. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7461. {
  7462. clif_displaymessage(fd, msg_txt(248));
  7463. return -1;
  7464. }
  7465. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7466. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7467. clif_displaymessage(fd, atcmd_output);
  7468. return 0;
  7469. }
  7470. /*==========================================
  7471. * Recall a player by PID number
  7472. * Original by Dino9021
  7473. * Added in by nsstrunks
  7474. *------------------------------------------
  7475. */
  7476. int atcommand_recallid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7477. {
  7478. int cid=0;
  7479. struct map_session_data *pl_sd;
  7480. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7481. if (!message || (cid = atoi(message)) == 0) {
  7482. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7483. return -1;
  7484. }
  7485. pl_sd = map_charid2sd(cid);
  7486. if (!pl_sd) {
  7487. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7488. return -1;
  7489. }
  7490. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can recall only lower or same level
  7491. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7492. return -1;
  7493. }
  7494. if (map[pl_sd->bl.m].flag.nowarpto &&
  7495. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7496. {
  7497. clif_displaymessage(fd, msg_txt(247));
  7498. return -1;
  7499. }
  7500. if (map[sd->bl.m].flag.nowarp &&
  7501. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7502. {
  7503. clif_displaymessage(fd, msg_txt(248));
  7504. return -1;
  7505. }
  7506. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7507. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  7508. clif_displaymessage(fd, atcmd_output);
  7509. return 0;
  7510. }
  7511. /*==========================================
  7512. * Recall a player by PID number
  7513. * Original by Dino9021
  7514. * Added in by nsstrunks
  7515. *------------------------------------------
  7516. */
  7517. int atcommand_recallid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7518. {
  7519. int aid=0;
  7520. struct map_session_data *pl_sd;
  7521. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7522. if (!message || (aid = atoi(message)) == 0) {
  7523. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7524. return -1;
  7525. }
  7526. pl_sd = map_id2sd(aid);
  7527. if (!pl_sd) {
  7528. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7529. return -1;
  7530. }
  7531. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7532. { // you can recall only lower or same level
  7533. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7534. return -1;
  7535. }
  7536. if (map[pl_sd->bl.m].flag.nowarpto &&
  7537. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7538. {
  7539. clif_displaymessage(fd, msg_txt(247));
  7540. return -1;
  7541. }
  7542. if (map[sd->bl.m].flag.nowarp &&
  7543. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7544. {
  7545. clif_displaymessage(fd, msg_txt(248));
  7546. return -1;
  7547. }
  7548. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7549. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  7550. clif_displaymessage(fd, atcmd_output);
  7551. return 0;
  7552. }
  7553. /*==========================================
  7554. * Kick a player by PID number
  7555. * Original by Dino9021
  7556. * Added in by nsstrunks
  7557. *------------------------------------------
  7558. */
  7559. int atcommand_kickid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7560. {
  7561. struct map_session_data *pl_sd;
  7562. int cid=0;
  7563. if (!message || (cid = atoi(message)) == 0) {
  7564. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7565. return -1;
  7566. }
  7567. pl_sd = map_charid2sd(cid);
  7568. if (!pl_sd) {
  7569. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7570. return -1;
  7571. }
  7572. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7573. { // you can kick only lower or same gm level
  7574. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7575. return -1;
  7576. }
  7577. clif_GM_kick(sd, pl_sd, 1);
  7578. return 0;
  7579. }
  7580. /*==========================================
  7581. * Kick a player by PID number
  7582. * Original by Dino9021
  7583. * Added in by nsstrunks
  7584. *------------------------------------------
  7585. */
  7586. int atcommand_kickid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7587. {
  7588. struct map_session_data *pl_sd;
  7589. int aid=0;
  7590. if (!message || (aid = atoi(message)) == 0) {
  7591. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7592. return -1;
  7593. }
  7594. pl_sd = map_id2sd(aid);
  7595. if (!pl_sd) {
  7596. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7597. return -1;
  7598. }
  7599. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7600. { // you can kick only lower or same gm level
  7601. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7602. return -1;
  7603. }
  7604. clif_GM_kick(sd, pl_sd, 1);
  7605. return 0;
  7606. }
  7607. /*==========================================
  7608. * Revive a player by PID number
  7609. * Original by Dino9021
  7610. * Added in by nsstrunks
  7611. *------------------------------------------
  7612. */
  7613. int atcommand_reviveid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7614. {
  7615. int cid=0;
  7616. struct map_session_data *pl_sd;
  7617. if (!message || (cid = atoi(message)) == 0) {
  7618. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7619. return -1;
  7620. }
  7621. pl_sd = map_charid2sd(cid);
  7622. if (!pl_sd) {
  7623. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7624. return -1;
  7625. }
  7626. if(!status_revive(&pl_sd->bl, 100, 100))
  7627. return -1;
  7628. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  7629. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  7630. return 0;
  7631. }
  7632. /*==========================================
  7633. * Revive a player by PID number
  7634. * Original by Dino9021
  7635. * Added in by nsstrunks
  7636. *------------------------------------------
  7637. */
  7638. int atcommand_reviveid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7639. {
  7640. int aid=0;
  7641. struct map_session_data *pl_sd;
  7642. if (!message || (aid = atoi(message)) == 0) {
  7643. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7644. return -1;
  7645. }
  7646. pl_sd = map_id2sd(aid);
  7647. if(!pl_sd) {
  7648. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7649. return -1;
  7650. }
  7651. if(!status_revive(&pl_sd->bl, 100, 100))
  7652. return -1;
  7653. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  7654. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  7655. return 0;
  7656. }
  7657. /*==========================================
  7658. * Kill a player by PID number
  7659. * Original by Dino9021
  7660. * Added in by nsstrunks
  7661. *------------------------------------------
  7662. */
  7663. int atcommand_killid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7664. {
  7665. int cid=0;
  7666. struct map_session_data *pl_sd;
  7667. if (!message || (cid = atoi(message)) == 0) {
  7668. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7669. return -1;
  7670. }
  7671. pl_sd = map_charid2sd(cid);
  7672. if (!pl_sd) {
  7673. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7674. return -1;
  7675. }
  7676. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7677. { // you can kill only lower or same level
  7678. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7679. return -1;
  7680. }
  7681. status_kill(&pl_sd->bl);
  7682. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  7683. return 0;
  7684. }
  7685. /*==========================================
  7686. * Kill a player by PID number
  7687. * Original by Dino9021
  7688. * Added in by nsstrunks
  7689. *------------------------------------------
  7690. */
  7691. int atcommand_killid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7692. {
  7693. int aid=0;
  7694. struct map_session_data *pl_sd;
  7695. if (!message || (aid = atoi(message)) == 0) {
  7696. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7697. return -1;
  7698. }
  7699. pl_sd = map_id2sd(aid);
  7700. if (!pl_sd) {
  7701. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7702. return -1;
  7703. }
  7704. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7705. { // you can kill only lower or same level
  7706. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7707. return -1;
  7708. }
  7709. status_kill(&pl_sd->bl);
  7710. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  7711. return 0;
  7712. }
  7713. /*==========================================
  7714. * Make a player killable, by PID
  7715. * Original by Dino9021
  7716. * Added in by nsstrunks
  7717. *------------------------------------------
  7718. */
  7719. int atcommand_charkillableid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7720. {
  7721. struct map_session_data *pl_sd = NULL;
  7722. int cid=0;
  7723. if (!message || (cid = atoi(message)) == 0) {
  7724. clif_displaymessage(fd, "Please, enter a player CID.");
  7725. return -1;
  7726. }
  7727. pl_sd = map_charid2sd(cid);
  7728. if (!pl_sd) {
  7729. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7730. return -1;
  7731. }
  7732. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7733. {
  7734. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7735. return -1;
  7736. }
  7737. pl_sd->state.killable = !pl_sd->state.killable;
  7738. if(pl_sd->state.killable)
  7739. clif_displaymessage(fd, msg_txt(289));
  7740. else
  7741. clif_displaymessage(fd, msg_txt(290));
  7742. return 0;
  7743. }
  7744. /*==========================================
  7745. * Make a player killable, by PID
  7746. * Original by Dino9021
  7747. * Added in by nsstrunks
  7748. *------------------------------------------
  7749. */
  7750. int atcommand_charkillableid2( const int fd, struct map_session_data* sd, const char* command, const char* message)
  7751. {
  7752. struct map_session_data *pl_sd = NULL;
  7753. int aid=0;
  7754. if (!message || (aid = atoi(message)) == 0) {
  7755. clif_displaymessage(fd, "Please, enter a player AID.");
  7756. return -1;
  7757. }
  7758. pl_sd = map_id2sd(aid);
  7759. if (!pl_sd) {
  7760. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7761. return -1;
  7762. }
  7763. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7764. {
  7765. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7766. return -1;
  7767. }
  7768. pl_sd->state.killable = !pl_sd->state.killable;
  7769. if(pl_sd->state.killable)
  7770. clif_displaymessage(fd, msg_txt(289));
  7771. else
  7772. clif_displaymessage(fd, msg_txt(290));
  7773. return 0;
  7774. }
  7775. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7776. /*==========================================
  7777. * Mail System commands by [Valaris]
  7778. *------------------------------------------
  7779. */
  7780. int atcommand_listmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7781. {
  7782. if(!mail_server_enable)
  7783. return 0;
  7784. nullpo_retr(-1, sd);
  7785. if(strlen(command)==12)
  7786. mail_check(sd,3);
  7787. else if(strlen(command)==9)
  7788. mail_check(sd,2);
  7789. else
  7790. mail_check(sd,1);
  7791. return 0;
  7792. }
  7793. int atcommand_readmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7794. {
  7795. int index;
  7796. if(!mail_server_enable)
  7797. return 0;
  7798. nullpo_retr(-1, sd);
  7799. if (!message || !*message) {
  7800. clif_displaymessage(sd->fd,"You must specify a message number.");
  7801. return 0;
  7802. }
  7803. index = atoi(message);
  7804. if (index < 1) {
  7805. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  7806. return 0;
  7807. }
  7808. if(strlen(command)==11)
  7809. mail_delete(sd,index);
  7810. else
  7811. mail_read(sd,index);
  7812. return 0;
  7813. }
  7814. int atcommand_sendmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7815. {
  7816. char name[NAME_LENGTH],text[80];
  7817. if(!mail_server_enable)
  7818. return 0;
  7819. nullpo_retr(-1, sd);
  7820. if (!message || !*message) {
  7821. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7822. return 0;
  7823. }
  7824. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  7825. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7826. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7827. return 0;
  7828. }
  7829. if(strlen(command)==17)
  7830. mail_send(sd,name,text,1);
  7831. else
  7832. mail_send(sd,name,text,0);
  7833. return 0;
  7834. }
  7835. /*==========================================
  7836. * Refresh online command for SQL [Valaris]
  7837. * Will refresh and check online column of players and set correctly.
  7838. *------------------------------------------
  7839. */
  7840. int atcommand_refreshonline(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7841. {
  7842. send_users_tochar(-1, gettick(), 0, 0);
  7843. return 0;
  7844. }
  7845. #endif /* end sql only */
  7846. /*==========================================
  7847. * Show Monster DB Info v 1.0
  7848. * originally by [Lupus] eAthena
  7849. *------------------------------------------
  7850. */
  7851. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7852. {
  7853. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  7854. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  7855. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  7856. char atcmd_output2[200];
  7857. struct item_data *item_data;
  7858. struct mob_db *mob, *mob_array[MAX_SEARCH];
  7859. int count;
  7860. int i, j, k;
  7861. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7862. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  7863. if (!message || !*message) {
  7864. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  7865. return -1;
  7866. }
  7867. // If monster identifier/name argument is a name
  7868. if ((i = mobdb_checkid(atoi(message))))
  7869. {
  7870. mob_array[0] = mob_db(i);
  7871. count = 1;
  7872. } else
  7873. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  7874. if (!count) {
  7875. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  7876. return -1;
  7877. }
  7878. if (count > MAX_SEARCH) {
  7879. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  7880. clif_displaymessage(fd, atcmd_output);
  7881. count = MAX_SEARCH;
  7882. }
  7883. for (k = 0; k < count; k++) {
  7884. mob = mob_array[k];
  7885. // stats
  7886. if (mob->mexp)
  7887. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  7888. else
  7889. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  7890. clif_displaymessage(fd, atcmd_output);
  7891. 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);
  7892. clif_displaymessage(fd, atcmd_output);
  7893. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  7894. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  7895. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  7896. clif_displaymessage(fd, atcmd_output);
  7897. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  7898. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  7899. mob->range2 , mob->range3, msize[mob->status.size],
  7900. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  7901. clif_displaymessage(fd, atcmd_output);
  7902. // drops
  7903. clif_displaymessage(fd, " Drops:");
  7904. strcpy(atcmd_output, " ");
  7905. j = 0;
  7906. for (i = 0; i < MAX_MOB_DROP; i++) {
  7907. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  7908. continue;
  7909. if (item_data->slot)
  7910. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  7911. else
  7912. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  7913. strcat(atcmd_output, atcmd_output2);
  7914. if (++j % 3 == 0) {
  7915. clif_displaymessage(fd, atcmd_output);
  7916. strcpy(atcmd_output, " ");
  7917. }
  7918. }
  7919. if (j == 0)
  7920. clif_displaymessage(fd, "This monster has no drops.");
  7921. else if (j % 3 != 0)
  7922. clif_displaymessage(fd, atcmd_output);
  7923. // mvp
  7924. if (mob->mexp) {
  7925. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  7926. clif_displaymessage(fd, atcmd_output);
  7927. strcpy(atcmd_output, " MVP Items:");
  7928. j = 0;
  7929. for (i = 0; i < 3; i++) {
  7930. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  7931. continue;
  7932. if (mob->mvpitem[i].p > 0) {
  7933. j++;
  7934. if (j == 1)
  7935. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  7936. else
  7937. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  7938. strcat(atcmd_output, atcmd_output2);
  7939. }
  7940. }
  7941. if (j == 0)
  7942. clif_displaymessage(fd, "This monster has no MVP prizes.");
  7943. else
  7944. clif_displaymessage(fd, atcmd_output);
  7945. }
  7946. }
  7947. return 0;
  7948. }
  7949. /*=========================================
  7950. * @showmobs by KarLaeda
  7951. * => For 5 sec displays the mobs on minimap
  7952. *------------------------------------------
  7953. */
  7954. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  7955. {
  7956. struct map_session_data *sd;
  7957. if (!session[id] || (sd = session[id]->session_data) == NULL)
  7958. return 0;
  7959. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  7960. return 1;
  7961. }
  7962. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  7963. {
  7964. int mob_id,fd;
  7965. struct map_session_data* sd;
  7966. static int number=0;
  7967. struct mob_data *md;
  7968. if(!ap){
  7969. number=0;
  7970. return 0;
  7971. }
  7972. mob_id = va_arg(ap,int);
  7973. fd = va_arg(ap,int);
  7974. sd = va_arg(ap,struct map_session_data*);
  7975. md = (struct mob_data *)bl;
  7976. if(md->special_state.ai || md->master_id)
  7977. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  7978. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  7979. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  7980. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  7981. }
  7982. return 0;
  7983. }
  7984. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7985. {
  7986. char mob_name[100];
  7987. int mob_id,map_id = 0;
  7988. nullpo_retr(-1, sd);
  7989. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7990. return -1;
  7991. if ((mob_id = atoi(mob_name)) == 0)
  7992. mob_id = mobdb_searchname(mob_name);
  7993. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7994. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7995. clif_displaymessage(fd, atcmd_output);
  7996. return 0;
  7997. }
  7998. // Uncomment the following line to show mini-bosses & MVP.
  7999. //#define SHOW_MVP
  8000. #ifndef SHOW_MVP
  8001. if(mob_db(mob_id)->status.mode&MD_BOSS){
  8002. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  8003. clif_displaymessage(fd, atcmd_output);
  8004. return 0;
  8005. }
  8006. #endif
  8007. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  8008. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  8009. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  8010. map_id = sd->bl.m;
  8011. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  8012. mob_name, mapindex_id2name(sd->mapindex));
  8013. clif_displaymessage(fd, atcmd_output);
  8014. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  8015. atshowmobs_sub(&sd->bl,0);
  8016. return 0;
  8017. }
  8018. /*==========================================
  8019. * homunculus level up [orn]
  8020. *------------------------------------------
  8021. */
  8022. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8023. {
  8024. TBL_HOM * hd;
  8025. int level = 0, i = 0;
  8026. nullpo_retr(-1, sd);
  8027. if (!message || !*message)
  8028. return -1;
  8029. if ( !merc_is_hom_active(sd->hd) )
  8030. return 1 ;
  8031. level = atoi(message);
  8032. hd = sd->hd;
  8033. for (i = 1; i <= level && hd->exp_next; i++){
  8034. hd->homunculus.exp += hd->exp_next;
  8035. merc_hom_levelup(hd);
  8036. }
  8037. status_calc_homunculus(hd,0);
  8038. status_percent_heal(&hd->bl, 100, 100);
  8039. clif_misceffect2(&hd->bl,568);
  8040. return 0;
  8041. }
  8042. /*==========================================
  8043. * homunculus evolution H [orn]
  8044. *------------------------------------------
  8045. */
  8046. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8047. {
  8048. nullpo_retr(-1, sd);
  8049. if (sd->hd && sd->hd->homunculusDB->evo_class)
  8050. {
  8051. merc_hom_evolution(sd->hd) ;
  8052. }
  8053. return 0;
  8054. }
  8055. /*==========================================
  8056. * call choosen homunculus [orn]
  8057. *------------------------------------------
  8058. */
  8059. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8060. {
  8061. int homunid;
  8062. nullpo_retr(-1, sd);
  8063. if(sscanf(message, "%d", &homunid)<1)
  8064. return -1;
  8065. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  8066. return -1;
  8067. if(sd->status.hom_id == 0)
  8068. {
  8069. merc_create_homunculus_request(sd,homunid);
  8070. }
  8071. else
  8072. {
  8073. clif_displaymessage(fd,msg_txt(450));
  8074. }
  8075. return 0;
  8076. }
  8077. /*==========================================
  8078. * modify homunculus intimacy [orn]
  8079. *------------------------------------------
  8080. */
  8081. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8082. {
  8083. int friendly = 0;
  8084. nullpo_retr(-1, sd);
  8085. if (!message || !*message)
  8086. return -1;
  8087. friendly = atoi(message);
  8088. if (merc_is_hom_active(sd->hd)) {
  8089. if (friendly > 0 && friendly <= 1000) {
  8090. sd->hd->homunculus.intimacy = friendly * 100 ;
  8091. clif_send_homdata(sd,SP_INTIMATE,friendly);
  8092. } else {
  8093. return -1;
  8094. }
  8095. }
  8096. return 0;
  8097. }
  8098. /*==========================================
  8099. * modify homunculus hunger [orn]
  8100. *------------------------------------------
  8101. */
  8102. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8103. {
  8104. int hungry = 0;
  8105. nullpo_retr(-1, sd);
  8106. if (!message || !*message)
  8107. return -1;
  8108. hungry = atoi(message);
  8109. if (sd->status.hom_id > 0 && sd->hd) {
  8110. struct homun_data *hd = sd->hd;
  8111. if (hungry >= 0 && hungry <= 100) {
  8112. hd->homunculus.hunger = hungry;
  8113. clif_send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger);
  8114. } else {
  8115. return -1;
  8116. }
  8117. }
  8118. return 0;
  8119. }
  8120. /*==========================================
  8121. * make the homunculus speak [orn]
  8122. *------------------------------------------
  8123. */
  8124. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8125. {
  8126. char mes[100],temp[100];
  8127. nullpo_retr(-1, sd);
  8128. if(!merc_is_hom_active(sd->hd))
  8129. return -1;
  8130. if (sscanf(message, "%99[^\n]", mes) < 1)
  8131. return -1;
  8132. snprintf(temp, sizeof temp ,"%s : %s",sd->hd->homunculus.name,mes);
  8133. clif_message(&sd->hd->bl, temp);
  8134. return 0;
  8135. }
  8136. /*==========================================
  8137. * Show homunculus stats
  8138. *------------------------------------------
  8139. */
  8140. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8141. {
  8142. struct homun_data *hd;
  8143. struct status_data *status;
  8144. nullpo_retr(-1, sd);
  8145. if(!merc_is_hom_active(sd->hd))
  8146. return -1;
  8147. hd = sd->hd;
  8148. status = status_get_status_data(&hd->bl);
  8149. clif_displaymessage(fd, "Homunculus stats :");
  8150. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  8151. status->hp, status->max_hp, status->sp, status->max_sp);
  8152. clif_displaymessage(fd, atcmd_output);
  8153. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  8154. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  8155. clif_displaymessage(fd, atcmd_output);
  8156. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  8157. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  8158. clif_displaymessage(fd, atcmd_output);
  8159. snprintf(atcmd_output, sizeof(atcmd_output) ,
  8160. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  8161. status->str, status->agi, status->vit,
  8162. status->int_, status->dex, status->luk);
  8163. clif_displaymessage(fd, atcmd_output);
  8164. return 0;
  8165. }
  8166. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8167. {
  8168. struct homun_data *hd;
  8169. struct homunculus_db *db;
  8170. struct s_homunculus *hom;
  8171. int lv;
  8172. nullpo_retr(-1, sd);
  8173. if(!merc_is_hom_active(sd->hd))
  8174. return -1;
  8175. hd = sd->hd;
  8176. hom = &hd->homunculus;
  8177. db = hd->homunculusDB;
  8178. lv = hom->level;
  8179. snprintf(atcmd_output, sizeof(atcmd_output) ,
  8180. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  8181. clif_displaymessage(fd, atcmd_output);
  8182. lv--; //Since the first increase is at level 2.
  8183. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)",
  8184. hom->max_hp, db->basemaxHP +lv*db->gminHP, db->basemaxHP +lv*db->gmaxHP);
  8185. clif_displaymessage(fd, atcmd_output);
  8186. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)",
  8187. hom->max_sp, db->basemaxSP +lv*db->gminSP, db->basemaxSP +lv*db->gmaxSP);
  8188. clif_displaymessage(fd, atcmd_output);
  8189. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)",
  8190. hom->str/10, db->baseSTR +lv*(db->gminSTR/10), db->baseSTR +lv*(db->gmaxSTR/10));
  8191. clif_displaymessage(fd, atcmd_output);
  8192. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)",
  8193. hom->agi/10, db->baseAGI +lv*(db->gminAGI/10), db->baseAGI +lv*(db->gmaxAGI/10));
  8194. clif_displaymessage(fd, atcmd_output);
  8195. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)",
  8196. hom->vit/10, db->baseVIT +lv*(db->gminVIT/10), db->baseVIT +lv*(db->gmaxVIT/10));
  8197. clif_displaymessage(fd, atcmd_output);
  8198. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)",
  8199. hom->int_/10, db->baseINT +lv*(db->gminINT/10), db->baseINT +lv*(db->gmaxINT/10));
  8200. clif_displaymessage(fd, atcmd_output);
  8201. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)",
  8202. hom->dex/10, db->baseDEX +lv*(db->gminDEX/10), db->baseDEX +lv*(db->gmaxDEX/10));
  8203. clif_displaymessage(fd, atcmd_output);
  8204. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)",
  8205. hom->luk/10, db->baseLUK +lv*(db->gminLUK/10), db->baseLUK +lv*(db->gmaxLUK/10));
  8206. clif_displaymessage(fd, atcmd_output);
  8207. return 0;
  8208. }
  8209. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8210. {
  8211. struct homun_data *hd;
  8212. int lv, i, skillpts;
  8213. unsigned int exp;
  8214. struct skill b_skill;
  8215. TBL_PC* tsd = sd;
  8216. nullpo_retr(-1, sd);
  8217. if ((!message || !*message) && !sd->hd)
  8218. {
  8219. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  8220. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  8221. return -1;
  8222. }
  8223. if (message && *message) {
  8224. tsd = map_nick2sd((char*)message);
  8225. if (!tsd) {
  8226. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8227. return -1;
  8228. }
  8229. if (pc_isGM(tsd) > pc_isGM(sd)) {
  8230. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8231. return -1;
  8232. }
  8233. }
  8234. hd = tsd->hd;
  8235. if(!merc_is_hom_active(hd))
  8236. return -1;
  8237. lv = hd->homunculus.level;
  8238. exp = hd->homunculus.exp;
  8239. memcpy(&b_skill, &hd->homunculus.hskill, sizeof(b_skill));
  8240. skillpts = hd->homunculus.skillpts;
  8241. //Reset values to level 1.
  8242. merc_reset_stats(hd);
  8243. //Level it back up
  8244. for (i = 1; i < lv && hd->exp_next; i++){
  8245. hd->homunculus.exp += hd->exp_next;
  8246. merc_hom_levelup(hd);
  8247. }
  8248. hd->homunculus.exp = exp;
  8249. memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill));
  8250. hd->homunculus.skillpts = skillpts;
  8251. status_calc_homunculus(hd,0);
  8252. status_percent_heal(&hd->bl, 100, 100);
  8253. clif_misceffect2(&hd->bl,568);
  8254. clif_displaymessage(fd, "Homunculus stats altered");
  8255. //Print out the new stats
  8256. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  8257. atcommand_homstats(fd, tsd, command, message);
  8258. return 0;
  8259. }
  8260. /*==========================================
  8261. * Show Items DB Info v 1.0
  8262. * originally by [Lupus] eAthena
  8263. *------------------------------------------
  8264. */
  8265. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8266. {
  8267. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8268. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8269. struct item_data *item_data, *item_array[MAX_SEARCH];
  8270. int i, count = 1;
  8271. if (!message || !*message) {
  8272. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8273. return -1;
  8274. }
  8275. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8276. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8277. if (!count) {
  8278. clif_displaymessage(fd, "Item not found.");
  8279. return -1;
  8280. }
  8281. if (count > MAX_SEARCH) {
  8282. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8283. clif_displaymessage(fd, atcmd_output);
  8284. count = MAX_SEARCH;
  8285. }
  8286. for (i = 0; i < count; i++) {
  8287. item_data = item_array[i];
  8288. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8289. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  8290. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8291. (item_data->script==NULL)? "None" : "With script"
  8292. );
  8293. clif_displaymessage(fd, atcmd_output);
  8294. 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. );
  8295. clif_displaymessage(fd, atcmd_output);
  8296. if (item_data->maxchance == 10000)
  8297. strcpy(atcmd_output, " - Available in the shops only");
  8298. else if (item_data->maxchance)
  8299. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8300. else
  8301. strcpy(atcmd_output, " - Monsters don't drop this item");
  8302. clif_displaymessage(fd, atcmd_output);
  8303. }
  8304. return 0;
  8305. }
  8306. /*==========================================
  8307. * Show who drops the item.
  8308. *------------------------------------------
  8309. */
  8310. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8311. {
  8312. struct item_data *item_data, *item_array[MAX_SEARCH];
  8313. int i,j, count = 1;
  8314. if (!message || !*message) {
  8315. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8316. return -1;
  8317. }
  8318. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8319. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8320. if (!count) {
  8321. clif_displaymessage(fd, "Item not found.");
  8322. return -1;
  8323. }
  8324. if (count > MAX_SEARCH) {
  8325. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8326. clif_displaymessage(fd, atcmd_output);
  8327. count = MAX_SEARCH;
  8328. }
  8329. for (i = 0; i < count; i++) {
  8330. item_data = item_array[i];
  8331. sprintf(atcmd_output, "Item: '%s'[%d]",
  8332. item_data->jname,item_data->slot);
  8333. clif_displaymessage(fd, atcmd_output);
  8334. if (item_data->mob[0].chance == 0) {
  8335. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8336. clif_displaymessage(fd, atcmd_output);
  8337. } else {
  8338. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8339. clif_displaymessage(fd, atcmd_output);
  8340. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8341. {
  8342. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8343. clif_displaymessage(fd, atcmd_output);
  8344. }
  8345. }
  8346. }
  8347. return 0;
  8348. }
  8349. /*==========================================
  8350. * @adopt by [Veider]
  8351. *
  8352. * adopt a novice
  8353. *------------------------------------------
  8354. */
  8355. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8356. {
  8357. struct map_session_data *pl_sd1 = NULL;
  8358. struct map_session_data *pl_sd2 = NULL;
  8359. struct map_session_data *pl_sd3 = NULL;
  8360. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8361. nullpo_retr(-1, sd);
  8362. if (!message || !*message)
  8363. return -1;
  8364. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8365. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8366. return -1;
  8367. }
  8368. if (battle_config.etc_log)
  8369. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8370. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8371. sprintf(player2, "Cannot find player %s online", player1);
  8372. clif_displaymessage(fd, player2);
  8373. return -1;
  8374. }
  8375. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8376. sprintf(player1, "Cannot find player %s online", player2);
  8377. clif_displaymessage(fd, player1);
  8378. return -1;
  8379. }
  8380. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8381. sprintf(player1, "Cannot find player %s online", player3);
  8382. clif_displaymessage(fd, player1);
  8383. return -1;
  8384. }
  8385. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8386. clif_displaymessage(fd, "They are too young to be parents!");
  8387. return -1;
  8388. }
  8389. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8390. clif_displaymessage(fd, "They are family.. wish them luck");
  8391. return 0;
  8392. }
  8393. else
  8394. return -1;
  8395. }
  8396. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8397. {
  8398. const char * revision;
  8399. if ((revision = get_svn_revision()) != 0) {
  8400. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8401. clif_displaymessage(fd,atcmd_output);
  8402. } else
  8403. clif_displaymessage(fd,"Cannot determine SVN revision");
  8404. return 0;
  8405. }
  8406. /*==========================================
  8407. * @mutearea by MouseJstr
  8408. *------------------------------------------
  8409. */
  8410. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8411. {
  8412. int time, id;
  8413. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8414. if (pl_sd == NULL)
  8415. return 0;
  8416. id = va_arg(ap, int);
  8417. time = va_arg(ap, int);
  8418. if (id != bl->id && !pc_isGM(pl_sd)) {
  8419. pl_sd->status.manner -= time;
  8420. if (pl_sd->status.manner < 0)
  8421. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8422. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8423. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8424. }
  8425. return 0;
  8426. }
  8427. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8428. {
  8429. int time;
  8430. nullpo_retr(0, sd);
  8431. time = atoi(message);
  8432. if (!time)
  8433. time = 15; // 15 minutes default
  8434. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8435. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8436. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8437. return 0;
  8438. }
  8439. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8440. {
  8441. char buf[255];
  8442. nullpo_retr(0, sd);
  8443. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8444. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8445. clif_displaymessage(fd, buf);
  8446. return 0;
  8447. }
  8448. /*==========================================
  8449. * @me by lordalfa
  8450. * => Displays the OUTPUT string on top of the Visible players Heads.
  8451. *------------------------------------------
  8452. */
  8453. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8454. {
  8455. char tempmes[200];
  8456. nullpo_retr(-1, sd);
  8457. memset(tempmes, '\0', sizeof(tempmes));
  8458. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8459. if (sd->sc.count && //no "chatting" while muted.
  8460. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  8461. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  8462. return -1;
  8463. if (!message || !*message) {
  8464. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8465. return -1;
  8466. }
  8467. sscanf(message, "%199[^\n]", tempmes);
  8468. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8469. clif_disp_overhead(sd, atcmd_output);
  8470. return 0;
  8471. }
  8472. /*==========================================
  8473. * @size
  8474. * => Resize your character sprite. [Valaris]
  8475. *------------------------------------------
  8476. */
  8477. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8478. {
  8479. int size=0;
  8480. nullpo_retr(-1, sd);
  8481. if (!message || !*message)
  8482. return -1;
  8483. if (sscanf(message,"%d", &size) < 1)
  8484. return -1;
  8485. if(sd->state.size) {
  8486. sd->state.size=0;
  8487. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8488. }
  8489. if(size==1) {
  8490. sd->state.size=1;
  8491. clif_specialeffect(&sd->bl,420,AREA);
  8492. } else if(size==2) {
  8493. sd->state.size=2;
  8494. clif_specialeffect(&sd->bl,422,AREA);
  8495. }
  8496. return 0;
  8497. }
  8498. /*==========================================
  8499. * @monsterignore
  8500. * => Makes monsters ignore you. [Valaris]
  8501. *------------------------------------------
  8502. */
  8503. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8504. {
  8505. nullpo_retr(-1, sd);
  8506. if (!sd->state.monster_ignore) {
  8507. sd->state.monster_ignore = 1;
  8508. clif_displaymessage(sd->fd, "You are now inmune to attacks.");
  8509. } else {
  8510. sd->state.monster_ignore = 0;
  8511. clif_displaymessage(sd->fd, "Returned to normal state.");
  8512. }
  8513. return 0;
  8514. }
  8515. /*==========================================
  8516. * @fakename
  8517. * => Gives your character a fake name. [Valaris]
  8518. *------------------------------------------
  8519. */
  8520. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8521. {
  8522. char name[NAME_LENGTH];
  8523. nullpo_retr(-1, sd);
  8524. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8525. sd->fakename[0]='\0';
  8526. clif_charnameack(0, &sd->bl);
  8527. clif_displaymessage(sd->fd,"Returned to real name.");
  8528. return 0;
  8529. }
  8530. if (!message || !*message) {
  8531. clif_displaymessage(sd->fd,"You must enter a name.");
  8532. return 0;
  8533. }
  8534. if (sscanf(message, "%23[^\n]", name) < 1) {
  8535. return 0;
  8536. }
  8537. if(strlen(name) < 2) {
  8538. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8539. return 0;
  8540. }
  8541. memcpy(sd->fakename,name,NAME_LENGTH);
  8542. sd->fakename[NAME_LENGTH-1] = '\0';
  8543. clif_charnameack(0, &sd->bl);
  8544. clif_displaymessage(sd->fd,"Fake name enabled.");
  8545. return 0;
  8546. }
  8547. /*==========================================
  8548. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  8549. * => Shows information about the map flags [map name]
  8550. * Also set flags
  8551. *------------------------------------------
  8552. */
  8553. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8554. {
  8555. // WIP
  8556. return 0;
  8557. }
  8558. /*===================================
  8559. * Remove some messages
  8560. *-----------------------------------
  8561. */
  8562. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8563. {
  8564. if (sd->state.showexp) {
  8565. sd->state.showexp = 0;
  8566. clif_displaymessage(fd, "Gained exp will not be shown.");
  8567. return 0;
  8568. }
  8569. sd->state.showexp = 1;
  8570. clif_displaymessage(fd, "Gained exp is now shown");
  8571. return 0;
  8572. }
  8573. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8574. {
  8575. if (sd->state.showzeny) {
  8576. sd->state.showzeny = 0;
  8577. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8578. return 0;
  8579. }
  8580. sd->state.showzeny = 1;
  8581. clif_displaymessage(fd, "Gained zeny is now shown");
  8582. return 0;
  8583. }
  8584. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8585. {
  8586. if (sd->state.showdelay) {
  8587. sd->state.showdelay = 0;
  8588. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8589. return 0;
  8590. }
  8591. sd->state.showdelay = 1;
  8592. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8593. return 0;
  8594. }
  8595. /*==========================================
  8596. * Duel organizing functions [LuzZza]
  8597. *
  8598. * @duel [limit|nick] - create a duel
  8599. * @invite <nick> - invite player
  8600. * @accept - accept invitation
  8601. * @reject - reject invitation
  8602. * @leave - leave duel
  8603. *------------------------------------------
  8604. */
  8605. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8606. {
  8607. unsigned int did = sd->duel_group;
  8608. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8609. if(did <= 0) {
  8610. // "Duel: @invite without @duel."
  8611. clif_displaymessage(fd, msg_txt(350));
  8612. return 0;
  8613. }
  8614. if(duel_list[did].max_players_limit > 0 &&
  8615. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8616. // "Duel: Limit of players is reached."
  8617. clif_displaymessage(fd, msg_txt(351));
  8618. return 0;
  8619. }
  8620. if(target_sd == NULL) {
  8621. // "Duel: Player not found."
  8622. clif_displaymessage(fd, msg_txt(352));
  8623. return 0;
  8624. }
  8625. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8626. // "Duel: Player already in duel."
  8627. clif_displaymessage(fd, msg_txt(353));
  8628. return 0;
  8629. }
  8630. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  8631. {
  8632. sprintf(atcmd_output, msg_txt(364), message);
  8633. clif_displaymessage(fd, atcmd_output);
  8634. return 0;
  8635. }
  8636. duel_invite(did, sd, target_sd);
  8637. // "Duel: Invitation has been sent."
  8638. clif_displaymessage(fd, msg_txt(354));
  8639. return 0;
  8640. }
  8641. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8642. {
  8643. char output[256];
  8644. unsigned int maxpl=0, newduel;
  8645. struct map_session_data *target_sd;
  8646. /* // Commnted because it can be disabled in at-comms conf.
  8647. if(!battle_config.duel_enable) {
  8648. clif_displaymessage(fd, "Duel: duel is disable.");
  8649. return 0;
  8650. }
  8651. */
  8652. if(sd->duel_group > 0) {
  8653. duel_showinfo(sd->duel_group, sd);
  8654. return 0;
  8655. }
  8656. if(sd->duel_invite > 0) {
  8657. // "Duel: @duel without @reject."
  8658. clif_displaymessage(fd, msg_txt(355));
  8659. return 0;
  8660. }
  8661. if(!duel_checktime(sd)) {
  8662. // "Duel: You can take part in duel only one time per %d minutes."
  8663. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8664. clif_displaymessage(fd, output);
  8665. return 0;
  8666. }
  8667. if(strlen(message) > 0) {
  8668. if(sscanf(message, "%d", &maxpl) >= 1) {
  8669. if(maxpl < 2 || maxpl > 65535) {
  8670. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8671. return 0;
  8672. }
  8673. duel_create(sd, maxpl);
  8674. } else {
  8675. target_sd = map_nick2sd((char *)message);
  8676. if(target_sd != NULL) {
  8677. if((newduel = duel_create(sd, 2)) != -1) {
  8678. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8679. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8680. return 0;
  8681. }
  8682. duel_invite(newduel, sd, target_sd);
  8683. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8684. }
  8685. } else {
  8686. // "Duel: Player not found."
  8687. clif_displaymessage(fd, msg_txt(352));
  8688. return 0;
  8689. }
  8690. }
  8691. } else
  8692. duel_create(sd, 0);
  8693. return 0;
  8694. }
  8695. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8696. {
  8697. if(sd->duel_group <= 0) {
  8698. // "Duel: @leave without @duel."
  8699. clif_displaymessage(fd, msg_txt(358));
  8700. return 0;
  8701. }
  8702. duel_leave(sd->duel_group, sd);
  8703. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8704. return 0;
  8705. }
  8706. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8707. {
  8708. char output[256];
  8709. if(!duel_checktime(sd)) {
  8710. // "Duel: You can take part in duel only one time per %d minutes."
  8711. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8712. clif_displaymessage(fd, output);
  8713. return 0;
  8714. }
  8715. if(sd->duel_invite <= 0) {
  8716. // "Duel: @accept without invititation."
  8717. clif_displaymessage(fd, msg_txt(360));
  8718. return 0;
  8719. }
  8720. duel_accept(sd->duel_invite, sd);
  8721. // "Duel: Invitation has been accepted."
  8722. clif_displaymessage(fd, msg_txt(361));
  8723. return 0;
  8724. }
  8725. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8726. {
  8727. if(sd->duel_invite <= 0) {
  8728. // "Duel: @reject without invititation."
  8729. clif_displaymessage(fd, msg_txt(362));
  8730. return 0;
  8731. }
  8732. duel_reject(sd->duel_invite, sd);
  8733. // "Duel: Invitation has been rejected."
  8734. clif_displaymessage(fd, msg_txt(363));
  8735. return 0;
  8736. }
  8737. /*===================================
  8738. * Away message (@away, @aw) [LuzZza]
  8739. *-----------------------------------
  8740. */
  8741. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8742. {
  8743. if(strlen(message) > 0) {
  8744. if(strlen(message) > 128)
  8745. return -1;
  8746. strcpy(sd->away_message, message);
  8747. //"Away automessage has been activated."
  8748. clif_displaymessage(fd, msg_txt(546));
  8749. } else {
  8750. if(strlen(sd->away_message) > 0) {
  8751. sd->away_message[0] = 0;
  8752. //"Away automessage has been disabled."
  8753. clif_displaymessage(fd, msg_txt(547));
  8754. return 0;
  8755. }
  8756. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8757. clif_displaymessage(fd, msg_txt(548));
  8758. }
  8759. return 0;
  8760. }
  8761. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8762. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8763. {
  8764. int x=0,y=0,flag=0,master=0,i=0;
  8765. struct map_session_data *pl_sd=NULL;
  8766. if (!message || !*message) {
  8767. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8768. return 0;
  8769. }
  8770. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8771. clif_displaymessage(fd, msg_txt(3));
  8772. return 0;
  8773. }
  8774. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8775. clif_displaymessage(fd, msg_txt(126));
  8776. return 0;
  8777. }
  8778. if (strcmpi(command, "@clone") == 0)
  8779. flag = 1;
  8780. else if (strcmpi(command, "@slaveclone") == 0) {
  8781. flag = 2;
  8782. master = sd->bl.id;
  8783. if (battle_config.atc_slave_clone_limit
  8784. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8785. clif_displaymessage(fd, msg_txt(127));
  8786. return 0;
  8787. }
  8788. }
  8789. do {
  8790. x = sd->bl.x + (rand() % 10 - 5);
  8791. y = sd->bl.y + (rand() % 10 - 5);
  8792. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8793. if (i >= 10) {
  8794. x = sd->bl.x;
  8795. y = sd->bl.y;
  8796. }
  8797. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8798. clif_displaymessage(fd, msg_txt(128+flag*2));
  8799. return 0;
  8800. }
  8801. clif_displaymessage(fd, msg_txt(129+flag*2));
  8802. return 0;
  8803. }
  8804. /*===================================
  8805. * Main chat [LuzZza]
  8806. * Usage: @main <on|off|message>
  8807. *-----------------------------------
  8808. */
  8809. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8810. {
  8811. if(strlen(message) > 0) {
  8812. if(strcmpi(message, "on") == 0) {
  8813. if(!sd->state.mainchat) {
  8814. sd->state.mainchat = 1;
  8815. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8816. } else {
  8817. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8818. }
  8819. } else if(strcmpi(message, "off") == 0) {
  8820. if(sd->state.mainchat) {
  8821. sd->state.mainchat = 0;
  8822. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8823. } else {
  8824. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8825. }
  8826. } else {
  8827. if(!sd->state.mainchat) {
  8828. sd->state.mainchat = 1;
  8829. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8830. }
  8831. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  8832. clif_displaymessage(fd, msg_txt(387));
  8833. return -1;
  8834. }
  8835. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8836. // I use 0xFE000000 color for signalizing that this message is
  8837. // main chat message. 0xFE000000 is invalid color, same using
  8838. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8839. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8840. }
  8841. } else {
  8842. if(sd->state.mainchat)
  8843. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8844. clif_displaymessage(fd, msg_txt(384));
  8845. else
  8846. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8847. clif_displaymessage(fd, msg_txt(385));
  8848. }
  8849. return 0;
  8850. }
  8851. /*=====================================
  8852. * Autorejecting Invites/Deals [LuzZza]
  8853. * Usage: @noask
  8854. *-------------------------------------
  8855. */
  8856. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8857. {
  8858. if(sd->state.noask) {
  8859. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  8860. sd->state.noask = 0;
  8861. } else {
  8862. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  8863. sd->state.noask = 1;
  8864. }
  8865. return 0;
  8866. }
  8867. /*=====================================
  8868. * Send a @request message to all GMs of lowest_gm_level.
  8869. * Usage: @request <petition>
  8870. *-------------------------------------
  8871. */
  8872. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8873. {
  8874. if (!message || !*message) {
  8875. clif_displaymessage(sd->fd,msg_txt(277));
  8876. return -1;
  8877. }
  8878. sprintf(atcmd_output, msg_txt(278), message);
  8879. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  8880. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  8881. clif_displaymessage(sd->fd,msg_txt(279));
  8882. return 0;
  8883. }
  8884. void do_init_atcommand()
  8885. {
  8886. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8887. duel_count = 0;
  8888. memset(&duel_list[0], 0, sizeof(duel_list));
  8889. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  8890. return;
  8891. }
  8892. void do_final_atcommand()
  8893. {
  8894. users_db->destroy(users_db,NULL);
  8895. }