atcommand.c 317 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270
  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 "pet.h"
  28. #include "mercenary.h" //[orn]
  29. #include "battle.h"
  30. #include "party.h"
  31. #include "guild.h"
  32. #include "script.h"
  33. #include "npc.h"
  34. #include "trade.h"
  35. #include "unit.h"
  36. #ifndef TXT_ONLY
  37. #include "mail.h"
  38. #endif
  39. char atcommand_symbol = '@'; // first char of the commands (by [Yor])
  40. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  41. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  42. ACMD_FUNC(broadcast);
  43. ACMD_FUNC(localbroadcast);
  44. ACMD_FUNC(rura);
  45. ACMD_FUNC(where);
  46. ACMD_FUNC(jumpto);
  47. ACMD_FUNC(jump);
  48. ACMD_FUNC(who);
  49. ACMD_FUNC(who2);
  50. ACMD_FUNC(who3);
  51. ACMD_FUNC(whomap);
  52. ACMD_FUNC(whomap2);
  53. ACMD_FUNC(whomap3);
  54. ACMD_FUNC(whogm); // by Yor
  55. ACMD_FUNC(whozeny); // [Valaris]
  56. ACMD_FUNC(save);
  57. ACMD_FUNC(load);
  58. ACMD_FUNC(speed);
  59. ACMD_FUNC(charspeed);
  60. ACMD_FUNC(storage);
  61. ACMD_FUNC(guildstorage);
  62. ACMD_FUNC(option);
  63. ACMD_FUNC(hide);
  64. ACMD_FUNC(jobchange);
  65. ACMD_FUNC(die);
  66. ACMD_FUNC(kill);
  67. ACMD_FUNC(alive);
  68. ACMD_FUNC(kami);
  69. ACMD_FUNC(heal);
  70. ACMD_FUNC(item);
  71. ACMD_FUNC(item2);
  72. ACMD_FUNC(itemreset);
  73. ACMD_FUNC(baselevelup);
  74. ACMD_FUNC(joblevelup);
  75. ACMD_FUNC(help);
  76. ACMD_FUNC(help2);
  77. ACMD_FUNC(gm);
  78. ACMD_FUNC(pvpoff);
  79. ACMD_FUNC(pvpon);
  80. ACMD_FUNC(gvgoff);
  81. ACMD_FUNC(gvgon);
  82. ACMD_FUNC(model);
  83. ACMD_FUNC(go);
  84. ACMD_FUNC(monster);
  85. ACMD_FUNC(monstersmall);
  86. ACMD_FUNC(monsterbig);
  87. ACMD_FUNC(spawn);
  88. ACMD_FUNC(killmonster);
  89. ACMD_FUNC(killmonster2);
  90. ACMD_FUNC(refine);
  91. ACMD_FUNC(produce);
  92. ACMD_FUNC(memo);
  93. ACMD_FUNC(gat);
  94. ACMD_FUNC(packet);
  95. ACMD_FUNC(waterlevel);
  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_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  371. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  372. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  373. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  374. { AtCommand_Strength, "@str", 60, atcommand_param },
  375. { AtCommand_Agility, "@agi", 60, atcommand_param },
  376. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  377. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  378. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  379. { AtCommand_Luck, "@luk", 60, atcommand_param },
  380. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  381. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  382. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  383. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  384. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  385. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  386. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  387. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  388. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  389. { AtCommand_Night, "@night", 80, atcommand_night },
  390. { AtCommand_Day, "@day", 80, atcommand_day },
  391. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  392. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  393. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  394. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  395. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  396. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  397. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  398. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  399. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  400. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  401. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  402. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  403. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  404. { AtCommand_Party, "@party", 1, atcommand_party },
  405. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  406. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  407. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  408. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  409. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  410. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  411. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  412. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  413. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  414. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  415. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  416. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  417. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  418. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  419. { AtCommand_ReloadBattleConf, "@reloadbattleconf",99, atcommand_reloadbattleconf },
  420. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  421. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  422. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  423. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  424. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  425. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  426. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  427. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  428. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  429. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  430. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  431. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  432. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  433. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  434. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  435. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  436. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  437. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  438. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  439. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  440. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  441. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  442. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  443. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  444. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  445. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  446. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  447. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  448. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  449. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  450. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  451. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  452. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  453. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  454. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  455. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  456. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  457. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  458. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  459. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  460. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  461. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  462. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  463. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  464. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  465. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  466. { AtCommand_JailFor, "@jailfor", 60, atcommand_jailfor }, //Meruru
  467. { AtCommand_JailTime, "@jailtime", 1, atcommand_jailtime },
  468. { AtCommand_CharJailTime, "@charjailtime", 60, atcommand_charjailtime },
  469. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  470. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  471. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  472. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  473. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  474. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  475. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  476. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  477. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  478. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  479. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  480. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  481. { AtCommand_NpcMove, "@npcmove", 80, atcommand_npcmove }, // by MouseJstr
  482. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  483. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  484. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  485. { AtCommand_Chardropall, "@chardropall", 60, atcommand_chardropall }, // MouseJstr
  486. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  487. { AtCommand_Charstoreall, "@charstoreall", 60, atcommand_charstoreall }, // MouseJstr
  488. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  489. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  490. // { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
  491. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  492. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  493. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  494. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  495. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  496. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  497. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  498. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  499. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  500. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  501. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  502. { AtCommand_Send, "@send", 99, atcommand_send },
  503. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  504. { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
  505. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  506. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  507. { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri
  508. { AtCommand_Mute, "@mute", 80, atcommand_mute }, // [celest]
  509. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  510. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  511. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  512. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  513. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  514. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  515. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  516. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  517. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  518. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  519. { AtCommand_Users, "@users", 40, atcommand_users },
  520. { AtCommand_ResetState, "@reset", 40, atcommand_reset },
  521. #ifndef TXT_ONLY // sql-only commands
  522. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  523. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  524. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  525. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  526. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  527. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  528. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  529. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  530. #endif /* TXT_ONLY */
  531. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  532. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  533. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  534. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  535. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  536. #ifdef DMALLOC
  537. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  538. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  539. #endif
  540. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  541. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  542. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  543. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  544. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  545. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  546. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  547. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  548. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  549. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  550. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  551. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  552. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  553. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  554. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  555. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  556. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  557. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  558. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  559. { AtCommand_ChangeLook, "@changelook", 60, atcommand_changelook },
  560. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  561. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  562. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  563. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  564. { AtCommand_Exp, "@exp", 1, atcommand_exp }, // [Skotlex]
  565. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  566. { AtCommand_Version, "@version", 1, atcommand_version },
  567. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  568. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  569. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  570. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  571. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  572. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  573. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  574. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  575. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  576. { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
  577. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  578. { AtCommand_Size, "@size", 20, atcommand_size },
  579. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  580. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  581. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  582. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  583. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  584. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  585. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  586. { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
  587. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  588. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  589. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  590. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  591. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  592. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  593. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  594. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  595. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  596. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  597. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  598. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  599. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  600. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  601. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  602. { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
  603. { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
  604. { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
  605. { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
  606. { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
  607. { AtCommand_HomTalk, "@homtalk", 10, atcommand_homtalk },
  608. { AtCommand_HomInfo, "@hominfo", 1, atcommand_hominfo },
  609. { AtCommand_HomStats, "@homstats", 1, atcommand_homstats },
  610. { AtCommand_HomShuffle, "@homshuffle", 60, atcommand_homshuffle },
  611. { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
  612. // add new commands before this line
  613. { AtCommand_Unknown, NULL, 1, NULL }
  614. };
  615. /*=========================================
  616. * Generic variables
  617. *-----------------------------------------
  618. */
  619. char atcmd_output[200];
  620. char atcmd_player_name[100];
  621. char atcmd_temp[100];
  622. /*==========================================
  623. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  624. *------------------------------------------
  625. */
  626. char *estr_lower(char *str)
  627. {
  628. int i;
  629. for (i=0; str[i]; i++)
  630. if ((str[i] >= 65) && (str[i] <= 90))
  631. str[i] += 32;
  632. return str;
  633. }
  634. // compare function for sorting high to lowest
  635. int hightolow_compare (const void * a, const void * b)
  636. {
  637. return ( *(int*)b - *(int*)a );
  638. }
  639. // compare function for sorting lowest to highest
  640. int lowtohigh_compare (const void * a, const void * b)
  641. {
  642. return ( *(int*)a - *(int*)b );
  643. }
  644. //-----------------------------------------------------------
  645. // Return the message string of the specified number by [Yor]
  646. //-----------------------------------------------------------
  647. char * msg_txt(int msg_number)
  648. {
  649. if (msg_number >= 0 && msg_number < MAX_MSG &&
  650. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  651. return msg_table[msg_number];
  652. return "??";
  653. }
  654. //-----------------------------------------------------------
  655. // Returns Players title (from msg_athena.conf) [Lupus]
  656. //-----------------------------------------------------------
  657. char * player_title_txt(int level) {
  658. if (level < battle_config.title_lvl1)
  659. return ""; //w/o any titles
  660. if (level >= battle_config.title_lvl8)
  661. sprintf(atcmd_temp, msg_txt(332), level);
  662. else
  663. if (level >= battle_config.title_lvl7)
  664. sprintf(atcmd_temp, msg_txt(331), level);
  665. else
  666. if (level >= battle_config.title_lvl6)
  667. sprintf(atcmd_temp, msg_txt(330), level);
  668. else
  669. if (level >= battle_config.title_lvl5)
  670. sprintf(atcmd_temp, msg_txt(329), level);
  671. else
  672. if (level >= battle_config.title_lvl4)
  673. sprintf(atcmd_temp, msg_txt(328), level);
  674. else
  675. if (level >= battle_config.title_lvl3)
  676. sprintf(atcmd_temp, msg_txt(327), level);
  677. else
  678. if (level >= battle_config.title_lvl2)
  679. sprintf(atcmd_temp, msg_txt(326), level);
  680. else
  681. sprintf(atcmd_temp, msg_txt(325), level); //lvl1
  682. return atcmd_temp;
  683. }
  684. //------------------------------------------------------------
  685. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  686. //------------------------------------------------------------
  687. int e_mail_check(char *email)
  688. {
  689. char ch;
  690. char* last_arobas;
  691. // athena limits
  692. if (strlen(email) < 3 || strlen(email) > 39)
  693. return 0;
  694. // part of RFC limits (official reference of e-mail description)
  695. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  696. return 0;
  697. if (email[strlen(email)-1] == '.')
  698. return 0;
  699. last_arobas = strrchr(email, '@');
  700. if (strstr(last_arobas, "@.") != NULL ||
  701. strstr(last_arobas, "..") != NULL)
  702. return 0;
  703. for(ch = 1; ch < 32; ch++) {
  704. if (strchr(last_arobas, ch) != NULL) {
  705. return 0;
  706. break;
  707. }
  708. }
  709. if (strchr(last_arobas, ' ') != NULL ||
  710. strchr(last_arobas, ';') != NULL)
  711. return 0;
  712. // all correct
  713. return 1;
  714. }
  715. /*==========================================
  716. * Retrieve the atcommand's required gm level
  717. *------------------------------------------
  718. */
  719. int get_atcommand_level(const AtCommandType type)
  720. {
  721. int i;
  722. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  723. if (atcommand_info[i].type == type)
  724. return atcommand_info[i].level;
  725. return 100; // 100: command can not be used
  726. }
  727. AtCommandType is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  728. {
  729. AtCommandInfo info;
  730. AtCommandType type;
  731. memset(&info, 0, sizeof(info));
  732. type = atcommand(sd, gmlvl, str, &info);
  733. if (type != AtCommand_None) {
  734. char command[100];
  735. const char* p = str;
  736. if (map[sd->bl.m].nocommand &&
  737. gmlvl < map[sd->bl.m].nocommand)
  738. { //Command not allowed on this map.
  739. sprintf(atcmd_output, msg_txt(143));
  740. clif_displaymessage(fd, atcmd_output);
  741. return AtCommand_None;
  742. }
  743. memset(command, '\0', sizeof(command));
  744. memset(atcmd_output, '\0', sizeof(atcmd_output));
  745. while (*p && !isspace(*p))
  746. p++;
  747. if (p - str >= sizeof(command)) // too long
  748. return AtCommand_Unknown;
  749. strncpy(command, str, p - str);
  750. while (isspace(*p))
  751. p++;
  752. if (type == AtCommand_Unknown || info.proc == NULL) {
  753. sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
  754. clif_displaymessage(fd, atcmd_output);
  755. } else {
  756. if (info.proc(fd, sd, command, p) != 0) {
  757. // Command can not be executed
  758. sprintf(atcmd_output, msg_txt(154), command); // %s failed.
  759. clif_displaymessage(fd, atcmd_output);
  760. }
  761. }
  762. return info.type;
  763. }
  764. return AtCommand_None;
  765. }
  766. /*==========================================
  767. *
  768. *------------------------------------------
  769. */
  770. AtCommandType is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  771. {
  772. const char* str = message;
  773. int s_flag = 0;
  774. nullpo_retr(AtCommand_None, sd);
  775. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
  776. return AtCommand_Unknown;
  777. }
  778. if (!message || !*message)
  779. return AtCommand_None;
  780. str += strlen(sd->status.name);
  781. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  782. if (*str == ':')
  783. s_flag = 1;
  784. str++;
  785. }
  786. if (!*str)
  787. return AtCommand_None;
  788. if(str[0] == '|' && strlen(str) >= 4 && str[3] == atcommand_symbol)
  789. str += 3; // skip 10/11-langtype's codepage indicator, if detected
  790. return is_atcommand_sub(fd,sd,str,pc_isGM(sd));
  791. }
  792. /*==========================================
  793. *
  794. *------------------------------------------
  795. */
  796. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info)
  797. {
  798. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  799. if (!info)
  800. return AtCommand_None;
  801. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  802. return AtCommand_None;
  803. if (!p || !*p) {
  804. ShowError("at command message is empty\n");
  805. return AtCommand_None;
  806. }
  807. if (*p == atcommand_symbol) { // check first char
  808. char command[101];
  809. int i = 0;
  810. memset(info, 0, sizeof(AtCommandInfo));
  811. sscanf(p, "%100s", command);
  812. command[sizeof(command)-1] = '\0';
  813. while (atcommand_info[i].type != AtCommand_Unknown) {
  814. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  815. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  816. break;
  817. }
  818. i++;
  819. }
  820. if (atcommand_info[i].type == AtCommand_Unknown) {
  821. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  822. if (level == 0)
  823. return AtCommand_None;
  824. else
  825. return AtCommand_Unknown;
  826. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  827. log_atcommand(sd, message);
  828. }
  829. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  830. } else {
  831. return AtCommand_None;
  832. }
  833. return info->type;
  834. }
  835. /*==========================================
  836. * Read Message Data
  837. *------------------------------------------
  838. */
  839. int msg_config_read(const char *cfgName)
  840. {
  841. int msg_number;
  842. char line[1024], w1[1024], w2[1024];
  843. FILE *fp;
  844. static int called = 1;
  845. if ((fp = fopen(cfgName, "r")) == NULL) {
  846. ShowError("Messages file not found: %s\n", cfgName);
  847. return 1;
  848. }
  849. if ((--called) == 0)
  850. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  851. while(fgets(line, sizeof(line)-1, fp)) {
  852. if (line[0] == '/' && line[1] == '/')
  853. continue;
  854. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  855. if (strcmpi(w1, "import") == 0) {
  856. msg_config_read(w2);
  857. } else {
  858. msg_number = atoi(w1);
  859. if (msg_number >= 0 && msg_number < MAX_MSG) {
  860. if (msg_table[msg_number] != NULL)
  861. aFree(msg_table[msg_number]);
  862. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  863. strcpy(msg_table[msg_number],w2);
  864. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  865. }
  866. }
  867. }
  868. }
  869. fclose(fp);
  870. return 0;
  871. }
  872. /*==========================================
  873. * Cleanup Message Data
  874. *------------------------------------------
  875. */
  876. void do_final_msg (void)
  877. {
  878. int i;
  879. for (i = 0; i < MAX_MSG; i++)
  880. aFree(msg_table[i]);
  881. return;
  882. }
  883. /*==========================================
  884. *
  885. *------------------------------------------
  886. */
  887. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  888. {
  889. int i;
  890. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  891. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  892. return &atcommand_info[i];
  893. return NULL;
  894. }
  895. /*==========================================
  896. *
  897. *------------------------------------------
  898. */
  899. int atcommand_config_read(const char *cfgName)
  900. {
  901. char line[1024], w1[1024], w2[1024];
  902. AtCommandInfo* p;
  903. FILE* fp;
  904. if ((fp = fopen(cfgName, "r")) == NULL) {
  905. ShowError("At commands configuration file not found: %s\n", cfgName);
  906. return 1;
  907. }
  908. while (fgets(line, sizeof(line)-1, fp)) {
  909. if (line[0] == '/' && line[1] == '/')
  910. continue;
  911. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  912. continue;
  913. p = get_atcommandinfo_byname(w1);
  914. if (p != NULL) {
  915. p->level = atoi(w2);
  916. if (p->level > 100)
  917. p->level = 100;
  918. else if (p->level < 0)
  919. p->level = 0;
  920. }
  921. if (strcmpi(w1, "import") == 0)
  922. atcommand_config_read(w2);
  923. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  924. w2[0] != '/' && // symbol of standard ragnarok GM commands
  925. w2[0] != '%' && // symbol of party chat speaking
  926. w2[0] != '$' && // symbol of guild chat
  927. w2[0] != '#') // symbol of charcommand
  928. atcommand_symbol = w2[0];
  929. }
  930. fclose(fp);
  931. return 0;
  932. }
  933. /*==========================================
  934. // @ command processing functions
  935. *------------------------------------------
  936. */
  937. /*==========================================
  938. * @commands Lists available @ commands to you (code 98% from Meruru)
  939. *------------------------------------------
  940. */
  941. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  942. {
  943. char cz_line_buff[CHAT_SIZE+1];
  944. register char *lpcz_cur = cz_line_buff;
  945. register unsigned int ui_slen;
  946. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  947. memset(cz_line_buff,' ',CHAT_SIZE);
  948. cz_line_buff[CHAT_SIZE] = 0;
  949. clif_displaymessage(fd, msg_txt(273));
  950. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  951. {
  952. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  953. continue;
  954. count++;
  955. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  956. //remember not <= bc we need null terminator
  957. if(((CHAT_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  958. {
  959. clif_displaymessage(fd,(char*)cz_line_buff);
  960. lpcz_cur = cz_line_buff;
  961. memset(cz_line_buff,' ',CHAT_SIZE);
  962. cz_line_buff[CHAT_SIZE] = 0;
  963. }
  964. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  965. lpcz_cur += ui_slen+(10-ui_slen%10);
  966. }
  967. clif_displaymessage(fd,(char*)cz_line_buff);
  968. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  969. clif_displaymessage(fd, atcmd_output);
  970. return 0;
  971. }
  972. /*==========================================
  973. * @send (used for testing packet sends from the client)
  974. *------------------------------------------
  975. */
  976. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  977. {
  978. int len=0,off,end,type;
  979. long num;
  980. (void)command; // not used
  981. // read message type as hex number (without the 0x)
  982. if(!message || !*message ||
  983. !((sscanf(message, "len %x", &type)==1 && (len=1))
  984. || sscanf(message, "%x", &type)==1) )
  985. {
  986. clif_displaymessage(fd, "Usage:");
  987. clif_displaymessage(fd, " @send len <packet hex number>");
  988. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  989. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  990. return -1;
  991. }
  992. #define PARSE_ERROR(error,p) \
  993. {\
  994. clif_displaymessage(fd, (error));\
  995. sprintf(atcmd_output, ">%s", (p));\
  996. clif_displaymessage(fd, atcmd_output);\
  997. }
  998. //define PARSE_ERROR
  999. #define CHECK_EOS(p) \
  1000. if(*(p) == 0){\
  1001. clif_displaymessage(fd, "Unexpected end of string");\
  1002. return -1;\
  1003. }
  1004. //define CHECK_EOS
  1005. #define SKIP_VALUE(p) \
  1006. {\
  1007. while(*(p) && !isspace(*(p))) ++(p); /* non-space */\
  1008. while(*(p) && isspace(*(p))) ++(p); /* space */\
  1009. }
  1010. //define SKIP_VALUE
  1011. #define GET_VALUE(p,num) \
  1012. {\
  1013. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  1014. PARSE_ERROR("Invalid number in:",(p));\
  1015. return -1;\
  1016. }\
  1017. }
  1018. //define GET_VALUE
  1019. if (type > 0 && type < MAX_PACKET_DB) {
  1020. if(len)
  1021. {// show packet length
  1022. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  1023. clif_displaymessage(fd, atcmd_output);
  1024. return 0;
  1025. }
  1026. len=packet_db[sd->packet_ver][type].len;
  1027. off=2;
  1028. if(len == 0)
  1029. {// unknown packet - ERROR
  1030. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  1031. clif_displaymessage(fd, atcmd_output);
  1032. return -1;
  1033. } else if(len == -1)
  1034. {// dynamic packet
  1035. len=SHRT_MAX-4; // maximum length
  1036. off=4;
  1037. }
  1038. WFIFOHEAD(fd, len);
  1039. WFIFOW(fd,0)=TOW(type);
  1040. // parse packet contents
  1041. SKIP_VALUE(message);
  1042. while(*message != 0 && off < len){
  1043. if(isdigit(*message) || *message == '-' || *message == '+')
  1044. {// default (byte)
  1045. GET_VALUE(message,num);
  1046. WFIFOB(fd,off)=TOB(num);
  1047. ++off;
  1048. } else if(toupper(*message) == 'B')
  1049. {// byte
  1050. ++message;
  1051. GET_VALUE(message,num);
  1052. WFIFOB(fd,off)=TOB(num);
  1053. ++off;
  1054. } else if(toupper(*message) == 'W')
  1055. {// word (2 bytes)
  1056. ++message;
  1057. GET_VALUE(message,num);
  1058. WFIFOW(fd,off)=TOW(num);
  1059. off+=2;
  1060. } else if(toupper(*message) == 'L')
  1061. {// long word (4 bytes)
  1062. ++message;
  1063. GET_VALUE(message,num);
  1064. WFIFOL(fd,off)=TOL(num);
  1065. off+=4;
  1066. } else if(toupper(*message) == 'S')
  1067. {// string - escapes are valid
  1068. // get string length - num <= 0 means not fixed length (default)
  1069. ++message;
  1070. if(*message == '"'){
  1071. num=0;
  1072. } else {
  1073. GET_VALUE(message,num);
  1074. while(*message != '"')
  1075. {// find start of string
  1076. if(*message == 0 || isspace(*message)){
  1077. PARSE_ERROR("Not a string:",message);
  1078. return -1;
  1079. }
  1080. ++message;
  1081. }
  1082. }
  1083. // parse string
  1084. ++message;
  1085. CHECK_EOS(message);
  1086. end=(num<=0? 0: min(off+((int)num),len));
  1087. for(; *message != '"' && (off < end || end == 0); ++off){
  1088. if(*message == '\\'){
  1089. ++message;
  1090. CHECK_EOS(message);
  1091. switch(*message){
  1092. case 'a': num=0x07; break; // Bell
  1093. case 'b': num=0x08; break; // Backspace
  1094. case 't': num=0x09; break; // Horizontal tab
  1095. case 'n': num=0x0A; break; // Line feed
  1096. case 'v': num=0x0B; break; // Vertical tab
  1097. case 'f': num=0x0C; break; // Form feed
  1098. case 'r': num=0x0D; break; // Carriage return
  1099. case 'e': num=0x1B; break; // Escape
  1100. default: num=*message; break;
  1101. case 'x': // Hexadecimal
  1102. {
  1103. ++message;
  1104. CHECK_EOS(message);
  1105. if(!isxdigit(*message)){
  1106. PARSE_ERROR("Not a hexadecimal digit:",message);
  1107. return -1;
  1108. }
  1109. num=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1110. if(isxdigit(*message)){
  1111. ++message;
  1112. CHECK_EOS(message);
  1113. num<<=8;
  1114. num+=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1115. }
  1116. WFIFOB(fd,off)=TOB(num);
  1117. ++message;
  1118. CHECK_EOS(message);
  1119. continue;
  1120. }
  1121. case '0':
  1122. case '1':
  1123. case '2':
  1124. case '3':
  1125. case '4':
  1126. case '5':
  1127. case '6':
  1128. case '7': // Octal
  1129. {
  1130. num=*message-'0'; // 1st octal digit
  1131. ++message;
  1132. CHECK_EOS(message);
  1133. if(isdigit(*message) && *message < '8'){
  1134. num<<=3;
  1135. num+=*message-'0'; // 2nd octal digit
  1136. ++message;
  1137. CHECK_EOS(message);
  1138. if(isdigit(*message) && *message < '8'){
  1139. num<<=3;
  1140. num+=*message-'0'; // 3rd octal digit
  1141. ++message;
  1142. CHECK_EOS(message);
  1143. }
  1144. }
  1145. WFIFOB(fd,off)=TOB(num);
  1146. continue;
  1147. }
  1148. }
  1149. } else
  1150. num=*message;
  1151. WFIFOB(fd,off)=TOB(num);
  1152. ++message;
  1153. CHECK_EOS(message);
  1154. }//for
  1155. while(*message != '"')
  1156. {// ignore extra characters
  1157. ++message;
  1158. CHECK_EOS(message);
  1159. }
  1160. // terminate the string
  1161. if(off < end)
  1162. {// fill the rest with 0's
  1163. memset(WFIFOP(fd,off),0,end-off);
  1164. off=end;
  1165. }
  1166. } else
  1167. {// unknown
  1168. PARSE_ERROR("Unknown type of value in:",message);
  1169. return -1;
  1170. }
  1171. SKIP_VALUE(message);
  1172. }
  1173. if(packet_db[sd->packet_ver][type].len == -1)
  1174. {// send dynamic packet
  1175. WFIFOW(fd,2)=TOW(off);
  1176. WFIFOSET(fd,off);
  1177. } else
  1178. {// send static packet
  1179. if(off < len)
  1180. memset(WFIFOP(fd,off),0,len-off);
  1181. WFIFOSET(fd,len);
  1182. }
  1183. } else {
  1184. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  1185. return -1;
  1186. }
  1187. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  1188. clif_displaymessage(fd, atcmd_output);
  1189. return 0;
  1190. #undef PARSE_ERROR
  1191. #undef CHECK_EOS
  1192. #undef SKIP_VALUE
  1193. #undef GET_VALUE
  1194. }
  1195. /*==========================================
  1196. * @rura
  1197. *------------------------------------------
  1198. */
  1199. int atcommand_rura( const int fd, struct map_session_data* sd, const char* command, const char* message)
  1200. {
  1201. char map_name[MAP_NAME_LENGTH];
  1202. unsigned short mapindex;
  1203. int x = 0, y = 0;
  1204. int m = -1;
  1205. nullpo_retr(-1, sd);
  1206. memset(map_name, '\0', sizeof(map_name));
  1207. if (!message || !*message ||
  1208. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1209. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1210. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1211. return -1;
  1212. }
  1213. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1214. strcat(map_name, ".gat");
  1215. mapindex = mapindex_name2id(map_name);
  1216. if (mapindex)
  1217. m = map_mapindex2mapid(mapindex);
  1218. if (!mapindex || m < 0) {
  1219. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1220. return -1;
  1221. }
  1222. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  1223. { //This is to prevent the pc_setpos call from printing an error.
  1224. clif_displaymessage(fd, msg_txt(2));
  1225. x = y = 0; //Invalid cell, use random spot.
  1226. }
  1227. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1228. clif_displaymessage(fd, msg_txt(247));
  1229. return -1;
  1230. }
  1231. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1232. clif_displaymessage(fd, msg_txt(248));
  1233. return -1;
  1234. }
  1235. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1236. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1237. else {
  1238. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1239. return -1;
  1240. }
  1241. return 0;
  1242. }
  1243. /*==========================================
  1244. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1245. *------------------------------------------
  1246. */
  1247. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1248. {
  1249. struct map_session_data *pl_sd = NULL;
  1250. int GM_level, pl_GM_level;
  1251. nullpo_retr(-1, sd);
  1252. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1253. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1254. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1255. return -1;
  1256. }
  1257. pl_sd = map_nick2sd(atcmd_player_name);
  1258. if (pl_sd == NULL)
  1259. return -1;
  1260. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1261. return -1;
  1262. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1263. pl_GM_level = pc_isGM(pl_sd);
  1264. if (battle_config.hide_GM_session) {
  1265. if(GM_level < pl_GM_level) {
  1266. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1267. return -1;
  1268. }
  1269. }
  1270. }
  1271. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1272. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1273. clif_displaymessage(fd, atcmd_output);
  1274. return 0;
  1275. }
  1276. /*==========================================
  1277. *
  1278. *------------------------------------------
  1279. */
  1280. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1281. {
  1282. struct map_session_data *pl_sd = NULL;
  1283. nullpo_retr(-1, sd);
  1284. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1285. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1286. return -1;
  1287. }
  1288. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1289. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1290. return -1;
  1291. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1292. return -1;
  1293. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1294. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1295. clif_displaymessage(fd, msg_txt(247));
  1296. return -1;
  1297. }
  1298. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1299. clif_displaymessage(fd, msg_txt(248));
  1300. return -1;
  1301. }
  1302. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1303. sprintf(atcmd_output, msg_txt(4), atcmd_player_name); // Jump to %s
  1304. clif_displaymessage(fd, atcmd_output);
  1305. } else {
  1306. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1307. return -1;
  1308. }
  1309. return 0;
  1310. }
  1311. /*==========================================
  1312. *
  1313. *------------------------------------------
  1314. */
  1315. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1316. {
  1317. int x = 0, y = 0;
  1318. nullpo_retr(-1, sd);
  1319. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1320. sscanf(message, "%d %d", &x, &y);
  1321. if (x <= 0) //If coordinates are 'wrong', random jump.
  1322. x = -1;
  1323. if (y <= 0)
  1324. y = -1;
  1325. 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)) {
  1326. clif_displaymessage(fd, msg_txt(248));
  1327. return -1;
  1328. }
  1329. pc_setpos(sd, sd->mapindex, x, y, 3);
  1330. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
  1331. clif_displaymessage(fd, atcmd_output);
  1332. return 0;
  1333. }
  1334. /*==========================================
  1335. * @who3 = Player name, his location
  1336. *------------------------------------------
  1337. */
  1338. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1339. {
  1340. char temp0[100];
  1341. struct map_session_data *pl_sd, **pl_allsd;
  1342. int i, j, count, users;
  1343. int pl_GM_level, GM_level;
  1344. char match_text[100];
  1345. char player_name[NAME_LENGTH];
  1346. nullpo_retr(-1, sd);
  1347. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1348. memset(match_text, '\0', sizeof(match_text));
  1349. memset(player_name, '\0', sizeof(player_name));
  1350. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1351. strcpy(match_text, "");
  1352. for (j = 0; match_text[j]; j++)
  1353. match_text[j] = tolower(match_text[j]);
  1354. count = 0;
  1355. GM_level = pc_isGM(sd);
  1356. pl_allsd = map_getallusers(&users);
  1357. for (i = 0; i < users; i++) {
  1358. if ((pl_sd = pl_allsd[i])) {
  1359. pl_GM_level = pc_isGM(pl_sd);
  1360. 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
  1361. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1362. for (j = 0; player_name[j]; j++)
  1363. player_name[j] = tolower(player_name[j]);
  1364. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1365. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1366. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1367. } else {
  1368. atcmd_output[0]=0;
  1369. }
  1370. //Player name
  1371. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1372. strcat(atcmd_output,temp0);
  1373. //Player title, if exists
  1374. if (pl_GM_level > 0) {
  1375. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1376. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1377. strcat(atcmd_output,temp0);
  1378. }
  1379. //Players Location: map x y
  1380. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1381. strcat(atcmd_output,temp0);
  1382. clif_displaymessage(fd, atcmd_output);
  1383. count++;
  1384. }
  1385. }
  1386. }
  1387. }
  1388. if (count == 0)
  1389. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1390. else if (count == 1)
  1391. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1392. else {
  1393. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1394. clif_displaymessage(fd, atcmd_output);
  1395. }
  1396. return 0;
  1397. }
  1398. /*==========================================
  1399. * Player name, BLevel, Job,
  1400. *------------------------------------------
  1401. */
  1402. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1403. {
  1404. char temp0[100];
  1405. struct map_session_data *pl_sd, **pl_allsd;
  1406. int i, j, count, users;
  1407. int pl_GM_level, GM_level;
  1408. char match_text[100];
  1409. char player_name[NAME_LENGTH];
  1410. nullpo_retr(-1, sd);
  1411. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1412. memset(match_text, '\0', sizeof(match_text));
  1413. memset(player_name, '\0', sizeof(player_name));
  1414. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1415. strcpy(match_text, "");
  1416. for (j = 0; match_text[j]; j++)
  1417. match_text[j] = tolower(match_text[j]);
  1418. count = 0;
  1419. GM_level = pc_isGM(sd);
  1420. pl_allsd = map_getallusers(&users);
  1421. for (i = 0; i < users; i++) {
  1422. if ((pl_sd = pl_allsd[i])) {
  1423. pl_GM_level = pc_isGM(pl_sd);
  1424. 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
  1425. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1426. for (j = 0; player_name[j]; j++)
  1427. player_name[j] = tolower(player_name[j]);
  1428. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1429. //Players Name
  1430. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1431. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1432. //Player title, if exists
  1433. if (pl_GM_level > 0) {
  1434. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1435. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1436. strcat(atcmd_output,temp0);
  1437. }
  1438. //Players Base Level / Job name
  1439. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1440. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1441. strcat(atcmd_output,temp0);
  1442. clif_displaymessage(fd, atcmd_output);
  1443. count++;
  1444. }
  1445. }
  1446. }
  1447. }
  1448. if (count == 0)
  1449. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1450. else if (count == 1)
  1451. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1452. else {
  1453. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1454. clif_displaymessage(fd, atcmd_output);
  1455. }
  1456. return 0;
  1457. }
  1458. /*==========================================
  1459. * Player name, Playrs Party / Guild name
  1460. *------------------------------------------
  1461. */
  1462. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1463. {
  1464. char temp0[100];
  1465. struct map_session_data *pl_sd, **pl_allsd;
  1466. int i, j, count, users;
  1467. int pl_GM_level, GM_level;
  1468. char match_text[100];
  1469. char player_name[NAME_LENGTH];
  1470. struct guild *g;
  1471. struct party_data *p;
  1472. nullpo_retr(-1, sd);
  1473. memset(temp0, '\0', sizeof(temp0));
  1474. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1475. memset(match_text, '\0', sizeof(match_text));
  1476. memset(player_name, '\0', sizeof(player_name));
  1477. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1478. strcpy(match_text, "");
  1479. for (j = 0; match_text[j]; j++)
  1480. match_text[j] = tolower(match_text[j]);
  1481. count = 0;
  1482. GM_level = pc_isGM(sd);
  1483. pl_allsd = map_getallusers(&users);
  1484. for (i = 0; i < users; i++) {
  1485. if ((pl_sd = pl_allsd[i])) {
  1486. pl_GM_level = pc_isGM(pl_sd);
  1487. 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
  1488. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1489. for (j = 0; player_name[j]; j++)
  1490. player_name[j] = tolower(player_name[j]);
  1491. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1492. g = guild_search(pl_sd->status.guild_id);
  1493. p = party_search(pl_sd->status.party_id);
  1494. //Players Name
  1495. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1496. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1497. //Player title, if exists
  1498. if (pl_GM_level > 0) {
  1499. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1500. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1501. strcat(atcmd_output,temp0);
  1502. }
  1503. //Players Party if exists
  1504. if (p != NULL) {
  1505. //sprintf(temp0," | Party: '%s'", p->name);
  1506. sprintf(temp0, msg_txt(335), p->party.name);
  1507. strcat(atcmd_output,temp0);
  1508. }
  1509. //Players Guild if exists
  1510. if (g != NULL) {
  1511. //sprintf(temp0," | Guild: '%s'", g->name);
  1512. sprintf(temp0, msg_txt(336), g->name);
  1513. strcat(atcmd_output,temp0);
  1514. }
  1515. clif_displaymessage(fd, atcmd_output);
  1516. count++;
  1517. }
  1518. }
  1519. }
  1520. }
  1521. if (count == 0)
  1522. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1523. else if (count == 1)
  1524. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1525. else {
  1526. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1527. clif_displaymessage(fd, atcmd_output);
  1528. }
  1529. return 0;
  1530. }
  1531. /*==========================================
  1532. *
  1533. *------------------------------------------
  1534. */
  1535. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1536. {
  1537. struct map_session_data *pl_sd, **pl_allsd;
  1538. int i, count, users;
  1539. int pl_GM_level, GM_level;
  1540. int map_id;
  1541. char map_name[MAP_NAME_LENGTH];
  1542. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1543. memset(map_name, '\0', sizeof(map_name));
  1544. if (!message || !*message)
  1545. map_id = sd->bl.m;
  1546. else {
  1547. sscanf(message, "%15s", map_name);
  1548. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1549. strcat(map_name, ".gat");
  1550. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1551. map_id = sd->bl.m;
  1552. }
  1553. count = 0;
  1554. GM_level = pc_isGM(sd);
  1555. pl_allsd = map_getallusers(&users);
  1556. for (i = 0; i < users; i++) {
  1557. if ((pl_sd = pl_allsd[i])) {
  1558. pl_GM_level = pc_isGM(pl_sd);
  1559. 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
  1560. if (pl_sd->bl.m == map_id) {
  1561. if (pl_GM_level > 0)
  1562. 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);
  1563. else
  1564. 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);
  1565. clif_displaymessage(fd, atcmd_output);
  1566. count++;
  1567. }
  1568. }
  1569. }
  1570. }
  1571. if (count == 0)
  1572. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1573. else if (count == 1)
  1574. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1575. else {
  1576. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1577. }
  1578. clif_displaymessage(fd, atcmd_output);
  1579. return 0;
  1580. }
  1581. /*==========================================
  1582. *
  1583. *------------------------------------------
  1584. */
  1585. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1586. {
  1587. struct map_session_data *pl_sd, **pl_allsd;
  1588. int i, count, users;
  1589. int pl_GM_level, GM_level;
  1590. int map_id = 0;
  1591. char map_name[MAP_NAME_LENGTH];
  1592. nullpo_retr(-1, sd);
  1593. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1594. memset(map_name, '\0', sizeof(map_name));
  1595. if (!message || !*message)
  1596. map_id = sd->bl.m;
  1597. else {
  1598. sscanf(message, "%15s", map_name);
  1599. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1600. strcat(map_name, ".gat");
  1601. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1602. map_id = sd->bl.m;
  1603. }
  1604. count = 0;
  1605. GM_level = pc_isGM(sd);
  1606. pl_allsd = map_getallusers(&users);
  1607. for (i = 0; i < users; i++) {
  1608. if ((pl_sd = pl_allsd[i])) {
  1609. pl_GM_level = pc_isGM(pl_sd);
  1610. 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
  1611. if (pl_sd->bl.m == map_id) {
  1612. if (pl_GM_level > 0)
  1613. 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);
  1614. else
  1615. 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);
  1616. clif_displaymessage(fd, atcmd_output);
  1617. count++;
  1618. }
  1619. }
  1620. }
  1621. }
  1622. if (count == 0)
  1623. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1624. else if (count == 1)
  1625. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1626. else {
  1627. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1628. }
  1629. clif_displaymessage(fd, atcmd_output);
  1630. return 0;
  1631. }
  1632. /*==========================================
  1633. *
  1634. *------------------------------------------
  1635. */
  1636. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1637. {
  1638. char temp0[100];
  1639. char temp1[100];
  1640. struct map_session_data *pl_sd, **pl_allsd;
  1641. int i, count, users;
  1642. int pl_GM_level, GM_level;
  1643. int map_id = 0;
  1644. char map_name[MAP_NAME_LENGTH];
  1645. struct guild *g;
  1646. struct party_data *p;
  1647. nullpo_retr(-1, sd);
  1648. memset(temp0, '\0', sizeof(temp0));
  1649. memset(temp1, '\0', sizeof(temp1));
  1650. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1651. memset(map_name, '\0', sizeof(map_name));
  1652. if (!message || !*message)
  1653. map_id = sd->bl.m;
  1654. else {
  1655. sscanf(message, "%15s", map_name);
  1656. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1657. strcat(map_name, ".gat");
  1658. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1659. map_id = sd->bl.m;
  1660. }
  1661. count = 0;
  1662. GM_level = pc_isGM(sd);
  1663. pl_allsd = map_getallusers(&users);
  1664. for (i = 0; i < users; i++) {
  1665. if ((pl_sd = pl_allsd[i])) {
  1666. pl_GM_level = pc_isGM(pl_sd);
  1667. 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
  1668. if (pl_sd->bl.m == map_id) {
  1669. g = guild_search(pl_sd->status.guild_id);
  1670. if (g == NULL)
  1671. sprintf(temp1, "None");
  1672. else
  1673. sprintf(temp1, "%s", g->name);
  1674. p = party_search(pl_sd->status.party_id);
  1675. if (p == NULL)
  1676. sprintf(temp0, "None");
  1677. else
  1678. sprintf(temp0, "%s", p->party.name);
  1679. if (pl_GM_level > 0)
  1680. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1681. else
  1682. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1683. clif_displaymessage(fd, atcmd_output);
  1684. count++;
  1685. }
  1686. }
  1687. }
  1688. }
  1689. if (count == 0)
  1690. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1691. else if (count == 1)
  1692. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1693. else {
  1694. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1695. }
  1696. clif_displaymessage(fd, atcmd_output);
  1697. return 0;
  1698. }
  1699. /*==========================================
  1700. *
  1701. *------------------------------------------
  1702. */
  1703. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1704. {
  1705. char temp0[100];
  1706. char temp1[100];
  1707. struct map_session_data *pl_sd, **pl_allsd;
  1708. int i, j, count, users;
  1709. int pl_GM_level, GM_level;
  1710. char match_text[100];
  1711. char player_name[NAME_LENGTH];
  1712. struct guild *g;
  1713. struct party_data *p;
  1714. nullpo_retr(-1, sd);
  1715. memset(temp0, '\0', sizeof(temp0));
  1716. memset(temp1, '\0', sizeof(temp1));
  1717. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1718. memset(match_text, '\0', sizeof(match_text));
  1719. memset(player_name, '\0', sizeof(player_name));
  1720. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1721. strcpy(match_text, "");
  1722. for (j = 0; match_text[j]; j++)
  1723. match_text[j] = tolower(match_text[j]);
  1724. count = 0;
  1725. GM_level = pc_isGM(sd);
  1726. pl_allsd = map_getallusers(&users);
  1727. for (i = 0; i < users; i++) {
  1728. if ((pl_sd = pl_allsd[i])) {
  1729. pl_GM_level = pc_isGM(pl_sd);
  1730. if (pl_GM_level > 0) {
  1731. 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
  1732. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1733. for (j = 0; player_name[j]; j++)
  1734. player_name[j] = tolower(player_name[j]);
  1735. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1736. 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);
  1737. clif_displaymessage(fd, atcmd_output);
  1738. 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);
  1739. clif_displaymessage(fd, atcmd_output);
  1740. g = guild_search(pl_sd->status.guild_id);
  1741. if (g == NULL)
  1742. sprintf(temp1, "None");
  1743. else
  1744. sprintf(temp1, "%s", g->name);
  1745. p = party_search(pl_sd->status.party_id);
  1746. if (p == NULL)
  1747. sprintf(temp0, "None");
  1748. else
  1749. sprintf(temp0, "%s", p->party.name);
  1750. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1751. clif_displaymessage(fd, atcmd_output);
  1752. count++;
  1753. }
  1754. }
  1755. }
  1756. }
  1757. }
  1758. if (count == 0)
  1759. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1760. else if (count == 1)
  1761. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1762. else {
  1763. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1764. clif_displaymessage(fd, atcmd_output);
  1765. }
  1766. return 0;
  1767. }
  1768. int atcommand_whozeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1769. {
  1770. struct map_session_data *pl_sd, **pl_allsd;
  1771. int i, j, count,c, users;
  1772. char match_text[100];
  1773. char player_name[NAME_LENGTH];
  1774. int *zeny;
  1775. int *counted;
  1776. nullpo_retr(-1, sd);
  1777. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1778. memset(match_text, '\0', sizeof(match_text));
  1779. memset(player_name, '\0', sizeof(player_name));
  1780. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1781. strcpy(match_text, "");
  1782. for (j = 0; match_text[j]; j++)
  1783. match_text[j] = tolower(match_text[j]);
  1784. count = 0;
  1785. pl_allsd = map_getallusers(&users);
  1786. if (users < 1)
  1787. {
  1788. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1789. return 0;
  1790. }
  1791. zeny = (int *)aMallocA(users*sizeof(int));
  1792. counted = (int *)aMallocA(users*sizeof(int));
  1793. for (i = 0; i < users; i++) {
  1794. if ((pl_sd = pl_allsd[i])) {
  1795. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1796. for (j = 0; player_name[j]; j++)
  1797. player_name[j] = tolower(player_name[j]);
  1798. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1799. zeny[count]=pl_sd->status.zeny;
  1800. counted[i]=0;
  1801. count++;
  1802. }
  1803. }
  1804. }
  1805. qsort(zeny, count, sizeof(int), hightolow_compare);
  1806. for (c = 0; c < count && c < 50; c++) {
  1807. if(!zeny[c])
  1808. continue;
  1809. for (i = 0; i < users; i++) {
  1810. if(!zeny[c])
  1811. continue;
  1812. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1813. if(pl_sd->status.zeny==zeny[c]) {
  1814. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1815. clif_displaymessage(fd, atcmd_output);
  1816. zeny[c]=0;
  1817. counted[i]=1;
  1818. }
  1819. }
  1820. }
  1821. }
  1822. if (count == 0)
  1823. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1824. else if (count == 1)
  1825. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1826. else {
  1827. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1828. clif_displaymessage(fd, atcmd_output);
  1829. }
  1830. aFree(zeny);
  1831. aFree(counted);
  1832. return 0;
  1833. }
  1834. /*==========================================
  1835. *
  1836. *------------------------------------------
  1837. */
  1838. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1839. {
  1840. nullpo_retr(-1, sd);
  1841. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1842. if (sd->status.pet_id > 0 && sd->pd)
  1843. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1844. chrif_save(sd,0);
  1845. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  1846. return 0;
  1847. }
  1848. /*==========================================
  1849. *
  1850. *------------------------------------------
  1851. */
  1852. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1853. {
  1854. int m;
  1855. nullpo_retr(-1, sd);
  1856. m = map_mapindex2mapid(sd->status.save_point.map);
  1857. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1858. clif_displaymessage(fd, msg_txt(249));
  1859. return -1;
  1860. }
  1861. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1862. clif_displaymessage(fd, msg_txt(248));
  1863. return -1;
  1864. }
  1865. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1866. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1867. return 0;
  1868. }
  1869. /*==========================================
  1870. *
  1871. *------------------------------------------
  1872. */
  1873. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1874. {
  1875. int speed;
  1876. nullpo_retr(-1, sd);
  1877. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1878. if (!message || !*message) {
  1879. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1880. clif_displaymessage(fd, atcmd_output);
  1881. return -1;
  1882. }
  1883. speed = atoi(message);
  1884. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1885. sd->base_status.speed = speed;
  1886. status_calc_bl(&sd->bl, SCB_SPEED);
  1887. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1888. } else {
  1889. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1890. clif_displaymessage(fd, atcmd_output);
  1891. return -1;
  1892. }
  1893. return 0;
  1894. }
  1895. /*==========================================
  1896. *
  1897. *------------------------------------------
  1898. */
  1899. int atcommand_charspeed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1900. {
  1901. struct map_session_data *pl_sd;
  1902. int speed;
  1903. nullpo_retr(-1, sd);
  1904. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1905. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1906. if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
  1907. sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1908. clif_displaymessage(fd, atcmd_output);
  1909. return -1;
  1910. }
  1911. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  1912. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1913. return -1;
  1914. }
  1915. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1916. { //GM level check
  1917. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1918. return -1;
  1919. }
  1920. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1921. pl_sd->base_status.speed = speed;
  1922. status_calc_bl(&pl_sd->bl, SCB_SPEED);
  1923. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1924. if(pl_sd->fd)
  1925. clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
  1926. } else {
  1927. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1928. clif_displaymessage(fd, atcmd_output);
  1929. return -1;
  1930. }
  1931. return 0;
  1932. }
  1933. /*==========================================
  1934. *
  1935. *------------------------------------------
  1936. */
  1937. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1938. {
  1939. nullpo_retr(-1, sd);
  1940. if (storage_storageopen(sd) == 1)
  1941. { //Already open.
  1942. clif_displaymessage(fd, msg_txt(250));
  1943. return -1;
  1944. }
  1945. return 0;
  1946. }
  1947. /*==========================================
  1948. *
  1949. *------------------------------------------
  1950. */
  1951. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1952. {
  1953. struct storage *stor; //changes from Freya/Yor
  1954. nullpo_retr(-1, sd);
  1955. if (sd->status.guild_id > 0) {
  1956. if (sd->state.storage_flag) {
  1957. clif_displaymessage(fd, msg_txt(251));
  1958. return -1;
  1959. }
  1960. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1961. clif_displaymessage(fd, msg_txt(251));
  1962. return -1;
  1963. }
  1964. storage_guild_storageopen(sd);
  1965. } else {
  1966. clif_displaymessage(fd, msg_txt(252));
  1967. return -1;
  1968. }
  1969. return 0;
  1970. }
  1971. /*==========================================
  1972. *
  1973. *------------------------------------------
  1974. */
  1975. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1976. {
  1977. int param1 = 0, param2 = 0, param3 = 0;
  1978. nullpo_retr(-1, sd);
  1979. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1980. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1981. return -1;
  1982. }
  1983. sd->sc.opt1 = param1;
  1984. sd->sc.opt2 = param2;
  1985. if (!(sd->sc.option & OPTION_CART) && param3 & OPTION_CART) {
  1986. clif_cartlist(sd);
  1987. clif_updatestatus(sd, SP_CARTINFO);
  1988. }
  1989. pc_setoption(sd, param3);
  1990. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1991. return 0;
  1992. }
  1993. /*==========================================
  1994. *
  1995. *------------------------------------------
  1996. */
  1997. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1998. {
  1999. nullpo_retr(-1, sd);
  2000. if (sd->sc.option & OPTION_INVISIBLE) {
  2001. sd->sc.option &= ~OPTION_INVISIBLE;
  2002. if (sd->disguise)
  2003. status_set_viewdata(&sd->bl, sd->disguise);
  2004. else
  2005. status_set_viewdata(&sd->bl, sd->status.class_);
  2006. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  2007. } else {
  2008. sd->sc.option |= OPTION_INVISIBLE;
  2009. sd->vd.class_ = INVISIBLE_CLASS;
  2010. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  2011. }
  2012. clif_changeoption(&sd->bl);
  2013. return 0;
  2014. }
  2015. /*==========================================
  2016. * Changes a character's class
  2017. *------------------------------------------
  2018. */
  2019. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2020. {
  2021. int job = 0, upper = 0;
  2022. nullpo_retr(-1, sd);
  2023. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  2024. int i, found = 0;
  2025. const struct { char name[16]; int id; } jobs[] = {
  2026. { "novice", 0 },
  2027. { "swordsman", 1 },
  2028. { "mage", 2 },
  2029. { "archer", 3 },
  2030. { "acolyte", 4 },
  2031. { "merchant", 5 },
  2032. { "thief", 6 },
  2033. { "knight", 7 },
  2034. { "priest", 8 },
  2035. { "priestess", 8 },
  2036. { "wizard", 9 },
  2037. { "blacksmith", 10 },
  2038. { "hunter", 11 },
  2039. { "assassin", 12 },
  2040. { "crusader", 14 },
  2041. { "monk", 15 },
  2042. { "sage", 16 },
  2043. { "rogue", 17 },
  2044. { "alchemist", 18 },
  2045. { "bard", 19 },
  2046. { "dancer", 20 },
  2047. { "super novice", 23 },
  2048. { "supernovice", 23 },
  2049. { "gunslinger", 24 },
  2050. { "gunner", 24 },
  2051. { "ninja", 25 },
  2052. { "high novice", 4001 },
  2053. { "swordsman high", 4002 },
  2054. { "mage high", 4003 },
  2055. { "archer high", 4004 },
  2056. { "acolyte high", 4005 },
  2057. { "merchant high", 4006 },
  2058. { "thief high", 4007 },
  2059. { "lord knight", 4008 },
  2060. { "high priest", 4009 },
  2061. { "high priestess", 4009 },
  2062. { "high wizard", 4010 },
  2063. { "whitesmith", 4011 },
  2064. { "sniper", 4012 },
  2065. { "assassin cross", 4013 },
  2066. { "paladin", 4015 },
  2067. { "champion", 4016 },
  2068. { "professor", 4017 },
  2069. { "stalker", 4018 },
  2070. { "creator", 4019 },
  2071. { "clown", 4020 },
  2072. { "gypsy", 4021 },
  2073. { "baby novice", 4023 },
  2074. { "baby swordsman", 4024 },
  2075. { "baby mage", 4025 },
  2076. { "baby archer", 4026 },
  2077. { "baby acolyte", 4027 },
  2078. { "baby merchant", 4028 },
  2079. { "baby thief", 4029 },
  2080. { "baby knight", 4030 },
  2081. { "baby priest", 4031 },
  2082. { "baby priestess", 4031 },
  2083. { "baby wizard", 4032 },
  2084. { "baby blacksmith",4033 },
  2085. { "baby hunter", 4034 },
  2086. { "baby assassin", 4035 },
  2087. { "baby crusader", 4037 },
  2088. { "baby monk", 4038 },
  2089. { "baby sage", 4039 },
  2090. { "baby rogue", 4040 },
  2091. { "baby alchemist", 4041 },
  2092. { "baby bard", 4042 },
  2093. { "baby dancer", 4043 },
  2094. { "super baby", 4045 },
  2095. { "taekwon", 4046 },
  2096. { "taekwon boy", 4046 },
  2097. { "taekwon girl", 4046 },
  2098. { "star gladiator", 4047 },
  2099. { "soul linker", 4049 },
  2100. };
  2101. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2102. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2103. job = jobs[i].id;
  2104. upper = 0;
  2105. found = 1;
  2106. break;
  2107. }
  2108. }
  2109. if (!found) {
  2110. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2111. return -1;
  2112. }
  2113. }
  2114. if (job == 37 ||job == 45)
  2115. return 0;
  2116. if ((job >= 0 && job < MAX_PC_CLASS))
  2117. {
  2118. int j;
  2119. for (j=0; j < MAX_INVENTORY; j++) {
  2120. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2121. pc_unequipitem(sd, j, 3);
  2122. }
  2123. if (pc_jobchange(sd, job, upper) == 0)
  2124. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  2125. else {
  2126. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  2127. return -1;
  2128. }
  2129. } else {
  2130. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2131. return -1;
  2132. }
  2133. return 0;
  2134. }
  2135. /*==========================================
  2136. *
  2137. *------------------------------------------
  2138. */
  2139. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2140. {
  2141. nullpo_retr(-1, sd);
  2142. clif_specialeffect(&sd->bl,450,SELF);
  2143. status_kill(&sd->bl);
  2144. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  2145. return 0;
  2146. }
  2147. /*==========================================
  2148. *
  2149. *------------------------------------------
  2150. */
  2151. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2152. {
  2153. struct map_session_data *pl_sd;
  2154. nullpo_retr(-1, sd);
  2155. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2156. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2157. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2158. return -1;
  2159. }
  2160. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2161. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2162. status_kill(&pl_sd->bl);
  2163. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  2164. } else {
  2165. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2166. return -1;
  2167. }
  2168. } else {
  2169. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2170. return -1;
  2171. }
  2172. return 0;
  2173. }
  2174. /*==========================================
  2175. *
  2176. *------------------------------------------
  2177. */
  2178. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2179. {
  2180. nullpo_retr(-1, sd);
  2181. if (!status_revive(&sd->bl, 100, 100))
  2182. return -1;
  2183. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2184. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  2185. return 0;
  2186. }
  2187. /*==========================================
  2188. * +kamic [LuzZza]
  2189. *------------------------------------------
  2190. */
  2191. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2192. {
  2193. unsigned long color=0;
  2194. nullpo_retr(-1, sd);
  2195. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2196. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2197. if (!message || !*message) {
  2198. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2199. return -1;
  2200. }
  2201. sscanf(message, "%199[^\n]", atcmd_output);
  2202. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2203. } else {
  2204. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2205. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2206. return -1;
  2207. }
  2208. if(color > 0xFFFFFF) {
  2209. clif_displaymessage(fd, "Invalid color.");
  2210. return -1;
  2211. }
  2212. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2213. }
  2214. return 0;
  2215. }
  2216. /*==========================================
  2217. *
  2218. *------------------------------------------
  2219. */
  2220. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2221. {
  2222. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2223. nullpo_retr(-1, sd);
  2224. sscanf(message, "%d %d", &hp, &sp);
  2225. if (hp == 0 && sp == 0) {
  2226. if (!status_percent_heal(&sd->bl, 100, 100))
  2227. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2228. else
  2229. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2230. return 0;
  2231. }
  2232. if(hp > 0 && sp >= 0) {
  2233. if(!status_heal(&sd->bl, hp, sp, 0))
  2234. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2235. else
  2236. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2237. return 0;
  2238. }
  2239. if(hp < 0 && sp <= 0) {
  2240. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2241. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2242. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2243. return 0;
  2244. }
  2245. //Opposing signs.
  2246. if (hp) {
  2247. if (hp > 0)
  2248. status_heal(&sd->bl, hp, 0, 0);
  2249. else {
  2250. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2251. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2252. }
  2253. }
  2254. if (sp) {
  2255. if (sp > 0)
  2256. status_heal(&sd->bl, 0, sp, 0);
  2257. else
  2258. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2259. }
  2260. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2261. return 0;
  2262. }
  2263. /*==========================================
  2264. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2265. *------------------------------------------
  2266. */
  2267. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2268. {
  2269. char item_name[100];
  2270. int number = 0, item_id, flag;
  2271. struct item item_tmp;
  2272. struct item_data *item_data;
  2273. int get_count, i;
  2274. nullpo_retr(-1, sd);
  2275. memset(item_name, '\0', sizeof(item_name));
  2276. if (!message || !*message || (
  2277. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  2278. sscanf(message, "%99s %d", item_name, &number) < 1
  2279. )) {
  2280. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2281. return -1;
  2282. }
  2283. if (number <= 0)
  2284. number = 1;
  2285. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2286. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2287. {
  2288. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2289. return -1;
  2290. }
  2291. item_id = item_data->nameid;
  2292. get_count = number;
  2293. //Check if it's stackable.
  2294. if (!itemdb_isstackable2(item_data))
  2295. get_count = 1;
  2296. for (i = 0; i < number; i += get_count) {
  2297. // if not pet egg
  2298. if (!pet_create_egg(sd, item_id)) {
  2299. memset(&item_tmp, 0, sizeof(item_tmp));
  2300. item_tmp.nameid = item_id;
  2301. item_tmp.identify = 1;
  2302. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2303. clif_additem(sd, 0, 0, flag);
  2304. }
  2305. }
  2306. //Logs (A)dmins items [Lupus]
  2307. if(log_config.enable_logs&0x400)
  2308. log_pick_pc(sd, "A", item_id, number, NULL);
  2309. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2310. return 0;
  2311. }
  2312. /*==========================================
  2313. *
  2314. *------------------------------------------
  2315. */
  2316. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2317. {
  2318. struct item item_tmp;
  2319. struct item_data *item_data;
  2320. char item_name[100];
  2321. int item_id, number = 0;
  2322. int identify = 0, refine = 0, attr = 0;
  2323. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2324. int flag;
  2325. int loop, get_count, i;
  2326. nullpo_retr(-1, sd);
  2327. memset(item_name, '\0', sizeof(item_name));
  2328. if (!message || !*message || (
  2329. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  2330. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  2331. )) {
  2332. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2333. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2334. return -1;
  2335. }
  2336. if (number <= 0)
  2337. number = 1;
  2338. item_id = 0;
  2339. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2340. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2341. item_id = item_data->nameid;
  2342. if (item_id > 500) {
  2343. loop = 1;
  2344. get_count = number;
  2345. if (item_data->type == 4 || item_data->type == 5 ||
  2346. item_data->type == 7 || item_data->type == 8) {
  2347. loop = number;
  2348. get_count = 1;
  2349. if (item_data->type == 7) {
  2350. identify = 1;
  2351. refine = 0;
  2352. }
  2353. if (item_data->type == 8)
  2354. refine = 0;
  2355. if (refine > 10)
  2356. refine = 10;
  2357. } else {
  2358. identify = 1;
  2359. refine = attr = 0;
  2360. }
  2361. for (i = 0; i < loop; i++) {
  2362. memset(&item_tmp, 0, sizeof(item_tmp));
  2363. item_tmp.nameid = item_id;
  2364. item_tmp.identify = identify;
  2365. item_tmp.refine = refine;
  2366. item_tmp.attribute = attr;
  2367. item_tmp.card[0] = c1;
  2368. item_tmp.card[1] = c2;
  2369. item_tmp.card[2] = c3;
  2370. item_tmp.card[3] = c4;
  2371. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2372. clif_additem(sd, 0, 0, flag);
  2373. }
  2374. //Logs (A)dmins items [Lupus]
  2375. if(log_config.enable_logs&0x400)
  2376. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  2377. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2378. } else {
  2379. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2380. return -1;
  2381. }
  2382. return 0;
  2383. }
  2384. /*==========================================
  2385. *
  2386. *------------------------------------------
  2387. */
  2388. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2389. {
  2390. int i;
  2391. nullpo_retr(-1, sd);
  2392. for (i = 0; i < MAX_INVENTORY; i++) {
  2393. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2394. //Logs (A)dmins items [Lupus]
  2395. if(log_config.enable_logs&0x400)
  2396. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2397. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2398. }
  2399. }
  2400. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  2401. return 0;
  2402. }
  2403. /*==========================================
  2404. * Atcommand @lvlup
  2405. *------------------------------------------
  2406. */
  2407. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2408. {
  2409. int level=0, i=0, status_point=0;
  2410. nullpo_retr(-1, sd);
  2411. level = atoi(message);
  2412. if (!message || !*message || !level) {
  2413. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2414. return -1;
  2415. }
  2416. if (level > 0) {
  2417. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2418. clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
  2419. return -1;
  2420. } /* End Addition */
  2421. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2422. level = pc_maxbaselv(sd) - sd->status.base_level;
  2423. for (i = 1; i <= level; i++)
  2424. status_point += (sd->status.base_level + i + 14) / 5;
  2425. if (sd->status.status_point > USHRT_MAX - status_point)
  2426. sd->status.status_point = USHRT_MAX;
  2427. else
  2428. sd->status.status_point += status_point;
  2429. sd->status.base_level += (unsigned int)level;
  2430. clif_updatestatus(sd, SP_BASELEVEL);
  2431. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2432. clif_updatestatus(sd, SP_STATUSPOINT);
  2433. status_calc_pc(sd, 0);
  2434. status_percent_heal(&sd->bl, 100, 100);
  2435. clif_misceffect(&sd->bl, 0);
  2436. clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
  2437. } else {
  2438. if (sd->status.base_level == 1) {
  2439. clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
  2440. return -1;
  2441. }
  2442. level*=-1;
  2443. if ((unsigned int)level >= sd->status.base_level)
  2444. level = sd->status.base_level-1;
  2445. for (i = 0; i > -level; i--)
  2446. status_point += (sd->status.base_level + i + 14) / 5;
  2447. if (sd->status.status_point < status_point)
  2448. pc_resetstate(sd);
  2449. if (sd->status.status_point < status_point)
  2450. sd->status.status_point = 0;
  2451. else
  2452. sd->status.status_point -= status_point;
  2453. clif_updatestatus(sd, SP_STATUSPOINT);
  2454. sd->status.base_level -= (unsigned int)level;
  2455. clif_updatestatus(sd, SP_BASELEVEL);
  2456. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2457. status_calc_pc(sd, 0);
  2458. clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
  2459. }
  2460. return 0;
  2461. }
  2462. /*==========================================
  2463. *
  2464. *------------------------------------------
  2465. */
  2466. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2467. {
  2468. int level=0;
  2469. nullpo_retr(-1, sd);
  2470. level = atoi(message);
  2471. if (!message || !*message || !level) {
  2472. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2473. return -1;
  2474. }
  2475. if (level > 0) {
  2476. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2477. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  2478. return -1;
  2479. }
  2480. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2481. level = pc_maxjoblv(sd) - sd->status.job_level;
  2482. sd->status.job_level += (unsigned int)level;
  2483. clif_updatestatus(sd, SP_JOBLEVEL);
  2484. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2485. if (sd->status.skill_point > USHRT_MAX - level)
  2486. sd->status.skill_point = USHRT_MAX;
  2487. else
  2488. sd->status.skill_point += level;
  2489. clif_updatestatus(sd, SP_SKILLPOINT);
  2490. status_calc_pc(sd, 0);
  2491. clif_misceffect(&sd->bl, 1);
  2492. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  2493. } else {
  2494. if (sd->status.job_level == 1) {
  2495. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  2496. return -1;
  2497. }
  2498. level *=-1;
  2499. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2500. level = sd->status.job_level-1;
  2501. sd->status.job_level -= (unsigned int)level;
  2502. clif_updatestatus(sd, SP_JOBLEVEL);
  2503. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2504. if (sd->status.skill_point < level)
  2505. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2506. if (sd->status.skill_point < level)
  2507. sd->status.skill_point = 0;
  2508. else
  2509. sd->status.skill_point -= level;
  2510. clif_updatestatus(sd, SP_SKILLPOINT);
  2511. status_calc_pc(sd, 0);
  2512. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  2513. }
  2514. return 0;
  2515. }
  2516. /*==========================================
  2517. * @help
  2518. *------------------------------------------
  2519. */
  2520. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2521. {
  2522. char buf[2048], w1[2048], w2[2048];
  2523. int i, gm_level;
  2524. FILE* fp;
  2525. nullpo_retr(-1, sd);
  2526. memset(buf, '\0', sizeof(buf));
  2527. if ((fp = fopen(help_txt, "r")) != NULL) {
  2528. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2529. gm_level = pc_isGM(sd);
  2530. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2531. if (buf[0] == '/' && buf[1] == '/')
  2532. continue;
  2533. for (i = 0; buf[i] != '\0'; i++) {
  2534. if (buf[i] == '\r' || buf[i] == '\n') {
  2535. buf[i] = '\0';
  2536. break;
  2537. }
  2538. }
  2539. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2540. clif_displaymessage(fd, buf);
  2541. else if (gm_level >= atoi(w1))
  2542. clif_displaymessage(fd, w2);
  2543. }
  2544. fclose(fp);
  2545. } else {
  2546. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2547. return -1;
  2548. }
  2549. return 0;
  2550. }
  2551. /*==========================================
  2552. * @help2 - Char commands [Kayla]
  2553. *------------------------------------------
  2554. */
  2555. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2556. {
  2557. char buf[2048], w1[2048], w2[2048];
  2558. int i, gm_level;
  2559. FILE* fp;
  2560. nullpo_retr(-1, sd);
  2561. memset(buf, '\0', sizeof(buf));
  2562. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2563. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2564. gm_level = pc_isGM(sd);
  2565. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2566. if (buf[0] == '/' && buf[1] == '/')
  2567. continue;
  2568. for (i = 0; buf[i] != '\0'; i++) {
  2569. if (buf[i] == '\r' || buf[i] == '\n') {
  2570. buf[i] = '\0';
  2571. break;
  2572. }
  2573. }
  2574. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2575. clif_displaymessage(fd, buf);
  2576. else if (gm_level >= atoi(w1))
  2577. clif_displaymessage(fd, w2);
  2578. }
  2579. fclose(fp);
  2580. } else {
  2581. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2582. return -1;
  2583. }
  2584. return 0;
  2585. }
  2586. /*==========================================
  2587. * @gm
  2588. *------------------------------------------
  2589. */
  2590. int atcommand_gm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2591. {
  2592. char password[100];
  2593. nullpo_retr(-1, sd);
  2594. memset(password, '\0', sizeof(password));
  2595. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2596. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2597. return -1;
  2598. }
  2599. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2600. clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
  2601. return -1;
  2602. } else
  2603. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2604. return 0;
  2605. }
  2606. /*==========================================
  2607. *
  2608. *------------------------------------------
  2609. */
  2610. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) {
  2611. TBL_PC* sd = (TBL_PC*)bl;
  2612. clif_pvpset(sd, 0, 0, 2);
  2613. if (sd->pvp_timer != UINT_MAX) {
  2614. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  2615. sd->pvp_timer = UINT_MAX;
  2616. }
  2617. return 0;
  2618. }
  2619. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2620. {
  2621. nullpo_retr(-1, sd);
  2622. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2623. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2624. return -1;
  2625. }
  2626. if (!map[sd->bl.m].flag.pvp) {
  2627. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2628. return -1;
  2629. }
  2630. map[sd->bl.m].flag.pvp = 0;
  2631. clif_send0199(sd->bl.m, 0);
  2632. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  2633. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2634. return 0;
  2635. }
  2636. /*==========================================
  2637. *
  2638. *------------------------------------------
  2639. */
  2640. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2641. {
  2642. struct map_session_data *pl_sd, **pl_allsd;
  2643. int i, users;
  2644. nullpo_retr(-1, sd);
  2645. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2646. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2647. return -1;
  2648. }
  2649. if (!map[sd->bl.m].flag.pvp) {
  2650. map[sd->bl.m].flag.pvp = 1;
  2651. clif_send0199(sd->bl.m, 1);
  2652. pl_allsd = map_getallusers(&users);
  2653. for (i = 0; i < users; i++) {
  2654. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2655. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2656. pl_sd->pvp_rank = 0;
  2657. pl_sd->pvp_lastusers = 0;
  2658. pl_sd->pvp_point = 5;
  2659. pl_sd->pvp_won = 0;
  2660. pl_sd->pvp_lost = 0;
  2661. }
  2662. }
  2663. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2664. } else {
  2665. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2666. return -1;
  2667. }
  2668. return 0;
  2669. }
  2670. /*==========================================
  2671. *
  2672. *------------------------------------------
  2673. */
  2674. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2675. {
  2676. nullpo_retr(-1, sd);
  2677. if (map[sd->bl.m].flag.gvg) {
  2678. map[sd->bl.m].flag.gvg = 0;
  2679. clif_send0199(sd->bl.m, 0);
  2680. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2681. } else {
  2682. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2683. return -1;
  2684. }
  2685. return 0;
  2686. }
  2687. /*==========================================
  2688. *
  2689. *------------------------------------------
  2690. */
  2691. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2692. {
  2693. nullpo_retr(-1, sd);
  2694. if (!map[sd->bl.m].flag.gvg) {
  2695. map[sd->bl.m].flag.gvg = 1;
  2696. clif_send0199(sd->bl.m, 3);
  2697. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2698. } else {
  2699. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2700. return -1;
  2701. }
  2702. return 0;
  2703. }
  2704. /*==========================================
  2705. *
  2706. *------------------------------------------
  2707. */
  2708. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2709. {
  2710. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2711. nullpo_retr(-1, sd);
  2712. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2713. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2714. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2715. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2716. clif_displaymessage(fd, atcmd_output);
  2717. return -1;
  2718. }
  2719. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2720. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2721. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2722. /* Removed because this check is TOO strange. [Skotlex]
  2723. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2724. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2725. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2726. return -1;
  2727. } else {
  2728. */
  2729. pc_changelook(sd, LOOK_HAIR, hair_style);
  2730. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2731. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2732. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2733. // }
  2734. } else {
  2735. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2736. return -1;
  2737. }
  2738. return 0;
  2739. }
  2740. /*==========================================
  2741. * @dye && @ccolor
  2742. *------------------------------------------
  2743. */
  2744. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2745. {
  2746. int cloth_color = 0;
  2747. nullpo_retr(-1, sd);
  2748. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2749. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2750. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2751. clif_displaymessage(fd, atcmd_output);
  2752. return -1;
  2753. }
  2754. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2755. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2756. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2757. } else {
  2758. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2759. return -1;
  2760. }
  2761. return 0;
  2762. }
  2763. /*==========================================
  2764. * @hairstyle && @hstyle
  2765. *------------------------------------------
  2766. */
  2767. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2768. {
  2769. int hair_style = 0;
  2770. nullpo_retr(-1, sd);
  2771. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2772. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2773. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2774. clif_displaymessage(fd, atcmd_output);
  2775. return -1;
  2776. }
  2777. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2778. /* Removed because this check is TOO strange. [Skotlex]
  2779. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2780. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2781. return -1;
  2782. } else {
  2783. */
  2784. pc_changelook(sd, LOOK_HAIR, hair_style);
  2785. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2786. // }
  2787. } else {
  2788. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2789. return -1;
  2790. }
  2791. return 0;
  2792. }
  2793. /*==========================================
  2794. * @haircolor && @hcolor
  2795. *------------------------------------------
  2796. */
  2797. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2798. {
  2799. int hair_color = 0;
  2800. nullpo_retr(-1, sd);
  2801. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2802. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2803. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2804. clif_displaymessage(fd, atcmd_output);
  2805. return -1;
  2806. }
  2807. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2808. /* Removed for being such a strange check. [Skotlex]
  2809. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2810. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2811. return -1;
  2812. } else {
  2813. */
  2814. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2815. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2816. // }
  2817. } else {
  2818. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2819. return -1;
  2820. }
  2821. return 0;
  2822. }
  2823. /*==========================================
  2824. * @go [city_number or city_name] - Updated by Harbin
  2825. *------------------------------------------
  2826. */
  2827. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2828. {
  2829. int i;
  2830. int town;
  2831. char map_name[MAP_NAME_LENGTH];
  2832. int m;
  2833. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2834. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2835. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2836. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2837. { MAP_PAYON, 162, 233 }, // 3=Payon
  2838. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2839. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2840. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2841. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2842. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2843. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2844. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2845. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2846. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2847. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2848. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2849. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  2850. { MAP_JAIL, 23, 61 }, // 16=Prison
  2851. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2852. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2853. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2854. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2855. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2856. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2857. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2858. { MAP_VEINS, 216, 123 }, // 24=Veins
  2859. };
  2860. nullpo_retr(-1, sd);
  2861. if(map[sd->bl.m].flag.nogo) {
  2862. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2863. return 0;
  2864. }
  2865. memset(map_name, '\0', sizeof(map_name));
  2866. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2867. // get the number
  2868. town = atoi(message);
  2869. // if no value, display all value
  2870. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2871. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2872. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  2873. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2874. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2875. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2876. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2877. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2878. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2879. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2880. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2881. clif_displaymessage(fd, " 24=Veins");
  2882. return -1;
  2883. } else {
  2884. // get possible name of the city and add .gat if not in the name
  2885. map_name[MAP_NAME_LENGTH-1] = '\0';
  2886. for (i = 0; map_name[i]; i++)
  2887. map_name[i] = tolower(map_name[i]);
  2888. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2889. strcat(map_name, ".gat");
  2890. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2891. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2892. town = 0;
  2893. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2894. town = 1;
  2895. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2896. town = 2;
  2897. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2898. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2899. town = 3;
  2900. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2901. town = 4;
  2902. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2903. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2904. town = 5;
  2905. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2906. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2907. town = 6;
  2908. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2909. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2910. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2911. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2912. town = 7;
  2913. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2914. town = 8;
  2915. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2916. town = 9;
  2917. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2918. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2919. town = 10;
  2920. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2921. town = 11;
  2922. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2923. town = 12;
  2924. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2925. town = 13;
  2926. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2927. town = 14;
  2928. } else if (strncmp(map_name, "new_zone01.gat", 3) == 0 || // 3 first characters (or "newbies")
  2929. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2930. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2931. town = 15;
  2932. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2933. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2934. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2935. town = 16;
  2936. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2937. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2938. town = 17;
  2939. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2940. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2941. town = 18;
  2942. } else if (strncmp(map_name, "einbroch.gat", 5) == 0 || // 5 first characters
  2943. strncmp(map_name, "ainbroch.gat", 5) == 0) { // writing error (5 first characters)
  2944. town = 19;
  2945. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2946. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2947. town = 20;
  2948. } else if (strncmp(map_name, "einbech.gat", 3) == 0) { // 3 first characters
  2949. town = 21;
  2950. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2951. town = 22;
  2952. } else if (strncmp(map_name, "rachel.gat", 3) == 0) { // 3 first characters
  2953. town = 23;
  2954. } else if (strncmp(map_name, "veins.gat", 3) == 0) { // 3 first characters
  2955. town = 24;
  2956. }
  2957. if (town >= -3 && town <= -1) {
  2958. if (sd->status.memo_point[-town-1].map) {
  2959. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2960. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2961. clif_displaymessage(fd, msg_txt(247));
  2962. return -1;
  2963. }
  2964. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2965. clif_displaymessage(fd, msg_txt(248));
  2966. return -1;
  2967. }
  2968. 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) {
  2969. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2970. } else {
  2971. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2972. return -1;
  2973. }
  2974. } else {
  2975. sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
  2976. clif_displaymessage(fd, atcmd_output);
  2977. return -1;
  2978. }
  2979. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2980. m = map_mapname2mapid((char *)data[town].map);
  2981. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2982. clif_displaymessage(fd, msg_txt(247));
  2983. return -1;
  2984. }
  2985. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2986. clif_displaymessage(fd, msg_txt(248));
  2987. return -1;
  2988. }
  2989. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2990. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2991. } else {
  2992. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2993. return -1;
  2994. }
  2995. } else { // if you arrive here, you have an error in town variable when reading of names
  2996. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2997. return -1;
  2998. }
  2999. }
  3000. return 0;
  3001. }
  3002. /*==========================================
  3003. *
  3004. *------------------------------------------
  3005. */
  3006. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3007. {
  3008. char name[NAME_LENGTH];
  3009. char monster[NAME_LENGTH];
  3010. int mob_id;
  3011. int number = 0;
  3012. int count;
  3013. int i, k, range;
  3014. short mx, my;
  3015. nullpo_retr(-1, sd);
  3016. memset(name, '\0', sizeof(name));
  3017. memset(monster, '\0', sizeof(monster));
  3018. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3019. if (!message || !*message) {
  3020. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3021. return -1;
  3022. }
  3023. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3024. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3025. //All data can be left as it is.
  3026. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3027. //Here, it is possible name was not given and we are using monster for it.
  3028. if (count < 3) //Blank mob's name.
  3029. name[0] = '\0';
  3030. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3031. //All data can be left as it is.
  3032. } else if (sscanf(message, "%23s", monster) > 0) {
  3033. //As before, name may be already filled.
  3034. name[0] = '\0';
  3035. } else {
  3036. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3037. return -1;
  3038. }
  3039. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3040. mob_id = mobdb_checkid(atoi(monster));
  3041. if (mob_id == 0) {
  3042. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3043. return -1;
  3044. }
  3045. if (mob_id == MOBID_EMPERIUM) {
  3046. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  3047. return -1;
  3048. }
  3049. if (number <= 0)
  3050. number = 1;
  3051. if (strlen(name) < 1)
  3052. strcpy(name, "--ja--");
  3053. // 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
  3054. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3055. number = battle_config.atc_spawn_quantity_limit;
  3056. if (battle_config.etc_log)
  3057. 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);
  3058. count = 0;
  3059. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3060. for (i = 0; i < number; i++) {
  3061. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3062. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3063. count += (k != 0) ? 1 : 0;
  3064. }
  3065. if (count != 0)
  3066. if (number == count)
  3067. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  3068. else {
  3069. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  3070. clif_displaymessage(fd, atcmd_output);
  3071. }
  3072. else {
  3073. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3074. return -1;
  3075. }
  3076. return 0;
  3077. }
  3078. // small monster spawning [Valaris]
  3079. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3080. {
  3081. char name[NAME_LENGTH] = "";
  3082. char monster[NAME_LENGTH] = "";
  3083. int mob_id = 0;
  3084. int number = 0;
  3085. int x = 0;
  3086. int y = 0;
  3087. int count;
  3088. int i;
  3089. nullpo_retr(-1, sd);
  3090. if (!message || !*message) {
  3091. clif_displaymessage(fd, "Give a monster name/id please.");
  3092. return -1;
  3093. }
  3094. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3095. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3096. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3097. clif_displaymessage(fd, "Give a monster name/id please.");
  3098. return -1;
  3099. }
  3100. // If monster identifier/name argument is a name
  3101. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3102. mob_id = atoi(monster);
  3103. if (mob_id == 0) {
  3104. clif_displaymessage(fd, msg_txt(40));
  3105. return -1;
  3106. }
  3107. if (mob_id == MOBID_EMPERIUM) {
  3108. clif_displaymessage(fd, msg_txt(83));
  3109. return -1;
  3110. }
  3111. if (mobdb_checkid(mob_id) == 0) {
  3112. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3113. return -1;
  3114. }
  3115. if (number <= 0)
  3116. number = 1;
  3117. if (strlen(name) < 1)
  3118. strcpy(name, "--ja--");
  3119. // 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
  3120. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3121. number = battle_config.atc_spawn_quantity_limit;
  3122. count = 0;
  3123. for (i = 0; i < number; i++) {
  3124. int mx, my;
  3125. if (x <= 0)
  3126. mx = sd->bl.x + (rand() % 11 - 5);
  3127. else
  3128. mx = x;
  3129. if (y <= 0)
  3130. my = sd->bl.y + (rand() % 11 - 5);
  3131. else
  3132. my = y;
  3133. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3134. }
  3135. if (count != 0)
  3136. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3137. else
  3138. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3139. return 0;
  3140. }
  3141. // big monster spawning [Valaris]
  3142. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3143. {
  3144. char name[NAME_LENGTH] = "";
  3145. char monster[NAME_LENGTH] = "";
  3146. int mob_id = 0;
  3147. int number = 0;
  3148. int x = 0;
  3149. int y = 0;
  3150. int count;
  3151. int i;
  3152. nullpo_retr(-1, sd);
  3153. if (!message || !*message) {
  3154. clif_displaymessage(fd, "Give a monster name/id please.");
  3155. return -1;
  3156. }
  3157. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3158. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3159. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3160. clif_displaymessage(fd, "Give a monster name/id please.");
  3161. return -1;
  3162. }
  3163. // If monster identifier/name argument is a name
  3164. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3165. mob_id = atoi(monster);
  3166. if (mob_id == 0) {
  3167. clif_displaymessage(fd, msg_txt(40));
  3168. return -1;
  3169. }
  3170. if (mob_id == MOBID_EMPERIUM) {
  3171. clif_displaymessage(fd, msg_txt(83));
  3172. return -1;
  3173. }
  3174. if (mobdb_checkid(mob_id) == 0) {
  3175. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3176. return -1;
  3177. }
  3178. if (number <= 0)
  3179. number = 1;
  3180. if (strlen(name) < 1)
  3181. strcpy(name, "--ja--");
  3182. // 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
  3183. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3184. number = battle_config.atc_spawn_quantity_limit;
  3185. count = 0;
  3186. for (i = 0; i < number; i++) {
  3187. int mx, my;
  3188. if (x <= 0)
  3189. mx = sd->bl.x + (rand() % 11 - 5);
  3190. else
  3191. mx = x;
  3192. if (y <= 0)
  3193. my = sd->bl.y + (rand() % 11 - 5);
  3194. else
  3195. my = y;
  3196. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3197. }
  3198. if (count != 0)
  3199. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3200. else
  3201. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3202. return 0;
  3203. }
  3204. /*==========================================
  3205. *
  3206. *------------------------------------------
  3207. */
  3208. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  3209. {
  3210. struct mob_data *md;
  3211. int flag;
  3212. nullpo_retr(0, ap);
  3213. nullpo_retr(0, md=(struct mob_data *)bl);
  3214. flag = va_arg(ap, int);
  3215. if (md->guardian_data)
  3216. return 0; //Do not touch WoE mobs!
  3217. if (flag)
  3218. status_zap(bl,md->status.hp, 0);
  3219. else
  3220. status_kill(bl);
  3221. return 1;
  3222. }
  3223. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  3224. {
  3225. int map_id;
  3226. char map_name[MAP_NAME_LENGTH];
  3227. if (!sd) return;
  3228. memset(map_name, '\0', sizeof(map_name));
  3229. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3230. map_id = sd->bl.m;
  3231. else {
  3232. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3233. strcat(map_name, ".gat");
  3234. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3235. map_id = sd->bl.m;
  3236. }
  3237. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3238. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  3239. return;
  3240. }
  3241. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3242. {
  3243. if (!sd) return 0;
  3244. atcommand_killmonster_sub(fd, sd, message, 1);
  3245. return 0;
  3246. }
  3247. /*==========================================
  3248. *
  3249. *------------------------------------------
  3250. */
  3251. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3252. {
  3253. if (!sd) return 0;
  3254. atcommand_killmonster_sub(fd, sd, message, 0);
  3255. return 0;
  3256. }
  3257. /*==========================================
  3258. *
  3259. *------------------------------------------
  3260. */
  3261. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3262. {
  3263. int i,j, position = 0, refine = 0, current_position, final_refine;
  3264. int count;
  3265. nullpo_retr(-1, sd);
  3266. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3267. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3268. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3269. return -1;
  3270. }
  3271. if (refine < -MAX_REFINE)
  3272. refine = -MAX_REFINE;
  3273. else if (refine > MAX_REFINE)
  3274. refine = MAX_REFINE;
  3275. else if (refine == 0)
  3276. refine = 1;
  3277. count = 0;
  3278. for (j = 0; j < EQI_MAX-1; j++) {
  3279. if ((i = sd->equip_index[j]) < 0)
  3280. continue;
  3281. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  3282. continue;
  3283. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  3284. continue;
  3285. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  3286. continue;
  3287. if(position && !(sd->status.inventory[i].equip & position))
  3288. continue;
  3289. final_refine = sd->status.inventory[i].refine + refine;
  3290. if (final_refine > MAX_REFINE)
  3291. final_refine = MAX_REFINE;
  3292. else if (final_refine < 0)
  3293. final_refine = 0;
  3294. if (sd->status.inventory[i].refine != final_refine) {
  3295. sd->status.inventory[i].refine = final_refine;
  3296. current_position = sd->status.inventory[i].equip;
  3297. pc_unequipitem(sd, i, 3);
  3298. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3299. clif_delitem(sd, i, 1);
  3300. clif_additem(sd, i, 1, 0);
  3301. pc_equipitem(sd, i, current_position);
  3302. clif_misceffect(&sd->bl, 3);
  3303. count++;
  3304. }
  3305. }
  3306. if (count == 0)
  3307. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  3308. else if (count == 1)
  3309. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  3310. else {
  3311. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  3312. clif_displaymessage(fd, atcmd_output);
  3313. }
  3314. return 0;
  3315. }
  3316. /*==========================================
  3317. *
  3318. *------------------------------------------
  3319. */
  3320. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3321. {
  3322. char item_name[100];
  3323. int item_id, attribute = 0, star = 0;
  3324. int flag = 0;
  3325. struct item_data *item_data;
  3326. struct item tmp_item;
  3327. nullpo_retr(-1, sd);
  3328. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3329. memset(item_name, '\0', sizeof(item_name));
  3330. if (!message || !*message || (
  3331. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  3332. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  3333. )) {
  3334. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3335. return -1;
  3336. }
  3337. item_id = 0;
  3338. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  3339. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  3340. {
  3341. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  3342. clif_displaymessage(fd, atcmd_output);
  3343. return -1;
  3344. }
  3345. item_id = item_data->nameid;
  3346. if (itemdb_isequip2(item_data)) {
  3347. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3348. attribute = ATTRIBUTE_NORMAL;
  3349. if (star < MIN_STAR || star > MAX_STAR)
  3350. star = 0;
  3351. memset(&tmp_item, 0, sizeof tmp_item);
  3352. tmp_item.nameid = item_id;
  3353. tmp_item.amount = 1;
  3354. tmp_item.identify = 1;
  3355. tmp_item.card[0] = CARD0_FORGE;
  3356. tmp_item.card[1] = item_data->type==IT_WEAPON?
  3357. ((star*5) << 8) + attribute:0;
  3358. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  3359. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  3360. clif_produceeffect(sd, 0, item_id);
  3361. clif_misceffect(&sd->bl, 3);
  3362. //Logs (A)dmins items [Lupus]
  3363. if(log_config.enable_logs&0x400)
  3364. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  3365. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3366. clif_additem(sd, 0, 0, flag);
  3367. } else {
  3368. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3369. clif_displaymessage(fd, atcmd_output);
  3370. return -1;
  3371. }
  3372. return 0;
  3373. }
  3374. /*==========================================
  3375. * Sub-function to display actual memo points
  3376. *------------------------------------------
  3377. */
  3378. void atcommand_memo_sub(struct map_session_data* sd)
  3379. {
  3380. int i;
  3381. if (!sd) return;
  3382. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3383. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3384. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3385. if (sd->status.memo_point[i].map)
  3386. 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);
  3387. else
  3388. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  3389. clif_displaymessage(sd->fd, atcmd_output);
  3390. }
  3391. return;
  3392. }
  3393. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3394. {
  3395. int position = 0;
  3396. nullpo_retr(-1, sd);
  3397. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3398. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3399. atcommand_memo_sub(sd);
  3400. else {
  3401. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3402. 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)) {
  3403. clif_displaymessage(fd, msg_txt(253));
  3404. return -1;
  3405. }
  3406. if (sd->status.memo_point[position].map) {
  3407. 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).
  3408. clif_displaymessage(fd, atcmd_output);
  3409. }
  3410. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3411. sd->status.memo_point[position].x = sd->bl.x;
  3412. sd->status.memo_point[position].y = sd->bl.y;
  3413. clif_skill_memo(sd, 0);
  3414. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3415. clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
  3416. atcommand_memo_sub(sd);
  3417. } else {
  3418. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3419. clif_displaymessage(fd, atcmd_output);
  3420. atcommand_memo_sub(sd);
  3421. return -1;
  3422. }
  3423. }
  3424. return 0;
  3425. }
  3426. /*==========================================
  3427. *
  3428. *------------------------------------------
  3429. */
  3430. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3431. {
  3432. int y;
  3433. nullpo_retr(-1, sd);
  3434. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3435. for (y = 2; y >= -2; y--) {
  3436. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3437. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3438. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3439. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3440. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3441. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3442. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3443. clif_displaymessage(fd, atcmd_output);
  3444. }
  3445. return 0;
  3446. }
  3447. /*==========================================
  3448. *
  3449. *------------------------------------------
  3450. */
  3451. int atcommand_packet(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3452. {
  3453. static int packet_mode = 0;
  3454. int i, x = 0, y = 0;
  3455. nullpo_retr(-1, sd);
  3456. if (strstr(command, "packetmode")) {
  3457. packet_mode = atoi(message);
  3458. clif_displaymessage(fd, "Packet mode changed.");
  3459. return 0;
  3460. }
  3461. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3462. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3463. return -1;
  3464. }
  3465. if (i == 1) y = 1;
  3466. switch (packet_mode)
  3467. {
  3468. case 0:
  3469. clif_status_change(&sd->bl, x, y);
  3470. break;
  3471. case 1:
  3472. sd->status.skill[sd->cloneskill_id].id=0;
  3473. sd->status.skill[sd->cloneskill_id].lv=0;
  3474. sd->status.skill[sd->cloneskill_id].flag=0;
  3475. sd->cloneskill_id = x;
  3476. sd->status.skill[x].id = x;
  3477. sd->status.skill[x].lv = skill_get_max(x);
  3478. sd->status.skill[x].flag = 13;//cloneskill flag
  3479. clif_skillinfoblock(sd);
  3480. break;
  3481. case 2:
  3482. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3483. case 3:
  3484. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3485. default:
  3486. break;
  3487. //added later
  3488. }
  3489. return 0;
  3490. }
  3491. /*==========================================
  3492. * @waterlevel [Skotlex]
  3493. *------------------------------------------
  3494. */
  3495. int atcommand_waterlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3496. {
  3497. int newlevel;
  3498. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3499. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3500. clif_displaymessage(fd, atcmd_output);
  3501. return 0;
  3502. }
  3503. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3504. if (newlevel > 0)
  3505. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3506. else
  3507. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3508. clif_displaymessage(fd, atcmd_output);
  3509. } else {
  3510. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3511. clif_displaymessage(fd, atcmd_output);
  3512. }
  3513. return 0;
  3514. }
  3515. /*==========================================
  3516. * @stpoint (Rewritten by [Yor])
  3517. *------------------------------------------
  3518. */
  3519. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3520. {
  3521. int point, new_status_point;
  3522. if (!message || !*message || (point = atoi(message)) == 0) {
  3523. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3524. return -1;
  3525. }
  3526. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3527. new_status_point = USHRT_MAX;
  3528. else
  3529. if (point < 0 && sd->status.status_point < -point)
  3530. new_status_point = 0;
  3531. else
  3532. new_status_point = sd->status.status_point + point;
  3533. if (new_status_point != (int)sd->status.status_point) {
  3534. sd->status.status_point = (unsigned short)new_status_point;
  3535. clif_updatestatus(sd, SP_STATUSPOINT);
  3536. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  3537. } else {
  3538. if (point < 0)
  3539. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3540. else
  3541. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3542. return -1;
  3543. }
  3544. return 0;
  3545. }
  3546. /*==========================================
  3547. * @skpoint (Rewritten by [Yor])
  3548. *------------------------------------------
  3549. */
  3550. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3551. {
  3552. int point, new_skill_point;
  3553. nullpo_retr(-1, sd);
  3554. if (!message || !*message || (point = atoi(message)) == 0) {
  3555. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3556. return -1;
  3557. }
  3558. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3559. new_skill_point = USHRT_MAX;
  3560. else if (point < 0 && sd->status.skill_point < -point)
  3561. new_skill_point = 0;
  3562. else
  3563. new_skill_point = sd->status.skill_point + point;
  3564. if (new_skill_point != (int)sd->status.skill_point) {
  3565. sd->status.skill_point = (unsigned short)new_skill_point;
  3566. clif_updatestatus(sd, SP_SKILLPOINT);
  3567. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  3568. } else {
  3569. if (point < 0)
  3570. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3571. else
  3572. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3573. return -1;
  3574. }
  3575. return 0;
  3576. }
  3577. /*==========================================
  3578. * @zeny (Rewritten by [Yor])
  3579. *------------------------------------------
  3580. */
  3581. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3582. {
  3583. int zeny, new_zeny;
  3584. nullpo_retr(-1, sd);
  3585. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3586. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3587. return -1;
  3588. }
  3589. new_zeny = sd->status.zeny + zeny;
  3590. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3591. new_zeny = MAX_ZENY;
  3592. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3593. new_zeny = 0;
  3594. if (new_zeny != sd->status.zeny) {
  3595. sd->status.zeny = new_zeny;
  3596. clif_updatestatus(sd, SP_ZENY);
  3597. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  3598. } else {
  3599. if (zeny < 0)
  3600. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3601. else
  3602. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3603. return -1;
  3604. }
  3605. return 0;
  3606. }
  3607. /*==========================================
  3608. *
  3609. *------------------------------------------
  3610. */
  3611. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3612. {
  3613. int i, value = 0, new_value, max;
  3614. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3615. short* status[6];
  3616. //we don't use direct initialization because it isn't part of the c standard.
  3617. nullpo_retr(-1, sd);
  3618. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3619. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3620. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3621. clif_displaymessage(fd, atcmd_output);
  3622. return -1;
  3623. }
  3624. for (i = 0; param[i] != NULL; i++)
  3625. if (strcmpi(command, param[i]) == 0)
  3626. break;
  3627. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  3628. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3629. clif_displaymessage(fd, atcmd_output);
  3630. return -1;
  3631. }
  3632. status[0] = &sd->status.str;
  3633. status[1] = &sd->status.agi;
  3634. status[2] = &sd->status.vit;
  3635. status[3] = &sd->status.int_;
  3636. status[4] = &sd->status.dex;
  3637. status[5] = &sd->status.luk;
  3638. max = pc_maxparameter(sd);
  3639. new_value = cap_value(*status[i] + value, 1, max);
  3640. if (new_value != (int)*status[i]) {
  3641. *status[i] = new_value;
  3642. clif_updatestatus(sd, SP_STR + i);
  3643. clif_updatestatus(sd, SP_USTR + i);
  3644. status_calc_pc(sd, 0);
  3645. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3646. } else {
  3647. if (value < 0)
  3648. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3649. else
  3650. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3651. return -1;
  3652. }
  3653. return 0;
  3654. }
  3655. /*==========================================
  3656. * Stat all by fritz (rewritten by [Yor])
  3657. *------------------------------------------
  3658. */
  3659. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3660. {
  3661. int index, count, value = 0, max, new_value;
  3662. short* status[6];
  3663. //we don't use direct initialization because it isn't part of the c standard.
  3664. nullpo_retr(-1, sd);
  3665. status[0] = &sd->status.str;
  3666. status[1] = &sd->status.agi;
  3667. status[2] = &sd->status.vit;
  3668. status[3] = &sd->status.int_;
  3669. status[4] = &sd->status.dex;
  3670. status[5] = &sd->status.luk;
  3671. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3672. value = pc_maxparameter(sd);
  3673. count = 0;
  3674. max = pc_maxparameter(sd);
  3675. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3676. if (value > 0 && *status[index] > max - value)
  3677. new_value = max;
  3678. else if (value < 0 && *status[index] <= -value)
  3679. new_value = 1;
  3680. else
  3681. new_value = *status[index] +value;
  3682. if (new_value != (int)*status[index]) {
  3683. *status[index] = new_value;
  3684. clif_updatestatus(sd, SP_STR + index);
  3685. clif_updatestatus(sd, SP_USTR + index);
  3686. status_calc_pc(sd, 0);
  3687. count++;
  3688. }
  3689. }
  3690. if (count > 0) // if at least 1 stat modified
  3691. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3692. else {
  3693. if (value < 0)
  3694. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  3695. else
  3696. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  3697. return -1;
  3698. }
  3699. return 0;
  3700. }
  3701. /*==========================================
  3702. *
  3703. *------------------------------------------
  3704. */
  3705. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3706. {
  3707. int level = 0;
  3708. short added_level;
  3709. struct guild *guild_info;
  3710. nullpo_retr(-1, sd);
  3711. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3712. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3713. return -1;
  3714. }
  3715. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3716. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3717. return -1;
  3718. }
  3719. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3720. clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3721. return -1;
  3722. }
  3723. added_level = (short)level;
  3724. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3725. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3726. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3727. added_level = 1 - guild_info->guild_lv;
  3728. if (added_level != 0) {
  3729. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3730. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3731. } else {
  3732. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3733. return -1;
  3734. }
  3735. return 0;
  3736. }
  3737. /*==========================================
  3738. *
  3739. *------------------------------------------
  3740. */
  3741. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3742. {
  3743. struct item_data *item_data;
  3744. int id, pet_id;
  3745. nullpo_retr(-1, sd);
  3746. if (!message || !*message) {
  3747. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3748. return -1;
  3749. }
  3750. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3751. id = item_data->nameid;
  3752. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3753. id = atoi(message);
  3754. pet_id = search_petDB_index(id, PET_CLASS);
  3755. if (pet_id < 0)
  3756. pet_id = search_petDB_index(id, PET_EGG);
  3757. if (pet_id >= 0) {
  3758. sd->catch_target_class = pet_db[pet_id].class_;
  3759. intif_create_pet(
  3760. sd->status.account_id, sd->status.char_id,
  3761. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3762. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3763. 100, 0, 1, pet_db[pet_id].jname);
  3764. } else {
  3765. clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
  3766. return -1;
  3767. }
  3768. return 0;
  3769. }
  3770. /*==========================================
  3771. *
  3772. *------------------------------------------
  3773. */
  3774. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3775. {
  3776. nullpo_retr(-1, sd);
  3777. if (sd->status.pet_id <= 0)
  3778. clif_sendegg(sd);
  3779. else {
  3780. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3781. return -1;
  3782. }
  3783. return 0;
  3784. }
  3785. /*==========================================
  3786. *
  3787. *------------------------------------------
  3788. */
  3789. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3790. {
  3791. int friendly;
  3792. struct pet_data *pd;
  3793. nullpo_retr(-1, sd);
  3794. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3795. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3796. return -1;
  3797. }
  3798. pd = sd->pd;
  3799. if (!pd) {
  3800. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3801. return -1;
  3802. }
  3803. if (friendly < 0 || friendly > 1000)
  3804. {
  3805. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3806. return -1;
  3807. }
  3808. if (friendly == pd->pet.intimate) {
  3809. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  3810. return -1;
  3811. }
  3812. pd->pet.intimate = friendly;
  3813. clif_send_petstatus(sd);
  3814. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  3815. return 0;
  3816. }
  3817. /*==========================================
  3818. *
  3819. *------------------------------------------
  3820. */
  3821. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3822. {
  3823. int hungry;
  3824. struct pet_data *pd;
  3825. nullpo_retr(-1, sd);
  3826. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3827. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3828. return -1;
  3829. }
  3830. pd = sd->pd;
  3831. if (!sd->status.pet_id || !pd) {
  3832. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3833. return -1;
  3834. }
  3835. if (hungry < 0 || hungry > 100) {
  3836. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3837. return -1;
  3838. }
  3839. if (hungry == pd->pet.hungry) {
  3840. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  3841. return -1;
  3842. }
  3843. pd->pet.hungry = hungry;
  3844. clif_send_petstatus(sd);
  3845. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  3846. return 0;
  3847. }
  3848. /*==========================================
  3849. *
  3850. *------------------------------------------
  3851. */
  3852. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3853. {
  3854. struct pet_data *pd;
  3855. nullpo_retr(-1, sd);
  3856. if (!sd->status.pet_id || !sd->pd) {
  3857. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3858. return -1;
  3859. }
  3860. pd = sd->pd;
  3861. if (!pd->pet.rename_flag) {
  3862. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  3863. return -1;
  3864. }
  3865. pd->pet.rename_flag = 0;
  3866. intif_save_petdata(sd->status.account_id, &pd->pet);
  3867. clif_send_petstatus(sd);
  3868. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  3869. return 0;
  3870. }
  3871. /*==========================================
  3872. *
  3873. *------------------------------------------
  3874. */
  3875. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3876. {
  3877. struct map_session_data *pl_sd = NULL;
  3878. nullpo_retr(-1, sd);
  3879. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3880. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3881. return -1;
  3882. }
  3883. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3884. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3885. return -1;
  3886. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3887. return -1;
  3888. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3889. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3890. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3891. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3892. return -1;
  3893. }
  3894. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3895. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3896. return -1;
  3897. }
  3898. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3899. sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
  3900. clif_displaymessage(fd, atcmd_output);
  3901. } else {
  3902. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3903. return -1;
  3904. }
  3905. } else {
  3906. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3907. return -1;
  3908. }
  3909. return 0;
  3910. }
  3911. /*==========================================
  3912. *
  3913. *------------------------------------------
  3914. */
  3915. int atcommand_revive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3916. {
  3917. struct map_session_data *pl_sd;
  3918. nullpo_retr(-1, sd);
  3919. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3920. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3921. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3922. return -1;
  3923. }
  3924. pl_sd = map_nick2sd(atcmd_player_name);
  3925. if (!pl_sd) {
  3926. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3927. return -1;
  3928. }
  3929. if (!status_revive(&pl_sd->bl, 100, 0))
  3930. return -1;
  3931. clif_skill_nodamage(&sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  3932. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  3933. return 0;
  3934. }
  3935. /*==========================================
  3936. * charblock command (usage: charblock <player_name>)
  3937. * This command do a definitiv ban on a player
  3938. *------------------------------------------
  3939. */
  3940. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3941. {
  3942. nullpo_retr(-1, sd);
  3943. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3944. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  3945. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3946. return -1;
  3947. }
  3948. // check player name
  3949. if (strlen(atcmd_player_name) < 4) {
  3950. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  3951. return -1;
  3952. } else if (strlen(atcmd_player_name) > 23) {
  3953. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  3954. return -1;
  3955. } else {
  3956. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3957. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  3958. }
  3959. return 0;
  3960. }
  3961. /*==========================================
  3962. * charban command (usage: charban <time> <player_name>)
  3963. * This command do a limited ban on a player
  3964. * Time is done as follows:
  3965. * Adjustment value (-1, 1, +1, etc...)
  3966. * Modified element:
  3967. * a or y: year
  3968. * m: month
  3969. * j or d: day
  3970. * h: hour
  3971. * mn: minute
  3972. * s: second
  3973. * <example> @ban +1m-2mn1s-6y test_player
  3974. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3975. *------------------------------------------
  3976. */
  3977. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3978. {
  3979. char * modif_p;
  3980. int year, month, day, hour, minute, second, value;
  3981. nullpo_retr(-1, sd);
  3982. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3983. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3984. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3985. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3986. return -1;
  3987. }
  3988. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3989. modif_p = atcmd_output;
  3990. year = month = day = hour = minute = second = 0;
  3991. while (modif_p[0] != '\0') {
  3992. value = atoi(modif_p);
  3993. if (value == 0)
  3994. modif_p++;
  3995. else {
  3996. if (modif_p[0] == '-' || modif_p[0] == '+')
  3997. modif_p++;
  3998. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3999. modif_p++;
  4000. if (modif_p[0] == 's') {
  4001. second = value;
  4002. modif_p++;
  4003. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4004. minute = value;
  4005. modif_p = modif_p + 2;
  4006. } else if (modif_p[0] == 'h') {
  4007. hour = value;
  4008. modif_p++;
  4009. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4010. day = value;
  4011. modif_p++;
  4012. } else if (modif_p[0] == 'm') {
  4013. month = value;
  4014. modif_p++;
  4015. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4016. year = value;
  4017. modif_p++;
  4018. } else if (modif_p[0] != '\0') {
  4019. modif_p++;
  4020. }
  4021. }
  4022. }
  4023. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4024. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  4025. return -1;
  4026. }
  4027. // check player name
  4028. if (strlen(atcmd_player_name) < 4) {
  4029. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4030. return -1;
  4031. } else if (strlen(atcmd_player_name) > 23) {
  4032. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4033. return -1;
  4034. } else {
  4035. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4036. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4037. }
  4038. return 0;
  4039. }
  4040. /*==========================================
  4041. * charunblock command (usage: charunblock <player_name>)
  4042. *------------------------------------------
  4043. */
  4044. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4045. {
  4046. nullpo_retr(-1, sd);
  4047. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4048. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4049. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4050. return -1;
  4051. }
  4052. // check player name
  4053. if (strlen(atcmd_player_name) < 4) {
  4054. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4055. return -1;
  4056. } else if (strlen(atcmd_player_name) > 23) {
  4057. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4058. return -1;
  4059. } else {
  4060. // send answer to login server via char-server
  4061. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4062. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4063. }
  4064. return 0;
  4065. }
  4066. /*==========================================
  4067. * charunban command (usage: charunban <player_name>)
  4068. *------------------------------------------
  4069. */
  4070. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4071. {
  4072. nullpo_retr(-1, sd);
  4073. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4074. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4075. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4076. return -1;
  4077. }
  4078. // check player name
  4079. if (strlen(atcmd_player_name) < 4) {
  4080. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4081. return -1;
  4082. } else if (strlen(atcmd_player_name) > 23) {
  4083. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4084. return -1;
  4085. } else {
  4086. // send answer to login server via char-server
  4087. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4088. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4089. }
  4090. return 0;
  4091. }
  4092. /*==========================================
  4093. *
  4094. *------------------------------------------
  4095. */
  4096. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4097. {
  4098. nullpo_retr(-1, sd);
  4099. if (night_flag != 1) {
  4100. map_night_timer(night_timer_tid, 0, 0, 1);
  4101. } else {
  4102. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  4103. return -1;
  4104. }
  4105. return 0;
  4106. }
  4107. /*==========================================
  4108. *
  4109. *------------------------------------------
  4110. */
  4111. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4112. {
  4113. nullpo_retr(-1, sd);
  4114. if (night_flag != 0) {
  4115. map_day_timer(day_timer_tid, 0, 0, 1);
  4116. } else {
  4117. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  4118. return -1;
  4119. }
  4120. return 0;
  4121. }
  4122. /*==========================================
  4123. *
  4124. *------------------------------------------
  4125. */
  4126. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4127. {
  4128. struct map_session_data *pl_sd, **pl_allsd;
  4129. int i, users;
  4130. nullpo_retr(-1, sd);
  4131. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4132. pl_allsd = map_getallusers(&users);
  4133. for(i = 0; i < users; i++) {
  4134. 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
  4135. status_kill(&pl_sd->bl);
  4136. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4137. }
  4138. }
  4139. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4140. return 0;
  4141. }
  4142. /*==========================================
  4143. *
  4144. *------------------------------------------
  4145. */
  4146. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4147. {
  4148. struct map_session_data *pl_sd, **pl_allsd;
  4149. int i, users;
  4150. nullpo_retr(-1, sd);
  4151. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4152. pl_allsd = map_getallusers(&users);
  4153. for (i = 0; i < users; i++) {
  4154. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4155. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4156. {
  4157. status_kill(&pl_sd->bl);
  4158. // clif_specialeffect(&pl_sd->bl,450,1);
  4159. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4160. }
  4161. }
  4162. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4163. return 0;
  4164. }
  4165. /*==========================================
  4166. *
  4167. *------------------------------------------
  4168. */
  4169. static void atcommand_raise_sub(struct map_session_data* sd)
  4170. {
  4171. if (!sd->state.auth || !status_isdead(&sd->bl))
  4172. return;
  4173. if(!status_revive(&sd->bl, 100, 100))
  4174. return;
  4175. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4176. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  4177. }
  4178. /*==========================================
  4179. *
  4180. *------------------------------------------
  4181. */
  4182. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4183. {
  4184. int i, users;
  4185. struct map_session_data **all_sd;
  4186. nullpo_retr(-1, sd);
  4187. all_sd = map_getallusers(&users);
  4188. for (i = 0; i < users; i++) {
  4189. atcommand_raise_sub(all_sd[i]);
  4190. }
  4191. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4192. return 0;
  4193. }
  4194. /*==========================================
  4195. *
  4196. *------------------------------------------
  4197. */
  4198. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4199. {
  4200. struct map_session_data **pl_allsd;
  4201. int i, users;
  4202. nullpo_retr(-1, sd);
  4203. pl_allsd = map_getallusers(&users);
  4204. for (i = 0; i < users; i++) {
  4205. if (sd->bl.m == pl_allsd[i]->bl.m)
  4206. atcommand_raise_sub(pl_allsd[i]);
  4207. }
  4208. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4209. return 0;
  4210. }
  4211. /*==========================================
  4212. *
  4213. *------------------------------------------
  4214. */
  4215. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4216. {
  4217. struct map_session_data *pl_sd;
  4218. nullpo_retr(-1, sd);
  4219. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4220. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4221. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4222. return -1;
  4223. }
  4224. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4225. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4226. clif_GM_kick(sd, pl_sd, 1);
  4227. else {
  4228. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4229. return -1;
  4230. }
  4231. } else {
  4232. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4233. return -1;
  4234. }
  4235. return 0;
  4236. }
  4237. /*==========================================
  4238. *
  4239. *------------------------------------------
  4240. */
  4241. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4242. {
  4243. struct map_session_data *pl_sd, **pl_allsd;
  4244. int i, users;
  4245. nullpo_retr(-1, sd);
  4246. pl_allsd = map_getallusers(&users);
  4247. for (i = 0; i < users; i++) {
  4248. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4249. if (sd->status.account_id != pl_sd->status.account_id)
  4250. clif_GM_kick(sd, pl_sd, 0);
  4251. }
  4252. }
  4253. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  4254. return 0;
  4255. }
  4256. /*==========================================
  4257. *
  4258. *------------------------------------------
  4259. */
  4260. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4261. {
  4262. nullpo_retr(-1, sd);
  4263. pc_allskillup(sd); // all skills
  4264. sd->status.skill_point = 0; // 0 skill points
  4265. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4266. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  4267. return 0;
  4268. }
  4269. /*==========================================
  4270. *
  4271. *------------------------------------------
  4272. */
  4273. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4274. {
  4275. int skill_id;
  4276. nullpo_retr(-1, sd);
  4277. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4278. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4279. return -1;
  4280. }
  4281. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4282. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4283. if (pc_checkskill(sd, skill_id) == 0) {
  4284. pc_skill(sd, skill_id, 1, 0);
  4285. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  4286. } else {
  4287. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  4288. return -1;
  4289. }
  4290. } else {
  4291. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4292. return -1;
  4293. }
  4294. } else {
  4295. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4296. return -1;
  4297. }
  4298. return 0;
  4299. }
  4300. /*==========================================
  4301. *
  4302. *------------------------------------------
  4303. */
  4304. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4305. {
  4306. int skill_id;
  4307. nullpo_retr(-1, sd);
  4308. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4309. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4310. return -1;
  4311. }
  4312. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4313. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4314. if (pc_checkskill(sd, skill_id) > 0) {
  4315. sd->status.skill[skill_id].lv = 0;
  4316. sd->status.skill[skill_id].flag = 0;
  4317. clif_skillinfoblock(sd);
  4318. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  4319. } else {
  4320. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  4321. return -1;
  4322. }
  4323. } else {
  4324. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4325. return -1;
  4326. }
  4327. } else {
  4328. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4329. return -1;
  4330. }
  4331. return 0;
  4332. }
  4333. /*==========================================
  4334. *
  4335. *------------------------------------------
  4336. */
  4337. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4338. {
  4339. int number;
  4340. nullpo_retr(-1, sd);
  4341. if (!message || !*message || (number = atoi(message)) < 0) {
  4342. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4343. return -1;
  4344. }
  4345. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4346. if (number > 500)
  4347. number = 500;
  4348. if (number >= 0 && number <= 0x7FFF) {
  4349. if (sd->spiritball != number || number > 499) {
  4350. if (sd->spiritball > 0)
  4351. pc_delspiritball(sd, sd->spiritball, 1);
  4352. sd->spiritball = number;
  4353. clif_spiritball(sd);
  4354. // no message, player can look the difference
  4355. if (number > 1000)
  4356. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4357. } else {
  4358. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  4359. return -1;
  4360. }
  4361. } else {
  4362. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4363. return -1;
  4364. }
  4365. return 0;
  4366. }
  4367. /*==========================================
  4368. *
  4369. *------------------------------------------
  4370. */
  4371. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4372. {
  4373. char party[NAME_LENGTH];
  4374. nullpo_retr(-1, sd);
  4375. memset(party, '\0', sizeof(party));
  4376. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4377. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4378. return -1;
  4379. }
  4380. party_create(sd, party, 0, 0);
  4381. return 0;
  4382. }
  4383. /*==========================================
  4384. *
  4385. *------------------------------------------
  4386. */
  4387. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4388. {
  4389. char guild[NAME_LENGTH];
  4390. int prev;
  4391. nullpo_retr(-1, sd);
  4392. memset(guild, '\0', sizeof(guild));
  4393. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4394. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4395. return -1;
  4396. }
  4397. prev = battle_config.guild_emperium_check;
  4398. battle_config.guild_emperium_check = 0;
  4399. guild_create(sd, guild);
  4400. battle_config.guild_emperium_check = prev;
  4401. return 0;
  4402. }
  4403. /*==========================================
  4404. *
  4405. *------------------------------------------
  4406. */
  4407. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4408. {
  4409. nullpo_retr(-1, sd);
  4410. if (agit_flag == 1) {
  4411. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  4412. return -1;
  4413. }
  4414. agit_flag = 1;
  4415. guild_agit_start();
  4416. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  4417. return 0;
  4418. }
  4419. /*==========================================
  4420. *
  4421. *------------------------------------------
  4422. */
  4423. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4424. {
  4425. nullpo_retr(-1, sd);
  4426. if (agit_flag == 0) {
  4427. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  4428. return -1;
  4429. }
  4430. agit_flag = 0;
  4431. guild_agit_end();
  4432. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  4433. return 0;
  4434. }
  4435. /*==========================================
  4436. * @mapexit - shuts down the map server
  4437. *------------------------------------------
  4438. */
  4439. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4440. {
  4441. struct map_session_data *pl_sd, **pl_allsd;
  4442. int i, users;
  4443. nullpo_retr(-1, sd);
  4444. pl_allsd = map_getallusers(&users);
  4445. for (i = 0; i < users; i++) {
  4446. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4447. clif_GM_kick(sd, pl_sd, 0);
  4448. }
  4449. clif_GM_kick(sd, sd, 0);
  4450. flush_fifos();
  4451. runflag = 0;
  4452. return 0;
  4453. }
  4454. /*==========================================
  4455. * idsearch <part_of_name>: revrited by [Yor]
  4456. *------------------------------------------
  4457. */
  4458. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4459. {
  4460. char item_name[100];
  4461. unsigned int i, match;
  4462. struct item_data *item_array[MAX_SEARCH];
  4463. nullpo_retr(-1, sd);
  4464. memset(item_name, '\0', sizeof(item_name));
  4465. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4466. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4467. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4468. return -1;
  4469. }
  4470. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  4471. clif_displaymessage(fd, atcmd_output);
  4472. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4473. if (match > MAX_SEARCH) {
  4474. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  4475. clif_displaymessage(fd, atcmd_output);
  4476. match = MAX_SEARCH;
  4477. }
  4478. for(i = 0; i < match; i++) {
  4479. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4480. clif_displaymessage(fd, atcmd_output);
  4481. }
  4482. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  4483. clif_displaymessage(fd, atcmd_output);
  4484. return 0;
  4485. }
  4486. /*==========================================
  4487. * Recall All Characters Online To Your Location
  4488. *------------------------------------------
  4489. */
  4490. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4491. {
  4492. struct map_session_data *pl_sd, **pl_allsd;
  4493. int i;
  4494. int count, users;
  4495. nullpo_retr(-1, sd);
  4496. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4497. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4498. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4499. return -1;
  4500. }
  4501. count = 0;
  4502. pl_allsd = map_getallusers(&users);
  4503. for (i = 0; i < users; i++) {
  4504. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4505. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4506. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4507. count++;
  4508. else {
  4509. if (pc_isdead(pl_sd)) { //Wake them up
  4510. pc_setstand(pl_sd);
  4511. pc_setrestartvalue(pl_sd,1);
  4512. }
  4513. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4514. }
  4515. }
  4516. }
  4517. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4518. if (count) {
  4519. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4520. clif_displaymessage(fd, atcmd_output);
  4521. }
  4522. return 0;
  4523. }
  4524. /*==========================================
  4525. * Recall online characters of a guild to your location
  4526. *------------------------------------------
  4527. */
  4528. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4529. {
  4530. struct map_session_data *pl_sd, **pl_allsd;
  4531. int i, users, count;
  4532. char guild_name[NAME_LENGTH];
  4533. struct guild *g;
  4534. nullpo_retr(-1, sd);
  4535. memset(guild_name, '\0', sizeof(guild_name));
  4536. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4537. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4538. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4539. return -1;
  4540. }
  4541. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4542. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4543. return -1;
  4544. }
  4545. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4546. (g = guild_search(atoi(message))) != NULL) {
  4547. count = 0;
  4548. pl_allsd = map_getallusers(&users);
  4549. for (i = 0; i < users; i++) {
  4550. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4551. pl_sd->status.guild_id == g->guild_id) {
  4552. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4553. continue; //Skip GMs greater than you.
  4554. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4555. count++;
  4556. else
  4557. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4558. }
  4559. }
  4560. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  4561. clif_displaymessage(fd, atcmd_output);
  4562. if (count) {
  4563. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4564. clif_displaymessage(fd, atcmd_output);
  4565. }
  4566. } else {
  4567. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4568. return -1;
  4569. }
  4570. return 0;
  4571. }
  4572. /*==========================================
  4573. * Recall online characters of a party to your location
  4574. *------------------------------------------
  4575. */
  4576. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4577. {
  4578. int i;
  4579. struct map_session_data *pl_sd, **pl_allsd;
  4580. char party_name[NAME_LENGTH];
  4581. struct party_data *p;
  4582. int count, users;
  4583. nullpo_retr(-1, sd);
  4584. memset(party_name, '\0', sizeof(party_name));
  4585. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4586. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4587. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4588. return -1;
  4589. }
  4590. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4591. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4592. return -1;
  4593. }
  4594. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4595. (p = party_search(atoi(message))) != NULL) {
  4596. count = 0;
  4597. pl_allsd = map_getallusers(&users);
  4598. for (i = 0; i < users; i++) {
  4599. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4600. pl_sd->status.party_id == p->party.party_id) {
  4601. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4602. continue; //Skip GMs greater than you.
  4603. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4604. count++;
  4605. else
  4606. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4607. }
  4608. }
  4609. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  4610. clif_displaymessage(fd, atcmd_output);
  4611. if (count) {
  4612. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4613. clif_displaymessage(fd, atcmd_output);
  4614. }
  4615. } else {
  4616. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4617. return -1;
  4618. }
  4619. return 0;
  4620. }
  4621. /*==========================================
  4622. *
  4623. *------------------------------------------
  4624. */
  4625. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4626. {
  4627. nullpo_retr(-1, sd);
  4628. itemdb_reload();
  4629. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  4630. return 0;
  4631. }
  4632. /*==========================================
  4633. *
  4634. *------------------------------------------
  4635. */
  4636. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4637. {
  4638. nullpo_retr(-1, sd);
  4639. mob_reload();
  4640. read_petdb();
  4641. merc_reload();
  4642. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  4643. return 0;
  4644. }
  4645. /*==========================================
  4646. *
  4647. *------------------------------------------
  4648. */
  4649. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4650. {
  4651. nullpo_retr(-1, sd);
  4652. skill_reload();
  4653. merc_skill_reload();
  4654. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  4655. return 0;
  4656. }
  4657. /*==========================================
  4658. * @reloadatcommand - reloads atcommand_athena.conf
  4659. *------------------------------------------
  4660. */
  4661. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4662. {
  4663. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4664. clif_displaymessage(fd, msg_txt(254));
  4665. return 0;
  4666. }
  4667. /*==========================================
  4668. * @reloadbattleconf - reloads battle_athena.conf
  4669. *------------------------------------------
  4670. */
  4671. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4672. {
  4673. struct Battle_Config prev_config;
  4674. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4675. battle_config_read(BATTLE_CONF_FILENAME);
  4676. if (memcmp(&prev_config.item_rate_mvp,
  4677. &battle_config.item_rate_mvp,
  4678. sizeof(battle_config.item_rate_mvp)+
  4679. sizeof(battle_config.item_rate_common)+
  4680. sizeof(battle_config.item_rate_common_boss)+
  4681. sizeof(battle_config.item_rate_card)+
  4682. sizeof(battle_config.item_rate_card_boss)+
  4683. sizeof(battle_config.item_rate_equip)+
  4684. sizeof(battle_config.item_rate_equip_boss)+
  4685. sizeof(battle_config.item_rate_heal)+
  4686. sizeof(battle_config.item_rate_heal_boss)+
  4687. sizeof(battle_config.item_rate_use)+
  4688. sizeof(battle_config.item_rate_use_boss)+
  4689. sizeof(battle_config.item_rate_treasure)+
  4690. sizeof(battle_config.item_rate_adddrop)+
  4691. sizeof(battle_config.logarithmic_drops)+
  4692. sizeof(battle_config.item_drop_common_min)+
  4693. sizeof(battle_config.item_drop_common_max)+
  4694. sizeof(battle_config.item_drop_card_min)+
  4695. sizeof(battle_config.item_drop_card_max)+
  4696. sizeof(battle_config.item_drop_equip_min)+
  4697. sizeof(battle_config.item_drop_equip_max)+
  4698. sizeof(battle_config.item_drop_mvp_min)+
  4699. sizeof(battle_config.item_drop_mvp_max)+
  4700. sizeof(battle_config.item_drop_heal_min)+
  4701. sizeof(battle_config.item_drop_heal_max)+
  4702. sizeof(battle_config.item_drop_use_min)+
  4703. sizeof(battle_config.item_drop_use_max)+
  4704. sizeof(battle_config.item_drop_treasure_min)+
  4705. sizeof(battle_config.item_drop_treasure_max)
  4706. ) != 0)
  4707. { //Drop rates changed.
  4708. mob_reload(); //Needed as well so rate changes take effect.
  4709. #ifndef TXT_ONLY
  4710. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4711. #endif
  4712. }
  4713. clif_displaymessage(fd, msg_txt(255));
  4714. return 0;
  4715. }
  4716. /*==========================================
  4717. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  4718. *------------------------------------------
  4719. */
  4720. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4721. {
  4722. status_readdb();
  4723. clif_displaymessage(fd, msg_txt(256));
  4724. return 0;
  4725. }
  4726. /*==========================================
  4727. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt
  4728. *------------------------------------------
  4729. */
  4730. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4731. {
  4732. pc_readdb();
  4733. clif_displaymessage(fd, msg_txt(257));
  4734. return 0;
  4735. }
  4736. /*==========================================
  4737. * @reloadmotd - reloads motd.txt
  4738. *------------------------------------------
  4739. */
  4740. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4741. {
  4742. pc_read_motd();
  4743. clif_displaymessage(fd, msg_txt(268));
  4744. return 0;
  4745. }
  4746. /*==========================================
  4747. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  4748. *------------------------------------------
  4749. */
  4750. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4751. {
  4752. nullpo_retr(-1, sd);
  4753. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4754. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4755. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4756. flush_fifos();
  4757. script_reload();
  4758. npc_reload();
  4759. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  4760. return 0;
  4761. }
  4762. /*==========================================
  4763. * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database)
  4764. *------------------------------------------
  4765. */
  4766. int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4767. {
  4768. nullpo_retr(-1, sd);
  4769. chrif_reloadGMdb();
  4770. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  4771. return 0;
  4772. }
  4773. /*==========================================
  4774. * @mapinfo <map name> [0-3] by MC_Cameri
  4775. * => Shows information about the map [map name]
  4776. * 0 = no additional information
  4777. * 1 = Show users in that map and their location
  4778. * 2 = Shows NPCs in that map
  4779. * 3 = Shows the shops/chats in that map (not implemented)
  4780. *------------------------------------------
  4781. */
  4782. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4783. {
  4784. struct map_session_data *pl_sd, **pl_allsd;
  4785. struct npc_data *nd = NULL;
  4786. struct chat_data *cd = NULL;
  4787. char direction[12];
  4788. int m_id, i, chat_num, users, list = 0;
  4789. unsigned short m_index;
  4790. nullpo_retr(-1, sd);
  4791. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4792. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4793. memset(direction, '\0', sizeof(direction));
  4794. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4795. if (list < 0 || list > 3) {
  4796. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4797. return -1;
  4798. }
  4799. if (atcmd_player_name[0] == '\0') {
  4800. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4801. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4802. m_id = map_mapindex2mapid(sd->mapindex);
  4803. } else {
  4804. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4805. strcat(atcmd_player_name, ".gat");
  4806. m_id = map_mapname2mapid(atcmd_player_name);
  4807. }
  4808. if (m_id < 0) {
  4809. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  4810. return -1;
  4811. }
  4812. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4813. clif_displaymessage(fd, "------ Map Info ------");
  4814. chat_num = 0;
  4815. pl_allsd = map_getallusers(&users);
  4816. for (i = 0; i < users; i++) {
  4817. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4818. chat_num++;
  4819. }
  4820. }
  4821. 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);
  4822. clif_displaymessage(fd, atcmd_output);
  4823. if (map[m_id].flag.alias)
  4824. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4825. clif_displaymessage(fd, "------ Map Flags ------");
  4826. strcpy(atcmd_output,"PvP Flags: ");
  4827. if (map[m_id].flag.pvp)
  4828. strcat(atcmd_output, "Pvp ON | ");
  4829. if (map[m_id].flag.pvp_noguild)
  4830. strcat(atcmd_output, "NoGuild | ");
  4831. if (map[m_id].flag.pvp_noparty)
  4832. strcat(atcmd_output, "NoParty | ");
  4833. if (map[m_id].flag.pvp_nightmaredrop)
  4834. strcat(atcmd_output, "NightmareDrop | ");
  4835. if (map[m_id].flag.pvp_nocalcrank)
  4836. strcat(atcmd_output, "NoCalcRank | ");
  4837. clif_displaymessage(fd, atcmd_output);
  4838. strcpy(atcmd_output,"GvG Flags: ");
  4839. if (map[m_id].flag.gvg)
  4840. strcat(atcmd_output, "GvG ON | ");
  4841. if (map[m_id].flag.gvg_dungeon)
  4842. strcat(atcmd_output, "GvG Dungeon | ");
  4843. if (map[m_id].flag.gvg_castle)
  4844. strcat(atcmd_output, "GvG Castle | ");
  4845. if (map[m_id].flag.gvg_noparty)
  4846. strcat(atcmd_output, "NoParty | ");
  4847. clif_displaymessage(fd, atcmd_output);
  4848. strcpy(atcmd_output,"Teleport Flags: ");
  4849. if (map[m_id].flag.noteleport)
  4850. strcat(atcmd_output, "NoTeleport | ");
  4851. if (map[m_id].flag.monster_noteleport)
  4852. strcat(atcmd_output, "Monster NoTeleport | ");
  4853. if (map[m_id].flag.nowarp)
  4854. strcat(atcmd_output, "NoWarp | ");
  4855. if (map[m_id].flag.nowarpto)
  4856. strcat(atcmd_output, "NoWarpTo | ");
  4857. if (map[m_id].flag.noreturn)
  4858. strcat(atcmd_output, "NoReturn | ");
  4859. if (map[m_id].flag.nogo)
  4860. strcat(atcmd_output, "NoGo | ");
  4861. if (map[m_id].flag.nomemo)
  4862. strcat(atcmd_output, "NoMemo | ");
  4863. clif_displaymessage(fd, atcmd_output);
  4864. 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");
  4865. clif_displaymessage(fd, atcmd_output);
  4866. if (map[m_id].flag.nosave) {
  4867. if (!map[m_id].save.map)
  4868. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  4869. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4870. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4871. else
  4872. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4873. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4874. clif_displaymessage(fd, atcmd_output);
  4875. }
  4876. strcpy(atcmd_output,"Weather Flags: ");
  4877. if (map[m_id].flag.snow)
  4878. strcat(atcmd_output, "Snow | ");
  4879. if (map[m_id].flag.fog)
  4880. strcat(atcmd_output, "Fog | ");
  4881. if (map[m_id].flag.sakura)
  4882. strcat(atcmd_output, "Sakura | ");
  4883. if (map[m_id].flag.clouds)
  4884. strcat(atcmd_output, "Clouds | ");
  4885. if (map[m_id].flag.clouds2)
  4886. strcat(atcmd_output, "Clouds2 | ");
  4887. if (map[m_id].flag.fireworks)
  4888. strcat(atcmd_output, "Fireworks | ");
  4889. if (map[m_id].flag.leaves)
  4890. strcat(atcmd_output, "Leaves | ");
  4891. if (map[m_id].flag.rain)
  4892. strcat(atcmd_output, "Rain | ");
  4893. if (map[m_id].flag.indoors)
  4894. strcat(atcmd_output, "Indoors | ");
  4895. if (map[m_id].flag.nightenabled)
  4896. strcat(atcmd_output, "Displays Night | ");
  4897. clif_displaymessage(fd, atcmd_output);
  4898. strcpy(atcmd_output,"Other Flags: ");
  4899. if (map[m_id].flag.nobranch)
  4900. strcat(atcmd_output, "NoBranch | ");
  4901. if (map[m_id].flag.notrade)
  4902. strcat(atcmd_output, "NoTrade | ");
  4903. if (map[m_id].flag.novending)
  4904. strcat(atcmd_output, "NoVending | ");
  4905. if (map[m_id].flag.nodrop)
  4906. strcat(atcmd_output, "NoDrop | ");
  4907. if (map[m_id].flag.noskill)
  4908. strcat(atcmd_output, "NoSkill | ");
  4909. if (map[m_id].flag.noicewall)
  4910. strcat(atcmd_output, "NoIcewall | ");
  4911. clif_displaymessage(fd, atcmd_output);
  4912. strcpy(atcmd_output,"Other Flags: ");
  4913. if (map[m_id].nocommand)
  4914. strcat(atcmd_output, "NoCommand | ");
  4915. if (map[m_id].flag.nobaseexp)
  4916. strcat(atcmd_output, "NoBaseEXP | ");
  4917. if (map[m_id].flag.nojobexp)
  4918. strcat(atcmd_output, "NoJobEXP | ");
  4919. if (map[m_id].flag.nomobloot)
  4920. strcat(atcmd_output, "NoMobLoot | ");
  4921. if (map[m_id].flag.nomvploot)
  4922. strcat(atcmd_output, "NoMVPLoot | ");
  4923. if (map[m_id].flag.partylock)
  4924. strcat(atcmd_output, "PartyLock | ");
  4925. if (map[m_id].flag.guildlock)
  4926. strcat(atcmd_output, "GuildLock | ");
  4927. clif_displaymessage(fd, atcmd_output);
  4928. switch (list) {
  4929. case 0:
  4930. // Do nothing. It's list 0, no additional display.
  4931. break;
  4932. case 1:
  4933. clif_displaymessage(fd, "----- Players in Map -----");
  4934. for (i = 0; i < users; i++) {
  4935. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  4936. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  4937. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4938. clif_displaymessage(fd, atcmd_output);
  4939. }
  4940. }
  4941. break;
  4942. case 2:
  4943. clif_displaymessage(fd, "----- NPCs in Map -----");
  4944. for (i = 0; i < map[m_id].npc_num;) {
  4945. nd = map[m_id].npc[i];
  4946. switch(nd->ud.dir) {
  4947. case 0: strcpy(direction, "North"); break;
  4948. case 1: strcpy(direction, "North West"); break;
  4949. case 2: strcpy(direction, "West"); break;
  4950. case 3: strcpy(direction, "South West"); break;
  4951. case 4: strcpy(direction, "South"); break;
  4952. case 5: strcpy(direction, "South East"); break;
  4953. case 6: strcpy(direction, "East"); break;
  4954. case 7: strcpy(direction, "North East"); break;
  4955. case 9: strcpy(direction, "North"); break;
  4956. default: strcpy(direction, "Unknown"); break;
  4957. }
  4958. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  4959. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4960. clif_displaymessage(fd, atcmd_output);
  4961. }
  4962. break;
  4963. case 3:
  4964. clif_displaymessage(fd, "----- Chats in Map -----");
  4965. for (i = 0; i < users; i++) {
  4966. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  4967. pl_sd->mapindex == m_index &&
  4968. cd->usersd[0] == pl_sd) {
  4969. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  4970. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4971. clif_displaymessage(fd, atcmd_output);
  4972. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4973. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4974. clif_displaymessage(fd, atcmd_output);
  4975. }
  4976. }
  4977. break;
  4978. default: // normally impossible to arrive here
  4979. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4980. return -1;
  4981. break;
  4982. }
  4983. return 0;
  4984. }
  4985. /*==========================================
  4986. *
  4987. *------------------------------------------
  4988. */
  4989. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4990. {
  4991. nullpo_retr(-1, sd);
  4992. if (!pc_isriding(sd)) { // if actually no peco
  4993. if (pc_checkskill(sd, KN_RIDING)) {
  4994. pc_setoption(sd, sd->sc.option | 0x0020);
  4995. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  4996. } else {
  4997. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  4998. return -1;
  4999. }
  5000. } else { //Dismount
  5001. pc_setoption(sd, sd->sc.option & ~0x0020);
  5002. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  5003. }
  5004. return 0;
  5005. }
  5006. /*==========================================
  5007. *
  5008. *------------------------------------------
  5009. */
  5010. int atcommand_char_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5011. {
  5012. struct map_session_data *pl_sd;
  5013. nullpo_retr(-1, sd);
  5014. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5015. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5016. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5017. return -1;
  5018. }
  5019. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5020. if (!pc_isriding(pl_sd)) { // if actually no peco
  5021. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5022. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5023. clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
  5024. } else {
  5025. clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
  5026. return -1;
  5027. }
  5028. } else { //Dismount
  5029. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5030. clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
  5031. }
  5032. } else {
  5033. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5034. return -1;
  5035. }
  5036. return 0;
  5037. }
  5038. /*==========================================
  5039. *Spy Commands by Syrus22
  5040. *------------------------------------------
  5041. */
  5042. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5043. {
  5044. char guild_name[NAME_LENGTH];
  5045. struct guild *g;
  5046. nullpo_retr(-1, sd);
  5047. memset(guild_name, '\0', sizeof(guild_name));
  5048. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5049. if (!enable_spy)
  5050. {
  5051. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5052. return -1;
  5053. }
  5054. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5055. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5056. return -1;
  5057. }
  5058. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5059. (g = guild_search(atoi(message))) != NULL) {
  5060. if (sd->guildspy == g->guild_id) {
  5061. sd->guildspy = 0;
  5062. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  5063. clif_displaymessage(fd, atcmd_output);
  5064. } else {
  5065. sd->guildspy = g->guild_id;
  5066. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  5067. clif_displaymessage(fd, atcmd_output);
  5068. }
  5069. } else {
  5070. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  5071. return -1;
  5072. }
  5073. return 0;
  5074. }
  5075. /*==========================================
  5076. *
  5077. *------------------------------------------
  5078. */
  5079. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5080. {
  5081. char party_name[NAME_LENGTH];
  5082. struct party_data *p;
  5083. nullpo_retr(-1, sd);
  5084. memset(party_name, '\0', sizeof(party_name));
  5085. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5086. if (!enable_spy)
  5087. {
  5088. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5089. return -1;
  5090. }
  5091. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5092. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5093. return -1;
  5094. }
  5095. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5096. (p = party_search(atoi(message))) != NULL) {
  5097. if (sd->partyspy == p->party.party_id) {
  5098. sd->partyspy = 0;
  5099. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  5100. clif_displaymessage(fd, atcmd_output);
  5101. } else {
  5102. sd->partyspy = p->party.party_id;
  5103. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  5104. clif_displaymessage(fd, atcmd_output);
  5105. }
  5106. } else {
  5107. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  5108. return -1;
  5109. }
  5110. return 0;
  5111. }
  5112. /*==========================================
  5113. * @repairall [Valaris]
  5114. *------------------------------------------
  5115. */
  5116. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5117. {
  5118. int count, i;
  5119. nullpo_retr(-1, sd);
  5120. count = 0;
  5121. for (i = 0; i < MAX_INVENTORY; i++) {
  5122. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5123. sd->status.inventory[i].attribute = 0;
  5124. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5125. count++;
  5126. }
  5127. }
  5128. if (count > 0) {
  5129. clif_misceffect(&sd->bl, 3);
  5130. clif_equiplist(sd);
  5131. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  5132. } else {
  5133. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  5134. return -1;
  5135. }
  5136. return 0;
  5137. }
  5138. /*==========================================
  5139. * @nuke [Valaris]
  5140. *------------------------------------------
  5141. */
  5142. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5143. {
  5144. struct map_session_data *pl_sd;
  5145. nullpo_retr(-1, sd);
  5146. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5147. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5148. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5149. return -1;
  5150. }
  5151. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5152. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5153. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5154. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  5155. } else {
  5156. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5157. return -1;
  5158. }
  5159. } else {
  5160. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5161. return -1;
  5162. }
  5163. return 0;
  5164. }
  5165. /*==========================================
  5166. * @tonpc
  5167. *------------------------------------------
  5168. */
  5169. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5170. {
  5171. char npcname[NAME_LENGTH];
  5172. struct npc_data *nd;
  5173. nullpo_retr(-1, sd);
  5174. memset(npcname, 0, sizeof(npcname));
  5175. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5176. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5177. return -1;
  5178. }
  5179. if ((nd = npc_name2id(npcname)) != NULL) {
  5180. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5181. clif_displaymessage(fd, msg_txt(0)); // Warped.
  5182. else
  5183. return -1;
  5184. } else {
  5185. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5186. return -1;
  5187. }
  5188. return 0;
  5189. }
  5190. /*==========================================
  5191. *
  5192. *------------------------------------------
  5193. */
  5194. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5195. {
  5196. char NPCname[NAME_LENGTH];
  5197. nullpo_retr(-1, sd);
  5198. memset(NPCname, '\0', sizeof(NPCname));
  5199. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5200. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5201. return -1;
  5202. }
  5203. if (npc_name2id(NPCname) != NULL) {
  5204. npc_enable(NPCname, 1);
  5205. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  5206. } else {
  5207. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5208. return -1;
  5209. }
  5210. return 0;
  5211. }
  5212. /*==========================================
  5213. *
  5214. *------------------------------------------
  5215. */
  5216. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5217. {
  5218. char NPCname[NAME_LENGTH];
  5219. nullpo_retr(-1, sd);
  5220. memset(NPCname, '\0', sizeof(NPCname));
  5221. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5222. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  5223. return -1;
  5224. }
  5225. if (npc_name2id(NPCname) != NULL) {
  5226. npc_enable(NPCname, 0);
  5227. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5228. } else {
  5229. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5230. return -1;
  5231. }
  5232. return 0;
  5233. }
  5234. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5235. {
  5236. FILE *fp;
  5237. if (!message || !*message) {
  5238. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5239. return -1;
  5240. }
  5241. // check if script file exists
  5242. if ((fp = fopen(message, "r")) == NULL) {
  5243. clif_displaymessage(fd, msg_txt(261));
  5244. return -1;
  5245. }
  5246. fclose(fp);
  5247. // add to list of script sources and run it
  5248. npc_addsrcfile((char *)message);
  5249. npc_parsesrcfile((char *)message);
  5250. clif_displaymessage(fd, msg_txt(262));
  5251. return 0;
  5252. }
  5253. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5254. {
  5255. struct npc_data *nd;
  5256. char NPCname[NAME_LENGTH];
  5257. nullpo_retr(-1, sd);
  5258. memset(NPCname, '\0', sizeof(NPCname));
  5259. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5260. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5261. return -1;
  5262. }
  5263. if ((nd = npc_name2id(NPCname)) != NULL) {
  5264. npc_unload_duplicates(nd);
  5265. npc_unload(nd);
  5266. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5267. } else {
  5268. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5269. return -1;
  5270. }
  5271. return 0;
  5272. }
  5273. /*==========================================
  5274. * time in txt for time command (by [Yor])
  5275. *------------------------------------------
  5276. */
  5277. char * txt_time(unsigned int duration)
  5278. {
  5279. int days, hours, minutes, seconds;
  5280. char temp[256];
  5281. static char temp1[256];
  5282. memset(temp, '\0', sizeof(temp));
  5283. memset(temp1, '\0', sizeof(temp1));
  5284. days = duration / (60 * 60 * 24);
  5285. duration = duration - (60 * 60 * 24 * days);
  5286. hours = duration / (60 * 60);
  5287. duration = duration - (60 * 60 * hours);
  5288. minutes = duration / 60;
  5289. seconds = duration - (60 * minutes);
  5290. if (days < 2)
  5291. sprintf(temp, msg_txt(219), days); // %d day
  5292. else
  5293. sprintf(temp, msg_txt(220), days); // %d days
  5294. if (hours < 2)
  5295. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  5296. else
  5297. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  5298. if (minutes < 2)
  5299. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  5300. else
  5301. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  5302. if (seconds < 2)
  5303. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  5304. else
  5305. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  5306. return temp1;
  5307. }
  5308. /*==========================================
  5309. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5310. * Calculation management of GM modification (@day/@night GM commands) is done
  5311. *------------------------------------------
  5312. */
  5313. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5314. {
  5315. struct TimerData * timer_data;
  5316. struct TimerData * timer_data2;
  5317. time_t time_server; // variable for number of seconds (used with time() function)
  5318. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5319. char temp[256];
  5320. nullpo_retr(-1, sd);
  5321. memset(temp, '\0', sizeof(temp));
  5322. time(&time_server); // get time in seconds since 1/1/1970
  5323. datetime = localtime(&time_server); // convert seconds in structure
  5324. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5325. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  5326. clif_displaymessage(fd, temp);
  5327. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5328. if (night_flag == 0)
  5329. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5330. else
  5331. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5332. } else if (battle_config.night_duration == 0)
  5333. if (night_flag == 1) { // we start with night
  5334. timer_data = get_timer(day_timer_tid);
  5335. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5336. clif_displaymessage(fd, temp);
  5337. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  5338. } else
  5339. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5340. else if (battle_config.day_duration == 0)
  5341. if (night_flag == 0) { // we start with day
  5342. timer_data = get_timer(night_timer_tid);
  5343. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5344. clif_displaymessage(fd, temp);
  5345. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  5346. } else
  5347. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5348. else {
  5349. if (night_flag == 0) {
  5350. timer_data = get_timer(night_timer_tid);
  5351. timer_data2 = get_timer(day_timer_tid);
  5352. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5353. clif_displaymessage(fd, temp);
  5354. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5355. 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.
  5356. else
  5357. 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.
  5358. clif_displaymessage(fd, temp);
  5359. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5360. clif_displaymessage(fd, temp);
  5361. } else {
  5362. timer_data = get_timer(day_timer_tid);
  5363. timer_data2 = get_timer(night_timer_tid);
  5364. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5365. clif_displaymessage(fd, temp);
  5366. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5367. 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.
  5368. else
  5369. 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.
  5370. clif_displaymessage(fd, temp);
  5371. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5372. clif_displaymessage(fd, temp);
  5373. }
  5374. }
  5375. return 0;
  5376. }
  5377. /*==========================================
  5378. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5379. * removes <quantity> item from a character
  5380. * item can be equiped or not.
  5381. * Inspired from a old command created by RoVeRT
  5382. *------------------------------------------
  5383. */
  5384. int atcommand_chardelitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5385. {
  5386. struct map_session_data *pl_sd;
  5387. char item_name[100];
  5388. int i, number = 0, item_id, item_position, count;
  5389. struct item_data *item_data;
  5390. nullpo_retr(-1, sd);
  5391. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5392. memset(item_name, '\0', sizeof(item_name));
  5393. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5394. if (!message || !*message || (
  5395. sscanf(message, "\"%99[^\"]\" %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 &&
  5396. sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3
  5397. ) || number < 1) {
  5398. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5399. return -1;
  5400. }
  5401. item_id = 0;
  5402. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5403. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5404. item_id = item_data->nameid;
  5405. if (item_id > 500) {
  5406. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5407. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5408. item_position = pc_search_inventory(pl_sd, item_id);
  5409. if (item_position >= 0) {
  5410. count = 0;
  5411. for(i = 0; i < number && item_position >= 0; i++) {
  5412. //Logs (A)dmins items [Lupus]
  5413. if(log_config.enable_logs&0x400)
  5414. log_pick_pc(pl_sd, "A", pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5415. pc_delitem(pl_sd, item_position, 1, 0);
  5416. count++;
  5417. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5418. }
  5419. sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
  5420. clif_displaymessage(pl_sd->fd, atcmd_output);
  5421. if (number == count)
  5422. sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
  5423. else
  5424. sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5425. clif_displaymessage(fd, atcmd_output);
  5426. } else {
  5427. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  5428. return -1;
  5429. }
  5430. } else {
  5431. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5432. return -1;
  5433. }
  5434. } else {
  5435. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5436. return -1;
  5437. }
  5438. } else {
  5439. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  5440. return -1;
  5441. }
  5442. return 0;
  5443. }
  5444. //Added by Coltaro
  5445. //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...).
  5446. //Well, using time_t could still work but for some reason that looks like more coding x_x
  5447. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  5448. {
  5449. const int factor_year = 518400; //12*30*24*60 = 518400
  5450. const int factor_month = 43200; //30*24*60 = 43200
  5451. const int factor_day = 1440; //24*60 = 1440
  5452. const int factor_hour = 60;
  5453. *year = jailtime/factor_year;
  5454. jailtime -= *year*factor_year;
  5455. *month = jailtime/factor_month;
  5456. jailtime -= *month*factor_month;
  5457. *day = jailtime/factor_day;
  5458. jailtime -= *day*factor_day;
  5459. *hour = jailtime/factor_hour;
  5460. jailtime -= *hour*factor_hour;
  5461. *minute = jailtime;
  5462. *year = *year > 0? *year : 0;
  5463. *month = *month > 0? *month : 0;
  5464. *day = *day > 0? *day : 0;
  5465. *hour = *hour > 0? *hour : 0;
  5466. *minute = *minute > 0? *minute : 0;
  5467. return;
  5468. }
  5469. /*==========================================
  5470. * @jail <char_name> by [Yor]
  5471. * Special warp! No check with nowarp and nowarpto flag
  5472. *------------------------------------------
  5473. */
  5474. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5475. {
  5476. struct map_session_data *pl_sd;
  5477. int x, y;
  5478. unsigned short m_index;
  5479. nullpo_retr(-1, sd);
  5480. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5481. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5482. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5483. return -1;
  5484. }
  5485. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5486. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5487. return -1;
  5488. }
  5489. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5490. { // you can jail only lower or same GM
  5491. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5492. return -1;
  5493. }
  5494. if (pl_sd->mapindex == mapindex_name2id(MAP_JAIL))
  5495. { //Already jailed
  5496. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5497. return -1;
  5498. }
  5499. switch(rand() % 2) { //Jail Locations
  5500. case 0:
  5501. m_index = mapindex_name2id(MAP_JAIL);
  5502. x = 24;
  5503. y = 75;
  5504. break;
  5505. default:
  5506. m_index = mapindex_name2id(MAP_JAIL);
  5507. x = 49;
  5508. y = 75;
  5509. break;
  5510. }
  5511. if (pc_setpos(pl_sd, m_index, x, y, 3)) {
  5512. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5513. return -1;
  5514. }
  5515. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5516. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5517. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5518. return 0;
  5519. }
  5520. /*==========================================
  5521. * @unjail/@discharge <char_name> by [Yor]
  5522. * Special warp! No check with nowarp and nowarpto flag
  5523. *------------------------------------------
  5524. */
  5525. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5526. {
  5527. struct map_session_data *pl_sd;
  5528. unsigned short m_index;
  5529. int x=0, y=0;
  5530. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5531. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5532. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5533. return -1;
  5534. }
  5535. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5536. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5537. return -1;
  5538. }
  5539. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5540. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5541. return -1;
  5542. }
  5543. if (pl_sd->mapindex != mapindex_name2id(MAP_JAIL)) {
  5544. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5545. return -1;
  5546. }
  5547. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5548. { //Retrieve return map.
  5549. m_index = pl_sd->sc.data[SC_JAILED].val3;
  5550. x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
  5551. y = pl_sd->sc.data[SC_JAILED].val4>>16;
  5552. status_change_end(&pl_sd->bl,SC_JAILED,-1);
  5553. } else
  5554. m_index = mapindex_name2id(MAP_PRONTERA);
  5555. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
  5556. pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
  5557. ) { //Send to Prontera is saved SC map fails.
  5558. pc_setsavepoint(pl_sd, m_index, x, y);
  5559. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5560. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5561. } else {
  5562. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5563. return -1;
  5564. }
  5565. return 0;
  5566. }
  5567. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5568. {
  5569. struct map_session_data *pl_sd = NULL;
  5570. int year, month, day, hour, minute, value;
  5571. char * modif_p;
  5572. int jailtime = 0,x,y;
  5573. short m_index = 0;
  5574. nullpo_retr(-1, sd);
  5575. if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5576. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5577. return -1;
  5578. }
  5579. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5580. modif_p = atcmd_output;
  5581. year = month = day = hour = minute = 0;
  5582. while (modif_p[0] != '\0') {
  5583. value = atoi(modif_p);
  5584. if (value == 0)
  5585. modif_p++;
  5586. else {
  5587. if (modif_p[0] == '-' || modif_p[0] == '+')
  5588. modif_p++;
  5589. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5590. modif_p++;
  5591. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  5592. minute = value;
  5593. modif_p = modif_p + 2;
  5594. } else if (modif_p[0] == 'h') {
  5595. hour = value;
  5596. modif_p++;
  5597. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5598. day = value;
  5599. modif_p++;
  5600. } else if (modif_p[0] == 'm') {
  5601. month = value;
  5602. modif_p++;
  5603. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5604. year = value;
  5605. modif_p++;
  5606. } else if (modif_p[0] != '\0') {
  5607. modif_p++;
  5608. }
  5609. }
  5610. }
  5611. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5612. clif_displaymessage(fd, "Invalid time for jail command.");
  5613. return -1;
  5614. }
  5615. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5616. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5617. return -1;
  5618. }
  5619. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5620. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5621. return -1;
  5622. }
  5623. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5624. if(jailtime==0) {
  5625. clif_displaymessage(fd, "Invalid time for jail command.");
  5626. return -1;
  5627. }
  5628. //Added by Coltaro
  5629. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5630. { //Update the player's jail time
  5631. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  5632. if (jailtime <= 0) {
  5633. jailtime = 0;
  5634. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5635. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5636. } else {
  5637. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5638. 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
  5639. clif_displaymessage(pl_sd->fd, atcmd_output);
  5640. 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
  5641. clif_displaymessage(fd, atcmd_output);
  5642. }
  5643. } else if (jailtime < 0) {
  5644. clif_displaymessage(fd, "Invalid time for jail command.");
  5645. return -1;
  5646. }
  5647. //Jail locations, add more as you wish.
  5648. switch(rand()%2)
  5649. {
  5650. case 1: //Jail #1
  5651. m_index = mapindex_name2id(MAP_JAIL);
  5652. x = 49; y = 75;
  5653. break;
  5654. default: //Default Jail
  5655. m_index = mapindex_name2id(MAP_JAIL);
  5656. x = 24; y = 75;
  5657. break;
  5658. }
  5659. 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).
  5660. return 0;
  5661. }
  5662. //By Coltaro
  5663. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5664. {
  5665. int year, month, day, hour, minute;
  5666. nullpo_retr(-1, sd);
  5667. if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5668. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5669. return -1;
  5670. }
  5671. 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?)
  5672. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5673. return -1;
  5674. }
  5675. //Get remaining jail time
  5676. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5677. 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
  5678. clif_displaymessage(fd, atcmd_output);
  5679. return 0;
  5680. }
  5681. //By Coltaro
  5682. int atcommand_charjailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5683. {
  5684. struct map_session_data* pl_sd;
  5685. int year, month, day, hour, minute;
  5686. nullpo_retr(-1, sd);
  5687. if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
  5688. clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
  5689. return -1;
  5690. }
  5691. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5692. if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
  5693. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5694. clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
  5695. return -1;
  5696. }
  5697. 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?)
  5698. clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
  5699. return -1;
  5700. }
  5701. //Get remaining jail time
  5702. get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5703. sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
  5704. clif_displaymessage(fd, atcmd_output);
  5705. } else {
  5706. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
  5707. return -1;
  5708. }
  5709. } else {
  5710. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5711. return -1;
  5712. }
  5713. return 0;
  5714. }
  5715. /*==========================================
  5716. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5717. *------------------------------------------
  5718. */
  5719. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5720. {
  5721. int id = 0;
  5722. nullpo_retr(-1, sd);
  5723. if (!message || !*message) {
  5724. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5725. return -1;
  5726. }
  5727. if ((id = atoi(message)) > 0)
  5728. { //Acquired an ID
  5729. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5730. id = 0; //Invalid id for either mobs or npcs.
  5731. } else { //Acquired a Name
  5732. if ((id = mobdb_searchname(message)) == 0)
  5733. {
  5734. struct npc_data* nd = npc_name2id(message);
  5735. if (nd != NULL)
  5736. id = nd->n;
  5737. }
  5738. }
  5739. if (id == 0)
  5740. { // Monster/NPC name/id hasn't been found.
  5741. clif_displaymessage(fd, msg_txt(123));
  5742. return -1;
  5743. }
  5744. pc_disguise(sd, id);
  5745. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5746. return 0;
  5747. }
  5748. /*==========================================
  5749. * DisguiseAll
  5750. *------------------------------------------
  5751. */
  5752. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5753. {
  5754. int mob_id=0, i=0, users;
  5755. struct map_session_data *pl_sd, **pl_allsd;
  5756. nullpo_retr(-1, sd);
  5757. if (!message || !*message) {
  5758. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5759. return -1;
  5760. }
  5761. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5762. mob_id = atoi(message);
  5763. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5764. pl_allsd = map_getallusers(&users);
  5765. for(i=0; i < users; i++) {
  5766. if((pl_sd = pl_allsd[i]))
  5767. pc_disguise(pl_sd, mob_id);
  5768. }
  5769. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5770. } else {
  5771. return -1;
  5772. }
  5773. return 0;
  5774. }
  5775. /*==========================================
  5776. * @undisguise by [Yor]
  5777. *------------------------------------------
  5778. */
  5779. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5780. {
  5781. nullpo_retr(-1, sd);
  5782. if (sd->disguise) {
  5783. pc_disguise(sd, 0);
  5784. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5785. } else {
  5786. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  5787. return -1;
  5788. }
  5789. return 0;
  5790. }
  5791. /*==========================================
  5792. * UndisguiseAll
  5793. *------------------------------------------
  5794. */
  5795. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5796. {
  5797. struct map_session_data *pl_sd, **pl_allsd;
  5798. int i, users;
  5799. nullpo_retr(-1, sd);
  5800. pl_allsd = map_getallusers(&users);
  5801. for(i=0; i < users; i++) {
  5802. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5803. pc_disguise(pl_sd, 0);
  5804. }
  5805. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5806. return 0;
  5807. }
  5808. /*==========================================
  5809. * @exp by [Skotlex]
  5810. *------------------------------------------
  5811. */
  5812. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5813. {
  5814. char output[200];
  5815. double nextb, nextj;
  5816. nullpo_retr(-1, sd);
  5817. memset(output, '\0', sizeof(output));
  5818. nextb = pc_nextbaseexp(sd);
  5819. if (nextb)
  5820. nextb = sd->status.base_exp*100.0/nextb;
  5821. nextj = pc_nextjobexp(sd);
  5822. if (nextj)
  5823. nextj = sd->status.job_exp*100.0/nextj;
  5824. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5825. clif_displaymessage(fd, output);
  5826. return 0;
  5827. }
  5828. /*==========================================
  5829. * @broadcast by [Valaris]
  5830. *------------------------------------------
  5831. */
  5832. int atcommand_broadcast(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: @broadcast <message>).");
  5838. return -1;
  5839. }
  5840. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5841. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5842. return 0;
  5843. }
  5844. /*==========================================
  5845. * @localbroadcast by [Valaris]
  5846. *------------------------------------------
  5847. */
  5848. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5849. {
  5850. nullpo_retr(-1, sd);
  5851. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5852. if (!message || !*message) {
  5853. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5854. return -1;
  5855. }
  5856. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5857. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5858. return 0;
  5859. }
  5860. /*==========================================
  5861. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5862. *------------------------------------------
  5863. */
  5864. int atcommand_chardisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5865. {
  5866. int mob_id;
  5867. char mob_name[NAME_LENGTH];
  5868. struct map_session_data* pl_sd;
  5869. nullpo_retr(-1, sd);
  5870. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5871. memset(mob_name, '\0', sizeof(mob_name));
  5872. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5873. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5874. return -1;
  5875. }
  5876. if ((mob_id = atoi(mob_name)) > 0)
  5877. { //Acquired an ID
  5878. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5879. mob_id = 0; //Invalid id for either mobs or npcs.
  5880. } else { //Acquired a Name
  5881. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5882. {
  5883. struct npc_data* nd = npc_name2id(mob_name);
  5884. if (nd != NULL)
  5885. mob_id = nd->n;
  5886. }
  5887. }
  5888. if (mob_id == 0)
  5889. {
  5890. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  5891. return -1;
  5892. }
  5893. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5894. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5895. pc_disguise(pl_sd, mob_id);
  5896. clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
  5897. } else {
  5898. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5899. return -1;
  5900. }
  5901. } else {
  5902. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5903. return -1;
  5904. }
  5905. return 0;
  5906. }
  5907. /*==========================================
  5908. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5909. *------------------------------------------
  5910. */
  5911. int atcommand_charundisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5912. {
  5913. struct map_session_data* pl_sd;
  5914. nullpo_retr(-1, sd);
  5915. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5916. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5917. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5918. return -1;
  5919. }
  5920. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5921. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5922. if (pl_sd->disguise)
  5923. pc_disguise(pl_sd, 0);
  5924. else {
  5925. clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
  5926. return -1;
  5927. }
  5928. } else {
  5929. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5930. return -1;
  5931. }
  5932. } else {
  5933. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5934. return -1;
  5935. }
  5936. return 0;
  5937. }
  5938. /*==========================================
  5939. * @email <actual@email> <new@email> by [Yor]
  5940. *------------------------------------------
  5941. */
  5942. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5943. {
  5944. char actual_email[100];
  5945. char new_email[100];
  5946. nullpo_retr(-1, sd);
  5947. memset(actual_email, '\0', sizeof(actual_email));
  5948. memset(new_email, '\0', sizeof(new_email));
  5949. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5950. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5951. return -1;
  5952. }
  5953. if (e_mail_check(actual_email) == 0) {
  5954. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  5955. return -1;
  5956. } else if (e_mail_check(new_email) == 0) {
  5957. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  5958. return -1;
  5959. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5960. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  5961. return -1;
  5962. } else if (strcmpi(actual_email, new_email) == 0) {
  5963. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  5964. return -1;
  5965. } else {
  5966. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5967. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  5968. }
  5969. return 0;
  5970. }
  5971. /*==========================================
  5972. *@effect
  5973. *------------------------------------------
  5974. */
  5975. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5976. {
  5977. int type = 0, flag = 0;
  5978. nullpo_retr(-1, sd);
  5979. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5980. clif_displaymessage(fd, "Please, enter a type and a send flag (usage: @effect <type> <flag>).");
  5981. return -1;
  5982. }
  5983. clif_specialeffect(&sd->bl, type, flag);
  5984. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  5985. return 0;
  5986. }
  5987. /*==========================================
  5988. * @charcartlist <character>: Displays the items list of a player's cart.
  5989. *------------------------------------------
  5990. */
  5991. int atcommand_character_cart_list(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5992. {
  5993. char outputtmp[200];
  5994. struct map_session_data *pl_sd;
  5995. struct item_data *item_data, *item_temp;
  5996. int i, j, count, counter, counter2;
  5997. nullpo_retr(-1, sd);
  5998. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5999. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6000. memset(outputtmp, '\0', sizeof(outputtmp));
  6001. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6002. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6003. return -1;
  6004. }
  6005. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6006. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6007. counter = 0;
  6008. count = 0;
  6009. for (i = 0; i < MAX_CART; i++) {
  6010. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6011. counter = counter + pl_sd->status.cart[i].amount;
  6012. count++;
  6013. if (count == 1) {
  6014. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6015. clif_displaymessage(fd, atcmd_output);
  6016. }
  6017. if (pl_sd->status.cart[i].refine)
  6018. 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);
  6019. else
  6020. 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);
  6021. clif_displaymessage(fd, atcmd_output);
  6022. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6023. counter2 = 0;
  6024. for (j = 0; j < item_data->slot; j++) {
  6025. if (pl_sd->status.cart[i].card[j]) {
  6026. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6027. if (atcmd_output[0] == '\0')
  6028. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6029. else
  6030. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6031. strcat(atcmd_output, outputtmp);
  6032. }
  6033. }
  6034. }
  6035. if (atcmd_output[0] != '\0') {
  6036. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6037. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6038. clif_displaymessage(fd, atcmd_output);
  6039. }
  6040. }
  6041. }
  6042. if (count == 0)
  6043. clif_displaymessage(fd, "No item found in the cart of this player.");
  6044. else {
  6045. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6046. clif_displaymessage(fd, atcmd_output);
  6047. }
  6048. } else {
  6049. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6050. return -1;
  6051. }
  6052. } else {
  6053. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6054. return -1;
  6055. }
  6056. return 0;
  6057. }
  6058. /*==========================================
  6059. * @killer by MouseJstr
  6060. * enable killing players even when not in pvp
  6061. *------------------------------------------
  6062. */
  6063. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6064. {
  6065. nullpo_retr(-1, sd);
  6066. sd->state.killer = !sd->state.killer;
  6067. if(sd->state.killer)
  6068. clif_displaymessage(fd, msg_txt(241));
  6069. else
  6070. clif_displaymessage(fd, msg_txt(287));
  6071. return 0;
  6072. }
  6073. /*==========================================
  6074. * @killable by MouseJstr
  6075. * enable other people killing you
  6076. *------------------------------------------
  6077. */
  6078. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6079. {
  6080. nullpo_retr(-1, sd);
  6081. sd->state.killable = !sd->state.killable;
  6082. if(sd->state.killable)
  6083. clif_displaymessage(fd, msg_txt(242));
  6084. else
  6085. clif_displaymessage(fd, msg_txt(288));
  6086. return 0;
  6087. }
  6088. /*==========================================
  6089. * @charkillable by MouseJstr
  6090. * enable another player to be killed
  6091. *------------------------------------------
  6092. */
  6093. int atcommand_charkillable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6094. {
  6095. struct map_session_data *pl_sd = NULL;
  6096. nullpo_retr(-1, sd);
  6097. if (!message || !*message)
  6098. return -1;
  6099. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6100. return -1;
  6101. pl_sd->state.killable = !pl_sd->state.killable;
  6102. if(pl_sd->state.killable)
  6103. clif_displaymessage(fd, msg_txt(289));
  6104. else
  6105. clif_displaymessage(fd, msg_txt(290));
  6106. return 0;
  6107. }
  6108. /*==========================================
  6109. * @skillon by MouseJstr
  6110. * turn skills on for the map
  6111. *------------------------------------------
  6112. */
  6113. int atcommand_skillon(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 = 0;
  6117. clif_displaymessage(fd, msg_txt(244));
  6118. return 0;
  6119. }
  6120. /*==========================================
  6121. * @skilloff by MouseJstr
  6122. * Turn skills off on the map
  6123. *------------------------------------------
  6124. */
  6125. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6126. {
  6127. nullpo_retr(-1, sd);
  6128. map[sd->bl.m].flag.noskill = 1;
  6129. clif_displaymessage(fd, msg_txt(243));
  6130. return 0;
  6131. }
  6132. /*==========================================
  6133. * @npcmove by MouseJstr
  6134. * move a npc
  6135. *------------------------------------------
  6136. */
  6137. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6138. {
  6139. int x = 0, y = 0, m;
  6140. struct npc_data *nd = 0;
  6141. nullpo_retr(-1, sd);
  6142. if (!message || !*message)
  6143. return -1;
  6144. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6145. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6146. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6147. return -1;
  6148. }
  6149. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6150. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6151. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6152. return -1;
  6153. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6154. return -1; //Not on a map.
  6155. if (x < 0) x = 0;
  6156. else if (x >= map[m].xs) x = map[m].xs-1;
  6157. if (y < 0) y = 0;
  6158. else if (y >= map[m].ys) y = map[m].ys-1;
  6159. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6160. map_moveblock(&nd->bl, x, y, gettick());
  6161. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6162. return 0;
  6163. }
  6164. /*==========================================
  6165. * @addwarp by MouseJstr
  6166. * Create a new static warp point.
  6167. *------------------------------------------
  6168. */
  6169. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6170. {
  6171. char w1[64], w3[64], w4[64];
  6172. int x,y,ret;
  6173. nullpo_retr(-1, sd);
  6174. if (!message || !*message)
  6175. return -1;
  6176. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6177. return -1;
  6178. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6179. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6180. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6181. ret = npc_parse_warp(w1, "warp", w3, w4);
  6182. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6183. clif_displaymessage(fd, atcmd_output);
  6184. return ret;
  6185. }
  6186. /*==========================================
  6187. * @follow by [MouseJstr]
  6188. * Follow a player .. staying no more then 5 spaces away
  6189. *------------------------------------------
  6190. */
  6191. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6192. {
  6193. struct map_session_data *pl_sd = NULL;
  6194. nullpo_retr(-1, sd);
  6195. if (!message || !*message) {
  6196. if (sd->followtarget == -1)
  6197. return -1;
  6198. pc_stop_following (sd);
  6199. clif_displaymessage(fd, "Follow mode OFF.");
  6200. return 0;
  6201. }
  6202. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6203. if (sd->followtarget == pl_sd->bl.id) {
  6204. pc_stop_following (sd);
  6205. clif_displaymessage(fd, "Follow mode OFF.");
  6206. } else {
  6207. pc_follow(sd, pl_sd->bl.id);
  6208. clif_displaymessage(fd, "Follow mode ON.");
  6209. }
  6210. return 0;
  6211. } else {
  6212. clif_displaymessage(fd, "Character not found.");
  6213. return -1;
  6214. }
  6215. return 1;
  6216. }
  6217. /*==========================================
  6218. * @dropall by [MouseJstr]
  6219. * Drop all your possession on the ground
  6220. *------------------------------------------
  6221. */
  6222. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6223. {
  6224. int i;
  6225. nullpo_retr(-1, sd);
  6226. for (i = 0; i < MAX_INVENTORY; i++) {
  6227. if (sd->status.inventory[i].amount) {
  6228. if(sd->status.inventory[i].equip != 0)
  6229. pc_unequipitem(sd, i, 3);
  6230. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6231. }
  6232. }
  6233. return 0;
  6234. }
  6235. /*==========================================
  6236. * @chardropall by [MouseJstr]
  6237. * Drop all of the target's possessions on the ground
  6238. *------------------------------------------
  6239. */
  6240. int atcommand_chardropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6241. {
  6242. int i;
  6243. struct map_session_data *pl_sd = NULL;
  6244. nullpo_retr(-1, sd);
  6245. if (!message || !*message)
  6246. return -1;
  6247. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6248. return -1;
  6249. for (i = 0; i < MAX_INVENTORY; i++) {
  6250. if (pl_sd->status.inventory[i].amount) {
  6251. if(pl_sd->status.inventory[i].equip != 0)
  6252. pc_unequipitem(pl_sd, i, 3);
  6253. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6254. }
  6255. }
  6256. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6257. clif_displaymessage(fd, "It is done");
  6258. return 0;
  6259. }
  6260. /*==========================================
  6261. * @storeall by [MouseJstr]
  6262. * Put everything into storage
  6263. *------------------------------------------
  6264. */
  6265. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6266. {
  6267. int i;
  6268. nullpo_retr(-1, sd);
  6269. if (sd->state.storage_flag != 1)
  6270. { //Open storage.
  6271. switch (storage_storageopen(sd)) {
  6272. case 2: //Try again
  6273. clif_displaymessage(fd, "run this command again..");
  6274. return 0;
  6275. case 1: //Failure
  6276. clif_displaymessage(fd, "You can't open the storage currently.");
  6277. return -1;
  6278. }
  6279. }
  6280. for (i = 0; i < MAX_INVENTORY; i++) {
  6281. if (sd->status.inventory[i].amount) {
  6282. if(sd->status.inventory[i].equip != 0)
  6283. pc_unequipitem(sd, i, 3);
  6284. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6285. }
  6286. }
  6287. storage_storageclose(sd);
  6288. clif_displaymessage(fd, "It is done");
  6289. return 0;
  6290. }
  6291. /*==========================================
  6292. * @charstoreall by [MouseJstr]
  6293. * A way to screw with players who piss you off
  6294. *------------------------------------------
  6295. */
  6296. int atcommand_charstoreall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6297. {
  6298. int i;
  6299. struct map_session_data *pl_sd = NULL;
  6300. nullpo_retr(-1, sd);
  6301. if (!message || !*message)
  6302. return -1;
  6303. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6304. return -1;
  6305. if (pl_sd->state.storage_flag != 1)
  6306. { //Open storage.
  6307. switch (storage_storageopen(pl_sd)) {
  6308. case 2: //Try again
  6309. clif_displaymessage(fd, "Had to open the characters storage window...");
  6310. clif_displaymessage(fd, "run this command again..");
  6311. return 0;
  6312. case 1: //Failure
  6313. clif_displaymessage(fd, "The character currently can't use the storage.");
  6314. return 1;
  6315. }
  6316. }
  6317. for (i = 0; i < MAX_INVENTORY; i++) {
  6318. if (pl_sd->status.inventory[i].amount) {
  6319. if(pl_sd->status.inventory[i].equip != 0)
  6320. pc_unequipitem(pl_sd, i, 3);
  6321. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6322. }
  6323. }
  6324. storage_storageclose(pl_sd);
  6325. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6326. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6327. clif_displaymessage(pl_sd->fd, " -- the management");
  6328. clif_displaymessage(fd, "It is done");
  6329. return 0;
  6330. }
  6331. /*==========================================
  6332. * @skillid by [MouseJstr]
  6333. * lookup a skill by name
  6334. *------------------------------------------
  6335. */
  6336. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6337. {
  6338. int skillen, idx;
  6339. nullpo_retr(-1, sd);
  6340. if (!message || !*message)
  6341. return -1;
  6342. skillen = strlen(message);
  6343. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6344. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6345. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6346. {
  6347. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6348. clif_displaymessage(fd, atcmd_output);
  6349. }
  6350. }
  6351. return 0;
  6352. }
  6353. /*==========================================
  6354. * @useskill by [MouseJstr]
  6355. * A way of using skills without having to find them in the skills menu
  6356. *------------------------------------------
  6357. */
  6358. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6359. {
  6360. struct map_session_data *pl_sd = NULL;
  6361. struct block_list *bl;
  6362. int skillnum;
  6363. int skilllv;
  6364. char target[255];
  6365. nullpo_retr(-1, sd);
  6366. if (!message || !*message)
  6367. return -1;
  6368. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6369. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6370. return -1;
  6371. }
  6372. if((pl_sd=map_nick2sd(target)) == NULL) {
  6373. return -1;
  6374. }
  6375. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  6376. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  6377. bl = &sd->hd->bl;
  6378. else
  6379. bl = &sd->bl;
  6380. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6381. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6382. else
  6383. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  6384. return 0;
  6385. }
  6386. /*==========================================
  6387. * @skilltree by [MouseJstr]
  6388. * prints the skill tree for a player required to get to a skill
  6389. *------------------------------------------
  6390. */
  6391. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6392. {
  6393. struct map_session_data *pl_sd = NULL;
  6394. int skillnum, skillidx = -1;
  6395. int meets = 1, j, c=0;
  6396. char target[NAME_LENGTH], *tbl;
  6397. struct skill_tree_entry *ent;
  6398. nullpo_retr(-1, sd);
  6399. if (!message || !*message)
  6400. return -1;
  6401. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6402. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6403. return -1;
  6404. }
  6405. if((pl_sd=map_nick2sd(target)) == NULL)
  6406. return -1;
  6407. c = pc_calc_skilltree_normalize_job(pl_sd);
  6408. c = pc_mapid2jobid(c, pl_sd->status.sex);
  6409. tbl = job_name(c);
  6410. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6411. tbl, pc_checkskill(pl_sd, 1));
  6412. clif_displaymessage(fd, atcmd_output);
  6413. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6414. if (skill_tree[c][j].id == skillnum) {
  6415. skillidx = j;
  6416. break;
  6417. }
  6418. }
  6419. if (skillidx == -1) {
  6420. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6421. clif_displaymessage(fd, atcmd_output);
  6422. return 0;
  6423. }
  6424. ent = &skill_tree[c][skillidx];
  6425. for(j=0;j<5;j++)
  6426. if( ent->need[j].id &&
  6427. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6428. {
  6429. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6430. sprintf(atcmd_output, "player requires level %d of skill %s",
  6431. ent->need[j].lv, desc);
  6432. clif_displaymessage(fd, atcmd_output);
  6433. meets = 0;
  6434. }
  6435. if (meets == 1) {
  6436. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6437. clif_displaymessage(fd, atcmd_output);
  6438. }
  6439. return 0;
  6440. }
  6441. // Hand a ring with partners name on it to this char
  6442. void getring (struct map_session_data *sd)
  6443. {
  6444. int flag,item_id = 0;
  6445. struct item item_tmp;
  6446. if(sd->status.sex==0)
  6447. item_id = 2635;
  6448. else
  6449. item_id = 2634;
  6450. memset(&item_tmp,0,sizeof(item_tmp));
  6451. item_tmp.nameid=item_id;
  6452. item_tmp.identify=1;
  6453. item_tmp.card[0]=255;
  6454. item_tmp.card[2]=sd->status.partner_id;
  6455. item_tmp.card[3]=sd->status.partner_id >> 16;
  6456. //Logs (A)dmins items [Lupus]
  6457. if(log_config.enable_logs&0x400)
  6458. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  6459. if((flag = pc_additem(sd,&item_tmp,1))) {
  6460. clif_additem(sd,0,0,flag);
  6461. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6462. }
  6463. }
  6464. /*==========================================
  6465. * @marry by [MouseJstr], fixed by Lupus
  6466. * Marry two players
  6467. *------------------------------------------
  6468. */
  6469. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6470. {
  6471. struct map_session_data *pl_sd1 = NULL;
  6472. struct map_session_data *pl_sd2 = NULL;
  6473. char player1[128], player2[128]; //Length used for return error msgs
  6474. nullpo_retr(-1, sd);
  6475. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  6476. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6477. return -1;
  6478. }
  6479. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6480. sprintf(player2, "Cannot find player '%s' online", player1);
  6481. clif_displaymessage(fd, player2);
  6482. return -1;
  6483. }
  6484. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6485. sprintf(player1, "Cannot find player '%s' online", player2);
  6486. clif_displaymessage(fd, player1);
  6487. return -1;
  6488. }
  6489. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6490. clif_displaymessage(fd, "They are married.. wish them well");
  6491. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6492. // Auto-give named rings (Aru)
  6493. getring (pl_sd1);
  6494. getring (pl_sd2);
  6495. return 0;
  6496. }
  6497. return -1;
  6498. }
  6499. /*==========================================
  6500. * @divorce by [MouseJstr], fixed by [Lupus]
  6501. * divorce two players
  6502. *------------------------------------------
  6503. */
  6504. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6505. {
  6506. struct map_session_data *pl_sd = NULL;
  6507. nullpo_retr(-1, sd);
  6508. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6509. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6510. return -1;
  6511. }
  6512. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6513. if (pc_divorce(pl_sd) != 0) {
  6514. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6515. clif_displaymessage(fd, atcmd_output);
  6516. return -1;
  6517. } else {
  6518. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6519. clif_displaymessage(fd, atcmd_output);
  6520. return 0;
  6521. }
  6522. }
  6523. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6524. clif_displaymessage(fd, atcmd_output);
  6525. return -1;
  6526. }
  6527. #ifdef DMALLOC
  6528. unsigned long dmark_;
  6529. int atcommand_dmstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6530. {
  6531. dmark_ = dmalloc_mark();
  6532. clif_displaymessage(fd, "debug mark set");
  6533. return 0;
  6534. }
  6535. int atcommand_dmtick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6536. {
  6537. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6538. dmark_ = dmalloc_mark();
  6539. clif_displaymessage(fd, "malloc changes logged");
  6540. return 0;
  6541. }
  6542. #endif
  6543. /*==========================================
  6544. * @grind by [MouseJstr]
  6545. *------------------------------------------
  6546. */
  6547. int atcommand_grind(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6548. {
  6549. struct map_session_data *pl_sd = NULL;
  6550. int skillnum;
  6551. int inf;
  6552. char target[NAME_LENGTH];
  6553. nullpo_retr(-1, sd);
  6554. if (!message || !*message)
  6555. return -1;
  6556. if(sscanf(message, "%23s", target) != 1) {
  6557. clif_displaymessage(fd, "Usage: @grind <target>");
  6558. return -1;
  6559. }
  6560. if((pl_sd=map_nick2sd(target)) == NULL)
  6561. return -1;
  6562. for (skillnum = 1; skillnum < 500; skillnum++) {
  6563. sd->status.sp = sd->status.max_sp;
  6564. atcommand_alive(fd, sd, command, message);
  6565. inf = skill_get_inf(skillnum);
  6566. if (inf & INF_GROUND_SKILL)
  6567. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6568. else if (!(inf & INF_SUPPORT_SKILL))
  6569. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6570. }
  6571. return 0;
  6572. }
  6573. /*==========================================
  6574. * @grind2 by [MouseJstr]
  6575. *------------------------------------------
  6576. */
  6577. int atcommand_grind2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6578. {
  6579. int i;
  6580. short x, y;
  6581. for (i = 1000; i < MAX_MOB_DB; i++) {
  6582. if (!mobdb_checkid(i))
  6583. continue;
  6584. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6585. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6586. }
  6587. return 0;
  6588. }
  6589. /*==========================================
  6590. * @changelook by [Celest]
  6591. *------------------------------------------
  6592. */
  6593. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6594. {
  6595. int i, j = 0, k = 0;
  6596. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6597. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6598. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6599. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6600. return -1;
  6601. } else if (i == 2) {
  6602. if (j < 1) j = 1;
  6603. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6604. j = pos[j - 1];
  6605. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6606. k = j; // swap
  6607. j = LOOK_HEAD_TOP;
  6608. }
  6609. clif_changelook(&sd->bl,j,k);
  6610. return 0;
  6611. }
  6612. /*==========================================
  6613. * @autotrade by durf (changed by Lupus)
  6614. * Turns on/off Autotrade for a specific player
  6615. *------------------------------------------
  6616. */
  6617. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6618. {
  6619. nullpo_retr(-1, sd);
  6620. if (sd->vender_id) //check if player's vending
  6621. {
  6622. sd->state.autotrade = 1;
  6623. clif_authfail_fd(fd, 15);
  6624. }
  6625. else
  6626. {
  6627. //"You should be vending to use @Autotrade."
  6628. clif_displaymessage(fd, msg_txt(549));
  6629. }
  6630. return 0;
  6631. }
  6632. /*==========================================
  6633. * @changegm by durf (changed by Lupus)
  6634. * Changes Master of your Guild to a specified guild member
  6635. *------------------------------------------
  6636. */
  6637. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6638. {
  6639. struct guild *g;
  6640. struct map_session_data *pl_sd;
  6641. nullpo_retr(-1, sd);
  6642. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6643. {
  6644. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6645. return -1;
  6646. }
  6647. if (strlen(message)==0)
  6648. {
  6649. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6650. return -1;
  6651. }
  6652. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6653. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6654. return -1;
  6655. }
  6656. guild_gm_change(sd->status.guild_id, pl_sd);
  6657. return 0;
  6658. }
  6659. /*==========================================
  6660. * @changeleader by Skotlex
  6661. * Changes the leader of a party.
  6662. *------------------------------------------
  6663. */
  6664. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6665. {
  6666. struct party_data *p;
  6667. struct map_session_data *pl_sd;
  6668. int mi, pl_mi;
  6669. nullpo_retr(-1, sd);
  6670. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6671. { //Need to be a party leader.
  6672. clif_displaymessage(fd, msg_txt(282));
  6673. return -1;
  6674. }
  6675. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6676. if (mi == MAX_PARTY)
  6677. return -1; //Shouldn't happen
  6678. if (!p->party.member[mi].leader)
  6679. { //Need to be a party leader.
  6680. clif_displaymessage(fd, msg_txt(282));
  6681. return -1;
  6682. }
  6683. if (strlen(message)==0)
  6684. {
  6685. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6686. return -1;
  6687. }
  6688. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6689. clif_displaymessage(fd, msg_txt(283));
  6690. return -1;
  6691. }
  6692. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  6693. if (pl_mi == MAX_PARTY)
  6694. return -1; //Shouldn't happen
  6695. //Change leadership.
  6696. p->party.member[mi].leader = 0;
  6697. if (p->data[mi].sd->fd)
  6698. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  6699. p->party.member[pl_mi].leader = 1;
  6700. if (p->data[pl_mi].sd->fd)
  6701. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  6702. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  6703. //Update info.
  6704. clif_party_main_info(p,-1);
  6705. clif_party_info(p,-1);
  6706. return 0;
  6707. }
  6708. /*==========================================
  6709. * @partyoption by Skotlex
  6710. * Used to change the item share setting of a party.
  6711. *------------------------------------------
  6712. */
  6713. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6714. {
  6715. struct party_data *p;
  6716. int mi, option;
  6717. char w1[15], w2[15];
  6718. nullpo_retr(-1, sd);
  6719. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6720. {
  6721. clif_displaymessage(fd, msg_txt(282));
  6722. return -1;
  6723. }
  6724. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6725. if (mi == MAX_PARTY)
  6726. return -1; //Shouldn't happen
  6727. if (!p->party.member[mi].leader)
  6728. {
  6729. clif_displaymessage(fd, msg_txt(282));
  6730. return -1;
  6731. }
  6732. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  6733. {
  6734. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  6735. return -1;
  6736. }
  6737. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  6738. option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
  6739. //Change item share type.
  6740. if (option != p->party.item)
  6741. party_changeoption(sd, p->party.exp, option);
  6742. else
  6743. clif_displaymessage(fd, msg_txt(286));
  6744. return 0;
  6745. }
  6746. /*==========================================
  6747. * @autoloot by Upa-Kun
  6748. * Turns on/off AutoLoot for a specific player
  6749. *------------------------------------------
  6750. */
  6751. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6752. {
  6753. int rate;
  6754. double drate;
  6755. nullpo_retr(-1, sd);
  6756. // autoloot command without value
  6757. if(!message || !*message)
  6758. {
  6759. if (sd->state.autoloot)
  6760. rate = 0;
  6761. else
  6762. rate = 10000;
  6763. } else {
  6764. drate = atof(message);
  6765. rate = (int)(drate*100);
  6766. }
  6767. if (rate < 0) rate = 0;
  6768. if (rate > 10000) rate = 10000;
  6769. sd->state.autoloot = rate;
  6770. if (sd->state.autoloot) {
  6771. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6772. clif_displaymessage(fd, atcmd_output);
  6773. }else
  6774. clif_displaymessage(fd, "Autoloot is now off.");
  6775. return 0;
  6776. }
  6777. /*==========================================
  6778. * It is made to rain.
  6779. *------------------------------------------
  6780. */
  6781. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6782. {
  6783. nullpo_retr(-1, sd);
  6784. if (map[sd->bl.m].flag.rain) {
  6785. map[sd->bl.m].flag.rain=0;
  6786. clif_weather(sd->bl.m);
  6787. clif_displaymessage(fd, "The rain has stopped.");
  6788. } else {
  6789. map[sd->bl.m].flag.rain=1;
  6790. clif_weather(sd->bl.m);
  6791. clif_displaymessage(fd, "It is made to rain.");
  6792. }
  6793. return 0;
  6794. }
  6795. /*==========================================
  6796. * It is made to snow.
  6797. *------------------------------------------
  6798. */
  6799. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6800. {
  6801. nullpo_retr(-1, sd);
  6802. if (map[sd->bl.m].flag.snow) {
  6803. map[sd->bl.m].flag.snow=0;
  6804. clif_weather(sd->bl.m);
  6805. clif_displaymessage(fd, "Snow has stopped falling.");
  6806. } else {
  6807. map[sd->bl.m].flag.snow=1;
  6808. clif_weather(sd->bl.m);
  6809. clif_displaymessage(fd, "It is made to snow.");
  6810. }
  6811. return 0;
  6812. }
  6813. /*==========================================
  6814. * Cherry tree snowstorm is made to fall. (Sakura)
  6815. *------------------------------------------
  6816. */
  6817. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6818. {
  6819. nullpo_retr(-1, sd);
  6820. if (map[sd->bl.m].flag.sakura) {
  6821. map[sd->bl.m].flag.sakura=0;
  6822. clif_weather(sd->bl.m);
  6823. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6824. } else {
  6825. map[sd->bl.m].flag.sakura=1;
  6826. clif_weather(sd->bl.m);
  6827. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6828. }
  6829. return 0;
  6830. }
  6831. /*==========================================
  6832. * Clouds appear.
  6833. *------------------------------------------
  6834. */
  6835. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6836. {
  6837. nullpo_retr(-1, sd);
  6838. if (map[sd->bl.m].flag.clouds) {
  6839. map[sd->bl.m].flag.clouds=0;
  6840. clif_weather(sd->bl.m);
  6841. clif_displaymessage(fd, "The clouds has disappear.");
  6842. } else {
  6843. map[sd->bl.m].flag.clouds=1;
  6844. clif_weather(sd->bl.m);
  6845. clif_displaymessage(fd, "Clouds appear.");
  6846. }
  6847. return 0;
  6848. }
  6849. /*==========================================
  6850. * Different type of clouds using effect 516
  6851. *------------------------------------------
  6852. */
  6853. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6854. {
  6855. nullpo_retr(-1, sd);
  6856. if (map[sd->bl.m].flag.clouds2) {
  6857. map[sd->bl.m].flag.clouds2=0;
  6858. clif_weather(sd->bl.m);
  6859. clif_displaymessage(fd, "The alternative clouds disappear.");
  6860. } else {
  6861. map[sd->bl.m].flag.clouds2=1;
  6862. clif_weather(sd->bl.m);
  6863. clif_displaymessage(fd, "Alternative clouds appear.");
  6864. }
  6865. return 0;
  6866. }
  6867. /*==========================================
  6868. * Fog hangs over.
  6869. *------------------------------------------
  6870. */
  6871. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6872. {
  6873. nullpo_retr(-1, sd);
  6874. if (map[sd->bl.m].flag.fog) {
  6875. map[sd->bl.m].flag.fog=0;
  6876. clif_weather(sd->bl.m);
  6877. clif_displaymessage(fd, "The fog has gone.");
  6878. } else {
  6879. map[sd->bl.m].flag.fog=1;
  6880. clif_weather(sd->bl.m);
  6881. clif_displaymessage(fd, "Fog hangs over.");
  6882. }
  6883. return 0;
  6884. }
  6885. /*==========================================
  6886. * Fallen leaves fall.
  6887. *------------------------------------------
  6888. */
  6889. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6890. {
  6891. nullpo_retr(-1, sd);
  6892. if (map[sd->bl.m].flag.leaves) {
  6893. map[sd->bl.m].flag.leaves=0;
  6894. clif_weather(sd->bl.m);
  6895. clif_displaymessage(fd, "Leaves no longer fall.");
  6896. } else {
  6897. map[sd->bl.m].flag.leaves=1;
  6898. clif_weather(sd->bl.m);
  6899. clif_displaymessage(fd, "Fallen leaves fall.");
  6900. }
  6901. return 0;
  6902. }
  6903. /*==========================================
  6904. * Fireworks appear.
  6905. *------------------------------------------
  6906. */
  6907. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6908. {
  6909. nullpo_retr(-1, sd);
  6910. if (map[sd->bl.m].flag.fireworks) {
  6911. map[sd->bl.m].flag.fireworks=0;
  6912. clif_weather(sd->bl.m);
  6913. clif_displaymessage(fd, "Fireworks are ended.");
  6914. } else {
  6915. map[sd->bl.m].flag.fireworks=1;
  6916. clif_weather(sd->bl.m);
  6917. clif_displaymessage(fd, "Fireworks are launched.");
  6918. }
  6919. return 0;
  6920. }
  6921. /*==========================================
  6922. * Clearing Weather Effects by Dexity
  6923. *------------------------------------------
  6924. */
  6925. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6926. {
  6927. nullpo_retr(-1, sd);
  6928. map[sd->bl.m].flag.rain=0;
  6929. map[sd->bl.m].flag.snow=0;
  6930. map[sd->bl.m].flag.sakura=0;
  6931. map[sd->bl.m].flag.clouds=0;
  6932. map[sd->bl.m].flag.clouds2=0;
  6933. map[sd->bl.m].flag.fog=0;
  6934. map[sd->bl.m].flag.fireworks=0;
  6935. map[sd->bl.m].flag.leaves=0;
  6936. clif_weather(sd->bl.m);
  6937. clif_displaymessage(fd, msg_txt(291));
  6938. return 0;
  6939. }
  6940. /*===============================================================
  6941. * Sound Command - plays a sound for everyone! [Codemaster]
  6942. *---------------------------------------------------------------
  6943. */
  6944. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6945. {
  6946. char sound_file[100];
  6947. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6948. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6949. return -1;
  6950. }
  6951. memset(sound_file, '\0', sizeof(sound_file));
  6952. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6953. return -1;
  6954. if(strstr(sound_file, ".wav") == NULL)
  6955. strcat(sound_file, ".wav");
  6956. clif_soundeffectall(&sd->bl, sound_file,0,2);
  6957. return 0;
  6958. }
  6959. /*==========================================
  6960. * MOB Search
  6961. *------------------------------------------
  6962. */
  6963. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  6964. {
  6965. int mob_id,fd;
  6966. static int number=0;
  6967. struct mob_data *md;
  6968. nullpo_retr(0, bl);
  6969. if(!ap){
  6970. number=0;
  6971. return 0;
  6972. }
  6973. mob_id = va_arg(ap,int);
  6974. fd = va_arg(ap,int);
  6975. md = (struct mob_data *)bl;
  6976. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  6977. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  6978. ++number,bl->x, bl->y,md->name);
  6979. clif_displaymessage(fd, atcmd_output);
  6980. }
  6981. return 0;
  6982. }
  6983. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6984. {
  6985. char mob_name[100];
  6986. int mob_id,map_id = 0;
  6987. nullpo_retr(-1, sd);
  6988. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6989. return -1;
  6990. if ((mob_id = atoi(mob_name)) == 0)
  6991. mob_id = mobdb_searchname(mob_name);
  6992. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6993. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6994. clif_displaymessage(fd, atcmd_output);
  6995. return 0;
  6996. }
  6997. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6998. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6999. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7000. map_id = sd->bl.m;
  7001. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  7002. clif_displaymessage(fd, atcmd_output);
  7003. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7004. atmobsearch_sub(&sd->bl,0); // reset the counter
  7005. return 0;
  7006. }
  7007. /*==========================================
  7008. * @cleanmap - cleans items on the ground
  7009. *------------------------------------------
  7010. */
  7011. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7012. {
  7013. nullpo_retr(0, bl);
  7014. map_clearflooritem(bl->id);
  7015. return 0;
  7016. }
  7017. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7018. {
  7019. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7020. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7021. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7022. BL_ITEM);
  7023. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7024. return 0;
  7025. }
  7026. /*==========================================
  7027. * make a NPC/PET talk
  7028. *------------------------------------------
  7029. */
  7030. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7031. {
  7032. char name[NAME_LENGTH],mes[100],temp[100];
  7033. struct npc_data *nd;
  7034. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7035. return -1;
  7036. if (!(nd = npc_name2id(name)))
  7037. return -1;
  7038. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7039. clif_message(&nd->bl, temp);
  7040. return 0;
  7041. }
  7042. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7043. {
  7044. char mes[100],temp[100];
  7045. struct pet_data *pd;
  7046. nullpo_retr(-1, sd);
  7047. if(!sd->status.pet_id || !(pd=sd->pd))
  7048. return -1;
  7049. if (sd->sc.count && //no "chatting" while muted.
  7050. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7051. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7052. return -1;
  7053. if (sscanf(message, "%99[^\n]", mes) < 1)
  7054. return -1;
  7055. snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
  7056. clif_message(&pd->bl, temp);
  7057. return 0;
  7058. }
  7059. /*==========================================
  7060. * @users - displays the number of players present on each map (percentage)
  7061. *------------------------------------------
  7062. */
  7063. static struct dbt *users_db = NULL;
  7064. static int users_all;
  7065. static int atcommand_users_sub1(struct map_session_data* sd,va_list va)
  7066. {
  7067. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7068. users_all++;
  7069. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7070. return 0;
  7071. }
  7072. static int atcommand_users_sub2(DBKey key,void* val,va_list va)
  7073. {
  7074. char buf[256];
  7075. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7076. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7077. clif_displaymessage(sd->fd,buf);
  7078. return 0;
  7079. }
  7080. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7081. {
  7082. char buf[256];
  7083. users_all = 0;
  7084. users_db->clear(users_db, NULL);
  7085. clif_foreachclient(atcommand_users_sub1);
  7086. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7087. sprintf(buf,"all : %d",users_all);
  7088. clif_displaymessage(fd,buf);
  7089. return 0;
  7090. }
  7091. /*==========================================
  7092. *
  7093. *------------------------------------------
  7094. */
  7095. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7096. {
  7097. pc_resetstate(sd);
  7098. pc_resetskill(sd,1);
  7099. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  7100. clif_displaymessage(fd, atcmd_output);
  7101. return 0;
  7102. }
  7103. /*==========================================
  7104. *
  7105. *------------------------------------------
  7106. */
  7107. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7108. {
  7109. char name[NAME_LENGTH];
  7110. int mob_id = 0;
  7111. int duration = 0;
  7112. struct mob_data *md;
  7113. unsigned int tick=gettick();
  7114. nullpo_retr(-1, sd);
  7115. if (!message || !*message)
  7116. return -1;
  7117. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7118. return -1;
  7119. if (duration < 1)
  7120. duration =1;
  7121. else if (duration > 60)
  7122. duration =60;
  7123. if ((mob_id = atoi(name)) == 0)
  7124. mob_id = mobdb_searchname(name);
  7125. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7126. return -1;
  7127. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7128. if(md){
  7129. md->master_id=sd->bl.id;
  7130. md->special_state.ai=1;
  7131. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  7132. clif_misceffect2(&md->bl,344);
  7133. mob_spawn(md);
  7134. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7135. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7136. }
  7137. return 0;
  7138. }
  7139. /*==========================================
  7140. * @adjcmdlvl by [MouseJstr]
  7141. *
  7142. * Temp adjust the GM level required to use a GM command
  7143. * Useful during beta testing to allow players to use GM commands for short periods of time
  7144. *------------------------------------------
  7145. */
  7146. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7147. {
  7148. int i, newlev;
  7149. char cmd[100];
  7150. nullpo_retr(-1, sd);
  7151. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7152. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7153. return -1;
  7154. }
  7155. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7156. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7157. atcommand_info[i].level = newlev;
  7158. clif_displaymessage(fd, "@command level changed.");
  7159. return 0;
  7160. }
  7161. clif_displaymessage(fd, "@command not found.");
  7162. return -1;
  7163. }
  7164. /*==========================================
  7165. * @adjgmlvl by [MouseJstr]
  7166. * Create a temp GM
  7167. * Useful during beta testing to allow players to use GM commands for short periods of time
  7168. *------------------------------------------
  7169. */
  7170. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7171. {
  7172. int newlev;
  7173. char user[NAME_LENGTH];
  7174. struct map_session_data *pl_sd;
  7175. nullpo_retr(-1, sd);
  7176. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7177. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7178. return -1;
  7179. }
  7180. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7181. return -1;
  7182. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7183. return 0;
  7184. }
  7185. /*==========================================
  7186. * @trade by [MouseJstr]
  7187. * Open a trade window with a remote player
  7188. *------------------------------------------
  7189. */
  7190. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7191. {
  7192. struct map_session_data *pl_sd = NULL;
  7193. nullpo_retr(-1, sd);
  7194. if (!message || !*message)
  7195. return -1;
  7196. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7197. trade_traderequest(sd, pl_sd);
  7198. return 0;
  7199. }
  7200. return -1;
  7201. }
  7202. /*==========================================
  7203. * @setbattleflag by [MouseJstr]
  7204. * set a battle_config flag without having to reboot
  7205. */
  7206. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7207. {
  7208. char flag[128], value[128];
  7209. nullpo_retr(-1, sd);
  7210. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7211. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7212. return -1;
  7213. }
  7214. if (battle_set_value(flag, value) == 0)
  7215. clif_displaymessage(fd, "unknown battle_config flag");
  7216. else
  7217. clif_displaymessage(fd, "battle_config set as requested");
  7218. return 0;
  7219. }
  7220. /*===========================
  7221. * @unmute [Valaris]
  7222. *===========================
  7223. */
  7224. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7225. {
  7226. struct map_session_data *pl_sd = NULL;
  7227. nullpo_retr(-1, sd);
  7228. if (!message || !*message)
  7229. return -1;
  7230. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7231. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7232. pl_sd->status.manner = 0;
  7233. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7234. clif_displaymessage(sd->fd,"Player unmuted");
  7235. }
  7236. else
  7237. clif_displaymessage(sd->fd,"Player is not muted");
  7238. }
  7239. return 0;
  7240. }
  7241. /*==========================================
  7242. * @uptime by MC Cameri
  7243. *------------------------------------------
  7244. */
  7245. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7246. {
  7247. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7248. minute = 60, days = 0, hours = 0, minutes = 0;
  7249. nullpo_retr(-1, sd);
  7250. seconds = get_uptime();
  7251. days = seconds/day;
  7252. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7253. hours = seconds/hour;
  7254. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7255. minutes = seconds/minute;
  7256. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7257. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  7258. clif_displaymessage(fd, atcmd_output);
  7259. return 0;
  7260. }
  7261. /*==========================================
  7262. * @changesex <sex>
  7263. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  7264. *------------------------------------------
  7265. */
  7266. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7267. {
  7268. nullpo_retr(-1, sd);
  7269. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7270. return 0;
  7271. }
  7272. /*================================================
  7273. * @mute - Mutes a player for a set amount of time
  7274. *------------------------------------------------
  7275. */
  7276. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7277. {
  7278. struct map_session_data *pl_sd = NULL;
  7279. int manner;
  7280. nullpo_retr(-1, sd);
  7281. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7282. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7283. return -1;
  7284. }
  7285. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7286. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7287. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7288. return -1;
  7289. }
  7290. clif_GM_silence(sd, pl_sd, 0);
  7291. pl_sd->status.manner -= manner;
  7292. if(pl_sd->status.manner < 0)
  7293. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7294. }
  7295. else {
  7296. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7297. return -1;
  7298. }
  7299. return 0;
  7300. }
  7301. /*==========================================
  7302. * @refresh (like @jumpto <<yourself>>)
  7303. *------------------------------------------
  7304. */
  7305. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7306. {
  7307. nullpo_retr(-1, sd);
  7308. clif_refresh(sd);
  7309. return 0;
  7310. }
  7311. /*==========================================
  7312. * @petid <part of pet name>
  7313. * => Displays a list of matching pets.
  7314. *------------------------------------------
  7315. */
  7316. int atcommand_petid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7317. {
  7318. char searchtext[100];
  7319. char temp0[100];
  7320. char temp1[100];
  7321. int cnt = 0, i = 0;
  7322. nullpo_retr(-1, sd);
  7323. if (!message || !*message)
  7324. return -1;
  7325. if (sscanf(message, "%99s", searchtext) < 1)
  7326. return -1;
  7327. estr_lower(searchtext);
  7328. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7329. clif_displaymessage(fd,temp0);
  7330. while (i < MAX_PET_DB) {
  7331. strcpy(temp1,pet_db[i].name);
  7332. strcpy(temp1, estr_lower(temp1));
  7333. strcpy(temp0,pet_db[i].jname);
  7334. strcpy(temp0, estr_lower(temp1));
  7335. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7336. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7337. pet_db[i].jname);
  7338. if (cnt >= 100) { // Only if there are custom pets
  7339. clif_displaymessage(fd, "Be more specific, can't send more than"
  7340. " 100 results.");
  7341. } else {
  7342. clif_displaymessage(fd, temp0);
  7343. }
  7344. cnt++;
  7345. }
  7346. i++;
  7347. }
  7348. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7349. clif_displaymessage(fd, temp0);
  7350. return 0;
  7351. }
  7352. /*==========================================
  7353. * @identify
  7354. * => GM's magnifier.
  7355. *------------------------------------------
  7356. */
  7357. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7358. {
  7359. int i,num;
  7360. nullpo_retr(-1, sd);
  7361. for(i=num=0;i<MAX_INVENTORY;i++){
  7362. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7363. num++;
  7364. }
  7365. }
  7366. if (num > 0) {
  7367. clif_item_identify_list(sd);
  7368. } else {
  7369. clif_displaymessage(fd,"There are no items to appraise.");
  7370. }
  7371. return 0;
  7372. }
  7373. /*==========================================
  7374. * @gmotd (Global MOTD)
  7375. * by davidsiaw :P
  7376. *------------------------------------------
  7377. */
  7378. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7379. {
  7380. char buf[256];
  7381. FILE *fp;
  7382. nullpo_retr(-1, sd);
  7383. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7384. while (fgets(buf, 250, fp) != NULL){
  7385. int i;
  7386. for( i=0; buf[i]; i++){
  7387. if( buf[i]=='\r' || buf[i]=='\n'){
  7388. buf[i]=0;
  7389. break;
  7390. }
  7391. }
  7392. intif_GMmessage(buf,strlen(buf)+1,8);
  7393. }
  7394. fclose(fp);
  7395. }
  7396. return 0;
  7397. }
  7398. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7399. {
  7400. int effect = 0;
  7401. nullpo_retr(-1, sd);
  7402. if (!message || !*message)
  7403. return -1;
  7404. if (sscanf(message, "%d", &effect) < 1)
  7405. return -1;
  7406. clif_misceffect(&sd->bl,effect);
  7407. return 0;
  7408. }
  7409. /*==========================================
  7410. * Jump to a player by PID number
  7411. * Original by Dino9021
  7412. * Added in by nsstrunks
  7413. *------------------------------------------
  7414. */
  7415. int atcommand_jumptoid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7416. {
  7417. int cid=0;
  7418. struct map_session_data *pl_sd;
  7419. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7420. if (!message || (cid = atoi(message)) == 0) {
  7421. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7422. return -1;
  7423. }
  7424. pl_sd = map_charid2sd(cid);
  7425. if (!pl_sd) {
  7426. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7427. return -1;
  7428. }
  7429. if (map[pl_sd->bl.m].flag.nowarpto &&
  7430. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7431. {
  7432. clif_displaymessage(fd, msg_txt(247));
  7433. return -1;
  7434. }
  7435. if (map[sd->bl.m].flag.nowarp &&
  7436. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7437. {
  7438. clif_displaymessage(fd, msg_txt(248));
  7439. return -1;
  7440. }
  7441. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7442. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7443. clif_displaymessage(fd, atcmd_output);
  7444. return 0;
  7445. }
  7446. /*==========================================
  7447. * Jump to a player by PID number
  7448. * Original by Dino9021
  7449. * Added in by nsstrunks
  7450. *------------------------------------------
  7451. */
  7452. int atcommand_jumptoid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7453. {
  7454. int aid=0;
  7455. struct map_session_data *pl_sd;
  7456. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7457. if (!message || (aid = atoi(message)) == 0) {
  7458. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7459. return -1;
  7460. }
  7461. pl_sd = map_id2sd(aid);
  7462. if (!pl_sd) {
  7463. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7464. return -1;
  7465. }
  7466. if (map[pl_sd->bl.m].flag.nowarpto &&
  7467. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7468. {
  7469. clif_displaymessage(fd, msg_txt(247));
  7470. return -1;
  7471. }
  7472. if (map[sd->bl.m].flag.nowarp &&
  7473. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7474. {
  7475. clif_displaymessage(fd, msg_txt(248));
  7476. return -1;
  7477. }
  7478. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7479. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7480. clif_displaymessage(fd, atcmd_output);
  7481. return 0;
  7482. }
  7483. /*==========================================
  7484. * Recall a player by PID number
  7485. * Original by Dino9021
  7486. * Added in by nsstrunks
  7487. *------------------------------------------
  7488. */
  7489. int atcommand_recallid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7490. {
  7491. int cid=0;
  7492. struct map_session_data *pl_sd;
  7493. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7494. if (!message || (cid = atoi(message)) == 0) {
  7495. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7496. return -1;
  7497. }
  7498. pl_sd = map_charid2sd(cid);
  7499. if (!pl_sd) {
  7500. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7501. return -1;
  7502. }
  7503. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can recall only lower or same level
  7504. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7505. return -1;
  7506. }
  7507. if (map[pl_sd->bl.m].flag.nowarpto &&
  7508. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7509. {
  7510. clif_displaymessage(fd, msg_txt(247));
  7511. return -1;
  7512. }
  7513. if (map[sd->bl.m].flag.nowarp &&
  7514. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7515. {
  7516. clif_displaymessage(fd, msg_txt(248));
  7517. return -1;
  7518. }
  7519. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7520. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  7521. clif_displaymessage(fd, atcmd_output);
  7522. return 0;
  7523. }
  7524. /*==========================================
  7525. * Recall a player by PID number
  7526. * Original by Dino9021
  7527. * Added in by nsstrunks
  7528. *------------------------------------------
  7529. */
  7530. int atcommand_recallid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7531. {
  7532. int aid=0;
  7533. struct map_session_data *pl_sd;
  7534. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7535. if (!message || (aid = atoi(message)) == 0) {
  7536. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7537. return -1;
  7538. }
  7539. pl_sd = map_id2sd(aid);
  7540. if (!pl_sd) {
  7541. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7542. return -1;
  7543. }
  7544. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7545. { // you can recall only lower or same level
  7546. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7547. return -1;
  7548. }
  7549. if (map[pl_sd->bl.m].flag.nowarpto &&
  7550. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7551. {
  7552. clif_displaymessage(fd, msg_txt(247));
  7553. return -1;
  7554. }
  7555. if (map[sd->bl.m].flag.nowarp &&
  7556. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7557. {
  7558. clif_displaymessage(fd, msg_txt(248));
  7559. return -1;
  7560. }
  7561. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7562. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  7563. clif_displaymessage(fd, atcmd_output);
  7564. return 0;
  7565. }
  7566. /*==========================================
  7567. * Kick a player by PID number
  7568. * Original by Dino9021
  7569. * Added in by nsstrunks
  7570. *------------------------------------------
  7571. */
  7572. int atcommand_kickid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7573. {
  7574. struct map_session_data *pl_sd;
  7575. int cid=0;
  7576. if (!message || (cid = atoi(message)) == 0) {
  7577. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7578. return -1;
  7579. }
  7580. pl_sd = map_charid2sd(cid);
  7581. if (!pl_sd) {
  7582. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7583. return -1;
  7584. }
  7585. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7586. { // you can kick only lower or same gm level
  7587. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7588. return -1;
  7589. }
  7590. clif_GM_kick(sd, pl_sd, 1);
  7591. return 0;
  7592. }
  7593. /*==========================================
  7594. * Kick a player by PID number
  7595. * Original by Dino9021
  7596. * Added in by nsstrunks
  7597. *------------------------------------------
  7598. */
  7599. int atcommand_kickid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7600. {
  7601. struct map_session_data *pl_sd;
  7602. int aid=0;
  7603. if (!message || (aid = atoi(message)) == 0) {
  7604. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7605. return -1;
  7606. }
  7607. pl_sd = map_id2sd(aid);
  7608. if (!pl_sd) {
  7609. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7610. return -1;
  7611. }
  7612. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7613. { // you can kick only lower or same gm level
  7614. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7615. return -1;
  7616. }
  7617. clif_GM_kick(sd, pl_sd, 1);
  7618. return 0;
  7619. }
  7620. /*==========================================
  7621. * Revive a player by PID number
  7622. * Original by Dino9021
  7623. * Added in by nsstrunks
  7624. *------------------------------------------
  7625. */
  7626. int atcommand_reviveid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7627. {
  7628. int cid=0;
  7629. struct map_session_data *pl_sd;
  7630. if (!message || (cid = atoi(message)) == 0) {
  7631. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7632. return -1;
  7633. }
  7634. pl_sd = map_charid2sd(cid);
  7635. if (!pl_sd) {
  7636. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7637. return -1;
  7638. }
  7639. if(!status_revive(&pl_sd->bl, 100, 100))
  7640. return -1;
  7641. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  7642. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  7643. return 0;
  7644. }
  7645. /*==========================================
  7646. * Revive a player by PID number
  7647. * Original by Dino9021
  7648. * Added in by nsstrunks
  7649. *------------------------------------------
  7650. */
  7651. int atcommand_reviveid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7652. {
  7653. int aid=0;
  7654. struct map_session_data *pl_sd;
  7655. if (!message || (aid = atoi(message)) == 0) {
  7656. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7657. return -1;
  7658. }
  7659. pl_sd = map_id2sd(aid);
  7660. if(!pl_sd) {
  7661. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7662. return -1;
  7663. }
  7664. if(!status_revive(&pl_sd->bl, 100, 100))
  7665. return -1;
  7666. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  7667. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  7668. return 0;
  7669. }
  7670. /*==========================================
  7671. * Kill a player by PID number
  7672. * Original by Dino9021
  7673. * Added in by nsstrunks
  7674. *------------------------------------------
  7675. */
  7676. int atcommand_killid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7677. {
  7678. int cid=0;
  7679. struct map_session_data *pl_sd;
  7680. if (!message || (cid = atoi(message)) == 0) {
  7681. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7682. return -1;
  7683. }
  7684. pl_sd = map_charid2sd(cid);
  7685. if (!pl_sd) {
  7686. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7687. return -1;
  7688. }
  7689. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7690. { // you can kill only lower or same level
  7691. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7692. return -1;
  7693. }
  7694. status_kill(&pl_sd->bl);
  7695. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  7696. return 0;
  7697. }
  7698. /*==========================================
  7699. * Kill a player by PID number
  7700. * Original by Dino9021
  7701. * Added in by nsstrunks
  7702. *------------------------------------------
  7703. */
  7704. int atcommand_killid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7705. {
  7706. int aid=0;
  7707. struct map_session_data *pl_sd;
  7708. if (!message || (aid = atoi(message)) == 0) {
  7709. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7710. return -1;
  7711. }
  7712. pl_sd = map_id2sd(aid);
  7713. if (!pl_sd) {
  7714. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7715. return -1;
  7716. }
  7717. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7718. { // you can kill only lower or same level
  7719. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7720. return -1;
  7721. }
  7722. status_kill(&pl_sd->bl);
  7723. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  7724. return 0;
  7725. }
  7726. /*==========================================
  7727. * Make a player killable, by PID
  7728. * Original by Dino9021
  7729. * Added in by nsstrunks
  7730. *------------------------------------------
  7731. */
  7732. int atcommand_charkillableid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7733. {
  7734. struct map_session_data *pl_sd = NULL;
  7735. int cid=0;
  7736. if (!message || (cid = atoi(message)) == 0) {
  7737. clif_displaymessage(fd, "Please, enter a player CID.");
  7738. return -1;
  7739. }
  7740. pl_sd = map_charid2sd(cid);
  7741. if (!pl_sd) {
  7742. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7743. return -1;
  7744. }
  7745. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7746. {
  7747. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7748. return -1;
  7749. }
  7750. pl_sd->state.killable = !pl_sd->state.killable;
  7751. if(pl_sd->state.killable)
  7752. clif_displaymessage(fd, msg_txt(289));
  7753. else
  7754. clif_displaymessage(fd, msg_txt(290));
  7755. return 0;
  7756. }
  7757. /*==========================================
  7758. * Make a player killable, by PID
  7759. * Original by Dino9021
  7760. * Added in by nsstrunks
  7761. *------------------------------------------
  7762. */
  7763. int atcommand_charkillableid2( const int fd, struct map_session_data* sd, const char* command, const char* message)
  7764. {
  7765. struct map_session_data *pl_sd = NULL;
  7766. int aid=0;
  7767. if (!message || (aid = atoi(message)) == 0) {
  7768. clif_displaymessage(fd, "Please, enter a player AID.");
  7769. return -1;
  7770. }
  7771. pl_sd = map_id2sd(aid);
  7772. if (!pl_sd) {
  7773. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7774. return -1;
  7775. }
  7776. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7777. {
  7778. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7779. return -1;
  7780. }
  7781. pl_sd->state.killable = !pl_sd->state.killable;
  7782. if(pl_sd->state.killable)
  7783. clif_displaymessage(fd, msg_txt(289));
  7784. else
  7785. clif_displaymessage(fd, msg_txt(290));
  7786. return 0;
  7787. }
  7788. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7789. /*==========================================
  7790. * Mail System commands by [Valaris]
  7791. *------------------------------------------
  7792. */
  7793. int atcommand_listmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7794. {
  7795. if(!mail_server_enable)
  7796. return 0;
  7797. nullpo_retr(-1, sd);
  7798. if(strlen(command)==12)
  7799. mail_check(sd,3);
  7800. else if(strlen(command)==9)
  7801. mail_check(sd,2);
  7802. else
  7803. mail_check(sd,1);
  7804. return 0;
  7805. }
  7806. int atcommand_readmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7807. {
  7808. int index;
  7809. if(!mail_server_enable)
  7810. return 0;
  7811. nullpo_retr(-1, sd);
  7812. if (!message || !*message) {
  7813. clif_displaymessage(sd->fd,"You must specify a message number.");
  7814. return 0;
  7815. }
  7816. index = atoi(message);
  7817. if (index < 1) {
  7818. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  7819. return 0;
  7820. }
  7821. if(strlen(command)==11)
  7822. mail_delete(sd,index);
  7823. else
  7824. mail_read(sd,index);
  7825. return 0;
  7826. }
  7827. int atcommand_sendmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7828. {
  7829. char name[NAME_LENGTH],text[80];
  7830. if(!mail_server_enable)
  7831. return 0;
  7832. nullpo_retr(-1, sd);
  7833. if (!message || !*message) {
  7834. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7835. return 0;
  7836. }
  7837. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  7838. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7839. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7840. return 0;
  7841. }
  7842. if(strlen(command)==17)
  7843. mail_send(sd,name,text,1);
  7844. else
  7845. mail_send(sd,name,text,0);
  7846. return 0;
  7847. }
  7848. /*==========================================
  7849. * Refresh online command for SQL [Valaris]
  7850. * Will refresh and check online column of players and set correctly.
  7851. *------------------------------------------
  7852. */
  7853. int atcommand_refreshonline(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7854. {
  7855. send_users_tochar(-1, gettick(), 0, 0);
  7856. return 0;
  7857. }
  7858. #endif /* end sql only */
  7859. /*==========================================
  7860. * Show Monster DB Info v 1.0
  7861. * originally by [Lupus] eAthena
  7862. *------------------------------------------
  7863. */
  7864. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7865. {
  7866. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  7867. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  7868. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  7869. char atcmd_output2[200];
  7870. struct item_data *item_data;
  7871. struct mob_db *mob, *mob_array[MAX_SEARCH];
  7872. int count;
  7873. int i, j, k;
  7874. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7875. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  7876. if (!message || !*message) {
  7877. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  7878. return -1;
  7879. }
  7880. // If monster identifier/name argument is a name
  7881. if ((i = mobdb_checkid(atoi(message))))
  7882. {
  7883. mob_array[0] = mob_db(i);
  7884. count = 1;
  7885. } else
  7886. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  7887. if (!count) {
  7888. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  7889. return -1;
  7890. }
  7891. if (count > MAX_SEARCH) {
  7892. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  7893. clif_displaymessage(fd, atcmd_output);
  7894. count = MAX_SEARCH;
  7895. }
  7896. for (k = 0; k < count; k++) {
  7897. mob = mob_array[k];
  7898. // stats
  7899. if (mob->mexp)
  7900. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  7901. else
  7902. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  7903. clif_displaymessage(fd, atcmd_output);
  7904. 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);
  7905. clif_displaymessage(fd, atcmd_output);
  7906. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  7907. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  7908. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  7909. clif_displaymessage(fd, atcmd_output);
  7910. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  7911. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  7912. mob->range2 , mob->range3, msize[mob->status.size],
  7913. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  7914. clif_displaymessage(fd, atcmd_output);
  7915. // drops
  7916. clif_displaymessage(fd, " Drops:");
  7917. strcpy(atcmd_output, " ");
  7918. j = 0;
  7919. for (i = 0; i < MAX_MOB_DROP; i++) {
  7920. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  7921. continue;
  7922. if (item_data->slot)
  7923. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  7924. else
  7925. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  7926. strcat(atcmd_output, atcmd_output2);
  7927. if (++j % 3 == 0) {
  7928. clif_displaymessage(fd, atcmd_output);
  7929. strcpy(atcmd_output, " ");
  7930. }
  7931. }
  7932. if (j == 0)
  7933. clif_displaymessage(fd, "This monster has no drops.");
  7934. else if (j % 3 != 0)
  7935. clif_displaymessage(fd, atcmd_output);
  7936. // mvp
  7937. if (mob->mexp) {
  7938. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  7939. clif_displaymessage(fd, atcmd_output);
  7940. strcpy(atcmd_output, " MVP Items:");
  7941. j = 0;
  7942. for (i = 0; i < 3; i++) {
  7943. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  7944. continue;
  7945. if (mob->mvpitem[i].p > 0) {
  7946. j++;
  7947. if (j == 1)
  7948. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  7949. else
  7950. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  7951. strcat(atcmd_output, atcmd_output2);
  7952. }
  7953. }
  7954. if (j == 0)
  7955. clif_displaymessage(fd, "This monster has no MVP prizes.");
  7956. else
  7957. clif_displaymessage(fd, atcmd_output);
  7958. }
  7959. }
  7960. return 0;
  7961. }
  7962. /*=========================================
  7963. * @showmobs by KarLaeda
  7964. * => For 5 sec displays the mobs on minimap
  7965. *------------------------------------------
  7966. */
  7967. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  7968. {
  7969. struct map_session_data *sd;
  7970. if (!session[id] || (sd = session[id]->session_data) == NULL)
  7971. return 0;
  7972. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  7973. return 1;
  7974. }
  7975. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  7976. {
  7977. int mob_id,fd;
  7978. struct map_session_data* sd;
  7979. static int number=0;
  7980. struct mob_data *md;
  7981. if(!ap){
  7982. number=0;
  7983. return 0;
  7984. }
  7985. mob_id = va_arg(ap,int);
  7986. fd = va_arg(ap,int);
  7987. sd = va_arg(ap,struct map_session_data*);
  7988. md = (struct mob_data *)bl;
  7989. if(md->special_state.ai || md->master_id)
  7990. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  7991. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  7992. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  7993. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  7994. }
  7995. return 0;
  7996. }
  7997. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7998. {
  7999. char mob_name[100];
  8000. int mob_id,map_id = 0;
  8001. nullpo_retr(-1, sd);
  8002. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  8003. return -1;
  8004. if ((mob_id = atoi(mob_name)) == 0)
  8005. mob_id = mobdb_searchname(mob_name);
  8006. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  8007. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  8008. clif_displaymessage(fd, atcmd_output);
  8009. return 0;
  8010. }
  8011. // Uncomment the following line to show mini-bosses & MVP.
  8012. //#define SHOW_MVP
  8013. #ifndef SHOW_MVP
  8014. if(mob_db(mob_id)->status.mode&MD_BOSS){
  8015. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  8016. clif_displaymessage(fd, atcmd_output);
  8017. return 0;
  8018. }
  8019. #endif
  8020. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  8021. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  8022. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  8023. map_id = sd->bl.m;
  8024. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  8025. mob_name, mapindex_id2name(sd->mapindex));
  8026. clif_displaymessage(fd, atcmd_output);
  8027. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  8028. atshowmobs_sub(&sd->bl,0);
  8029. return 0;
  8030. }
  8031. /*==========================================
  8032. * homunculus level up [orn]
  8033. *------------------------------------------
  8034. */
  8035. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8036. {
  8037. TBL_HOM * hd;
  8038. int level = 0, i = 0;
  8039. nullpo_retr(-1, sd);
  8040. if (!message || !*message)
  8041. return -1;
  8042. if ( !merc_is_hom_active(sd->hd) )
  8043. return 1 ;
  8044. level = atoi(message);
  8045. hd = sd->hd;
  8046. for (i = 1; i <= level && hd->exp_next; i++){
  8047. hd->homunculus.exp += hd->exp_next;
  8048. merc_hom_levelup(hd);
  8049. }
  8050. status_calc_homunculus(hd,0);
  8051. status_percent_heal(&hd->bl, 100, 100);
  8052. clif_misceffect2(&hd->bl,568);
  8053. return 0;
  8054. }
  8055. /*==========================================
  8056. * homunculus evolution H [orn]
  8057. *------------------------------------------
  8058. */
  8059. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8060. {
  8061. nullpo_retr(-1, sd);
  8062. if (sd->hd && sd->hd->homunculusDB->evo_class)
  8063. {
  8064. merc_hom_evolution(sd->hd) ;
  8065. }
  8066. return 0;
  8067. }
  8068. /*==========================================
  8069. * call choosen homunculus [orn]
  8070. *------------------------------------------
  8071. */
  8072. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8073. {
  8074. int homunid;
  8075. nullpo_retr(-1, sd);
  8076. if(sscanf(message, "%d", &homunid)<1)
  8077. return -1;
  8078. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  8079. return -1;
  8080. if(sd->status.hom_id == 0)
  8081. {
  8082. merc_create_homunculus_request(sd,homunid);
  8083. }
  8084. else
  8085. {
  8086. clif_displaymessage(fd,msg_txt(450));
  8087. }
  8088. return 0;
  8089. }
  8090. /*==========================================
  8091. * modify homunculus intimacy [orn]
  8092. *------------------------------------------
  8093. */
  8094. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8095. {
  8096. int friendly = 0;
  8097. nullpo_retr(-1, sd);
  8098. if (!message || !*message)
  8099. return -1;
  8100. friendly = atoi(message);
  8101. if (merc_is_hom_active(sd->hd)) {
  8102. if (friendly > 0 && friendly <= 1000) {
  8103. sd->hd->homunculus.intimacy = friendly * 100 ;
  8104. clif_send_homdata(sd,SP_INTIMATE,friendly);
  8105. } else {
  8106. return -1;
  8107. }
  8108. }
  8109. return 0;
  8110. }
  8111. /*==========================================
  8112. * modify homunculus hunger [orn]
  8113. *------------------------------------------
  8114. */
  8115. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8116. {
  8117. int hungry = 0;
  8118. nullpo_retr(-1, sd);
  8119. if (!message || !*message)
  8120. return -1;
  8121. hungry = atoi(message);
  8122. if (sd->status.hom_id > 0 && sd->hd) {
  8123. struct homun_data *hd = sd->hd;
  8124. if (hungry >= 0 && hungry <= 100) {
  8125. hd->homunculus.hunger = hungry;
  8126. clif_send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger);
  8127. } else {
  8128. return -1;
  8129. }
  8130. }
  8131. return 0;
  8132. }
  8133. /*==========================================
  8134. * modify homunculus hunger [orn]
  8135. *------------------------------------------
  8136. */
  8137. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8138. {
  8139. char mes[100],temp[100];
  8140. nullpo_retr(-1, sd);
  8141. if(!merc_is_hom_active(sd->hd))
  8142. return -1;
  8143. if (sscanf(message, "%99[^\n]", mes) < 1)
  8144. return -1;
  8145. snprintf(temp, sizeof temp ,"%s : %s",sd->hd->homunculus.name,mes);
  8146. clif_message(&sd->hd->bl, temp);
  8147. return 0;
  8148. }
  8149. /*==========================================
  8150. * Show homunculus stats
  8151. *------------------------------------------
  8152. */
  8153. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8154. {
  8155. struct homun_data *hd;
  8156. struct status_data *status;
  8157. nullpo_retr(-1, sd);
  8158. if(!merc_is_hom_active(sd->hd))
  8159. return -1;
  8160. hd = sd->hd;
  8161. status = status_get_status_data(&hd->bl);
  8162. clif_displaymessage(fd, "Homunculus stats :");
  8163. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  8164. status->hp, status->max_hp, status->sp, status->max_sp);
  8165. clif_displaymessage(fd, atcmd_output);
  8166. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  8167. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  8168. clif_displaymessage(fd, atcmd_output);
  8169. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  8170. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  8171. clif_displaymessage(fd, atcmd_output);
  8172. snprintf(atcmd_output, sizeof(atcmd_output) ,
  8173. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  8174. status->str, status->agi, status->vit,
  8175. status->int_, status->dex, status->luk);
  8176. clif_displaymessage(fd, atcmd_output);
  8177. return 0;
  8178. }
  8179. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8180. {
  8181. struct homun_data *hd;
  8182. struct homunculus_db *db;
  8183. struct s_homunculus *hom;
  8184. int lv;
  8185. nullpo_retr(-1, sd);
  8186. if(!merc_is_hom_active(sd->hd))
  8187. return -1;
  8188. hd = sd->hd;
  8189. hom = &hd->homunculus;
  8190. db = hd->homunculusDB;
  8191. lv = hom->level;
  8192. snprintf(atcmd_output, sizeof(atcmd_output) ,
  8193. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  8194. clif_displaymessage(fd, atcmd_output);
  8195. lv--; //Since the first increase is at level 2.
  8196. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)",
  8197. hom->max_hp, db->basemaxHP +lv*db->gminHP, db->basemaxHP +lv*db->gmaxHP);
  8198. clif_displaymessage(fd, atcmd_output);
  8199. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)",
  8200. hom->max_sp, db->basemaxSP +lv*db->gminSP, db->basemaxSP +lv*db->gmaxSP);
  8201. clif_displaymessage(fd, atcmd_output);
  8202. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)",
  8203. hom->str/10, db->baseSTR +lv*db->gminSTR/10, db->baseSTR +lv*db->gmaxSTR/10);
  8204. clif_displaymessage(fd, atcmd_output);
  8205. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)",
  8206. hom->agi/10, db->baseAGI +lv*db->gminAGI/10, db->baseAGI +lv*db->gmaxAGI/10);
  8207. clif_displaymessage(fd, atcmd_output);
  8208. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)",
  8209. hom->vit/10, db->baseVIT +lv*db->gminVIT/10, db->baseVIT +lv*db->gmaxVIT/10);
  8210. clif_displaymessage(fd, atcmd_output);
  8211. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)",
  8212. hom->int_/10, db->baseINT +lv*db->gminINT/10, db->baseINT +lv*db->gmaxINT/10);
  8213. clif_displaymessage(fd, atcmd_output);
  8214. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)",
  8215. hom->dex/10, db->baseDEX +lv*db->gminDEX/10, db->baseDEX +lv*db->gmaxDEX/10);
  8216. clif_displaymessage(fd, atcmd_output);
  8217. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)",
  8218. hom->luk/10, db->baseLUK +lv*db->gminLUK/10, db->baseLUK +lv*db->gmaxLUK/10);
  8219. clif_displaymessage(fd, atcmd_output);
  8220. return 0;
  8221. }
  8222. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8223. {
  8224. struct homun_data *hd;
  8225. int lv, i, skillpts;
  8226. unsigned int exp;
  8227. struct skill b_skill;
  8228. TBL_PC* tsd = sd;
  8229. nullpo_retr(-1, sd);
  8230. if ((!message || !*message) && !sd->hd)
  8231. {
  8232. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  8233. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  8234. return -1;
  8235. }
  8236. if (message && *message) {
  8237. tsd = map_nick2sd((char*)message);
  8238. if (!tsd) {
  8239. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8240. return -1;
  8241. }
  8242. if (pc_isGM(tsd) > pc_isGM(sd)) {
  8243. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8244. return -1;
  8245. }
  8246. }
  8247. hd = tsd->hd;
  8248. if(!merc_is_hom_active(hd))
  8249. return -1;
  8250. lv = hd->homunculus.level;
  8251. exp = hd->homunculus.exp;
  8252. memcpy(&b_skill, &hd->homunculus.hskill, sizeof(b_skill));
  8253. skillpts = hd->homunculus.skillpts;
  8254. //Reset values to level 1.
  8255. merc_reset_stats(hd);
  8256. //Level it back up
  8257. for (i = 1; i < lv && hd->exp_next; i++){
  8258. hd->homunculus.exp += hd->exp_next;
  8259. merc_hom_levelup(hd);
  8260. }
  8261. hd->homunculus.exp = exp;
  8262. memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill));
  8263. hd->homunculus.skillpts = skillpts;
  8264. status_calc_homunculus(hd,0);
  8265. status_percent_heal(&hd->bl, 100, 100);
  8266. clif_misceffect2(&hd->bl,568);
  8267. clif_displaymessage(fd, "Homunculus stats altered");
  8268. //Print out the new stats
  8269. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  8270. atcommand_homstats(fd, tsd, command, message);
  8271. return 0;
  8272. }
  8273. /*==========================================
  8274. * Show Items DB Info v 1.0
  8275. * originally by [Lupus] eAthena
  8276. *------------------------------------------
  8277. */
  8278. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8279. {
  8280. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8281. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8282. struct item_data *item_data, *item_array[MAX_SEARCH];
  8283. int i, count = 1;
  8284. if (!message || !*message) {
  8285. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8286. return -1;
  8287. }
  8288. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8289. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8290. if (!count) {
  8291. clif_displaymessage(fd, "Item not found.");
  8292. return -1;
  8293. }
  8294. if (count > MAX_SEARCH) {
  8295. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8296. clif_displaymessage(fd, atcmd_output);
  8297. count = MAX_SEARCH;
  8298. }
  8299. for (i = 0; i < count; i++) {
  8300. item_data = item_array[i];
  8301. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8302. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  8303. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8304. (item_data->script==NULL)? "None" : "With script"
  8305. );
  8306. clif_displaymessage(fd, atcmd_output);
  8307. 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. );
  8308. clif_displaymessage(fd, atcmd_output);
  8309. if (item_data->maxchance == 10000)
  8310. strcpy(atcmd_output, " - Available in the shops only");
  8311. else if (item_data->maxchance)
  8312. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8313. else
  8314. strcpy(atcmd_output, " - Monsters don't drop this item");
  8315. clif_displaymessage(fd, atcmd_output);
  8316. }
  8317. return 0;
  8318. }
  8319. /*==========================================
  8320. * Show who drops the item.
  8321. *------------------------------------------
  8322. */
  8323. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8324. {
  8325. struct item_data *item_data, *item_array[MAX_SEARCH];
  8326. int i,j, count = 1;
  8327. if (!message || !*message) {
  8328. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8329. return -1;
  8330. }
  8331. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8332. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8333. if (!count) {
  8334. clif_displaymessage(fd, "Item not found.");
  8335. return -1;
  8336. }
  8337. if (count > MAX_SEARCH) {
  8338. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8339. clif_displaymessage(fd, atcmd_output);
  8340. count = MAX_SEARCH;
  8341. }
  8342. for (i = 0; i < count; i++) {
  8343. item_data = item_array[i];
  8344. sprintf(atcmd_output, "Item: '%s'[%d]",
  8345. item_data->jname,item_data->slot);
  8346. clif_displaymessage(fd, atcmd_output);
  8347. if (item_data->mob[0].chance == 0) {
  8348. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8349. clif_displaymessage(fd, atcmd_output);
  8350. } else {
  8351. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8352. clif_displaymessage(fd, atcmd_output);
  8353. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8354. {
  8355. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8356. clif_displaymessage(fd, atcmd_output);
  8357. }
  8358. }
  8359. }
  8360. return 0;
  8361. }
  8362. /*==========================================
  8363. * @adopt by [Veider]
  8364. *
  8365. * adopt a novice
  8366. *------------------------------------------
  8367. */
  8368. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8369. {
  8370. struct map_session_data *pl_sd1 = NULL;
  8371. struct map_session_data *pl_sd2 = NULL;
  8372. struct map_session_data *pl_sd3 = NULL;
  8373. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8374. nullpo_retr(-1, sd);
  8375. if (!message || !*message)
  8376. return -1;
  8377. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8378. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8379. return -1;
  8380. }
  8381. if (battle_config.etc_log)
  8382. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8383. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8384. sprintf(player2, "Cannot find player %s online", player1);
  8385. clif_displaymessage(fd, player2);
  8386. return -1;
  8387. }
  8388. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8389. sprintf(player1, "Cannot find player %s online", player2);
  8390. clif_displaymessage(fd, player1);
  8391. return -1;
  8392. }
  8393. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8394. sprintf(player1, "Cannot find player %s online", player3);
  8395. clif_displaymessage(fd, player1);
  8396. return -1;
  8397. }
  8398. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8399. clif_displaymessage(fd, "They are too young to be parents!");
  8400. return -1;
  8401. }
  8402. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8403. clif_displaymessage(fd, "They are family.. wish them luck");
  8404. return 0;
  8405. }
  8406. else
  8407. return -1;
  8408. }
  8409. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8410. {
  8411. const char * revision;
  8412. if ((revision = get_svn_revision()) != 0) {
  8413. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8414. clif_displaymessage(fd,atcmd_output);
  8415. } else
  8416. clif_displaymessage(fd,"Cannot determine SVN revision");
  8417. return 0;
  8418. }
  8419. /*==========================================
  8420. * @mutearea by MouseJstr
  8421. *------------------------------------------
  8422. */
  8423. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8424. {
  8425. int time, id;
  8426. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8427. if (pl_sd == NULL)
  8428. return 0;
  8429. id = va_arg(ap, int);
  8430. time = va_arg(ap, int);
  8431. if (id != bl->id && !pc_isGM(pl_sd)) {
  8432. pl_sd->status.manner -= time;
  8433. if (pl_sd->status.manner < 0)
  8434. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8435. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8436. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8437. }
  8438. return 0;
  8439. }
  8440. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8441. {
  8442. int time;
  8443. nullpo_retr(0, sd);
  8444. time = atoi(message);
  8445. if (!time)
  8446. time = 15; // 15 minutes default
  8447. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8448. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8449. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8450. return 0;
  8451. }
  8452. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8453. {
  8454. char buf[255];
  8455. nullpo_retr(0, sd);
  8456. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8457. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8458. clif_displaymessage(fd, buf);
  8459. return 0;
  8460. }
  8461. /*==========================================
  8462. * @me by lordalfa
  8463. * => Displays the OUTPUT string on top of the Visible players Heads.
  8464. *------------------------------------------
  8465. */
  8466. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8467. {
  8468. char tempmes[200];
  8469. nullpo_retr(-1, sd);
  8470. memset(tempmes, '\0', sizeof(tempmes));
  8471. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8472. if (sd->sc.count && //no "chatting" while muted.
  8473. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  8474. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  8475. return -1;
  8476. if (!message || !*message) {
  8477. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8478. return -1;
  8479. }
  8480. sscanf(message, "%199[^\n]", tempmes);
  8481. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8482. clif_disp_overhead(sd, atcmd_output);
  8483. return 0;
  8484. }
  8485. /*==========================================
  8486. * @size
  8487. * => Resize your character sprite. [Valaris]
  8488. *------------------------------------------
  8489. */
  8490. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8491. {
  8492. int size=0;
  8493. nullpo_retr(-1, sd);
  8494. if (!message || !*message)
  8495. return -1;
  8496. if (sscanf(message,"%d", &size) < 1)
  8497. return -1;
  8498. if(sd->state.size) {
  8499. sd->state.size=0;
  8500. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8501. }
  8502. if(size==1) {
  8503. sd->state.size=1;
  8504. clif_specialeffect(&sd->bl,420,AREA);
  8505. } else if(size==2) {
  8506. sd->state.size=2;
  8507. clif_specialeffect(&sd->bl,422,AREA);
  8508. }
  8509. return 0;
  8510. }
  8511. /*==========================================
  8512. * @monsterignore
  8513. * => Makes monsters ignore you. [Valaris]
  8514. *------------------------------------------
  8515. */
  8516. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8517. {
  8518. nullpo_retr(-1, sd);
  8519. if (!sd->state.monster_ignore) {
  8520. sd->state.monster_ignore = 1;
  8521. clif_displaymessage(sd->fd, "You are now inmune to attacks.");
  8522. } else {
  8523. sd->state.monster_ignore = 0;
  8524. clif_displaymessage(sd->fd, "Returned to normal state.");
  8525. }
  8526. return 0;
  8527. }
  8528. /*==========================================
  8529. * @fakename
  8530. * => Gives your character a fake name. [Valaris]
  8531. *------------------------------------------
  8532. */
  8533. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8534. {
  8535. char name[NAME_LENGTH];
  8536. nullpo_retr(-1, sd);
  8537. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8538. sd->fakename[0]='\0';
  8539. clif_charnameack(0, &sd->bl);
  8540. clif_displaymessage(sd->fd,"Returned to real name.");
  8541. return 0;
  8542. }
  8543. if (!message || !*message) {
  8544. clif_displaymessage(sd->fd,"You must enter a name.");
  8545. return 0;
  8546. }
  8547. if (sscanf(message, "%23[^\n]", name) < 1) {
  8548. return 0;
  8549. }
  8550. if(strlen(name) < 2) {
  8551. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8552. return 0;
  8553. }
  8554. memcpy(sd->fakename,name,NAME_LENGTH);
  8555. sd->fakename[NAME_LENGTH-1] = '\0';
  8556. clif_charnameack(0, &sd->bl);
  8557. clif_displaymessage(sd->fd,"Fake name enabled.");
  8558. return 0;
  8559. }
  8560. /*==========================================
  8561. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  8562. * => Shows information about the map flags [map name]
  8563. * Also set flags
  8564. *------------------------------------------
  8565. */
  8566. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8567. {
  8568. // WIP
  8569. return 0;
  8570. }
  8571. /*===================================
  8572. * Remove some messages
  8573. *-----------------------------------
  8574. */
  8575. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8576. {
  8577. if (sd->state.showexp) {
  8578. sd->state.showexp = 0;
  8579. clif_displaymessage(fd, "Gained exp will not be shown.");
  8580. return 0;
  8581. }
  8582. sd->state.showexp = 1;
  8583. clif_displaymessage(fd, "Gained exp is now shown");
  8584. return 0;
  8585. }
  8586. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8587. {
  8588. if (sd->state.showzeny) {
  8589. sd->state.showzeny = 0;
  8590. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8591. return 0;
  8592. }
  8593. sd->state.showzeny = 1;
  8594. clif_displaymessage(fd, "Gained zeny is now shown");
  8595. return 0;
  8596. }
  8597. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8598. {
  8599. if (sd->state.showdelay) {
  8600. sd->state.showdelay = 0;
  8601. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8602. return 0;
  8603. }
  8604. sd->state.showdelay = 1;
  8605. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8606. return 0;
  8607. }
  8608. /*==========================================
  8609. * Duel organizing functions [LuzZza]
  8610. *
  8611. * @duel [limit|nick] - create a duel
  8612. * @invite <nick> - invite player
  8613. * @accept - accept invitation
  8614. * @reject - reject invitation
  8615. * @leave - leave duel
  8616. *------------------------------------------
  8617. */
  8618. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8619. {
  8620. unsigned int did = sd->duel_group;
  8621. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8622. if(did <= 0) {
  8623. // "Duel: @invite without @duel."
  8624. clif_displaymessage(fd, msg_txt(350));
  8625. return 0;
  8626. }
  8627. if(duel_list[did].max_players_limit > 0 &&
  8628. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8629. // "Duel: Limit of players is reached."
  8630. clif_displaymessage(fd, msg_txt(351));
  8631. return 0;
  8632. }
  8633. if(target_sd == NULL) {
  8634. // "Duel: Player not found."
  8635. clif_displaymessage(fd, msg_txt(352));
  8636. return 0;
  8637. }
  8638. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8639. // "Duel: Player already in duel."
  8640. clif_displaymessage(fd, msg_txt(353));
  8641. return 0;
  8642. }
  8643. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  8644. {
  8645. sprintf(atcmd_output, msg_txt(364), message);
  8646. clif_displaymessage(fd, atcmd_output);
  8647. return 0;
  8648. }
  8649. duel_invite(did, sd, target_sd);
  8650. // "Duel: Invitation has been sent."
  8651. clif_displaymessage(fd, msg_txt(354));
  8652. return 0;
  8653. }
  8654. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8655. {
  8656. char output[256];
  8657. unsigned int maxpl=0, newduel;
  8658. struct map_session_data *target_sd;
  8659. /* // Commnted because it can be disabled in at-comms conf.
  8660. if(!battle_config.duel_enable) {
  8661. clif_displaymessage(fd, "Duel: duel is disable.");
  8662. return 0;
  8663. }
  8664. */
  8665. if(sd->duel_group > 0) {
  8666. duel_showinfo(sd->duel_group, sd);
  8667. return 0;
  8668. }
  8669. if(sd->duel_invite > 0) {
  8670. // "Duel: @duel without @reject."
  8671. clif_displaymessage(fd, msg_txt(355));
  8672. return 0;
  8673. }
  8674. if(!duel_checktime(sd)) {
  8675. // "Duel: You can take part in duel only one time per %d minutes."
  8676. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8677. clif_displaymessage(fd, output);
  8678. return 0;
  8679. }
  8680. if(strlen(message) > 0) {
  8681. if(sscanf(message, "%d", &maxpl) >= 1) {
  8682. if(maxpl < 2 || maxpl > 65535) {
  8683. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8684. return 0;
  8685. }
  8686. duel_create(sd, maxpl);
  8687. } else {
  8688. target_sd = map_nick2sd((char *)message);
  8689. if(target_sd != NULL) {
  8690. if((newduel = duel_create(sd, 2)) != -1) {
  8691. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8692. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8693. return 0;
  8694. }
  8695. duel_invite(newduel, sd, target_sd);
  8696. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8697. }
  8698. } else {
  8699. // "Duel: Player not found."
  8700. clif_displaymessage(fd, msg_txt(352));
  8701. return 0;
  8702. }
  8703. }
  8704. } else
  8705. duel_create(sd, 0);
  8706. return 0;
  8707. }
  8708. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8709. {
  8710. if(sd->duel_group <= 0) {
  8711. // "Duel: @leave without @duel."
  8712. clif_displaymessage(fd, msg_txt(358));
  8713. return 0;
  8714. }
  8715. duel_leave(sd->duel_group, sd);
  8716. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8717. return 0;
  8718. }
  8719. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8720. {
  8721. char output[256];
  8722. if(!duel_checktime(sd)) {
  8723. // "Duel: You can take part in duel only one time per %d minutes."
  8724. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8725. clif_displaymessage(fd, output);
  8726. return 0;
  8727. }
  8728. if(sd->duel_invite <= 0) {
  8729. // "Duel: @accept without invititation."
  8730. clif_displaymessage(fd, msg_txt(360));
  8731. return 0;
  8732. }
  8733. duel_accept(sd->duel_invite, sd);
  8734. // "Duel: Invitation has been accepted."
  8735. clif_displaymessage(fd, msg_txt(361));
  8736. return 0;
  8737. }
  8738. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8739. {
  8740. if(sd->duel_invite <= 0) {
  8741. // "Duel: @reject without invititation."
  8742. clif_displaymessage(fd, msg_txt(362));
  8743. return 0;
  8744. }
  8745. duel_reject(sd->duel_invite, sd);
  8746. // "Duel: Invitation has been rejected."
  8747. clif_displaymessage(fd, msg_txt(363));
  8748. return 0;
  8749. }
  8750. /*===================================
  8751. * Away message (@away, @aw) [LuzZza]
  8752. *-----------------------------------
  8753. */
  8754. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8755. {
  8756. if(strlen(message) > 0) {
  8757. if(strlen(message) > 128)
  8758. return -1;
  8759. strcpy(sd->away_message, message);
  8760. //"Away automessage has been activated."
  8761. clif_displaymessage(fd, msg_txt(546));
  8762. } else {
  8763. if(strlen(sd->away_message) > 0) {
  8764. sd->away_message[0] = 0;
  8765. //"Away automessage has been disabled."
  8766. clif_displaymessage(fd, msg_txt(547));
  8767. return 0;
  8768. }
  8769. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8770. clif_displaymessage(fd, msg_txt(548));
  8771. }
  8772. return 0;
  8773. }
  8774. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8775. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8776. {
  8777. int x=0,y=0,flag=0,master=0,i=0;
  8778. struct map_session_data *pl_sd=NULL;
  8779. if (!message || !*message) {
  8780. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8781. return 0;
  8782. }
  8783. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8784. clif_displaymessage(fd, msg_txt(3));
  8785. return 0;
  8786. }
  8787. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8788. clif_displaymessage(fd, msg_txt(126));
  8789. return 0;
  8790. }
  8791. if (strcmpi(command, "@clone") == 0)
  8792. flag = 1;
  8793. else if (strcmpi(command, "@slaveclone") == 0) {
  8794. flag = 2;
  8795. master = sd->bl.id;
  8796. if (battle_config.atc_slave_clone_limit
  8797. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8798. clif_displaymessage(fd, msg_txt(127));
  8799. return 0;
  8800. }
  8801. }
  8802. do {
  8803. x = sd->bl.x + (rand() % 10 - 5);
  8804. y = sd->bl.y + (rand() % 10 - 5);
  8805. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8806. if (i >= 10) {
  8807. x = sd->bl.x;
  8808. y = sd->bl.y;
  8809. }
  8810. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8811. clif_displaymessage(fd, msg_txt(128+flag*2));
  8812. return 0;
  8813. }
  8814. clif_displaymessage(fd, msg_txt(129+flag*2));
  8815. return 0;
  8816. }
  8817. /*===================================
  8818. * Main chat [LuzZza]
  8819. * Usage: @main <on|off|message>
  8820. *-----------------------------------
  8821. */
  8822. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8823. {
  8824. if(strlen(message) > 0) {
  8825. if(strcmpi(message, "on") == 0) {
  8826. if(!sd->state.mainchat) {
  8827. sd->state.mainchat = 1;
  8828. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8829. } else {
  8830. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8831. }
  8832. } else if(strcmpi(message, "off") == 0) {
  8833. if(sd->state.mainchat) {
  8834. sd->state.mainchat = 0;
  8835. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8836. } else {
  8837. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8838. }
  8839. } else {
  8840. if(!sd->state.mainchat) {
  8841. sd->state.mainchat = 1;
  8842. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8843. }
  8844. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  8845. clif_displaymessage(fd, msg_txt(387));
  8846. return -1;
  8847. }
  8848. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8849. // I use 0xFE000000 color for signalizing that this message is
  8850. // main chat message. 0xFE000000 is invalid color, same using
  8851. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8852. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8853. }
  8854. } else {
  8855. if(sd->state.mainchat)
  8856. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8857. clif_displaymessage(fd, msg_txt(384));
  8858. else
  8859. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8860. clif_displaymessage(fd, msg_txt(385));
  8861. }
  8862. return 0;
  8863. }
  8864. /*=====================================
  8865. * Autorejecting Invites/Deals [LuzZza]
  8866. * Usage: @noask
  8867. *-------------------------------------
  8868. */
  8869. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8870. {
  8871. if(sd->state.noask) {
  8872. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  8873. sd->state.noask = 0;
  8874. } else {
  8875. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  8876. sd->state.noask = 1;
  8877. }
  8878. return 0;
  8879. }
  8880. /*=====================================
  8881. * Send a @request message to all GMs of lowest_gm_level.
  8882. * Usage: @request <petition>
  8883. *-------------------------------------
  8884. */
  8885. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8886. {
  8887. if (!message || !*message) {
  8888. clif_displaymessage(sd->fd,msg_txt(277));
  8889. return -1;
  8890. }
  8891. sprintf(atcmd_output, msg_txt(278), message);
  8892. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  8893. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  8894. clif_displaymessage(sd->fd,msg_txt(279));
  8895. return 0;
  8896. }
  8897. void do_init_atcommand()
  8898. {
  8899. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8900. duel_count = 0;
  8901. memset(&duel_list[0], 0, sizeof(duel_list));
  8902. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  8903. return;
  8904. }
  8905. void do_final_atcommand()
  8906. {
  8907. users_db->destroy(users_db,NULL);
  8908. }