atcommand.c 310 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264
  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 <limits.h>
  9. #include "../common/socket.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/mmo.h"
  13. #include "../common/core.h"
  14. #include "../common/showmsg.h"
  15. #include "log.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "intif.h"
  19. #include "itemdb.h"
  20. #include "map.h"
  21. #include "pc.h"
  22. #include "status.h"
  23. #include "skill.h"
  24. #include "mob.h"
  25. #include "pet.h"
  26. #include "battle.h"
  27. #include "party.h"
  28. #include "guild.h"
  29. #include "atcommand.h"
  30. #include "script.h"
  31. #include "npc.h"
  32. #include "trade.h"
  33. #include "unit.h"
  34. #ifndef TXT_ONLY
  35. #include "mail.h"
  36. #endif
  37. static char command_symbol = '@'; // first char of the commands (by [Yor])
  38. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  39. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  40. ACMD_FUNC(broadcast);
  41. ACMD_FUNC(localbroadcast);
  42. ACMD_FUNC(rura);
  43. ACMD_FUNC(where);
  44. ACMD_FUNC(jumpto);
  45. ACMD_FUNC(jump);
  46. ACMD_FUNC(who);
  47. ACMD_FUNC(who2);
  48. ACMD_FUNC(who3);
  49. ACMD_FUNC(whomap);
  50. ACMD_FUNC(whomap2);
  51. ACMD_FUNC(whomap3);
  52. ACMD_FUNC(whogm); // by Yor
  53. ACMD_FUNC(whozeny); // [Valaris]
  54. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  55. ACMD_FUNC(save);
  56. ACMD_FUNC(load);
  57. ACMD_FUNC(speed);
  58. ACMD_FUNC(storage);
  59. ACMD_FUNC(guildstorage);
  60. ACMD_FUNC(option);
  61. ACMD_FUNC(hide);
  62. ACMD_FUNC(jobchange);
  63. ACMD_FUNC(die);
  64. ACMD_FUNC(kill);
  65. ACMD_FUNC(alive);
  66. ACMD_FUNC(kami);
  67. ACMD_FUNC(heal);
  68. ACMD_FUNC(item);
  69. ACMD_FUNC(item2);
  70. ACMD_FUNC(itemreset);
  71. ACMD_FUNC(itemcheck);
  72. ACMD_FUNC(baselevelup);
  73. ACMD_FUNC(joblevelup);
  74. ACMD_FUNC(help);
  75. ACMD_FUNC(help2);
  76. ACMD_FUNC(gm);
  77. ACMD_FUNC(pvpoff);
  78. ACMD_FUNC(pvpon);
  79. ACMD_FUNC(gvgoff);
  80. ACMD_FUNC(gvgon);
  81. ACMD_FUNC(model);
  82. ACMD_FUNC(go);
  83. ACMD_FUNC(monster);
  84. ACMD_FUNC(monstersmall);
  85. ACMD_FUNC(monsterbig);
  86. ACMD_FUNC(spawn);
  87. ACMD_FUNC(killmonster);
  88. ACMD_FUNC(killmonster2);
  89. ACMD_FUNC(refine);
  90. ACMD_FUNC(produce);
  91. ACMD_FUNC(memo);
  92. ACMD_FUNC(gat);
  93. ACMD_FUNC(packet);
  94. ACMD_FUNC(waterlevel);
  95. ACMD_FUNC(statuspoint);
  96. ACMD_FUNC(skillpoint);
  97. ACMD_FUNC(zeny);
  98. ACMD_FUNC(param);
  99. ACMD_FUNC(guildlevelup);
  100. ACMD_FUNC(makeegg);
  101. ACMD_FUNC(hatch);
  102. ACMD_FUNC(petfriendly);
  103. ACMD_FUNC(pethungry);
  104. ACMD_FUNC(petrename);
  105. ACMD_FUNC(recall);
  106. ACMD_FUNC(recallall);
  107. ACMD_FUNC(revive);
  108. ACMD_FUNC(night);
  109. ACMD_FUNC(day);
  110. ACMD_FUNC(doom);
  111. ACMD_FUNC(doommap);
  112. ACMD_FUNC(raise);
  113. ACMD_FUNC(raisemap);
  114. ACMD_FUNC(kick);
  115. ACMD_FUNC(kickall);
  116. ACMD_FUNC(allskill);
  117. ACMD_FUNC(questskill);
  118. ACMD_FUNC(lostskill);
  119. ACMD_FUNC(spiritball);
  120. ACMD_FUNC(party);
  121. ACMD_FUNC(guild);
  122. ACMD_FUNC(agitstart);
  123. ACMD_FUNC(agitend);
  124. ACMD_FUNC(reloaditemdb);
  125. ACMD_FUNC(reloadmobdb);
  126. ACMD_FUNC(reloadskilldb);
  127. ACMD_FUNC(reloadscript);
  128. ACMD_FUNC(reloadgmdb); // by Yor
  129. ACMD_FUNC(reloadatcommand);
  130. ACMD_FUNC(reloadbattleconf);
  131. ACMD_FUNC(reloadstatusdb);
  132. ACMD_FUNC(reloadpcdb);
  133. ACMD_FUNC(reloadmotd); // [Valaris]
  134. ACMD_FUNC(mapexit);
  135. ACMD_FUNC(idsearch);
  136. ACMD_FUNC(mapinfo);
  137. ACMD_FUNC(dye); //** by fritz
  138. ACMD_FUNC(hair_style); //** by fritz
  139. ACMD_FUNC(hair_color); //** by fritz
  140. ACMD_FUNC(stat_all); //** by fritz
  141. ACMD_FUNC(char_block); // by Yor
  142. ACMD_FUNC(char_ban); // by Yor
  143. ACMD_FUNC(char_unblock); // by Yor
  144. ACMD_FUNC(char_unban); // by Yor
  145. ACMD_FUNC(mount_peco); // by Valaris
  146. ACMD_FUNC(char_mount_peco); // by Yor
  147. ACMD_FUNC(guildspy); // [Syrus22]
  148. ACMD_FUNC(partyspy); // [Syrus22]
  149. ACMD_FUNC(repairall); // [Valaris]
  150. ACMD_FUNC(guildrecall); // by Yor
  151. ACMD_FUNC(partyrecall); // by Yor
  152. ACMD_FUNC(nuke); // [Valaris]
  153. ACMD_FUNC(shownpc);
  154. ACMD_FUNC(hidenpc);
  155. ACMD_FUNC(loadnpc);
  156. ACMD_FUNC(unloadnpc);
  157. ACMD_FUNC(servertime); // by Yor
  158. ACMD_FUNC(chardelitem); // by Yor
  159. ACMD_FUNC(jail); // by Yor
  160. ACMD_FUNC(unjail); // by Yor
  161. ACMD_FUNC(disguise); // [Valaris]
  162. ACMD_FUNC(undisguise); // by Yor
  163. ACMD_FUNC(chardisguise); // Kalaspuff
  164. ACMD_FUNC(charundisguise); // Kalaspuff
  165. ACMD_FUNC(email); // by Yor
  166. ACMD_FUNC(effect);//by Apple
  167. ACMD_FUNC(character_cart_list); // by Yor
  168. ACMD_FUNC(addwarp); // by MouseJstr
  169. ACMD_FUNC(follow); // by MouseJstr
  170. ACMD_FUNC(skillon); // by MouseJstr
  171. ACMD_FUNC(skilloff); // by MouseJstr
  172. ACMD_FUNC(killer); // by MouseJstr
  173. ACMD_FUNC(npcmove); // by MouseJstr
  174. ACMD_FUNC(killable); // by MouseJstr
  175. ACMD_FUNC(charkillable); // by MouseJstr
  176. ACMD_FUNC(dropall); // by MouseJstr
  177. ACMD_FUNC(chardropall); // by MouseJstr
  178. ACMD_FUNC(storeall); // by MouseJstr
  179. ACMD_FUNC(charstoreall); // by MouseJstr
  180. ACMD_FUNC(skillid); // by MouseJstr
  181. ACMD_FUNC(useskill); // by MouseJstr
  182. ACMD_FUNC(summon);
  183. ACMD_FUNC(rain);
  184. ACMD_FUNC(snow);
  185. ACMD_FUNC(sakura);
  186. ACMD_FUNC(clouds);
  187. ACMD_FUNC(clouds2); // [Valaris]
  188. ACMD_FUNC(fog);
  189. ACMD_FUNC(fireworks);
  190. ACMD_FUNC(leaves);
  191. ACMD_FUNC(adjgmlvl); // by MouseJstr
  192. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  193. ACMD_FUNC(trade); // by MouseJstr
  194. ACMD_FUNC(send); // by davidsiaw
  195. ACMD_FUNC(setbattleflag); // by MouseJstr
  196. ACMD_FUNC(unmute); // [Valaris]
  197. ACMD_FUNC(clearweather); // Dexity
  198. ACMD_FUNC(uptime); // by MC Cameri
  199. ACMD_FUNC(changesex); // by MC Cameri
  200. ACMD_FUNC(mute); // celest
  201. ACMD_FUNC(refresh); // by MC Cameri
  202. ACMD_FUNC(petid); // by MC Cameri
  203. ACMD_FUNC(identify); // by MC Cameri
  204. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  205. ACMD_FUNC(misceffect); // by MC Cameri
  206. ACMD_FUNC(mobsearch);
  207. ACMD_FUNC(cleanmap);
  208. ACMD_FUNC(npctalk);
  209. ACMD_FUNC(pettalk);
  210. ACMD_FUNC(users);
  211. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  212. #ifndef TXT_ONLY
  213. ACMD_FUNC(checkmail); // [Valaris]
  214. ACMD_FUNC(listmail); // [Valaris]
  215. ACMD_FUNC(listnewmail); // [Valaris]
  216. ACMD_FUNC(readmail); // [Valaris]
  217. ACMD_FUNC(sendmail); // [Valaris]
  218. ACMD_FUNC(sendprioritymail); // [Valaris]
  219. ACMD_FUNC(deletemail); // [Valaris]
  220. ACMD_FUNC(refreshonline); // [Valaris]
  221. #endif /* TXT_ONLY */
  222. ACMD_FUNC(skilltree); // by MouseJstr
  223. ACMD_FUNC(marry); // by MouseJstr
  224. ACMD_FUNC(divorce); // by MouseJstr
  225. ACMD_FUNC(grind); // by MouseJstr
  226. ACMD_FUNC(grind2); // by MouseJstr
  227. #ifdef DMALLOC
  228. ACMD_FUNC(dmstart); // by MouseJstr
  229. ACMD_FUNC(dmtick); // by MouseJstr
  230. #endif
  231. ACMD_FUNC(jumptoid); // by Dino9021
  232. ACMD_FUNC(jumptoid2); // by Dino9021
  233. ACMD_FUNC(recallid); // by Dino9021
  234. ACMD_FUNC(recallid2); // by Dino9021
  235. ACMD_FUNC(kickid); // by Dino9021
  236. ACMD_FUNC(kickid2); // by Dino9021
  237. ACMD_FUNC(reviveid); // by Dino9021
  238. ACMD_FUNC(reviveid2); // by Dino9021
  239. ACMD_FUNC(killid); // by Dino9021
  240. ACMD_FUNC(killid2); // by Dino9021
  241. ACMD_FUNC(charkillableid); // by Dino9021
  242. ACMD_FUNC(charkillableid2); // by Dino9021
  243. ACMD_FUNC(sound);
  244. ACMD_FUNC(undisguiseall);
  245. ACMD_FUNC(disguiseall);
  246. ACMD_FUNC(changelook);
  247. ACMD_FUNC(mobinfo); //by Lupus
  248. ACMD_FUNC(exp); // by Skotlex
  249. ACMD_FUNC(adopt); // by Veider
  250. ACMD_FUNC(version); // by Ancyker
  251. ACMD_FUNC(mutearea); // by MouseJstr
  252. ACMD_FUNC(shuffle); // by MouseJstr
  253. ACMD_FUNC(rates); // by MouseJstr
  254. ACMD_FUNC(iteminfo); // Lupus
  255. ACMD_FUNC(whodrops); //Skotlex
  256. ACMD_FUNC(mapflag); // Lupus
  257. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  258. ACMD_FUNC(monsterignore); // [Valaris]
  259. ACMD_FUNC(fakename); //[Valaris]
  260. ACMD_FUNC(size); //[Valaris]
  261. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  262. ACMD_FUNC(showzeny);
  263. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  264. ACMD_FUNC(autotrade);// durf
  265. ACMD_FUNC(changeleader);// [Skotlex]
  266. ACMD_FUNC(changegm);// durf
  267. // Duel [LuzZza]
  268. ACMD_FUNC(invite);
  269. ACMD_FUNC(duel);
  270. ACMD_FUNC(leave);
  271. ACMD_FUNC(accept);
  272. ACMD_FUNC(reject);
  273. ACMD_FUNC(away); // LuzZza
  274. ACMD_FUNC(main); // LuzZza
  275. ACMD_FUNC(clone); // [Valaris]
  276. ACMD_FUNC(tonpc); // LuzZza
  277. ACMD_FUNC(commands); // [Skotlex]
  278. ACMD_FUNC(noask); //LuzZza
  279. ACMD_FUNC(request); //[Skotlex]
  280. /*==========================================
  281. *AtCommandInfo atcommand_info[]構造体の定義
  282. *------------------------------------------
  283. */
  284. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  285. // to set default level, read atcommand_athena.conf first please.
  286. static AtCommandInfo atcommand_info[] = {
  287. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  288. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  289. { AtCommand_Where, "@where", 1, atcommand_where },
  290. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  291. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  292. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  293. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  294. { AtCommand_Who, "@who", 20, atcommand_who },
  295. { AtCommand_Who, "@whois", 20, atcommand_who },
  296. { AtCommand_Who, "@w", 20, atcommand_who },
  297. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  298. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  299. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  300. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  301. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  302. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  303. { AtCommand_Save, "@save", 40, atcommand_save },
  304. { AtCommand_Load, "@return", 40, atcommand_load },
  305. { AtCommand_Load, "@load", 40, atcommand_load },
  306. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  307. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  308. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  309. { AtCommand_Option, "@option", 40, atcommand_option },
  310. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  311. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  312. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  313. { AtCommand_Die, "@die", 1, atcommand_die },
  314. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  315. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  316. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  317. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  318. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  319. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  320. { AtCommand_Item, "@item", 60, atcommand_item },
  321. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  322. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  323. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  324. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  325. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  326. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  327. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  328. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  329. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  330. { AtCommand_H, "@h", 20, atcommand_help },
  331. { AtCommand_Help, "@help", 20, atcommand_help },
  332. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  333. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  334. { AtCommand_GM, "@gm", 100,atcommand_gm },
  335. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  336. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  337. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  338. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  339. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  340. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  341. { AtCommand_Model, "@model", 20, atcommand_model },
  342. { AtCommand_Go, "@go", 10, atcommand_go },
  343. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  344. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  345. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  346. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  347. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  348. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  349. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  350. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  351. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  352. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  353. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  354. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  355. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  356. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  357. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  358. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  359. { AtCommand_Strength, "@str", 60, atcommand_param },
  360. { AtCommand_Agility, "@agi", 60, atcommand_param },
  361. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  362. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  363. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  364. { AtCommand_Luck, "@luk", 60, atcommand_param },
  365. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  366. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  367. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  368. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  369. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  370. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  371. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  372. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  373. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  374. { AtCommand_Night, "@night", 80, atcommand_night },
  375. { AtCommand_Day, "@day", 80, atcommand_day },
  376. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  377. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  378. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  379. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  380. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  381. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  382. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  383. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  384. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  385. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  386. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  387. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  388. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  389. { AtCommand_Party, "@party", 1, atcommand_party },
  390. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  391. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  392. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  393. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  394. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  395. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  396. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  397. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  398. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  399. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  400. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  401. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  402. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  403. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  404. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  405. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  406. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  407. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  408. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  409. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  410. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  411. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  412. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  413. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  414. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  415. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  416. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  417. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  418. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  419. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  420. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  421. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  422. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  423. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  424. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  425. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  426. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  427. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  428. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  429. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  430. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  431. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  432. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  433. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  434. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  435. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  436. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  437. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  438. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  439. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  440. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  441. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  442. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  443. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  444. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  445. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  446. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  447. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  448. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  449. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  450. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  451. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  452. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  453. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  454. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  455. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  456. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  457. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  458. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  459. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  460. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  461. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  462. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  463. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  464. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  465. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  466. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  467. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  468. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  469. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  470. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  471. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  472. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  473. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  474. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  475. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  476. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  477. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  478. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  479. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  480. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  481. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  482. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  483. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  484. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  485. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  486. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  487. { AtCommand_Send, "@send", 60, atcommand_send },
  488. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  489. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  490. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  491. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  492. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken]
  493. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  494. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  495. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  496. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  497. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  498. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  499. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  500. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  501. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  502. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  503. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  504. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  505. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  506. { AtCommand_Users, "@users", 40, atcommand_users },
  507. { AtCommand_ResetState, "/reset", 40, NULL },
  508. #ifndef TXT_ONLY // sql-only commands
  509. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  510. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  511. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  512. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  513. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  514. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  515. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  516. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  517. #endif /* TXT_ONLY */
  518. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  519. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  520. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  521. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  522. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  523. #ifdef DMALLOC
  524. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  525. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  526. #endif
  527. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  528. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  529. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  530. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  531. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  532. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  533. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  534. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  535. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  536. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  537. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  538. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  539. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  540. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  541. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  542. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  543. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  544. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  545. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  546. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  547. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  548. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  549. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  550. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  551. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  552. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  553. { AtCommand_Version, "@version", 1, atcommand_version },
  554. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  555. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  556. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  557. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  558. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  559. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  560. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  561. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  562. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  563. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  564. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  565. { AtCommand_Size, "@size", 20, atcommand_size },
  566. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  567. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  568. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  569. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  570. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  571. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  572. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  573. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  574. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  575. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  576. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  577. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  578. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  579. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  580. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  581. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  582. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  583. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  584. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  585. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  586. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  587. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  588. // add new commands before this line
  589. { AtCommand_Unknown, NULL, 1, NULL }
  590. };
  591. /*=========================================
  592. * Generic variables
  593. *-----------------------------------------
  594. */
  595. char atcmd_output[200];
  596. char atcmd_player_name[100];
  597. char atcmd_temp[100];
  598. /*==========================================
  599. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  600. *------------------------------------------
  601. */
  602. char *estr_lower(char *str)
  603. {
  604. int i;
  605. for (i=0; str[i]; i++)
  606. if ((str[i] >= 65) && (str[i] <= 90))
  607. str[i] += 32;
  608. return str;
  609. }
  610. // compare function for sorting high to lowest
  611. int hightolow_compare (const void * a, const void * b)
  612. {
  613. return ( *(int*)b - *(int*)a );
  614. }
  615. // compare function for sorting lowest to highest
  616. int lowtohigh_compare (const void * a, const void * b)
  617. {
  618. return ( *(int*)a - *(int*)b );
  619. }
  620. //-----------------------------------------------------------
  621. // Return the message string of the specified number by [Yor]
  622. //-----------------------------------------------------------
  623. char * msg_txt(int msg_number) {
  624. if (msg_number >= 0 && msg_number < MAX_MSG &&
  625. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  626. return msg_table[msg_number];
  627. return "??";
  628. }
  629. //-----------------------------------------------------------
  630. // Returns Players title (from msg_athena.conf) [Lupus]
  631. //-----------------------------------------------------------
  632. char * player_title_txt(int level) {
  633. if (level < battle_config.title_lvl1)
  634. return ""; //w/o any titles
  635. if (level >= battle_config.title_lvl8)
  636. sprintf(atcmd_temp, msg_table[332], level);
  637. else
  638. if (level >= battle_config.title_lvl7)
  639. sprintf(atcmd_temp, msg_table[331], level);
  640. else
  641. if (level >= battle_config.title_lvl6)
  642. sprintf(atcmd_temp, msg_table[330], level);
  643. else
  644. if (level >= battle_config.title_lvl5)
  645. sprintf(atcmd_temp, msg_table[329], level);
  646. else
  647. if (level >= battle_config.title_lvl4)
  648. sprintf(atcmd_temp, msg_table[328], level);
  649. else
  650. if (level >= battle_config.title_lvl3)
  651. sprintf(atcmd_temp, msg_table[327], level);
  652. else
  653. if (level >= battle_config.title_lvl2)
  654. sprintf(atcmd_temp, msg_table[326], level);
  655. else
  656. sprintf(atcmd_temp, msg_table[325], level); //lvl1
  657. return atcmd_temp;
  658. }
  659. //------------------------------------------------------------
  660. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  661. //------------------------------------------------------------
  662. int e_mail_check(char *email) {
  663. char ch;
  664. char* last_arobas;
  665. // athena limits
  666. if (strlen(email) < 3 || strlen(email) > 39)
  667. return 0;
  668. // part of RFC limits (official reference of e-mail description)
  669. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  670. return 0;
  671. if (email[strlen(email)-1] == '.')
  672. return 0;
  673. last_arobas = strrchr(email, '@');
  674. if (strstr(last_arobas, "@.") != NULL ||
  675. strstr(last_arobas, "..") != NULL)
  676. return 0;
  677. for(ch = 1; ch < 32; ch++) {
  678. if (strchr(last_arobas, ch) != NULL) {
  679. return 0;
  680. break;
  681. }
  682. }
  683. if (strchr(last_arobas, ' ') != NULL ||
  684. strchr(last_arobas, ';') != NULL)
  685. return 0;
  686. // all correct
  687. return 1;
  688. }
  689. /*==========================================
  690. * get_atcommand_level @コマンドの必要レベルを取得
  691. *------------------------------------------
  692. */
  693. int get_atcommand_level(const AtCommandType type) {
  694. int i;
  695. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  696. if (atcommand_info[i].type == type)
  697. return atcommand_info[i].level;
  698. return 100; // 100: command can not be used
  699. }
  700. /*==========================================
  701. *is_atcommand @コマンドに存在するかどうか確認する
  702. *------------------------------------------
  703. */
  704. AtCommandType
  705. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  706. const char* str = message;
  707. int s_flag = 0;
  708. AtCommandInfo info;
  709. AtCommandType type;
  710. nullpo_retr(AtCommand_None, sd);
  711. if (!battle_config.allow_atcommand_when_mute &&
  712. sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1) {
  713. return AtCommand_Unknown;
  714. }
  715. if (!message || !*message)
  716. return AtCommand_None;
  717. memset(&info, 0, sizeof(info));
  718. str += strlen(sd->status.name);
  719. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  720. if (*str == ':')
  721. s_flag = 1;
  722. str++;
  723. }
  724. if (!*str)
  725. return AtCommand_None;
  726. if (map[sd->bl.m].flag.nocommand &&
  727. (gmlvl > 0? gmlvl:pc_isGM(sd)) < battle_config.gm_skilluncond)
  728. { //Command not allowed on this map.
  729. sprintf(atcmd_output, msg_table[143]);
  730. clif_displaymessage(fd, atcmd_output);
  731. return AtCommand_None;
  732. }
  733. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  734. if (type != AtCommand_None) {
  735. char command[100];
  736. const char* p = str;
  737. memset(command, '\0', sizeof(command));
  738. memset(atcmd_output, '\0', sizeof(atcmd_output));
  739. while (*p && !isspace(*p))
  740. p++;
  741. if (p - str >= sizeof(command)) // too long
  742. return AtCommand_Unknown;
  743. strncpy(command, str, p - str);
  744. while (isspace(*p))
  745. p++;
  746. if (type == AtCommand_Unknown || info.proc == NULL) {
  747. sprintf(atcmd_output, msg_table[153], command); // %s is Unknown Command.
  748. clif_displaymessage(fd, atcmd_output);
  749. } else {
  750. if (info.proc(fd, sd, command, p) != 0) {
  751. // Command can not be executed
  752. sprintf(atcmd_output, msg_table[154], command); // %s failed.
  753. clif_displaymessage(fd, atcmd_output);
  754. }
  755. }
  756. return info.type;
  757. }
  758. return AtCommand_None;
  759. }
  760. /*==========================================
  761. *
  762. *------------------------------------------
  763. */
  764. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  765. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  766. if (!info)
  767. return AtCommand_None;
  768. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  769. return AtCommand_None;
  770. if (!p || !*p) {
  771. ShowError("at command message is empty\n");
  772. return AtCommand_None;
  773. }
  774. if (*p == command_symbol) { // check first char.
  775. char command[101];
  776. int i = 0;
  777. memset(info, 0, sizeof(AtCommandInfo));
  778. sscanf(p, "%100s", command);
  779. command[sizeof(command)-1] = '\0';
  780. while (atcommand_info[i].type != AtCommand_Unknown) {
  781. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  782. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  783. break;
  784. }
  785. i++;
  786. }
  787. if (atcommand_info[i].type == AtCommand_Unknown) {
  788. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  789. if (level == 0)
  790. return AtCommand_None;
  791. else
  792. return AtCommand_Unknown;
  793. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  794. log_atcommand(sd, message);
  795. }
  796. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  797. } else {
  798. return AtCommand_None;
  799. }
  800. return info->type;
  801. }
  802. /*==========================================
  803. * Read Message Data
  804. *------------------------------------------
  805. */
  806. int msg_config_read(const char *cfgName) {
  807. int msg_number;
  808. char line[1024], w1[1024], w2[1024];
  809. FILE *fp;
  810. static int called = 1;
  811. if ((fp = fopen(cfgName, "r")) == NULL) {
  812. ShowError("Messages file not found: %s\n", cfgName);
  813. return 1;
  814. }
  815. if ((--called) == 0)
  816. memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
  817. while(fgets(line, sizeof(line)-1, fp)) {
  818. if (line[0] == '/' && line[1] == '/')
  819. continue;
  820. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  821. if (strcmpi(w1, "import") == 0) {
  822. msg_config_read(w2);
  823. } else {
  824. msg_number = atoi(w1);
  825. if (msg_number >= 0 && msg_number < MAX_MSG) {
  826. if (msg_table[msg_number] != NULL)
  827. aFree(msg_table[msg_number]);
  828. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  829. strcpy(msg_table[msg_number],w2);
  830. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  831. }
  832. }
  833. }
  834. }
  835. fclose(fp);
  836. return 0;
  837. }
  838. /*==========================================
  839. * Cleanup Message Data
  840. *------------------------------------------
  841. */
  842. void do_final_msg (void) {
  843. int i;
  844. for (i = 0; i < MAX_MSG; i++)
  845. aFree(msg_table[i]);
  846. return;
  847. }
  848. /*==========================================
  849. *
  850. *------------------------------------------
  851. */
  852. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  853. int i;
  854. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  855. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  856. return &atcommand_info[i];
  857. return NULL;
  858. }
  859. /*==========================================
  860. *
  861. *------------------------------------------
  862. */
  863. int atcommand_config_read(const char *cfgName) {
  864. char line[1024], w1[1024], w2[1024];
  865. AtCommandInfo* p;
  866. FILE* fp;
  867. if ((fp = fopen(cfgName, "r")) == NULL) {
  868. ShowError("At commands configuration file not found: %s\n", cfgName);
  869. return 1;
  870. }
  871. while (fgets(line, sizeof(line)-1, fp)) {
  872. if (line[0] == '/' && line[1] == '/')
  873. continue;
  874. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  875. continue;
  876. p = get_atcommandinfo_byname(w1);
  877. if (p != NULL) {
  878. p->level = atoi(w2);
  879. if (p->level > 100)
  880. p->level = 100;
  881. else if (p->level < 0)
  882. p->level = 0;
  883. }
  884. if (strcmpi(w1, "import") == 0)
  885. atcommand_config_read(w2);
  886. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  887. w2[0] != '/' && // symbol of standard ragnarok GM commands
  888. w2[0] != '%' && // symbol of party chat speaking
  889. w2[0] != '$' && // symbol of guild chat
  890. w2[0] != '#') // symbol of charcommand
  891. command_symbol = w2[0];
  892. }
  893. fclose(fp);
  894. return 0;
  895. }
  896. /*==========================================
  897. * Duel organizing functions [LuzZza]
  898. *------------------------------------------
  899. */
  900. void duel_msg_foreach_sameduel_wos(
  901. const unsigned int did, struct map_session_data* sd, char *output)
  902. {
  903. int i;
  904. struct map_session_data* msg_sd;
  905. for(i=0; i<fd_max; i++)
  906. if(session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  907. && msg_sd->state.auth && msg_sd->duel_group == did && msg_sd != sd)
  908. clif_disp_onlyself(msg_sd, output, strlen(output));
  909. return;
  910. }
  911. void duel_savetime(struct map_session_data* sd) {
  912. time_t timer;
  913. struct tm *t;
  914. time(&timer);
  915. t = localtime(&timer);
  916. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  917. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  918. return;
  919. }
  920. int duel_checktime(struct map_session_data* sd) {
  921. int diff;
  922. time_t timer;
  923. struct tm *t;
  924. time(&timer);
  925. t = localtime(&timer);
  926. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  927. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  928. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  929. }
  930. int duel_showinfo(
  931. const unsigned int did, struct map_session_data* sd)
  932. {
  933. int i, p=0;
  934. char output[256];
  935. struct map_session_data* msg_sd;
  936. if(duel_list[did].max_players_limit > 0)
  937. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  938. did, duel_count,
  939. duel_list[did].members_count,
  940. duel_list[did].members_count + duel_list[did].invites_count,
  941. duel_list[did].max_players_limit);
  942. else
  943. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  944. did, duel_count,
  945. duel_list[did].members_count,
  946. duel_list[did].members_count + duel_list[did].invites_count);
  947. clif_disp_onlyself(sd, output, strlen(output));
  948. for(i=0; i<fd_max; i++)
  949. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  950. && msg_sd->state.auth && msg_sd->duel_group == did) {
  951. sprintf(output, " %d. %s", ++p, (unsigned char *) msg_sd->status.name);
  952. clif_disp_onlyself(sd, output, strlen(output));
  953. }
  954. return 0;
  955. }
  956. int duel_create(
  957. struct map_session_data* sd, const unsigned int maxpl)
  958. {
  959. int i=1;
  960. char output[256];
  961. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  962. if(i == MAX_DUEL) return 0;
  963. duel_count++;
  964. sd->duel_group = i;
  965. duel_list[i].members_count++;
  966. duel_list[i].invites_count = 0;
  967. duel_list[i].max_players_limit = maxpl;
  968. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  969. clif_disp_onlyself(sd, output, strlen(output));
  970. clif_set0199(sd->fd, 1);
  971. //clif_misceffect2(&sd->bl, 159);
  972. return i;
  973. }
  974. int duel_invite(
  975. const unsigned int did, struct map_session_data* sd,
  976. struct map_session_data* target_sd)
  977. {
  978. char output[256];
  979. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  980. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  981. duel_msg_foreach_sameduel_wos(did, sd, output);
  982. target_sd->duel_invite = did;
  983. duel_list[did].invites_count++;
  984. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  985. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  986. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  987. return 0;
  988. }
  989. int duel_leave(
  990. const unsigned int did, struct map_session_data* sd)
  991. {
  992. int i;
  993. char output[256];
  994. struct map_session_data* msg_sd;
  995. // " <- Player %s has left duel --"
  996. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  997. duel_msg_foreach_sameduel_wos(did, sd, output);
  998. duel_list[did].members_count--;
  999. if(duel_list[did].members_count == 0) {
  1000. for (i=0; i<fd_max; i++)
  1001. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  1002. && msg_sd->state.auth && msg_sd->duel_invite == did && msg_sd != sd) {
  1003. msg_sd->duel_invite = 0;
  1004. }
  1005. duel_count--;
  1006. }
  1007. sd->duel_group = 0;
  1008. duel_savetime(sd);
  1009. clif_set0199(sd->fd, 0);
  1010. return 0;
  1011. }
  1012. int duel_accept(
  1013. const unsigned int did, struct map_session_data* sd)
  1014. {
  1015. char output[256];
  1016. // " -> Player %s has accepted duel --"
  1017. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  1018. duel_msg_foreach_sameduel_wos(did, sd, output);
  1019. duel_list[did].members_count++;
  1020. sd->duel_group = sd->duel_invite;
  1021. duel_list[did].invites_count--;
  1022. sd->duel_invite = 0;
  1023. clif_set0199(sd->fd, 1);
  1024. //clif_misceffect2(&sd->bl, 159);
  1025. return 0;
  1026. }
  1027. int duel_reject(
  1028. const unsigned int did, struct map_session_data* sd)
  1029. {
  1030. char output[256];
  1031. // " -- Player %s has rejected duel --"
  1032. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1033. duel_msg_foreach_sameduel_wos(did, sd, output);
  1034. duel_list[did].invites_count--;
  1035. sd->duel_invite = 0;
  1036. return 0;
  1037. }
  1038. /*==========================================
  1039. // @ command processing functions
  1040. *------------------------------------------
  1041. */
  1042. /*==========================================
  1043. * @commands Lists available @ commands to you (code 98% from Meruru)
  1044. *------------------------------------------
  1045. */
  1046. int atcommand_commands(
  1047. const int fd, struct map_session_data* sd,
  1048. const char* command, const char* message)
  1049. {
  1050. char cz_line_buff[MESSAGE_SIZE+1];
  1051. register char *lpcz_cur = cz_line_buff;
  1052. register unsigned int ui_slen;
  1053. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  1054. memset(cz_line_buff,' ',MESSAGE_SIZE);
  1055. cz_line_buff[MESSAGE_SIZE] = 0;
  1056. clif_displaymessage(fd, msg_txt(273));
  1057. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  1058. {
  1059. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  1060. continue;
  1061. count++;
  1062. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  1063. //rember not <= bc we need null terminator
  1064. if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  1065. {
  1066. clif_displaymessage(fd,(char*)cz_line_buff);
  1067. lpcz_cur = cz_line_buff;
  1068. memset(cz_line_buff,' ',MESSAGE_SIZE);
  1069. cz_line_buff[MESSAGE_SIZE] = 0;
  1070. }
  1071. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  1072. lpcz_cur += ui_slen+(10-ui_slen%10);
  1073. }
  1074. clif_displaymessage(fd,(char*)cz_line_buff);
  1075. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  1076. clif_displaymessage(fd, atcmd_output);
  1077. return 0;
  1078. }
  1079. /*==========================================
  1080. * @send (used for testing packet sends from the client)
  1081. *------------------------------------------
  1082. */
  1083. int atcommand_send(
  1084. const int fd, struct map_session_data* sd,
  1085. const char* command, const char* message)
  1086. {
  1087. int i,type=0;
  1088. int info[20];
  1089. if (!message || !*message || sscanf(message, "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &type, &info[1], &info[2], &info[3], &info[4], &info[5], &info[6], &info[7], &info[8], &info[9], &info[10], &info[11], &info[12], &info[13], &info[14], &info[15], &info[16], &info[17], &info[18], &info[19], &info[20]) < 1) {
  1090. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1091. return -1;
  1092. }
  1093. if (type > 0 && type < MAX_PACKET_DB) {
  1094. switch (type)
  1095. {
  1096. case 0x209: {
  1097. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1098. WFIFOW(fd,0) = 0x209;
  1099. WFIFOW(fd,2) = 2;
  1100. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1101. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1102. break;
  1103. }
  1104. case 0x1b1:
  1105. case 0x1c2:
  1106. //case xxx:
  1107. // add others here
  1108. // break;
  1109. default: {
  1110. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1111. WFIFOW(fd,0) = type;
  1112. for(i=1;i<=sizeof(info);i++)
  1113. if(info[i])
  1114. WFIFOW(fd,i) = info[i];
  1115. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1116. break;
  1117. }
  1118. }
  1119. sprintf (atcmd_output, msg_table[258], type, type);
  1120. clif_displaymessage(fd, atcmd_output);
  1121. } else {
  1122. clif_displaymessage(fd, msg_table[259]);
  1123. }
  1124. return 0;
  1125. }
  1126. // @rura
  1127. /*==========================================
  1128. *
  1129. *------------------------------------------
  1130. */
  1131. int atcommand_rura(
  1132. const int fd, struct map_session_data* sd,
  1133. const char* command, const char* message)
  1134. {
  1135. char map_name[MAP_NAME_LENGTH];
  1136. unsigned short mapindex;
  1137. int x = 0, y = 0;
  1138. int m = -1;
  1139. nullpo_retr(-1, sd);
  1140. memset(map_name, '\0', sizeof(map_name));
  1141. if (!message || !*message ||
  1142. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1143. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1144. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1145. return -1;
  1146. }
  1147. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1148. strcat(map_name, ".gat");
  1149. mapindex = mapindex_name2id(map_name);
  1150. if (mapindex)
  1151. m = map_mapindex2mapid(mapindex);
  1152. if (!mapindex || m < 0) {
  1153. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1154. return -1;
  1155. }
  1156. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) {
  1157. clif_displaymessage(fd, msg_table[2]);
  1158. x = y = 0; //Invalid cell, use random spot.
  1159. }
  1160. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1161. clif_displaymessage(fd, msg_table[247]);
  1162. return -1;
  1163. }
  1164. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1165. clif_displaymessage(fd, msg_table[248]);
  1166. return -1;
  1167. }
  1168. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1169. clif_displaymessage(fd, msg_table[0]); // Warped.
  1170. else {
  1171. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1172. return -1;
  1173. }
  1174. return 0;
  1175. }
  1176. /*==========================================
  1177. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1178. *------------------------------------------
  1179. */
  1180. int atcommand_where(
  1181. const int fd, struct map_session_data* sd,
  1182. const char* command, const char* message)
  1183. {
  1184. struct map_session_data *pl_sd = NULL;
  1185. int GM_level, pl_GM_level;
  1186. nullpo_retr(-1, sd);
  1187. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1188. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1189. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1190. return -1;
  1191. }
  1192. pl_sd = map_nick2sd(atcmd_player_name);
  1193. if (pl_sd == NULL)
  1194. return -1;
  1195. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1196. return -1;
  1197. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1198. pl_GM_level = pc_isGM(pl_sd);
  1199. if (battle_config.hide_GM_session) {
  1200. if(GM_level < pl_GM_level) {
  1201. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1202. return -1;
  1203. }
  1204. }
  1205. }
  1206. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1207. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1208. clif_displaymessage(fd, atcmd_output);
  1209. return 0;
  1210. }
  1211. /*==========================================
  1212. *
  1213. *------------------------------------------
  1214. */
  1215. int atcommand_jumpto(
  1216. const int fd, struct map_session_data* sd,
  1217. const char* command, const char* message)
  1218. {
  1219. struct map_session_data *pl_sd = NULL;
  1220. nullpo_retr(-1, sd);
  1221. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1222. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1223. return -1;
  1224. }
  1225. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1226. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1227. return -1;
  1228. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1229. return -1;
  1230. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1231. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1232. clif_displaymessage(fd, msg_table[247]);
  1233. return -1;
  1234. }
  1235. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1236. clif_displaymessage(fd, msg_table[248]);
  1237. return -1;
  1238. }
  1239. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1240. sprintf(atcmd_output, msg_table[4], atcmd_player_name); // Jump to %s
  1241. clif_displaymessage(fd, atcmd_output);
  1242. } else {
  1243. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1244. return -1;
  1245. }
  1246. return 0;
  1247. }
  1248. /*==========================================
  1249. *
  1250. *------------------------------------------
  1251. */
  1252. int atcommand_jump(
  1253. const int fd, struct map_session_data* sd,
  1254. const char* command, const char* message)
  1255. {
  1256. int x = 0, y = 0;
  1257. nullpo_retr(-1, sd);
  1258. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1259. sscanf(message, "%d %d", &x, &y);
  1260. if (x <= 0) //If coordinates are 'wrong', random jump.
  1261. x = -1;
  1262. if (y <= 0)
  1263. y = -1;
  1264. 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)) {
  1265. clif_displaymessage(fd, msg_table[248]);
  1266. return -1;
  1267. }
  1268. pc_setpos(sd, sd->mapindex, x, y, 3);
  1269. sprintf(atcmd_output, msg_table[5], sd->bl.x, sd->bl.y); // Jump to %d %d
  1270. clif_displaymessage(fd, atcmd_output);
  1271. return 0;
  1272. }
  1273. /*==========================================
  1274. * @who3 = Player name, his location
  1275. *------------------------------------------
  1276. */
  1277. int atcommand_who3(
  1278. const int fd, struct map_session_data* sd,
  1279. const char* command, const char* message)
  1280. {
  1281. char temp0[100];
  1282. struct map_session_data *pl_sd, **pl_allsd;
  1283. int i, j, count, users;
  1284. int pl_GM_level, GM_level;
  1285. char match_text[100];
  1286. char player_name[NAME_LENGTH];
  1287. nullpo_retr(-1, sd);
  1288. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1289. memset(match_text, '\0', sizeof(match_text));
  1290. memset(player_name, '\0', sizeof(player_name));
  1291. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1292. strcpy(match_text, "");
  1293. for (j = 0; match_text[j]; j++)
  1294. match_text[j] = tolower(match_text[j]);
  1295. count = 0;
  1296. GM_level = pc_isGM(sd);
  1297. pl_allsd = map_getallusers(&users);
  1298. for (i = 0; i < users; i++) {
  1299. if ((pl_sd = pl_allsd[i])) {
  1300. pl_GM_level = pc_isGM(pl_sd);
  1301. 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
  1302. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1303. for (j = 0; player_name[j]; j++)
  1304. player_name[j] = tolower(player_name[j]);
  1305. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1306. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1307. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1308. } else {
  1309. atcmd_output[0]=0;
  1310. }
  1311. //Player name
  1312. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1313. strcat(atcmd_output,temp0);
  1314. //Player title, if exists
  1315. if (pl_GM_level > 0) {
  1316. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1317. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1318. strcat(atcmd_output,temp0);
  1319. }
  1320. //Players Location: map x y
  1321. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1322. strcat(atcmd_output,temp0);
  1323. clif_displaymessage(fd, atcmd_output);
  1324. count++;
  1325. }
  1326. }
  1327. }
  1328. }
  1329. if (count == 0)
  1330. clif_displaymessage(fd, msg_table[28]); // No player found.
  1331. else if (count == 1)
  1332. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1333. else {
  1334. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1335. clif_displaymessage(fd, atcmd_output);
  1336. }
  1337. return 0;
  1338. }
  1339. /*==========================================
  1340. * Player name, BLevel, Job,
  1341. *------------------------------------------
  1342. */
  1343. int atcommand_who2(
  1344. const int fd, struct map_session_data* sd,
  1345. const char* command, const char* message)
  1346. {
  1347. char temp0[100];
  1348. struct map_session_data *pl_sd, **pl_allsd;
  1349. int i, j, count, users;
  1350. int pl_GM_level, GM_level;
  1351. char match_text[100];
  1352. char player_name[NAME_LENGTH];
  1353. nullpo_retr(-1, sd);
  1354. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1355. memset(match_text, '\0', sizeof(match_text));
  1356. memset(player_name, '\0', sizeof(player_name));
  1357. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1358. strcpy(match_text, "");
  1359. for (j = 0; match_text[j]; j++)
  1360. match_text[j] = tolower(match_text[j]);
  1361. count = 0;
  1362. GM_level = pc_isGM(sd);
  1363. pl_allsd = map_getallusers(&users);
  1364. for (i = 0; i < users; i++) {
  1365. if ((pl_sd = pl_allsd[i])) {
  1366. pl_GM_level = pc_isGM(pl_sd);
  1367. 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
  1368. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1369. for (j = 0; player_name[j]; j++)
  1370. player_name[j] = tolower(player_name[j]);
  1371. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1372. //Players Name
  1373. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1374. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1375. //Player title, if exists
  1376. if (pl_GM_level > 0) {
  1377. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1378. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1379. strcat(atcmd_output,temp0);
  1380. }
  1381. //Players Base Level / Job name
  1382. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1383. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1384. strcat(atcmd_output,temp0);
  1385. clif_displaymessage(fd, atcmd_output);
  1386. count++;
  1387. }
  1388. }
  1389. }
  1390. }
  1391. if (count == 0)
  1392. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1393. else if (count == 1)
  1394. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1395. else {
  1396. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1397. clif_displaymessage(fd, atcmd_output);
  1398. }
  1399. return 0;
  1400. }
  1401. /*==========================================
  1402. * Player name, Playrs Party / Guild name
  1403. *------------------------------------------
  1404. */
  1405. int atcommand_who(
  1406. const int fd, struct map_session_data* sd,
  1407. const char* command, const char* message)
  1408. {
  1409. char temp0[100];
  1410. struct map_session_data *pl_sd, **pl_allsd;
  1411. int i, j, count, users;
  1412. int pl_GM_level, GM_level;
  1413. char match_text[100];
  1414. char player_name[NAME_LENGTH];
  1415. struct guild *g;
  1416. struct party *p;
  1417. nullpo_retr(-1, sd);
  1418. memset(temp0, '\0', sizeof(temp0));
  1419. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1420. memset(match_text, '\0', sizeof(match_text));
  1421. memset(player_name, '\0', sizeof(player_name));
  1422. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1423. strcpy(match_text, "");
  1424. for (j = 0; match_text[j]; j++)
  1425. match_text[j] = tolower(match_text[j]);
  1426. count = 0;
  1427. GM_level = pc_isGM(sd);
  1428. pl_allsd = map_getallusers(&users);
  1429. for (i = 0; i < users; i++) {
  1430. if ((pl_sd = pl_allsd[i])) {
  1431. pl_GM_level = pc_isGM(pl_sd);
  1432. 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
  1433. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1434. for (j = 0; player_name[j]; j++)
  1435. player_name[j] = tolower(player_name[j]);
  1436. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1437. g = guild_search(pl_sd->status.guild_id);
  1438. p = party_search(pl_sd->status.party_id);
  1439. //Players Name
  1440. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1441. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1442. //Player title, if exists
  1443. if (pl_GM_level > 0) {
  1444. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1445. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1446. strcat(atcmd_output,temp0);
  1447. }
  1448. //Players Party if exists
  1449. if (p != NULL) {
  1450. //sprintf(temp0," | Party: '%s'", p->name);
  1451. sprintf(temp0, msg_txt(335), p->name);
  1452. strcat(atcmd_output,temp0);
  1453. }
  1454. //Players Guild if exists
  1455. if (g != NULL) {
  1456. //sprintf(temp0," | Guild: '%s'", g->name);
  1457. sprintf(temp0, msg_txt(336), g->name);
  1458. strcat(atcmd_output,temp0);
  1459. }
  1460. clif_displaymessage(fd, atcmd_output);
  1461. count++;
  1462. }
  1463. }
  1464. }
  1465. }
  1466. if (count == 0)
  1467. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1468. else if (count == 1)
  1469. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1470. else {
  1471. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1472. clif_displaymessage(fd, atcmd_output);
  1473. }
  1474. return 0;
  1475. }
  1476. /*==========================================
  1477. *
  1478. *------------------------------------------
  1479. */
  1480. int atcommand_whomap3(
  1481. const int fd, struct map_session_data* sd,
  1482. const char* command, const char* message)
  1483. {
  1484. struct map_session_data *pl_sd, **pl_allsd;
  1485. int i, count, users;
  1486. int pl_GM_level, GM_level;
  1487. int map_id;
  1488. char map_name[MAP_NAME_LENGTH];
  1489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1490. memset(map_name, '\0', sizeof(map_name));
  1491. if (!message || !*message)
  1492. map_id = sd->bl.m;
  1493. else {
  1494. sscanf(message, "%15s", map_name);
  1495. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1496. strcat(map_name, ".gat");
  1497. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1498. map_id = sd->bl.m;
  1499. }
  1500. count = 0;
  1501. GM_level = pc_isGM(sd);
  1502. pl_allsd = map_getallusers(&users);
  1503. for (i = 0; i < users; i++) {
  1504. if ((pl_sd = pl_allsd[i])) {
  1505. pl_GM_level = pc_isGM(pl_sd);
  1506. 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
  1507. if (pl_sd->bl.m == map_id) {
  1508. if (pl_GM_level > 0)
  1509. 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);
  1510. else
  1511. 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);
  1512. clif_displaymessage(fd, atcmd_output);
  1513. count++;
  1514. }
  1515. }
  1516. }
  1517. }
  1518. if (count == 0)
  1519. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1520. else if (count == 1)
  1521. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1522. else {
  1523. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1524. }
  1525. clif_displaymessage(fd, atcmd_output);
  1526. return 0;
  1527. }
  1528. /*==========================================
  1529. *
  1530. *------------------------------------------
  1531. */
  1532. int atcommand_whomap2(
  1533. const int fd, struct map_session_data* sd,
  1534. const char* command, const char* message)
  1535. {
  1536. struct map_session_data *pl_sd, **pl_allsd;
  1537. int i, count, users;
  1538. int pl_GM_level, GM_level;
  1539. int map_id = 0;
  1540. char map_name[MAP_NAME_LENGTH];
  1541. nullpo_retr(-1, sd);
  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) | 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);
  1563. else
  1564. 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);
  1565. clif_displaymessage(fd, atcmd_output);
  1566. count++;
  1567. }
  1568. }
  1569. }
  1570. }
  1571. if (count == 0)
  1572. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1573. else if (count == 1)
  1574. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1575. else {
  1576. sprintf(atcmd_output, msg_table[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_whomap(
  1586. const int fd, struct map_session_data* sd,
  1587. const char* command, const char* message)
  1588. {
  1589. char temp0[100];
  1590. char temp1[100];
  1591. struct map_session_data *pl_sd, **pl_allsd;
  1592. int i, count, users;
  1593. int pl_GM_level, GM_level;
  1594. int map_id = 0;
  1595. char map_name[MAP_NAME_LENGTH];
  1596. struct guild *g;
  1597. struct party *p;
  1598. nullpo_retr(-1, sd);
  1599. memset(temp0, '\0', sizeof(temp0));
  1600. memset(temp1, '\0', sizeof(temp1));
  1601. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1602. memset(map_name, '\0', sizeof(map_name));
  1603. if (!message || !*message)
  1604. map_id = sd->bl.m;
  1605. else {
  1606. sscanf(message, "%15s", map_name);
  1607. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1608. strcat(map_name, ".gat");
  1609. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1610. map_id = sd->bl.m;
  1611. }
  1612. count = 0;
  1613. GM_level = pc_isGM(sd);
  1614. pl_allsd = map_getallusers(&users);
  1615. for (i = 0; i < users; i++) {
  1616. if ((pl_sd = pl_allsd[i])) {
  1617. pl_GM_level = pc_isGM(pl_sd);
  1618. 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
  1619. if (pl_sd->bl.m == map_id) {
  1620. g = guild_search(pl_sd->status.guild_id);
  1621. if (g == NULL)
  1622. sprintf(temp1, "None");
  1623. else
  1624. sprintf(temp1, "%s", g->name);
  1625. p = party_search(pl_sd->status.party_id);
  1626. if (p == NULL)
  1627. sprintf(temp0, "None");
  1628. else
  1629. sprintf(temp0, "%s", p->name);
  1630. if (pl_GM_level > 0)
  1631. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1632. else
  1633. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1634. clif_displaymessage(fd, atcmd_output);
  1635. count++;
  1636. }
  1637. }
  1638. }
  1639. }
  1640. if (count == 0)
  1641. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1642. else if (count == 1)
  1643. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1644. else {
  1645. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1646. }
  1647. clif_displaymessage(fd, atcmd_output);
  1648. return 0;
  1649. }
  1650. /*==========================================
  1651. *
  1652. *------------------------------------------
  1653. */
  1654. int atcommand_whogm(
  1655. const int fd, struct map_session_data* sd,
  1656. const char* command, const char* message)
  1657. {
  1658. char temp0[100];
  1659. char temp1[100];
  1660. struct map_session_data *pl_sd, **pl_allsd;
  1661. int i, j, count, users;
  1662. int pl_GM_level, GM_level;
  1663. char match_text[100];
  1664. char player_name[NAME_LENGTH];
  1665. struct guild *g;
  1666. struct party *p;
  1667. nullpo_retr(-1, sd);
  1668. memset(temp0, '\0', sizeof(temp0));
  1669. memset(temp1, '\0', sizeof(temp1));
  1670. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1671. memset(match_text, '\0', sizeof(match_text));
  1672. memset(player_name, '\0', sizeof(player_name));
  1673. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1674. strcpy(match_text, "");
  1675. for (j = 0; match_text[j]; j++)
  1676. match_text[j] = tolower(match_text[j]);
  1677. count = 0;
  1678. GM_level = pc_isGM(sd);
  1679. pl_allsd = map_getallusers(&users);
  1680. for (i = 0; i < users; i++) {
  1681. if ((pl_sd = pl_allsd[i])) {
  1682. pl_GM_level = pc_isGM(pl_sd);
  1683. if (pl_GM_level > 0) {
  1684. 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
  1685. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1686. for (j = 0; player_name[j]; j++)
  1687. player_name[j] = tolower(player_name[j]);
  1688. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1689. 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);
  1690. clif_displaymessage(fd, atcmd_output);
  1691. 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);
  1692. clif_displaymessage(fd, atcmd_output);
  1693. g = guild_search(pl_sd->status.guild_id);
  1694. if (g == NULL)
  1695. sprintf(temp1, "None");
  1696. else
  1697. sprintf(temp1, "%s", g->name);
  1698. p = party_search(pl_sd->status.party_id);
  1699. if (p == NULL)
  1700. sprintf(temp0, "None");
  1701. else
  1702. sprintf(temp0, "%s", p->name);
  1703. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1704. clif_displaymessage(fd, atcmd_output);
  1705. count++;
  1706. }
  1707. }
  1708. }
  1709. }
  1710. }
  1711. if (count == 0)
  1712. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1713. else if (count == 1)
  1714. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1715. else {
  1716. sprintf(atcmd_output, msg_table[152], count); // %d GMs found.
  1717. clif_displaymessage(fd, atcmd_output);
  1718. }
  1719. return 0;
  1720. }
  1721. int atcommand_whozeny(
  1722. const int fd, struct map_session_data* sd,
  1723. const char* command, const char* message)
  1724. {
  1725. struct map_session_data *pl_sd, **pl_allsd;
  1726. int i, j, count,c, users;
  1727. char match_text[100];
  1728. char player_name[NAME_LENGTH];
  1729. int *zeny;
  1730. int *counted;
  1731. nullpo_retr(-1, sd);
  1732. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1733. memset(match_text, '\0', sizeof(match_text));
  1734. memset(player_name, '\0', sizeof(player_name));
  1735. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1736. strcpy(match_text, "");
  1737. for (j = 0; match_text[j]; j++)
  1738. match_text[j] = tolower(match_text[j]);
  1739. count = 0;
  1740. pl_allsd = map_getallusers(&users);
  1741. if (users < 1)
  1742. {
  1743. clif_displaymessage(fd, msg_table[28]); // No player found.
  1744. return 0;
  1745. }
  1746. zeny = (int *)aMallocA(users*sizeof(int));
  1747. counted = (int *)aMallocA(users*sizeof(int));
  1748. for (i = 0; i < users; i++) {
  1749. if ((pl_sd = pl_allsd[i])) {
  1750. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1751. for (j = 0; player_name[j]; j++)
  1752. player_name[j] = tolower(player_name[j]);
  1753. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1754. zeny[count]=pl_sd->status.zeny;
  1755. counted[i]=0;
  1756. count++;
  1757. }
  1758. }
  1759. }
  1760. qsort(zeny, count, sizeof(int), hightolow_compare);
  1761. for (c = 0; c < count && c < 50; c++) {
  1762. if(!zeny[c])
  1763. continue;
  1764. for (i = 0; i < users; i++) {
  1765. if(!zeny[c])
  1766. continue;
  1767. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1768. if(pl_sd->status.zeny==zeny[c]) {
  1769. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1770. clif_displaymessage(fd, atcmd_output);
  1771. zeny[c]=0;
  1772. counted[i]=1;
  1773. }
  1774. }
  1775. }
  1776. }
  1777. if (count == 0)
  1778. clif_displaymessage(fd, msg_table[28]); // No player found.
  1779. else if (count == 1)
  1780. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1781. else {
  1782. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1783. clif_displaymessage(fd, atcmd_output);
  1784. }
  1785. aFree(zeny);
  1786. aFree(counted);
  1787. return 0;
  1788. }
  1789. // cause random emote on all online players [Valaris]
  1790. int atcommand_happyhappyjoyjoy(
  1791. const int fd, struct map_session_data* sd,
  1792. const char* command, const char* message)
  1793. {
  1794. struct map_session_data *pl_sd, **pl_allsd;
  1795. int i,e, users;
  1796. nullpo_retr(-1, sd);
  1797. pl_allsd = map_getallusers(&users);
  1798. for (i = 0; i < users; i++) {
  1799. if ((pl_sd = pl_allsd[i])) {
  1800. e=rand()%40;
  1801. if(e==34)
  1802. e = 0;
  1803. clif_emotion(&pl_sd->bl,e);
  1804. }
  1805. }
  1806. return 0;
  1807. }
  1808. /*==========================================
  1809. *
  1810. *------------------------------------------
  1811. */
  1812. int atcommand_save(
  1813. const int fd, struct map_session_data* sd,
  1814. const char* command, const char* message)
  1815. {
  1816. nullpo_retr(-1, sd);
  1817. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1818. if (sd->status.pet_id > 0 && sd->pd)
  1819. intif_save_petdata(sd->status.account_id, &sd->pet);
  1820. chrif_save(sd,0);
  1821. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1822. return 0;
  1823. }
  1824. /*==========================================
  1825. *
  1826. *------------------------------------------
  1827. */
  1828. int atcommand_load(
  1829. const int fd, struct map_session_data* sd,
  1830. const char* command, const char* message)
  1831. {
  1832. int m;
  1833. nullpo_retr(-1, sd);
  1834. m = map_mapindex2mapid(sd->status.save_point.map);
  1835. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1836. clif_displaymessage(fd, msg_table[249]);
  1837. return -1;
  1838. }
  1839. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1840. clif_displaymessage(fd, msg_table[248]);
  1841. return -1;
  1842. }
  1843. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1844. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1845. return 0;
  1846. }
  1847. /*==========================================
  1848. *
  1849. *------------------------------------------
  1850. */
  1851. int atcommand_speed(
  1852. const int fd, struct map_session_data* sd,
  1853. const char* command, const char* message)
  1854. {
  1855. int speed;
  1856. nullpo_retr(-1, sd);
  1857. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1858. if (!message || !*message) {
  1859. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1860. clif_displaymessage(fd, atcmd_output);
  1861. return -1;
  1862. }
  1863. speed = atoi(message);
  1864. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1865. sd->battle_status.speed = speed;
  1866. clif_updatestatus(sd, SP_SPEED);
  1867. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1868. } else {
  1869. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1870. clif_displaymessage(fd, atcmd_output);
  1871. return -1;
  1872. }
  1873. return 0;
  1874. }
  1875. /*==========================================
  1876. *
  1877. *------------------------------------------
  1878. */
  1879. int atcommand_storage(
  1880. const int fd, struct map_session_data* sd,
  1881. const char* command, const char* message)
  1882. {
  1883. struct storage *stor; //changes from Freya/Yor
  1884. nullpo_retr(-1, sd);
  1885. if (sd->state.storage_flag) {
  1886. clif_displaymessage(fd, msg_table[250]);
  1887. return -1;
  1888. }
  1889. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1890. clif_displaymessage(fd, msg_table[250]);
  1891. return -1;
  1892. }
  1893. storage_storageopen(sd);
  1894. return 0;
  1895. }
  1896. /*==========================================
  1897. *
  1898. *------------------------------------------
  1899. */
  1900. int atcommand_guildstorage(
  1901. const int fd, struct map_session_data* sd,
  1902. const char* command, const char* message)
  1903. {
  1904. struct storage *stor; //changes from Freya/Yor
  1905. nullpo_retr(-1, sd);
  1906. if (sd->status.guild_id > 0) {
  1907. if (sd->state.storage_flag) {
  1908. clif_displaymessage(fd, msg_table[251]);
  1909. return -1;
  1910. }
  1911. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1912. clif_displaymessage(fd, msg_table[251]);
  1913. return -1;
  1914. }
  1915. storage_guild_storageopen(sd);
  1916. } else {
  1917. clif_displaymessage(fd, msg_table[252]);
  1918. return -1;
  1919. }
  1920. return 0;
  1921. }
  1922. /*==========================================
  1923. *
  1924. *------------------------------------------
  1925. */
  1926. int atcommand_option(
  1927. const int fd, struct map_session_data* sd,
  1928. const char* command, const char* message)
  1929. {
  1930. int param1 = 0, param2 = 0, param3 = 0;
  1931. nullpo_retr(-1, sd);
  1932. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1933. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1934. return -1;
  1935. }
  1936. sd->sc.opt1 = param1;
  1937. sd->sc.opt2 = param2;
  1938. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1939. if (sd->status.class_ == JOB_BABY_MERCHANT)
  1940. clif_cart_itemlist(sd);
  1941. clif_cart_equiplist(sd);
  1942. clif_updatestatus(sd, SP_CARTINFO);
  1943. }
  1944. pc_setoption(sd, param3);
  1945. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1946. return 0;
  1947. }
  1948. /*==========================================
  1949. *
  1950. *------------------------------------------
  1951. */
  1952. int atcommand_hide(
  1953. const int fd, struct map_session_data* sd,
  1954. const char* command, const char* message)
  1955. {
  1956. nullpo_retr(-1, sd);
  1957. if (sd->sc.option & OPTION_INVISIBLE) {
  1958. sd->sc.option &= ~OPTION_INVISIBLE;
  1959. if (sd->disguise)
  1960. status_set_viewdata(&sd->bl, sd->disguise);
  1961. else
  1962. status_set_viewdata(&sd->bl, sd->status.class_);
  1963. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1964. } else {
  1965. sd->sc.option |= OPTION_INVISIBLE;
  1966. sd->vd.class_ = INVISIBLE_CLASS;
  1967. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1968. }
  1969. clif_changeoption(&sd->bl);
  1970. return 0;
  1971. }
  1972. /*==========================================
  1973. * 転職する upperを指定すると転生や養子にもなれる
  1974. *------------------------------------------
  1975. */
  1976. int atcommand_jobchange(
  1977. const int fd, struct map_session_data* sd,
  1978. const char* command, const char* message)
  1979. {
  1980. int job = 0, upper = 0;
  1981. nullpo_retr(-1, sd);
  1982. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1983. int i, found = 0;
  1984. const struct { char name[16]; int id; } jobs[] = {
  1985. { "novice", 0 },
  1986. { "swordsman", 1 },
  1987. { "mage", 2 },
  1988. { "archer", 3 },
  1989. { "acolyte", 4 },
  1990. { "merchant", 5 },
  1991. { "thief", 6 },
  1992. { "knight", 7 },
  1993. { "priest", 8 },
  1994. { "priestess", 8 },
  1995. { "wizard", 9 },
  1996. { "blacksmith", 10 },
  1997. { "hunter", 11 },
  1998. { "assassin", 12 },
  1999. { "crusader", 14 },
  2000. { "monk", 15 },
  2001. { "sage", 16 },
  2002. { "rogue", 17 },
  2003. { "alchemist", 18 },
  2004. { "bard", 19 },
  2005. { "dancer", 20 },
  2006. { "super novice", 23 },
  2007. { "supernovice", 23 },
  2008. { "gunslinger", 24 },
  2009. { "gunner", 24 },
  2010. { "ninja", 25 },
  2011. { "high novice", 4001 },
  2012. { "swordsman high", 4002 },
  2013. { "mage high", 4003 },
  2014. { "archer high", 4004 },
  2015. { "acolyte high", 4005 },
  2016. { "merchant high", 4006 },
  2017. { "thief high", 4007 },
  2018. { "lord knight", 4008 },
  2019. { "high priest", 4009 },
  2020. { "high priestess", 4009 },
  2021. { "high wizard", 4010 },
  2022. { "whitesmith", 4011 },
  2023. { "sniper", 4012 },
  2024. { "assassin cross", 4013 },
  2025. { "paladin", 4015 },
  2026. { "champion", 4016 },
  2027. { "professor", 4017 },
  2028. { "stalker", 4018 },
  2029. { "creator", 4019 },
  2030. { "clown", 4020 },
  2031. { "gypsy", 4021 },
  2032. { "baby novice", 4023 },
  2033. { "baby swordsman", 4024 },
  2034. { "baby mage", 4025 },
  2035. { "baby archer", 4026 },
  2036. { "baby acolyte", 4027 },
  2037. { "baby merchant", 4028 },
  2038. { "baby thief", 4029 },
  2039. { "baby knight", 4030 },
  2040. { "baby priest", 4031 },
  2041. { "baby priestess", 4031 },
  2042. { "baby wizard", 4032 },
  2043. { "baby blacksmith",4033 },
  2044. { "baby hunter", 4034 },
  2045. { "baby assassin", 4035 },
  2046. { "baby crusader", 4037 },
  2047. { "baby monk", 4038 },
  2048. { "baby sage", 4039 },
  2049. { "baby rogue", 4040 },
  2050. { "baby alchemist", 4041 },
  2051. { "baby bard", 4042 },
  2052. { "baby dancer", 4043 },
  2053. { "super baby", 4045 },
  2054. { "taekwon", 4046 },
  2055. { "taekwon boy", 4046 },
  2056. { "taekwon girl", 4046 },
  2057. { "star gladiator", 4047 },
  2058. { "soul linker", 4049 },
  2059. };
  2060. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2061. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2062. job = jobs[i].id;
  2063. upper = 0;
  2064. found = 1;
  2065. break;
  2066. }
  2067. }
  2068. if (!found) {
  2069. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2070. return -1;
  2071. }
  2072. }
  2073. if (job == 37 ||job == 45)
  2074. return 0;
  2075. if ((job >= 0 && job < MAX_PC_CLASS))
  2076. {
  2077. int j;
  2078. for (j=0; j < MAX_INVENTORY; j++) {
  2079. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2080. pc_unequipitem(sd, j, 3);
  2081. }
  2082. if (pc_jobchange(sd, job, upper) == 0)
  2083. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  2084. else {
  2085. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  2086. return -1;
  2087. }
  2088. } else {
  2089. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2090. return -1;
  2091. }
  2092. return 0;
  2093. }
  2094. /*==========================================
  2095. *
  2096. *------------------------------------------
  2097. */
  2098. int atcommand_die(
  2099. const int fd, struct map_session_data* sd,
  2100. const char* command, const char* message)
  2101. {
  2102. nullpo_retr(-1, sd);
  2103. clif_specialeffect(&sd->bl,450,SELF);
  2104. status_kill(&sd->bl);
  2105. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  2106. return 0;
  2107. }
  2108. /*==========================================
  2109. *
  2110. *------------------------------------------
  2111. */
  2112. int atcommand_kill(
  2113. const int fd, struct map_session_data* sd,
  2114. const char* command, const char* message)
  2115. {
  2116. struct map_session_data *pl_sd;
  2117. nullpo_retr(-1, sd);
  2118. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2119. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2120. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2121. return -1;
  2122. }
  2123. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2124. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2125. status_kill(&pl_sd->bl);
  2126. clif_displaymessage(fd, msg_table[14]); // Character killed.
  2127. } else {
  2128. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  2129. return -1;
  2130. }
  2131. } else {
  2132. clif_displaymessage(fd, msg_table[3]); // Character not found.
  2133. return -1;
  2134. }
  2135. return 0;
  2136. }
  2137. /*==========================================
  2138. *
  2139. *------------------------------------------
  2140. */
  2141. int atcommand_alive(
  2142. const int fd, struct map_session_data* sd,
  2143. const char* command, const char* message)
  2144. {
  2145. nullpo_retr(-1, sd);
  2146. if (!status_revive(&sd->bl, 100, 100))
  2147. return -1;
  2148. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2149. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  2150. return 0;
  2151. }
  2152. /*==========================================
  2153. * +kamic [LuzZza]
  2154. *------------------------------------------
  2155. */
  2156. int atcommand_kami(
  2157. const int fd, struct map_session_data* sd,
  2158. const char* command, const char* message)
  2159. {
  2160. unsigned long color=0;
  2161. nullpo_retr(-1, sd);
  2162. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2163. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2164. if (!message || !*message) {
  2165. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2166. return -1;
  2167. }
  2168. sscanf(message, "%199[^\n]", atcmd_output);
  2169. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2170. } else {
  2171. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2172. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2173. return -1;
  2174. }
  2175. if(color > 0xFFFFFF) {
  2176. clif_displaymessage(fd, "Invalid color.");
  2177. return -1;
  2178. }
  2179. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2180. }
  2181. return 0;
  2182. }
  2183. /*==========================================
  2184. *
  2185. *------------------------------------------
  2186. */
  2187. int atcommand_heal(
  2188. const int fd, struct map_session_data* sd,
  2189. const char* command, const char* message)
  2190. {
  2191. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2192. nullpo_retr(-1, sd);
  2193. sscanf(message, "%d %d", &hp, &sp);
  2194. if (hp == 0 && sp == 0) {
  2195. if (!status_heal(&sd->bl, sd->battle_status.max_hp, sd->battle_status.max_sp, 2))
  2196. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2197. else
  2198. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2199. return 0;
  2200. }
  2201. if(hp > 0 && sp >= 0) {
  2202. if(!status_heal(&sd->bl, hp, sp, 2))
  2203. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2204. else
  2205. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2206. return 0;
  2207. }
  2208. if(hp < 0 && sp <= 0) {
  2209. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2210. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2211. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2212. return 0;
  2213. }
  2214. //Opposing signs.
  2215. if (hp) {
  2216. if (hp > 0)
  2217. status_heal(&sd->bl, hp, 0, 2);
  2218. else {
  2219. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2220. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2221. }
  2222. }
  2223. if (sp) {
  2224. if (sp > 0)
  2225. status_heal(&sd->bl, 0, sp, 2);
  2226. else
  2227. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2228. }
  2229. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2230. return 0;
  2231. }
  2232. /*==========================================
  2233. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2234. *------------------------------------------
  2235. */
  2236. int atcommand_item(
  2237. const int fd, struct map_session_data* sd,
  2238. const char* command, const char* message)
  2239. {
  2240. char item_name[100];
  2241. int number = 0, item_id, flag;
  2242. struct item item_tmp;
  2243. struct item_data *item_data;
  2244. int get_count, i, pet_id;
  2245. nullpo_retr(-1, sd);
  2246. memset(item_name, '\0', sizeof(item_name));
  2247. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2248. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2249. return -1;
  2250. }
  2251. if (number <= 0)
  2252. number = 1;
  2253. item_id = 0;
  2254. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2255. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2256. item_id = item_data->nameid;
  2257. if (item_id >= 500) {
  2258. get_count = number;
  2259. // check pet egg
  2260. pet_id = search_petDB_index(item_id, PET_EGG);
  2261. if (item_data->type == 4 || item_data->type == 5 ||
  2262. item_data->type == 7 || item_data->type == 8) {
  2263. get_count = 1;
  2264. }
  2265. for (i = 0; i < number; i += get_count) {
  2266. // if pet egg
  2267. if (pet_id >= 0) {
  2268. sd->catch_target_class = pet_db[pet_id].class_;
  2269. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2270. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2271. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2272. 100, 0, 1, pet_db[pet_id].jname);
  2273. // if not pet egg
  2274. } else {
  2275. memset(&item_tmp, 0, sizeof(item_tmp));
  2276. item_tmp.nameid = item_id;
  2277. item_tmp.identify = 1;
  2278. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2279. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2280. }
  2281. }
  2282. //Logs (A)dmins items [Lupus]
  2283. if(log_config.pick > 0 ) {
  2284. log_pick(sd, "A", 0, item_id, number, NULL);
  2285. }
  2286. //Logs
  2287. clif_displaymessage(fd, msg_table[18]); // Item created.
  2288. } else {
  2289. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2290. return -1;
  2291. }
  2292. return 0;
  2293. }
  2294. /*==========================================
  2295. *
  2296. *------------------------------------------
  2297. */
  2298. int atcommand_item2(
  2299. const int fd, struct map_session_data* sd,
  2300. const char* command, const char* message)
  2301. {
  2302. struct item item_tmp;
  2303. struct item_data *item_data;
  2304. char item_name[100];
  2305. int item_id, number = 0;
  2306. int identify = 0, refine = 0, attr = 0;
  2307. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2308. int flag;
  2309. int loop, get_count, i;
  2310. nullpo_retr(-1, sd);
  2311. memset(item_name, '\0', sizeof(item_name));
  2312. if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
  2313. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2314. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2315. return -1;
  2316. }
  2317. if (number <= 0)
  2318. number = 1;
  2319. item_id = 0;
  2320. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2321. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2322. item_id = item_data->nameid;
  2323. if (item_id > 500) {
  2324. loop = 1;
  2325. get_count = number;
  2326. if (item_data->type == 4 || item_data->type == 5 ||
  2327. item_data->type == 7 || item_data->type == 8) {
  2328. loop = number;
  2329. get_count = 1;
  2330. if (item_data->type == 7) {
  2331. identify = 1;
  2332. refine = 0;
  2333. }
  2334. if (item_data->type == 8)
  2335. refine = 0;
  2336. if (refine > 10)
  2337. refine = 10;
  2338. } else {
  2339. identify = 1;
  2340. refine = attr = 0;
  2341. }
  2342. for (i = 0; i < loop; i++) {
  2343. memset(&item_tmp, 0, sizeof(item_tmp));
  2344. item_tmp.nameid = item_id;
  2345. item_tmp.identify = identify;
  2346. item_tmp.refine = refine;
  2347. item_tmp.attribute = attr;
  2348. item_tmp.card[0] = c1;
  2349. item_tmp.card[1] = c2;
  2350. item_tmp.card[2] = c3;
  2351. item_tmp.card[3] = c4;
  2352. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2353. clif_additem(sd, 0, 0, flag);
  2354. }
  2355. //Logs (A)dmins items [Lupus]
  2356. if(log_config.pick > 0 ) {
  2357. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2358. }
  2359. //Logs
  2360. clif_displaymessage(fd, msg_table[18]); // Item created.
  2361. } else {
  2362. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2363. return -1;
  2364. }
  2365. return 0;
  2366. }
  2367. /*==========================================
  2368. *
  2369. *------------------------------------------
  2370. */
  2371. int atcommand_itemreset(
  2372. const int fd, struct map_session_data* sd,
  2373. const char* command, const char* message)
  2374. {
  2375. int i;
  2376. nullpo_retr(-1, sd);
  2377. for (i = 0; i < MAX_INVENTORY; i++) {
  2378. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2379. //Logs (A)dmins items [Lupus]
  2380. if(log_config.pick > 0 ) {
  2381. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2382. }
  2383. //Logs
  2384. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2385. }
  2386. }
  2387. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2388. return 0;
  2389. }
  2390. /*==========================================
  2391. *
  2392. *------------------------------------------
  2393. */
  2394. int atcommand_itemcheck(
  2395. const int fd, struct map_session_data* sd,
  2396. const char* command, const char* message)
  2397. {
  2398. nullpo_retr(-1, sd);
  2399. pc_checkitem(sd);
  2400. return 0;
  2401. }
  2402. /*==========================================
  2403. * Atcommand @lvlup
  2404. *------------------------------------------
  2405. */
  2406. int atcommand_baselevelup(
  2407. const int fd, struct map_session_data* sd,
  2408. const char* command, const char* message)
  2409. {
  2410. int level=0, i=0, status_point=0;
  2411. nullpo_retr(-1, sd);
  2412. level = atoi(message);
  2413. if (!message || !*message || !level) {
  2414. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2415. return -1;
  2416. }
  2417. if (level > 0) {
  2418. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2419. clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
  2420. return -1;
  2421. } /* End Addition */
  2422. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2423. level = pc_maxbaselv(sd) - sd->status.base_level;
  2424. for (i = 1; i <= level; i++)
  2425. status_point += (sd->status.base_level + i + 14) / 5;
  2426. if (sd->status.status_point > USHRT_MAX - status_point)
  2427. sd->status.status_point = USHRT_MAX;
  2428. else
  2429. sd->status.status_point += status_point;
  2430. sd->status.base_level += (unsigned int)level;
  2431. clif_updatestatus(sd, SP_BASELEVEL);
  2432. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2433. clif_updatestatus(sd, SP_STATUSPOINT);
  2434. status_calc_pc(sd, 0);
  2435. status_percent_heal(&sd->bl, 100, 100);
  2436. clif_misceffect(&sd->bl, 0);
  2437. clif_displaymessage(fd, msg_table[21]); /* Base level raised. */
  2438. } else {
  2439. if (sd->status.base_level == 1) {
  2440. clif_displaymessage(fd, msg_table[158]); /* Base level can't go any lower. */
  2441. return -1;
  2442. }
  2443. level*=-1;
  2444. if ((unsigned int)level >= sd->status.base_level)
  2445. level = sd->status.base_level-1;
  2446. if (sd->status.status_point > 0) {
  2447. for (i = 0; i > -level; i--)
  2448. status_point += (sd->status.base_level + i + 14) / 5;
  2449. if (sd->status.status_point < status_point)
  2450. pc_resetstate(sd);
  2451. if (sd->status.status_point < status_point)
  2452. sd->status.status_point = 0;
  2453. else
  2454. sd->status.status_point -= status_point;
  2455. clif_updatestatus(sd, SP_STATUSPOINT);
  2456. } /* to add: remove status points from stats */
  2457. sd->status.base_level -= (unsigned int)level;
  2458. clif_updatestatus(sd, SP_BASELEVEL);
  2459. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2460. status_calc_pc(sd, 0);
  2461. clif_displaymessage(fd, msg_table[22]); /* Base level lowered. */
  2462. }
  2463. return 0;
  2464. }
  2465. /*==========================================
  2466. *
  2467. *------------------------------------------
  2468. */
  2469. int atcommand_joblevelup(
  2470. const int fd, struct map_session_data* sd,
  2471. const char* command, const char* message)
  2472. {
  2473. int level=0;
  2474. nullpo_retr(-1, sd);
  2475. level = atoi(message);
  2476. if (!message || !*message || !level) {
  2477. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2478. return -1;
  2479. }
  2480. if (level > 0) {
  2481. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2482. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2483. return -1;
  2484. }
  2485. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2486. level = pc_maxjoblv(sd) - sd->status.job_level;
  2487. sd->status.job_level += (unsigned int)level;
  2488. clif_updatestatus(sd, SP_JOBLEVEL);
  2489. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2490. if (sd->status.skill_point > USHRT_MAX - level)
  2491. sd->status.skill_point = USHRT_MAX;
  2492. else
  2493. sd->status.skill_point += level;
  2494. clif_updatestatus(sd, SP_SKILLPOINT);
  2495. status_calc_pc(sd, 0);
  2496. clif_misceffect(&sd->bl, 1);
  2497. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2498. } else {
  2499. if (sd->status.job_level == 1) {
  2500. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2501. return -1;
  2502. }
  2503. level *=-1;
  2504. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2505. level = sd->status.job_level-1;
  2506. sd->status.job_level -= (unsigned int)level;
  2507. clif_updatestatus(sd, SP_JOBLEVEL);
  2508. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2509. if (sd->status.skill_point < level)
  2510. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2511. if (sd->status.skill_point < level)
  2512. sd->status.skill_point = 0;
  2513. else
  2514. sd->status.skill_point -= level;
  2515. clif_updatestatus(sd, SP_SKILLPOINT);
  2516. status_calc_pc(sd, 0);
  2517. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2518. }
  2519. return 0;
  2520. }
  2521. /*==========================================
  2522. * @help
  2523. *------------------------------------------
  2524. */
  2525. int atcommand_help(
  2526. const int fd, struct map_session_data* sd,
  2527. const char* command, const char* message)
  2528. {
  2529. char buf[2048], w1[2048], w2[2048];
  2530. int i, gm_level;
  2531. FILE* fp;
  2532. nullpo_retr(-1, sd);
  2533. memset(buf, '\0', sizeof(buf));
  2534. if ((fp = fopen(help_txt, "r")) != NULL) {
  2535. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2536. gm_level = pc_isGM(sd);
  2537. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2538. if (buf[0] == '/' && buf[1] == '/')
  2539. continue;
  2540. for (i = 0; buf[i] != '\0'; i++) {
  2541. if (buf[i] == '\r' || buf[i] == '\n') {
  2542. buf[i] = '\0';
  2543. break;
  2544. }
  2545. }
  2546. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2547. clif_displaymessage(fd, buf);
  2548. else if (gm_level >= atoi(w1))
  2549. clif_displaymessage(fd, w2);
  2550. }
  2551. fclose(fp);
  2552. } else {
  2553. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2554. return -1;
  2555. }
  2556. return 0;
  2557. }
  2558. /*==========================================
  2559. * @help2 - Char commands [Kayla]
  2560. *------------------------------------------
  2561. */
  2562. int atcommand_help2(
  2563. const int fd, struct map_session_data* sd,
  2564. const char* command, const char* message)
  2565. {
  2566. char buf[2048], w1[2048], w2[2048];
  2567. int i, gm_level;
  2568. FILE* fp;
  2569. nullpo_retr(-1, sd);
  2570. memset(buf, '\0', sizeof(buf));
  2571. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2572. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2573. gm_level = pc_isGM(sd);
  2574. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2575. if (buf[0] == '/' && buf[1] == '/')
  2576. continue;
  2577. for (i = 0; buf[i] != '\0'; i++) {
  2578. if (buf[i] == '\r' || buf[i] == '\n') {
  2579. buf[i] = '\0';
  2580. break;
  2581. }
  2582. }
  2583. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2584. clif_displaymessage(fd, buf);
  2585. else if (gm_level >= atoi(w1))
  2586. clif_displaymessage(fd, w2);
  2587. }
  2588. fclose(fp);
  2589. } else {
  2590. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2591. return -1;
  2592. }
  2593. return 0;
  2594. }
  2595. /*==========================================
  2596. * @gm
  2597. *------------------------------------------
  2598. */
  2599. int atcommand_gm(
  2600. const int fd, struct map_session_data* sd,
  2601. const char* command, const char* message)
  2602. {
  2603. char password[100];
  2604. nullpo_retr(-1, sd);
  2605. memset(password, '\0', sizeof(password));
  2606. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2607. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2608. return -1;
  2609. }
  2610. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2611. clif_displaymessage(fd, msg_table[50]); /* You already have some GM powers. */
  2612. return -1;
  2613. } else
  2614. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2615. return 0;
  2616. }
  2617. /*==========================================
  2618. *
  2619. *------------------------------------------
  2620. */
  2621. int atcommand_pvpoff(
  2622. const int fd, struct map_session_data* sd,
  2623. const char* command, const char* message)
  2624. {
  2625. struct map_session_data *pl_sd, **pl_allsd;
  2626. int i, users;
  2627. nullpo_retr(-1, sd);
  2628. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2629. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2630. return -1;
  2631. }
  2632. if (map[sd->bl.m].flag.pvp) {
  2633. map[sd->bl.m].flag.pvp = 0;
  2634. clif_send0199(sd->bl.m, 0);
  2635. pl_allsd = map_getallusers(&users);
  2636. for (i = 0; i < users; i++) { //人数分ループ
  2637. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2638. clif_pvpset(pl_sd, 0, 0, 2);
  2639. if (pl_sd->pvp_timer != -1) {
  2640. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2641. pl_sd->pvp_timer = -1;
  2642. }
  2643. }
  2644. }
  2645. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2646. } else {
  2647. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2648. return -1;
  2649. }
  2650. return 0;
  2651. }
  2652. /*==========================================
  2653. *
  2654. *------------------------------------------
  2655. */
  2656. int atcommand_pvpon(
  2657. const int fd, struct map_session_data* sd,
  2658. const char* command, const char* message)
  2659. {
  2660. struct map_session_data *pl_sd, **pl_allsd;
  2661. int i, users;
  2662. nullpo_retr(-1, sd);
  2663. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2664. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2665. return -1;
  2666. }
  2667. if (!map[sd->bl.m].flag.pvp) {
  2668. map[sd->bl.m].flag.pvp = 1;
  2669. clif_send0199(sd->bl.m, 1);
  2670. pl_allsd = map_getallusers(&users);
  2671. for (i = 0; i < users; i++) {
  2672. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2673. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2674. pl_sd->pvp_rank = 0;
  2675. pl_sd->pvp_lastusers = 0;
  2676. pl_sd->pvp_point = 5;
  2677. pl_sd->pvp_won = 0;
  2678. pl_sd->pvp_lost = 0;
  2679. }
  2680. }
  2681. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2682. } else {
  2683. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2684. return -1;
  2685. }
  2686. return 0;
  2687. }
  2688. /*==========================================
  2689. *
  2690. *------------------------------------------
  2691. */
  2692. int atcommand_gvgoff(
  2693. const int fd, struct map_session_data* sd,
  2694. const char* command, const char* message)
  2695. {
  2696. nullpo_retr(-1, sd);
  2697. if (map[sd->bl.m].flag.gvg) {
  2698. map[sd->bl.m].flag.gvg = 0;
  2699. clif_send0199(sd->bl.m, 0);
  2700. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2701. } else {
  2702. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2703. return -1;
  2704. }
  2705. return 0;
  2706. }
  2707. /*==========================================
  2708. *
  2709. *------------------------------------------
  2710. */
  2711. int atcommand_gvgon(
  2712. const int fd, struct map_session_data* sd,
  2713. const char* command, const char* message)
  2714. {
  2715. nullpo_retr(-1, sd);
  2716. if (!map[sd->bl.m].flag.gvg) {
  2717. map[sd->bl.m].flag.gvg = 1;
  2718. clif_send0199(sd->bl.m, 3);
  2719. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2720. } else {
  2721. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2722. return -1;
  2723. }
  2724. return 0;
  2725. }
  2726. /*==========================================
  2727. *
  2728. *------------------------------------------
  2729. */
  2730. int atcommand_model(
  2731. const int fd, struct map_session_data* sd,
  2732. const char* command, const char* message)
  2733. {
  2734. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2735. nullpo_retr(-1, sd);
  2736. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2737. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2738. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2739. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2740. clif_displaymessage(fd, atcmd_output);
  2741. return -1;
  2742. }
  2743. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2744. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2745. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2746. /* Removed because this check is TOO strange. [Skotlex]
  2747. //秒フ色変更
  2748. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2749. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2750. //秒フ色未実装職の判定
  2751. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2752. return -1;
  2753. } else {
  2754. */
  2755. pc_changelook(sd, LOOK_HAIR, hair_style);
  2756. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2757. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2758. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2759. // }
  2760. } else {
  2761. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2762. return -1;
  2763. }
  2764. return 0;
  2765. }
  2766. /*==========================================
  2767. * @dye && @ccolor
  2768. *------------------------------------------
  2769. */
  2770. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2771. {
  2772. int cloth_color = 0;
  2773. nullpo_retr(-1, sd);
  2774. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2775. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2776. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2777. clif_displaymessage(fd, atcmd_output);
  2778. return -1;
  2779. }
  2780. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2781. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2782. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2783. } else {
  2784. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2785. return -1;
  2786. }
  2787. return 0;
  2788. }
  2789. /*==========================================
  2790. * @hairstyle && @hstyle
  2791. *------------------------------------------
  2792. */
  2793. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2794. {
  2795. int hair_style = 0;
  2796. nullpo_retr(-1, sd);
  2797. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2798. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2799. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2800. clif_displaymessage(fd, atcmd_output);
  2801. return -1;
  2802. }
  2803. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2804. /* Removed because this check is TOO strange. [Skotlex]
  2805. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2806. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2807. return -1;
  2808. } else {
  2809. */
  2810. pc_changelook(sd, LOOK_HAIR, hair_style);
  2811. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2812. // }
  2813. } else {
  2814. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2815. return -1;
  2816. }
  2817. return 0;
  2818. }
  2819. /*==========================================
  2820. * @charhairstyle by [MouseJstr]
  2821. *------------------------------------------
  2822. */
  2823. int
  2824. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2825. const char* command, const char* message)
  2826. {
  2827. nullpo_retr(-1, sd);
  2828. return 0;
  2829. }
  2830. /*==========================================
  2831. * @haircolor && @hcolor
  2832. *------------------------------------------
  2833. */
  2834. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2835. {
  2836. int hair_color = 0;
  2837. nullpo_retr(-1, sd);
  2838. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2839. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2840. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2841. clif_displaymessage(fd, atcmd_output);
  2842. return -1;
  2843. }
  2844. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2845. /* Removed for being such a strange check. [Skotlex]
  2846. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2847. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2848. return -1;
  2849. } else {
  2850. */
  2851. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2852. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2853. // }
  2854. } else {
  2855. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2856. return -1;
  2857. }
  2858. return 0;
  2859. }
  2860. /*==========================================
  2861. * @go [city_number or city_name] - Updated by Harbin
  2862. *------------------------------------------
  2863. */
  2864. int atcommand_go(
  2865. const int fd, struct map_session_data* sd,
  2866. const char* command, const char* message)
  2867. {
  2868. int i;
  2869. int town;
  2870. char map_name[MAP_NAME_LENGTH];
  2871. int m;
  2872. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2873. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2874. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2875. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2876. { MAP_PAYON, 162, 233 }, // 3=Payon
  2877. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2878. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2879. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2880. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2881. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2882. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2883. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2884. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2885. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2886. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2887. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2888. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2889. { MAP_JAIL, 23, 61 }, // 16=Prison
  2890. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2891. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2892. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2893. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2894. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2895. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2896. };
  2897. nullpo_retr(-1, sd);
  2898. if(map[sd->bl.m].flag.nogo) {
  2899. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2900. return 0;
  2901. }
  2902. memset(map_name, '\0', sizeof(map_name));
  2903. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2904. // get the number
  2905. town = atoi(message);
  2906. // if no value, display all value
  2907. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2908. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2909. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2910. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2911. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2912. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2913. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2914. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2915. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2916. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2917. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2918. return -1;
  2919. } else {
  2920. // get possible name of the city and add .gat if not in the name
  2921. map_name[MAP_NAME_LENGTH-1] = '\0';
  2922. for (i = 0; map_name[i]; i++)
  2923. map_name[i] = tolower(map_name[i]);
  2924. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2925. strcat(map_name, ".gat");
  2926. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2927. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2928. town = 0;
  2929. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2930. town = 1;
  2931. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2932. town = 2;
  2933. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2934. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2935. town = 3;
  2936. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2937. town = 4;
  2938. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2939. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2940. town = 5;
  2941. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2942. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2943. town = 6;
  2944. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2945. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2946. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2947. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2948. town = 7;
  2949. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2950. town = 8;
  2951. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2952. town = 9;
  2953. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2954. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2955. town = 10;
  2956. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2957. town = 11;
  2958. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2959. town = 12;
  2960. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2961. town = 13;
  2962. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2963. town = 14;
  2964. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2965. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2966. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2967. town = 15;
  2968. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2969. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2970. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2971. town = 16;
  2972. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2973. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2974. town = 17;
  2975. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2976. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2977. town = 18;
  2978. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  2979. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  2980. town = 19;
  2981. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2982. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2983. town = 20;
  2984. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  2985. town = 21;
  2986. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2987. town = 22;
  2988. }
  2989. if (town >= -3 && town <= -1) {
  2990. if (sd->status.memo_point[-town-1].map) {
  2991. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2992. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2993. clif_displaymessage(fd, msg_table[247]);
  2994. return -1;
  2995. }
  2996. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2997. clif_displaymessage(fd, msg_table[248]);
  2998. return -1;
  2999. }
  3000. 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) {
  3001. clif_displaymessage(fd, msg_table[0]); // Warped.
  3002. } else {
  3003. clif_displaymessage(fd, msg_table[1]); // Map not found.
  3004. return -1;
  3005. }
  3006. } else {
  3007. sprintf(atcmd_output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  3008. clif_displaymessage(fd, atcmd_output);
  3009. return -1;
  3010. }
  3011. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  3012. m = map_mapname2mapid((char *)data[town].map);
  3013. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3014. clif_displaymessage(fd, msg_table[247]);
  3015. return -1;
  3016. }
  3017. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3018. clif_displaymessage(fd, msg_table[248]);
  3019. return -1;
  3020. }
  3021. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  3022. clif_displaymessage(fd, msg_table[0]); // Warped.
  3023. } else {
  3024. clif_displaymessage(fd, msg_table[1]); // Map not found.
  3025. return -1;
  3026. }
  3027. } else { // if you arrive here, you have an error in town variable when reading of names
  3028. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  3029. return -1;
  3030. }
  3031. }
  3032. return 0;
  3033. }
  3034. /*==========================================
  3035. *
  3036. *------------------------------------------
  3037. */
  3038. int atcommand_monster(
  3039. const int fd, struct map_session_data* sd,
  3040. const char* command, const char* message)
  3041. {
  3042. char name[NAME_LENGTH];
  3043. char monster[NAME_LENGTH];
  3044. int mob_id;
  3045. int number = 0;
  3046. int count;
  3047. int i, k, range;
  3048. short mx, my;
  3049. nullpo_retr(-1, sd);
  3050. memset(name, '\0', sizeof(name));
  3051. memset(monster, '\0', sizeof(monster));
  3052. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3053. if (!message || !*message) {
  3054. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3055. return -1;
  3056. }
  3057. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3058. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3059. //All data can be left as it is.
  3060. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3061. //Here, it is possible name was not given and we are using monster for it.
  3062. if (count < 3) //Blank mob's name.
  3063. name[0] = '\0';
  3064. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3065. //All data can be left as it is.
  3066. } else if (sscanf(message, "%23s", monster) > 0) {
  3067. //As before, name may be already filled.
  3068. name[0] = '\0';
  3069. } else {
  3070. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3071. return -1;
  3072. }
  3073. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3074. mob_id = mobdb_checkid(atoi(monster));
  3075. if (mob_id == 0) {
  3076. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3077. return -1;
  3078. }
  3079. if (mob_id == MOBID_EMPERIUM) {
  3080. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  3081. return -1;
  3082. }
  3083. if (number <= 0)
  3084. number = 1;
  3085. if (strlen(name) < 1)
  3086. strcpy(name, "--ja--");
  3087. // 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
  3088. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3089. number = battle_config.atc_spawn_quantity_limit;
  3090. if (battle_config.etc_log)
  3091. 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);
  3092. count = 0;
  3093. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3094. for (i = 0; i < number; i++) {
  3095. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3096. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3097. count += (k != 0) ? 1 : 0;
  3098. }
  3099. if (count != 0)
  3100. if (number == count)
  3101. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  3102. else {
  3103. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  3104. clif_displaymessage(fd, atcmd_output);
  3105. }
  3106. else {
  3107. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3108. return -1;
  3109. }
  3110. return 0;
  3111. }
  3112. // small monster spawning [Valaris]
  3113. int atcommand_monstersmall(
  3114. const int fd, struct map_session_data* sd,
  3115. const char* command, const char* message) {
  3116. char name[NAME_LENGTH] = "";
  3117. char monster[NAME_LENGTH] = "";
  3118. int mob_id = 0;
  3119. int number = 0;
  3120. int x = 0;
  3121. int y = 0;
  3122. int count;
  3123. int i;
  3124. nullpo_retr(-1, sd);
  3125. if (!message || !*message) {
  3126. clif_displaymessage(fd, "Give a monster name/id please.");
  3127. return -1;
  3128. }
  3129. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3130. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3131. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3132. clif_displaymessage(fd, "Give a monster name/id please.");
  3133. return -1;
  3134. }
  3135. // If monster identifier/name argument is a name
  3136. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3137. mob_id = atoi(monster);
  3138. if (mob_id == 0) {
  3139. clif_displaymessage(fd, msg_table[40]);
  3140. return -1;
  3141. }
  3142. if (mob_id == MOBID_EMPERIUM) {
  3143. clif_displaymessage(fd, msg_table[83]);
  3144. return -1;
  3145. }
  3146. if (mobdb_checkid(mob_id) == 0) {
  3147. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3148. return -1;
  3149. }
  3150. if (number <= 0)
  3151. number = 1;
  3152. if (strlen(name) < 1)
  3153. strcpy(name, "--ja--");
  3154. // 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
  3155. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3156. number = battle_config.atc_spawn_quantity_limit;
  3157. count = 0;
  3158. for (i = 0; i < number; i++) {
  3159. int mx, my;
  3160. if (x <= 0)
  3161. mx = sd->bl.x + (rand() % 11 - 5);
  3162. else
  3163. mx = x;
  3164. if (y <= 0)
  3165. my = sd->bl.y + (rand() % 11 - 5);
  3166. else
  3167. my = y;
  3168. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3169. }
  3170. if (count != 0)
  3171. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3172. else
  3173. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3174. return 0;
  3175. }
  3176. // big monster spawning [Valaris]
  3177. int atcommand_monsterbig(
  3178. const int fd, struct map_session_data* sd,
  3179. const char* command, const char* message) {
  3180. char name[NAME_LENGTH] = "";
  3181. char monster[NAME_LENGTH] = "";
  3182. int mob_id = 0;
  3183. int number = 0;
  3184. int x = 0;
  3185. int y = 0;
  3186. int count;
  3187. int i;
  3188. nullpo_retr(-1, sd);
  3189. if (!message || !*message) {
  3190. clif_displaymessage(fd, "Give a monster name/id please.");
  3191. return -1;
  3192. }
  3193. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3194. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3195. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3196. clif_displaymessage(fd, "Give a monster name/id please.");
  3197. return -1;
  3198. }
  3199. // If monster identifier/name argument is a name
  3200. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3201. mob_id = atoi(monster);
  3202. if (mob_id == 0) {
  3203. clif_displaymessage(fd, msg_table[40]);
  3204. return -1;
  3205. }
  3206. if (mob_id == MOBID_EMPERIUM) {
  3207. clif_displaymessage(fd, msg_table[83]);
  3208. return -1;
  3209. }
  3210. if (mobdb_checkid(mob_id) == 0) {
  3211. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3212. return -1;
  3213. }
  3214. if (number <= 0)
  3215. number = 1;
  3216. if (strlen(name) < 1)
  3217. strcpy(name, "--ja--");
  3218. // 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
  3219. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3220. number = battle_config.atc_spawn_quantity_limit;
  3221. count = 0;
  3222. for (i = 0; i < number; i++) {
  3223. int mx, my;
  3224. if (x <= 0)
  3225. mx = sd->bl.x + (rand() % 11 - 5);
  3226. else
  3227. mx = x;
  3228. if (y <= 0)
  3229. my = sd->bl.y + (rand() % 11 - 5);
  3230. else
  3231. my = y;
  3232. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3233. }
  3234. if (count != 0)
  3235. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3236. else
  3237. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3238. return 0;
  3239. }
  3240. /*==========================================
  3241. *
  3242. *------------------------------------------
  3243. */
  3244. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3245. struct mob_data *md;
  3246. int flag;
  3247. nullpo_retr(0, ap);
  3248. nullpo_retr(0, md=(struct mob_data *)bl);
  3249. flag = va_arg(ap, int);
  3250. if (md->guardian_data)
  3251. return 0; //Do not touch WoE mobs!
  3252. if (flag)
  3253. status_kill(bl);
  3254. else //FIXME: Eh.. what exactly is the difference here?
  3255. status_kill(bl);
  3256. return 1;
  3257. }
  3258. void atcommand_killmonster_sub(
  3259. const int fd, struct map_session_data* sd, const char* message,
  3260. const int drop)
  3261. {
  3262. int map_id;
  3263. char map_name[MAP_NAME_LENGTH];
  3264. if (!sd) return;
  3265. memset(map_name, '\0', sizeof(map_name));
  3266. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3267. map_id = sd->bl.m;
  3268. else {
  3269. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3270. strcat(map_name, ".gat");
  3271. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3272. map_id = sd->bl.m;
  3273. }
  3274. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3275. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3276. return;
  3277. }
  3278. /*==========================================
  3279. *
  3280. *------------------------------------------
  3281. */
  3282. int atcommand_killmonster(
  3283. const int fd, struct map_session_data* sd,
  3284. const char* command, const char* message)
  3285. {
  3286. if (!sd) return 0;
  3287. atcommand_killmonster_sub(fd, sd, message, 1);
  3288. return 0;
  3289. }
  3290. /*==========================================
  3291. *
  3292. *------------------------------------------
  3293. */
  3294. int atcommand_killmonster2(
  3295. const int fd, struct map_session_data* sd,
  3296. const char* command, const char* message)
  3297. {
  3298. if (!sd) return 0;
  3299. atcommand_killmonster_sub(fd, sd, message, 0);
  3300. return 0;
  3301. }
  3302. /*==========================================
  3303. *
  3304. *------------------------------------------
  3305. */
  3306. int atcommand_refine(
  3307. const int fd, struct map_session_data* sd,
  3308. const char* command, const char* message)
  3309. {
  3310. int i, position = 0, refine = 0, current_position, final_refine;
  3311. int count;
  3312. nullpo_retr(-1, sd);
  3313. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3314. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3315. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3316. return -1;
  3317. }
  3318. if (refine < -10)
  3319. refine = -10;
  3320. else if (refine > 10)
  3321. refine = 10;
  3322. else if (refine == 0)
  3323. refine = 1;
  3324. count = 0;
  3325. for (i = 0; i < MAX_INVENTORY; i++) {
  3326. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3327. (sd->status.inventory[i].equip & position ||
  3328. (sd->status.inventory[i].equip && !position))) {
  3329. final_refine = sd->status.inventory[i].refine + refine;
  3330. if (final_refine > 10)
  3331. final_refine = 10;
  3332. else if (final_refine < 0)
  3333. final_refine = 0;
  3334. if (sd->status.inventory[i].refine != final_refine) {
  3335. sd->status.inventory[i].refine = final_refine;
  3336. current_position = sd->status.inventory[i].equip;
  3337. pc_unequipitem(sd, i, 3);
  3338. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3339. clif_delitem(sd, i, 1);
  3340. clif_additem(sd, i, 1, 0);
  3341. pc_equipitem(sd, i, current_position);
  3342. clif_misceffect((struct block_list*)&sd->bl, 3);
  3343. count++;
  3344. }
  3345. }
  3346. }
  3347. if (count == 0)
  3348. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3349. else if (count == 1)
  3350. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3351. else {
  3352. sprintf(atcmd_output, msg_table[168], count); // %d items have been refined!
  3353. clif_displaymessage(fd, atcmd_output);
  3354. }
  3355. return 0;
  3356. }
  3357. /*==========================================
  3358. *
  3359. *------------------------------------------
  3360. */
  3361. int atcommand_produce(
  3362. const int fd, struct map_session_data* sd,
  3363. const char* command, const char* message)
  3364. {
  3365. char item_name[100];
  3366. int item_id, attribute = 0, star = 0;
  3367. int flag = 0;
  3368. struct item_data *item_data;
  3369. struct item tmp_item;
  3370. nullpo_retr(-1, sd);
  3371. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3372. memset(item_name, '\0', sizeof(item_name));
  3373. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3374. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3375. return -1;
  3376. }
  3377. item_id = 0;
  3378. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3379. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3380. item_id = item_data->nameid;
  3381. if (itemdb_exists(item_id) &&
  3382. (item_id <= 500 || item_id > 1099) &&
  3383. (item_id < 4001 || item_id > 4148) &&
  3384. (item_id < 7001 || item_id > 10019) &&
  3385. itemdb_isequip(item_id)) {
  3386. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3387. attribute = ATTRIBUTE_NORMAL;
  3388. if (star < MIN_STAR || star > MAX_STAR)
  3389. star = 0;
  3390. memset(&tmp_item, 0, sizeof tmp_item);
  3391. tmp_item.nameid = item_id;
  3392. tmp_item.amount = 1;
  3393. tmp_item.identify = 1;
  3394. tmp_item.card[0] = 0x00ff;
  3395. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3396. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3397. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3398. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3399. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3400. //Logs (A)dmins items [Lupus]
  3401. if(log_config.pick > 0 ) {
  3402. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3403. }
  3404. //Logs
  3405. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3406. clif_additem(sd, 0, 0, flag);
  3407. } else {
  3408. if (battle_config.error_log)
  3409. ShowError("@produce NOT WEAPON [%d]\n", item_id);
  3410. if (item_id != 0 && itemdb_exists(item_id))
  3411. sprintf(atcmd_output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3412. else
  3413. sprintf(atcmd_output, msg_table[170]); // This item is not an equipment.
  3414. clif_displaymessage(fd, atcmd_output);
  3415. return -1;
  3416. }
  3417. return 0;
  3418. }
  3419. /*==========================================
  3420. * Sub-function to display actual memo points
  3421. *------------------------------------------
  3422. */
  3423. void atcommand_memo_sub(struct map_session_data* sd) {
  3424. int i;
  3425. if (!sd) return;
  3426. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3427. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3428. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3429. if (sd->status.memo_point[i].map)
  3430. 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);
  3431. else
  3432. sprintf(atcmd_output, msg_table[171], i); // %d - void
  3433. clif_displaymessage(sd->fd, atcmd_output);
  3434. }
  3435. return;
  3436. }
  3437. /*==========================================
  3438. *
  3439. *------------------------------------------
  3440. */
  3441. int atcommand_memo(
  3442. const int fd, struct map_session_data* sd,
  3443. const char* command, const char* message)
  3444. {
  3445. int position = 0;
  3446. nullpo_retr(-1, sd);
  3447. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3448. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3449. atcommand_memo_sub(sd);
  3450. else {
  3451. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3452. 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)) {
  3453. clif_displaymessage(fd, msg_table[253]);
  3454. return -1;
  3455. }
  3456. if (sd->status.memo_point[position].map) {
  3457. sprintf(atcmd_output, msg_table[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).
  3458. clif_displaymessage(fd, atcmd_output);
  3459. }
  3460. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3461. sd->status.memo_point[position].x = sd->bl.x;
  3462. sd->status.memo_point[position].y = sd->bl.y;
  3463. clif_skill_memo(sd, 0);
  3464. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3465. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3466. atcommand_memo_sub(sd);
  3467. } else {
  3468. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3469. clif_displaymessage(fd, atcmd_output);
  3470. atcommand_memo_sub(sd);
  3471. return -1;
  3472. }
  3473. }
  3474. return 0;
  3475. }
  3476. /*==========================================
  3477. *
  3478. *------------------------------------------
  3479. */
  3480. int atcommand_gat(
  3481. const int fd, struct map_session_data* sd,
  3482. const char* command, const char* message)
  3483. {
  3484. int y;
  3485. nullpo_retr(-1, sd);
  3486. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3487. for (y = 2; y >= -2; y--) {
  3488. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3489. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3490. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3491. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3492. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3493. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3494. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3495. clif_displaymessage(fd, atcmd_output);
  3496. }
  3497. return 0;
  3498. }
  3499. /*==========================================
  3500. *
  3501. *------------------------------------------
  3502. */
  3503. int atcommand_packet(
  3504. const int fd, struct map_session_data* sd,
  3505. const char* command, const char* message)
  3506. {
  3507. static int packet_mode = 0;
  3508. int i, x = 0, y = 0;
  3509. nullpo_retr(-1, sd);
  3510. if (strstr(command, "packetmode")) {
  3511. packet_mode = atoi(message);
  3512. clif_displaymessage(fd, "Packet mode changed.");
  3513. return 0;
  3514. }
  3515. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3516. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3517. return -1;
  3518. }
  3519. if (i == 1) y = 1;
  3520. switch (packet_mode)
  3521. {
  3522. case 0:
  3523. clif_status_change(&sd->bl, x, y);
  3524. break;
  3525. case 1:
  3526. sd->status.skill[sd->cloneskill_id].id=0;
  3527. sd->status.skill[sd->cloneskill_id].lv=0;
  3528. sd->status.skill[sd->cloneskill_id].flag=0;
  3529. sd->cloneskill_id = x;
  3530. sd->status.skill[x].id = x;
  3531. sd->status.skill[x].lv = skill_get_max(x);
  3532. sd->status.skill[x].flag = 13;//cloneskill flag
  3533. clif_skillinfoblock(sd);
  3534. break;
  3535. case 2:
  3536. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3537. case 3:
  3538. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3539. default:
  3540. break;
  3541. //added later
  3542. }
  3543. return 0;
  3544. }
  3545. /*==========================================
  3546. * @waterlevel [Skotlex]
  3547. *------------------------------------------
  3548. */
  3549. int atcommand_waterlevel(
  3550. const int fd, struct map_session_data* sd,
  3551. const char* command, const char* message)
  3552. {
  3553. int newlevel;
  3554. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3555. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3556. clif_displaymessage(fd, atcmd_output);
  3557. return 0;
  3558. }
  3559. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3560. if (newlevel > 0)
  3561. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3562. else
  3563. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3564. clif_displaymessage(fd, atcmd_output);
  3565. } else {
  3566. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3567. clif_displaymessage(fd, atcmd_output);
  3568. }
  3569. return 0;
  3570. }
  3571. /*==========================================
  3572. * @stpoint (Rewritten by [Yor])
  3573. *------------------------------------------
  3574. */
  3575. int atcommand_statuspoint(
  3576. const int fd, struct map_session_data* sd,
  3577. const char* command, const char* message)
  3578. {
  3579. int point, new_status_point;
  3580. if (!message || !*message || (point = atoi(message)) == 0) {
  3581. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3582. return -1;
  3583. }
  3584. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3585. new_status_point = USHRT_MAX;
  3586. else
  3587. if (point < 0 && sd->status.status_point < -point)
  3588. new_status_point = 0;
  3589. else
  3590. new_status_point = sd->status.status_point + point;
  3591. if (new_status_point != (int)sd->status.status_point) {
  3592. sd->status.status_point = (unsigned short)new_status_point;
  3593. clif_updatestatus(sd, SP_STATUSPOINT);
  3594. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3595. } else {
  3596. if (point < 0)
  3597. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3598. else
  3599. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3600. return -1;
  3601. }
  3602. return 0;
  3603. }
  3604. /*==========================================
  3605. * @skpoint (Rewritten by [Yor])
  3606. *------------------------------------------
  3607. */
  3608. int atcommand_skillpoint(
  3609. const int fd, struct map_session_data* sd,
  3610. const char* command, const char* message)
  3611. {
  3612. int point, new_skill_point;
  3613. nullpo_retr(-1, sd);
  3614. if (!message || !*message || (point = atoi(message)) == 0) {
  3615. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3616. return -1;
  3617. }
  3618. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3619. new_skill_point = USHRT_MAX;
  3620. else if (point < 0 && sd->status.skill_point < -point)
  3621. new_skill_point = 0;
  3622. else
  3623. new_skill_point = sd->status.skill_point + point;
  3624. if (new_skill_point != (int)sd->status.skill_point) {
  3625. sd->status.skill_point = (unsigned short)new_skill_point;
  3626. clif_updatestatus(sd, SP_SKILLPOINT);
  3627. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3628. } else {
  3629. if (point < 0)
  3630. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3631. else
  3632. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3633. return -1;
  3634. }
  3635. return 0;
  3636. }
  3637. /*==========================================
  3638. * @zeny (Rewritten by [Yor])
  3639. *------------------------------------------
  3640. */
  3641. int atcommand_zeny(
  3642. const int fd, struct map_session_data* sd,
  3643. const char* command, const char* message)
  3644. {
  3645. int zeny, new_zeny;
  3646. nullpo_retr(-1, sd);
  3647. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3648. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3649. return -1;
  3650. }
  3651. new_zeny = sd->status.zeny + zeny;
  3652. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3653. new_zeny = MAX_ZENY;
  3654. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3655. new_zeny = 0;
  3656. if (new_zeny != sd->status.zeny) {
  3657. sd->status.zeny = new_zeny;
  3658. clif_updatestatus(sd, SP_ZENY);
  3659. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3660. } else {
  3661. if (zeny < 0)
  3662. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3663. else
  3664. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3665. return -1;
  3666. }
  3667. return 0;
  3668. }
  3669. /*==========================================
  3670. *
  3671. *------------------------------------------
  3672. */
  3673. int atcommand_param(
  3674. const int fd, struct map_session_data* sd,
  3675. const char* command, const char* message)
  3676. {
  3677. int index, value = 0, new_value, max;
  3678. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3679. short* status[6];
  3680. //we don't use direct initialization because it isn't part of the c standard.
  3681. nullpo_retr(-1, sd);
  3682. status[0] = &sd->status.str;
  3683. status[1] = &sd->status.agi;
  3684. status[2] = &sd->status.vit;
  3685. status[3] = &sd->status.int_;
  3686. status[4] = &sd->status.dex;
  3687. status[5] = &sd->status.luk;
  3688. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3689. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3690. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3691. clif_displaymessage(fd, atcmd_output);
  3692. return -1;
  3693. }
  3694. index = -1;
  3695. for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
  3696. if (strcmpi(command, param[index]) == 0)
  3697. break;
  3698. }
  3699. if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
  3700. // normaly impossible...
  3701. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3702. clif_displaymessage(fd, atcmd_output);
  3703. return -1;
  3704. }
  3705. max = pc_maxparameter(sd);
  3706. if (value > 0 && *status[index] > max - value)
  3707. new_value = max;
  3708. else if (value < 0 && *status[index] <= -value)
  3709. new_value = 1;
  3710. else
  3711. new_value = *status[index] + value;
  3712. if (new_value != (int)*status[index]) {
  3713. *status[index] = new_value;
  3714. clif_updatestatus(sd, SP_STR + index);
  3715. clif_updatestatus(sd, SP_USTR + index);
  3716. status_calc_pc(sd, 0);
  3717. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3718. } else {
  3719. if (value < 0)
  3720. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3721. else
  3722. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3723. return -1;
  3724. }
  3725. return 0;
  3726. }
  3727. /*==========================================
  3728. *
  3729. *------------------------------------------
  3730. */
  3731. //** Stat all by fritz (rewritten by [Yor])
  3732. int atcommand_stat_all(
  3733. const int fd, struct map_session_data* sd,
  3734. const char* command, const char* message)
  3735. {
  3736. int index, count, value = 0, max, new_value;
  3737. short* status[6];
  3738. //we don't use direct initialization because it isn't part of the c standard.
  3739. nullpo_retr(-1, sd);
  3740. status[0] = &sd->status.str;
  3741. status[1] = &sd->status.agi;
  3742. status[2] = &sd->status.vit;
  3743. status[3] = &sd->status.int_;
  3744. status[4] = &sd->status.dex;
  3745. status[5] = &sd->status.luk;
  3746. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3747. value = pc_maxparameter(sd);
  3748. count = 0;
  3749. max = pc_maxparameter(sd);
  3750. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3751. if (value > 0 && *status[index] > max - value)
  3752. new_value = max;
  3753. else if (value < 0 && *status[index] <= -value)
  3754. new_value = 1;
  3755. else
  3756. new_value = *status[index] +value;
  3757. if (new_value != (int)*status[index]) {
  3758. *status[index] = new_value;
  3759. clif_updatestatus(sd, SP_STR + index);
  3760. clif_updatestatus(sd, SP_USTR + index);
  3761. status_calc_pc(sd, 0);
  3762. count++;
  3763. }
  3764. }
  3765. if (count > 0) // if at least 1 stat modified
  3766. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3767. else {
  3768. if (value < 0)
  3769. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3770. else
  3771. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3772. return -1;
  3773. }
  3774. return 0;
  3775. }
  3776. /*==========================================
  3777. *
  3778. *------------------------------------------
  3779. */
  3780. int atcommand_guildlevelup(
  3781. const int fd, struct map_session_data* sd,
  3782. const char* command, const char* message)
  3783. {
  3784. int level = 0;
  3785. short added_level;
  3786. struct guild *guild_info;
  3787. nullpo_retr(-1, sd);
  3788. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3789. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3790. return -1;
  3791. }
  3792. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3793. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3794. return -1;
  3795. }
  3796. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3797. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3798. return -1;
  3799. }
  3800. added_level = (short)level;
  3801. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3802. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3803. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3804. added_level = 1 - guild_info->guild_lv;
  3805. if (added_level != 0) {
  3806. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3807. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3808. } else {
  3809. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3810. return -1;
  3811. }
  3812. return 0;
  3813. }
  3814. /*==========================================
  3815. *
  3816. *------------------------------------------
  3817. */
  3818. int atcommand_makeegg(
  3819. const int fd, struct map_session_data* sd,
  3820. const char* command, const char* message)
  3821. {
  3822. struct item_data *item_data;
  3823. int id, pet_id;
  3824. nullpo_retr(-1, sd);
  3825. if (!message || !*message) {
  3826. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3827. return -1;
  3828. }
  3829. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3830. id = item_data->nameid;
  3831. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3832. id = atoi(message);
  3833. pet_id = search_petDB_index(id, PET_CLASS);
  3834. if (pet_id < 0)
  3835. pet_id = search_petDB_index(id, PET_EGG);
  3836. if (pet_id >= 0) {
  3837. sd->catch_target_class = pet_db[pet_id].class_;
  3838. intif_create_pet(
  3839. sd->status.account_id, sd->status.char_id,
  3840. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3841. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3842. 100, 0, 1, pet_db[pet_id].jname);
  3843. } else {
  3844. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3845. return -1;
  3846. }
  3847. return 0;
  3848. }
  3849. /*==========================================
  3850. *
  3851. *------------------------------------------
  3852. */
  3853. int atcommand_hatch(
  3854. const int fd, struct map_session_data* sd,
  3855. const char* command, const char* message)
  3856. {
  3857. nullpo_retr(-1, sd);
  3858. if (sd->status.pet_id <= 0)
  3859. clif_sendegg(sd);
  3860. else {
  3861. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3862. return -1;
  3863. }
  3864. return 0;
  3865. }
  3866. /*==========================================
  3867. *
  3868. *------------------------------------------
  3869. */
  3870. int atcommand_petfriendly(
  3871. const int fd, struct map_session_data* sd,
  3872. const char* command, const char* message)
  3873. {
  3874. int friendly;
  3875. nullpo_retr(-1, sd);
  3876. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3877. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3878. return -1;
  3879. }
  3880. if (!sd->pd) {
  3881. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3882. return -1;
  3883. }
  3884. if (friendly < 0 || friendly > 1000)
  3885. {
  3886. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3887. return -1;
  3888. }
  3889. if (friendly == sd->pet.intimate) {
  3890. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3891. return -1;
  3892. }
  3893. sd->pet.intimate = friendly;
  3894. clif_send_petstatus(sd);
  3895. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3896. return 0;
  3897. }
  3898. /*==========================================
  3899. *
  3900. *------------------------------------------
  3901. */
  3902. int atcommand_pethungry(
  3903. const int fd, struct map_session_data* sd,
  3904. const char* command, const char* message)
  3905. {
  3906. int hungry;
  3907. nullpo_retr(-1, sd);
  3908. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3909. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3910. return -1;
  3911. }
  3912. if (sd->status.pet_id > 0 && sd->pd) {
  3913. if (hungry >= 0 && hungry <= 100) {
  3914. if (hungry != sd->pet.hungry) {
  3915. sd->pet.hungry = hungry;
  3916. clif_send_petstatus(sd);
  3917. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3918. } else {
  3919. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3920. return -1;
  3921. }
  3922. } else {
  3923. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3924. return -1;
  3925. }
  3926. } else {
  3927. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3928. return -1;
  3929. }
  3930. return 0;
  3931. }
  3932. /*==========================================
  3933. *
  3934. *------------------------------------------
  3935. */
  3936. int atcommand_petrename(
  3937. const int fd, struct map_session_data* sd,
  3938. const char* command, const char* message)
  3939. {
  3940. nullpo_retr(-1, sd);
  3941. if (sd->status.pet_id > 0 && sd->pd) {
  3942. if (sd->pet.rename_flag != 0) {
  3943. sd->pet.rename_flag = 0;
  3944. intif_save_petdata(sd->status.account_id, &sd->pet);
  3945. clif_send_petstatus(sd);
  3946. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3947. } else {
  3948. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3949. return -1;
  3950. }
  3951. } else {
  3952. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3953. return -1;
  3954. }
  3955. return 0;
  3956. }
  3957. /*==========================================
  3958. *
  3959. *------------------------------------------
  3960. */
  3961. int
  3962. atcommand_recall(
  3963. const int fd, struct map_session_data* sd,
  3964. const char* command, const char* message)
  3965. {
  3966. struct map_session_data *pl_sd = NULL;
  3967. nullpo_retr(-1, sd);
  3968. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3969. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3970. return -1;
  3971. }
  3972. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3973. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3974. return -1;
  3975. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3976. return -1;
  3977. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3978. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3979. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3980. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3981. return -1;
  3982. }
  3983. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3984. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3985. return -1;
  3986. }
  3987. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3988. sprintf(atcmd_output, msg_table[46], atcmd_player_name); // %s recalled!
  3989. clif_displaymessage(fd, atcmd_output);
  3990. } else {
  3991. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3992. return -1;
  3993. }
  3994. } else {
  3995. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3996. return -1;
  3997. }
  3998. return 0;
  3999. }
  4000. /*==========================================
  4001. *
  4002. *------------------------------------------
  4003. */
  4004. int atcommand_revive(
  4005. const int fd, struct map_session_data* sd,
  4006. const char* command, const char* message)
  4007. {
  4008. struct map_session_data *pl_sd;
  4009. nullpo_retr(-1, sd);
  4010. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4011. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4012. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  4013. return -1;
  4014. }
  4015. pl_sd = map_nick2sd(atcmd_player_name);
  4016. if (!pl_sd) {
  4017. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4018. return -1;
  4019. }
  4020. if (!status_revive(&sd->bl, 100, 0))
  4021. return -1;
  4022. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4023. clif_displaymessage(fd, msg_table[51]); // Character revived.
  4024. return 0;
  4025. }
  4026. /*==========================================
  4027. * charblock command (usage: charblock <player_name>)
  4028. * This command do a definitiv ban on a player
  4029. *------------------------------------------
  4030. */
  4031. int atcommand_char_block(
  4032. const int fd, struct map_session_data* sd,
  4033. const char* command, const char* message)
  4034. {
  4035. nullpo_retr(-1, sd);
  4036. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4037. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4038. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4039. return -1;
  4040. }
  4041. // check player name
  4042. if (strlen(atcmd_player_name) < 4) {
  4043. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4044. return -1;
  4045. } else if (strlen(atcmd_player_name) > 23) {
  4046. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4047. return -1;
  4048. } else {
  4049. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4050. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4051. }
  4052. return 0;
  4053. }
  4054. /*==========================================
  4055. * charban command (usage: charban <time> <player_name>)
  4056. * This command do a limited ban on a player
  4057. * Time is done as follows:
  4058. * Adjustment value (-1, 1, +1, etc...)
  4059. * Modified element:
  4060. * a or y: year
  4061. * m: month
  4062. * j or d: day
  4063. * h: hour
  4064. * mn: minute
  4065. * s: second
  4066. * <example> @ban +1m-2mn1s-6y test_player
  4067. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4068. *------------------------------------------
  4069. */
  4070. int atcommand_char_ban(
  4071. const int fd, struct map_session_data* sd,
  4072. const char* command, const char* message)
  4073. {
  4074. char * modif_p;
  4075. int year, month, day, hour, minute, second, value;
  4076. nullpo_retr(-1, sd);
  4077. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4078. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4079. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4080. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4081. return -1;
  4082. }
  4083. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4084. modif_p = atcmd_output;
  4085. year = month = day = hour = minute = second = 0;
  4086. while (modif_p[0] != '\0') {
  4087. value = atoi(modif_p);
  4088. if (value == 0)
  4089. modif_p++;
  4090. else {
  4091. if (modif_p[0] == '-' || modif_p[0] == '+')
  4092. modif_p++;
  4093. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4094. modif_p++;
  4095. if (modif_p[0] == 's') {
  4096. second = value;
  4097. modif_p++;
  4098. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4099. minute = value;
  4100. modif_p = modif_p + 2;
  4101. } else if (modif_p[0] == 'h') {
  4102. hour = value;
  4103. modif_p++;
  4104. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4105. day = value;
  4106. modif_p++;
  4107. } else if (modif_p[0] == 'm') {
  4108. month = value;
  4109. modif_p++;
  4110. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4111. year = value;
  4112. modif_p++;
  4113. } else if (modif_p[0] != '\0') {
  4114. modif_p++;
  4115. }
  4116. }
  4117. }
  4118. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4119. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  4120. return -1;
  4121. }
  4122. // check player name
  4123. if (strlen(atcmd_player_name) < 4) {
  4124. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4125. return -1;
  4126. } else if (strlen(atcmd_player_name) > 23) {
  4127. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4128. return -1;
  4129. } else {
  4130. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4131. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4132. }
  4133. return 0;
  4134. }
  4135. /*==========================================
  4136. * charunblock command (usage: charunblock <player_name>)
  4137. *------------------------------------------
  4138. */
  4139. int atcommand_char_unblock(
  4140. const int fd, struct map_session_data* sd,
  4141. const char* command, const char* message)
  4142. {
  4143. nullpo_retr(-1, sd);
  4144. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4145. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4146. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4147. return -1;
  4148. }
  4149. // check player name
  4150. if (strlen(atcmd_player_name) < 4) {
  4151. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4152. return -1;
  4153. } else if (strlen(atcmd_player_name) > 23) {
  4154. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4155. return -1;
  4156. } else {
  4157. // send answer to login server via char-server
  4158. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4159. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4160. }
  4161. return 0;
  4162. }
  4163. /*==========================================
  4164. * charunban command (usage: charunban <player_name>)
  4165. *------------------------------------------
  4166. */
  4167. int atcommand_char_unban(
  4168. const int fd, struct map_session_data* sd,
  4169. const char* command, const char* message)
  4170. {
  4171. nullpo_retr(-1, sd);
  4172. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4173. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4174. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4175. return -1;
  4176. }
  4177. // check player name
  4178. if (strlen(atcmd_player_name) < 4) {
  4179. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4180. return -1;
  4181. } else if (strlen(atcmd_player_name) > 23) {
  4182. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4183. return -1;
  4184. } else {
  4185. // send answer to login server via char-server
  4186. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4187. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4188. }
  4189. return 0;
  4190. }
  4191. /*==========================================
  4192. *
  4193. *------------------------------------------
  4194. */
  4195. int atcommand_night(
  4196. const int fd, struct map_session_data* sd,
  4197. const char* command, const char* message)
  4198. {
  4199. nullpo_retr(-1, sd);
  4200. if (night_flag != 1) {
  4201. map_night_timer(night_timer_tid, 0, 0, 1);
  4202. } else {
  4203. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4204. return -1;
  4205. }
  4206. return 0;
  4207. }
  4208. /*==========================================
  4209. *
  4210. *------------------------------------------
  4211. */
  4212. int atcommand_day(
  4213. const int fd, struct map_session_data* sd,
  4214. const char* command, const char* message)
  4215. {
  4216. nullpo_retr(-1, sd);
  4217. if (night_flag != 0) {
  4218. map_day_timer(day_timer_tid, 0, 0, 1);
  4219. } else {
  4220. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4221. return -1;
  4222. }
  4223. return 0;
  4224. }
  4225. /*==========================================
  4226. *
  4227. *------------------------------------------
  4228. */
  4229. int atcommand_doom(
  4230. const int fd, struct map_session_data* sd,
  4231. const char* command, const char* message)
  4232. {
  4233. struct map_session_data *pl_sd, **pl_allsd;
  4234. int i, users;
  4235. nullpo_retr(-1, sd);
  4236. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4237. pl_allsd = map_getallusers(&users);
  4238. for(i = 0; i < users; i++) {
  4239. 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
  4240. status_kill(&pl_sd->bl);
  4241. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4242. }
  4243. }
  4244. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4245. return 0;
  4246. }
  4247. /*==========================================
  4248. *
  4249. *------------------------------------------
  4250. */
  4251. int atcommand_doommap(
  4252. const int fd, struct map_session_data* sd,
  4253. const char* command, const char* message)
  4254. {
  4255. struct map_session_data *pl_sd, **pl_allsd;
  4256. int i, users;
  4257. nullpo_retr(-1, sd);
  4258. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4259. pl_allsd = map_getallusers(&users);
  4260. for (i = 0; i < users; i++) {
  4261. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4262. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4263. {
  4264. status_kill(&pl_sd->bl);
  4265. // clif_specialeffect(&pl_sd->bl,450,1);
  4266. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4267. }
  4268. }
  4269. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4270. return 0;
  4271. }
  4272. /*==========================================
  4273. *
  4274. *------------------------------------------
  4275. */
  4276. static void atcommand_raise_sub(struct map_session_data* sd)
  4277. {
  4278. if (!sd->state.auth || !status_isdead(&sd->bl))
  4279. return;
  4280. if(!status_revive(&sd->bl, 100, 100))
  4281. return;
  4282. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4283. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4284. }
  4285. /*==========================================
  4286. *
  4287. *------------------------------------------
  4288. */
  4289. int atcommand_raise(
  4290. const int fd, struct map_session_data* sd,
  4291. const char* command, const char* message)
  4292. {
  4293. int i, users;
  4294. struct map_session_data **all_sd;
  4295. nullpo_retr(-1, sd);
  4296. all_sd = map_getallusers(&users);
  4297. for (i = 0; i < users; i++) {
  4298. atcommand_raise_sub(all_sd[i]);
  4299. }
  4300. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4301. return 0;
  4302. }
  4303. /*==========================================
  4304. *
  4305. *------------------------------------------
  4306. */
  4307. int atcommand_raisemap(
  4308. const int fd, struct map_session_data* sd,
  4309. const char* command, const char* message)
  4310. {
  4311. struct map_session_data **pl_allsd;
  4312. int i, users;
  4313. nullpo_retr(-1, sd);
  4314. pl_allsd = map_getallusers(&users);
  4315. for (i = 0; i < users; i++) {
  4316. if (sd->bl.m == pl_allsd[i]->bl.m)
  4317. atcommand_raise_sub(pl_allsd[i]);
  4318. }
  4319. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4320. return 0;
  4321. }
  4322. /*==========================================
  4323. *
  4324. *------------------------------------------
  4325. */
  4326. int atcommand_kick(
  4327. const int fd, struct map_session_data* sd,
  4328. const char* command, const char* message)
  4329. {
  4330. struct map_session_data *pl_sd;
  4331. nullpo_retr(-1, sd);
  4332. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4333. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4334. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4335. return -1;
  4336. }
  4337. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4338. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4339. clif_GM_kick(sd, pl_sd, 1);
  4340. else {
  4341. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4342. return -1;
  4343. }
  4344. } else {
  4345. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4346. return -1;
  4347. }
  4348. return 0;
  4349. }
  4350. /*==========================================
  4351. *
  4352. *------------------------------------------
  4353. */
  4354. int atcommand_kickall(
  4355. const int fd, struct map_session_data* sd,
  4356. const char* command, const char* message)
  4357. {
  4358. struct map_session_data *pl_sd, **pl_allsd;
  4359. int i, users;
  4360. nullpo_retr(-1, sd);
  4361. pl_allsd = map_getallusers(&users);
  4362. for (i = 0; i < users; i++) {
  4363. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4364. if (sd->status.account_id != pl_sd->status.account_id)
  4365. clif_GM_kick(sd, pl_sd, 0);
  4366. }
  4367. }
  4368. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4369. return 0;
  4370. }
  4371. /*==========================================
  4372. *
  4373. *------------------------------------------
  4374. */
  4375. int atcommand_allskill(
  4376. const int fd, struct map_session_data* sd,
  4377. const char* command, const char* message)
  4378. {
  4379. nullpo_retr(-1, sd);
  4380. pc_allskillup(sd); // all skills
  4381. sd->status.skill_point = 0; // 0 skill points
  4382. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4383. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4384. return 0;
  4385. }
  4386. /*==========================================
  4387. *
  4388. *------------------------------------------
  4389. */
  4390. int atcommand_questskill(
  4391. const int fd, struct map_session_data* sd,
  4392. const char* command, const char* message)
  4393. {
  4394. int skill_id;
  4395. nullpo_retr(-1, sd);
  4396. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4397. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4398. return -1;
  4399. }
  4400. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4401. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4402. if (pc_checkskill(sd, skill_id) == 0) {
  4403. pc_skill(sd, skill_id, 1, 0);
  4404. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4405. } else {
  4406. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4407. return -1;
  4408. }
  4409. } else {
  4410. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4411. return -1;
  4412. }
  4413. } else {
  4414. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4415. return -1;
  4416. }
  4417. return 0;
  4418. }
  4419. /*==========================================
  4420. *
  4421. *------------------------------------------
  4422. */
  4423. int atcommand_lostskill(
  4424. const int fd, struct map_session_data* sd,
  4425. const char* command, const char* message)
  4426. {
  4427. int skill_id;
  4428. nullpo_retr(-1, sd);
  4429. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4430. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4431. return -1;
  4432. }
  4433. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4434. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4435. if (pc_checkskill(sd, skill_id) > 0) {
  4436. sd->status.skill[skill_id].lv = 0;
  4437. sd->status.skill[skill_id].flag = 0;
  4438. clif_skillinfoblock(sd);
  4439. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4440. } else {
  4441. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4442. return -1;
  4443. }
  4444. } else {
  4445. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4446. return -1;
  4447. }
  4448. } else {
  4449. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4450. return -1;
  4451. }
  4452. return 0;
  4453. }
  4454. /*==========================================
  4455. *
  4456. *------------------------------------------
  4457. */
  4458. int atcommand_spiritball(
  4459. const int fd, struct map_session_data* sd,
  4460. const char* command, const char* message)
  4461. {
  4462. int number;
  4463. nullpo_retr(-1, sd);
  4464. if (!message || !*message || (number = atoi(message)) < 0) {
  4465. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4466. return -1;
  4467. }
  4468. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4469. if (number > 500)
  4470. number = 500;
  4471. if (number >= 0 && number <= 0x7FFF) {
  4472. if (sd->spiritball != number || number > 499) {
  4473. if (sd->spiritball > 0)
  4474. pc_delspiritball(sd, sd->spiritball, 1);
  4475. sd->spiritball = number;
  4476. clif_spiritball(sd);
  4477. // no message, player can look the difference
  4478. if (number > 1000)
  4479. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4480. } else {
  4481. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4482. return -1;
  4483. }
  4484. } else {
  4485. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4486. return -1;
  4487. }
  4488. return 0;
  4489. }
  4490. /*==========================================
  4491. *
  4492. *------------------------------------------
  4493. */
  4494. int atcommand_party(
  4495. const int fd, struct map_session_data* sd,
  4496. const char* command, const char* message)
  4497. {
  4498. char party[NAME_LENGTH];
  4499. nullpo_retr(-1, sd);
  4500. memset(party, '\0', sizeof(party));
  4501. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4502. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4503. return -1;
  4504. }
  4505. party_create(sd, party, 0, 0);
  4506. return 0;
  4507. }
  4508. /*==========================================
  4509. *
  4510. *------------------------------------------
  4511. */
  4512. int atcommand_guild(
  4513. const int fd, struct map_session_data* sd,
  4514. const char* command, const char* message)
  4515. {
  4516. char guild[NAME_LENGTH];
  4517. int prev;
  4518. nullpo_retr(-1, sd);
  4519. memset(guild, '\0', sizeof(guild));
  4520. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4521. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4522. return -1;
  4523. }
  4524. prev = battle_config.guild_emperium_check;
  4525. battle_config.guild_emperium_check = 0;
  4526. guild_create(sd, guild);
  4527. battle_config.guild_emperium_check = prev;
  4528. return 0;
  4529. }
  4530. /*==========================================
  4531. *
  4532. *------------------------------------------
  4533. */
  4534. int atcommand_agitstart(
  4535. const int fd, struct map_session_data* sd,
  4536. const char* command, const char* message)
  4537. {
  4538. nullpo_retr(-1, sd);
  4539. if (agit_flag == 1) {
  4540. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4541. return -1;
  4542. }
  4543. agit_flag = 1;
  4544. guild_agit_start();
  4545. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4546. return 0;
  4547. }
  4548. /*==========================================
  4549. *
  4550. *------------------------------------------
  4551. */
  4552. int atcommand_agitend(
  4553. const int fd, struct map_session_data* sd,
  4554. const char* command, const char* message)
  4555. {
  4556. nullpo_retr(-1, sd);
  4557. if (agit_flag == 0) {
  4558. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4559. return -1;
  4560. }
  4561. agit_flag = 0;
  4562. guild_agit_end();
  4563. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4564. return 0;
  4565. }
  4566. /*==========================================
  4567. * @mapexitでマップサーバーを終了させる
  4568. *------------------------------------------
  4569. */
  4570. int atcommand_mapexit(
  4571. const int fd, struct map_session_data* sd,
  4572. const char* command, const char* message)
  4573. {
  4574. struct map_session_data *pl_sd, **pl_allsd;
  4575. int i, users;
  4576. nullpo_retr(-1, sd);
  4577. pl_allsd = map_getallusers(&users);
  4578. for (i = 0; i < users; i++) {
  4579. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4580. clif_GM_kick(sd, pl_sd, 0);
  4581. }
  4582. clif_GM_kick(sd, sd, 0);
  4583. flush_fifos();
  4584. runflag = 0;
  4585. return 0;
  4586. }
  4587. /*==========================================
  4588. * idsearch <part_of_name>: revrited by [Yor]
  4589. *------------------------------------------
  4590. */
  4591. int atcommand_idsearch(
  4592. const int fd, struct map_session_data* sd,
  4593. const char* command, const char* message)
  4594. {
  4595. char item_name[100];
  4596. unsigned int i, match;
  4597. struct item_data *item_array[MAX_SEARCH];
  4598. nullpo_retr(-1, sd);
  4599. memset(item_name, '\0', sizeof(item_name));
  4600. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4601. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4602. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4603. return -1;
  4604. }
  4605. sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4606. clif_displaymessage(fd, atcmd_output);
  4607. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4608. if (match > MAX_SEARCH) {
  4609. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, match);
  4610. clif_displaymessage(fd, atcmd_output);
  4611. match = MAX_SEARCH;
  4612. }
  4613. for(i = 0; i < match; i++) {
  4614. sprintf(atcmd_output, msg_table[78], item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4615. clif_displaymessage(fd, atcmd_output);
  4616. }
  4617. sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
  4618. clif_displaymessage(fd, atcmd_output);
  4619. return 0;
  4620. }
  4621. /*==========================================
  4622. * Recall All Characters Online To Your Location
  4623. *------------------------------------------
  4624. */
  4625. int atcommand_recallall(
  4626. const int fd, struct map_session_data* sd,
  4627. const char* command, const char* message)
  4628. {
  4629. struct map_session_data *pl_sd, **pl_allsd;
  4630. int i;
  4631. int count, users;
  4632. nullpo_retr(-1, sd);
  4633. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4634. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4635. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4636. return -1;
  4637. }
  4638. count = 0;
  4639. pl_allsd = map_getallusers(&users);
  4640. for (i = 0; i < users; i++) {
  4641. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4642. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4643. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4644. count++;
  4645. else {
  4646. if (pc_isdead(pl_sd)) { //Wake them up
  4647. pc_setstand(pl_sd);
  4648. pc_setrestartvalue(pl_sd,1);
  4649. }
  4650. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4651. }
  4652. }
  4653. }
  4654. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4655. if (count) {
  4656. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4657. clif_displaymessage(fd, atcmd_output);
  4658. }
  4659. return 0;
  4660. }
  4661. /*==========================================
  4662. * Recall online characters of a guild to your location
  4663. *------------------------------------------
  4664. */
  4665. int atcommand_guildrecall(
  4666. const int fd, struct map_session_data* sd,
  4667. const char* command, const char* message)
  4668. {
  4669. struct map_session_data *pl_sd, **pl_allsd;
  4670. int i, users, count;
  4671. char guild_name[NAME_LENGTH];
  4672. struct guild *g;
  4673. nullpo_retr(-1, sd);
  4674. memset(guild_name, '\0', sizeof(guild_name));
  4675. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4676. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4677. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4678. return -1;
  4679. }
  4680. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4681. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4682. return -1;
  4683. }
  4684. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4685. (g = guild_search(atoi(message))) != NULL) {
  4686. count = 0;
  4687. pl_allsd = map_getallusers(&users);
  4688. for (i = 0; i < users; i++) {
  4689. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4690. pl_sd->status.guild_id == g->guild_id) {
  4691. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4692. continue; //Skip GMs greater than you.
  4693. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4694. count++;
  4695. else
  4696. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4697. }
  4698. }
  4699. sprintf(atcmd_output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4700. clif_displaymessage(fd, atcmd_output);
  4701. if (count) {
  4702. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4703. clif_displaymessage(fd, atcmd_output);
  4704. }
  4705. } else {
  4706. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4707. return -1;
  4708. }
  4709. return 0;
  4710. }
  4711. /*==========================================
  4712. * Recall online characters of a party to your location
  4713. *------------------------------------------
  4714. */
  4715. int atcommand_partyrecall(
  4716. const int fd, struct map_session_data* sd,
  4717. const char* command, const char* message)
  4718. {
  4719. int i;
  4720. struct map_session_data *pl_sd, **pl_allsd;
  4721. char party_name[NAME_LENGTH];
  4722. struct party *p;
  4723. int count, users;
  4724. nullpo_retr(-1, sd);
  4725. memset(party_name, '\0', sizeof(party_name));
  4726. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4727. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4728. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4729. return -1;
  4730. }
  4731. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4732. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4733. return -1;
  4734. }
  4735. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4736. (p = party_search(atoi(message))) != NULL) {
  4737. count = 0;
  4738. pl_allsd = map_getallusers(&users);
  4739. for (i = 0; i < users; i++) {
  4740. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4741. pl_sd->status.party_id == p->party_id) {
  4742. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4743. continue; //Skip GMs greater than you.
  4744. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4745. count++;
  4746. else
  4747. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4748. }
  4749. }
  4750. sprintf(atcmd_output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4751. clif_displaymessage(fd, atcmd_output);
  4752. if (count) {
  4753. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4754. clif_displaymessage(fd, atcmd_output);
  4755. }
  4756. } else {
  4757. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4758. return -1;
  4759. }
  4760. return 0;
  4761. }
  4762. /*==========================================
  4763. *
  4764. *------------------------------------------
  4765. */
  4766. int atcommand_reloaditemdb(
  4767. const int fd, struct map_session_data* sd,
  4768. const char* command, const char* message)
  4769. {
  4770. nullpo_retr(-1, sd);
  4771. itemdb_reload();
  4772. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4773. return 0;
  4774. }
  4775. /*==========================================
  4776. *
  4777. *------------------------------------------
  4778. */
  4779. int atcommand_reloadmobdb(
  4780. const int fd, struct map_session_data* sd,
  4781. const char* command, const char* message)
  4782. {
  4783. nullpo_retr(-1, sd);
  4784. mob_reload();
  4785. do_final_pet();
  4786. read_petdb();
  4787. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4788. return 0;
  4789. }
  4790. /*==========================================
  4791. *
  4792. *------------------------------------------
  4793. */
  4794. int atcommand_reloadskilldb(
  4795. const int fd, struct map_session_data* sd,
  4796. const char* command, const char* message)
  4797. {
  4798. nullpo_retr(-1, sd);
  4799. skill_reload();
  4800. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4801. return 0;
  4802. }
  4803. /*==========================================
  4804. * @reloadatcommand
  4805. * atcommand_athena.conf のリロード
  4806. *------------------------------------------
  4807. */
  4808. int
  4809. atcommand_reloadatcommand(
  4810. const int fd, struct map_session_data* sd,
  4811. const char* command, const char* message)
  4812. {
  4813. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4814. clif_displaymessage(fd, msg_table[254]);
  4815. return 0;
  4816. }
  4817. /*==========================================
  4818. * @reloadbattleconf
  4819. * battle_athena.conf のリロード
  4820. *------------------------------------------
  4821. */
  4822. int
  4823. atcommand_reloadbattleconf(
  4824. const int fd, struct map_session_data* sd,
  4825. const char* command, const char* message)
  4826. {
  4827. battle_config_read(BATTLE_CONF_FILENAME);
  4828. mob_reload(); //Needed as well so rate changes take effect.
  4829. clif_displaymessage(fd, msg_table[255]);
  4830. return 0;
  4831. }
  4832. /*==========================================
  4833. * @reloadstatusdb
  4834. * job_db1.txt job_db2.txt job_db2-2.txt
  4835. * refine_db.txt size_fix.txt
  4836. * のリロード
  4837. *------------------------------------------
  4838. */
  4839. int
  4840. atcommand_reloadstatusdb(
  4841. const int fd, struct map_session_data* sd,
  4842. const char* command, const char* message)
  4843. {
  4844. status_readdb();
  4845. clif_displaymessage(fd, msg_table[256]);
  4846. return 0;
  4847. }
  4848. /*==========================================
  4849. * @reloadpcdb
  4850. * exp.txt skill_tree.txt attr_fix.txt
  4851. * のリロード
  4852. *------------------------------------------
  4853. */
  4854. int
  4855. atcommand_reloadpcdb(
  4856. const int fd, struct map_session_data* sd,
  4857. const char* command, const char* message)
  4858. {
  4859. pc_readdb();
  4860. clif_displaymessage(fd, msg_table[257]);
  4861. return 0;
  4862. }
  4863. /*==========================================
  4864. * @reloadmotd [Valaris]
  4865. * Reloads motd.txt
  4866. *------------------------------------------
  4867. */
  4868. int
  4869. atcommand_reloadmotd(
  4870. const int fd, struct map_session_data* sd,
  4871. const char* command, const char* message)
  4872. {
  4873. pc_read_motd();
  4874. clif_displaymessage(fd, msg_table[268]);
  4875. return 0;
  4876. }
  4877. /*==========================================
  4878. *
  4879. *------------------------------------------
  4880. */
  4881. int atcommand_reloadscript(
  4882. const int fd, struct map_session_data* sd,
  4883. const char* command, const char* message)
  4884. {
  4885. nullpo_retr(-1, sd);
  4886. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4887. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4888. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4889. flush_fifos();
  4890. //do_init_npc();
  4891. script_reload();
  4892. npc_reload();
  4893. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4894. return 0;
  4895. }
  4896. /*==========================================
  4897. *
  4898. *------------------------------------------
  4899. */
  4900. int atcommand_reloadgmdb( // by [Yor]
  4901. const int fd, struct map_session_data* sd,
  4902. const char* command, const char* message)
  4903. {
  4904. nullpo_retr(-1, sd);
  4905. chrif_reloadGMdb();
  4906. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4907. return 0;
  4908. }
  4909. /*==========================================
  4910. * @mapinfo <map name> [0-3] by MC_Cameri
  4911. * => Shows information about the map [map name]
  4912. * 0 = no additional information
  4913. * 1 = Show users in that map and their location
  4914. * 2 = Shows NPCs in that map
  4915. * 3 = Shows the shops/chats in that map (not implemented)
  4916. *------------------------------------------
  4917. */
  4918. int atcommand_mapinfo(
  4919. const int fd, struct map_session_data* sd,
  4920. const char* command, const char* message)
  4921. {
  4922. struct map_session_data *pl_sd, **pl_allsd;
  4923. struct npc_data *nd = NULL;
  4924. struct chat_data *cd = NULL;
  4925. char direction[12];
  4926. int m_id, i, chat_num, users, list = 0;
  4927. unsigned short m_index;
  4928. nullpo_retr(-1, sd);
  4929. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4930. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4931. memset(direction, '\0', sizeof(direction));
  4932. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4933. if (list < 0 || list > 3) {
  4934. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4935. return -1;
  4936. }
  4937. if (atcmd_player_name[0] == '\0') {
  4938. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4939. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4940. m_id = map_mapindex2mapid(sd->mapindex);
  4941. } else {
  4942. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4943. strcat(atcmd_player_name, ".gat");
  4944. m_id = map_mapname2mapid(atcmd_player_name);
  4945. }
  4946. if (m_id < 0) {
  4947. clif_displaymessage(fd, msg_table[1]); // Map not found.
  4948. return -1;
  4949. }
  4950. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4951. clif_displaymessage(fd, "------ Map Info ------");
  4952. chat_num = 0;
  4953. pl_allsd = map_getallusers(&users);
  4954. for (i = 0; i < users; i++) {
  4955. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4956. chat_num++;
  4957. }
  4958. }
  4959. 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);
  4960. clif_displaymessage(fd, atcmd_output);
  4961. if (map[m_id].flag.alias)
  4962. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4963. clif_displaymessage(fd, "------ Map Flags ------");
  4964. strcpy(atcmd_output,"PvP Flags: ");
  4965. if (map[m_id].flag.pvp)
  4966. strcat(atcmd_output, "Pvp ON | ");
  4967. if (map[m_id].flag.pvp_noguild)
  4968. strcat(atcmd_output, "NoGuild | ");
  4969. if (map[m_id].flag.pvp_noparty)
  4970. strcat(atcmd_output, "NoParty | ");
  4971. if (map[m_id].flag.pvp_nightmaredrop)
  4972. strcat(atcmd_output, "NightmareDrop | ");
  4973. if (map[m_id].flag.pvp_nocalcrank)
  4974. strcat(atcmd_output, "NoCalcRank | ");
  4975. clif_displaymessage(fd, atcmd_output);
  4976. strcpy(atcmd_output,"GvG Flags: ");
  4977. if (map[m_id].flag.gvg)
  4978. strcat(atcmd_output, "GvG ON | ");
  4979. if (map[m_id].flag.gvg_dungeon)
  4980. strcat(atcmd_output, "GvG Dungeon | ");
  4981. if (map[m_id].flag.gvg_castle)
  4982. strcat(atcmd_output, "GvG Castle | ");
  4983. if (map[m_id].flag.gvg_noparty)
  4984. strcat(atcmd_output, "NoParty | ");
  4985. clif_displaymessage(fd, atcmd_output);
  4986. strcpy(atcmd_output,"Teleport Flags: ");
  4987. if (map[m_id].flag.noteleport)
  4988. strcat(atcmd_output, "NoTeleport | ");
  4989. if (map[m_id].flag.monster_noteleport)
  4990. strcat(atcmd_output, "Monster NoTeleport | ");
  4991. if (map[m_id].flag.nowarp)
  4992. strcat(atcmd_output, "NoWarp | ");
  4993. if (map[m_id].flag.nowarpto)
  4994. strcat(atcmd_output, "NoWarpTo | ");
  4995. if (map[m_id].flag.noreturn)
  4996. strcat(atcmd_output, "NoReturn | ");
  4997. if (map[m_id].flag.nogo)
  4998. strcat(atcmd_output, "NoGo | ");
  4999. if (map[m_id].flag.nomemo)
  5000. strcat(atcmd_output, "NoMemo | ");
  5001. clif_displaymessage(fd, atcmd_output);
  5002. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  5003. clif_displaymessage(fd, atcmd_output);
  5004. if (map[m_id].flag.nosave) {
  5005. if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  5006. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  5007. else
  5008. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  5009. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  5010. clif_displaymessage(fd, atcmd_output);
  5011. }
  5012. strcpy(atcmd_output,"Weather Flags: ");
  5013. if (map[m_id].flag.snow)
  5014. strcat(atcmd_output, "Snow | ");
  5015. if (map[m_id].flag.fog)
  5016. strcat(atcmd_output, "Fog | ");
  5017. if (map[m_id].flag.sakura)
  5018. strcat(atcmd_output, "Sakura | ");
  5019. if (map[m_id].flag.clouds)
  5020. strcat(atcmd_output, "Clouds | ");
  5021. if (map[m_id].flag.clouds2)
  5022. strcat(atcmd_output, "Clouds2 | ");
  5023. if (map[m_id].flag.fireworks)
  5024. strcat(atcmd_output, "Fireworks | ");
  5025. if (map[m_id].flag.leaves)
  5026. strcat(atcmd_output, "Leaves | ");
  5027. if (map[m_id].flag.rain)
  5028. strcat(atcmd_output, "Rain | ");
  5029. if (map[m_id].flag.indoors)
  5030. strcat(atcmd_output, "Indoors | ");
  5031. if (map[m_id].flag.nightenabled)
  5032. strcat(atcmd_output, "Displays Night | ");
  5033. clif_displaymessage(fd, atcmd_output);
  5034. strcpy(atcmd_output,"Other Flags: ");
  5035. if (map[m_id].flag.nobranch)
  5036. strcat(atcmd_output, "NoBranch | ");
  5037. if (map[m_id].flag.notrade)
  5038. strcat(atcmd_output, "NoTrade | ");
  5039. if (map[m_id].flag.novending)
  5040. strcat(atcmd_output, "NoVending | ");
  5041. if (map[m_id].flag.nodrop)
  5042. strcat(atcmd_output, "NoDrop | ");
  5043. if (map[m_id].flag.noskill)
  5044. strcat(atcmd_output, "NoSkill | ");
  5045. if (map[m_id].flag.noicewall)
  5046. strcat(atcmd_output, "NoIcewall | ");
  5047. clif_displaymessage(fd, atcmd_output);
  5048. strcpy(atcmd_output,"Other Flags: ");
  5049. if (map[m_id].flag.nocommand)
  5050. strcat(atcmd_output, "NoCommand | ");
  5051. if (map[m_id].flag.nobaseexp)
  5052. strcat(atcmd_output, "NoBaseEXP | ");
  5053. if (map[m_id].flag.nojobexp)
  5054. strcat(atcmd_output, "NoJobEXP | ");
  5055. if (map[m_id].flag.nomobloot)
  5056. strcat(atcmd_output, "NoMobLoot | ");
  5057. if (map[m_id].flag.nomvploot)
  5058. strcat(atcmd_output, "NoMVPLoot | ");
  5059. clif_displaymessage(fd, atcmd_output);
  5060. switch (list) {
  5061. case 0:
  5062. // Do nothing. It's list 0, no additional display.
  5063. break;
  5064. case 1:
  5065. clif_displaymessage(fd, "----- Players in Map -----");
  5066. for (i = 0; i < users; i++) {
  5067. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5068. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5069. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5070. clif_displaymessage(fd, atcmd_output);
  5071. }
  5072. }
  5073. break;
  5074. case 2:
  5075. clif_displaymessage(fd, "----- NPCs in Map -----");
  5076. for (i = 0; i < map[m_id].npc_num;) {
  5077. nd = map[m_id].npc[i];
  5078. switch(nd->ud.dir) {
  5079. case 0: strcpy(direction, "North"); break;
  5080. case 1: strcpy(direction, "North West"); break;
  5081. case 2: strcpy(direction, "West"); break;
  5082. case 3: strcpy(direction, "South West"); break;
  5083. case 4: strcpy(direction, "South"); break;
  5084. case 5: strcpy(direction, "South East"); break;
  5085. case 6: strcpy(direction, "East"); break;
  5086. case 7: strcpy(direction, "North East"); break;
  5087. case 9: strcpy(direction, "North"); break;
  5088. default: strcpy(direction, "Unknown"); break;
  5089. }
  5090. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5091. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5092. clif_displaymessage(fd, atcmd_output);
  5093. }
  5094. break;
  5095. case 3:
  5096. clif_displaymessage(fd, "----- Chats in Map -----");
  5097. for (i = 0; i < users; i++) {
  5098. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5099. pl_sd->mapindex == m_index &&
  5100. cd->usersd[0] == pl_sd) {
  5101. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5102. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5103. clif_displaymessage(fd, atcmd_output);
  5104. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5105. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5106. clif_displaymessage(fd, atcmd_output);
  5107. }
  5108. }
  5109. break;
  5110. default: // normally impossible to arrive here
  5111. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5112. return -1;
  5113. break;
  5114. }
  5115. return 0;
  5116. }
  5117. /*==========================================
  5118. *
  5119. *------------------------------------------
  5120. */
  5121. int atcommand_mount_peco(
  5122. const int fd, struct map_session_data* sd,
  5123. const char* command, const char* message)
  5124. {
  5125. nullpo_retr(-1, sd);
  5126. if (!pc_isriding(sd)) { // if actually no peco
  5127. if (pc_checkskill(sd, KN_RIDING)) {
  5128. pc_setoption(sd, sd->sc.option | 0x0020);
  5129. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5130. } else {
  5131. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5132. return -1;
  5133. }
  5134. } else { //Dismount
  5135. pc_setoption(sd, sd->sc.option & ~0x0020);
  5136. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5137. }
  5138. return 0;
  5139. }
  5140. /*==========================================
  5141. *
  5142. *------------------------------------------
  5143. */
  5144. int atcommand_char_mount_peco(
  5145. const int fd, struct map_session_data* sd,
  5146. const char* command, const char* message)
  5147. {
  5148. struct map_session_data *pl_sd;
  5149. nullpo_retr(-1, sd);
  5150. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5151. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5152. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5153. return -1;
  5154. }
  5155. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5156. if (!pc_isriding(pl_sd)) { // if actually no peco
  5157. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5158. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5159. clif_displaymessage(fd, msg_table[216]); // Mounted Peco.
  5160. } else {
  5161. clif_displaymessage(fd, msg_table[217]); // You can not mount a peco with your job.
  5162. return -1;
  5163. }
  5164. } else { //Dismount
  5165. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5166. clif_displaymessage(fd, msg_table[218]); // Unmounted Peco.
  5167. }
  5168. } else {
  5169. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5170. return -1;
  5171. }
  5172. return 0;
  5173. }
  5174. /*==========================================
  5175. *Spy Commands by Syrus22
  5176. *------------------------------------------
  5177. */
  5178. int atcommand_guildspy(
  5179. const int fd, struct map_session_data* sd,
  5180. const char* command, const char* message)
  5181. {
  5182. char guild_name[NAME_LENGTH];
  5183. struct guild *g;
  5184. nullpo_retr(-1, sd);
  5185. memset(guild_name, '\0', sizeof(guild_name));
  5186. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5187. if (!enable_spy)
  5188. {
  5189. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5190. return -1;
  5191. }
  5192. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5193. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5194. return -1;
  5195. }
  5196. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5197. (g = guild_search(atoi(message))) != NULL) {
  5198. if (sd->guildspy == g->guild_id) {
  5199. sd->guildspy = 0;
  5200. sprintf(atcmd_output, msg_table[103], g->name); // No longer spying on the %s guild.
  5201. clif_displaymessage(fd, atcmd_output);
  5202. } else {
  5203. sd->guildspy = g->guild_id;
  5204. sprintf(atcmd_output, msg_table[104], g->name); // Spying on the %s guild.
  5205. clif_displaymessage(fd, atcmd_output);
  5206. }
  5207. } else {
  5208. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5209. return -1;
  5210. }
  5211. return 0;
  5212. }
  5213. /*==========================================
  5214. *
  5215. *------------------------------------------
  5216. */
  5217. int atcommand_partyspy(
  5218. const int fd, struct map_session_data* sd,
  5219. const char* command, const char* message)
  5220. {
  5221. char party_name[NAME_LENGTH];
  5222. struct party *p;
  5223. nullpo_retr(-1, sd);
  5224. memset(party_name, '\0', sizeof(party_name));
  5225. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5226. if (!enable_spy)
  5227. {
  5228. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5229. return -1;
  5230. }
  5231. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5232. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5233. return -1;
  5234. }
  5235. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5236. (p = party_search(atoi(message))) != NULL) {
  5237. if (sd->partyspy == p->party_id) {
  5238. sd->partyspy = 0;
  5239. sprintf(atcmd_output, msg_table[105], p->name); // No longer spying on the %s party.
  5240. clif_displaymessage(fd, atcmd_output);
  5241. } else {
  5242. sd->partyspy = p->party_id;
  5243. sprintf(atcmd_output, msg_table[106], p->name); // Spying on the %s party.
  5244. clif_displaymessage(fd, atcmd_output);
  5245. }
  5246. } else {
  5247. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5248. return -1;
  5249. }
  5250. return 0;
  5251. }
  5252. /*==========================================
  5253. * @repairall [Valaris]
  5254. *------------------------------------------
  5255. */
  5256. int atcommand_repairall(
  5257. const int fd, struct map_session_data* sd,
  5258. const char* command, const char* message)
  5259. {
  5260. int count, i;
  5261. nullpo_retr(-1, sd);
  5262. count = 0;
  5263. for (i = 0; i < MAX_INVENTORY; i++) {
  5264. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5265. sd->status.inventory[i].attribute = 0;
  5266. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5267. count++;
  5268. }
  5269. }
  5270. if (count > 0) {
  5271. clif_misceffect(&sd->bl, 3);
  5272. clif_equiplist(sd);
  5273. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5274. } else {
  5275. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5276. return -1;
  5277. }
  5278. return 0;
  5279. }
  5280. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5281. int atcommand_nuke(
  5282. const int fd, struct map_session_data* sd,
  5283. const char* command, const char* message)
  5284. {
  5285. struct map_session_data *pl_sd;
  5286. nullpo_retr(-1, sd);
  5287. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5288. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5289. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5290. return -1;
  5291. }
  5292. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5293. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5294. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5295. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5296. } else {
  5297. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5298. return -1;
  5299. }
  5300. } else {
  5301. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5302. return -1;
  5303. }
  5304. return 0;
  5305. }
  5306. /*==========================================
  5307. * @tonpc
  5308. *------------------------------------------
  5309. */
  5310. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5311. const char* command, const char* message)
  5312. {
  5313. char npcname[NAME_LENGTH];
  5314. struct npc_data *nd;
  5315. nullpo_retr(-1, sd);
  5316. memset(npcname, 0, sizeof(npcname));
  5317. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5318. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5319. return -1;
  5320. }
  5321. if ((nd = npc_name2id(npcname)) != NULL) {
  5322. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5323. clif_displaymessage(fd, msg_table[0]); // Warped.
  5324. else
  5325. return -1;
  5326. } else {
  5327. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5328. return -1;
  5329. }
  5330. return 0;
  5331. }
  5332. /*==========================================
  5333. *
  5334. *------------------------------------------
  5335. */
  5336. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5337. const char* command, const char* message)
  5338. {
  5339. char NPCname[NAME_LENGTH];
  5340. nullpo_retr(-1, sd);
  5341. memset(NPCname, '\0', sizeof(NPCname));
  5342. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5343. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5344. return -1;
  5345. }
  5346. if (npc_name2id(NPCname) != NULL) {
  5347. npc_enable(NPCname, 1);
  5348. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5349. } else {
  5350. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5351. return -1;
  5352. }
  5353. return 0;
  5354. }
  5355. /*==========================================
  5356. *
  5357. *------------------------------------------
  5358. */
  5359. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5360. const char* command, const char* message)
  5361. {
  5362. char NPCname[NAME_LENGTH];
  5363. nullpo_retr(-1, sd);
  5364. memset(NPCname, '\0', sizeof(NPCname));
  5365. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5366. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5367. return -1;
  5368. }
  5369. if (npc_name2id(NPCname) != NULL) {
  5370. npc_enable(NPCname, 0);
  5371. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5372. } else {
  5373. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5374. return -1;
  5375. }
  5376. return 0;
  5377. }
  5378. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5379. const char* command, const char* message)
  5380. {
  5381. FILE *fp;
  5382. if (!message || !*message) {
  5383. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5384. return -1;
  5385. }
  5386. // check if script file exists
  5387. if ((fp = fopen(message, "r")) == NULL) {
  5388. clif_displaymessage(fd, msg_table[261]);
  5389. return -1;
  5390. }
  5391. fclose(fp);
  5392. // add to list of script sources and run it
  5393. npc_addsrcfile((char *)message);
  5394. npc_parsesrcfile((char *)message);
  5395. clif_displaymessage(fd, msg_table[262]);
  5396. return 0;
  5397. }
  5398. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5399. const char* command, const char* message)
  5400. {
  5401. struct npc_data *nd;
  5402. char NPCname[NAME_LENGTH];
  5403. nullpo_retr(-1, sd);
  5404. memset(NPCname, '\0', sizeof(NPCname));
  5405. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5406. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5407. return -1;
  5408. }
  5409. if ((nd = npc_name2id(NPCname)) != NULL) {
  5410. npc_unload(nd);
  5411. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5412. } else {
  5413. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5414. return -1;
  5415. }
  5416. return 0;
  5417. }
  5418. /*==========================================
  5419. * time in txt for time command (by [Yor])
  5420. *------------------------------------------
  5421. */
  5422. char * txt_time(unsigned int duration) {
  5423. int days, hours, minutes, seconds;
  5424. char temp[256];
  5425. static char temp1[256];
  5426. memset(temp, '\0', sizeof(temp));
  5427. memset(temp1, '\0', sizeof(temp1));
  5428. days = duration / (60 * 60 * 24);
  5429. duration = duration - (60 * 60 * 24 * days);
  5430. hours = duration / (60 * 60);
  5431. duration = duration - (60 * 60 * hours);
  5432. minutes = duration / 60;
  5433. seconds = duration - (60 * minutes);
  5434. if (days < 2)
  5435. sprintf(temp, msg_table[219], days); // %d day
  5436. else
  5437. sprintf(temp, msg_table[220], days); // %d days
  5438. if (hours < 2)
  5439. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5440. else
  5441. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5442. if (minutes < 2)
  5443. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5444. else
  5445. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5446. if (seconds < 2)
  5447. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5448. else
  5449. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5450. return temp1;
  5451. }
  5452. /*==========================================
  5453. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5454. * Calculation management of GM modification (@day/@night GM commands) is done
  5455. *------------------------------------------
  5456. */
  5457. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5458. const char* command, const char* message)
  5459. {
  5460. struct TimerData * timer_data;
  5461. struct TimerData * timer_data2;
  5462. time_t time_server; // variable for number of seconds (used with time() function)
  5463. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5464. char temp[256];
  5465. nullpo_retr(-1, sd);
  5466. memset(temp, '\0', sizeof(temp));
  5467. time(&time_server); // get time in seconds since 1/1/1970
  5468. datetime = localtime(&time_server); // convert seconds in structure
  5469. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5470. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5471. clif_displaymessage(fd, temp);
  5472. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5473. if (night_flag == 0)
  5474. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5475. else
  5476. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5477. } else if (battle_config.night_duration == 0)
  5478. if (night_flag == 1) { // we start with night
  5479. timer_data = get_timer(day_timer_tid);
  5480. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5481. clif_displaymessage(fd, temp);
  5482. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5483. } else
  5484. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5485. else if (battle_config.day_duration == 0)
  5486. if (night_flag == 0) { // we start with day
  5487. timer_data = get_timer(night_timer_tid);
  5488. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5489. clif_displaymessage(fd, temp);
  5490. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5491. } else
  5492. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5493. else {
  5494. if (night_flag == 0) {
  5495. timer_data = get_timer(night_timer_tid);
  5496. timer_data2 = get_timer(day_timer_tid);
  5497. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5498. clif_displaymessage(fd, temp);
  5499. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5500. sprintf(temp, msg_table[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.
  5501. else
  5502. sprintf(temp, msg_table[237], txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5503. clif_displaymessage(fd, temp);
  5504. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5505. clif_displaymessage(fd, temp);
  5506. } else {
  5507. timer_data = get_timer(day_timer_tid);
  5508. timer_data2 = get_timer(night_timer_tid);
  5509. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5510. clif_displaymessage(fd, temp);
  5511. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5512. sprintf(temp, msg_table[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.
  5513. else
  5514. sprintf(temp, msg_table[239], txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5515. clif_displaymessage(fd, temp);
  5516. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5517. clif_displaymessage(fd, temp);
  5518. }
  5519. }
  5520. return 0;
  5521. }
  5522. /*==========================================
  5523. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5524. * removes <quantity> item from a character
  5525. * item can be equiped or not.
  5526. * Inspired from a old command created by RoVeRT
  5527. *------------------------------------------
  5528. */
  5529. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5530. const char* command, const char* message)
  5531. {
  5532. struct map_session_data *pl_sd;
  5533. char item_name[100];
  5534. int i, number = 0, item_id, item_position, count;
  5535. struct item_data *item_data;
  5536. nullpo_retr(-1, sd);
  5537. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5538. memset(item_name, '\0', sizeof(item_name));
  5539. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5540. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5541. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5542. return -1;
  5543. }
  5544. item_id = 0;
  5545. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5546. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5547. item_id = item_data->nameid;
  5548. if (item_id > 500) {
  5549. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5550. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5551. item_position = pc_search_inventory(pl_sd, item_id);
  5552. if (item_position >= 0) {
  5553. count = 0;
  5554. for(i = 0; i < number && item_position >= 0; i++) {
  5555. //Logs (A)dmins items [Lupus]
  5556. if(log_config.pick > 0 ) {
  5557. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5558. }
  5559. //Logs
  5560. pc_delitem(pl_sd, item_position, 1, 0);
  5561. count++;
  5562. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5563. }
  5564. sprintf(atcmd_output, msg_table[113], count); // %d item(s) removed by a GM.
  5565. clif_displaymessage(pl_sd->fd, atcmd_output);
  5566. if (number == count)
  5567. sprintf(atcmd_output, msg_table[114], count); // %d item(s) removed from the player.
  5568. else
  5569. sprintf(atcmd_output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5570. clif_displaymessage(fd, atcmd_output);
  5571. } else {
  5572. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5573. return -1;
  5574. }
  5575. } else {
  5576. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5577. return -1;
  5578. }
  5579. } else {
  5580. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5581. return -1;
  5582. }
  5583. } else {
  5584. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5585. return -1;
  5586. }
  5587. return 0;
  5588. }
  5589. /*==========================================
  5590. * @jail <char_name> by [Yor]
  5591. * Special warp! No check with nowarp and nowarpto flag
  5592. *------------------------------------------
  5593. */
  5594. int atcommand_jail(
  5595. const int fd, struct map_session_data* sd,
  5596. const char* command, const char* message)
  5597. {
  5598. struct map_session_data *pl_sd;
  5599. int x, y;
  5600. unsigned short m_index;
  5601. nullpo_retr(-1, sd);
  5602. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5603. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5604. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5605. return -1;
  5606. }
  5607. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5608. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5609. switch(rand() % 2) {
  5610. case 0:
  5611. x = 24;
  5612. y = 75;
  5613. break;
  5614. default:
  5615. x = 49;
  5616. y = 75;
  5617. break;
  5618. }
  5619. m_index = mapindex_name2id(MAP_JAIL);
  5620. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0) {
  5621. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5622. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5623. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5624. } else {
  5625. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5626. return -1;
  5627. }
  5628. } else {
  5629. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5630. return -1;
  5631. }
  5632. } else {
  5633. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5634. return -1;
  5635. }
  5636. return 0;
  5637. }
  5638. /*==========================================
  5639. * @unjail/@discharge <char_name> by [Yor]
  5640. * Special warp! No check with nowarp and nowarpto flag
  5641. *------------------------------------------
  5642. */
  5643. int atcommand_unjail(
  5644. const int fd, struct map_session_data* sd,
  5645. const char* command, const char* message)
  5646. {
  5647. struct map_session_data *pl_sd;
  5648. unsigned short m_index;
  5649. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5650. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5651. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5652. return -1;
  5653. }
  5654. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5655. m_index = mapindex_name2id(MAP_PRONTERA);
  5656. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5657. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5658. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5659. return -1;
  5660. } else if (pc_setpos(pl_sd, m_index, 0, 0, 3) == 0) { //old coords: 156,191
  5661. pc_setsavepoint(pl_sd, m_index, 0, 0); // Save char respawn point in Prontera
  5662. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5663. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5664. } else {
  5665. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5666. return -1;
  5667. }
  5668. } else {
  5669. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5670. return -1;
  5671. }
  5672. } else {
  5673. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5674. return -1;
  5675. }
  5676. return 0;
  5677. }
  5678. /*==========================================
  5679. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5680. *------------------------------------------
  5681. */
  5682. int atcommand_disguise(
  5683. const int fd, struct map_session_data* sd,
  5684. const char* command, const char* message)
  5685. {
  5686. int id = 0;
  5687. nullpo_retr(-1, sd);
  5688. if (!message || !*message) {
  5689. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5690. return -1;
  5691. }
  5692. if ((id = atoi(message)) > 0)
  5693. { //Acquired an ID
  5694. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5695. id = 0; //Invalid id for either mobs or npcs.
  5696. } else { //Acquired a Name
  5697. if ((id = mobdb_searchname(message)) == 0)
  5698. {
  5699. struct npc_data* nd = npc_name2id(message);
  5700. if (nd != NULL)
  5701. id = nd->n;
  5702. }
  5703. }
  5704. if (id == 0)
  5705. { // Monster/NPC name/id hasn't been found.
  5706. clif_displaymessage(fd, msg_table[123]);
  5707. return -1;
  5708. }
  5709. pc_disguise(sd, id);
  5710. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5711. return 0;
  5712. }
  5713. /*==========================================
  5714. * DisguiseAll
  5715. *------------------------------------------
  5716. */
  5717. int atcommand_disguiseall(
  5718. const int fd, struct map_session_data* sd,
  5719. const char* command, const char* message)
  5720. {
  5721. int mob_id=0, i=0, users;
  5722. struct map_session_data *pl_sd, **pl_allsd;
  5723. nullpo_retr(-1, sd);
  5724. if (!message || !*message) {
  5725. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5726. return -1;
  5727. }
  5728. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5729. mob_id = atoi(message);
  5730. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5731. pl_allsd = map_getallusers(&users);
  5732. for(i=0; i < users; i++) {
  5733. if((pl_sd = pl_allsd[i]))
  5734. pc_disguise(pl_sd, mob_id);
  5735. }
  5736. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5737. } else {
  5738. return -1;
  5739. }
  5740. return 0;
  5741. }
  5742. /*==========================================
  5743. * @undisguise by [Yor]
  5744. *------------------------------------------
  5745. */
  5746. int atcommand_undisguise(
  5747. const int fd, struct map_session_data* sd,
  5748. const char* command, const char* message)
  5749. {
  5750. nullpo_retr(-1, sd);
  5751. if (sd->disguise) {
  5752. pc_disguise(sd, 0);
  5753. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5754. } else {
  5755. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5756. return -1;
  5757. }
  5758. return 0;
  5759. }
  5760. /*==========================================
  5761. * UndisguiseAll
  5762. *------------------------------------------
  5763. */
  5764. int atcommand_undisguiseall(
  5765. const int fd, struct map_session_data* sd,
  5766. const char* command, const char* message)
  5767. {
  5768. struct map_session_data *pl_sd, **pl_allsd;
  5769. int i, users;
  5770. nullpo_retr(-1, sd);
  5771. pl_allsd = map_getallusers(&users);
  5772. for(i=0; i < users; i++) {
  5773. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5774. pc_disguise(pl_sd, 0);
  5775. }
  5776. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5777. return 0;
  5778. }
  5779. /*==========================================
  5780. * @exp by [Skotlex]
  5781. *------------------------------------------
  5782. */
  5783. int atcommand_exp(
  5784. const int fd, struct map_session_data* sd,
  5785. const char* command, const char* message)
  5786. {
  5787. char output[200];
  5788. double nextb, nextj;
  5789. nullpo_retr(-1, sd);
  5790. memset(output, '\0', sizeof(output));
  5791. nextb = pc_nextbaseexp(sd);
  5792. if (nextb)
  5793. nextb = sd->status.base_exp*100.0/nextb;
  5794. nextj = pc_nextjobexp(sd);
  5795. if (nextj)
  5796. nextj = sd->status.job_exp*100.0/nextj;
  5797. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5798. clif_displaymessage(fd, output);
  5799. return 0;
  5800. }
  5801. /*==========================================
  5802. * @broadcast by [Valaris]
  5803. *------------------------------------------
  5804. */
  5805. int atcommand_broadcast(
  5806. const int fd, struct map_session_data* sd,
  5807. const char* command, const char* message)
  5808. {
  5809. nullpo_retr(-1, sd);
  5810. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5811. if (!message || !*message) {
  5812. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5813. return -1;
  5814. }
  5815. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5816. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5817. return 0;
  5818. }
  5819. /*==========================================
  5820. * @localbroadcast by [Valaris]
  5821. *------------------------------------------
  5822. */
  5823. int atcommand_localbroadcast(
  5824. const int fd, struct map_session_data* sd,
  5825. const char* command, const char* message)
  5826. {
  5827. nullpo_retr(-1, sd);
  5828. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5829. if (!message || !*message) {
  5830. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5831. return -1;
  5832. }
  5833. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5834. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5835. return 0;
  5836. }
  5837. /*==========================================
  5838. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5839. *------------------------------------------
  5840. */
  5841. int atcommand_chardisguise(
  5842. const int fd, struct map_session_data* sd,
  5843. const char* command, const char* message)
  5844. {
  5845. int mob_id;
  5846. char mob_name[NAME_LENGTH];
  5847. struct map_session_data* pl_sd;
  5848. nullpo_retr(-1, sd);
  5849. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5850. memset(mob_name, '\0', sizeof(mob_name));
  5851. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5852. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5853. return -1;
  5854. }
  5855. if ((mob_id = atoi(mob_name)) > 0)
  5856. { //Acquired an ID
  5857. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5858. mob_id = 0; //Invalid id for either mobs or npcs.
  5859. } else { //Acquired a Name
  5860. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5861. {
  5862. struct npc_data* nd = npc_name2id(mob_name);
  5863. if (nd != NULL)
  5864. mob_id = nd->n;
  5865. }
  5866. }
  5867. if (mob_id == 0)
  5868. {
  5869. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5870. return -1;
  5871. }
  5872. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5873. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5874. pc_disguise(pl_sd, mob_id);
  5875. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5876. } else {
  5877. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5878. return -1;
  5879. }
  5880. } else {
  5881. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5882. return -1;
  5883. }
  5884. return 0;
  5885. }
  5886. /*==========================================
  5887. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5888. *------------------------------------------
  5889. */
  5890. int atcommand_charundisguise(
  5891. const int fd, struct map_session_data* sd,
  5892. const char* command, const char* message)
  5893. {
  5894. struct map_session_data* pl_sd;
  5895. nullpo_retr(-1, sd);
  5896. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5897. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5898. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5899. return -1;
  5900. }
  5901. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5902. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5903. if (pl_sd->disguise)
  5904. pc_disguise(pl_sd, 0);
  5905. else {
  5906. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5907. return -1;
  5908. }
  5909. } else {
  5910. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5911. return -1;
  5912. }
  5913. } else {
  5914. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5915. return -1;
  5916. }
  5917. return 0;
  5918. }
  5919. /*==========================================
  5920. * @email <actual@email> <new@email> by [Yor]
  5921. *------------------------------------------
  5922. */
  5923. int atcommand_email(
  5924. const int fd, struct map_session_data* sd,
  5925. const char* command, const char* message)
  5926. {
  5927. char actual_email[100];
  5928. char new_email[100];
  5929. nullpo_retr(-1, sd);
  5930. memset(actual_email, '\0', sizeof(actual_email));
  5931. memset(new_email, '\0', sizeof(new_email));
  5932. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5933. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5934. return -1;
  5935. }
  5936. if (e_mail_check(actual_email) == 0) {
  5937. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5938. return -1;
  5939. } else if (e_mail_check(new_email) == 0) {
  5940. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5941. return -1;
  5942. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5943. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5944. return -1;
  5945. } else if (strcmpi(actual_email, new_email) == 0) {
  5946. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5947. return -1;
  5948. } else {
  5949. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5950. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5951. }
  5952. return 0;
  5953. }
  5954. /*==========================================
  5955. *@effect
  5956. *------------------------------------------
  5957. */
  5958. int atcommand_effect(
  5959. const int fd, struct map_session_data* sd,
  5960. const char* command, const char* message)
  5961. {
  5962. int type = 0, flag = 0;
  5963. nullpo_retr(-1, sd);
  5964. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5965. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5966. return -1;
  5967. }
  5968. clif_specialeffect(&sd->bl, type, flag);
  5969. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5970. return 0;
  5971. }
  5972. /*==========================================
  5973. * @charcartlist <character>: Displays the items list of a player's cart.
  5974. *------------------------------------------
  5975. */
  5976. int
  5977. atcommand_character_cart_list(
  5978. const int fd, struct map_session_data* sd,
  5979. const char* command, const char* message)
  5980. {
  5981. char outputtmp[200];
  5982. struct map_session_data *pl_sd;
  5983. struct item_data *item_data, *item_temp;
  5984. int i, j, count, counter, counter2;
  5985. nullpo_retr(-1, sd);
  5986. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5987. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5988. memset(outputtmp, '\0', sizeof(outputtmp));
  5989. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5990. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5991. return -1;
  5992. }
  5993. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5994. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5995. counter = 0;
  5996. count = 0;
  5997. for (i = 0; i < MAX_CART; i++) {
  5998. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5999. counter = counter + pl_sd->status.cart[i].amount;
  6000. count++;
  6001. if (count == 1) {
  6002. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6003. clif_displaymessage(fd, atcmd_output);
  6004. }
  6005. if (pl_sd->status.cart[i].refine)
  6006. 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);
  6007. else
  6008. 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);
  6009. clif_displaymessage(fd, atcmd_output);
  6010. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6011. counter2 = 0;
  6012. for (j = 0; j < item_data->slot; j++) {
  6013. if (pl_sd->status.cart[i].card[j]) {
  6014. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6015. if (atcmd_output[0] == '\0')
  6016. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6017. else
  6018. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6019. strcat(atcmd_output, outputtmp);
  6020. }
  6021. }
  6022. }
  6023. if (atcmd_output[0] != '\0') {
  6024. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6025. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6026. clif_displaymessage(fd, atcmd_output);
  6027. }
  6028. }
  6029. }
  6030. if (count == 0)
  6031. clif_displaymessage(fd, "No item found in the cart of this player.");
  6032. else {
  6033. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6034. clif_displaymessage(fd, atcmd_output);
  6035. }
  6036. } else {
  6037. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6038. return -1;
  6039. }
  6040. } else {
  6041. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6042. return -1;
  6043. }
  6044. return 0;
  6045. }
  6046. /*==========================================
  6047. * @killer by MouseJstr
  6048. * enable killing players even when not in pvp
  6049. *------------------------------------------
  6050. */
  6051. int
  6052. atcommand_killer(
  6053. const int fd, struct map_session_data* sd,
  6054. const char* command, const char* message)
  6055. {
  6056. nullpo_retr(-1, sd);
  6057. sd->special_state.killer = !sd->special_state.killer;
  6058. if(sd->special_state.killer)
  6059. clif_displaymessage(fd, msg_table[241]);
  6060. else
  6061. clif_displaymessage(fd, msg_table[242]);
  6062. return 0;
  6063. }
  6064. /*==========================================
  6065. * @killable by MouseJstr
  6066. * enable other people killing you
  6067. *------------------------------------------
  6068. */
  6069. int
  6070. atcommand_killable(
  6071. const int fd, struct map_session_data* sd,
  6072. const char* command, const char* message)
  6073. {
  6074. nullpo_retr(-1, sd);
  6075. sd->special_state.killable = !sd->special_state.killable;
  6076. if(sd->special_state.killable)
  6077. clif_displaymessage(fd, msg_table[242]);
  6078. else
  6079. clif_displaymessage(fd, msg_table[241]);
  6080. return 0;
  6081. }
  6082. /*==========================================
  6083. * @charkillable by MouseJstr
  6084. * enable another player to be killed
  6085. *------------------------------------------
  6086. */
  6087. int
  6088. atcommand_charkillable(
  6089. const int fd, struct map_session_data* sd,
  6090. const char* command, const char* message)
  6091. {
  6092. struct map_session_data *pl_sd = NULL;
  6093. nullpo_retr(-1, sd);
  6094. if (!message || !*message)
  6095. return -1;
  6096. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6097. return -1;
  6098. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6099. if(pl_sd->special_state.killable)
  6100. clif_displaymessage(fd, "The player is now killable");
  6101. else
  6102. clif_displaymessage(fd, "The player is no longer killable");
  6103. return 0;
  6104. }
  6105. /*==========================================
  6106. * @skillon by MouseJstr
  6107. * turn skills on for the map
  6108. *------------------------------------------
  6109. */
  6110. int
  6111. atcommand_skillon(
  6112. const int fd, struct map_session_data* sd,
  6113. 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_table[244]);
  6118. return 0;
  6119. }
  6120. /*==========================================
  6121. * @skilloff by MouseJstr
  6122. * Turn skills off on the map
  6123. *------------------------------------------
  6124. */
  6125. int
  6126. atcommand_skilloff(
  6127. const int fd, struct map_session_data* sd,
  6128. const char* command, const char* message)
  6129. {
  6130. nullpo_retr(-1, sd);
  6131. map[sd->bl.m].flag.noskill = 1;
  6132. clif_displaymessage(fd, msg_table[243]);
  6133. return 0;
  6134. }
  6135. /*==========================================
  6136. * @npcmove by MouseJstr
  6137. *
  6138. * move a npc
  6139. *------------------------------------------
  6140. */
  6141. int
  6142. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6143. const char* command, const char* message)
  6144. {
  6145. int x = 0, y = 0, m;
  6146. struct npc_data *nd = 0;
  6147. nullpo_retr(-1, sd);
  6148. if (!message || !*message)
  6149. return -1;
  6150. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6151. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6152. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6153. return -1;
  6154. }
  6155. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6156. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6157. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6158. return -1;
  6159. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6160. return -1; //Not on a map.
  6161. if (x < 0) x = 0;
  6162. else if (x >= map[m].xs) x = map[m].xs-1;
  6163. if (y < 0) y = 0;
  6164. else if (y >= map[m].ys) y = map[m].ys-1;
  6165. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6166. map_moveblock(&nd->bl, x, y, gettick());
  6167. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6168. return 0;
  6169. }
  6170. /*==========================================
  6171. * @addwarp by MouseJstr
  6172. *
  6173. * Create a new static warp point.
  6174. *------------------------------------------
  6175. */
  6176. int
  6177. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6178. const char* command, const char* message)
  6179. {
  6180. char w1[64], w3[64], w4[64];
  6181. int x,y,ret;
  6182. nullpo_retr(-1, sd);
  6183. if (!message || !*message)
  6184. return -1;
  6185. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6186. return -1;
  6187. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6188. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6189. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6190. ret = npc_parse_warp(w1, "warp", w3, w4);
  6191. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6192. clif_displaymessage(fd, atcmd_output);
  6193. return ret;
  6194. }
  6195. /*==========================================
  6196. * @follow by [MouseJstr]
  6197. *
  6198. * Follow a player .. staying no more then 5 spaces away
  6199. *------------------------------------------
  6200. */
  6201. int
  6202. atcommand_follow(const int fd, struct map_session_data* sd,
  6203. const char* command, const char* message)
  6204. {
  6205. struct map_session_data *pl_sd = NULL;
  6206. nullpo_retr(-1, sd);
  6207. if (!message || !*message) {
  6208. if (sd->followtarget == -1)
  6209. return -1;
  6210. pc_stop_following (sd);
  6211. clif_displaymessage(fd, "Stop following");
  6212. return 0;
  6213. }
  6214. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6215. if (sd->followtarget == pl_sd->bl.id)
  6216. pc_stop_following (sd);
  6217. else
  6218. pc_follow(sd, pl_sd->bl.id);
  6219. return 0;
  6220. }
  6221. return 1;
  6222. }
  6223. /*==========================================
  6224. * @dropall by [MouseJstr]
  6225. *
  6226. * Drop all your possession on the ground
  6227. *------------------------------------------
  6228. */
  6229. int
  6230. atcommand_dropall(const int fd, struct map_session_data* sd,
  6231. const char* command, const char* message)
  6232. {
  6233. int i;
  6234. nullpo_retr(-1, sd);
  6235. for (i = 0; i < MAX_INVENTORY; i++) {
  6236. if (sd->status.inventory[i].amount) {
  6237. if(sd->status.inventory[i].equip != 0)
  6238. pc_unequipitem(sd, i, 3);
  6239. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6240. }
  6241. }
  6242. return 0;
  6243. }
  6244. /*==========================================
  6245. * @chardropall by [MouseJstr]
  6246. *
  6247. * Throw all the characters possessions on the ground. Normally
  6248. * done in response to them being disrespectful of a GM
  6249. *------------------------------------------
  6250. */
  6251. int
  6252. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6253. const char* command, const char* message)
  6254. {
  6255. int i;
  6256. struct map_session_data *pl_sd = NULL;
  6257. nullpo_retr(-1, sd);
  6258. if (!message || !*message)
  6259. return -1;
  6260. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6261. return -1;
  6262. for (i = 0; i < MAX_INVENTORY; i++) {
  6263. if (pl_sd->status.inventory[i].amount) {
  6264. if(pl_sd->status.inventory[i].equip != 0)
  6265. pc_unequipitem(pl_sd, i, 3);
  6266. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6267. }
  6268. }
  6269. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6270. clif_displaymessage(fd, "It is done");
  6271. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6272. return 0;
  6273. }
  6274. /*==========================================
  6275. * @storeall by [MouseJstr]
  6276. *
  6277. * Put everything into storage to simplify your inventory to make
  6278. * debugging easie
  6279. *------------------------------------------
  6280. */
  6281. int
  6282. atcommand_storeall(const int fd, struct map_session_data* sd,
  6283. const char* command, const char* message)
  6284. {
  6285. int i;
  6286. nullpo_retr(-1, sd);
  6287. if (storage_storageopen(sd) == 1) {
  6288. clif_displaymessage(fd, "run this command again..");
  6289. return 0;
  6290. }
  6291. for (i = 0; i < MAX_INVENTORY; i++) {
  6292. if (sd->status.inventory[i].amount) {
  6293. if(sd->status.inventory[i].equip != 0)
  6294. pc_unequipitem(sd, i, 3);
  6295. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6296. }
  6297. }
  6298. storage_storageclose(sd);
  6299. clif_displaymessage(fd, "It is done");
  6300. return 0;
  6301. }
  6302. /*==========================================
  6303. * @charstoreall by [MouseJstr]
  6304. *
  6305. * A way to screw with players who piss you off
  6306. *------------------------------------------
  6307. */
  6308. int
  6309. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6310. const char* command, const char* message)
  6311. {
  6312. int i;
  6313. struct map_session_data *pl_sd = NULL;
  6314. nullpo_retr(-1, sd);
  6315. if (!message || !*message)
  6316. return -1;
  6317. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6318. return -1;
  6319. if (storage_storageopen(pl_sd) == 1) {
  6320. clif_displaymessage(fd, "Had to open the characters storage window...");
  6321. clif_displaymessage(fd, "run this command again..");
  6322. return 0;
  6323. }
  6324. for (i = 0; i < MAX_INVENTORY; i++) {
  6325. if (pl_sd->status.inventory[i].amount) {
  6326. if(pl_sd->status.inventory[i].equip != 0)
  6327. pc_unequipitem(pl_sd, i, 3);
  6328. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6329. }
  6330. }
  6331. storage_storageclose(pl_sd);
  6332. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6333. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6334. clif_displaymessage(pl_sd->fd, " -- the management");
  6335. clif_displaymessage(fd, "It is done");
  6336. return 0;
  6337. }
  6338. /*==========================================
  6339. * @skillid by [MouseJstr]
  6340. *
  6341. * lookup a skill by name
  6342. *------------------------------------------
  6343. */
  6344. int
  6345. atcommand_skillid(const int fd, struct map_session_data* sd,
  6346. const char* command, const char* message)
  6347. {
  6348. int skillen, idx;
  6349. nullpo_retr(-1, sd);
  6350. if (!message || !*message)
  6351. return -1;
  6352. skillen = strlen(message);
  6353. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6354. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6355. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6356. {
  6357. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6358. clif_displaymessage(fd, atcmd_output);
  6359. }
  6360. }
  6361. return 0;
  6362. }
  6363. /*==========================================
  6364. * @useskill by [MouseJstr]
  6365. *
  6366. * A way of using skills without having to find them in the skills menu
  6367. *------------------------------------------
  6368. */
  6369. int
  6370. atcommand_useskill(const int fd, struct map_session_data* sd,
  6371. const char* command, const char* message)
  6372. {
  6373. struct map_session_data *pl_sd = NULL;
  6374. int skillnum;
  6375. int skilllv;
  6376. char target[255];
  6377. nullpo_retr(-1, sd);
  6378. if (!message || !*message)
  6379. return -1;
  6380. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6381. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6382. return -1;
  6383. }
  6384. if((pl_sd=map_nick2sd(target)) == NULL) {
  6385. return -1;
  6386. }
  6387. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6388. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6389. else
  6390. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, skilllv);
  6391. return 0;
  6392. }
  6393. /*==========================================
  6394. * @skilltree by [MouseJstr]
  6395. *
  6396. * prints the skill tree for a player required to get to a skill
  6397. *------------------------------------------
  6398. */
  6399. int
  6400. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6401. const char* command, const char* message)
  6402. {
  6403. struct map_session_data *pl_sd = NULL;
  6404. int skillnum, skillidx = -1;
  6405. int meets = 1, j, c=0;
  6406. char target[NAME_LENGTH], *tbl;
  6407. struct skill_tree_entry *ent;
  6408. nullpo_retr(-1, sd);
  6409. if (!message || !*message)
  6410. return -1;
  6411. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6412. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6413. return -1;
  6414. }
  6415. if((pl_sd=map_nick2sd(target)) == NULL)
  6416. return -1;
  6417. c = pc_calc_skilltree_normalize_job(pl_sd);
  6418. tbl = job_name(c);
  6419. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6420. tbl, pc_checkskill(pl_sd, 1));
  6421. clif_displaymessage(fd, atcmd_output);
  6422. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6423. if (skill_tree[c][j].id == skillnum) {
  6424. skillidx = j;
  6425. break;
  6426. }
  6427. }
  6428. if (skillidx == -1) {
  6429. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6430. clif_displaymessage(fd, atcmd_output);
  6431. return 0;
  6432. }
  6433. ent = &skill_tree[c][skillidx];
  6434. for(j=0;j<5;j++)
  6435. if( ent->need[j].id &&
  6436. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6437. {
  6438. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6439. sprintf(atcmd_output, "player requires level %d of skill %s",
  6440. ent->need[j].lv, desc);
  6441. clif_displaymessage(fd, atcmd_output);
  6442. meets = 0;
  6443. }
  6444. if (meets == 1) {
  6445. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6446. clif_displaymessage(fd, atcmd_output);
  6447. }
  6448. return 0;
  6449. }
  6450. // Hand a ring with partners name on it to this char
  6451. void getring (struct map_session_data *sd)
  6452. {
  6453. int flag,item_id = 0;
  6454. struct item item_tmp;
  6455. if(sd->status.sex==0)
  6456. item_id = 2635;
  6457. else
  6458. item_id = 2634;
  6459. memset(&item_tmp,0,sizeof(item_tmp));
  6460. item_tmp.nameid=item_id;
  6461. item_tmp.identify=1;
  6462. item_tmp.card[0]=255;
  6463. item_tmp.card[2]=sd->status.partner_id;
  6464. item_tmp.card[3]=sd->status.partner_id >> 16;
  6465. //Logs (A)dmins items [Lupus]
  6466. if(log_config.pick > 0 ) {
  6467. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6468. }
  6469. //Logs
  6470. if((flag = pc_additem(sd,&item_tmp,1))) {
  6471. clif_additem(sd,0,0,flag);
  6472. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6473. }
  6474. }
  6475. /*==========================================
  6476. * @marry by [MouseJstr], fixed by Lupus
  6477. *
  6478. * Marry two players
  6479. *------------------------------------------
  6480. */
  6481. int
  6482. atcommand_marry(const int fd, struct map_session_data* sd,
  6483. const char* command, const char* message)
  6484. {
  6485. struct map_session_data *pl_sd1 = NULL;
  6486. struct map_session_data *pl_sd2 = NULL;
  6487. char player1[128], player2[128]; //Length used for return error msgs
  6488. nullpo_retr(-1, sd);
  6489. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6490. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6491. return -1;
  6492. }
  6493. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6494. sprintf(player2, "Cannot find player '%s' online", player1);
  6495. clif_displaymessage(fd, player2);
  6496. return -1;
  6497. }
  6498. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6499. sprintf(player1, "Cannot find player '%s' online", player2);
  6500. clif_displaymessage(fd, player1);
  6501. return -1;
  6502. }
  6503. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6504. clif_displaymessage(fd, "They are married.. wish them well");
  6505. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6506. // Auto-give named rings (Aru)
  6507. getring (pl_sd1);
  6508. getring (pl_sd2);
  6509. return 0;
  6510. }
  6511. return -1;
  6512. }
  6513. /*==========================================
  6514. * @divorce by [MouseJstr], fixed by [Lupus]
  6515. *
  6516. * divorce two players
  6517. *------------------------------------------
  6518. */
  6519. int
  6520. atcommand_divorce(const int fd, struct map_session_data* sd,
  6521. const char* command, const char* message)
  6522. {
  6523. struct map_session_data *pl_sd = NULL;
  6524. nullpo_retr(-1, sd);
  6525. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6526. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6527. return -1;
  6528. }
  6529. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6530. if (pc_divorce(pl_sd) != 0) {
  6531. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6532. clif_displaymessage(fd, atcmd_output);
  6533. return -1;
  6534. } else {
  6535. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6536. clif_displaymessage(fd, atcmd_output);
  6537. return 0;
  6538. }
  6539. }
  6540. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6541. clif_displaymessage(fd, atcmd_output);
  6542. return -1;
  6543. }
  6544. #ifdef DMALLOC
  6545. unsigned long dmark_;
  6546. int
  6547. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6548. const char* command, const char* message)
  6549. {
  6550. dmark_ = dmalloc_mark();
  6551. clif_displaymessage(fd, "debug mark set");
  6552. return 0;
  6553. }
  6554. int
  6555. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6556. const char* command, const char* message)
  6557. {
  6558. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6559. dmark_ = dmalloc_mark();
  6560. clif_displaymessage(fd, "malloc changes logged");
  6561. return 0;
  6562. }
  6563. #endif
  6564. /*==========================================
  6565. * @grind by [MouseJstr]
  6566. *------------------------------------------
  6567. */
  6568. int
  6569. atcommand_grind(const int fd, struct map_session_data* sd,
  6570. const char* command, const char* message)
  6571. {
  6572. struct map_session_data *pl_sd = NULL;
  6573. int skillnum;
  6574. int inf;
  6575. char target[NAME_LENGTH];
  6576. nullpo_retr(-1, sd);
  6577. if (!message || !*message)
  6578. return -1;
  6579. if(sscanf(message, "%23s", target) != 1) {
  6580. clif_displaymessage(fd, "Usage: @grind <target>");
  6581. return -1;
  6582. }
  6583. if((pl_sd=map_nick2sd(target)) == NULL)
  6584. return -1;
  6585. for (skillnum = 1; skillnum < 500; skillnum++) {
  6586. sd->status.sp = sd->status.max_sp;
  6587. atcommand_alive(fd, sd, command, message);
  6588. inf = skill_get_inf(skillnum);
  6589. if (inf & INF_GROUND_SKILL)
  6590. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6591. else if (!(inf & INF_SUPPORT_SKILL))
  6592. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6593. }
  6594. return 0;
  6595. }
  6596. /*==========================================
  6597. * @grind2 by [MouseJstr]
  6598. *------------------------------------------
  6599. */
  6600. int
  6601. atcommand_grind2(const int fd, struct map_session_data* sd,
  6602. const char* command, const char* message)
  6603. {
  6604. int i;
  6605. short x, y;
  6606. for (i = 1000; i < MAX_MOB_DB; i++) {
  6607. if (!mobdb_checkid(i))
  6608. continue;
  6609. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6610. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6611. }
  6612. return 0;
  6613. }
  6614. /*==========================================
  6615. * @changelook by [Celest]
  6616. *------------------------------------------
  6617. */
  6618. int
  6619. atcommand_changelook(const int fd, struct map_session_data* sd,
  6620. const char* command, const char* message)
  6621. {
  6622. int i, j = 0, k = 0;
  6623. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6624. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6625. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6626. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6627. return -1;
  6628. } else if (i == 2) {
  6629. if (j < 1) j = 1;
  6630. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6631. j = pos[j - 1];
  6632. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6633. k = j; // swap
  6634. j = LOOK_HEAD_TOP;
  6635. }
  6636. clif_changelook(&sd->bl,j,k);
  6637. return 0;
  6638. }
  6639. /*==========================================
  6640. *Turns on/off Autotrade for a specific player
  6641. *------------------------------------------
  6642. *by durf (changed by Lupus)
  6643. */
  6644. int
  6645. atcommand_autotrade(
  6646. const int fd, struct map_session_data* sd,
  6647. const char* command, const char* message)
  6648. {
  6649. nullpo_retr(-1, sd);
  6650. if (sd->vender_id) //check if player's vending
  6651. {
  6652. sd->state.autotrade = 1;
  6653. clif_authfail_fd(fd, 15);
  6654. }
  6655. else
  6656. {
  6657. //"You should be vending to use @Autotrade."
  6658. clif_displaymessage(fd, msg_txt(549));
  6659. }
  6660. return 0;
  6661. }
  6662. /*==========================================
  6663. * Changes Master of your Guild to a specified guild member
  6664. *------------------------------------------
  6665. *by durf (changed by Lupus)
  6666. */
  6667. int
  6668. atcommand_changegm(
  6669. const int fd, struct map_session_data* sd,
  6670. const char* command, const char* message)
  6671. {
  6672. struct guild *g;
  6673. struct map_session_data *pl_sd;
  6674. nullpo_retr(-1, sd);
  6675. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6676. {
  6677. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6678. return -1;
  6679. }
  6680. if (strlen(message)==0)
  6681. {
  6682. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6683. return -1;
  6684. }
  6685. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6686. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6687. return -1;
  6688. }
  6689. guild_gm_change(sd->status.guild_id, pl_sd);
  6690. return 0;
  6691. }
  6692. /*==========================================
  6693. *Changes the leader of a party.
  6694. *------------------------------------------
  6695. *by Skotlex
  6696. */
  6697. int
  6698. atcommand_changeleader(
  6699. const int fd, struct map_session_data* sd,
  6700. const char* command, const char* message)
  6701. {
  6702. struct party *p;
  6703. struct map_session_data *pl_sd;
  6704. int mi, pl_mi;
  6705. nullpo_retr(-1, sd);
  6706. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6707. {
  6708. clif_displaymessage(fd, "You need to be a party's leader to use this command.");
  6709. return -1;
  6710. }
  6711. for (mi = 0; mi < MAX_PARTY && p->member[mi].sd != sd; mi++);
  6712. if (mi == MAX_PARTY)
  6713. return -1; //Shouldn't happen
  6714. if (!p->member[mi].leader)
  6715. {
  6716. clif_displaymessage(fd, "You need to be the party's leader to use this command.");
  6717. return -1;
  6718. }
  6719. if (strlen(message)==0)
  6720. {
  6721. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6722. return -1;
  6723. }
  6724. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6725. clif_displaymessage(fd, "Target character must be online and be in your party.");
  6726. return -1;
  6727. }
  6728. for (pl_mi = 0; pl_mi < MAX_PARTY && p->member[pl_mi].sd != pl_sd; pl_mi++);
  6729. if (pl_mi == MAX_PARTY)
  6730. return -1; //Shouldn't happen
  6731. //Change leadership.
  6732. p->member[mi].leader = 0;
  6733. if (p->member[mi].sd->fd)
  6734. clif_displaymessage(p->member[mi].sd->fd, "Leadership transferred.");
  6735. p->member[pl_mi].leader = 1;
  6736. if (p->member[pl_mi].sd->fd)
  6737. clif_displaymessage(p->member[pl_mi].sd->fd, "You've become the party leader.");
  6738. intif_party_leaderchange(p->party_id,p->member[pl_mi].account_id,p->member[pl_mi].char_id);
  6739. //Update info.
  6740. clif_party_main_info(p,-1);
  6741. clif_party_info(p,-1);
  6742. return 0;
  6743. }
  6744. /*==========================================
  6745. *Turns on/off AutoLoot for a specific player
  6746. *------------------------------------------
  6747. *by Upa-Kun
  6748. */
  6749. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6750. {
  6751. // autoloot command with value
  6752. unsigned int rate;
  6753. nullpo_retr(-1, sd);
  6754. // autoloot command without value
  6755. if(!message || !*message)
  6756. {
  6757. // autoloot on -> off
  6758. if(sd->state.autoloot)
  6759. {
  6760. clif_displaymessage(fd, "Autoloot is now off.");
  6761. sd->state.autoloot = 0;
  6762. return 0;
  6763. // autoloot off -> on
  6764. } else {
  6765. clif_displaymessage(fd, "Autoloot is now on.");
  6766. sd->state.autoloot = 10000;
  6767. return 0;
  6768. }
  6769. }
  6770. // autoloot command with value
  6771. //unsigned int rate; // Moved to top due to decleration error after executional block. [Zido]
  6772. // get maximum droprate limit
  6773. rate = atoi(message) * 100;
  6774. // check for invalid value
  6775. if(rate > 10000)
  6776. {
  6777. clif_displaymessage(fd, "Invalid value. Choose value between 0 and 100.");
  6778. return 0;
  6779. }
  6780. // autoloot value is 0, turn autoloot off
  6781. if(rate == 0)
  6782. {
  6783. if(sd->state.autoloot == 0)
  6784. {
  6785. clif_displaymessage(fd, "Autoloot is already off.");
  6786. return 0;
  6787. } else {
  6788. clif_displaymessage(fd, "Autoloot is now off.");
  6789. sd->state.autoloot = 0;
  6790. return 0;
  6791. }
  6792. }
  6793. // autoloot value is 100, turn autoloot on
  6794. if(rate == 10000)
  6795. {
  6796. if(sd->state.autoloot == 10000)
  6797. {
  6798. clif_displaymessage(fd, "Autoloot is already on.");
  6799. return 0;
  6800. } else {
  6801. clif_displaymessage(fd, "Autoloot is now on.");
  6802. sd->state.autoloot = 10000;
  6803. return 0;
  6804. }
  6805. }
  6806. // autoloot value is between 0 and 100
  6807. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %d percent and below.", (rate / 100));
  6808. clif_displaymessage(fd, atcmd_output);
  6809. sd->state.autoloot = rate;
  6810. return 0;
  6811. }
  6812. /*==========================================
  6813. * It is made to rain.
  6814. *------------------------------------------
  6815. */
  6816. int
  6817. atcommand_rain(
  6818. const int fd, struct map_session_data* sd,
  6819. const char* command, const char* message)
  6820. {
  6821. nullpo_retr(-1, sd);
  6822. if (map[sd->bl.m].flag.rain) {
  6823. map[sd->bl.m].flag.rain=0;
  6824. clif_weather(sd->bl.m);
  6825. clif_displaymessage(fd, "The rain has stopped.");
  6826. } else {
  6827. map[sd->bl.m].flag.rain=1;
  6828. clif_weather(sd->bl.m);
  6829. clif_displaymessage(fd, "It is made to rain.");
  6830. }
  6831. return 0;
  6832. }
  6833. /*==========================================
  6834. * It is made to snow.
  6835. *------------------------------------------
  6836. */
  6837. int
  6838. atcommand_snow(
  6839. const int fd, struct map_session_data* sd,
  6840. const char* command, const char* message)
  6841. {
  6842. nullpo_retr(-1, sd);
  6843. if (map[sd->bl.m].flag.snow) {
  6844. map[sd->bl.m].flag.snow=0;
  6845. clif_weather(sd->bl.m);
  6846. clif_displaymessage(fd, "Snow has stopped falling.");
  6847. } else {
  6848. map[sd->bl.m].flag.snow=1;
  6849. clif_weather(sd->bl.m);
  6850. clif_displaymessage(fd, "It is made to snow.");
  6851. }
  6852. return 0;
  6853. }
  6854. /*==========================================
  6855. * Cherry tree snowstorm is made to fall. (Sakura)
  6856. *------------------------------------------
  6857. */
  6858. int
  6859. atcommand_sakura(
  6860. const int fd, struct map_session_data* sd,
  6861. const char* command, const char* message)
  6862. {
  6863. nullpo_retr(-1, sd);
  6864. if (map[sd->bl.m].flag.sakura) {
  6865. map[sd->bl.m].flag.sakura=0;
  6866. clif_weather(sd->bl.m);
  6867. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6868. } else {
  6869. map[sd->bl.m].flag.sakura=1;
  6870. clif_weather(sd->bl.m);
  6871. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6872. }
  6873. return 0;
  6874. }
  6875. /*==========================================
  6876. * Clouds appear.
  6877. *------------------------------------------
  6878. */
  6879. int
  6880. atcommand_clouds(
  6881. const int fd, struct map_session_data* sd,
  6882. const char* command, const char* message)
  6883. {
  6884. nullpo_retr(-1, sd);
  6885. if (map[sd->bl.m].flag.clouds) {
  6886. map[sd->bl.m].flag.clouds=0;
  6887. clif_weather(sd->bl.m);
  6888. clif_displaymessage(fd, "The clouds has disappear.");
  6889. } else {
  6890. map[sd->bl.m].flag.clouds=1;
  6891. clif_weather(sd->bl.m);
  6892. clif_displaymessage(fd, "Clouds appear.");
  6893. }
  6894. return 0;
  6895. }
  6896. /*==========================================
  6897. * Different type of clouds using effect 516
  6898. *------------------------------------------
  6899. */
  6900. int
  6901. atcommand_clouds2(
  6902. const int fd, struct map_session_data* sd,
  6903. const char* command, const char* message)
  6904. {
  6905. nullpo_retr(-1, sd);
  6906. if (map[sd->bl.m].flag.clouds2) {
  6907. map[sd->bl.m].flag.clouds2=0;
  6908. clif_weather(sd->bl.m);
  6909. clif_displaymessage(fd, "The alternative clouds disappear.");
  6910. } else {
  6911. map[sd->bl.m].flag.clouds2=1;
  6912. clif_weather(sd->bl.m);
  6913. clif_displaymessage(fd, "Alternative clouds appear.");
  6914. }
  6915. return 0;
  6916. }
  6917. /*==========================================
  6918. * Fog hangs over.
  6919. *------------------------------------------
  6920. */
  6921. int
  6922. atcommand_fog(
  6923. const int fd, struct map_session_data* sd,
  6924. const char* command, const char* message)
  6925. {
  6926. nullpo_retr(-1, sd);
  6927. if (map[sd->bl.m].flag.fog) {
  6928. map[sd->bl.m].flag.fog=0;
  6929. clif_weather(sd->bl.m);
  6930. clif_displaymessage(fd, "The fog has gone.");
  6931. } else {
  6932. map[sd->bl.m].flag.fog=1;
  6933. clif_weather(sd->bl.m);
  6934. clif_displaymessage(fd, "Fog hangs over.");
  6935. }
  6936. return 0;
  6937. }
  6938. /*==========================================
  6939. * Fallen leaves fall.
  6940. *------------------------------------------
  6941. */
  6942. int
  6943. atcommand_leaves(
  6944. const int fd, struct map_session_data* sd,
  6945. const char* command, const char* message)
  6946. {
  6947. nullpo_retr(-1, sd);
  6948. if (map[sd->bl.m].flag.leaves) {
  6949. map[sd->bl.m].flag.leaves=0;
  6950. clif_weather(sd->bl.m);
  6951. clif_displaymessage(fd, "Leaves no longer fall.");
  6952. } else {
  6953. map[sd->bl.m].flag.leaves=1;
  6954. clif_weather(sd->bl.m);
  6955. clif_displaymessage(fd, "Fallen leaves fall.");
  6956. }
  6957. return 0;
  6958. }
  6959. /*==========================================
  6960. * Fireworks appear.
  6961. *------------------------------------------
  6962. */
  6963. int
  6964. atcommand_fireworks(
  6965. const int fd, struct map_session_data* sd,
  6966. const char* command, const char* message)
  6967. {
  6968. nullpo_retr(-1, sd);
  6969. if (map[sd->bl.m].flag.fireworks) {
  6970. map[sd->bl.m].flag.fireworks=0;
  6971. clif_weather(sd->bl.m);
  6972. clif_displaymessage(fd, "Fireworks are ended.");
  6973. } else {
  6974. map[sd->bl.m].flag.fireworks=1;
  6975. clif_weather(sd->bl.m);
  6976. clif_displaymessage(fd, "Fireworks are launched.");
  6977. }
  6978. return 0;
  6979. }
  6980. /*==========================================
  6981. * Clearing Weather Effects by Dexity
  6982. *------------------------------------------
  6983. */
  6984. int
  6985. atcommand_clearweather(
  6986. const int fd, struct map_session_data* sd,
  6987. const char* command, const char* message)
  6988. {
  6989. nullpo_retr(-1, sd);
  6990. map[sd->bl.m].flag.rain=0;
  6991. map[sd->bl.m].flag.snow=0;
  6992. map[sd->bl.m].flag.sakura=0;
  6993. map[sd->bl.m].flag.clouds=0;
  6994. map[sd->bl.m].flag.clouds2=0;
  6995. map[sd->bl.m].flag.fog=0;
  6996. map[sd->bl.m].flag.fireworks=0;
  6997. map[sd->bl.m].flag.leaves=0;
  6998. clif_weather(sd->bl.m);
  6999. return 0;
  7000. }
  7001. /*===============================================================
  7002. * Sound Command - plays a sound for everyone! [Codemaster]
  7003. *---------------------------------------------------------------
  7004. */
  7005. int
  7006. atcommand_sound(
  7007. const int fd, struct map_session_data *sd,
  7008. const char *command, const char *message)
  7009. {
  7010. char sound_file[100];
  7011. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  7012. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  7013. return -1;
  7014. }
  7015. memset(sound_file, '\0', sizeof(sound_file));
  7016. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  7017. return -1;
  7018. if(strstr(sound_file, ".wav") == NULL)
  7019. strcat(sound_file, ".wav");
  7020. clif_soundeffectall(&sd->bl, sound_file,0,2);
  7021. return 0;
  7022. }
  7023. /*==========================================
  7024. * MOB Search
  7025. *------------------------------------------
  7026. */
  7027. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  7028. {
  7029. int mob_id,fd;
  7030. static int number=0;
  7031. struct mob_data *md;
  7032. nullpo_retr(0, bl);
  7033. if(!ap){
  7034. number=0;
  7035. return 0;
  7036. }
  7037. mob_id = va_arg(ap,int);
  7038. fd = va_arg(ap,int);
  7039. md = (struct mob_data *)bl;
  7040. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7041. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7042. ++number,bl->x, bl->y,md->name);
  7043. clif_displaymessage(fd, atcmd_output);
  7044. }
  7045. return 0;
  7046. }
  7047. int atcommand_mobsearch(
  7048. const int fd, struct map_session_data* sd,
  7049. const char* command, const char* message)
  7050. {
  7051. char mob_name[100];
  7052. int mob_id,map_id = 0;
  7053. nullpo_retr(-1, sd);
  7054. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7055. return -1;
  7056. if ((mob_id = atoi(mob_name)) == 0)
  7057. mob_id = mobdb_searchname(mob_name);
  7058. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7059. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7060. clif_displaymessage(fd, atcmd_output);
  7061. return 0;
  7062. }
  7063. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7064. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7065. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7066. map_id = sd->bl.m;
  7067. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7068. mob_name, mapindex_id2name(sd->mapindex));
  7069. clif_displaymessage(fd, atcmd_output);
  7070. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7071. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7072. return 0;
  7073. }
  7074. /*==========================================
  7075. * ドロップアイテムの掃除
  7076. *------------------------------------------
  7077. */
  7078. /*==========================================
  7079. * cleanmap
  7080. *------------------------------------------
  7081. */
  7082. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7083. {
  7084. nullpo_retr(0, bl);
  7085. map_clearflooritem(bl->id);
  7086. return 0;
  7087. }
  7088. int
  7089. atcommand_cleanmap(
  7090. const int fd, struct map_session_data* sd,
  7091. const char* command, const char* message)
  7092. {
  7093. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7094. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7095. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7096. BL_ITEM);
  7097. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7098. return 0;
  7099. }
  7100. /*==========================================
  7101. * NPC/PETに話させる
  7102. *------------------------------------------
  7103. */
  7104. int
  7105. atcommand_npctalk(
  7106. const int fd, struct map_session_data* sd,
  7107. const char* command, const char* message)
  7108. {
  7109. char name[NAME_LENGTH],mes[100],temp[100];
  7110. struct npc_data *nd;
  7111. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7112. return -1;
  7113. if (!(nd = npc_name2id(name)))
  7114. return -1;
  7115. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7116. clif_message(&nd->bl, temp);
  7117. return 0;
  7118. }
  7119. int
  7120. atcommand_pettalk(
  7121. const int fd, struct map_session_data* sd,
  7122. const char* command, const char* message)
  7123. {
  7124. char mes[100],temp[100];
  7125. struct pet_data *pd;
  7126. nullpo_retr(-1, sd);
  7127. if(!sd->status.pet_id || !(pd=sd->pd))
  7128. return -1;
  7129. if (sscanf(message, "%99[^\n]", mes) < 1)
  7130. return -1;
  7131. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  7132. clif_message(&pd->bl, temp);
  7133. return 0;
  7134. }
  7135. /*==========================================
  7136. * @users
  7137. * サーバー内の人数マップを表示させる
  7138. * 手抜きのため汚くなっているのは仕様です。
  7139. *------------------------------------------
  7140. */
  7141. static struct dbt *users_db = NULL;
  7142. static int users_all;
  7143. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7144. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7145. users_all++;
  7146. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7147. return 0;
  7148. }
  7149. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7150. char buf[256];
  7151. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7152. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7153. clif_displaymessage(sd->fd,buf);
  7154. return 0;
  7155. }
  7156. int
  7157. atcommand_users(
  7158. const int fd, struct map_session_data* sd,
  7159. const char* command, const char* message)
  7160. {
  7161. char buf[256];
  7162. users_all = 0;
  7163. users_db->clear(users_db, NULL);
  7164. clif_foreachclient(atcommand_users_sub1);
  7165. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7166. sprintf(buf,"all : %d",users_all);
  7167. clif_displaymessage(fd,buf);
  7168. return 0;
  7169. }
  7170. /*==========================================
  7171. *
  7172. *------------------------------------------
  7173. */
  7174. int
  7175. atcommand_summon(
  7176. const int fd, struct map_session_data* sd,
  7177. const char* command, const char* message)
  7178. {
  7179. char name[NAME_LENGTH];
  7180. int mob_id = 0;
  7181. int id = 0;
  7182. int duration = 0;
  7183. struct mob_data *md;
  7184. unsigned int tick=gettick();
  7185. nullpo_retr(-1, sd);
  7186. if (!message || !*message)
  7187. return -1;
  7188. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7189. return -1;
  7190. if (duration < 1)
  7191. duration =1;
  7192. else if (duration > 60)
  7193. duration =60;
  7194. if ((mob_id = atoi(name)) == 0)
  7195. mob_id = mobdb_searchname(name);
  7196. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7197. return -1;
  7198. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7199. if(md){
  7200. md->master_id=sd->bl.id;
  7201. md->special_state.ai=1;
  7202. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7203. clif_misceffect2(&md->bl,344);
  7204. mob_spawn(md);
  7205. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7206. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7207. }
  7208. return 0;
  7209. }
  7210. /*==========================================
  7211. * @adjcmdlvl by [MouseJstr]
  7212. *
  7213. * Temp adjust the GM level required to use a GM command
  7214. *
  7215. * Used during beta testing to allow players to use GM commands
  7216. * for short periods of time
  7217. *------------------------------------------
  7218. */
  7219. int
  7220. atcommand_adjcmdlvl(
  7221. const int fd, struct map_session_data* sd,
  7222. const char* command, const char* message)
  7223. {
  7224. int i, newlev;
  7225. char cmd[100];
  7226. nullpo_retr(-1, sd);
  7227. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7228. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7229. return -1;
  7230. }
  7231. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7232. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7233. atcommand_info[i].level = newlev;
  7234. clif_displaymessage(fd, "@command level changed.");
  7235. return 0;
  7236. }
  7237. clif_displaymessage(fd, "@command not found.");
  7238. return -1;
  7239. }
  7240. /*==========================================
  7241. * @adjgmlvl by [MouseJstr]
  7242. *
  7243. * Create a temp GM
  7244. *
  7245. * Used during beta testing to allow players to use GM commands
  7246. * for short periods of time
  7247. *------------------------------------------
  7248. */
  7249. int
  7250. atcommand_adjgmlvl(
  7251. const int fd, struct map_session_data* sd,
  7252. const char* command, const char* message)
  7253. {
  7254. int newlev;
  7255. char user[NAME_LENGTH];
  7256. struct map_session_data *pl_sd;
  7257. nullpo_retr(-1, sd);
  7258. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7259. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7260. return -1;
  7261. }
  7262. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7263. return -1;
  7264. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7265. return 0;
  7266. }
  7267. /*==========================================
  7268. * @trade by [MouseJstr]
  7269. *
  7270. * Open a trade window with a remote player
  7271. *
  7272. * If I have to jump to a remote player one more time, I am
  7273. * gonna scream!
  7274. *------------------------------------------
  7275. */
  7276. int
  7277. atcommand_trade(
  7278. const int fd, struct map_session_data* sd,
  7279. const char* command, const char* message)
  7280. {
  7281. struct map_session_data *pl_sd = NULL;
  7282. nullpo_retr(-1, sd);
  7283. if (!message || !*message)
  7284. return -1;
  7285. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7286. trade_traderequest(sd, pl_sd->bl.id);
  7287. return 0;
  7288. }
  7289. return -1;
  7290. }
  7291. /*==========================================
  7292. * @setbattleflag by [MouseJstr]
  7293. *
  7294. * set a battle_config flag without having to reboot
  7295. */
  7296. int
  7297. atcommand_setbattleflag(
  7298. const int fd, struct map_session_data* sd,
  7299. const char* command, const char* message)
  7300. {
  7301. char flag[128], value[128];
  7302. nullpo_retr(-1, sd);
  7303. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7304. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7305. return -1;
  7306. }
  7307. if (battle_set_value(flag, value) == 0)
  7308. clif_displaymessage(fd, "unknown battle_config flag");
  7309. else
  7310. clif_displaymessage(fd, "battle_config set as requested");
  7311. return 0;
  7312. }
  7313. /*===========================
  7314. * @unmute [Valaris]
  7315. *===========================
  7316. */
  7317. int atcommand_unmute(
  7318. const int fd, struct map_session_data* sd,
  7319. const char* command, const char* message)
  7320. {
  7321. struct map_session_data *pl_sd = NULL;
  7322. nullpo_retr(-1, sd);
  7323. if(!battle_config.muting_players) {
  7324. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7325. return 0;
  7326. }
  7327. if (!message || !*message)
  7328. return -1;
  7329. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7330. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7331. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7332. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7333. clif_displaymessage(sd->fd,"Player unmuted");
  7334. }
  7335. else
  7336. clif_displaymessage(sd->fd,"Player is not muted");
  7337. }
  7338. return 0;
  7339. }
  7340. /*==========================================
  7341. * @uptime by MC Cameri
  7342. *------------------------------------------
  7343. */
  7344. int
  7345. atcommand_uptime(
  7346. const int fd, struct map_session_data* sd,
  7347. const char* command, const char* message)
  7348. {
  7349. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7350. minute = 60, days = 0, hours = 0, minutes = 0;
  7351. nullpo_retr(-1, sd);
  7352. seconds = get_uptime();
  7353. days = seconds/day;
  7354. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7355. hours = seconds/hour;
  7356. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7357. minutes = seconds/minute;
  7358. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7359. snprintf(atcmd_output, sizeof(atcmd_output), msg_table[245], days, hours, minutes, seconds);
  7360. clif_displaymessage(fd, atcmd_output);
  7361. return 0;
  7362. }
  7363. /*==========================================
  7364. * @changesex <sex>
  7365. * => Changes one's sex. Argument sex can be
  7366. * 0 or 1, m or f, male or female.
  7367. *------------------------------------------
  7368. */
  7369. int
  7370. atcommand_changesex(
  7371. const int fd, struct map_session_data* sd,
  7372. const char* command, const char* message)
  7373. {
  7374. nullpo_retr(-1, sd);
  7375. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7376. return 0;
  7377. }
  7378. /*================================================
  7379. * @mute - Mutes a player for a set amount of time
  7380. *------------------------------------------------
  7381. */
  7382. int atcommand_mute(
  7383. const int fd, struct map_session_data* sd,
  7384. const char* command, const char* message)
  7385. {
  7386. struct map_session_data *pl_sd = NULL;
  7387. int manner;
  7388. nullpo_retr(-1, sd);
  7389. if(!battle_config.muting_players) {
  7390. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7391. return 0;
  7392. }
  7393. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7394. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7395. return -1;
  7396. }
  7397. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7398. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7399. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7400. return -1;
  7401. }
  7402. clif_GM_silence(sd, pl_sd, 0);
  7403. pl_sd->status.manner -= manner;
  7404. if(pl_sd->status.manner < 0)
  7405. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7406. }
  7407. else {
  7408. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7409. return -1;
  7410. }
  7411. return 0;
  7412. }
  7413. /*==========================================
  7414. * @refresh (like @jumpto <<yourself>>)
  7415. *------------------------------------------
  7416. */
  7417. int atcommand_refresh(
  7418. const int fd, struct map_session_data* sd,
  7419. const char* command, const char* message)
  7420. {
  7421. nullpo_retr(-1, sd);
  7422. clif_refresh(sd);
  7423. return 0;
  7424. }
  7425. /*==========================================
  7426. * @petid <part of pet name>
  7427. * => Displays a list of matching pets.
  7428. *------------------------------------------
  7429. */
  7430. int
  7431. atcommand_petid(const int fd, struct map_session_data* sd,
  7432. const char* command, const char* message)
  7433. {
  7434. char searchtext[100];
  7435. char temp0[100];
  7436. char temp1[100];
  7437. int cnt = 0, i = 0;
  7438. nullpo_retr(-1, sd);
  7439. if (!message || !*message)
  7440. return -1;
  7441. if (sscanf(message, "%99s", searchtext) < 1)
  7442. return -1;
  7443. estr_lower(searchtext);
  7444. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7445. clif_displaymessage(fd,temp0);
  7446. while (i < MAX_PET_DB) {
  7447. strcpy(temp1,pet_db[i].name);
  7448. strcpy(temp1, estr_lower(temp1));
  7449. strcpy(temp0,pet_db[i].jname);
  7450. strcpy(temp0, estr_lower(temp1));
  7451. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7452. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7453. pet_db[i].jname);
  7454. if (cnt >= 100) { // Only if there are custom pets
  7455. clif_displaymessage(fd, "Be more specific, can't send more than"
  7456. " 100 results.");
  7457. } else {
  7458. clif_displaymessage(fd, temp0);
  7459. }
  7460. cnt++;
  7461. }
  7462. i++;
  7463. }
  7464. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7465. clif_displaymessage(fd, temp0);
  7466. return 0;
  7467. }
  7468. /*==========================================
  7469. * @identify
  7470. * => GM's magnifier.
  7471. *------------------------------------------
  7472. */
  7473. int
  7474. atcommand_identify(
  7475. const int fd, struct map_session_data* sd,
  7476. const char* command, const char* message)
  7477. {
  7478. int i,num;
  7479. nullpo_retr(-1, sd);
  7480. for(i=num=0;i<MAX_INVENTORY;i++){
  7481. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7482. num++;
  7483. }
  7484. }
  7485. if (num > 0) {
  7486. clif_item_identify_list(sd);
  7487. } else {
  7488. clif_displaymessage(fd,"There are no items to appraise.");
  7489. }
  7490. return 0;
  7491. }
  7492. /*==========================================
  7493. * @gmotd (Global MOTD)
  7494. * by davidsiaw :P
  7495. *------------------------------------------
  7496. */
  7497. int
  7498. atcommand_gmotd(
  7499. const int fd, struct map_session_data* sd,
  7500. const char* command, const char* message)
  7501. {
  7502. char buf[256];
  7503. FILE *fp;
  7504. nullpo_retr(-1, sd);
  7505. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7506. while (fgets(buf, 250, fp) != NULL){
  7507. int i;
  7508. for( i=0; buf[i]; i++){
  7509. if( buf[i]=='\r' || buf[i]=='\n'){
  7510. buf[i]=0;
  7511. break;
  7512. }
  7513. }
  7514. intif_GMmessage(buf,strlen(buf)+1,8);
  7515. }
  7516. fclose(fp);
  7517. }
  7518. return 0;
  7519. }
  7520. int atcommand_misceffect(
  7521. const int fd, struct map_session_data* sd,
  7522. const char* command, const char* message)
  7523. {
  7524. int effect = 0;
  7525. nullpo_retr(-1, sd);
  7526. if (!message || !*message)
  7527. return -1;
  7528. if (sscanf(message, "%d", &effect) < 1)
  7529. return -1;
  7530. clif_misceffect(&sd->bl,effect);
  7531. return 0;
  7532. }
  7533. int charid2sessionid(int charid)
  7534. {
  7535. struct map_session_data *pl_sd = NULL;
  7536. pl_sd = map_charid2sd(charid);
  7537. if (pl_sd) return pl_sd->fd;
  7538. return 0;
  7539. }
  7540. int accountid2sessionid(int accountid)
  7541. {
  7542. struct map_session_data *pl_sd = NULL;
  7543. pl_sd = map_id2sd(accountid);
  7544. if (pl_sd) return pl_sd->fd;
  7545. return 0;
  7546. }
  7547. /*==========================================
  7548. * Jump to a player by PID number
  7549. * Original by Dino9021
  7550. * Added in by nsstrunks
  7551. *------------------------------------------
  7552. */
  7553. int atcommand_jumptoid(
  7554. const int fd, struct map_session_data* sd,
  7555. const char* command, const char* message)
  7556. {
  7557. int cid=0;
  7558. int session_id=0;
  7559. struct map_session_data *pl_sd;
  7560. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7561. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7562. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7563. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7564. return -1;
  7565. }
  7566. cid=atoi(message);
  7567. if ((session_id=charid2sessionid(cid))!=0)
  7568. {
  7569. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7570. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7571. clif_displaymessage(fd, msg_table[247]);
  7572. return -1;
  7573. }
  7574. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7575. clif_displaymessage(fd, msg_table[248]);
  7576. return -1;
  7577. }
  7578. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7579. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7580. clif_displaymessage(fd, atcmd_output);
  7581. } else {
  7582. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7583. return -1;
  7584. }
  7585. }
  7586. else
  7587. {
  7588. clif_displaymessage(fd,msg_table[3]);
  7589. }
  7590. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7591. return 0;
  7592. }
  7593. /*==========================================
  7594. * Jump to a player by PID number
  7595. * Original by Dino9021
  7596. * Added in by nsstrunks
  7597. *------------------------------------------
  7598. */
  7599. int atcommand_jumptoid2(
  7600. const int fd, struct map_session_data* sd,
  7601. const char* command, const char* message)
  7602. {
  7603. int aid=0;
  7604. int session_id=0;
  7605. struct map_session_data *pl_sd;
  7606. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7607. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7608. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7609. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7610. return -1;
  7611. }
  7612. aid=atoi(message);
  7613. if ((session_id=accountid2sessionid(aid))!=0)
  7614. {
  7615. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7616. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7617. clif_displaymessage(fd, msg_table[247]);
  7618. return -1;
  7619. }
  7620. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7621. clif_displaymessage(fd, msg_table[248]);
  7622. return -1;
  7623. }
  7624. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7625. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7626. clif_displaymessage(fd, atcmd_output);
  7627. } else {
  7628. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7629. return -1;
  7630. }
  7631. }
  7632. else
  7633. {
  7634. clif_displaymessage(fd,msg_table[3]);
  7635. }
  7636. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7637. return 0;
  7638. }
  7639. /*==========================================
  7640. * Recall a player by PID number
  7641. * Original by Dino9021
  7642. * Added in by nsstrunks
  7643. *------------------------------------------
  7644. */
  7645. int atcommand_recallid(
  7646. const int fd, struct map_session_data* sd,
  7647. const char* command, const char* message)
  7648. {
  7649. int cid=0;
  7650. int session_id=0;
  7651. struct map_session_data *pl_sd;
  7652. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7654. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7655. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7656. return -1;
  7657. }
  7658. cid=atoi(message);
  7659. if ((session_id=charid2sessionid(cid))!=0)
  7660. {
  7661. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7662. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7663. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7664. clif_displaymessage(fd, msg_table[247]);
  7665. return -1;
  7666. }
  7667. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7668. clif_displaymessage(fd, msg_table[248]);
  7669. return -1;
  7670. }
  7671. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7672. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7673. clif_displaymessage(fd, atcmd_output);
  7674. } else {
  7675. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7676. return -1;
  7677. }
  7678. } else {
  7679. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7680. return -1;
  7681. }
  7682. }
  7683. else
  7684. {
  7685. clif_displaymessage(fd,msg_table[3]);
  7686. }
  7687. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7688. return 0;
  7689. }
  7690. /*==========================================
  7691. * Recall a player by PID number
  7692. * Original by Dino9021
  7693. * Added in by nsstrunks
  7694. *------------------------------------------
  7695. */
  7696. int atcommand_recallid2(
  7697. const int fd, struct map_session_data* sd,
  7698. const char* command, const char* message)
  7699. {
  7700. int aid=0;
  7701. int session_id=0;
  7702. struct map_session_data *pl_sd;
  7703. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7704. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7705. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7706. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7707. return -1;
  7708. }
  7709. aid=atoi(message);
  7710. if ((session_id=accountid2sessionid(aid))!=0)
  7711. {
  7712. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7713. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7714. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7715. clif_displaymessage(fd, msg_table[247]);
  7716. return -1;
  7717. }
  7718. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7719. clif_displaymessage(fd, msg_table[248]);
  7720. return -1;
  7721. }
  7722. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7723. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7724. clif_displaymessage(fd, atcmd_output);
  7725. } else {
  7726. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7727. return -1;
  7728. }
  7729. } else {
  7730. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7731. return -1;
  7732. }
  7733. }
  7734. else
  7735. {
  7736. clif_displaymessage(fd,msg_table[3]);
  7737. }
  7738. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7739. return 0;
  7740. }
  7741. /*==========================================
  7742. * Kick a player by PID number
  7743. * Original by Dino9021
  7744. * Added in by nsstrunks
  7745. *------------------------------------------
  7746. */
  7747. int atcommand_kickid(
  7748. const int fd, struct map_session_data* sd,
  7749. const char* command, const char* message)
  7750. {
  7751. struct map_session_data *pl_sd;
  7752. int cid=0;
  7753. int session_id=0;
  7754. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7755. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7756. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7757. return -1;
  7758. }
  7759. cid=atoi(message);
  7760. if ((session_id=charid2sessionid(cid))!=0)
  7761. {
  7762. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7763. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7764. clif_GM_kick(sd, pl_sd, 1);
  7765. else {
  7766. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7767. return -1;
  7768. }
  7769. } else {
  7770. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7771. return -1;
  7772. }
  7773. }
  7774. else
  7775. {
  7776. clif_displaymessage(fd,msg_table[3]);
  7777. }
  7778. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7779. return 0;
  7780. }
  7781. /*==========================================
  7782. * Kick a player by PID number
  7783. * Original by Dino9021
  7784. * Added in by nsstrunks
  7785. *------------------------------------------
  7786. */
  7787. int atcommand_kickid2(
  7788. const int fd, struct map_session_data* sd,
  7789. const char* command, const char* message)
  7790. {
  7791. struct map_session_data *pl_sd;
  7792. int aid=0;
  7793. int session_id=0;
  7794. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7795. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7796. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7797. return -1;
  7798. }
  7799. aid=atoi(message);
  7800. if ((session_id=accountid2sessionid(aid))!=0)
  7801. {
  7802. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7803. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7804. clif_GM_kick(sd, pl_sd, 1);
  7805. else {
  7806. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7807. return -1;
  7808. }
  7809. } else {
  7810. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7811. return -1;
  7812. }
  7813. }
  7814. else
  7815. {
  7816. clif_displaymessage(fd,msg_table[3]);
  7817. }
  7818. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7819. return 0;
  7820. }
  7821. /*==========================================
  7822. * Revive a player by PID number
  7823. * Original by Dino9021
  7824. * Added in by nsstrunks
  7825. *------------------------------------------
  7826. */
  7827. int atcommand_reviveid(
  7828. const int fd, struct map_session_data* sd,
  7829. const char* command, const char* message)
  7830. {
  7831. int cid=0;
  7832. int session_id=0;
  7833. struct map_session_data *pl_sd;
  7834. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7835. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7836. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7837. return -1;
  7838. }
  7839. cid=atoi(message);
  7840. if ((session_id=charid2sessionid(cid))!=0)
  7841. {
  7842. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7843. pl_sd->status.hp = pl_sd->status.max_hp;
  7844. pc_setstand(pl_sd);
  7845. if (battle_config.pc_invincible_time > 0)
  7846. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7847. clif_updatestatus(pl_sd, SP_HP);
  7848. clif_updatestatus(pl_sd, SP_SP);
  7849. clif_resurrection(&pl_sd->bl, 1);
  7850. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7851. } else {
  7852. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7853. return -1;
  7854. }
  7855. }
  7856. else
  7857. {
  7858. clif_displaymessage(fd,msg_table[3]);
  7859. }
  7860. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7861. return 0;
  7862. }
  7863. /*==========================================
  7864. * Revive a player by PID number
  7865. * Original by Dino9021
  7866. * Added in by nsstrunks
  7867. *------------------------------------------
  7868. */
  7869. int atcommand_reviveid2(
  7870. const int fd, struct map_session_data* sd,
  7871. const char* command, const char* message)
  7872. {
  7873. int aid=0;
  7874. int session_id=0;
  7875. struct map_session_data *pl_sd;
  7876. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7877. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7878. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7879. return -1;
  7880. }
  7881. aid=atoi(message);
  7882. if ((session_id=accountid2sessionid(aid))!=0)
  7883. {
  7884. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7885. pl_sd->status.hp = pl_sd->status.max_hp;
  7886. pc_setstand(pl_sd);
  7887. if (battle_config.pc_invincible_time > 0)
  7888. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7889. clif_updatestatus(pl_sd, SP_HP);
  7890. clif_updatestatus(pl_sd, SP_SP);
  7891. clif_resurrection(&pl_sd->bl, 1);
  7892. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7893. } else {
  7894. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7895. return -1;
  7896. }
  7897. }
  7898. else
  7899. {
  7900. clif_displaymessage(fd,msg_table[3]);
  7901. }
  7902. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7903. return 0;
  7904. }
  7905. /*==========================================
  7906. * Kill a player by PID number
  7907. * Original by Dino9021
  7908. * Added in by nsstrunks
  7909. *------------------------------------------
  7910. */
  7911. int atcommand_killid(
  7912. const int fd, struct map_session_data* sd,
  7913. const char* command, const char* message)
  7914. {
  7915. int cid=0;
  7916. int session_id=0;
  7917. struct map_session_data *pl_sd;
  7918. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7919. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7920. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7921. return -1;
  7922. }
  7923. cid=atoi(message);
  7924. if ((session_id=charid2sessionid(cid))!=0)
  7925. {
  7926. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7927. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7928. status_kill(&pl_sd->bl);
  7929. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7930. } else {
  7931. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7932. return -1;
  7933. }
  7934. } else {
  7935. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7936. return -1;
  7937. }
  7938. }
  7939. else
  7940. {
  7941. clif_displaymessage(fd,msg_table[3]);
  7942. }
  7943. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7944. return 0;
  7945. }
  7946. /*==========================================
  7947. * Kill a player by PID number
  7948. * Original by Dino9021
  7949. * Added in by nsstrunks
  7950. *------------------------------------------
  7951. */
  7952. int atcommand_killid2(
  7953. const int fd, struct map_session_data* sd,
  7954. const char* command, const char* message)
  7955. {
  7956. int aid=0;
  7957. int session_id=0;
  7958. struct map_session_data *pl_sd;
  7959. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7960. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7961. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7962. return -1;
  7963. }
  7964. aid=atoi(message);
  7965. if ((session_id=accountid2sessionid(aid))!=0)
  7966. {
  7967. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7968. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7969. status_kill(&pl_sd->bl);
  7970. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7971. } else {
  7972. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7973. return -1;
  7974. }
  7975. } else {
  7976. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7977. return -1;
  7978. }
  7979. }
  7980. else
  7981. {
  7982. clif_displaymessage(fd,msg_table[3]);
  7983. }
  7984. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7985. return 0;
  7986. }
  7987. /*==========================================
  7988. * Make a player killable, by PID
  7989. * Original by Dino9021
  7990. * Added in by nsstrunks
  7991. *------------------------------------------
  7992. */
  7993. int
  7994. atcommand_charkillableid(
  7995. const int fd, struct map_session_data* sd,
  7996. const char* command, const char* message)
  7997. {
  7998. struct map_session_data *pl_sd = NULL;
  7999. int cid=0;
  8000. int session_id=0;
  8001. if (!message || (cid = atoi(message)) == 0 || !*message)
  8002. return -1;
  8003. cid=atoi(message);
  8004. if ((session_id=charid2sessionid(cid))!=0)
  8005. {
  8006. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8007. return -1;
  8008. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  8009. if(pl_sd->special_state.killable)
  8010. clif_displaymessage(fd, "The player is now killable");
  8011. else
  8012. clif_displaymessage(fd, "The player is no longer killable");
  8013. }
  8014. else
  8015. {
  8016. clif_displaymessage(fd,msg_table[3]);
  8017. }
  8018. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8019. return 0;
  8020. }
  8021. /*==========================================
  8022. * Make a player killable, by PID
  8023. * Original by Dino9021
  8024. * Added in by nsstrunks
  8025. *------------------------------------------
  8026. */
  8027. int
  8028. atcommand_charkillableid2(
  8029. const int fd, struct map_session_data* sd,
  8030. const char* command, const char* message)
  8031. {
  8032. struct map_session_data *pl_sd = NULL;
  8033. int aid=0;
  8034. int session_id=0;
  8035. if (!message || (aid = atoi(message)) == 0 || !*message)
  8036. return -1;
  8037. aid=atoi(message);
  8038. if ((session_id=accountid2sessionid(aid))!=0)
  8039. {
  8040. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8041. return -1;
  8042. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  8043. if(pl_sd->special_state.killable)
  8044. clif_displaymessage(fd, "The player is now killable");
  8045. else
  8046. clif_displaymessage(fd, "The player is no longer killable");
  8047. }
  8048. else
  8049. {
  8050. clif_displaymessage(fd,msg_table[3]);
  8051. }
  8052. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8053. return 0;
  8054. }
  8055. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8056. /*==========================================
  8057. * Mail System commands by [Valaris]
  8058. *------------------------------------------
  8059. */
  8060. int atcommand_listmail(
  8061. const int fd, struct map_session_data* sd,
  8062. const char* command, const char* message)
  8063. {
  8064. if(!mail_server_enable)
  8065. return 0;
  8066. nullpo_retr(-1, sd);
  8067. if(strlen(command)==12)
  8068. mail_check(sd,3);
  8069. else if(strlen(command)==9)
  8070. mail_check(sd,2);
  8071. else
  8072. mail_check(sd,1);
  8073. return 0;
  8074. }
  8075. int atcommand_readmail(
  8076. const int fd, struct map_session_data* sd,
  8077. const char* command, const char* message)
  8078. {
  8079. int index;
  8080. if(!mail_server_enable)
  8081. return 0;
  8082. nullpo_retr(-1, sd);
  8083. if (!message || !*message) {
  8084. clif_displaymessage(sd->fd,"You must specify a message number.");
  8085. return 0;
  8086. }
  8087. index = atoi(message);
  8088. if (index < 1) {
  8089. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8090. return 0;
  8091. }
  8092. if(strlen(command)==11)
  8093. mail_delete(sd,index);
  8094. else
  8095. mail_read(sd,index);
  8096. return 0;
  8097. }
  8098. int atcommand_sendmail(
  8099. const int fd, struct map_session_data* sd,
  8100. const char* command, const char* message)
  8101. {
  8102. char name[NAME_LENGTH],text[80];
  8103. if(!mail_server_enable)
  8104. return 0;
  8105. nullpo_retr(-1, sd);
  8106. if (!message || !*message) {
  8107. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8108. return 0;
  8109. }
  8110. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8111. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8112. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8113. return 0;
  8114. }
  8115. if(strlen(command)==17)
  8116. mail_send(sd,name,text,1);
  8117. else
  8118. mail_send(sd,name,text,0);
  8119. return 0;
  8120. }
  8121. /*==========================================
  8122. * Refresh online command for SQL [Valaris]
  8123. * Will refresh and check online column of
  8124. * players and set correctly.
  8125. *------------------------------------------
  8126. */
  8127. int atcommand_refreshonline(
  8128. const int fd, struct map_session_data* sd,
  8129. const char* command, const char* message)
  8130. {
  8131. send_users_tochar(-1, gettick(), 0, 0);
  8132. return 0;
  8133. }
  8134. #endif /* end sql only */
  8135. /*==========================================
  8136. * Show Monster DB Info v 1.0
  8137. * originally by [Lupus] eAthena
  8138. *------------------------------------------
  8139. */
  8140. int atcommand_mobinfo(
  8141. const int fd, struct map_session_data* sd,
  8142. const char* command, const char* message)
  8143. {
  8144. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8145. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8146. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8147. char atcmd_output2[200];
  8148. struct item_data *item_data;
  8149. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8150. int mob_id, count;
  8151. int i, j, k;
  8152. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8153. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8154. if (!message || !*message) {
  8155. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8156. return -1;
  8157. }
  8158. // If monster identifier/name argument is a name
  8159. if ((mob_id = mobdb_checkid(atoi(message))))
  8160. {
  8161. mob_array[0] = mob_db(mob_id);
  8162. count = 1;
  8163. } else
  8164. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8165. if (!count) {
  8166. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8167. return -1;
  8168. }
  8169. if (count > MAX_SEARCH) {
  8170. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8171. clif_displaymessage(fd, atcmd_output);
  8172. count = MAX_SEARCH;
  8173. }
  8174. for (k = 0; k < count; k++) {
  8175. mob = mob_array[k];
  8176. // stats
  8177. if (mob->mexp)
  8178. sprintf(atcmd_output, "MVP Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8179. else
  8180. sprintf(atcmd_output, "Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8181. clif_displaymessage(fd, atcmd_output);
  8182. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%d Job EXP:%d", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  8183. clif_displaymessage(fd, atcmd_output);
  8184. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  8185. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  8186. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  8187. clif_displaymessage(fd, atcmd_output);
  8188. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  8189. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  8190. mob->range2 , mob->range3, msize[mob->status.size],
  8191. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  8192. clif_displaymessage(fd, atcmd_output);
  8193. // drops
  8194. clif_displaymessage(fd, " Drops:");
  8195. strcpy(atcmd_output, " ");
  8196. j = 0;
  8197. for (i = 0; i < MAX_MOB_DROP; i++) {
  8198. if (mob->dropitem[i].nameid <= 0 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8199. continue;
  8200. if (mob->dropitem[i].p > 0) {
  8201. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  8202. strcat(atcmd_output, atcmd_output2);
  8203. if (++j % 3 == 0) {
  8204. clif_displaymessage(fd, atcmd_output);
  8205. strcpy(atcmd_output, " ");
  8206. }
  8207. }
  8208. }
  8209. if (j == 0)
  8210. clif_displaymessage(fd, "This monster has no drops.");
  8211. else if (j % 3 != 0)
  8212. clif_displaymessage(fd, atcmd_output);
  8213. // mvp
  8214. if (mob->mexp) {
  8215. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8216. clif_displaymessage(fd, atcmd_output);
  8217. strcpy(atcmd_output, " MVP Items:");
  8218. j = 0;
  8219. for (i = 0; i < 3; i++) {
  8220. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8221. continue;
  8222. if (mob->mvpitem[i].p > 0) {
  8223. j++;
  8224. if (j == 1)
  8225. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8226. else
  8227. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8228. strcat(atcmd_output, atcmd_output2);
  8229. }
  8230. }
  8231. if (j == 0)
  8232. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8233. else
  8234. clif_displaymessage(fd, atcmd_output);
  8235. }
  8236. }
  8237. return 0;
  8238. }
  8239. /*==========================================
  8240. * Show Items DB Info v 1.0
  8241. * originally by [Lupus] eAthena
  8242. *------------------------------------------
  8243. */
  8244. int atcommand_iteminfo(
  8245. const int fd, struct map_session_data* sd,
  8246. const char* command, const char* message)
  8247. {
  8248. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8249. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8250. struct item_data *item_data, *item_array[MAX_SEARCH];
  8251. int i, item_id=0, count = 1;
  8252. if (!message || !*message) {
  8253. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8254. return -1;
  8255. }
  8256. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8257. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8258. if (!count) {
  8259. clif_displaymessage(fd, "Item not found.");
  8260. return -1;
  8261. }
  8262. if (count > MAX_SEARCH) {
  8263. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8264. clif_displaymessage(fd, atcmd_output);
  8265. count = MAX_SEARCH;
  8266. }
  8267. for (i = 0; i < count; i++) {
  8268. item_data = item_array[i];
  8269. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8270. item_data->name,item_data->jname,item_data->slot,item_id,
  8271. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8272. (item_data->script==NULL)? "None" : "With script"
  8273. );
  8274. clif_displaymessage(fd, atcmd_output);
  8275. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %d ", 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 );
  8276. clif_displaymessage(fd, atcmd_output);
  8277. if (item_data->maxchance == 10000)
  8278. strcpy(atcmd_output, " - Available in the shops only");
  8279. else if (item_data->maxchance)
  8280. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8281. else
  8282. strcpy(atcmd_output, " - Monsters don't drop this item");
  8283. clif_displaymessage(fd, atcmd_output);
  8284. }
  8285. return 0;
  8286. }
  8287. /*==========================================
  8288. * Show who drops the item.
  8289. *------------------------------------------
  8290. */
  8291. int atcommand_whodrops(
  8292. const int fd, struct map_session_data* sd,
  8293. const char* command, const char* message)
  8294. {
  8295. struct item_data *item_data, *item_array[MAX_SEARCH];
  8296. int i,j, count = 1;
  8297. if (!message || !*message) {
  8298. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8299. return -1;
  8300. }
  8301. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8302. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8303. if (!count) {
  8304. clif_displaymessage(fd, "Item not found.");
  8305. return -1;
  8306. }
  8307. if (count > MAX_SEARCH) {
  8308. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8309. clif_displaymessage(fd, atcmd_output);
  8310. count = MAX_SEARCH;
  8311. }
  8312. for (i = 0; i < count; i++) {
  8313. item_data = item_array[i];
  8314. sprintf(atcmd_output, "Item: '%s'[%d]",
  8315. item_data->jname,item_data->slot);
  8316. clif_displaymessage(fd, atcmd_output);
  8317. if (item_data->mob[0].chance == 0) {
  8318. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8319. clif_displaymessage(fd, atcmd_output);
  8320. } else {
  8321. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8322. clif_displaymessage(fd, atcmd_output);
  8323. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8324. {
  8325. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8326. clif_displaymessage(fd, atcmd_output);
  8327. }
  8328. }
  8329. }
  8330. return 0;
  8331. }
  8332. /*==========================================
  8333. * @adopt by [Veider]
  8334. *
  8335. * adopt a novice
  8336. *------------------------------------------
  8337. */
  8338. int
  8339. atcommand_adopt(const int fd, struct map_session_data* sd,
  8340. const char* command, const char* message)
  8341. {
  8342. struct map_session_data *pl_sd1 = NULL;
  8343. struct map_session_data *pl_sd2 = NULL;
  8344. struct map_session_data *pl_sd3 = NULL;
  8345. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8346. nullpo_retr(-1, sd);
  8347. if (!message || !*message)
  8348. return -1;
  8349. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8350. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8351. return -1;
  8352. }
  8353. if (battle_config.etc_log)
  8354. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8355. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8356. sprintf(player2, "Cannot find player %s online", player1);
  8357. clif_displaymessage(fd, player2);
  8358. return -1;
  8359. }
  8360. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8361. sprintf(player1, "Cannot find player %s online", player2);
  8362. clif_displaymessage(fd, player1);
  8363. return -1;
  8364. }
  8365. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8366. sprintf(player1, "Cannot find player %s online", player3);
  8367. clif_displaymessage(fd, player1);
  8368. return -1;
  8369. }
  8370. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8371. clif_displaymessage(fd, "They are too young to be parents!");
  8372. return -1;
  8373. }
  8374. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8375. clif_displaymessage(fd, "They are family.. wish them luck");
  8376. return 0;
  8377. }
  8378. else
  8379. return -1;
  8380. }
  8381. int atcommand_version(
  8382. const int fd, struct map_session_data* sd,
  8383. const char* command, const char* message)
  8384. {
  8385. const char * revision;
  8386. if ((revision = get_svn_revision()) != 0) {
  8387. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8388. clif_displaymessage(fd,atcmd_output);
  8389. } else
  8390. clif_displaymessage(fd,"Cannot determine SVN revision");
  8391. return 0;
  8392. }
  8393. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8394. {
  8395. int time, id;
  8396. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8397. if (pl_sd == NULL)
  8398. return 0;
  8399. id = va_arg(ap, int);
  8400. time = va_arg(ap, int);
  8401. if (id != bl->id && !pc_isGM(pl_sd)) {
  8402. pl_sd->status.manner -= time;
  8403. if (pl_sd->status.manner < 0)
  8404. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8405. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8406. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8407. }
  8408. return 0;
  8409. }
  8410. /*==========================================
  8411. * @mutearea by MouseJstr
  8412. *------------------------------------------
  8413. */
  8414. int atcommand_mutearea(
  8415. const int fd, struct map_session_data* sd,
  8416. const char* command, const char* message)
  8417. {
  8418. int time;
  8419. nullpo_retr(0, sd);
  8420. if(!battle_config.muting_players) {
  8421. clif_displaymessage(fd, "Please enable the muting system before using it.");
  8422. return 0;
  8423. }
  8424. time = atoi(message);
  8425. if (!time)
  8426. time = 15; // 15 minutes default
  8427. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8428. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8429. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8430. return 0;
  8431. }
  8432. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8433. {
  8434. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8435. if (bl == NULL)
  8436. return 0;
  8437. if (!pc_isGM(pl_sd))
  8438. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8439. return 0;
  8440. }
  8441. /*==========================================
  8442. * @shuffle by MouseJstr
  8443. *------------------------------------------
  8444. */
  8445. int atcommand_shuffle(
  8446. const int fd, struct map_session_data* sd,
  8447. const char* command, const char* message)
  8448. {
  8449. nullpo_retr(0, sd);
  8450. if (strcmp(message, "area")== 0) {
  8451. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8452. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8453. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8454. } else if (strcmp(message, "map")== 0) {
  8455. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8456. } else if (strcmp(message, "world") == 0) {
  8457. struct map_session_data **pl_allsd;
  8458. int i, users;
  8459. pl_allsd = map_getallusers(&users);
  8460. for (i = 0; i < users; i++)
  8461. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8462. } else
  8463. clif_displaymessage(fd, "options are area, map, or world");
  8464. return 0;
  8465. }
  8466. int atcommand_rates(
  8467. const int fd, struct map_session_data* sd,
  8468. const char* command, const char* message)
  8469. {
  8470. char buf[255];
  8471. nullpo_retr(0, sd);
  8472. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8473. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8474. clif_displaymessage(fd, buf);
  8475. return 0;
  8476. }
  8477. /*==========================================
  8478. * @me by lordalfa
  8479. * => Displays the OUTPUT string on top of
  8480. * the Visible players Heads.
  8481. *------------------------------------------
  8482. */
  8483. int atcommand_me(
  8484. const int fd, struct map_session_data* sd,
  8485. const char* command, const char* message)
  8486. {
  8487. char tempmes[200];
  8488. nullpo_retr(-1, sd);
  8489. memset(tempmes, '\0', sizeof(tempmes));
  8490. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8491. if (!message || !*message) {
  8492. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8493. return -1;
  8494. }
  8495. sscanf(message, "%199[^\n]", tempmes);
  8496. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8497. clif_disp_overhead(sd, atcmd_output);
  8498. return 0;
  8499. }
  8500. /*==========================================
  8501. * @size
  8502. * => Resize your character sprite. [Valaris]
  8503. *------------------------------------------
  8504. */
  8505. int atcommand_size(
  8506. const int fd, struct map_session_data* sd,
  8507. const char* command, const char* message)
  8508. {
  8509. int size=0;
  8510. nullpo_retr(-1, sd);
  8511. if (!message || !*message)
  8512. return -1;
  8513. if (sscanf(message,"%d", &size) < 1)
  8514. return -1;
  8515. if(sd->state.size) {
  8516. sd->state.size=0;
  8517. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8518. }
  8519. if(size==1) {
  8520. sd->state.size=1;
  8521. clif_specialeffect(&sd->bl,420,AREA);
  8522. } else if(size==2) {
  8523. sd->state.size=2;
  8524. clif_specialeffect(&sd->bl,422,AREA);
  8525. }
  8526. return 0;
  8527. }
  8528. /*==========================================
  8529. * @monsterignore
  8530. * => Makes monsters ignore you. [Valaris]
  8531. *------------------------------------------
  8532. */
  8533. int atcommand_monsterignore(
  8534. const int fd, struct map_session_data* sd,
  8535. const char* command, const char* message)
  8536. {
  8537. nullpo_retr(-1, sd);
  8538. if (!sd->state.monster_ignore) {
  8539. sd->state.monster_ignore = 1;
  8540. clif_displaymessage(sd->fd, "Monsters will now ignore you.");
  8541. } else {
  8542. sd->state.monster_ignore = 0;
  8543. clif_displaymessage(sd->fd, "Monsters are no longer ignoring you.");
  8544. }
  8545. return 0;
  8546. }
  8547. /*==========================================
  8548. * @fakename
  8549. * => Gives your character a fake name. [Valaris]
  8550. *------------------------------------------
  8551. */
  8552. int atcommand_fakename(
  8553. const int fd, struct map_session_data* sd,
  8554. const char* command, const char* message)
  8555. {
  8556. char name[NAME_LENGTH];
  8557. nullpo_retr(-1, sd);
  8558. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8559. sd->fakename[0]='\0';
  8560. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8561. clif_displaymessage(sd->fd,"Returned to real name.");
  8562. return 0;
  8563. }
  8564. if (!message || !*message) {
  8565. clif_displaymessage(sd->fd,"You must enter a name.");
  8566. return 0;
  8567. }
  8568. if (sscanf(message, "%23[^\n]", name) < 1) {
  8569. return 0;
  8570. }
  8571. if(strlen(name) < 2) {
  8572. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8573. return 0;
  8574. }
  8575. memcpy(sd->fakename,name,NAME_LENGTH-1);
  8576. clif_charnameack(0, &sd->bl);
  8577. clif_displaymessage(sd->fd,"Fake name enabled.");
  8578. return 0;
  8579. }
  8580. /*==========================================
  8581. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  8582. * => Shows information about the map flags [map name]
  8583. * Also set flags
  8584. *------------------------------------------
  8585. */
  8586. int atcommand_mapflag(
  8587. const int fd, struct map_session_data* sd,
  8588. const char* command, const char* message)
  8589. {
  8590. // WIP
  8591. return 0;
  8592. }
  8593. /*===================================
  8594. * Remove some messages
  8595. *-----------------------------------
  8596. */
  8597. int atcommand_showexp(
  8598. const int fd, struct map_session_data* sd,
  8599. const char* command, const char* message)
  8600. {
  8601. if (sd->state.showexp) {
  8602. sd->state.showexp = 0;
  8603. clif_displaymessage(fd, "Gained exp will not be shown.");
  8604. return 0;
  8605. }
  8606. sd->state.showexp = 1;
  8607. clif_displaymessage(fd, "Gained exp is now shown");
  8608. return 0;
  8609. }
  8610. int atcommand_showzeny(
  8611. const int fd, struct map_session_data* sd,
  8612. const char* command, const char* message)
  8613. {
  8614. if (sd->state.showzeny) {
  8615. sd->state.showzeny = 0;
  8616. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8617. return 0;
  8618. }
  8619. sd->state.showzeny = 1;
  8620. clif_displaymessage(fd, "Gained zeny is now shown");
  8621. return 0;
  8622. }
  8623. int atcommand_showdelay(
  8624. const int fd, struct map_session_data* sd,
  8625. const char* command, const char* message)
  8626. {
  8627. if (sd->state.showdelay) {
  8628. sd->state.showdelay = 0;
  8629. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8630. return 0;
  8631. }
  8632. sd->state.showdelay = 1;
  8633. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8634. return 0;
  8635. }
  8636. /*==========================================
  8637. * Duel organizing functions [LuzZza]
  8638. *
  8639. * @duel [limit|nick] - create a duel
  8640. * @invite <nick> - invite player
  8641. * @accept - accept invitation
  8642. * @reject - reject invitation
  8643. * @leave - leave duel
  8644. *------------------------------------------
  8645. */
  8646. int atcommand_invite(
  8647. const int fd, struct map_session_data* sd,
  8648. const char* command, const char* message)
  8649. {
  8650. unsigned int did = sd->duel_group;
  8651. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8652. if(did <= 0) {
  8653. // "Duel: @invite without @duel."
  8654. clif_displaymessage(fd, msg_txt(350));
  8655. return 0;
  8656. }
  8657. if(duel_list[did].max_players_limit > 0 &&
  8658. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8659. // "Duel: Limit of players is reached."
  8660. clif_displaymessage(fd, msg_txt(351));
  8661. return 0;
  8662. }
  8663. if(target_sd == NULL) {
  8664. // "Duel: Player not found."
  8665. clif_displaymessage(fd, msg_txt(352));
  8666. return 0;
  8667. }
  8668. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8669. // "Duel: Player already in duel."
  8670. clif_displaymessage(fd, msg_txt(353));
  8671. return 0;
  8672. }
  8673. duel_invite(did, sd, target_sd);
  8674. // "Duel: Invitation has been sent."
  8675. clif_displaymessage(fd, msg_txt(354));
  8676. return 0;
  8677. }
  8678. int atcommand_duel(
  8679. const int fd, struct map_session_data* sd,
  8680. const char* command, const char* message)
  8681. {
  8682. char output[256];
  8683. unsigned int maxpl=0, newduel;
  8684. struct map_session_data *target_sd;
  8685. /* // Commnted because it can be disabled in at-comms conf.
  8686. if(!battle_config.duel_enable) {
  8687. clif_displaymessage(fd, "Duel: duel is disable.");
  8688. return 0;
  8689. }
  8690. */
  8691. if(sd->duel_group > 0) {
  8692. duel_showinfo(sd->duel_group, sd);
  8693. return 0;
  8694. }
  8695. if(sd->duel_invite > 0) {
  8696. // "Duel: @duel without @reject."
  8697. clif_displaymessage(fd, msg_txt(355));
  8698. return 0;
  8699. }
  8700. if(!duel_checktime(sd)) {
  8701. // "Duel: You can take part in duel only one time per %d minutes."
  8702. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8703. clif_displaymessage(fd, output);
  8704. return 0;
  8705. }
  8706. if(strlen(message) > 0) {
  8707. if(sscanf(message, "%d", &maxpl) >= 1) {
  8708. if(maxpl < 2 || maxpl > 65535) {
  8709. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8710. return 0;
  8711. }
  8712. duel_create(sd, maxpl);
  8713. } else {
  8714. target_sd = map_nick2sd((char *)message);
  8715. if(target_sd != NULL) {
  8716. if((newduel = duel_create(sd, 2)) != -1) {
  8717. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8718. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8719. return 0;
  8720. }
  8721. duel_invite(newduel, sd, target_sd);
  8722. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8723. }
  8724. } else {
  8725. // "Duel: Player not found."
  8726. clif_displaymessage(fd, msg_txt(352));
  8727. return 0;
  8728. }
  8729. }
  8730. } else
  8731. duel_create(sd, 0);
  8732. return 0;
  8733. }
  8734. int atcommand_leave(
  8735. const int fd, struct map_session_data* sd,
  8736. const char* command, const char* message)
  8737. {
  8738. if(sd->duel_group <= 0) {
  8739. // "Duel: @leave without @duel."
  8740. clif_displaymessage(fd, msg_txt(358));
  8741. return 0;
  8742. }
  8743. duel_leave(sd->duel_group, sd);
  8744. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8745. return 0;
  8746. }
  8747. int atcommand_accept(
  8748. const int fd, struct map_session_data* sd,
  8749. const char* command, const char* message)
  8750. {
  8751. char output[256];
  8752. if(!duel_checktime(sd)) {
  8753. // "Duel: You can take part in duel only one time per %d minutes."
  8754. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8755. clif_displaymessage(fd, output);
  8756. return 0;
  8757. }
  8758. if(sd->duel_invite <= 0) {
  8759. // "Duel: @accept without invititation."
  8760. clif_displaymessage(fd, msg_txt(360));
  8761. return 0;
  8762. }
  8763. duel_accept(sd->duel_invite, sd);
  8764. // "Duel: Invitation has been accepted."
  8765. clif_displaymessage(fd, msg_txt(361));
  8766. return 0;
  8767. }
  8768. int atcommand_reject(
  8769. const int fd, struct map_session_data* sd,
  8770. const char* command, const char* message)
  8771. {
  8772. if(sd->duel_invite <= 0) {
  8773. // "Duel: @reject without invititation."
  8774. clif_displaymessage(fd, msg_txt(362));
  8775. return 0;
  8776. }
  8777. duel_reject(sd->duel_invite, sd);
  8778. // "Duel: Invitation has been rejected."
  8779. clif_displaymessage(fd, msg_txt(363));
  8780. return 0;
  8781. }
  8782. /*===================================
  8783. * Away message (@away, @aw) [LuzZza]
  8784. *-----------------------------------
  8785. */
  8786. int atcommand_away(
  8787. const int fd, struct map_session_data* sd,
  8788. const char* command, const char* message)
  8789. {
  8790. if(strlen(message) > 0) {
  8791. if(strlen(message) > 128)
  8792. return -1;
  8793. strcpy(sd->away_message, message);
  8794. //"Away automessage has been activated."
  8795. clif_displaymessage(fd, msg_txt(546));
  8796. } else {
  8797. if(strlen(sd->away_message) > 0) {
  8798. sd->away_message[0] = 0;
  8799. //"Away automessage has been disabled."
  8800. clif_displaymessage(fd, msg_txt(547));
  8801. return 0;
  8802. }
  8803. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8804. clif_displaymessage(fd, msg_txt(548));
  8805. }
  8806. return 0;
  8807. }
  8808. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8809. int atcommand_clone(
  8810. const int fd, struct map_session_data* sd,
  8811. const char* command, const char* message)
  8812. {
  8813. int x=0,y=0,flag=0,master=0,i=0;
  8814. struct map_session_data *pl_sd=NULL;
  8815. if (!message || !*message) {
  8816. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8817. return 0;
  8818. }
  8819. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8820. clif_displaymessage(fd, msg_txt(3));
  8821. return 0;
  8822. }
  8823. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8824. clif_displaymessage(fd, msg_txt(126));
  8825. return 0;
  8826. }
  8827. if (strcmpi(command, "@clone") == 0)
  8828. flag = 1;
  8829. else if (strcmpi(command, "@slaveclone") == 0) {
  8830. flag = 2;
  8831. master = sd->bl.id;
  8832. if (battle_config.atc_slave_clone_limit
  8833. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8834. clif_displaymessage(fd, msg_txt(127));
  8835. return 0;
  8836. }
  8837. }
  8838. do {
  8839. x = sd->bl.x + (rand() % 10 - 5);
  8840. y = sd->bl.y + (rand() % 10 - 5);
  8841. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8842. if (i >= 10) {
  8843. x = sd->bl.x;
  8844. y = sd->bl.y;
  8845. }
  8846. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8847. clif_displaymessage(fd, msg_txt(128+flag*2));
  8848. return 0;
  8849. }
  8850. clif_displaymessage(fd, msg_txt(129+flag*2));
  8851. return 0;
  8852. }
  8853. /*===================================
  8854. * Main chat [LuzZza]
  8855. * Usage: @main <on|off|message>
  8856. *-----------------------------------
  8857. */
  8858. int atcommand_main(
  8859. const int fd, struct map_session_data* sd,
  8860. const char* command, const char* message)
  8861. {
  8862. if(strlen(message) > 0) {
  8863. if(strcmpi(message, "on") == 0) {
  8864. if(!sd->state.mainchat) {
  8865. sd->state.mainchat = 1;
  8866. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8867. } else {
  8868. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8869. }
  8870. } else if(strcmpi(message, "off") == 0) {
  8871. if(sd->state.mainchat) {
  8872. sd->state.mainchat = 0;
  8873. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8874. } else {
  8875. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8876. }
  8877. } else {
  8878. if(!sd->state.mainchat) {
  8879. sd->state.mainchat = 1;
  8880. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8881. }
  8882. if (sd->sc.data[SC_NOCHAT].timer != -1) {
  8883. clif_displaymessage(fd, msg_txt(387));
  8884. return -1;
  8885. }
  8886. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8887. // I use 0xFE000000 color for signalizing that this message is
  8888. // main chat message. 0xFE000000 is invalid color, same using
  8889. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8890. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8891. }
  8892. } else {
  8893. if(sd->state.mainchat)
  8894. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8895. clif_displaymessage(fd, msg_txt(384));
  8896. else
  8897. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8898. clif_displaymessage(fd, msg_txt(385));
  8899. }
  8900. return 0;
  8901. }
  8902. /*=====================================
  8903. * Autorejecting Invites/Deals [LuzZza]
  8904. * Usage: @noask
  8905. *-------------------------------------
  8906. */
  8907. int atcommand_noask(
  8908. const int fd, struct map_session_data* sd,
  8909. const char* command, const char* message)
  8910. {
  8911. if(sd->state.noask) {
  8912. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  8913. sd->state.noask = 0;
  8914. } else {
  8915. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  8916. sd->state.noask = 1;
  8917. }
  8918. return 0;
  8919. }
  8920. /*=====================================
  8921. * Send a @request message to all GMs of lowest_gm_level.
  8922. * Usage: @request <petition>
  8923. *-------------------------------------
  8924. */
  8925. int atcommand_request(
  8926. const int fd, struct map_session_data* sd,
  8927. const char* command, const char* message)
  8928. {
  8929. if (!message || !*message) {
  8930. clif_displaymessage(sd->fd,msg_txt(277));
  8931. return -1;
  8932. }
  8933. sprintf(atcmd_output, msg_txt(278), message);
  8934. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  8935. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  8936. clif_displaymessage(sd->fd,msg_txt(279));
  8937. return 0;
  8938. }
  8939. void do_init_atcommand() {
  8940. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8941. duel_count = 0;
  8942. memset(&duel_list[0], 0, sizeof(duel_list));
  8943. return;
  8944. }
  8945. void do_final_atcommand() {
  8946. users_db->destroy(users_db,NULL);
  8947. }