atcommand.c 281 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "atcommand.h"
  14. #include "battle.h"
  15. #include "chat.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "intif.h"
  19. #include "itemdb.h"
  20. #include "log.h"
  21. #include "map.h"
  22. #include "pc.h"
  23. #include "status.h"
  24. #include "skill.h"
  25. #include "mob.h"
  26. #include "npc.h"
  27. #include "pet.h"
  28. #include "homunculus.h"
  29. #include "mercenary.h"
  30. #include "party.h"
  31. #include "guild.h"
  32. #include "script.h"
  33. #include "trade.h"
  34. #include "unit.h"
  35. #ifndef TXT_ONLY
  36. #include "mail.h"
  37. #endif
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. #include <string.h>
  41. #include <math.h>
  42. // extern variables
  43. char atcommand_symbol = '@'; // first char of the commands
  44. char charcommand_symbol = '#';
  45. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  46. // local declarations
  47. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  48. typedef struct AtCommandInfo
  49. {
  50. const char* command;
  51. int level;
  52. int level2;
  53. AtCommandFunc func;
  54. } AtCommandInfo;
  55. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  56. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  57. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message);
  58. /*=========================================
  59. * Generic variables
  60. *-----------------------------------------*/
  61. char atcmd_output[200];
  62. char atcmd_player_name[NAME_LENGTH];
  63. char atcmd_temp[100];
  64. // compare function for sorting high to lowest
  65. int hightolow_compare (const void * a, const void * b)
  66. {
  67. return ( *(int*)b - *(int*)a );
  68. }
  69. // compare function for sorting lowest to highest
  70. int lowtohigh_compare (const void * a, const void * b)
  71. {
  72. return ( *(int*)a - *(int*)b );
  73. }
  74. //-----------------------------------------------------------
  75. // Return the message string of the specified number by [Yor]
  76. //-----------------------------------------------------------
  77. char* msg_txt(int msg_number)
  78. {
  79. if (msg_number >= 0 && msg_number < MAX_MSG &&
  80. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  81. return msg_table[msg_number];
  82. return "??";
  83. }
  84. //-----------------------------------------------------------
  85. // Returns Players title (from msg_athena.conf) [Lupus]
  86. //-----------------------------------------------------------
  87. static char* player_title_txt(int level)
  88. {
  89. const char* format;
  90. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  91. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  92. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  93. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  94. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  95. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  96. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  97. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  98. : "";
  99. sprintf(atcmd_temp, format, level);
  100. return atcmd_temp;
  101. }
  102. /*==========================================
  103. * Read Message Data
  104. *------------------------------------------*/
  105. int msg_config_read(const char* cfgName)
  106. {
  107. int msg_number;
  108. char line[1024], w1[1024], w2[1024];
  109. FILE *fp;
  110. static int called = 1;
  111. if ((fp = fopen(cfgName, "r")) == NULL) {
  112. ShowError("Messages file not found: %s\n", cfgName);
  113. return 1;
  114. }
  115. if ((--called) == 0)
  116. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  117. while(fgets(line, sizeof(line), fp))
  118. {
  119. if (line[0] == '/' && line[1] == '/')
  120. continue;
  121. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  122. continue;
  123. if (strcmpi(w1, "import") == 0)
  124. msg_config_read(w2);
  125. else
  126. {
  127. msg_number = atoi(w1);
  128. if (msg_number >= 0 && msg_number < MAX_MSG)
  129. {
  130. if (msg_table[msg_number] != NULL)
  131. aFree(msg_table[msg_number]);
  132. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  133. strcpy(msg_table[msg_number],w2);
  134. }
  135. }
  136. }
  137. fclose(fp);
  138. return 0;
  139. }
  140. /*==========================================
  141. * Cleanup Message Data
  142. *------------------------------------------*/
  143. void do_final_msg(void)
  144. {
  145. int i;
  146. for (i = 0; i < MAX_MSG; i++)
  147. aFree(msg_table[i]);
  148. }
  149. /*==========================================
  150. * @send (used for testing packet sends from the client)
  151. *------------------------------------------*/
  152. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  153. {
  154. int len=0,off,end,type;
  155. long num;
  156. (void)command; // not used
  157. // read message type as hex number (without the 0x)
  158. if(!message || !*message ||
  159. !((sscanf(message, "len %x", &type)==1 && (len=1))
  160. || sscanf(message, "%x", &type)==1) )
  161. {
  162. clif_displaymessage(fd, "Usage:");
  163. clif_displaymessage(fd, " @send len <packet hex number>");
  164. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  165. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  166. return -1;
  167. }
  168. #define PARSE_ERROR(error,p) \
  169. {\
  170. clif_displaymessage(fd, (error));\
  171. sprintf(atcmd_output, ">%s", (p));\
  172. clif_displaymessage(fd, atcmd_output);\
  173. }
  174. //define PARSE_ERROR
  175. #define CHECK_EOS(p) \
  176. if(*(p) == 0){\
  177. clif_displaymessage(fd, "Unexpected end of string");\
  178. return -1;\
  179. }
  180. //define CHECK_EOS
  181. #define SKIP_VALUE(p) \
  182. {\
  183. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  184. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  185. }
  186. //define SKIP_VALUE
  187. #define GET_VALUE(p,num) \
  188. {\
  189. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  190. PARSE_ERROR("Invalid number in:",(p));\
  191. return -1;\
  192. }\
  193. }
  194. //define GET_VALUE
  195. if (type > 0 && type < MAX_PACKET_DB) {
  196. if(len)
  197. {// show packet length
  198. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  199. clif_displaymessage(fd, atcmd_output);
  200. return 0;
  201. }
  202. len=packet_db[sd->packet_ver][type].len;
  203. off=2;
  204. if(len == 0)
  205. {// unknown packet - ERROR
  206. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  207. clif_displaymessage(fd, atcmd_output);
  208. return -1;
  209. } else if(len == -1)
  210. {// dynamic packet
  211. len=SHRT_MAX-4; // maximum length
  212. off=4;
  213. }
  214. WFIFOHEAD(fd, len);
  215. WFIFOW(fd,0)=TOW(type);
  216. // parse packet contents
  217. SKIP_VALUE(message);
  218. while(*message != 0 && off < len){
  219. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  220. {// default (byte)
  221. GET_VALUE(message,num);
  222. WFIFOB(fd,off)=TOB(num);
  223. ++off;
  224. } else if(TOUPPER(*message) == 'B')
  225. {// byte
  226. ++message;
  227. GET_VALUE(message,num);
  228. WFIFOB(fd,off)=TOB(num);
  229. ++off;
  230. } else if(TOUPPER(*message) == 'W')
  231. {// word (2 bytes)
  232. ++message;
  233. GET_VALUE(message,num);
  234. WFIFOW(fd,off)=TOW(num);
  235. off+=2;
  236. } else if(TOUPPER(*message) == 'L')
  237. {// long word (4 bytes)
  238. ++message;
  239. GET_VALUE(message,num);
  240. WFIFOL(fd,off)=TOL(num);
  241. off+=4;
  242. } else if(TOUPPER(*message) == 'S')
  243. {// string - escapes are valid
  244. // get string length - num <= 0 means not fixed length (default)
  245. ++message;
  246. if(*message == '"'){
  247. num=0;
  248. } else {
  249. GET_VALUE(message,num);
  250. while(*message != '"')
  251. {// find start of string
  252. if(*message == 0 || ISSPACE(*message)){
  253. PARSE_ERROR("Not a string:",message);
  254. return -1;
  255. }
  256. ++message;
  257. }
  258. }
  259. // parse string
  260. ++message;
  261. CHECK_EOS(message);
  262. end=(num<=0? 0: min(off+((int)num),len));
  263. for(; *message != '"' && (off < end || end == 0); ++off){
  264. if(*message == '\\'){
  265. ++message;
  266. CHECK_EOS(message);
  267. switch(*message){
  268. case 'a': num=0x07; break; // Bell
  269. case 'b': num=0x08; break; // Backspace
  270. case 't': num=0x09; break; // Horizontal tab
  271. case 'n': num=0x0A; break; // Line feed
  272. case 'v': num=0x0B; break; // Vertical tab
  273. case 'f': num=0x0C; break; // Form feed
  274. case 'r': num=0x0D; break; // Carriage return
  275. case 'e': num=0x1B; break; // Escape
  276. default: num=*message; break;
  277. case 'x': // Hexadecimal
  278. {
  279. ++message;
  280. CHECK_EOS(message);
  281. if(!ISXDIGIT(*message)){
  282. PARSE_ERROR("Not a hexadecimal digit:",message);
  283. return -1;
  284. }
  285. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  286. if(ISXDIGIT(*message)){
  287. ++message;
  288. CHECK_EOS(message);
  289. num<<=8;
  290. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  291. }
  292. WFIFOB(fd,off)=TOB(num);
  293. ++message;
  294. CHECK_EOS(message);
  295. continue;
  296. }
  297. case '0':
  298. case '1':
  299. case '2':
  300. case '3':
  301. case '4':
  302. case '5':
  303. case '6':
  304. case '7': // Octal
  305. {
  306. num=*message-'0'; // 1st octal digit
  307. ++message;
  308. CHECK_EOS(message);
  309. if(ISDIGIT(*message) && *message < '8'){
  310. num<<=3;
  311. num+=*message-'0'; // 2nd octal digit
  312. ++message;
  313. CHECK_EOS(message);
  314. if(ISDIGIT(*message) && *message < '8'){
  315. num<<=3;
  316. num+=*message-'0'; // 3rd octal digit
  317. ++message;
  318. CHECK_EOS(message);
  319. }
  320. }
  321. WFIFOB(fd,off)=TOB(num);
  322. continue;
  323. }
  324. }
  325. } else
  326. num=*message;
  327. WFIFOB(fd,off)=TOB(num);
  328. ++message;
  329. CHECK_EOS(message);
  330. }//for
  331. while(*message != '"')
  332. {// ignore extra characters
  333. ++message;
  334. CHECK_EOS(message);
  335. }
  336. // terminate the string
  337. if(off < end)
  338. {// fill the rest with 0's
  339. memset(WFIFOP(fd,off),0,end-off);
  340. off=end;
  341. }
  342. } else
  343. {// unknown
  344. PARSE_ERROR("Unknown type of value in:",message);
  345. return -1;
  346. }
  347. SKIP_VALUE(message);
  348. }
  349. if(packet_db[sd->packet_ver][type].len == -1)
  350. {// send dynamic packet
  351. WFIFOW(fd,2)=TOW(off);
  352. WFIFOSET(fd,off);
  353. } else
  354. {// send static packet
  355. if(off < len)
  356. memset(WFIFOP(fd,off),0,len-off);
  357. WFIFOSET(fd,len);
  358. }
  359. } else {
  360. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  361. return -1;
  362. }
  363. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  364. clif_displaymessage(fd, atcmd_output);
  365. return 0;
  366. #undef PARSE_ERROR
  367. #undef CHECK_EOS
  368. #undef SKIP_VALUE
  369. #undef GET_VALUE
  370. }
  371. /*==========================================
  372. * @rura, @warp, @mapmove
  373. *------------------------------------------*/
  374. int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  375. {
  376. char map_name[MAP_NAME_LENGTH_EXT];
  377. unsigned short mapindex;
  378. int x = 0, y = 0;
  379. int m = -1;
  380. nullpo_retr(-1, sd);
  381. memset(map_name, '\0', sizeof(map_name));
  382. if (!message || !*message ||
  383. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  384. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  385. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  386. return -1;
  387. }
  388. mapindex = mapindex_name2id(map_name);
  389. if (mapindex)
  390. m = map_mapindex2mapid(mapindex);
  391. if (!mapindex) { // m < 0 means on different server! [Kevin]
  392. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  393. return -1;
  394. }
  395. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  396. { //This is to prevent the pc_setpos call from printing an error.
  397. clif_displaymessage(fd, msg_txt(2));
  398. x = y = 0; //Invalid cell, use random spot.
  399. }
  400. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  401. clif_displaymessage(fd, msg_txt(247));
  402. return -1;
  403. }
  404. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  405. clif_displaymessage(fd, msg_txt(248));
  406. return -1;
  407. }
  408. if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
  409. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  410. return -1;
  411. }
  412. clif_displaymessage(fd, msg_txt(0)); // Warped.
  413. return 0;
  414. }
  415. /*==========================================
  416. * Displays where a character is. Corrected version by Silent. [Skotlex]
  417. *------------------------------------------*/
  418. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  419. {
  420. struct map_session_data* pl_sd;
  421. nullpo_retr(-1, sd);
  422. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  423. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  424. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  425. return -1;
  426. }
  427. pl_sd = map_nick2sd(atcmd_player_name);
  428. if( pl_sd == NULL
  429. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  430. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  431. ) {
  432. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  433. return -1;
  434. }
  435. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  436. clif_displaymessage(fd, atcmd_output);
  437. return 0;
  438. }
  439. /*==========================================
  440. *
  441. *------------------------------------------*/
  442. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  443. {
  444. struct map_session_data *pl_sd = NULL;
  445. nullpo_retr(-1, sd);
  446. if (!message || !*message) {
  447. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  448. return -1;
  449. }
  450. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  451. {
  452. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  453. return -1;
  454. }
  455. if (pl_sd == sd)
  456. {
  457. clif_displaymessage(fd, "But you are already where you are...");
  458. return -1;
  459. }
  460. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  461. {
  462. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  463. return -1;
  464. }
  465. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  466. {
  467. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  468. return -1;
  469. }
  470. if( pc_isdead(sd) )
  471. {
  472. clif_displaymessage(fd, "You cannot use this command when dead.");
  473. return -1;
  474. }
  475. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  476. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  477. clif_displaymessage(fd, atcmd_output);
  478. return 0;
  479. }
  480. /*==========================================
  481. *
  482. *------------------------------------------*/
  483. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  484. {
  485. int x = 0, y = 0;
  486. nullpo_retr(-1, sd);
  487. memset(atcmd_output, '\0', sizeof(atcmd_output));
  488. sscanf(message, "%d %d", &x, &y);
  489. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  490. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  491. return -1;
  492. }
  493. if( pc_isdead(sd) )
  494. {
  495. clif_displaymessage(fd, "You cannot use this command when dead.");
  496. return -1;
  497. }
  498. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  499. { //This is to prevent the pc_setpos call from printing an error.
  500. clif_displaymessage(fd, msg_txt(2));
  501. x = y = 0; //Invalid cell, use random spot.
  502. }
  503. pc_setpos(sd, sd->mapindex, x, y, 3);
  504. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  505. clif_displaymessage(fd, atcmd_output);
  506. return 0;
  507. }
  508. /*==========================================
  509. * @who3 = Player name, his location
  510. *------------------------------------------*/
  511. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  512. {
  513. char temp0[100];
  514. struct map_session_data *pl_sd;
  515. struct s_mapiterator* iter;
  516. int j, count;
  517. int pl_GM_level, GM_level;
  518. char match_text[100];
  519. char player_name[NAME_LENGTH];
  520. nullpo_retr(-1, sd);
  521. memset(atcmd_output, '\0', sizeof(atcmd_output));
  522. memset(match_text, '\0', sizeof(match_text));
  523. memset(player_name, '\0', sizeof(player_name));
  524. if (sscanf(message, "%99[^\n]", match_text) < 1)
  525. strcpy(match_text, "");
  526. for (j = 0; match_text[j]; j++)
  527. match_text[j] = TOLOWER(match_text[j]);
  528. count = 0;
  529. GM_level = pc_isGM(sd);
  530. iter = mapit_getallusers();
  531. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  532. {
  533. pl_GM_level = pc_isGM(pl_sd);
  534. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  535. {// you can look only lower or same level
  536. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  537. for (j = 0; player_name[j]; j++)
  538. player_name[j] = TOLOWER(player_name[j]);
  539. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  540. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  541. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  542. } else {
  543. atcmd_output[0]=0;
  544. }
  545. //Player name
  546. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  547. strcat(atcmd_output,temp0);
  548. //Player title, if exists
  549. if (pl_GM_level > 0) {
  550. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  551. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  552. strcat(atcmd_output,temp0);
  553. }
  554. //Players Location: map x y
  555. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  556. strcat(atcmd_output,temp0);
  557. clif_displaymessage(fd, atcmd_output);
  558. count++;
  559. }
  560. }
  561. }
  562. mapit_free(iter);
  563. if (count == 0)
  564. clif_displaymessage(fd, msg_txt(28)); // No player found.
  565. else if (count == 1)
  566. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  567. else {
  568. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  569. clif_displaymessage(fd, atcmd_output);
  570. }
  571. return 0;
  572. }
  573. /*==========================================
  574. * Player name, BLevel, Job,
  575. *------------------------------------------*/
  576. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  577. {
  578. char temp0[100];
  579. struct map_session_data *pl_sd;
  580. struct s_mapiterator* iter;
  581. int j, count;
  582. int pl_GM_level, GM_level;
  583. char match_text[100];
  584. char player_name[NAME_LENGTH];
  585. nullpo_retr(-1, sd);
  586. memset(atcmd_output, '\0', sizeof(atcmd_output));
  587. memset(match_text, '\0', sizeof(match_text));
  588. memset(player_name, '\0', sizeof(player_name));
  589. if (sscanf(message, "%99[^\n]", match_text) < 1)
  590. strcpy(match_text, "");
  591. for (j = 0; match_text[j]; j++)
  592. match_text[j] = TOLOWER(match_text[j]);
  593. count = 0;
  594. GM_level = pc_isGM(sd);
  595. iter = mapit_getallusers();
  596. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  597. {
  598. pl_GM_level = pc_isGM(pl_sd);
  599. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  600. {// you can look only lower or same level
  601. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  602. for (j = 0; player_name[j]; j++)
  603. player_name[j] = TOLOWER(player_name[j]);
  604. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  605. //Players Name
  606. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  607. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  608. //Player title, if exists
  609. if (pl_GM_level > 0) {
  610. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  611. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  612. strcat(atcmd_output,temp0);
  613. }
  614. //Players Base Level / Job name
  615. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  616. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  617. strcat(atcmd_output,temp0);
  618. clif_displaymessage(fd, atcmd_output);
  619. count++;
  620. }
  621. }
  622. }
  623. mapit_free(iter);
  624. if (count == 0)
  625. clif_displaymessage(fd, msg_txt(28)); // No player found.
  626. else if (count == 1)
  627. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  628. else {
  629. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  630. clif_displaymessage(fd, atcmd_output);
  631. }
  632. return 0;
  633. }
  634. /*==========================================
  635. * Player name, Playrs Party / Guild name
  636. *------------------------------------------*/
  637. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  638. {
  639. char temp0[100];
  640. struct map_session_data *pl_sd;
  641. struct s_mapiterator* iter;
  642. int j, count;
  643. int pl_GM_level, GM_level;
  644. char match_text[100];
  645. char player_name[NAME_LENGTH];
  646. struct guild *g;
  647. struct party_data *p;
  648. nullpo_retr(-1, sd);
  649. memset(temp0, '\0', sizeof(temp0));
  650. memset(atcmd_output, '\0', sizeof(atcmd_output));
  651. memset(match_text, '\0', sizeof(match_text));
  652. memset(player_name, '\0', sizeof(player_name));
  653. if (sscanf(message, "%99[^\n]", match_text) < 1)
  654. strcpy(match_text, "");
  655. for (j = 0; match_text[j]; j++)
  656. match_text[j] = TOLOWER(match_text[j]);
  657. count = 0;
  658. GM_level = pc_isGM(sd);
  659. iter = mapit_getallusers();
  660. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  661. {
  662. pl_GM_level = pc_isGM(pl_sd);
  663. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  664. {// you can look only lower or same level
  665. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  666. for (j = 0; player_name[j]; j++)
  667. player_name[j] = TOLOWER(player_name[j]);
  668. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  669. g = guild_search(pl_sd->status.guild_id);
  670. p = party_search(pl_sd->status.party_id);
  671. //Players Name
  672. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  673. //Player title, if exists
  674. if (pl_GM_level > 0) {
  675. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  676. strcat(atcmd_output,temp0);
  677. }
  678. //Players Party if exists
  679. if (p != NULL) {
  680. //sprintf(temp0," | Party: '%s'", p->name);
  681. sprintf(temp0, msg_txt(335), p->party.name);
  682. strcat(atcmd_output,temp0);
  683. }
  684. //Players Guild if exists
  685. if (g != NULL) {
  686. //sprintf(temp0," | Guild: '%s'", g->name);
  687. sprintf(temp0, msg_txt(336), g->name);
  688. strcat(atcmd_output,temp0);
  689. }
  690. clif_displaymessage(fd, atcmd_output);
  691. count++;
  692. }
  693. }
  694. }
  695. mapit_free(iter);
  696. if (count == 0)
  697. clif_displaymessage(fd, msg_txt(28)); // No player found.
  698. else if (count == 1)
  699. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  700. else {
  701. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  702. clif_displaymessage(fd, atcmd_output);
  703. }
  704. return 0;
  705. }
  706. /*==========================================
  707. *
  708. *------------------------------------------*/
  709. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  710. {
  711. struct map_session_data *pl_sd;
  712. struct s_mapiterator* iter;
  713. int count;
  714. int pl_GM_level, GM_level;
  715. int map_id;
  716. char map_name[MAP_NAME_LENGTH_EXT];
  717. memset(atcmd_output, '\0', sizeof(atcmd_output));
  718. memset(map_name, '\0', sizeof(map_name));
  719. if (!message || !*message)
  720. map_id = sd->bl.m;
  721. else {
  722. sscanf(message, "%15s", map_name);
  723. if ((map_id = map_mapname2mapid(map_name)) < 0)
  724. map_id = sd->bl.m;
  725. }
  726. count = 0;
  727. GM_level = pc_isGM(sd);
  728. iter = mapit_getallusers();
  729. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  730. {
  731. pl_GM_level = pc_isGM(pl_sd);
  732. if( pl_sd->bl.m != map_id )
  733. continue;
  734. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  735. continue;
  736. if (pl_GM_level > 0)
  737. 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);
  738. else
  739. 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);
  740. clif_displaymessage(fd, atcmd_output);
  741. count++;
  742. }
  743. mapit_free(iter);
  744. if (count == 0)
  745. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  746. else if (count == 1)
  747. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  748. else {
  749. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  750. }
  751. clif_displaymessage(fd, atcmd_output);
  752. return 0;
  753. }
  754. /*==========================================
  755. *
  756. *------------------------------------------*/
  757. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  758. {
  759. struct map_session_data *pl_sd;
  760. struct s_mapiterator* iter;
  761. int count;
  762. int pl_GM_level, GM_level;
  763. int map_id = 0;
  764. char map_name[MAP_NAME_LENGTH_EXT];
  765. nullpo_retr(-1, sd);
  766. memset(atcmd_output, '\0', sizeof(atcmd_output));
  767. memset(map_name, '\0', sizeof(map_name));
  768. if (!message || !*message)
  769. map_id = sd->bl.m;
  770. else {
  771. sscanf(message, "%15s", map_name);
  772. if ((map_id = map_mapname2mapid(map_name)) < 0)
  773. map_id = sd->bl.m;
  774. }
  775. count = 0;
  776. GM_level = pc_isGM(sd);
  777. iter = mapit_getallusers();
  778. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  779. {
  780. pl_GM_level = pc_isGM(pl_sd);
  781. if( pl_sd->bl.m != map_id )
  782. continue;
  783. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  784. continue;
  785. if (pl_GM_level > 0)
  786. 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);
  787. else
  788. 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);
  789. clif_displaymessage(fd, atcmd_output);
  790. count++;
  791. }
  792. mapit_free(iter);
  793. if (count == 0)
  794. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  795. else if (count == 1)
  796. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  797. else {
  798. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  799. }
  800. clif_displaymessage(fd, atcmd_output);
  801. return 0;
  802. }
  803. /*==========================================
  804. *
  805. *------------------------------------------*/
  806. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  807. {
  808. char temp0[100];
  809. char temp1[100];
  810. struct map_session_data *pl_sd;
  811. struct s_mapiterator* iter;
  812. int count;
  813. int pl_GM_level, GM_level;
  814. int map_id = 0;
  815. char map_name[MAP_NAME_LENGTH_EXT];
  816. struct guild *g;
  817. struct party_data *p;
  818. nullpo_retr(-1, sd);
  819. memset(temp0, '\0', sizeof(temp0));
  820. memset(temp1, '\0', sizeof(temp1));
  821. memset(atcmd_output, '\0', sizeof(atcmd_output));
  822. memset(map_name, '\0', sizeof(map_name));
  823. if (!message || !*message)
  824. map_id = sd->bl.m;
  825. else {
  826. sscanf(message, "%15s", map_name);
  827. if ((map_id = map_mapname2mapid(map_name)) < 0)
  828. map_id = sd->bl.m;
  829. }
  830. count = 0;
  831. GM_level = pc_isGM(sd);
  832. iter = mapit_getallusers();
  833. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  834. {
  835. pl_GM_level = pc_isGM(pl_sd);
  836. if( pl_sd->bl.m != map_id )
  837. continue;
  838. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  839. continue;
  840. g = guild_search(pl_sd->status.guild_id);
  841. if (g == NULL)
  842. sprintf(temp1, "None");
  843. else
  844. sprintf(temp1, "%s", g->name);
  845. p = party_search(pl_sd->status.party_id);
  846. if (p == NULL)
  847. sprintf(temp0, "None");
  848. else
  849. sprintf(temp0, "%s", p->party.name);
  850. if (pl_GM_level > 0)
  851. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  852. else
  853. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  854. clif_displaymessage(fd, atcmd_output);
  855. count++;
  856. }
  857. mapit_free(iter);
  858. if (count == 0)
  859. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  860. else if (count == 1)
  861. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  862. else {
  863. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  864. }
  865. clif_displaymessage(fd, atcmd_output);
  866. return 0;
  867. }
  868. /*==========================================
  869. *
  870. *------------------------------------------*/
  871. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  872. {
  873. struct map_session_data* pl_sd;
  874. struct s_mapiterator* iter;
  875. int j, count;
  876. int pl_GM_level, GM_level;
  877. char match_text[200];
  878. char player_name[NAME_LENGTH];
  879. struct guild *g;
  880. struct party_data *p;
  881. nullpo_retr(-1, sd);
  882. memset(atcmd_output, '\0', sizeof(atcmd_output));
  883. memset(match_text, '\0', sizeof(match_text));
  884. memset(player_name, '\0', sizeof(player_name));
  885. if (sscanf(message, "%199[^\n]", match_text) < 1)
  886. strcpy(match_text, "");
  887. for (j = 0; match_text[j]; j++)
  888. match_text[j] = TOLOWER(match_text[j]);
  889. count = 0;
  890. GM_level = pc_isGM(sd);
  891. iter = mapit_getallusers();
  892. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  893. {
  894. pl_GM_level = pc_isGM(pl_sd);
  895. if (!pl_GM_level)
  896. continue;
  897. if (match_text[0])
  898. {
  899. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  900. for (j = 0; player_name[j]; j++)
  901. player_name[j] = TOLOWER(player_name[j]);
  902. // search with no case sensitive
  903. if (strstr(player_name, match_text) == NULL)
  904. continue;
  905. }
  906. if (pl_GM_level > GM_level) {
  907. if (pl_sd->sc.option & OPTION_INVISIBLE)
  908. continue;
  909. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  910. clif_displaymessage(fd, atcmd_output);
  911. count++;
  912. continue;
  913. }
  914. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  915. pl_sd->status.name, pl_GM_level,
  916. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  917. clif_displaymessage(fd, atcmd_output);
  918. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  919. pl_sd->status.base_level,
  920. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  921. clif_displaymessage(fd, atcmd_output);
  922. p = party_search(pl_sd->status.party_id);
  923. g = guild_search(pl_sd->status.guild_id);
  924. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  925. p?p->party.name:"None", g?g->name:"None");
  926. clif_displaymessage(fd, atcmd_output);
  927. count++;
  928. }
  929. mapit_free(iter);
  930. if (count == 0)
  931. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  932. else if (count == 1)
  933. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  934. else {
  935. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  936. clif_displaymessage(fd, atcmd_output);
  937. }
  938. return 0;
  939. }
  940. /*==========================================
  941. *
  942. *------------------------------------------*/
  943. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  944. {
  945. nullpo_retr(-1, sd);
  946. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  947. if (sd->status.pet_id > 0 && sd->pd)
  948. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  949. chrif_save(sd,0);
  950. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  951. return 0;
  952. }
  953. /*==========================================
  954. *
  955. *------------------------------------------*/
  956. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  957. {
  958. int m;
  959. nullpo_retr(-1, sd);
  960. m = map_mapindex2mapid(sd->status.save_point.map);
  961. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  962. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  963. return -1;
  964. }
  965. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  966. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  967. return -1;
  968. }
  969. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  970. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  971. return 0;
  972. }
  973. /*==========================================
  974. *
  975. *------------------------------------------*/
  976. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  977. {
  978. int speed;
  979. nullpo_retr(-1, sd);
  980. memset(atcmd_output, '\0', sizeof(atcmd_output));
  981. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  982. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  983. clif_displaymessage(fd, atcmd_output);
  984. return -1;
  985. }
  986. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  987. status_calc_bl(&sd->bl, SCB_SPEED);
  988. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  989. return 0;
  990. }
  991. /*==========================================
  992. *
  993. *------------------------------------------*/
  994. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  995. {
  996. nullpo_retr(-1, sd);
  997. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  998. return -1;
  999. if (storage_storageopen(sd) == 1)
  1000. { //Already open.
  1001. clif_displaymessage(fd, msg_txt(250));
  1002. return -1;
  1003. }
  1004. clif_displaymessage(fd, "Storage opened.");
  1005. return 0;
  1006. }
  1007. /*==========================================
  1008. *
  1009. *------------------------------------------*/
  1010. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1011. {
  1012. nullpo_retr(-1, sd);
  1013. if (!sd->status.guild_id) {
  1014. clif_displaymessage(fd, msg_txt(252));
  1015. return -1;
  1016. }
  1017. if (sd->npc_id || sd->vender_id || sd->state.trading)
  1018. return -1;
  1019. if (sd->state.storage_flag == 1) {
  1020. clif_displaymessage(fd, msg_txt(250));
  1021. return -1;
  1022. }
  1023. if (sd->state.storage_flag == 2) {
  1024. clif_displaymessage(fd, msg_txt(251));
  1025. return -1;
  1026. }
  1027. storage_guild_storageopen(sd);
  1028. clif_displaymessage(fd, "Guild storage opened.");
  1029. return 0;
  1030. }
  1031. /*==========================================
  1032. *
  1033. *------------------------------------------*/
  1034. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1035. {
  1036. int param1 = 0, param2 = 0, param3 = 0;
  1037. nullpo_retr(-1, sd);
  1038. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1039. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1040. return -1;
  1041. }
  1042. sd->sc.opt1 = param1;
  1043. sd->sc.opt2 = param2;
  1044. pc_setoption(sd, param3);
  1045. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1046. return 0;
  1047. }
  1048. /*==========================================
  1049. *
  1050. *------------------------------------------*/
  1051. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1052. {
  1053. nullpo_retr(-1, sd);
  1054. if (sd->sc.option & OPTION_INVISIBLE) {
  1055. sd->sc.option &= ~OPTION_INVISIBLE;
  1056. if (sd->disguise)
  1057. status_set_viewdata(&sd->bl, sd->disguise);
  1058. else
  1059. status_set_viewdata(&sd->bl, sd->status.class_);
  1060. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1061. } else {
  1062. sd->sc.option |= OPTION_INVISIBLE;
  1063. sd->vd.class_ = INVISIBLE_CLASS;
  1064. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1065. }
  1066. clif_changeoption(&sd->bl);
  1067. return 0;
  1068. }
  1069. /*==========================================
  1070. * Changes a character's class
  1071. *------------------------------------------*/
  1072. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1073. {
  1074. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1075. int job = 0, upper = 0;
  1076. nullpo_retr(-1, sd);
  1077. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1078. {
  1079. int i, found = 0;
  1080. const struct { char name[16]; int id; } jobs[] = {
  1081. { "novice", 0 },
  1082. { "swordsman", 1 },
  1083. { "mage", 2 },
  1084. { "archer", 3 },
  1085. { "acolyte", 4 },
  1086. { "merchant", 5 },
  1087. { "thief", 6 },
  1088. { "knight", 7 },
  1089. { "priest", 8 },
  1090. { "priestess", 8 },
  1091. { "wizard", 9 },
  1092. { "blacksmith", 10 },
  1093. { "hunter", 11 },
  1094. { "assassin", 12 },
  1095. { "crusader", 14 },
  1096. { "monk", 15 },
  1097. { "sage", 16 },
  1098. { "rogue", 17 },
  1099. { "alchemist", 18 },
  1100. { "bard", 19 },
  1101. { "dancer", 20 },
  1102. { "super novice", 23 },
  1103. { "supernovice", 23 },
  1104. { "gunslinger", 24 },
  1105. { "gunner", 24 },
  1106. { "ninja", 25 },
  1107. { "high novice", 4001 },
  1108. { "swordsman high", 4002 },
  1109. { "mage high", 4003 },
  1110. { "archer high", 4004 },
  1111. { "acolyte high", 4005 },
  1112. { "merchant high", 4006 },
  1113. { "thief high", 4007 },
  1114. { "lord knight", 4008 },
  1115. { "high priest", 4009 },
  1116. { "high priestess", 4009 },
  1117. { "high wizard", 4010 },
  1118. { "whitesmith", 4011 },
  1119. { "sniper", 4012 },
  1120. { "assassin cross", 4013 },
  1121. { "paladin", 4015 },
  1122. { "champion", 4016 },
  1123. { "professor", 4017 },
  1124. { "stalker", 4018 },
  1125. { "creator", 4019 },
  1126. { "clown", 4020 },
  1127. { "gypsy", 4021 },
  1128. { "baby novice", 4023 },
  1129. { "baby swordsman", 4024 },
  1130. { "baby mage", 4025 },
  1131. { "baby archer", 4026 },
  1132. { "baby acolyte", 4027 },
  1133. { "baby merchant", 4028 },
  1134. { "baby thief", 4029 },
  1135. { "baby knight", 4030 },
  1136. { "baby priest", 4031 },
  1137. { "baby priestess", 4031 },
  1138. { "baby wizard", 4032 },
  1139. { "baby blacksmith",4033 },
  1140. { "baby hunter", 4034 },
  1141. { "baby assassin", 4035 },
  1142. { "baby crusader", 4037 },
  1143. { "baby monk", 4038 },
  1144. { "baby sage", 4039 },
  1145. { "baby rogue", 4040 },
  1146. { "baby alchemist", 4041 },
  1147. { "baby bard", 4042 },
  1148. { "baby dancer", 4043 },
  1149. { "super baby", 4045 },
  1150. { "taekwon", 4046 },
  1151. { "taekwon boy", 4046 },
  1152. { "taekwon girl", 4046 },
  1153. { "star gladiator", 4047 },
  1154. { "soul linker", 4049 },
  1155. };
  1156. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1157. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1158. job = jobs[i].id;
  1159. upper = 0;
  1160. found = 1;
  1161. break;
  1162. }
  1163. }
  1164. if (!found) {
  1165. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1166. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1167. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1168. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1169. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1170. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1171. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1172. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1173. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1174. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1175. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1176. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1177. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1178. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1179. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1180. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1181. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1182. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1183. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1184. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1185. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1186. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1187. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1188. return -1;
  1189. }
  1190. }
  1191. if (job == 37 ||job == 45)
  1192. return 0;
  1193. if (pcdb_checkid(job))
  1194. {
  1195. if (pc_jobchange(sd, job, upper) == 0)
  1196. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1197. else {
  1198. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1199. return -1;
  1200. }
  1201. } else {
  1202. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1203. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1204. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1205. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1206. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1207. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1208. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1209. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1210. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1211. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1212. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1213. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1214. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1215. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1216. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1217. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1218. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1219. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1220. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1221. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1222. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1223. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1224. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1225. return -1;
  1226. }
  1227. return 0;
  1228. }
  1229. /*==========================================
  1230. *
  1231. *------------------------------------------*/
  1232. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1233. {
  1234. nullpo_retr(-1, sd);
  1235. clif_specialeffect(&sd->bl,450,SELF);
  1236. status_kill(&sd->bl);
  1237. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1238. return 0;
  1239. }
  1240. /*==========================================
  1241. *
  1242. *------------------------------------------*/
  1243. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1244. {
  1245. struct map_session_data *pl_sd;
  1246. nullpo_retr(-1, sd);
  1247. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1248. if (!message || !*message) {
  1249. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1250. return -1;
  1251. }
  1252. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1253. {
  1254. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1255. return -1;
  1256. }
  1257. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1258. { // you can kill only lower or same level
  1259. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1260. return -1;
  1261. }
  1262. status_kill(&pl_sd->bl);
  1263. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1264. if (fd != pl_sd->fd)
  1265. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1266. return 0;
  1267. }
  1268. /*==========================================
  1269. *
  1270. *------------------------------------------*/
  1271. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1272. {
  1273. nullpo_retr(-1, sd);
  1274. if (!status_revive(&sd->bl, 100, 100))
  1275. {
  1276. clif_displaymessage(fd, "You're not dead.");
  1277. return -1;
  1278. }
  1279. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1280. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1281. return 0;
  1282. }
  1283. /*==========================================
  1284. * +kamic [LuzZza]
  1285. *------------------------------------------*/
  1286. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1287. {
  1288. unsigned long color=0;
  1289. nullpo_retr(-1, sd);
  1290. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1291. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1292. if (!message || !*message) {
  1293. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1294. return -1;
  1295. }
  1296. sscanf(message, "%199[^\n]", atcmd_output);
  1297. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1298. } else {
  1299. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1300. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1301. return -1;
  1302. }
  1303. if(color > 0xFFFFFF) {
  1304. clif_displaymessage(fd, "Invalid color.");
  1305. return -1;
  1306. }
  1307. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1308. }
  1309. return 0;
  1310. }
  1311. /*==========================================
  1312. *
  1313. *------------------------------------------*/
  1314. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1315. {
  1316. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1317. nullpo_retr(-1, sd);
  1318. sscanf(message, "%d %d", &hp, &sp);
  1319. // some overflow checks
  1320. if( hp == INT_MIN ) hp++;
  1321. if( sp == INT_MIN ) sp++;
  1322. if ( hp == 0 && sp == 0 ) {
  1323. if (!status_percent_heal(&sd->bl, 100, 100))
  1324. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1325. else
  1326. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1327. return 0;
  1328. }
  1329. if ( hp > 0 && sp >= 0 ) {
  1330. if(!status_heal(&sd->bl, hp, sp, 0))
  1331. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1332. else
  1333. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1334. return 0;
  1335. }
  1336. if ( hp < 0 && sp <= 0 ) {
  1337. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1338. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1339. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1340. return 0;
  1341. }
  1342. //Opposing signs.
  1343. if ( hp ) {
  1344. if (hp > 0)
  1345. status_heal(&sd->bl, hp, 0, 0);
  1346. else {
  1347. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1348. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1349. }
  1350. }
  1351. if ( sp ) {
  1352. if (sp > 0)
  1353. status_heal(&sd->bl, 0, sp, 0);
  1354. else
  1355. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1356. }
  1357. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1358. return 0;
  1359. }
  1360. /*==========================================
  1361. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1362. *------------------------------------------*/
  1363. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1364. {
  1365. char item_name[100];
  1366. int number = 0, item_id, flag;
  1367. struct item item_tmp;
  1368. struct item_data *item_data;
  1369. int get_count, i;
  1370. nullpo_retr(-1, sd);
  1371. memset(item_name, '\0', sizeof(item_name));
  1372. if (!message || !*message || (
  1373. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1374. sscanf(message, "%99s %d", item_name, &number) < 1
  1375. )) {
  1376. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1377. return -1;
  1378. }
  1379. if (number <= 0)
  1380. number = 1;
  1381. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1382. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1383. {
  1384. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1385. return -1;
  1386. }
  1387. item_id = item_data->nameid;
  1388. get_count = number;
  1389. //Check if it's stackable.
  1390. if (!itemdb_isstackable2(item_data))
  1391. get_count = 1;
  1392. for (i = 0; i < number; i += get_count) {
  1393. // if not pet egg
  1394. if (!pet_create_egg(sd, item_id)) {
  1395. memset(&item_tmp, 0, sizeof(item_tmp));
  1396. item_tmp.nameid = item_id;
  1397. item_tmp.identify = 1;
  1398. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1399. clif_additem(sd, 0, 0, flag);
  1400. }
  1401. }
  1402. //Logs (A)dmins items [Lupus]
  1403. if(log_config.enable_logs&0x400)
  1404. log_pick_pc(sd, "A", item_id, number, NULL);
  1405. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1406. return 0;
  1407. }
  1408. /*==========================================
  1409. *
  1410. *------------------------------------------*/
  1411. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1412. {
  1413. struct item item_tmp;
  1414. struct item_data *item_data;
  1415. char item_name[100];
  1416. int item_id, number = 0;
  1417. int identify = 0, refine = 0, attr = 0;
  1418. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1419. int flag;
  1420. int loop, get_count, i;
  1421. nullpo_retr(-1, sd);
  1422. memset(item_name, '\0', sizeof(item_name));
  1423. if (!message || !*message || (
  1424. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1425. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1426. )) {
  1427. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1428. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1429. return -1;
  1430. }
  1431. if (number <= 0)
  1432. number = 1;
  1433. item_id = 0;
  1434. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1435. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1436. item_id = item_data->nameid;
  1437. if (item_id > 500) {
  1438. loop = 1;
  1439. get_count = number;
  1440. if (item_data->type == 4 || item_data->type == 5 ||
  1441. item_data->type == 7 || item_data->type == 8) {
  1442. loop = number;
  1443. get_count = 1;
  1444. if (item_data->type == 7) {
  1445. identify = 1;
  1446. refine = 0;
  1447. }
  1448. if (item_data->type == 8)
  1449. refine = 0;
  1450. if (refine > 10)
  1451. refine = 10;
  1452. } else {
  1453. identify = 1;
  1454. refine = attr = 0;
  1455. }
  1456. for (i = 0; i < loop; i++) {
  1457. memset(&item_tmp, 0, sizeof(item_tmp));
  1458. item_tmp.nameid = item_id;
  1459. item_tmp.identify = identify;
  1460. item_tmp.refine = refine;
  1461. item_tmp.attribute = attr;
  1462. item_tmp.card[0] = c1;
  1463. item_tmp.card[1] = c2;
  1464. item_tmp.card[2] = c3;
  1465. item_tmp.card[3] = c4;
  1466. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1467. clif_additem(sd, 0, 0, flag);
  1468. }
  1469. //Logs (A)dmins items [Lupus]
  1470. if(log_config.enable_logs&0x400)
  1471. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  1472. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1473. } else {
  1474. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1475. return -1;
  1476. }
  1477. return 0;
  1478. }
  1479. /*==========================================
  1480. *
  1481. *------------------------------------------*/
  1482. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1483. {
  1484. int i;
  1485. nullpo_retr(-1, sd);
  1486. for (i = 0; i < MAX_INVENTORY; i++) {
  1487. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1488. //Logs (A)dmins items [Lupus]
  1489. if(log_config.enable_logs&0x400)
  1490. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1491. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  1492. }
  1493. }
  1494. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1495. return 0;
  1496. }
  1497. /*==========================================
  1498. * Atcommand @lvlup
  1499. *------------------------------------------*/
  1500. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1501. {
  1502. int level=0, i=0, status_point=0;
  1503. nullpo_retr(-1, sd);
  1504. level = atoi(message);
  1505. if (!message || !*message || !level) {
  1506. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1507. return -1;
  1508. }
  1509. if (level > 0) {
  1510. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1511. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1512. return -1;
  1513. } // End Addition
  1514. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1515. level = pc_maxbaselv(sd) - sd->status.base_level;
  1516. for (i = 1; i <= level; i++)
  1517. status_point += (sd->status.base_level + i + 14) / 5;
  1518. sd->status.status_point += status_point;
  1519. sd->status.base_level += (unsigned int)level;
  1520. status_percent_heal(&sd->bl, 100, 100);
  1521. clif_misceffect(&sd->bl, 0);
  1522. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1523. } else {
  1524. if (sd->status.base_level == 1) {
  1525. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1526. return -1;
  1527. }
  1528. level*=-1;
  1529. if ((unsigned int)level >= sd->status.base_level)
  1530. level = sd->status.base_level-1;
  1531. for (i = 0; i > -level; i--)
  1532. status_point += (sd->status.base_level + i + 14) / 5;
  1533. if (sd->status.status_point < status_point)
  1534. pc_resetstate(sd);
  1535. if (sd->status.status_point < status_point)
  1536. sd->status.status_point = 0;
  1537. else
  1538. sd->status.status_point -= status_point;
  1539. sd->status.base_level -= (unsigned int)level;
  1540. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1541. }
  1542. clif_updatestatus(sd, SP_STATUSPOINT);
  1543. clif_updatestatus(sd, SP_BASELEVEL);
  1544. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1545. status_calc_pc(sd, 0);
  1546. if(sd->status.party_id)
  1547. party_send_levelup(sd);
  1548. return 0;
  1549. }
  1550. /*==========================================
  1551. *
  1552. *------------------------------------------*/
  1553. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1554. {
  1555. int level=0;
  1556. nullpo_retr(-1, sd);
  1557. level = atoi(message);
  1558. if (!message || !*message || !level) {
  1559. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1560. return -1;
  1561. }
  1562. if (level > 0) {
  1563. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1564. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1565. return -1;
  1566. }
  1567. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1568. level = pc_maxjoblv(sd) - sd->status.job_level;
  1569. sd->status.job_level += (unsigned int)level;
  1570. clif_updatestatus(sd, SP_JOBLEVEL);
  1571. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1572. sd->status.skill_point += level;
  1573. clif_updatestatus(sd, SP_SKILLPOINT);
  1574. status_calc_pc(sd, 0);
  1575. clif_misceffect(&sd->bl, 1);
  1576. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1577. } else {
  1578. if (sd->status.job_level == 1) {
  1579. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1580. return -1;
  1581. }
  1582. level *=-1;
  1583. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1584. level = sd->status.job_level-1;
  1585. sd->status.job_level -= (unsigned int)level;
  1586. clif_updatestatus(sd, SP_JOBLEVEL);
  1587. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1588. if (sd->status.skill_point < level)
  1589. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1590. if (sd->status.skill_point < level)
  1591. sd->status.skill_point = 0;
  1592. else
  1593. sd->status.skill_point -= level;
  1594. clif_updatestatus(sd, SP_SKILLPOINT);
  1595. status_calc_pc(sd, 0);
  1596. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1597. }
  1598. return 0;
  1599. }
  1600. /*==========================================
  1601. * @help
  1602. *------------------------------------------*/
  1603. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1604. {
  1605. char buf[2048], w1[2048], w2[2048];
  1606. int i, gm_level;
  1607. FILE* fp;
  1608. nullpo_retr(-1, sd);
  1609. memset(buf, '\0', sizeof(buf));
  1610. if ((fp = fopen(help_txt, "r")) != NULL) {
  1611. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1612. gm_level = pc_isGM(sd);
  1613. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1614. if (buf[0] == '/' && buf[1] == '/')
  1615. continue;
  1616. for (i = 0; buf[i] != '\0'; i++) {
  1617. if (buf[i] == '\r' || buf[i] == '\n') {
  1618. buf[i] = '\0';
  1619. break;
  1620. }
  1621. }
  1622. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1623. clif_displaymessage(fd, buf);
  1624. else if (gm_level >= atoi(w1))
  1625. clif_displaymessage(fd, w2);
  1626. }
  1627. fclose(fp);
  1628. } else {
  1629. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1630. return -1;
  1631. }
  1632. return 0;
  1633. }
  1634. /*==========================================
  1635. * @help2 - Char commands [Kayla]
  1636. *------------------------------------------*/
  1637. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1638. {
  1639. char buf[2048], w1[2048], w2[2048];
  1640. int i, gm_level;
  1641. FILE* fp;
  1642. nullpo_retr(-1, sd);
  1643. memset(buf, '\0', sizeof(buf));
  1644. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1645. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1646. gm_level = pc_isGM(sd);
  1647. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1648. if (buf[0] == '/' && buf[1] == '/')
  1649. continue;
  1650. for (i = 0; buf[i] != '\0'; i++) {
  1651. if (buf[i] == '\r' || buf[i] == '\n') {
  1652. buf[i] = '\0';
  1653. break;
  1654. }
  1655. }
  1656. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1657. clif_displaymessage(fd, buf);
  1658. else if (gm_level >= atoi(w1))
  1659. clif_displaymessage(fd, w2);
  1660. }
  1661. fclose(fp);
  1662. } else {
  1663. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1664. return -1;
  1665. }
  1666. return 0;
  1667. }
  1668. // helper function, used in foreach calls to stop auto-attack timers
  1669. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1670. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1671. {
  1672. struct unit_data *ud = unit_bl2ud(bl);
  1673. int id = va_arg(ap, int);
  1674. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1675. {
  1676. unit_stop_attack(bl);
  1677. return 1;
  1678. }
  1679. return 0;
  1680. }
  1681. /*==========================================
  1682. *
  1683. *------------------------------------------*/
  1684. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1685. {
  1686. TBL_PC* sd = (TBL_PC*)bl;
  1687. clif_pvpset(sd, 0, 0, 2);
  1688. if (sd->pvp_timer != -1) {
  1689. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1690. sd->pvp_timer = INVALID_TIMER;
  1691. }
  1692. return 0;
  1693. }
  1694. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1695. {
  1696. nullpo_retr(-1, sd);
  1697. if (!map[sd->bl.m].flag.pvp) {
  1698. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1699. return -1;
  1700. }
  1701. map[sd->bl.m].flag.pvp = 0;
  1702. if (!battle_config.pk_mode)
  1703. clif_send0199(sd->bl.m, 0);
  1704. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1705. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1706. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1707. return 0;
  1708. }
  1709. /*==========================================
  1710. *
  1711. *------------------------------------------*/
  1712. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1713. {
  1714. TBL_PC* sd = (TBL_PC*)bl;
  1715. if (sd->pvp_timer == -1) {
  1716. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1717. sd->pvp_rank = 0;
  1718. sd->pvp_lastusers = 0;
  1719. sd->pvp_point = 5;
  1720. sd->pvp_won = 0;
  1721. sd->pvp_lost = 0;
  1722. }
  1723. return 0;
  1724. }
  1725. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1726. {
  1727. nullpo_retr(-1, sd);
  1728. if (map[sd->bl.m].flag.pvp) {
  1729. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1730. return -1;
  1731. }
  1732. map[sd->bl.m].flag.pvp = 1;
  1733. if (!battle_config.pk_mode)
  1734. {// display pvp circle and rank
  1735. clif_send0199(sd->bl.m, 1);
  1736. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1737. }
  1738. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1739. return 0;
  1740. }
  1741. /*==========================================
  1742. *
  1743. *------------------------------------------*/
  1744. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1745. {
  1746. nullpo_retr(-1, sd);
  1747. if (!map[sd->bl.m].flag.gvg) {
  1748. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1749. return -1;
  1750. }
  1751. map[sd->bl.m].flag.gvg = 0;
  1752. clif_send0199(sd->bl.m, 0);
  1753. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1754. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1755. return 0;
  1756. }
  1757. /*==========================================
  1758. *
  1759. *------------------------------------------*/
  1760. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1761. {
  1762. nullpo_retr(-1, sd);
  1763. if (map[sd->bl.m].flag.gvg) {
  1764. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1765. return -1;
  1766. }
  1767. map[sd->bl.m].flag.gvg = 1;
  1768. clif_send0199(sd->bl.m, 3);
  1769. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1770. return 0;
  1771. }
  1772. /*==========================================
  1773. *
  1774. *------------------------------------------*/
  1775. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1776. {
  1777. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1778. nullpo_retr(-1, sd);
  1779. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1780. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1781. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1782. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1783. clif_displaymessage(fd, atcmd_output);
  1784. return -1;
  1785. }
  1786. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1787. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1788. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1789. pc_changelook(sd, LOOK_HAIR, hair_style);
  1790. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1791. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1792. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1793. } else {
  1794. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1795. return -1;
  1796. }
  1797. return 0;
  1798. }
  1799. /*==========================================
  1800. * @dye && @ccolor
  1801. *------------------------------------------*/
  1802. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1803. {
  1804. int cloth_color = 0;
  1805. nullpo_retr(-1, sd);
  1806. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1807. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1808. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1809. clif_displaymessage(fd, atcmd_output);
  1810. return -1;
  1811. }
  1812. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1813. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1814. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1815. } else {
  1816. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1817. return -1;
  1818. }
  1819. return 0;
  1820. }
  1821. /*==========================================
  1822. * @hairstyle && @hstyle
  1823. *------------------------------------------*/
  1824. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1825. {
  1826. int hair_style = 0;
  1827. nullpo_retr(-1, sd);
  1828. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1829. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1830. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1831. clif_displaymessage(fd, atcmd_output);
  1832. return -1;
  1833. }
  1834. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1835. pc_changelook(sd, LOOK_HAIR, hair_style);
  1836. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1837. } else {
  1838. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1839. return -1;
  1840. }
  1841. return 0;
  1842. }
  1843. /*==========================================
  1844. * @haircolor && @hcolor
  1845. *------------------------------------------*/
  1846. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1847. {
  1848. int hair_color = 0;
  1849. nullpo_retr(-1, sd);
  1850. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1851. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1852. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1853. clif_displaymessage(fd, atcmd_output);
  1854. return -1;
  1855. }
  1856. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1857. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1858. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1859. } else {
  1860. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1861. return -1;
  1862. }
  1863. return 0;
  1864. }
  1865. /*==========================================
  1866. * @go [city_number or city_name] - Updated by Harbin
  1867. *------------------------------------------*/
  1868. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1869. {
  1870. int i;
  1871. int town;
  1872. char map_name[MAP_NAME_LENGTH];
  1873. int m;
  1874. const struct {
  1875. char map[MAP_NAME_LENGTH];
  1876. int x, y;
  1877. } data[] = {
  1878. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1879. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1880. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1881. { MAP_PAYON, 162, 233 }, // 3=Payon
  1882. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1883. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1884. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1885. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1886. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1887. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1888. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1889. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1890. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1891. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1892. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1893. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1894. { MAP_JAIL, 23, 61 }, // 16=Prison
  1895. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1896. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1897. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1898. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1899. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1900. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1901. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1902. { MAP_VEINS, 216, 123 }, // 24=Veins
  1903. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1904. };
  1905. nullpo_retr(-1, sd);
  1906. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  1907. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1908. return 0;
  1909. }
  1910. memset(map_name, '\0', sizeof(map_name));
  1911. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1912. // get the number
  1913. town = atoi(message);
  1914. // if no value, display all value
  1915. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1916. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  1917. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  1918. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1919. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1920. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1921. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1922. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1923. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1924. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1925. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  1926. clif_displaymessage(fd, " 24=Veins 25=Moscovia");
  1927. return -1;
  1928. }
  1929. // get possible name of the city
  1930. map_name[MAP_NAME_LENGTH-1] = '\0';
  1931. for (i = 0; map_name[i]; i++)
  1932. map_name[i] = TOLOWER(map_name[i]);
  1933. // try to identify the map name
  1934. if (strncmp(map_name, "prontera", 3) == 0) {
  1935. town = 0;
  1936. } else if (strncmp(map_name, "morocc", 3) == 0) {
  1937. town = 1;
  1938. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1939. town = 2;
  1940. } else if (strncmp(map_name, "payon", 3) == 0 ||
  1941. strncmp(map_name, "paion", 3) == 0) {
  1942. town = 3;
  1943. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1944. town = 4;
  1945. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  1946. strncmp(map_name, "islude", 3) == 0) {
  1947. town = 5;
  1948. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  1949. strcmp(map_name, "al") == 0) {
  1950. town = 6;
  1951. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1952. strcmp(map_name, "christmas") == 0 ||
  1953. strncmp(map_name, "xmas", 3) == 0 ||
  1954. strncmp(map_name, "x-mas", 3) == 0) {
  1955. town = 7;
  1956. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1957. town = 8;
  1958. } else if (strncmp(map_name, "yuno", 3) == 0) {
  1959. town = 9;
  1960. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1961. town = 10;
  1962. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  1963. town = 11;
  1964. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1965. town = 12;
  1966. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1967. town = 13;
  1968. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1969. town = 14;
  1970. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1971. strncmp(map_name, "startpoint", 3) == 0 ||
  1972. strncmp(map_name, "begining", 3) == 0) {
  1973. town = 15;
  1974. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1975. strncmp(map_name, "prison", 3) == 0 ||
  1976. strncmp(map_name, "jails", 3) == 0) {
  1977. town = 16;
  1978. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  1979. strncmp(map_name, "jawai", 3) == 0) {
  1980. town = 17;
  1981. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  1982. strncmp(map_name, "ayotaya", 3) == 0) {
  1983. town = 18;
  1984. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  1985. strncmp(map_name, "ainbroch", 5) == 0) {
  1986. town = 19;
  1987. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1988. town = 20;
  1989. } else if (strncmp(map_name, "einbech", 3) == 0) {
  1990. town = 21;
  1991. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1992. town = 22;
  1993. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1994. town = 23;
  1995. } else if (strncmp(map_name, "veins", 3) == 0) {
  1996. town = 24;
  1997. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1998. town = 25;
  1999. }
  2000. if (town >= 0 && town < ARRAYLENGTH(data))
  2001. {
  2002. m = map_mapname2mapid(data[town].map);
  2003. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2004. clif_displaymessage(fd, msg_txt(247));
  2005. return -1;
  2006. }
  2007. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2008. clif_displaymessage(fd, msg_txt(248));
  2009. return -1;
  2010. }
  2011. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
  2012. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2013. } else {
  2014. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2015. return -1;
  2016. }
  2017. } else { // if you arrive here, you have an error in town variable when reading of names
  2018. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2019. return -1;
  2020. }
  2021. return 0;
  2022. }
  2023. /*==========================================
  2024. *
  2025. *------------------------------------------*/
  2026. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2027. {
  2028. char name[NAME_LENGTH];
  2029. char monster[NAME_LENGTH];
  2030. int mob_id;
  2031. int number = 0;
  2032. int count;
  2033. int i, k, range;
  2034. short mx, my;
  2035. nullpo_retr(-1, sd);
  2036. memset(name, '\0', sizeof(name));
  2037. memset(monster, '\0', sizeof(monster));
  2038. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2039. if (!message || !*message) {
  2040. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2041. return -1;
  2042. }
  2043. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2044. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2045. //All data can be left as it is.
  2046. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2047. //Here, it is possible name was not given and we are using monster for it.
  2048. if (count < 3) //Blank mob's name.
  2049. name[0] = '\0';
  2050. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2051. //All data can be left as it is.
  2052. } else if (sscanf(message, "%23s", monster) > 0) {
  2053. //As before, name may be already filled.
  2054. name[0] = '\0';
  2055. } else {
  2056. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2057. return -1;
  2058. }
  2059. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2060. mob_id = mobdb_checkid(atoi(monster));
  2061. if (mob_id == 0) {
  2062. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2063. return -1;
  2064. }
  2065. if (mob_id == MOBID_EMPERIUM) {
  2066. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2067. return -1;
  2068. }
  2069. if (number <= 0)
  2070. number = 1;
  2071. if (strlen(name) < 1)
  2072. strcpy(name, "--ja--");
  2073. // 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
  2074. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2075. number = battle_config.atc_spawn_quantity_limit;
  2076. if (battle_config.etc_log)
  2077. 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);
  2078. count = 0;
  2079. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2080. for (i = 0; i < number; i++) {
  2081. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2082. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2083. count += (k != 0) ? 1 : 0;
  2084. }
  2085. if (count != 0)
  2086. if (number == count)
  2087. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2088. else {
  2089. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2090. clif_displaymessage(fd, atcmd_output);
  2091. }
  2092. else {
  2093. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2094. return -1;
  2095. }
  2096. return 0;
  2097. }
  2098. // small monster spawning [Valaris]
  2099. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2100. {
  2101. char name[NAME_LENGTH] = "";
  2102. char monster[NAME_LENGTH] = "";
  2103. int mob_id = 0;
  2104. int number = 0;
  2105. int x = 0;
  2106. int y = 0;
  2107. int count;
  2108. int i;
  2109. nullpo_retr(-1, sd);
  2110. if (!message || !*message) {
  2111. clif_displaymessage(fd, "Give a monster name/id please.");
  2112. return -1;
  2113. }
  2114. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2115. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2116. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2117. clif_displaymessage(fd, "Give a monster name/id please.");
  2118. return -1;
  2119. }
  2120. // If monster identifier/name argument is a name
  2121. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2122. mob_id = atoi(monster);
  2123. if (mob_id == 0) {
  2124. clif_displaymessage(fd, msg_txt(40));
  2125. return -1;
  2126. }
  2127. if (mob_id == MOBID_EMPERIUM) {
  2128. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2129. return -1;
  2130. }
  2131. if (mobdb_checkid(mob_id) == 0) {
  2132. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2133. return -1;
  2134. }
  2135. if (number <= 0)
  2136. number = 1;
  2137. if (strlen(name) < 1)
  2138. strcpy(name, "--ja--");
  2139. // 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
  2140. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2141. number = battle_config.atc_spawn_quantity_limit;
  2142. count = 0;
  2143. for (i = 0; i < number; i++) {
  2144. int mx, my;
  2145. if (x <= 0)
  2146. mx = sd->bl.x + (rand() % 11 - 5);
  2147. else
  2148. mx = x;
  2149. if (y <= 0)
  2150. my = sd->bl.y + (rand() % 11 - 5);
  2151. else
  2152. my = y;
  2153. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2154. }
  2155. if (count != 0)
  2156. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2157. else
  2158. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2159. return 0;
  2160. }
  2161. // big monster spawning [Valaris]
  2162. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2163. {
  2164. char name[NAME_LENGTH] = "";
  2165. char monster[NAME_LENGTH] = "";
  2166. int mob_id = 0;
  2167. int number = 0;
  2168. int x = 0;
  2169. int y = 0;
  2170. int count;
  2171. int i;
  2172. nullpo_retr(-1, sd);
  2173. if (!message || !*message) {
  2174. clif_displaymessage(fd, "Give a monster name/id please.");
  2175. return -1;
  2176. }
  2177. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2178. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2179. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2180. clif_displaymessage(fd, "Give a monster name/id please.");
  2181. return -1;
  2182. }
  2183. // If monster identifier/name argument is a name
  2184. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2185. mob_id = atoi(monster);
  2186. if (mob_id == 0) {
  2187. clif_displaymessage(fd, msg_txt(40));
  2188. return -1;
  2189. }
  2190. if (mob_id == MOBID_EMPERIUM) {
  2191. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2192. return -1;
  2193. }
  2194. if (mobdb_checkid(mob_id) == 0) {
  2195. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2196. return -1;
  2197. }
  2198. if (number <= 0)
  2199. number = 1;
  2200. if (strlen(name) < 1)
  2201. strcpy(name, "--ja--");
  2202. // 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
  2203. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2204. number = battle_config.atc_spawn_quantity_limit;
  2205. count = 0;
  2206. for (i = 0; i < number; i++) {
  2207. int mx, my;
  2208. if (x <= 0)
  2209. mx = sd->bl.x + (rand() % 11 - 5);
  2210. else
  2211. mx = x;
  2212. if (y <= 0)
  2213. my = sd->bl.y + (rand() % 11 - 5);
  2214. else
  2215. my = y;
  2216. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2217. }
  2218. if (count != 0)
  2219. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2220. else
  2221. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2222. return 0;
  2223. }
  2224. /*==========================================
  2225. *
  2226. *------------------------------------------*/
  2227. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2228. {
  2229. struct mob_data *md;
  2230. int flag;
  2231. nullpo_retr(0, md=(struct mob_data *)bl);
  2232. flag = va_arg(ap, int);
  2233. if (md->guardian_data)
  2234. return 0; //Do not touch WoE mobs!
  2235. if (flag)
  2236. status_zap(bl,md->status.hp, 0);
  2237. else
  2238. status_kill(bl);
  2239. return 1;
  2240. }
  2241. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2242. {
  2243. int map_id;
  2244. char map_name[MAP_NAME_LENGTH_EXT];
  2245. if (!sd) return;
  2246. memset(map_name, '\0', sizeof(map_name));
  2247. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2248. map_id = sd->bl.m;
  2249. else {
  2250. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2251. map_id = sd->bl.m;
  2252. }
  2253. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2254. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2255. return;
  2256. }
  2257. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2258. {
  2259. atcommand_killmonster_sub(fd, sd, message, 1);
  2260. return 0;
  2261. }
  2262. /*==========================================
  2263. *
  2264. *------------------------------------------*/
  2265. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2266. {
  2267. atcommand_killmonster_sub(fd, sd, message, 0);
  2268. return 0;
  2269. }
  2270. /*==========================================
  2271. *
  2272. *------------------------------------------*/
  2273. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2274. {
  2275. int i,j, position = 0, refine = 0, current_position, final_refine;
  2276. int count;
  2277. nullpo_retr(-1, sd);
  2278. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2279. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2280. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2281. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2282. clif_displaymessage(fd, atcmd_output);
  2283. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2284. clif_displaymessage(fd, atcmd_output);
  2285. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2286. clif_displaymessage(fd, atcmd_output);
  2287. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2288. clif_displaymessage(fd, atcmd_output);
  2289. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2290. clif_displaymessage(fd, atcmd_output);
  2291. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2292. clif_displaymessage(fd, atcmd_output);
  2293. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2294. clif_displaymessage(fd, atcmd_output);
  2295. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2296. clif_displaymessage(fd, atcmd_output);
  2297. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2298. clif_displaymessage(fd, atcmd_output);
  2299. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2300. clif_displaymessage(fd, atcmd_output);
  2301. return -1;
  2302. }
  2303. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2304. count = 0;
  2305. for (j = 0; j < EQI_MAX-1; j++) {
  2306. if ((i = sd->equip_index[j]) < 0)
  2307. continue;
  2308. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2309. continue;
  2310. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2311. continue;
  2312. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2313. continue;
  2314. if(position && !(sd->status.inventory[i].equip & position))
  2315. continue;
  2316. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2317. if (sd->status.inventory[i].refine != final_refine) {
  2318. sd->status.inventory[i].refine = final_refine;
  2319. current_position = sd->status.inventory[i].equip;
  2320. pc_unequipitem(sd, i, 3);
  2321. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2322. clif_delitem(sd, i, 1);
  2323. clif_additem(sd, i, 1, 0);
  2324. pc_equipitem(sd, i, current_position);
  2325. clif_misceffect(&sd->bl, 3);
  2326. count++;
  2327. }
  2328. }
  2329. if (count == 0)
  2330. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2331. else if (count == 1)
  2332. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2333. else {
  2334. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2335. clif_displaymessage(fd, atcmd_output);
  2336. }
  2337. return 0;
  2338. }
  2339. /*==========================================
  2340. *
  2341. *------------------------------------------*/
  2342. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2343. {
  2344. char item_name[100];
  2345. int item_id, attribute = 0, star = 0;
  2346. int flag = 0;
  2347. struct item_data *item_data;
  2348. struct item tmp_item;
  2349. nullpo_retr(-1, sd);
  2350. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2351. memset(item_name, '\0', sizeof(item_name));
  2352. if (!message || !*message || (
  2353. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2354. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2355. )) {
  2356. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2357. return -1;
  2358. }
  2359. item_id = 0;
  2360. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2361. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2362. {
  2363. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2364. return -1;
  2365. }
  2366. item_id = item_data->nameid;
  2367. if (itemdb_isequip2(item_data)) {
  2368. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2369. attribute = ATTRIBUTE_NORMAL;
  2370. if (star < MIN_STAR || star > MAX_STAR)
  2371. star = 0;
  2372. memset(&tmp_item, 0, sizeof tmp_item);
  2373. tmp_item.nameid = item_id;
  2374. tmp_item.amount = 1;
  2375. tmp_item.identify = 1;
  2376. tmp_item.card[0] = CARD0_FORGE;
  2377. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2378. ((star*5) << 8) + attribute:0;
  2379. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2380. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2381. clif_produceeffect(sd, 0, item_id);
  2382. clif_misceffect(&sd->bl, 3);
  2383. //Logs (A)dmins items [Lupus]
  2384. if(log_config.enable_logs&0x400)
  2385. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  2386. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2387. clif_additem(sd, 0, 0, flag);
  2388. } else {
  2389. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2390. clif_displaymessage(fd, atcmd_output);
  2391. return -1;
  2392. }
  2393. return 0;
  2394. }
  2395. /*==========================================
  2396. *
  2397. *------------------------------------------*/
  2398. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2399. {
  2400. int position = 0;
  2401. nullpo_retr(-1, sd);
  2402. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2403. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2404. {
  2405. int i;
  2406. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2407. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2408. {
  2409. if( sd->status.memo_point[i].map )
  2410. 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);
  2411. else
  2412. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2413. clif_displaymessage(sd->fd, atcmd_output);
  2414. }
  2415. return 0;
  2416. }
  2417. if( position < 0 || position >= MAX_MEMOPOINTS )
  2418. {
  2419. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2420. clif_displaymessage(fd, atcmd_output);
  2421. return -1;
  2422. }
  2423. pc_memo(sd, position);
  2424. return 0;
  2425. }
  2426. /*==========================================
  2427. *
  2428. *------------------------------------------*/
  2429. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2430. {
  2431. int y;
  2432. nullpo_retr(-1, sd);
  2433. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2434. for (y = 2; y >= -2; y--) {
  2435. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2436. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2437. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2438. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2439. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2440. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2441. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2442. clif_displaymessage(fd, atcmd_output);
  2443. }
  2444. return 0;
  2445. }
  2446. /*==========================================
  2447. *
  2448. *------------------------------------------*/
  2449. int atcommand_displaystatus(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2450. {
  2451. int i, type, flag, tick;
  2452. nullpo_retr(-1, sd);
  2453. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2454. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2455. return -1;
  2456. }
  2457. if (i < 2) flag = 1;
  2458. if (i < 3) tick = 0;
  2459. clif_status_change(&sd->bl, type, flag, tick);
  2460. return 0;
  2461. }
  2462. /*==========================================
  2463. * @stpoint (Rewritten by [Yor])
  2464. *------------------------------------------*/
  2465. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2466. {
  2467. int point, new_status_point;
  2468. if (!message || !*message || (point = atoi(message)) == 0) {
  2469. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2470. return -1;
  2471. }
  2472. if (point < 0 && sd->status.status_point < -point)
  2473. new_status_point = 0;
  2474. else
  2475. new_status_point = sd->status.status_point + point;
  2476. if (new_status_point != (int)sd->status.status_point) {
  2477. sd->status.status_point = new_status_point;
  2478. clif_updatestatus(sd, SP_STATUSPOINT);
  2479. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2480. } else {
  2481. if (point < 0)
  2482. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2483. else
  2484. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2485. return -1;
  2486. }
  2487. return 0;
  2488. }
  2489. /*==========================================
  2490. * @skpoint (Rewritten by [Yor])
  2491. *------------------------------------------*/
  2492. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2493. {
  2494. int point, new_skill_point;
  2495. nullpo_retr(-1, sd);
  2496. if (!message || !*message || (point = atoi(message)) == 0) {
  2497. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2498. return -1;
  2499. }
  2500. if (point < 0 && sd->status.skill_point < -point)
  2501. new_skill_point = 0;
  2502. else
  2503. new_skill_point = sd->status.skill_point + point;
  2504. if (new_skill_point != (int)sd->status.skill_point) {
  2505. sd->status.skill_point = new_skill_point;
  2506. clif_updatestatus(sd, SP_SKILLPOINT);
  2507. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2508. } else {
  2509. if (point < 0)
  2510. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2511. else
  2512. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2513. return -1;
  2514. }
  2515. return 0;
  2516. }
  2517. /*==========================================
  2518. * @zeny (Rewritten by [Yor])
  2519. *------------------------------------------*/
  2520. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2521. {
  2522. int zeny, new_zeny;
  2523. nullpo_retr(-1, sd);
  2524. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2525. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2526. return -1;
  2527. }
  2528. new_zeny = sd->status.zeny + zeny;
  2529. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2530. new_zeny = MAX_ZENY;
  2531. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2532. new_zeny = 0;
  2533. if (new_zeny != sd->status.zeny) {
  2534. sd->status.zeny = new_zeny;
  2535. clif_updatestatus(sd, SP_ZENY);
  2536. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2537. } else {
  2538. if (zeny < 0)
  2539. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2540. else
  2541. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2542. return -1;
  2543. }
  2544. return 0;
  2545. }
  2546. /*==========================================
  2547. *
  2548. *------------------------------------------*/
  2549. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2550. {
  2551. int i, value = 0, new_value, max;
  2552. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2553. short* status[6];
  2554. //we don't use direct initialization because it isn't part of the c standard.
  2555. nullpo_retr(-1, sd);
  2556. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2557. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2558. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2559. clif_displaymessage(fd, atcmd_output);
  2560. return -1;
  2561. }
  2562. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2563. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2564. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2565. clif_displaymessage(fd, atcmd_output);
  2566. return -1;
  2567. }
  2568. status[0] = &sd->status.str;
  2569. status[1] = &sd->status.agi;
  2570. status[2] = &sd->status.vit;
  2571. status[3] = &sd->status.int_;
  2572. status[4] = &sd->status.dex;
  2573. status[5] = &sd->status.luk;
  2574. max = SHRT_MAX;
  2575. new_value = cap_value(*status[i] + value, 1, max);
  2576. if (new_value != (int)*status[i]) {
  2577. *status[i] = new_value;
  2578. clif_updatestatus(sd, SP_STR + i);
  2579. clif_updatestatus(sd, SP_USTR + i);
  2580. status_calc_pc(sd, 0);
  2581. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2582. } else {
  2583. if (value < 0)
  2584. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2585. else
  2586. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2587. return -1;
  2588. }
  2589. return 0;
  2590. }
  2591. /*==========================================
  2592. * Stat all by fritz (rewritten by [Yor])
  2593. *------------------------------------------*/
  2594. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2595. {
  2596. int index, count, value, max, new_value;
  2597. short* status[6];
  2598. //we don't use direct initialization because it isn't part of the c standard.
  2599. nullpo_retr(-1, sd);
  2600. status[0] = &sd->status.str;
  2601. status[1] = &sd->status.agi;
  2602. status[2] = &sd->status.vit;
  2603. status[3] = &sd->status.int_;
  2604. status[4] = &sd->status.dex;
  2605. status[5] = &sd->status.luk;
  2606. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2607. value = pc_maxparameter(sd);
  2608. max = pc_maxparameter(sd);
  2609. } else {
  2610. max = SHRT_MAX;
  2611. }
  2612. count = 0;
  2613. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2614. if (value > 0 && *status[index] > max - value)
  2615. new_value = max;
  2616. else if (value < 0 && *status[index] <= -value)
  2617. new_value = 1;
  2618. else
  2619. new_value = *status[index] +value;
  2620. if (new_value != (int)*status[index]) {
  2621. *status[index] = new_value;
  2622. clif_updatestatus(sd, SP_STR + index);
  2623. clif_updatestatus(sd, SP_USTR + index);
  2624. count++;
  2625. }
  2626. }
  2627. if (count > 0) { // if at least 1 stat modified
  2628. status_calc_pc(sd, 0);
  2629. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2630. } else {
  2631. if (value < 0)
  2632. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2633. else
  2634. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2635. return -1;
  2636. }
  2637. return 0;
  2638. }
  2639. /*==========================================
  2640. *
  2641. *------------------------------------------*/
  2642. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2643. {
  2644. int level = 0;
  2645. short added_level;
  2646. struct guild *guild_info;
  2647. nullpo_retr(-1, sd);
  2648. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2649. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2650. return -1;
  2651. }
  2652. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2653. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2654. return -1;
  2655. }
  2656. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2657. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2658. // return -1;
  2659. //}
  2660. added_level = (short)level;
  2661. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2662. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2663. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2664. added_level = 1 - guild_info->guild_lv;
  2665. if (added_level != 0) {
  2666. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  2667. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2668. } else {
  2669. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2670. return -1;
  2671. }
  2672. return 0;
  2673. }
  2674. /*==========================================
  2675. *
  2676. *------------------------------------------*/
  2677. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2678. {
  2679. struct item_data *item_data;
  2680. int id, pet_id;
  2681. nullpo_retr(-1, sd);
  2682. if (!message || !*message) {
  2683. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2684. return -1;
  2685. }
  2686. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2687. id = item_data->nameid;
  2688. else
  2689. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2690. ;
  2691. else
  2692. id = atoi(message);
  2693. pet_id = search_petDB_index(id, PET_CLASS);
  2694. if (pet_id < 0)
  2695. pet_id = search_petDB_index(id, PET_EGG);
  2696. if (pet_id >= 0) {
  2697. sd->catch_target_class = pet_db[pet_id].class_;
  2698. intif_create_pet(
  2699. sd->status.account_id, sd->status.char_id,
  2700. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2701. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2702. 100, 0, 1, pet_db[pet_id].jname);
  2703. } else {
  2704. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2705. return -1;
  2706. }
  2707. return 0;
  2708. }
  2709. /*==========================================
  2710. *
  2711. *------------------------------------------*/
  2712. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2713. {
  2714. nullpo_retr(-1, sd);
  2715. if (sd->status.pet_id <= 0)
  2716. clif_sendegg(sd);
  2717. else {
  2718. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2719. return -1;
  2720. }
  2721. return 0;
  2722. }
  2723. /*==========================================
  2724. *
  2725. *------------------------------------------*/
  2726. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2727. {
  2728. int friendly;
  2729. struct pet_data *pd;
  2730. nullpo_retr(-1, sd);
  2731. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2732. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2733. return -1;
  2734. }
  2735. pd = sd->pd;
  2736. if (!pd) {
  2737. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2738. return -1;
  2739. }
  2740. if (friendly < 0 || friendly > 1000)
  2741. {
  2742. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2743. return -1;
  2744. }
  2745. if (friendly == pd->pet.intimate) {
  2746. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2747. return -1;
  2748. }
  2749. pet_set_intimate(pd, friendly);
  2750. clif_send_petstatus(sd);
  2751. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2752. return 0;
  2753. }
  2754. /*==========================================
  2755. *
  2756. *------------------------------------------*/
  2757. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2758. {
  2759. int hungry;
  2760. struct pet_data *pd;
  2761. nullpo_retr(-1, sd);
  2762. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2763. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2764. return -1;
  2765. }
  2766. pd = sd->pd;
  2767. if (!sd->status.pet_id || !pd) {
  2768. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2769. return -1;
  2770. }
  2771. if (hungry < 0 || hungry > 100) {
  2772. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2773. return -1;
  2774. }
  2775. if (hungry == pd->pet.hungry) {
  2776. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2777. return -1;
  2778. }
  2779. pd->pet.hungry = hungry;
  2780. clif_send_petstatus(sd);
  2781. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2782. return 0;
  2783. }
  2784. /*==========================================
  2785. *
  2786. *------------------------------------------*/
  2787. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2788. {
  2789. struct pet_data *pd;
  2790. nullpo_retr(-1, sd);
  2791. if (!sd->status.pet_id || !sd->pd) {
  2792. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2793. return -1;
  2794. }
  2795. pd = sd->pd;
  2796. if (!pd->pet.rename_flag) {
  2797. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2798. return -1;
  2799. }
  2800. pd->pet.rename_flag = 0;
  2801. intif_save_petdata(sd->status.account_id, &pd->pet);
  2802. clif_send_petstatus(sd);
  2803. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2804. return 0;
  2805. }
  2806. /*==========================================
  2807. *
  2808. *------------------------------------------*/
  2809. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2810. {
  2811. struct map_session_data *pl_sd = NULL;
  2812. nullpo_retr(-1, sd);
  2813. if (!message || !*message) {
  2814. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2815. return -1;
  2816. }
  2817. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2818. {
  2819. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2820. return -1;
  2821. }
  2822. if (pl_sd == sd)
  2823. {
  2824. clif_displaymessage(fd, "You are already where you are...");
  2825. return -1;
  2826. }
  2827. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2828. {
  2829. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2830. return -1;
  2831. }
  2832. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2833. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  2834. return -1;
  2835. }
  2836. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2837. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2838. return -1;
  2839. }
  2840. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  2841. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2842. clif_displaymessage(fd, atcmd_output);
  2843. return 0;
  2844. }
  2845. /*==========================================
  2846. * charblock command (usage: charblock <player_name>)
  2847. * This command do a definitiv ban on a player
  2848. *------------------------------------------*/
  2849. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2850. {
  2851. nullpo_retr(-1, sd);
  2852. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2853. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2854. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2855. return -1;
  2856. }
  2857. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2858. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2859. return 0;
  2860. }
  2861. /*==========================================
  2862. * charban command (usage: charban <time> <player_name>)
  2863. * This command do a limited ban on a player
  2864. * Time is done as follows:
  2865. * Adjustment value (-1, 1, +1, etc...)
  2866. * Modified element:
  2867. * a or y: year
  2868. * m: month
  2869. * j or d: day
  2870. * h: hour
  2871. * mn: minute
  2872. * s: second
  2873. * <example> @ban +1m-2mn1s-6y test_player
  2874. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2875. *------------------------------------------*/
  2876. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2877. {
  2878. char * modif_p;
  2879. int year, month, day, hour, minute, second, value;
  2880. nullpo_retr(-1, sd);
  2881. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2882. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2883. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2884. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2885. return -1;
  2886. }
  2887. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2888. modif_p = atcmd_output;
  2889. year = month = day = hour = minute = second = 0;
  2890. while (modif_p[0] != '\0') {
  2891. value = atoi(modif_p);
  2892. if (value == 0)
  2893. modif_p++;
  2894. else {
  2895. if (modif_p[0] == '-' || modif_p[0] == '+')
  2896. modif_p++;
  2897. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2898. modif_p++;
  2899. if (modif_p[0] == 's') {
  2900. second = value;
  2901. modif_p++;
  2902. } else if (modif_p[0] == 'n') {
  2903. minute = value;
  2904. modif_p++;
  2905. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2906. minute = value;
  2907. modif_p = modif_p + 2;
  2908. } else if (modif_p[0] == 'h') {
  2909. hour = value;
  2910. modif_p++;
  2911. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2912. day = value;
  2913. modif_p++;
  2914. } else if (modif_p[0] == 'm') {
  2915. month = value;
  2916. modif_p++;
  2917. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2918. year = value;
  2919. modif_p++;
  2920. } else if (modif_p[0] != '\0') {
  2921. modif_p++;
  2922. }
  2923. }
  2924. }
  2925. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2926. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2927. return -1;
  2928. }
  2929. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2930. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2931. return 0;
  2932. }
  2933. /*==========================================
  2934. * charunblock command (usage: charunblock <player_name>)
  2935. *------------------------------------------*/
  2936. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2937. {
  2938. nullpo_retr(-1, sd);
  2939. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2940. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2941. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  2942. return -1;
  2943. }
  2944. // send answer to login server via char-server
  2945. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2946. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2947. return 0;
  2948. }
  2949. /*==========================================
  2950. * charunban command (usage: charunban <player_name>)
  2951. *------------------------------------------*/
  2952. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2953. {
  2954. nullpo_retr(-1, sd);
  2955. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2956. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2957. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  2958. return -1;
  2959. }
  2960. // send answer to login server via char-server
  2961. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2962. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2963. return 0;
  2964. }
  2965. /*==========================================
  2966. *
  2967. *------------------------------------------*/
  2968. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2969. {
  2970. nullpo_retr(-1, sd);
  2971. if (night_flag != 1) {
  2972. map_night_timer(night_timer_tid, 0, 0, 1);
  2973. } else {
  2974. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  2975. return -1;
  2976. }
  2977. return 0;
  2978. }
  2979. /*==========================================
  2980. *
  2981. *------------------------------------------*/
  2982. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2983. {
  2984. nullpo_retr(-1, sd);
  2985. if (night_flag != 0) {
  2986. map_day_timer(day_timer_tid, 0, 0, 1);
  2987. } else {
  2988. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  2989. return -1;
  2990. }
  2991. return 0;
  2992. }
  2993. /*==========================================
  2994. *
  2995. *------------------------------------------*/
  2996. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2997. {
  2998. struct map_session_data* pl_sd;
  2999. struct s_mapiterator* iter;
  3000. nullpo_retr(-1, sd);
  3001. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  3002. iter = mapit_getallusers();
  3003. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3004. {
  3005. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3006. {
  3007. status_kill(&pl_sd->bl);
  3008. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3009. }
  3010. }
  3011. mapit_free(iter);
  3012. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3013. return 0;
  3014. }
  3015. /*==========================================
  3016. *
  3017. *------------------------------------------*/
  3018. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3019. {
  3020. struct map_session_data* pl_sd;
  3021. struct s_mapiterator* iter;
  3022. nullpo_retr(-1, sd);
  3023. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  3024. iter = mapit_getallusers();
  3025. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3026. {
  3027. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3028. {
  3029. status_kill(&pl_sd->bl);
  3030. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3031. }
  3032. }
  3033. mapit_free(iter);
  3034. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3035. return 0;
  3036. }
  3037. /*==========================================
  3038. *
  3039. *------------------------------------------*/
  3040. static void atcommand_raise_sub(struct map_session_data* sd)
  3041. {
  3042. if (!status_isdead(&sd->bl))
  3043. return;
  3044. if(!status_revive(&sd->bl, 100, 100))
  3045. return;
  3046. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3047. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3048. }
  3049. /*==========================================
  3050. *
  3051. *------------------------------------------*/
  3052. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3053. {
  3054. struct map_session_data* pl_sd;
  3055. struct s_mapiterator* iter;
  3056. nullpo_retr(-1, sd);
  3057. iter = mapit_getallusers();
  3058. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3059. atcommand_raise_sub(pl_sd);
  3060. mapit_free(iter);
  3061. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3062. return 0;
  3063. }
  3064. /*==========================================
  3065. *
  3066. *------------------------------------------*/
  3067. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3068. {
  3069. struct map_session_data* pl_sd;
  3070. struct s_mapiterator* iter;
  3071. nullpo_retr(-1, sd);
  3072. iter = mapit_getallusers();
  3073. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3074. if (sd->bl.m == pl_sd->bl.m)
  3075. atcommand_raise_sub(pl_sd);
  3076. mapit_free(iter);
  3077. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3078. return 0;
  3079. }
  3080. /*==========================================
  3081. *
  3082. *------------------------------------------*/
  3083. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3084. {
  3085. struct map_session_data *pl_sd;
  3086. nullpo_retr(-1, sd);
  3087. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3088. if (!message || !*message) {
  3089. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3090. return -1;
  3091. }
  3092. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3093. {
  3094. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3095. return -1;
  3096. }
  3097. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3098. {
  3099. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3100. return -1;
  3101. }
  3102. clif_GM_kick(sd, pl_sd);
  3103. return 0;
  3104. }
  3105. /*==========================================
  3106. *
  3107. *------------------------------------------*/
  3108. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3109. {
  3110. struct map_session_data* pl_sd;
  3111. struct s_mapiterator* iter;
  3112. nullpo_retr(-1, sd);
  3113. iter = mapit_getallusers();
  3114. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3115. {
  3116. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3117. if (sd->status.account_id != pl_sd->status.account_id)
  3118. clif_GM_kick(NULL, pl_sd);
  3119. }
  3120. }
  3121. mapit_free(iter);
  3122. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3123. return 0;
  3124. }
  3125. /*==========================================
  3126. *
  3127. *------------------------------------------*/
  3128. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3129. {
  3130. nullpo_retr(-1, sd);
  3131. pc_allskillup(sd); // all skills
  3132. sd->status.skill_point = 0; // 0 skill points
  3133. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3134. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3135. return 0;
  3136. }
  3137. /*==========================================
  3138. *
  3139. *------------------------------------------*/
  3140. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3141. {
  3142. int skill_id;
  3143. nullpo_retr(-1, sd);
  3144. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3145. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3146. return -1;
  3147. }
  3148. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3149. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3150. return -1;
  3151. }
  3152. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3153. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3154. return -1;
  3155. }
  3156. if (pc_checkskill(sd, skill_id) > 0) {
  3157. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3158. return -1;
  3159. }
  3160. pc_skill(sd, skill_id, 1, 0);
  3161. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3162. return 0;
  3163. }
  3164. /*==========================================
  3165. *
  3166. *------------------------------------------*/
  3167. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3168. {
  3169. int skill_id;
  3170. nullpo_retr(-1, sd);
  3171. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3172. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3173. return -1;
  3174. }
  3175. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3176. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3177. return -1;
  3178. }
  3179. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3180. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3181. return -1;
  3182. }
  3183. if (pc_checkskill(sd, skill_id) == 0) {
  3184. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3185. return -1;
  3186. }
  3187. sd->status.skill[skill_id].lv = 0;
  3188. sd->status.skill[skill_id].flag = 0;
  3189. clif_deleteskill(sd,skill_id);
  3190. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3191. return 0;
  3192. }
  3193. /*==========================================
  3194. *
  3195. *------------------------------------------*/
  3196. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3197. {
  3198. int max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3199. int number;
  3200. nullpo_retr(-1, sd);
  3201. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3202. {
  3203. char msg[256];
  3204. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3205. clif_displaymessage(fd, msg);
  3206. return -1;
  3207. }
  3208. if( sd->spiritball > 0 )
  3209. pc_delspiritball(sd, sd->spiritball, 1);
  3210. sd->spiritball = number;
  3211. clif_spiritball(sd);
  3212. // no message, player can look the difference
  3213. return 0;
  3214. }
  3215. /*==========================================
  3216. *
  3217. *------------------------------------------*/
  3218. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3219. {
  3220. char party[NAME_LENGTH];
  3221. nullpo_retr(-1, sd);
  3222. memset(party, '\0', sizeof(party));
  3223. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3224. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3225. return -1;
  3226. }
  3227. party_create(sd, party, 0, 0);
  3228. return 0;
  3229. }
  3230. /*==========================================
  3231. *
  3232. *------------------------------------------*/
  3233. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3234. {
  3235. char guild[NAME_LENGTH];
  3236. int prev;
  3237. nullpo_retr(-1, sd);
  3238. memset(guild, '\0', sizeof(guild));
  3239. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3240. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3241. return -1;
  3242. }
  3243. prev = battle_config.guild_emperium_check;
  3244. battle_config.guild_emperium_check = 0;
  3245. guild_create(sd, guild);
  3246. battle_config.guild_emperium_check = prev;
  3247. return 0;
  3248. }
  3249. /*==========================================
  3250. *
  3251. *------------------------------------------*/
  3252. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3253. {
  3254. nullpo_retr(-1, sd);
  3255. if (agit_flag == 1) {
  3256. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3257. return -1;
  3258. }
  3259. agit_flag = 1;
  3260. guild_agit_start();
  3261. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3262. return 0;
  3263. }
  3264. /*==========================================
  3265. *
  3266. *------------------------------------------*/
  3267. int atcommand_agitstart2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3268. {
  3269. nullpo_retr(-1, sd);
  3270. if (agit2_flag == 1) {
  3271. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3272. return -1;
  3273. }
  3274. agit2_flag = 1;
  3275. guild_agit2_start();
  3276. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3277. return 0;
  3278. }
  3279. /*==========================================
  3280. *
  3281. *------------------------------------------*/
  3282. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3283. {
  3284. nullpo_retr(-1, sd);
  3285. if (agit_flag == 0) {
  3286. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3287. return -1;
  3288. }
  3289. agit_flag = 0;
  3290. guild_agit_end();
  3291. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3292. return 0;
  3293. }
  3294. /*==========================================
  3295. *
  3296. *------------------------------------------*/
  3297. int atcommand_agitend2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3298. {
  3299. nullpo_retr(-1, sd);
  3300. if (agit2_flag == 0) {
  3301. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3302. return -1;
  3303. }
  3304. agit2_flag = 0;
  3305. guild_agit2_end();
  3306. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3307. return 0;
  3308. }
  3309. /*==========================================
  3310. * @mapexit - shuts down the map server
  3311. *------------------------------------------*/
  3312. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3313. {
  3314. struct map_session_data* pl_sd;
  3315. struct s_mapiterator* iter;
  3316. nullpo_retr(-1, sd);
  3317. iter = mapit_getallusers();
  3318. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3319. if (sd->status.account_id != pl_sd->status.account_id)
  3320. clif_GM_kick(NULL, pl_sd);
  3321. mapit_free(iter);
  3322. clif_GM_kick(NULL, sd);
  3323. flush_fifos();
  3324. runflag = 0;
  3325. return 0;
  3326. }
  3327. /*==========================================
  3328. * idsearch <part_of_name>: revrited by [Yor]
  3329. *------------------------------------------*/
  3330. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3331. {
  3332. char item_name[100];
  3333. unsigned int i, match;
  3334. struct item_data *item_array[MAX_SEARCH];
  3335. nullpo_retr(-1, sd);
  3336. memset(item_name, '\0', sizeof(item_name));
  3337. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3338. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3339. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3340. return -1;
  3341. }
  3342. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3343. clif_displaymessage(fd, atcmd_output);
  3344. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3345. if (match > MAX_SEARCH) {
  3346. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3347. clif_displaymessage(fd, atcmd_output);
  3348. match = MAX_SEARCH;
  3349. }
  3350. for(i = 0; i < match; i++) {
  3351. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3352. clif_displaymessage(fd, atcmd_output);
  3353. }
  3354. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3355. clif_displaymessage(fd, atcmd_output);
  3356. return 0;
  3357. }
  3358. /*==========================================
  3359. * Recall All Characters Online To Your Location
  3360. *------------------------------------------*/
  3361. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3362. {
  3363. struct map_session_data* pl_sd;
  3364. struct s_mapiterator* iter;
  3365. int count;
  3366. nullpo_retr(-1, sd);
  3367. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3368. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3369. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3370. return -1;
  3371. }
  3372. count = 0;
  3373. iter = mapit_getallusers();
  3374. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3375. {
  3376. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3377. {
  3378. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3379. count++;
  3380. else {
  3381. if (pc_isdead(pl_sd)) { //Wake them up
  3382. pc_setstand(pl_sd);
  3383. pc_setrestartvalue(pl_sd,1);
  3384. }
  3385. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3386. }
  3387. }
  3388. }
  3389. mapit_free(iter);
  3390. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3391. if (count) {
  3392. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3393. clif_displaymessage(fd, atcmd_output);
  3394. }
  3395. return 0;
  3396. }
  3397. /*==========================================
  3398. * Recall online characters of a guild to your location
  3399. *------------------------------------------*/
  3400. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3401. {
  3402. struct map_session_data* pl_sd;
  3403. struct s_mapiterator* iter;
  3404. int count;
  3405. char guild_name[NAME_LENGTH];
  3406. struct guild *g;
  3407. nullpo_retr(-1, sd);
  3408. memset(guild_name, '\0', sizeof(guild_name));
  3409. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3410. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3411. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3412. return -1;
  3413. }
  3414. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3415. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3416. return -1;
  3417. }
  3418. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3419. (g = guild_search(atoi(message))) == NULL)
  3420. {
  3421. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3422. return -1;
  3423. }
  3424. count = 0;
  3425. iter = mapit_getallusers();
  3426. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3427. {
  3428. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3429. {
  3430. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3431. continue; //Skip GMs greater than you.
  3432. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3433. count++;
  3434. else
  3435. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3436. }
  3437. }
  3438. mapit_free(iter);
  3439. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3440. clif_displaymessage(fd, atcmd_output);
  3441. if (count) {
  3442. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3443. clif_displaymessage(fd, atcmd_output);
  3444. }
  3445. return 0;
  3446. }
  3447. /*==========================================
  3448. * Recall online characters of a party to your location
  3449. *------------------------------------------*/
  3450. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3451. {
  3452. struct map_session_data* pl_sd;
  3453. struct s_mapiterator* iter;
  3454. char party_name[NAME_LENGTH];
  3455. struct party_data *p;
  3456. int count;
  3457. nullpo_retr(-1, sd);
  3458. memset(party_name, '\0', sizeof(party_name));
  3459. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3460. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3461. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3462. return -1;
  3463. }
  3464. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3465. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3466. return -1;
  3467. }
  3468. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3469. (p = party_search(atoi(message))) == NULL)
  3470. {
  3471. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3472. return -1;
  3473. }
  3474. count = 0;
  3475. iter = mapit_getallusers();
  3476. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3477. {
  3478. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3479. {
  3480. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3481. continue; //Skip GMs greater than you.
  3482. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3483. count++;
  3484. else
  3485. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3486. }
  3487. }
  3488. mapit_free(iter);
  3489. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3490. clif_displaymessage(fd, atcmd_output);
  3491. if (count) {
  3492. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3493. clif_displaymessage(fd, atcmd_output);
  3494. }
  3495. return 0;
  3496. }
  3497. /*==========================================
  3498. *
  3499. *------------------------------------------*/
  3500. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3501. {
  3502. nullpo_retr(-1, sd);
  3503. itemdb_reload();
  3504. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3505. return 0;
  3506. }
  3507. /*==========================================
  3508. *
  3509. *------------------------------------------*/
  3510. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3511. {
  3512. nullpo_retr(-1, sd);
  3513. mob_reload();
  3514. read_petdb();
  3515. merc_reload();
  3516. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3517. return 0;
  3518. }
  3519. /*==========================================
  3520. *
  3521. *------------------------------------------*/
  3522. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3523. {
  3524. nullpo_retr(-1, sd);
  3525. skill_reload();
  3526. merc_skill_reload();
  3527. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3528. return 0;
  3529. }
  3530. /*==========================================
  3531. * @reloadatcommand - reloads atcommand_athena.conf
  3532. *------------------------------------------*/
  3533. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3534. {
  3535. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  3536. clif_displaymessage(fd, msg_txt(254));
  3537. return 0;
  3538. }
  3539. /*==========================================
  3540. * @reloadbattleconf - reloads battle_athena.conf
  3541. *------------------------------------------*/
  3542. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3543. {
  3544. struct Battle_Config prev_config;
  3545. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3546. battle_config_read(BATTLE_CONF_FILENAME);
  3547. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3548. || prev_config.item_rate_common != battle_config.item_rate_common
  3549. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3550. || prev_config.item_rate_card != battle_config.item_rate_card
  3551. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3552. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3553. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3554. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3555. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3556. || prev_config.item_rate_use != battle_config.item_rate_use
  3557. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3558. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3559. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3560. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3561. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3562. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3563. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3564. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3565. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3566. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3567. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3568. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3569. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3570. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3571. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3572. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3573. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3574. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3575. )
  3576. { //Drop rates changed.
  3577. mob_reload(); //Needed as well so rate changes take effect.
  3578. #ifndef TXT_ONLY
  3579. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3580. #endif
  3581. }
  3582. clif_displaymessage(fd, msg_txt(255));
  3583. return 0;
  3584. }
  3585. /*==========================================
  3586. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3587. *------------------------------------------*/
  3588. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3589. {
  3590. status_readdb();
  3591. clif_displaymessage(fd, msg_txt(256));
  3592. return 0;
  3593. }
  3594. /*==========================================
  3595. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3596. *------------------------------------------*/
  3597. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3598. {
  3599. pc_readdb();
  3600. clif_displaymessage(fd, msg_txt(257));
  3601. return 0;
  3602. }
  3603. /*==========================================
  3604. * @reloadmotd - reloads motd.txt
  3605. *------------------------------------------*/
  3606. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3607. {
  3608. pc_read_motd();
  3609. clif_displaymessage(fd, msg_txt(268));
  3610. return 0;
  3611. }
  3612. /*==========================================
  3613. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3614. *------------------------------------------*/
  3615. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3616. {
  3617. nullpo_retr(-1, sd);
  3618. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3619. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3620. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3621. flush_fifos();
  3622. script_reload();
  3623. npc_reload();
  3624. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3625. return 0;
  3626. }
  3627. /*==========================================
  3628. * @mapinfo [0-3] <map name> by MC_Cameri
  3629. * => Shows information about the map [map name]
  3630. * 0 = no additional information
  3631. * 1 = Show users in that map and their location
  3632. * 2 = Shows NPCs in that map
  3633. * 3 = Shows the shops/chats in that map (not implemented)
  3634. *------------------------------------------*/
  3635. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3636. {
  3637. struct map_session_data* pl_sd;
  3638. struct s_mapiterator* iter;
  3639. struct npc_data *nd = NULL;
  3640. struct chat_data *cd = NULL;
  3641. char direction[12];
  3642. int i, m_id, chat_num, list = 0;
  3643. unsigned short m_index;
  3644. char mapname[24];
  3645. nullpo_retr(-1, sd);
  3646. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3647. memset(mapname, '\0', sizeof(mapname));
  3648. memset(direction, '\0', sizeof(direction));
  3649. sscanf(message, "%d %23[^\n]", &list, mapname);
  3650. if (list < 0 || list > 3) {
  3651. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3652. return -1;
  3653. }
  3654. if (mapname[0] == '\0') {
  3655. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3656. m_id = map_mapindex2mapid(sd->mapindex);
  3657. } else {
  3658. m_id = map_mapname2mapid(mapname);
  3659. }
  3660. if (m_id < 0) {
  3661. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3662. return -1;
  3663. }
  3664. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3665. clif_displaymessage(fd, "------ Map Info ------");
  3666. // count chats (for initial message)
  3667. chat_num = 0;
  3668. iter = mapit_getallusers();
  3669. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3670. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3671. chat_num++;
  3672. mapit_free(iter);
  3673. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
  3674. clif_displaymessage(fd, atcmd_output);
  3675. clif_displaymessage(fd, "------ Map Flags ------");
  3676. strcpy(atcmd_output,"PvP Flags: ");
  3677. if (map[m_id].flag.pvp)
  3678. strcat(atcmd_output, "Pvp ON | ");
  3679. if (map[m_id].flag.pvp_noguild)
  3680. strcat(atcmd_output, "NoGuild | ");
  3681. if (map[m_id].flag.pvp_noparty)
  3682. strcat(atcmd_output, "NoParty | ");
  3683. if (map[m_id].flag.pvp_nightmaredrop)
  3684. strcat(atcmd_output, "NightmareDrop | ");
  3685. if (map[m_id].flag.pvp_nocalcrank)
  3686. strcat(atcmd_output, "NoCalcRank | ");
  3687. clif_displaymessage(fd, atcmd_output);
  3688. strcpy(atcmd_output,"GvG Flags: ");
  3689. if (map[m_id].flag.gvg)
  3690. strcat(atcmd_output, "GvG ON | ");
  3691. if (map[m_id].flag.gvg_dungeon)
  3692. strcat(atcmd_output, "GvG Dungeon | ");
  3693. if (map[m_id].flag.gvg_castle)
  3694. strcat(atcmd_output, "GvG Castle | ");
  3695. if (map[m_id].flag.gvg_noparty)
  3696. strcat(atcmd_output, "NoParty | ");
  3697. clif_displaymessage(fd, atcmd_output);
  3698. strcpy(atcmd_output,"Teleport Flags: ");
  3699. if (map[m_id].flag.noteleport)
  3700. strcat(atcmd_output, "NoTeleport | ");
  3701. if (map[m_id].flag.monster_noteleport)
  3702. strcat(atcmd_output, "Monster NoTeleport | ");
  3703. if (map[m_id].flag.nowarp)
  3704. strcat(atcmd_output, "NoWarp | ");
  3705. if (map[m_id].flag.nowarpto)
  3706. strcat(atcmd_output, "NoWarpTo | ");
  3707. if (map[m_id].flag.noreturn)
  3708. strcat(atcmd_output, "NoReturn | ");
  3709. if (map[m_id].flag.nogo)
  3710. strcat(atcmd_output, "NoGo | ");
  3711. if (map[m_id].flag.nomemo)
  3712. strcat(atcmd_output, "NoMemo | ");
  3713. clif_displaymessage(fd, atcmd_output);
  3714. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  3715. clif_displaymessage(fd, atcmd_output);
  3716. if (map[m_id].flag.nosave) {
  3717. if (!map[m_id].save.map)
  3718. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3719. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3720. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3721. else
  3722. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3723. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3724. clif_displaymessage(fd, atcmd_output);
  3725. }
  3726. strcpy(atcmd_output,"Weather Flags: ");
  3727. if (map[m_id].flag.snow)
  3728. strcat(atcmd_output, "Snow | ");
  3729. if (map[m_id].flag.fog)
  3730. strcat(atcmd_output, "Fog | ");
  3731. if (map[m_id].flag.sakura)
  3732. strcat(atcmd_output, "Sakura | ");
  3733. if (map[m_id].flag.clouds)
  3734. strcat(atcmd_output, "Clouds | ");
  3735. if (map[m_id].flag.clouds2)
  3736. strcat(atcmd_output, "Clouds2 | ");
  3737. if (map[m_id].flag.fireworks)
  3738. strcat(atcmd_output, "Fireworks | ");
  3739. if (map[m_id].flag.leaves)
  3740. strcat(atcmd_output, "Leaves | ");
  3741. if (map[m_id].flag.rain)
  3742. strcat(atcmd_output, "Rain | ");
  3743. if (map[m_id].flag.indoors)
  3744. strcat(atcmd_output, "Indoors | ");
  3745. if (map[m_id].flag.nightenabled)
  3746. strcat(atcmd_output, "Displays Night | ");
  3747. clif_displaymessage(fd, atcmd_output);
  3748. strcpy(atcmd_output,"Other Flags: ");
  3749. if (map[m_id].flag.nobranch)
  3750. strcat(atcmd_output, "NoBranch | ");
  3751. if (map[m_id].flag.notrade)
  3752. strcat(atcmd_output, "NoTrade | ");
  3753. if (map[m_id].flag.novending)
  3754. strcat(atcmd_output, "NoVending | ");
  3755. if (map[m_id].flag.nodrop)
  3756. strcat(atcmd_output, "NoDrop | ");
  3757. if (map[m_id].flag.noskill)
  3758. strcat(atcmd_output, "NoSkill | ");
  3759. if (map[m_id].flag.noicewall)
  3760. strcat(atcmd_output, "NoIcewall | ");
  3761. clif_displaymessage(fd, atcmd_output);
  3762. strcpy(atcmd_output,"Other Flags: ");
  3763. if (map[m_id].nocommand)
  3764. strcat(atcmd_output, "NoCommand | ");
  3765. if (map[m_id].flag.nobaseexp)
  3766. strcat(atcmd_output, "NoBaseEXP | ");
  3767. if (map[m_id].flag.nojobexp)
  3768. strcat(atcmd_output, "NoJobEXP | ");
  3769. if (map[m_id].flag.nomobloot)
  3770. strcat(atcmd_output, "NoMobLoot | ");
  3771. if (map[m_id].flag.nomvploot)
  3772. strcat(atcmd_output, "NoMVPLoot | ");
  3773. if (map[m_id].flag.partylock)
  3774. strcat(atcmd_output, "PartyLock | ");
  3775. if (map[m_id].flag.guildlock)
  3776. strcat(atcmd_output, "GuildLock | ");
  3777. clif_displaymessage(fd, atcmd_output);
  3778. switch (list) {
  3779. case 0:
  3780. // Do nothing. It's list 0, no additional display.
  3781. break;
  3782. case 1:
  3783. clif_displaymessage(fd, "----- Players in Map -----");
  3784. iter = mapit_getallusers();
  3785. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3786. {
  3787. if (pl_sd->mapindex == m_index) {
  3788. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3789. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3790. clif_displaymessage(fd, atcmd_output);
  3791. }
  3792. }
  3793. mapit_free(iter);
  3794. break;
  3795. case 2:
  3796. clif_displaymessage(fd, "----- NPCs in Map -----");
  3797. for (i = 0; i < map[m_id].npc_num;)
  3798. {
  3799. nd = map[m_id].npc[i];
  3800. switch(nd->ud.dir) {
  3801. case 0: strcpy(direction, "North"); break;
  3802. case 1: strcpy(direction, "North West"); break;
  3803. case 2: strcpy(direction, "West"); break;
  3804. case 3: strcpy(direction, "South West"); break;
  3805. case 4: strcpy(direction, "South"); break;
  3806. case 5: strcpy(direction, "South East"); break;
  3807. case 6: strcpy(direction, "East"); break;
  3808. case 7: strcpy(direction, "North East"); break;
  3809. case 9: strcpy(direction, "North"); break;
  3810. default: strcpy(direction, "Unknown"); break;
  3811. }
  3812. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3813. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3814. clif_displaymessage(fd, atcmd_output);
  3815. }
  3816. break;
  3817. case 3:
  3818. clif_displaymessage(fd, "----- Chats in Map -----");
  3819. iter = mapit_getallusers();
  3820. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3821. {
  3822. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3823. pl_sd->mapindex == m_index &&
  3824. cd->usersd[0] == pl_sd)
  3825. {
  3826. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  3827. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3828. clif_displaymessage(fd, atcmd_output);
  3829. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3830. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3831. clif_displaymessage(fd, atcmd_output);
  3832. }
  3833. }
  3834. mapit_free(iter);
  3835. break;
  3836. default: // normally impossible to arrive here
  3837. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3838. return -1;
  3839. break;
  3840. }
  3841. return 0;
  3842. }
  3843. /*==========================================
  3844. *
  3845. *------------------------------------------*/
  3846. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3847. {
  3848. nullpo_retr(-1, sd);
  3849. if (!pc_isriding(sd)) { // if actually no peco
  3850. if (!pc_checkskill(sd, KN_RIDING))
  3851. {
  3852. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  3853. return -1;
  3854. }
  3855. if (sd->disguise)
  3856. {
  3857. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  3858. return -1;
  3859. }
  3860. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3861. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  3862. } else { //Dismount
  3863. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3864. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  3865. }
  3866. return 0;
  3867. }
  3868. /*==========================================
  3869. *Spy Commands by Syrus22
  3870. *------------------------------------------*/
  3871. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3872. {
  3873. char guild_name[NAME_LENGTH];
  3874. struct guild *g;
  3875. nullpo_retr(-1, sd);
  3876. memset(guild_name, '\0', sizeof(guild_name));
  3877. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3878. if (!enable_spy)
  3879. {
  3880. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3881. return -1;
  3882. }
  3883. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3884. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3885. return -1;
  3886. }
  3887. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3888. (g = guild_search(atoi(message))) != NULL) {
  3889. if (sd->guildspy == g->guild_id) {
  3890. sd->guildspy = 0;
  3891. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3892. clif_displaymessage(fd, atcmd_output);
  3893. } else {
  3894. sd->guildspy = g->guild_id;
  3895. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3896. clif_displaymessage(fd, atcmd_output);
  3897. }
  3898. } else {
  3899. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  3900. return -1;
  3901. }
  3902. return 0;
  3903. }
  3904. /*==========================================
  3905. *
  3906. *------------------------------------------*/
  3907. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3908. {
  3909. char party_name[NAME_LENGTH];
  3910. struct party_data *p;
  3911. nullpo_retr(-1, sd);
  3912. memset(party_name, '\0', sizeof(party_name));
  3913. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3914. if (!enable_spy)
  3915. {
  3916. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3917. return -1;
  3918. }
  3919. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3920. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3921. return -1;
  3922. }
  3923. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3924. (p = party_search(atoi(message))) != NULL) {
  3925. if (sd->partyspy == p->party.party_id) {
  3926. sd->partyspy = 0;
  3927. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3928. clif_displaymessage(fd, atcmd_output);
  3929. } else {
  3930. sd->partyspy = p->party.party_id;
  3931. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3932. clif_displaymessage(fd, atcmd_output);
  3933. }
  3934. } else {
  3935. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  3936. return -1;
  3937. }
  3938. return 0;
  3939. }
  3940. /*==========================================
  3941. * @repairall [Valaris]
  3942. *------------------------------------------*/
  3943. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3944. {
  3945. int count, i;
  3946. nullpo_retr(-1, sd);
  3947. count = 0;
  3948. for (i = 0; i < MAX_INVENTORY; i++) {
  3949. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3950. sd->status.inventory[i].attribute = 0;
  3951. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3952. count++;
  3953. }
  3954. }
  3955. if (count > 0) {
  3956. clif_misceffect(&sd->bl, 3);
  3957. clif_equiplist(sd);
  3958. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3959. } else {
  3960. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3961. return -1;
  3962. }
  3963. return 0;
  3964. }
  3965. /*==========================================
  3966. * @nuke [Valaris]
  3967. *------------------------------------------*/
  3968. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3969. {
  3970. struct map_session_data *pl_sd;
  3971. nullpo_retr(-1, sd);
  3972. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3973. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3974. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  3975. return -1;
  3976. }
  3977. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3978. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  3979. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3980. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3981. } else {
  3982. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3983. return -1;
  3984. }
  3985. } else {
  3986. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3987. return -1;
  3988. }
  3989. return 0;
  3990. }
  3991. /*==========================================
  3992. * @tonpc
  3993. *------------------------------------------*/
  3994. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3995. {
  3996. char npcname[NAME_LENGTH+1];
  3997. struct npc_data *nd;
  3998. nullpo_retr(-1, sd);
  3999. memset(npcname, 0, sizeof(npcname));
  4000. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4001. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4002. return -1;
  4003. }
  4004. if ((nd = npc_name2id(npcname)) != NULL) {
  4005. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
  4006. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4007. else
  4008. return -1;
  4009. } else {
  4010. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4011. return -1;
  4012. }
  4013. return 0;
  4014. }
  4015. /*==========================================
  4016. *
  4017. *------------------------------------------*/
  4018. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4019. {
  4020. char NPCname[NAME_LENGTH+1];
  4021. nullpo_retr(-1, sd);
  4022. memset(NPCname, '\0', sizeof(NPCname));
  4023. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4024. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4025. return -1;
  4026. }
  4027. if (npc_name2id(NPCname) != NULL) {
  4028. npc_enable(NPCname, 1);
  4029. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4030. } else {
  4031. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4032. return -1;
  4033. }
  4034. return 0;
  4035. }
  4036. /*==========================================
  4037. *
  4038. *------------------------------------------*/
  4039. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4040. {
  4041. char NPCname[NAME_LENGTH+1];
  4042. nullpo_retr(-1, sd);
  4043. memset(NPCname, '\0', sizeof(NPCname));
  4044. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4045. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4046. return -1;
  4047. }
  4048. if (npc_name2id(NPCname) == NULL) {
  4049. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4050. return -1;
  4051. }
  4052. npc_enable(NPCname, 0);
  4053. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4054. return 0;
  4055. }
  4056. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4057. {
  4058. FILE *fp;
  4059. if (!message || !*message) {
  4060. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4061. return -1;
  4062. }
  4063. // check if script file exists
  4064. if ((fp = fopen(message, "r")) == NULL) {
  4065. clif_displaymessage(fd, msg_txt(261));
  4066. return -1;
  4067. }
  4068. fclose(fp);
  4069. // add to list of script sources and run it
  4070. npc_addsrcfile(message);
  4071. npc_parsesrcfile(message);
  4072. npc_read_event_script();
  4073. clif_displaymessage(fd, msg_txt(262));
  4074. return 0;
  4075. }
  4076. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4077. {
  4078. struct npc_data *nd;
  4079. char NPCname[NAME_LENGTH+1];
  4080. nullpo_retr(-1, sd);
  4081. memset(NPCname, '\0', sizeof(NPCname));
  4082. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4083. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4084. return -1;
  4085. }
  4086. if ((nd = npc_name2id(NPCname)) == NULL) {
  4087. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4088. return -1;
  4089. }
  4090. npc_unload_duplicates(nd);
  4091. npc_unload(nd);
  4092. npc_read_event_script();
  4093. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4094. return 0;
  4095. }
  4096. /*==========================================
  4097. * time in txt for time command (by [Yor])
  4098. *------------------------------------------*/
  4099. char* txt_time(unsigned int duration)
  4100. {
  4101. int days, hours, minutes, seconds;
  4102. char temp[256];
  4103. static char temp1[256];
  4104. memset(temp, '\0', sizeof(temp));
  4105. memset(temp1, '\0', sizeof(temp1));
  4106. days = duration / (60 * 60 * 24);
  4107. duration = duration - (60 * 60 * 24 * days);
  4108. hours = duration / (60 * 60);
  4109. duration = duration - (60 * 60 * hours);
  4110. minutes = duration / 60;
  4111. seconds = duration - (60 * minutes);
  4112. if (days < 2)
  4113. sprintf(temp, msg_txt(219), days); // %d day
  4114. else
  4115. sprintf(temp, msg_txt(220), days); // %d days
  4116. if (hours < 2)
  4117. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4118. else
  4119. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4120. if (minutes < 2)
  4121. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4122. else
  4123. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4124. if (seconds < 2)
  4125. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4126. else
  4127. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4128. return temp1;
  4129. }
  4130. /*==========================================
  4131. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4132. * Calculation management of GM modification (@day/@night GM commands) is done
  4133. *------------------------------------------*/
  4134. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4135. {
  4136. const struct TimerData * timer_data;
  4137. const struct TimerData * timer_data2;
  4138. time_t time_server; // variable for number of seconds (used with time() function)
  4139. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4140. char temp[256];
  4141. nullpo_retr(-1, sd);
  4142. memset(temp, '\0', sizeof(temp));
  4143. time(&time_server); // get time in seconds since 1/1/1970
  4144. datetime = localtime(&time_server); // convert seconds in structure
  4145. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4146. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4147. clif_displaymessage(fd, temp);
  4148. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4149. if (night_flag == 0)
  4150. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4151. else
  4152. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4153. } else if (battle_config.night_duration == 0)
  4154. if (night_flag == 1) { // we start with night
  4155. timer_data = get_timer(day_timer_tid);
  4156. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4157. clif_displaymessage(fd, temp);
  4158. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4159. } else
  4160. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4161. else if (battle_config.day_duration == 0)
  4162. if (night_flag == 0) { // we start with day
  4163. timer_data = get_timer(night_timer_tid);
  4164. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4165. clif_displaymessage(fd, temp);
  4166. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4167. } else
  4168. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4169. else {
  4170. if (night_flag == 0) {
  4171. timer_data = get_timer(night_timer_tid);
  4172. timer_data2 = get_timer(day_timer_tid);
  4173. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4174. clif_displaymessage(fd, temp);
  4175. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4176. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  4177. else
  4178. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4179. clif_displaymessage(fd, temp);
  4180. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4181. clif_displaymessage(fd, temp);
  4182. } else {
  4183. timer_data = get_timer(day_timer_tid);
  4184. timer_data2 = get_timer(night_timer_tid);
  4185. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4186. clif_displaymessage(fd, temp);
  4187. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4188. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  4189. else
  4190. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4191. clif_displaymessage(fd, temp);
  4192. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4193. clif_displaymessage(fd, temp);
  4194. }
  4195. }
  4196. return 0;
  4197. }
  4198. //Added by Coltaro
  4199. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  4200. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4201. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4202. {
  4203. const int factor_year = 518400; //12*30*24*60 = 518400
  4204. const int factor_month = 43200; //30*24*60 = 43200
  4205. const int factor_day = 1440; //24*60 = 1440
  4206. const int factor_hour = 60;
  4207. *year = jailtime/factor_year;
  4208. jailtime -= *year*factor_year;
  4209. *month = jailtime/factor_month;
  4210. jailtime -= *month*factor_month;
  4211. *day = jailtime/factor_day;
  4212. jailtime -= *day*factor_day;
  4213. *hour = jailtime/factor_hour;
  4214. jailtime -= *hour*factor_hour;
  4215. *minute = jailtime;
  4216. *year = *year > 0? *year : 0;
  4217. *month = *month > 0? *month : 0;
  4218. *day = *day > 0? *day : 0;
  4219. *hour = *hour > 0? *hour : 0;
  4220. *minute = *minute > 0? *minute : 0;
  4221. return;
  4222. }
  4223. /*==========================================
  4224. * @jail <char_name> by [Yor]
  4225. * Special warp! No check with nowarp and nowarpto flag
  4226. *------------------------------------------*/
  4227. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4228. {
  4229. struct map_session_data *pl_sd;
  4230. int x, y;
  4231. unsigned short m_index;
  4232. nullpo_retr(-1, sd);
  4233. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4234. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4235. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4236. return -1;
  4237. }
  4238. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4239. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4240. return -1;
  4241. }
  4242. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4243. { // you can jail only lower or same GM
  4244. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4245. return -1;
  4246. }
  4247. if (pl_sd->sc.data[SC_JAILED])
  4248. {
  4249. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4250. return -1;
  4251. }
  4252. switch(rand() % 2) { //Jail Locations
  4253. case 0:
  4254. m_index = mapindex_name2id(MAP_JAIL);
  4255. x = 24;
  4256. y = 75;
  4257. break;
  4258. default:
  4259. m_index = mapindex_name2id(MAP_JAIL);
  4260. x = 49;
  4261. y = 75;
  4262. break;
  4263. }
  4264. //Duration of INT_MAX to specify infinity.
  4265. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4266. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4267. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4268. return 0;
  4269. }
  4270. /*==========================================
  4271. * @unjail/@discharge <char_name> by [Yor]
  4272. * Special warp! No check with nowarp and nowarpto flag
  4273. *------------------------------------------*/
  4274. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4275. {
  4276. struct map_session_data *pl_sd;
  4277. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4278. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4279. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4280. return -1;
  4281. }
  4282. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4283. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4284. return -1;
  4285. }
  4286. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4287. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4288. return -1;
  4289. }
  4290. if (!pl_sd->sc.data[SC_JAILED])
  4291. {
  4292. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4293. return -1;
  4294. }
  4295. //Reset jail time to 1 sec.
  4296. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4297. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4298. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4299. return 0;
  4300. }
  4301. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4302. {
  4303. struct map_session_data *pl_sd = NULL;
  4304. int year, month, day, hour, minute, value;
  4305. char * modif_p;
  4306. int jailtime = 0,x,y;
  4307. short m_index = 0;
  4308. nullpo_retr(-1, sd);
  4309. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4310. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4311. return -1;
  4312. }
  4313. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4314. modif_p = atcmd_output;
  4315. year = month = day = hour = minute = 0;
  4316. while (modif_p[0] != '\0') {
  4317. value = atoi(modif_p);
  4318. if (value == 0)
  4319. modif_p++;
  4320. else {
  4321. if (modif_p[0] == '-' || modif_p[0] == '+')
  4322. modif_p++;
  4323. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4324. modif_p++;
  4325. if (modif_p[0] == 'n') {
  4326. minute = value;
  4327. modif_p++;
  4328. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4329. minute = value;
  4330. modif_p = modif_p + 2;
  4331. } else if (modif_p[0] == 'h') {
  4332. hour = value;
  4333. modif_p++;
  4334. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4335. day = value;
  4336. modif_p++;
  4337. } else if (modif_p[0] == 'm') {
  4338. month = value;
  4339. modif_p++;
  4340. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4341. year = value;
  4342. modif_p++;
  4343. } else if (modif_p[0] != '\0') {
  4344. modif_p++;
  4345. }
  4346. }
  4347. }
  4348. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4349. clif_displaymessage(fd, "Invalid time for jail command.");
  4350. return -1;
  4351. }
  4352. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4353. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4354. return -1;
  4355. }
  4356. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4357. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4358. return -1;
  4359. }
  4360. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4361. if(jailtime==0) {
  4362. clif_displaymessage(fd, "Invalid time for jail command.");
  4363. return -1;
  4364. }
  4365. //Added by Coltaro
  4366. if(pl_sd->sc.data[SC_JAILED] &&
  4367. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4368. { //Update the player's jail time
  4369. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4370. if (jailtime <= 0) {
  4371. jailtime = 0;
  4372. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4373. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4374. } else {
  4375. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4376. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4377. clif_displaymessage(pl_sd->fd, atcmd_output);
  4378. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4379. clif_displaymessage(fd, atcmd_output);
  4380. }
  4381. } else if (jailtime < 0) {
  4382. clif_displaymessage(fd, "Invalid time for jail command.");
  4383. return -1;
  4384. }
  4385. //Jail locations, add more as you wish.
  4386. switch(rand()%2)
  4387. {
  4388. case 1: //Jail #1
  4389. m_index = mapindex_name2id(MAP_JAIL);
  4390. x = 49; y = 75;
  4391. break;
  4392. default: //Default Jail
  4393. m_index = mapindex_name2id(MAP_JAIL);
  4394. x = 24; y = 75;
  4395. break;
  4396. }
  4397. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  4398. return 0;
  4399. }
  4400. //By Coltaro
  4401. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4402. {
  4403. int year, month, day, hour, minute;
  4404. nullpo_retr(-1, sd);
  4405. if (!sd->sc.data[SC_JAILED]) {
  4406. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4407. return -1;
  4408. }
  4409. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4410. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4411. return 0;
  4412. }
  4413. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4414. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4415. return -1;
  4416. }
  4417. //Get remaining jail time
  4418. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4419. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4420. clif_displaymessage(fd, atcmd_output);
  4421. return 0;
  4422. }
  4423. /*==========================================
  4424. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4425. *------------------------------------------*/
  4426. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4427. {
  4428. int id = 0;
  4429. nullpo_retr(-1, sd);
  4430. if (!message || !*message) {
  4431. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4432. return -1;
  4433. }
  4434. if ((id = atoi(message)) > 0)
  4435. { //Acquired an ID
  4436. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4437. id = 0; //Invalid id for either mobs or npcs.
  4438. } else { //Acquired a Name
  4439. if ((id = mobdb_searchname(message)) == 0)
  4440. {
  4441. struct npc_data* nd = npc_name2id(message);
  4442. if (nd != NULL)
  4443. id = nd->class_;
  4444. }
  4445. }
  4446. if (id == 0)
  4447. {
  4448. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4449. return -1;
  4450. }
  4451. if(pc_isriding(sd))
  4452. {
  4453. //FIXME: wrong message [ultramage]
  4454. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4455. return -1;
  4456. }
  4457. pc_disguise(sd, id);
  4458. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4459. return 0;
  4460. }
  4461. /*==========================================
  4462. * DisguiseAll
  4463. *------------------------------------------*/
  4464. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4465. {
  4466. int mob_id=0;
  4467. struct map_session_data *pl_sd;
  4468. struct s_mapiterator* iter;
  4469. nullpo_retr(-1, sd);
  4470. if (!message || !*message) {
  4471. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4472. return -1;
  4473. }
  4474. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4475. mob_id = atoi(message);
  4476. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4477. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4478. return -1;
  4479. }
  4480. iter = mapit_getallusers();
  4481. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4482. pc_disguise(pl_sd, mob_id);
  4483. mapit_free(iter);
  4484. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4485. return 0;
  4486. }
  4487. /*==========================================
  4488. * @undisguise by [Yor]
  4489. *------------------------------------------*/
  4490. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4491. {
  4492. nullpo_retr(-1, sd);
  4493. if (sd->disguise) {
  4494. pc_disguise(sd, 0);
  4495. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4496. } else {
  4497. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4498. return -1;
  4499. }
  4500. return 0;
  4501. }
  4502. /*==========================================
  4503. * UndisguiseAll
  4504. *------------------------------------------*/
  4505. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4506. {
  4507. struct map_session_data *pl_sd;
  4508. struct s_mapiterator* iter;
  4509. nullpo_retr(-1, sd);
  4510. iter = mapit_getallusers();
  4511. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4512. if( pl_sd->disguise )
  4513. pc_disguise(pl_sd, 0);
  4514. mapit_free(iter);
  4515. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4516. return 0;
  4517. }
  4518. /*==========================================
  4519. * @exp by [Skotlex]
  4520. *------------------------------------------*/
  4521. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4522. {
  4523. char output[200];
  4524. double nextb, nextj;
  4525. nullpo_retr(-1, sd);
  4526. memset(output, '\0', sizeof(output));
  4527. nextb = pc_nextbaseexp(sd);
  4528. if (nextb)
  4529. nextb = sd->status.base_exp*100.0/nextb;
  4530. nextj = pc_nextjobexp(sd);
  4531. if (nextj)
  4532. nextj = sd->status.job_exp*100.0/nextj;
  4533. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4534. clif_displaymessage(fd, output);
  4535. return 0;
  4536. }
  4537. /*==========================================
  4538. * @broadcast by [Valaris]
  4539. *------------------------------------------*/
  4540. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4541. {
  4542. nullpo_retr(-1, sd);
  4543. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4544. if (!message || !*message) {
  4545. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4546. return -1;
  4547. }
  4548. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4549. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4550. return 0;
  4551. }
  4552. /*==========================================
  4553. * @localbroadcast by [Valaris]
  4554. *------------------------------------------*/
  4555. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4556. {
  4557. nullpo_retr(-1, sd);
  4558. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4559. if (!message || !*message) {
  4560. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4561. return -1;
  4562. }
  4563. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4564. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4565. return 0;
  4566. }
  4567. /*==========================================
  4568. * @email <actual@email> <new@email> by [Yor]
  4569. *------------------------------------------*/
  4570. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4571. {
  4572. char actual_email[100];
  4573. char new_email[100];
  4574. nullpo_retr(-1, sd);
  4575. memset(actual_email, '\0', sizeof(actual_email));
  4576. memset(new_email, '\0', sizeof(new_email));
  4577. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4578. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4579. return -1;
  4580. }
  4581. if (e_mail_check(actual_email) == 0) {
  4582. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4583. return -1;
  4584. } else if (e_mail_check(new_email) == 0) {
  4585. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4586. return -1;
  4587. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4588. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4589. return -1;
  4590. } else if (strcmpi(actual_email, new_email) == 0) {
  4591. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4592. return -1;
  4593. }
  4594. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4595. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4596. return 0;
  4597. }
  4598. /*==========================================
  4599. *@effect
  4600. *------------------------------------------*/
  4601. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4602. {
  4603. int type = 0, flag = 0;
  4604. nullpo_retr(-1, sd);
  4605. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4606. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4607. return -1;
  4608. }
  4609. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4610. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4611. return 0;
  4612. }
  4613. /*==========================================
  4614. * @killer by MouseJstr
  4615. * enable killing players even when not in pvp
  4616. *------------------------------------------*/
  4617. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4618. {
  4619. nullpo_retr(-1, sd);
  4620. sd->state.killer = !sd->state.killer;
  4621. if(sd->state.killer)
  4622. clif_displaymessage(fd, msg_txt(241));
  4623. else {
  4624. clif_displaymessage(fd, msg_txt(287));
  4625. pc_stop_attack(sd);
  4626. }
  4627. return 0;
  4628. }
  4629. /*==========================================
  4630. * @killable by MouseJstr
  4631. * enable other people killing you
  4632. *------------------------------------------*/
  4633. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4634. {
  4635. nullpo_retr(-1, sd);
  4636. sd->state.killable = !sd->state.killable;
  4637. if(sd->state.killable)
  4638. clif_displaymessage(fd, msg_txt(242));
  4639. else {
  4640. clif_displaymessage(fd, msg_txt(288));
  4641. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4642. }
  4643. return 0;
  4644. }
  4645. /*==========================================
  4646. * @skillon by MouseJstr
  4647. * turn skills on for the map
  4648. *------------------------------------------*/
  4649. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4650. {
  4651. nullpo_retr(-1, sd);
  4652. map[sd->bl.m].flag.noskill = 0;
  4653. clif_displaymessage(fd, msg_txt(244));
  4654. return 0;
  4655. }
  4656. /*==========================================
  4657. * @skilloff by MouseJstr
  4658. * Turn skills off on the map
  4659. *------------------------------------------*/
  4660. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4661. {
  4662. nullpo_retr(-1, sd);
  4663. map[sd->bl.m].flag.noskill = 1;
  4664. clif_displaymessage(fd, msg_txt(243));
  4665. return 0;
  4666. }
  4667. /*==========================================
  4668. * @npcmove by MouseJstr
  4669. * move a npc
  4670. *------------------------------------------*/
  4671. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4672. {
  4673. int x = 0, y = 0, m;
  4674. struct npc_data *nd = 0;
  4675. nullpo_retr(-1, sd);
  4676. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4677. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4678. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4679. return -1;
  4680. }
  4681. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4682. {
  4683. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4684. return -1;
  4685. }
  4686. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4687. {
  4688. clif_displaymessage(fd, "NPC is not on this map.");
  4689. return -1; //Not on a map.
  4690. }
  4691. x = cap_value(x, 0, map[m].xs-1);
  4692. y = cap_value(y, 0, map[m].ys-1);
  4693. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4694. map_moveblock(&nd->bl, x, y, gettick());
  4695. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4696. clif_displaymessage(fd, "NPC moved.");
  4697. return 0;
  4698. }
  4699. /*==========================================
  4700. * @addwarp by MouseJstr
  4701. * Create a new static warp point.
  4702. *------------------------------------------*/
  4703. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4704. {
  4705. char mapname[32];
  4706. int x,y;
  4707. unsigned short m;
  4708. struct npc_data* nd;
  4709. nullpo_retr(-1, sd);
  4710. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4711. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4712. return -1;
  4713. }
  4714. m = mapindex_name2id(mapname);
  4715. if( m == 0 )
  4716. {
  4717. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4718. clif_displaymessage(fd, atcmd_output);
  4719. return -1;
  4720. }
  4721. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4722. if( nd == NULL )
  4723. return -1;
  4724. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4725. clif_displaymessage(fd, atcmd_output);
  4726. return 0;
  4727. }
  4728. /*==========================================
  4729. * @follow by [MouseJstr]
  4730. * Follow a player .. staying no more then 5 spaces away
  4731. *------------------------------------------*/
  4732. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4733. {
  4734. struct map_session_data *pl_sd = NULL;
  4735. nullpo_retr(-1, sd);
  4736. if (!message || !*message) {
  4737. if (sd->followtarget == -1)
  4738. return -1;
  4739. pc_stop_following (sd);
  4740. clif_displaymessage(fd, "Follow mode OFF.");
  4741. return 0;
  4742. }
  4743. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4744. {
  4745. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4746. return -1;
  4747. }
  4748. if (sd->followtarget == pl_sd->bl.id) {
  4749. pc_stop_following (sd);
  4750. clif_displaymessage(fd, "Follow mode OFF.");
  4751. } else {
  4752. pc_follow(sd, pl_sd->bl.id);
  4753. clif_displaymessage(fd, "Follow mode ON.");
  4754. }
  4755. return 0;
  4756. }
  4757. /*==========================================
  4758. * @dropall by [MouseJstr]
  4759. * Drop all your possession on the ground
  4760. *------------------------------------------*/
  4761. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4762. {
  4763. int i;
  4764. nullpo_retr(-1, sd);
  4765. for (i = 0; i < MAX_INVENTORY; i++) {
  4766. if (sd->status.inventory[i].amount) {
  4767. if(sd->status.inventory[i].equip != 0)
  4768. pc_unequipitem(sd, i, 3);
  4769. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4770. }
  4771. }
  4772. return 0;
  4773. }
  4774. /*==========================================
  4775. * @storeall by [MouseJstr]
  4776. * Put everything into storage
  4777. *------------------------------------------*/
  4778. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4779. {
  4780. int i;
  4781. nullpo_retr(-1, sd);
  4782. if (sd->state.storage_flag != 1)
  4783. { //Open storage.
  4784. if( storage_storageopen(sd) == 1 ) {
  4785. clif_displaymessage(fd, "You can't open the storage currently.");
  4786. return -1;
  4787. }
  4788. }
  4789. for (i = 0; i < MAX_INVENTORY; i++) {
  4790. if (sd->status.inventory[i].amount) {
  4791. if(sd->status.inventory[i].equip != 0)
  4792. pc_unequipitem(sd, i, 3);
  4793. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4794. }
  4795. }
  4796. storage_storageclose(sd);
  4797. clif_displaymessage(fd, "It is done");
  4798. return 0;
  4799. }
  4800. /*==========================================
  4801. * @skillid by [MouseJstr]
  4802. * lookup a skill by name
  4803. *------------------------------------------*/
  4804. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4805. {
  4806. int skillen, idx;
  4807. nullpo_retr(-1, sd);
  4808. if (!message || !*message)
  4809. {
  4810. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4811. return -1;
  4812. }
  4813. skillen = strlen(message);
  4814. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4815. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4816. {
  4817. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4818. clif_displaymessage(fd, atcmd_output);
  4819. }
  4820. }
  4821. return 0;
  4822. }
  4823. /*==========================================
  4824. * @useskill by [MouseJstr]
  4825. * A way of using skills without having to find them in the skills menu
  4826. *------------------------------------------*/
  4827. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4828. {
  4829. struct map_session_data *pl_sd = NULL;
  4830. struct block_list *bl;
  4831. int skillnum;
  4832. int skilllv;
  4833. char target[100];
  4834. nullpo_retr(-1, sd);
  4835. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4836. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4837. return -1;
  4838. }
  4839. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4840. {
  4841. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4842. return -1;
  4843. }
  4844. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  4845. {
  4846. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4847. return -1;
  4848. }
  4849. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4850. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4851. bl = &sd->hd->bl;
  4852. else
  4853. bl = &sd->bl;
  4854. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4855. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4856. else
  4857. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4858. return 0;
  4859. }
  4860. /*==========================================
  4861. * @displayskill by [Skotlex]
  4862. * Debug command to locate new skill IDs. It sends the
  4863. * three possible skill-effect packets to the area.
  4864. *------------------------------------------*/
  4865. int atcommand_displayskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4866. {
  4867. struct status_data * status;
  4868. unsigned int tick;
  4869. int skillnum;
  4870. int skilllv = 1;
  4871. nullpo_retr(-1, sd);
  4872. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4873. {
  4874. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4875. return -1;
  4876. }
  4877. status = status_get_status_data(&sd->bl);
  4878. tick = gettick();
  4879. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4880. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4881. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4882. return 0;
  4883. }
  4884. /*==========================================
  4885. * @skilltree by [MouseJstr]
  4886. * prints the skill tree for a player required to get to a skill
  4887. *------------------------------------------*/
  4888. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4889. {
  4890. struct map_session_data *pl_sd = NULL;
  4891. int skillnum;
  4892. int meets, j, c=0;
  4893. char target[NAME_LENGTH], *tbl;
  4894. struct skill_tree_entry *ent;
  4895. nullpo_retr(-1, sd);
  4896. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4897. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4898. return -1;
  4899. }
  4900. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4901. {
  4902. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4903. return -1;
  4904. }
  4905. c = pc_calc_skilltree_normalize_job(pl_sd);
  4906. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4907. tbl = job_name(c);
  4908. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", tbl, pc_checkskill(pl_sd, 1));
  4909. clif_displaymessage(fd, atcmd_output);
  4910. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  4911. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4912. {
  4913. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4914. clif_displaymessage(fd, atcmd_output);
  4915. return 0;
  4916. }
  4917. ent = &skill_tree[c][j];
  4918. meets = 1;
  4919. for(j=0;j<5;j++)
  4920. {
  4921. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4922. {
  4923. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  4924. clif_displaymessage(fd, atcmd_output);
  4925. meets = 0;
  4926. }
  4927. }
  4928. if (meets == 1) {
  4929. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4930. clif_displaymessage(fd, atcmd_output);
  4931. }
  4932. return 0;
  4933. }
  4934. // Hand a ring with partners name on it to this char
  4935. void getring (struct map_session_data* sd)
  4936. {
  4937. int flag, item_id;
  4938. struct item item_tmp;
  4939. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4940. memset(&item_tmp, 0, sizeof(item_tmp));
  4941. item_tmp.nameid = item_id;
  4942. item_tmp.identify = 1;
  4943. item_tmp.card[0] = 255;
  4944. item_tmp.card[2] = sd->status.partner_id;
  4945. item_tmp.card[3] = sd->status.partner_id >> 16;
  4946. //Logs (A)dmins items [Lupus]
  4947. if(log_config.enable_logs&0x400)
  4948. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  4949. if((flag = pc_additem(sd,&item_tmp,1))) {
  4950. clif_additem(sd,0,0,flag);
  4951. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4952. }
  4953. }
  4954. /*==========================================
  4955. * @marry by [MouseJstr], fixed by Lupus
  4956. * Marry two players
  4957. *------------------------------------------*/
  4958. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4959. {
  4960. struct map_session_data *pl_sd1 = NULL;
  4961. struct map_session_data *pl_sd2 = NULL;
  4962. char player1[128], player2[128]; //Length used for return error msgs
  4963. nullpo_retr(-1, sd);
  4964. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  4965. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  4966. return -1;
  4967. }
  4968. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  4969. sprintf(player2, "Cannot find player '%s' online", player1);
  4970. clif_displaymessage(fd, player2);
  4971. return -1;
  4972. }
  4973. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  4974. sprintf(player1, "Cannot find player '%s' online", player2);
  4975. clif_displaymessage(fd, player1);
  4976. return -1;
  4977. }
  4978. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  4979. clif_displaymessage(fd, "They are married.. wish them well");
  4980. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  4981. // Auto-give named rings (Aru)
  4982. getring (pl_sd1);
  4983. getring (pl_sd2);
  4984. return 0;
  4985. }
  4986. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  4987. return -1;
  4988. }
  4989. /*==========================================
  4990. * @divorce by [MouseJstr], fixed by [Lupus]
  4991. * divorce two players
  4992. *------------------------------------------*/
  4993. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4994. {
  4995. struct map_session_data *pl_sd = NULL;
  4996. nullpo_retr(-1, sd);
  4997. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  4998. clif_displaymessage(fd, "Usage: @divorce <player>.");
  4999. return -1;
  5000. }
  5001. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5002. {
  5003. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5004. return -1;
  5005. }
  5006. if (pc_divorce(pl_sd) != 0) {
  5007. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5008. clif_displaymessage(fd, atcmd_output);
  5009. return -1;
  5010. }
  5011. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5012. clif_displaymessage(fd, atcmd_output);
  5013. return 0;
  5014. }
  5015. /*==========================================
  5016. * @changelook by [Celest]
  5017. *------------------------------------------*/
  5018. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5019. {
  5020. int i, j = 0, k = 0;
  5021. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5022. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5023. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5024. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5025. return -1;
  5026. } else if (i == 2) {
  5027. if (j < 1) j = 1;
  5028. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5029. j = pos[j - 1];
  5030. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5031. k = j; // swap
  5032. j = LOOK_HEAD_TOP;
  5033. }
  5034. clif_changelook(&sd->bl,j,k);
  5035. return 0;
  5036. }
  5037. /*==========================================
  5038. * @autotrade by durf (changed by Lupus)
  5039. * Turns on/off Autotrade for a specific player
  5040. *------------------------------------------*/
  5041. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5042. {
  5043. nullpo_retr(-1, sd);
  5044. if( sd->vender_id ) //check if player's vending
  5045. {
  5046. if( pc_isdead(sd) )
  5047. {
  5048. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  5049. return -1;
  5050. }
  5051. if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
  5052. {
  5053. sd->state.autotrade = 1;
  5054. if( battle_config.at_timeout )
  5055. {
  5056. int timeout = atoi(message);
  5057. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  5058. }
  5059. clif_authfail_fd(fd, 15);
  5060. } else
  5061. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5062. }
  5063. else
  5064. clif_displaymessage(fd, msg_txt(549)); // You should be vending to use @Autotrade.
  5065. return 0;
  5066. }
  5067. /*==========================================
  5068. * @changegm by durf (changed by Lupus)
  5069. * Changes Master of your Guild to a specified guild member
  5070. *------------------------------------------*/
  5071. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5072. {
  5073. struct guild *g;
  5074. struct map_session_data *pl_sd;
  5075. nullpo_retr(-1, sd);
  5076. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5077. {
  5078. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5079. return -1;
  5080. }
  5081. if( map[sd->bl.m].flag.guildlock )
  5082. {
  5083. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5084. return -1;
  5085. }
  5086. if (strlen(message)==0)
  5087. {
  5088. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5089. return -1;
  5090. }
  5091. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5092. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5093. return -1;
  5094. }
  5095. guild_gm_change(sd->status.guild_id, pl_sd);
  5096. return 0;
  5097. }
  5098. /*==========================================
  5099. * @changeleader by Skotlex
  5100. * Changes the leader of a party.
  5101. *------------------------------------------*/
  5102. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5103. {
  5104. nullpo_retr(-1, sd);
  5105. if (strlen(message)==0)
  5106. {
  5107. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5108. return -1;
  5109. }
  5110. if (party_changeleader(sd, map_nick2sd((char *) message)))
  5111. return 0;
  5112. return -1;
  5113. }
  5114. /*==========================================
  5115. * @partyoption by Skotlex
  5116. * Used to change the item share setting of a party.
  5117. *------------------------------------------*/
  5118. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5119. {
  5120. struct party_data *p;
  5121. int mi, option;
  5122. char w1[16], w2[16];
  5123. nullpo_retr(-1, sd);
  5124. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5125. {
  5126. clif_displaymessage(fd, msg_txt(282));
  5127. return -1;
  5128. }
  5129. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5130. if (mi == MAX_PARTY)
  5131. return -1; //Shouldn't happen
  5132. if (!p->party.member[mi].leader)
  5133. {
  5134. clif_displaymessage(fd, msg_txt(282));
  5135. return -1;
  5136. }
  5137. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5138. {
  5139. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5140. return -1;
  5141. }
  5142. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5143. //Change item share type.
  5144. if (option != p->party.item)
  5145. party_changeoption(sd, p->party.exp, option);
  5146. else
  5147. clif_displaymessage(fd, msg_txt(286));
  5148. return 0;
  5149. }
  5150. /*==========================================
  5151. * @autoloot by Upa-Kun
  5152. * Turns on/off AutoLoot for a specific player
  5153. *------------------------------------------*/
  5154. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5155. {
  5156. int rate;
  5157. double drate;
  5158. nullpo_retr(-1, sd);
  5159. // autoloot command without value
  5160. if(!message || !*message)
  5161. {
  5162. if (sd->state.autoloot)
  5163. rate = 0;
  5164. else
  5165. rate = 10000;
  5166. } else {
  5167. drate = atof(message);
  5168. rate = (int)(drate*100);
  5169. }
  5170. if (rate < 0) rate = 0;
  5171. if (rate > 10000) rate = 10000;
  5172. sd->state.autoloot = rate;
  5173. if (sd->state.autoloot) {
  5174. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5175. clif_displaymessage(fd, atcmd_output);
  5176. }else
  5177. clif_displaymessage(fd, "Autoloot is now off.");
  5178. return 0;
  5179. }
  5180. /*==========================================
  5181. * @autolootitem
  5182. *------------------------------------------*/
  5183. int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5184. {
  5185. struct item_data *item_data = NULL;
  5186. if (!message || !*message) {
  5187. if (sd->state.autolootid) {
  5188. sd->state.autolootid = 0;
  5189. clif_displaymessage(fd, "Autolootitem have been turned OFF.");
  5190. } else
  5191. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>).");
  5192. return -1;
  5193. }
  5194. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5195. item_data = itemdb_searchname(message);
  5196. if (!item_data) {
  5197. // No items founds in the DB with Id or Name
  5198. clif_displaymessage(fd, "Item not found.");
  5199. return -1;
  5200. }
  5201. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  5202. sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
  5203. item_data->name, item_data->jname, item_data->nameid);
  5204. clif_displaymessage(fd, atcmd_output);
  5205. return 0;
  5206. }
  5207. /*==========================================
  5208. * It is made to rain.
  5209. *------------------------------------------*/
  5210. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5211. {
  5212. nullpo_retr(-1, sd);
  5213. if (map[sd->bl.m].flag.rain) {
  5214. map[sd->bl.m].flag.rain=0;
  5215. clif_weather(sd->bl.m);
  5216. clif_displaymessage(fd, "The rain has stopped.");
  5217. } else {
  5218. map[sd->bl.m].flag.rain=1;
  5219. clif_weather(sd->bl.m);
  5220. clif_displaymessage(fd, "It is made to rain.");
  5221. }
  5222. return 0;
  5223. }
  5224. /*==========================================
  5225. * It is made to snow.
  5226. *------------------------------------------*/
  5227. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5228. {
  5229. nullpo_retr(-1, sd);
  5230. if (map[sd->bl.m].flag.snow) {
  5231. map[sd->bl.m].flag.snow=0;
  5232. clif_weather(sd->bl.m);
  5233. clif_displaymessage(fd, "Snow has stopped falling.");
  5234. } else {
  5235. map[sd->bl.m].flag.snow=1;
  5236. clif_weather(sd->bl.m);
  5237. clif_displaymessage(fd, "It is made to snow.");
  5238. }
  5239. return 0;
  5240. }
  5241. /*==========================================
  5242. * Cherry tree snowstorm is made to fall. (Sakura)
  5243. *------------------------------------------*/
  5244. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5245. {
  5246. nullpo_retr(-1, sd);
  5247. if (map[sd->bl.m].flag.sakura) {
  5248. map[sd->bl.m].flag.sakura=0;
  5249. clif_weather(sd->bl.m);
  5250. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5251. } else {
  5252. map[sd->bl.m].flag.sakura=1;
  5253. clif_weather(sd->bl.m);
  5254. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5255. }
  5256. return 0;
  5257. }
  5258. /*==========================================
  5259. * Clouds appear.
  5260. *------------------------------------------*/
  5261. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5262. {
  5263. nullpo_retr(-1, sd);
  5264. if (map[sd->bl.m].flag.clouds) {
  5265. map[sd->bl.m].flag.clouds=0;
  5266. clif_weather(sd->bl.m);
  5267. clif_displaymessage(fd, "The clouds has disappear.");
  5268. } else {
  5269. map[sd->bl.m].flag.clouds=1;
  5270. clif_weather(sd->bl.m);
  5271. clif_displaymessage(fd, "Clouds appear.");
  5272. }
  5273. return 0;
  5274. }
  5275. /*==========================================
  5276. * Different type of clouds using effect 516
  5277. *------------------------------------------*/
  5278. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5279. {
  5280. nullpo_retr(-1, sd);
  5281. if (map[sd->bl.m].flag.clouds2) {
  5282. map[sd->bl.m].flag.clouds2=0;
  5283. clif_weather(sd->bl.m);
  5284. clif_displaymessage(fd, "The alternative clouds disappear.");
  5285. } else {
  5286. map[sd->bl.m].flag.clouds2=1;
  5287. clif_weather(sd->bl.m);
  5288. clif_displaymessage(fd, "Alternative clouds appear.");
  5289. }
  5290. return 0;
  5291. }
  5292. /*==========================================
  5293. * Fog hangs over.
  5294. *------------------------------------------*/
  5295. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5296. {
  5297. nullpo_retr(-1, sd);
  5298. if (map[sd->bl.m].flag.fog) {
  5299. map[sd->bl.m].flag.fog=0;
  5300. clif_weather(sd->bl.m);
  5301. clif_displaymessage(fd, "The fog has gone.");
  5302. } else {
  5303. map[sd->bl.m].flag.fog=1;
  5304. clif_weather(sd->bl.m);
  5305. clif_displaymessage(fd, "Fog hangs over.");
  5306. }
  5307. return 0;
  5308. }
  5309. /*==========================================
  5310. * Fallen leaves fall.
  5311. *------------------------------------------*/
  5312. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5313. {
  5314. nullpo_retr(-1, sd);
  5315. if (map[sd->bl.m].flag.leaves) {
  5316. map[sd->bl.m].flag.leaves=0;
  5317. clif_weather(sd->bl.m);
  5318. clif_displaymessage(fd, "Leaves no longer fall.");
  5319. } else {
  5320. map[sd->bl.m].flag.leaves=1;
  5321. clif_weather(sd->bl.m);
  5322. clif_displaymessage(fd, "Fallen leaves fall.");
  5323. }
  5324. return 0;
  5325. }
  5326. /*==========================================
  5327. * Fireworks appear.
  5328. *------------------------------------------*/
  5329. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5330. {
  5331. nullpo_retr(-1, sd);
  5332. if (map[sd->bl.m].flag.fireworks) {
  5333. map[sd->bl.m].flag.fireworks=0;
  5334. clif_weather(sd->bl.m);
  5335. clif_displaymessage(fd, "Fireworks are ended.");
  5336. } else {
  5337. map[sd->bl.m].flag.fireworks=1;
  5338. clif_weather(sd->bl.m);
  5339. clif_displaymessage(fd, "Fireworks are launched.");
  5340. }
  5341. return 0;
  5342. }
  5343. /*==========================================
  5344. * Clearing Weather Effects by Dexity
  5345. *------------------------------------------*/
  5346. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5347. {
  5348. nullpo_retr(-1, sd);
  5349. map[sd->bl.m].flag.rain=0;
  5350. map[sd->bl.m].flag.snow=0;
  5351. map[sd->bl.m].flag.sakura=0;
  5352. map[sd->bl.m].flag.clouds=0;
  5353. map[sd->bl.m].flag.clouds2=0;
  5354. map[sd->bl.m].flag.fog=0;
  5355. map[sd->bl.m].flag.fireworks=0;
  5356. map[sd->bl.m].flag.leaves=0;
  5357. clif_weather(sd->bl.m);
  5358. clif_displaymessage(fd, msg_txt(291));
  5359. return 0;
  5360. }
  5361. /*===============================================================
  5362. * Sound Command - plays a sound for everyone around! [Codemaster]
  5363. *---------------------------------------------------------------*/
  5364. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  5365. {
  5366. char sound_file[100];
  5367. memset(sound_file, '\0', sizeof(sound_file));
  5368. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5369. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5370. return -1;
  5371. }
  5372. if(strstr(sound_file, ".wav") == NULL)
  5373. strcat(sound_file, ".wav");
  5374. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5375. return 0;
  5376. }
  5377. /*==========================================
  5378. * MOB Search
  5379. *------------------------------------------*/
  5380. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5381. {
  5382. char mob_name[100];
  5383. int mob_id;
  5384. int number = 0;
  5385. struct s_mapiterator* it;
  5386. nullpo_retr(-1, sd);
  5387. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5388. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5389. return -1;
  5390. }
  5391. if ((mob_id = atoi(mob_name)) == 0)
  5392. mob_id = mobdb_searchname(mob_name);
  5393. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5394. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5395. clif_displaymessage(fd, atcmd_output);
  5396. return -1;
  5397. }
  5398. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5399. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5400. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5401. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5402. clif_displaymessage(fd, atcmd_output);
  5403. it = mapit_geteachmob();
  5404. while( true )
  5405. {
  5406. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5407. if( md == NULL )
  5408. break;// no more mobs
  5409. if( md->bl.m != sd->bl.m )
  5410. continue;
  5411. if( mob_id != -1 && md->class_ != mob_id )
  5412. continue;
  5413. ++number;
  5414. if( md->spawn_timer == INVALID_TIMER )
  5415. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5416. else
  5417. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5418. clif_displaymessage(fd, atcmd_output);
  5419. }
  5420. mapit_free(it);
  5421. return 0;
  5422. }
  5423. /*==========================================
  5424. * @cleanmap - cleans items on the ground
  5425. *------------------------------------------*/
  5426. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5427. {
  5428. nullpo_retr(0, bl);
  5429. map_clearflooritem(bl->id);
  5430. return 0;
  5431. }
  5432. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5433. {
  5434. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5435. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5436. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5437. BL_ITEM);
  5438. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5439. return 0;
  5440. }
  5441. /*==========================================
  5442. * make a NPC/PET talk
  5443. * @npctalkc [SnakeDrak]
  5444. *------------------------------------------*/
  5445. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5446. {
  5447. char name[NAME_LENGTH],mes[100],temp[100];
  5448. struct npc_data *nd;
  5449. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5450. unsigned long color=0;
  5451. if (sd->sc.count && //no "chatting" while muted.
  5452. (sd->sc.data[SC_BERSERK] ||
  5453. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5454. return -1;
  5455. if(!ifcolor) {
  5456. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5457. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5458. return -1;
  5459. }
  5460. }
  5461. else {
  5462. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5463. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  5464. return -1;
  5465. }
  5466. }
  5467. if (!(nd = npc_name2id(name))) {
  5468. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5469. return -1;
  5470. }
  5471. strtok(name, "#"); // discard extra name identifier if present
  5472. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5473. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5474. else clif_message(&nd->bl, temp);
  5475. return 0;
  5476. }
  5477. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5478. {
  5479. char mes[100],temp[100];
  5480. struct pet_data *pd;
  5481. nullpo_retr(-1, sd);
  5482. if(!sd->status.pet_id || !(pd=sd->pd))
  5483. {
  5484. clif_displaymessage(fd, msg_txt(184));
  5485. return -1;
  5486. }
  5487. if (sd->sc.count && //no "chatting" while muted.
  5488. (sd->sc.data[SC_BERSERK] ||
  5489. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5490. return -1;
  5491. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5492. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5493. return -1;
  5494. }
  5495. if (message[0] == '/')
  5496. {// pet emotion processing
  5497. const char* emo[] = {
  5498. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5499. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5500. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5501. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5502. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5503. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5504. };
  5505. int i;
  5506. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5507. if( i < ARRAYLENGTH(emo) )
  5508. {
  5509. clif_emotion(&pd->bl, i);
  5510. return 0;
  5511. }
  5512. }
  5513. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5514. clif_message(&pd->bl, temp);
  5515. return 0;
  5516. }
  5517. /// @users - displays the number of players present on each map (and percentage)
  5518. /// #users displays on the target user instead of self
  5519. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5520. {
  5521. char buf[256];
  5522. int i;
  5523. int users[MAX_MAPINDEX];
  5524. int users_all;
  5525. struct s_mapiterator* iter;
  5526. memset(users, 0, sizeof(users));
  5527. users_all = 0;
  5528. // count users on each map
  5529. iter = mapit_getallusers();
  5530. while( true )
  5531. {
  5532. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5533. if( sd2 == NULL )
  5534. break;// no more users
  5535. if( sd2->mapindex >= MAX_MAPINDEX )
  5536. continue;// invalid mapindex
  5537. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5538. if( users_all < INT_MAX ) ++users_all;
  5539. }
  5540. mapit_free(iter);
  5541. // display results for each map
  5542. for( i = 0; i < MAX_MAPINDEX; ++i )
  5543. {
  5544. if( users[i] == 0 )
  5545. continue;// empty
  5546. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5547. clif_displaymessage(sd->fd, buf);
  5548. }
  5549. // display overall count
  5550. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5551. clif_displaymessage(sd->fd, buf);
  5552. return 0;
  5553. }
  5554. /*==========================================
  5555. *
  5556. *------------------------------------------*/
  5557. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5558. {
  5559. pc_resetstate(sd);
  5560. pc_resetskill(sd,1);
  5561. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5562. clif_displaymessage(fd, atcmd_output);
  5563. return 0;
  5564. }
  5565. /*==========================================
  5566. *
  5567. *------------------------------------------*/
  5568. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5569. {
  5570. char name[NAME_LENGTH];
  5571. int mob_id = 0;
  5572. int duration = 0;
  5573. struct mob_data *md;
  5574. unsigned int tick=gettick();
  5575. nullpo_retr(-1, sd);
  5576. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5577. {
  5578. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5579. return -1;
  5580. }
  5581. if (duration < 1)
  5582. duration =1;
  5583. else if (duration > 60)
  5584. duration =60;
  5585. if ((mob_id = atoi(name)) == 0)
  5586. mob_id = mobdb_searchname(name);
  5587. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5588. {
  5589. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5590. return -1;
  5591. }
  5592. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5593. if(!md)
  5594. return -1;
  5595. md->master_id=sd->bl.id;
  5596. md->special_state.ai=1;
  5597. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5598. clif_misceffect2(&md->bl,344);
  5599. mob_spawn(md);
  5600. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5601. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5602. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5603. return 0;
  5604. }
  5605. /*==========================================
  5606. * @adjcmdlvl by [MouseJstr]
  5607. *
  5608. * Temp adjust the GM level required to use a GM command
  5609. * Useful during beta testing to allow players to use GM commands for short periods of time
  5610. *------------------------------------------*/
  5611. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5612. {
  5613. int newlev, newremotelev;
  5614. char name[100];
  5615. AtCommandInfo* cmd;
  5616. nullpo_retr(-1, sd);
  5617. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  5618. {
  5619. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  5620. return -1;
  5621. }
  5622. cmd = get_atcommandinfo_byname(name);
  5623. if (cmd == NULL)
  5624. {
  5625. clif_displaymessage(fd, "@command not found.");
  5626. return -1;
  5627. }
  5628. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  5629. {
  5630. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5631. return -1;
  5632. }
  5633. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  5634. {
  5635. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5636. return -1;
  5637. }
  5638. else
  5639. {
  5640. cmd->level = newlev;
  5641. cmd->level2 = newremotelev;
  5642. clif_displaymessage(fd, "@command level changed.");
  5643. return 0;
  5644. }
  5645. }
  5646. /*==========================================
  5647. * @adjgmlvl by [MouseJstr]
  5648. * Create a temp GM
  5649. * Useful during beta testing to allow players to use GM commands for short periods of time
  5650. *------------------------------------------*/
  5651. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5652. {
  5653. int newlev;
  5654. char user[NAME_LENGTH];
  5655. struct map_session_data *pl_sd;
  5656. nullpo_retr(-1, sd);
  5657. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5658. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5659. return -1;
  5660. }
  5661. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5662. {
  5663. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5664. return -1;
  5665. }
  5666. pl_sd->gmlevel = newlev;
  5667. return 0;
  5668. }
  5669. /*==========================================
  5670. * @trade by [MouseJstr]
  5671. * Open a trade window with a remote player
  5672. *------------------------------------------*/
  5673. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5674. {
  5675. struct map_session_data *pl_sd = NULL;
  5676. nullpo_retr(-1, sd);
  5677. if (!message || !*message) {
  5678. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5679. return -1;
  5680. }
  5681. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5682. {
  5683. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5684. return -1;
  5685. }
  5686. trade_traderequest(sd, pl_sd);
  5687. return 0;
  5688. }
  5689. /*==========================================
  5690. * @setbattleflag by [MouseJstr]
  5691. * set a battle_config flag without having to reboot
  5692. *------------------------------------------*/
  5693. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5694. {
  5695. char flag[128], value[128];
  5696. nullpo_retr(-1, sd);
  5697. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5698. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5699. return -1;
  5700. }
  5701. if (battle_set_value(flag, value) == 0)
  5702. {
  5703. clif_displaymessage(fd, "unknown battle_config flag");
  5704. return -1;
  5705. }
  5706. clif_displaymessage(fd, "battle_config set as requested");
  5707. return 0;
  5708. }
  5709. /*==========================================
  5710. * @unmute [Valaris]
  5711. *------------------------------------------*/
  5712. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5713. {
  5714. struct map_session_data *pl_sd = NULL;
  5715. nullpo_retr(-1, sd);
  5716. if (!message || !*message) {
  5717. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5718. return -1;
  5719. }
  5720. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5721. {
  5722. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5723. return -1;
  5724. }
  5725. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5726. clif_displaymessage(sd->fd,"Player is not muted");
  5727. return -1;
  5728. }
  5729. pl_sd->status.manner = 0;
  5730. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5731. clif_displaymessage(sd->fd,"Player unmuted");
  5732. return 0;
  5733. }
  5734. /*==========================================
  5735. * @uptime by MC Cameri
  5736. *------------------------------------------*/
  5737. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5738. {
  5739. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5740. minute = 60, days = 0, hours = 0, minutes = 0;
  5741. nullpo_retr(-1, sd);
  5742. seconds = get_uptime();
  5743. days = seconds/day;
  5744. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5745. hours = seconds/hour;
  5746. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5747. minutes = seconds/minute;
  5748. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5749. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5750. clif_displaymessage(fd, atcmd_output);
  5751. return 0;
  5752. }
  5753. /*==========================================
  5754. * @changesex <sex>
  5755. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5756. *------------------------------------------*/
  5757. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5758. {
  5759. nullpo_retr(-1, sd);
  5760. chrif_changesex(sd);
  5761. return 0;
  5762. }
  5763. /*================================================
  5764. * @mute - Mutes a player for a set amount of time
  5765. *------------------------------------------------*/
  5766. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5767. {
  5768. struct map_session_data *pl_sd = NULL;
  5769. int manner;
  5770. nullpo_retr(-1, sd);
  5771. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5772. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5773. return -1;
  5774. }
  5775. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5776. {
  5777. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5778. return -1;
  5779. }
  5780. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5781. {
  5782. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5783. return -1;
  5784. }
  5785. clif_manner_message(sd, 0);
  5786. clif_manner_message(pl_sd, 5);
  5787. if( pl_sd->status.manner < manner ) {
  5788. pl_sd->status.manner -= manner;
  5789. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5790. } else {
  5791. pl_sd->status.manner = 0;
  5792. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5793. }
  5794. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5795. return 0;
  5796. }
  5797. /*==========================================
  5798. * @refresh (like @jumpto <<yourself>>)
  5799. *------------------------------------------*/
  5800. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5801. {
  5802. nullpo_retr(-1, sd);
  5803. clif_refresh(sd);
  5804. return 0;
  5805. }
  5806. /*==========================================
  5807. * @identify
  5808. * => GM's magnifier.
  5809. *------------------------------------------*/
  5810. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5811. {
  5812. int i,num;
  5813. nullpo_retr(-1, sd);
  5814. for(i=num=0;i<MAX_INVENTORY;i++){
  5815. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5816. num++;
  5817. }
  5818. }
  5819. if (num > 0) {
  5820. clif_item_identify_list(sd);
  5821. } else {
  5822. clif_displaymessage(fd,"There are no items to appraise.");
  5823. }
  5824. return 0;
  5825. }
  5826. /*==========================================
  5827. * @gmotd (Global MOTD)
  5828. * by davidsiaw :P
  5829. *------------------------------------------*/
  5830. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5831. {
  5832. char buf[256];
  5833. FILE *fp;
  5834. nullpo_retr(-1, sd);
  5835. if((fp = fopen(motd_txt, "r"))!=NULL){
  5836. while(fgets(buf, sizeof(buf), fp) != NULL)
  5837. {
  5838. int i;
  5839. if (buf[0] == '/' && buf[1] == '/')
  5840. continue;
  5841. for(i=0; buf[i]; i++){
  5842. if(buf[i]=='\r' || buf[i]=='\n'){
  5843. buf[i]=0;
  5844. break;
  5845. }
  5846. }
  5847. intif_broadcast(buf, strlen(buf)+1, 0);
  5848. }
  5849. fclose(fp);
  5850. }
  5851. return 0;
  5852. }
  5853. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5854. {
  5855. int effect = 0;
  5856. nullpo_retr(-1, sd);
  5857. if (!message || !*message)
  5858. return -1;
  5859. if (sscanf(message, "%d", &effect) < 1)
  5860. return -1;
  5861. clif_misceffect(&sd->bl,effect);
  5862. return 0;
  5863. }
  5864. /*==========================================
  5865. * MAIL SYSTEM
  5866. *------------------------------------------*/
  5867. int atcommand_mail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5868. {
  5869. nullpo_retr(0,sd);
  5870. #ifndef TXT_ONLY
  5871. mail_openmail(sd);
  5872. #endif
  5873. return 0;
  5874. }
  5875. /*==========================================
  5876. * Show Monster DB Info v 1.0
  5877. * originally by [Lupus] eAthena
  5878. *------------------------------------------*/
  5879. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5880. {
  5881. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5882. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5883. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5884. char atcmd_output2[200];
  5885. struct item_data *item_data;
  5886. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5887. int count;
  5888. int i, j, k;
  5889. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5890. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5891. if (!message || !*message) {
  5892. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5893. return -1;
  5894. }
  5895. // If monster identifier/name argument is a name
  5896. if ((i = mobdb_checkid(atoi(message))))
  5897. {
  5898. mob_array[0] = mob_db(i);
  5899. count = 1;
  5900. } else
  5901. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5902. if (!count) {
  5903. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5904. return -1;
  5905. }
  5906. if (count > MAX_SEARCH) {
  5907. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5908. clif_displaymessage(fd, atcmd_output);
  5909. count = MAX_SEARCH;
  5910. }
  5911. for (k = 0; k < count; k++) {
  5912. mob = mob_array[k];
  5913. // stats
  5914. if (mob->mexp)
  5915. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5916. else
  5917. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5918. clif_displaymessage(fd, atcmd_output);
  5919. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  5920. clif_displaymessage(fd, atcmd_output);
  5921. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5922. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5923. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5924. clif_displaymessage(fd, atcmd_output);
  5925. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5926. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5927. mob->range2 , mob->range3, msize[mob->status.size],
  5928. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5929. clif_displaymessage(fd, atcmd_output);
  5930. // drops
  5931. clif_displaymessage(fd, " Drops:");
  5932. strcpy(atcmd_output, " ");
  5933. j = 0;
  5934. for (i = 0; i < MAX_MOB_DROP; i++) {
  5935. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  5936. continue;
  5937. if (item_data->slot)
  5938. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5939. else
  5940. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5941. strcat(atcmd_output, atcmd_output2);
  5942. if (++j % 3 == 0) {
  5943. clif_displaymessage(fd, atcmd_output);
  5944. strcpy(atcmd_output, " ");
  5945. }
  5946. }
  5947. if (j == 0)
  5948. clif_displaymessage(fd, "This monster has no drops.");
  5949. else if (j % 3 != 0)
  5950. clif_displaymessage(fd, atcmd_output);
  5951. // mvp
  5952. if (mob->mexp) {
  5953. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  5954. clif_displaymessage(fd, atcmd_output);
  5955. strcpy(atcmd_output, " MVP Items:");
  5956. j = 0;
  5957. for (i = 0; i < 3; i++) {
  5958. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  5959. continue;
  5960. if (mob->mvpitem[i].p > 0) {
  5961. j++;
  5962. if (j == 1)
  5963. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5964. else
  5965. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5966. strcat(atcmd_output, atcmd_output2);
  5967. }
  5968. }
  5969. if (j == 0)
  5970. clif_displaymessage(fd, "This monster has no MVP prizes.");
  5971. else
  5972. clif_displaymessage(fd, atcmd_output);
  5973. }
  5974. }
  5975. return 0;
  5976. }
  5977. /*=========================================
  5978. * @showmobs by KarLaeda
  5979. * => For 5 sec displays the mobs on minimap
  5980. *------------------------------------------*/
  5981. int atshowmobs_timer(int tid, unsigned int tick, int id, intptr data)
  5982. {
  5983. struct map_session_data* sd = map_id2sd(id);
  5984. if( sd == NULL )
  5985. return 0;
  5986. // remove indicator
  5987. clif_viewpoint(sd, 1, 2, 0, 0, (int)data, 0xFFFFFF);
  5988. return 1;
  5989. }
  5990. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5991. {
  5992. char mob_name[100];
  5993. int mob_id;
  5994. int number = 0;
  5995. struct s_mapiterator* it;
  5996. nullpo_retr(-1, sd);
  5997. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5998. return -1;
  5999. if((mob_id = atoi(mob_name)) == 0)
  6000. mob_id = mobdb_searchname(mob_name);
  6001. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6002. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6003. clif_displaymessage(fd, atcmd_output);
  6004. return 0;
  6005. }
  6006. // Uncomment the following line to show mini-bosses & MVP.
  6007. //#define SHOW_MVP
  6008. #ifndef SHOW_MVP
  6009. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6010. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6011. clif_displaymessage(fd, atcmd_output);
  6012. return 0;
  6013. }
  6014. #endif
  6015. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6016. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6017. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6018. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6019. mob_name, mapindex_id2name(sd->mapindex));
  6020. clif_displaymessage(fd, atcmd_output);
  6021. it = mapit_geteachmob();
  6022. while( true )
  6023. {
  6024. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6025. if( md == NULL )
  6026. break;// no more mobs
  6027. if( md->bl.m != sd->bl.m )
  6028. continue;
  6029. if( mob_id != -1 && md->class_ != mob_id )
  6030. continue;
  6031. if( md->special_state.ai || md->master_id )
  6032. continue; // hide slaves and player summoned mobs
  6033. if( md->spawn_timer != INVALID_TIMER )
  6034. continue; // hide mobs waiting for respawn
  6035. ++number;
  6036. clif_viewpoint(sd, 1, 1, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6037. add_timer(gettick()+5000, atshowmobs_timer, sd->bl.id, number);
  6038. }
  6039. mapit_free(it);
  6040. return 0;
  6041. }
  6042. /*==========================================
  6043. * homunculus level up [orn]
  6044. *------------------------------------------*/
  6045. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6046. {
  6047. TBL_HOM * hd;
  6048. int level = 0, i = 0;
  6049. nullpo_retr(-1, sd);
  6050. if (!message || !*message) {
  6051. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <+/- # of levels>.");
  6052. return -1;
  6053. }
  6054. if ( !merc_is_hom_active(sd->hd) ) {
  6055. clif_displaymessage(fd, "You do not have a homunculus.");
  6056. return -1;
  6057. }
  6058. level = atoi(message);
  6059. hd = sd->hd;
  6060. for (i = 1; i <= level && hd->exp_next; i++){
  6061. hd->homunculus.exp += hd->exp_next;
  6062. merc_hom_levelup(hd);
  6063. }
  6064. status_calc_homunculus(hd,0);
  6065. status_percent_heal(&hd->bl, 100, 100);
  6066. clif_misceffect2(&hd->bl,568);
  6067. return 0;
  6068. }
  6069. /*==========================================
  6070. * homunculus evolution H [orn]
  6071. *------------------------------------------*/
  6072. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6073. {
  6074. nullpo_retr(-1, sd);
  6075. if ( !merc_is_hom_active(sd->hd) ) {
  6076. clif_displaymessage(fd, "You do not have a homunculus.");
  6077. return -1;
  6078. }
  6079. if ( !merc_hom_evolution(sd->hd) ) {
  6080. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6081. return -1;
  6082. }
  6083. return 0;
  6084. }
  6085. /*==========================================
  6086. * call choosen homunculus [orn]
  6087. *------------------------------------------*/
  6088. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6089. {
  6090. int homunid;
  6091. nullpo_retr(-1, sd);
  6092. if ( merc_is_hom_active(sd->hd) ) {
  6093. clif_displaymessage(fd, msg_txt(450));
  6094. return -1;
  6095. }
  6096. if (!message || !*message) {
  6097. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6098. return -1;
  6099. }
  6100. homunid = atoi(message);
  6101. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6102. {
  6103. clif_displaymessage(fd, "Invalid Homunculus id.");
  6104. return -1;
  6105. }
  6106. merc_create_homunculus_request(sd,homunid);
  6107. return 0;
  6108. }
  6109. /*==========================================
  6110. * modify homunculus intimacy [orn]
  6111. *------------------------------------------*/
  6112. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6113. {
  6114. int friendly = 0;
  6115. nullpo_retr(-1, sd);
  6116. if ( !merc_is_hom_active(sd->hd) ) {
  6117. clif_displaymessage(fd, "You do not have a homunculus.");
  6118. return -1;
  6119. }
  6120. if (!message || !*message) {
  6121. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6122. return -1;
  6123. }
  6124. friendly = atoi(message);
  6125. friendly = cap_value(friendly, 0, 1000);
  6126. sd->hd->homunculus.intimacy = friendly * 100 ;
  6127. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6128. return 0;
  6129. }
  6130. /*==========================================
  6131. * modify homunculus hunger [orn]
  6132. *------------------------------------------*/
  6133. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6134. {
  6135. int hungry = 0;
  6136. nullpo_retr(-1, sd);
  6137. if ( !merc_is_hom_active(sd->hd) ) {
  6138. clif_displaymessage(fd, "You do not have a homunculus.");
  6139. return -1;
  6140. }
  6141. if (!message || !*message) {
  6142. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6143. return -1;
  6144. }
  6145. hungry = atoi(message);
  6146. hungry = cap_value(hungry, 0, 100);
  6147. sd->hd->homunculus.hunger = hungry;
  6148. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6149. return 0;
  6150. }
  6151. /*==========================================
  6152. * make the homunculus speak [orn]
  6153. *------------------------------------------*/
  6154. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6155. {
  6156. char mes[100],temp[100];
  6157. nullpo_retr(-1, sd);
  6158. if (sd->sc.count && //no "chatting" while muted.
  6159. (sd->sc.data[SC_BERSERK] ||
  6160. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6161. return -1;
  6162. if ( !merc_is_hom_active(sd->hd) ) {
  6163. clif_displaymessage(fd, "You do not have a homunculus.");
  6164. return -1;
  6165. }
  6166. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6167. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6168. return -1;
  6169. }
  6170. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6171. clif_message(&sd->hd->bl, temp);
  6172. return 0;
  6173. }
  6174. /*==========================================
  6175. * Show homunculus stats
  6176. *------------------------------------------*/
  6177. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6178. {
  6179. struct homun_data *hd;
  6180. struct status_data *status;
  6181. nullpo_retr(-1, sd);
  6182. if ( !merc_is_hom_active(sd->hd) ) {
  6183. clif_displaymessage(fd, "You do not have a homunculus.");
  6184. return -1;
  6185. }
  6186. hd = sd->hd;
  6187. status = status_get_status_data(&hd->bl);
  6188. clif_displaymessage(fd, "Homunculus stats :");
  6189. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6190. status->hp, status->max_hp, status->sp, status->max_sp);
  6191. clif_displaymessage(fd, atcmd_output);
  6192. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6193. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6194. clif_displaymessage(fd, atcmd_output);
  6195. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6196. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6197. clif_displaymessage(fd, atcmd_output);
  6198. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6199. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6200. status->str, status->agi, status->vit,
  6201. status->int_, status->dex, status->luk);
  6202. clif_displaymessage(fd, atcmd_output);
  6203. return 0;
  6204. }
  6205. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6206. {
  6207. struct homun_data *hd;
  6208. struct s_homunculus_db *db;
  6209. struct s_homunculus *hom;
  6210. int lv, min, max, evo;
  6211. nullpo_retr(-1, sd);
  6212. if ( !merc_is_hom_active(sd->hd) ) {
  6213. clif_displaymessage(fd, "You do not have a homunculus.");
  6214. return -1;
  6215. }
  6216. hd = sd->hd;
  6217. hom = &hd->homunculus;
  6218. db = hd->homunculusDB;
  6219. lv = hom->level;
  6220. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6221. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6222. clif_displaymessage(fd, atcmd_output);
  6223. lv--; //Since the first increase is at level 2.
  6224. evo = (hom->class_ == db->evo_class);
  6225. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6226. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6227. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6228. clif_displaymessage(fd, atcmd_output);
  6229. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6230. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6231. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6232. clif_displaymessage(fd, atcmd_output);
  6233. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6234. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6235. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6236. clif_displaymessage(fd, atcmd_output);
  6237. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6238. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6239. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6240. clif_displaymessage(fd, atcmd_output);
  6241. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6242. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6243. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6244. clif_displaymessage(fd, atcmd_output);
  6245. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6246. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6247. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6248. clif_displaymessage(fd, atcmd_output);
  6249. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6250. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6251. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6252. clif_displaymessage(fd, atcmd_output);
  6253. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6254. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6255. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6256. clif_displaymessage(fd, atcmd_output);
  6257. return 0;
  6258. }
  6259. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6260. {
  6261. nullpo_retr(-1, sd);
  6262. if(!sd->hd)
  6263. return -1; // nothing to do
  6264. if(!merc_hom_shuffle(sd->hd))
  6265. return -1;
  6266. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6267. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6268. return 0;
  6269. }
  6270. /*==========================================
  6271. * Show Items DB Info v 1.0
  6272. * originally by [Lupus] eAthena
  6273. *------------------------------------------*/
  6274. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6275. {
  6276. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  6277. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  6278. struct item_data *item_data, *item_array[MAX_SEARCH];
  6279. int i, count = 1;
  6280. if (!message || !*message) {
  6281. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6282. return -1;
  6283. }
  6284. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6285. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6286. if (!count) {
  6287. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6288. return -1;
  6289. }
  6290. if (count > MAX_SEARCH) {
  6291. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6292. clif_displaymessage(fd, atcmd_output);
  6293. count = MAX_SEARCH;
  6294. }
  6295. for (i = 0; i < count; i++) {
  6296. item_data = item_array[i];
  6297. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6298. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6299. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  6300. (item_data->script==NULL)? "None" : "With script"
  6301. );
  6302. clif_displaymessage(fd, atcmd_output);
  6303. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
  6304. clif_displaymessage(fd, atcmd_output);
  6305. if (item_data->maxchance == 10000)
  6306. strcpy(atcmd_output, " - Available in the shops only");
  6307. else if (item_data->maxchance)
  6308. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6309. else
  6310. strcpy(atcmd_output, " - Monsters don't drop this item");
  6311. clif_displaymessage(fd, atcmd_output);
  6312. }
  6313. return 0;
  6314. }
  6315. /*==========================================
  6316. * Show who drops the item.
  6317. *------------------------------------------*/
  6318. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6319. {
  6320. struct item_data *item_data, *item_array[MAX_SEARCH];
  6321. int i,j, count = 1;
  6322. if (!message || !*message) {
  6323. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6324. return -1;
  6325. }
  6326. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6327. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6328. if (!count) {
  6329. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6330. return -1;
  6331. }
  6332. if (count > MAX_SEARCH) {
  6333. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6334. clif_displaymessage(fd, atcmd_output);
  6335. count = MAX_SEARCH;
  6336. }
  6337. for (i = 0; i < count; i++) {
  6338. item_data = item_array[i];
  6339. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6340. clif_displaymessage(fd, atcmd_output);
  6341. if (item_data->mob[0].chance == 0) {
  6342. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6343. clif_displaymessage(fd, atcmd_output);
  6344. } else {
  6345. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6346. clif_displaymessage(fd, atcmd_output);
  6347. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6348. {
  6349. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6350. clif_displaymessage(fd, atcmd_output);
  6351. }
  6352. }
  6353. }
  6354. return 0;
  6355. }
  6356. int atcommand_whereis(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6357. {
  6358. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6359. int count;
  6360. int i, j, k;
  6361. if (!message || !*message) {
  6362. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6363. return -1;
  6364. }
  6365. // If monster identifier/name argument is a name
  6366. if ((i = mobdb_checkid(atoi(message))))
  6367. {
  6368. mob_array[0] = mob_db(i);
  6369. count = 1;
  6370. } else
  6371. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6372. if (!count) {
  6373. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6374. return -1;
  6375. }
  6376. if (count > MAX_SEARCH) {
  6377. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6378. clif_displaymessage(fd, atcmd_output);
  6379. count = MAX_SEARCH;
  6380. }
  6381. for (k = 0; k < count; k++) {
  6382. mob = mob_array[k];
  6383. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6384. clif_displaymessage(fd, atcmd_output);
  6385. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6386. {
  6387. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6388. if (j < 0) continue;
  6389. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6390. clif_displaymessage(fd, atcmd_output);
  6391. }
  6392. if (i == 0)
  6393. clif_displaymessage(fd, "This monster does not spawn normally.");
  6394. }
  6395. return 0;
  6396. }
  6397. /*==========================================
  6398. * @adopt by [Veider]
  6399. * adopt a novice
  6400. *------------------------------------------*/
  6401. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6402. {
  6403. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6404. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6405. char output[256];
  6406. nullpo_retr(-1, sd);
  6407. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6408. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6409. return -1;
  6410. }
  6411. if (battle_config.etc_log)
  6412. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6413. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6414. sprintf(output, "Cannot find player %s online", player1);
  6415. clif_displaymessage(fd, output);
  6416. return -1;
  6417. }
  6418. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6419. sprintf(output, "Cannot find player %s online", player2);
  6420. clif_displaymessage(fd, output);
  6421. return -1;
  6422. }
  6423. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6424. sprintf(output, "Cannot find player %s online", player3);
  6425. clif_displaymessage(fd, output);
  6426. return -1;
  6427. }
  6428. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6429. return -1;
  6430. }
  6431. clif_displaymessage(fd, "They are family... wish them luck");
  6432. return 0;
  6433. }
  6434. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6435. {
  6436. const char * revision;
  6437. if ((revision = get_svn_revision()) != 0) {
  6438. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6439. clif_displaymessage(fd,atcmd_output);
  6440. } else
  6441. clif_displaymessage(fd,"Cannot determine SVN revision");
  6442. return 0;
  6443. }
  6444. /*==========================================
  6445. * @mutearea by MouseJstr
  6446. *------------------------------------------*/
  6447. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6448. {
  6449. int time, id;
  6450. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6451. if (pl_sd == NULL)
  6452. return 0;
  6453. id = va_arg(ap, int);
  6454. time = va_arg(ap, int);
  6455. if (id != bl->id && !pc_isGM(pl_sd)) {
  6456. pl_sd->status.manner -= time;
  6457. if (pl_sd->status.manner < 0)
  6458. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6459. else if (pl_sd->sc.data[SC_NOCHAT])
  6460. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  6461. }
  6462. return 0;
  6463. }
  6464. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6465. {
  6466. int time;
  6467. nullpo_retr(0, sd);
  6468. if (!message || !*message) {
  6469. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6470. return -1;
  6471. }
  6472. time = atoi(message);
  6473. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6474. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6475. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6476. return 0;
  6477. }
  6478. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6479. {
  6480. char buf[255];
  6481. nullpo_retr(0, sd);
  6482. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  6483. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6484. clif_displaymessage(fd, buf);
  6485. return 0;
  6486. }
  6487. /*==========================================
  6488. * @me by lordalfa
  6489. * => Displays the OUTPUT string on top of the Visible players Heads.
  6490. *------------------------------------------*/
  6491. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6492. {
  6493. char tempmes[200];
  6494. nullpo_retr(-1, sd);
  6495. memset(tempmes, '\0', sizeof(tempmes));
  6496. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6497. if (sd->sc.count && //no "chatting" while muted.
  6498. (sd->sc.data[SC_BERSERK] ||
  6499. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6500. return -1;
  6501. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6502. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6503. return -1;
  6504. }
  6505. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6506. clif_disp_overhead(sd, atcmd_output);
  6507. return 0;
  6508. }
  6509. /*==========================================
  6510. * @size
  6511. * => Resize your character sprite. [Valaris]
  6512. *------------------------------------------*/
  6513. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6514. {
  6515. int size=0;
  6516. nullpo_retr(-1, sd);
  6517. size = atoi(message);
  6518. if(sd->state.size) {
  6519. sd->state.size=0;
  6520. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  6521. }
  6522. if(size==1) {
  6523. sd->state.size=1;
  6524. clif_specialeffect(&sd->bl,420,AREA);
  6525. } else if(size==2) {
  6526. sd->state.size=2;
  6527. clif_specialeffect(&sd->bl,422,AREA);
  6528. }
  6529. return 0;
  6530. }
  6531. /*==========================================
  6532. * @monsterignore
  6533. * => Makes monsters ignore you. [Valaris]
  6534. *------------------------------------------*/
  6535. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6536. {
  6537. nullpo_retr(-1, sd);
  6538. if (!sd->state.monster_ignore) {
  6539. sd->state.monster_ignore = 1;
  6540. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6541. } else {
  6542. sd->state.monster_ignore = 0;
  6543. clif_displaymessage(sd->fd, "Returned to normal state.");
  6544. }
  6545. return 0;
  6546. }
  6547. /*==========================================
  6548. * @fakename
  6549. * => Gives your character a fake name. [Valaris]
  6550. *------------------------------------------*/
  6551. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6552. {
  6553. char name[NAME_LENGTH];
  6554. nullpo_retr(-1, sd);
  6555. if((!message || !*message) && strlen(sd->fakename) > 1) {
  6556. sd->fakename[0]='\0';
  6557. clif_charnameack(0, &sd->bl);
  6558. clif_displaymessage(sd->fd,"Returned to real name.");
  6559. return 0;
  6560. }
  6561. if (!message || !*message || sscanf(message, "%23[^\n]", name) < 1) {
  6562. clif_displaymessage(sd->fd,"You must enter a name.");
  6563. return -1;
  6564. }
  6565. if(strlen(name) < 2) {
  6566. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  6567. return -1;
  6568. }
  6569. memcpy(sd->fakename,name,NAME_LENGTH);
  6570. sd->fakename[NAME_LENGTH-1] = '\0';
  6571. clif_charnameack(0, &sd->bl);
  6572. clif_displaymessage(sd->fd,"Fake name enabled.");
  6573. return 0;
  6574. }
  6575. /*==========================================
  6576. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  6577. * => Shows information about the map flags [map name]
  6578. * Also set flags
  6579. *------------------------------------------*/
  6580. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6581. {
  6582. // WIP
  6583. return 0;
  6584. }
  6585. /*===================================
  6586. * Remove some messages
  6587. *-----------------------------------*/
  6588. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6589. {
  6590. if (sd->state.showexp) {
  6591. sd->state.showexp = 0;
  6592. clif_displaymessage(fd, "Gained exp will not be shown.");
  6593. return 0;
  6594. }
  6595. sd->state.showexp = 1;
  6596. clif_displaymessage(fd, "Gained exp is now shown");
  6597. return 0;
  6598. }
  6599. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6600. {
  6601. if (sd->state.showzeny) {
  6602. sd->state.showzeny = 0;
  6603. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6604. return 0;
  6605. }
  6606. sd->state.showzeny = 1;
  6607. clif_displaymessage(fd, "Gained zeny is now shown");
  6608. return 0;
  6609. }
  6610. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6611. {
  6612. if (sd->state.showdelay) {
  6613. sd->state.showdelay = 0;
  6614. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6615. return 0;
  6616. }
  6617. sd->state.showdelay = 1;
  6618. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6619. return 0;
  6620. }
  6621. /*==========================================
  6622. * Duel organizing functions [LuzZza]
  6623. *
  6624. * @duel [limit|nick] - create a duel
  6625. * @invite <nick> - invite player
  6626. * @accept - accept invitation
  6627. * @reject - reject invitation
  6628. * @leave - leave duel
  6629. *------------------------------------------*/
  6630. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6631. {
  6632. unsigned int did = sd->duel_group;
  6633. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6634. if(did <= 0) {
  6635. // "Duel: @invite without @duel."
  6636. clif_displaymessage(fd, msg_txt(350));
  6637. return 0;
  6638. }
  6639. if(duel_list[did].max_players_limit > 0 &&
  6640. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6641. // "Duel: Limit of players is reached."
  6642. clif_displaymessage(fd, msg_txt(351));
  6643. return 0;
  6644. }
  6645. if(target_sd == NULL) {
  6646. // "Duel: Player not found."
  6647. clif_displaymessage(fd, msg_txt(352));
  6648. return 0;
  6649. }
  6650. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6651. // "Duel: Player already in duel."
  6652. clif_displaymessage(fd, msg_txt(353));
  6653. return 0;
  6654. }
  6655. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6656. {
  6657. sprintf(atcmd_output, msg_txt(364), message);
  6658. clif_displaymessage(fd, atcmd_output);
  6659. return 0;
  6660. }
  6661. duel_invite(did, sd, target_sd);
  6662. // "Duel: Invitation has been sent."
  6663. clif_displaymessage(fd, msg_txt(354));
  6664. return 0;
  6665. }
  6666. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6667. {
  6668. char output[256];
  6669. unsigned int maxpl=0, newduel;
  6670. struct map_session_data *target_sd;
  6671. if(sd->duel_group > 0) {
  6672. duel_showinfo(sd->duel_group, sd);
  6673. return 0;
  6674. }
  6675. if(sd->duel_invite > 0) {
  6676. // "Duel: @duel without @reject."
  6677. clif_displaymessage(fd, msg_txt(355));
  6678. return 0;
  6679. }
  6680. if(!duel_checktime(sd)) {
  6681. // "Duel: You can take part in duel only one time per %d minutes."
  6682. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6683. clif_displaymessage(fd, output);
  6684. return 0;
  6685. }
  6686. if(strlen(message) > 0) {
  6687. if(sscanf(message, "%d", &maxpl) >= 1) {
  6688. if(maxpl < 2 || maxpl > 65535) {
  6689. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6690. return 0;
  6691. }
  6692. duel_create(sd, maxpl);
  6693. } else {
  6694. target_sd = map_nick2sd((char *)message);
  6695. if(target_sd != NULL) {
  6696. if((newduel = duel_create(sd, 2)) != -1) {
  6697. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6698. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6699. return 0;
  6700. }
  6701. duel_invite(newduel, sd, target_sd);
  6702. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6703. }
  6704. } else {
  6705. // "Duel: Player not found."
  6706. clif_displaymessage(fd, msg_txt(352));
  6707. return 0;
  6708. }
  6709. }
  6710. } else
  6711. duel_create(sd, 0);
  6712. return 0;
  6713. }
  6714. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6715. {
  6716. if(sd->duel_group <= 0) {
  6717. // "Duel: @leave without @duel."
  6718. clif_displaymessage(fd, msg_txt(358));
  6719. return 0;
  6720. }
  6721. duel_leave(sd->duel_group, sd);
  6722. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6723. return 0;
  6724. }
  6725. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6726. {
  6727. char output[256];
  6728. if(!duel_checktime(sd)) {
  6729. // "Duel: You can take part in duel only one time per %d minutes."
  6730. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6731. clif_displaymessage(fd, output);
  6732. return 0;
  6733. }
  6734. if(sd->duel_invite <= 0) {
  6735. // "Duel: @accept without invititation."
  6736. clif_displaymessage(fd, msg_txt(360));
  6737. return 0;
  6738. }
  6739. duel_accept(sd->duel_invite, sd);
  6740. // "Duel: Invitation has been accepted."
  6741. clif_displaymessage(fd, msg_txt(361));
  6742. return 0;
  6743. }
  6744. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6745. {
  6746. if(sd->duel_invite <= 0) {
  6747. // "Duel: @reject without invititation."
  6748. clif_displaymessage(fd, msg_txt(362));
  6749. return 0;
  6750. }
  6751. duel_reject(sd->duel_invite, sd);
  6752. // "Duel: Invitation has been rejected."
  6753. clif_displaymessage(fd, msg_txt(363));
  6754. return 0;
  6755. }
  6756. /*===================================
  6757. * Cash Points
  6758. *-----------------------------------*/
  6759. int atcommand_cash(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6760. {
  6761. int value;
  6762. nullpo_retr(-1, sd);
  6763. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6764. clif_displaymessage(fd, "Please, enter an amount.");
  6765. return -1;
  6766. }
  6767. if( !strcmpi(command+1,"cash") )
  6768. {
  6769. if( value > 0 )
  6770. pc_getcash(sd, value, 0);
  6771. else
  6772. pc_paycash(sd, -value, 0);
  6773. }
  6774. else
  6775. { // @points
  6776. if( value > 0 )
  6777. pc_getcash(sd, 0, value);
  6778. else
  6779. pc_paycash(sd, -value, -value);
  6780. }
  6781. return 0;
  6782. }
  6783. /*===================================
  6784. * Away message (@away, @aw) [LuzZza]
  6785. *-----------------------------------*/
  6786. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6787. {
  6788. if(strlen(message) > 0) {
  6789. if(strlen(message) > 128)
  6790. return -1;
  6791. strcpy(sd->away_message, message);
  6792. //"Away automessage has been activated."
  6793. clif_displaymessage(fd, msg_txt(546));
  6794. } else {
  6795. if(strlen(sd->away_message) > 0) {
  6796. sd->away_message[0] = 0;
  6797. //"Away automessage has been disabled."
  6798. clif_displaymessage(fd, msg_txt(547));
  6799. return 0;
  6800. }
  6801. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  6802. clif_displaymessage(fd, msg_txt(548));
  6803. }
  6804. return 0;
  6805. }
  6806. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6807. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6808. {
  6809. int x=0,y=0,flag=0,master=0,i=0;
  6810. struct map_session_data *pl_sd=NULL;
  6811. if (!message || !*message) {
  6812. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6813. return 0;
  6814. }
  6815. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6816. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6817. return 0;
  6818. }
  6819. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  6820. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6821. return 0;
  6822. }
  6823. if (strcmpi(command+1, "clone") == 0)
  6824. flag = 1;
  6825. else if (strcmpi(command+1, "slaveclone") == 0) {
  6826. flag = 2;
  6827. master = sd->bl.id;
  6828. if (battle_config.atc_slave_clone_limit
  6829. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6830. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6831. return 0;
  6832. }
  6833. }
  6834. do {
  6835. x = sd->bl.x + (rand() % 10 - 5);
  6836. y = sd->bl.y + (rand() % 10 - 5);
  6837. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6838. if (i >= 10) {
  6839. x = sd->bl.x;
  6840. y = sd->bl.y;
  6841. }
  6842. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6843. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6844. return 0;
  6845. }
  6846. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6847. return 0;
  6848. }
  6849. /*===================================
  6850. * Main chat [LuzZza]
  6851. * Usage: @main <on|off|message>
  6852. *-----------------------------------*/
  6853. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6854. {
  6855. if(strlen(message) > 0) {
  6856. if(strcmpi(message, "on") == 0) {
  6857. if(!sd->state.mainchat) {
  6858. sd->state.mainchat = 1;
  6859. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6860. } else {
  6861. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6862. }
  6863. } else if(strcmpi(message, "off") == 0) {
  6864. if(sd->state.mainchat) {
  6865. sd->state.mainchat = 0;
  6866. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6867. } else {
  6868. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6869. }
  6870. } else {
  6871. if(!sd->state.mainchat) {
  6872. sd->state.mainchat = 1;
  6873. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6874. }
  6875. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6876. clif_displaymessage(fd, msg_txt(387));
  6877. return -1;
  6878. }
  6879. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  6880. // I use 0xFE000000 color for signalizing that this message is
  6881. // main chat message. 0xFE000000 is invalid color, same using
  6882. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  6883. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
  6884. // Chat logging type 'M' / Main Chat
  6885. if( log_config.chat&1 || (log_config.chat&32 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
  6886. log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  6887. }
  6888. } else {
  6889. if(sd->state.mainchat)
  6890. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6891. else
  6892. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6893. }
  6894. return 0;
  6895. }
  6896. /*=====================================
  6897. * Autorejecting Invites/Deals [LuzZza]
  6898. * Usage: @noask
  6899. *-------------------------------------*/
  6900. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6901. {
  6902. if(sd->state.noask) {
  6903. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6904. sd->state.noask = 0;
  6905. } else {
  6906. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6907. sd->state.noask = 1;
  6908. }
  6909. return 0;
  6910. }
  6911. /*=====================================
  6912. * Send a @request message to all GMs of lowest_gm_level.
  6913. * Usage: @request <petition>
  6914. *-------------------------------------*/
  6915. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6916. {
  6917. if (!message || !*message) {
  6918. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6919. return -1;
  6920. }
  6921. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6922. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  6923. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6924. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6925. return 0;
  6926. }
  6927. /*==========================================
  6928. * Feel (SG save map) Reset [HiddenDragon]
  6929. *------------------------------------------*/
  6930. int atcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6931. {
  6932. pc_resetfeel(sd);
  6933. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  6934. return 0;
  6935. }
  6936. /*==========================================
  6937. * AUCTION SYSTEM
  6938. *------------------------------------------*/
  6939. int atcommand_auction(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6940. {
  6941. nullpo_retr(0,sd);
  6942. #ifndef TXT_ONLY
  6943. clif_Auction_openwindow(sd);
  6944. #endif
  6945. return 0;
  6946. }
  6947. /*==========================================
  6948. * Kill Steal Protection
  6949. *------------------------------------------*/
  6950. int atcommand_ksprotection(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6951. {
  6952. nullpo_retr(-1,sd);
  6953. if( sd->state.noks ) {
  6954. sd->state.noks = 0;
  6955. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  6956. }
  6957. else
  6958. {
  6959. if( !message || !*message || !strcmpi(message, "party") )
  6960. { // Default is Party
  6961. sd->state.noks = 2;
  6962. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  6963. }
  6964. else if( !strcmpi(message, "self") )
  6965. {
  6966. sd->state.noks = 1;
  6967. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  6968. }
  6969. else if( !strcmpi(message, "guild") )
  6970. {
  6971. sd->state.noks = 3;
  6972. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  6973. }
  6974. else
  6975. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  6976. }
  6977. clif_displaymessage(fd, atcmd_output);
  6978. return 0;
  6979. }
  6980. /*==========================================
  6981. * Map Kill Steal Protection Setting
  6982. *------------------------------------------*/
  6983. int atcommand_allowks(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6984. {
  6985. nullpo_retr(-1,sd);
  6986. if( map[sd->bl.m].flag.allowks ) {
  6987. map[sd->bl.m].flag.allowks = 0;
  6988. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  6989. } else {
  6990. map[sd->bl.m].flag.allowks = 1;
  6991. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  6992. }
  6993. clif_displaymessage(fd, atcmd_output);
  6994. return 0;
  6995. }
  6996. int atcommand_resetstat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6997. {
  6998. nullpo_retr(-1, sd);
  6999. pc_resetstate(sd);
  7000. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  7001. clif_displaymessage(fd, atcmd_output);
  7002. return 0;
  7003. }
  7004. int atcommand_resetskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7005. {
  7006. nullpo_retr(-1,sd);
  7007. pc_resetskill(sd,1);
  7008. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  7009. clif_displaymessage(fd, atcmd_output);
  7010. return 0;
  7011. }
  7012. /*==========================================
  7013. * #storagelist: Displays the items list of a player's storage.
  7014. * #cartlist: Displays contents of target's cart.
  7015. * #itemlist: Displays contents of target's inventory.
  7016. *------------------------------------------*/
  7017. int atcommand_itemlist(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7018. {
  7019. int i, j, count, counter;
  7020. const char* location;
  7021. const struct item* items;
  7022. int size;
  7023. StringBuf buf;
  7024. nullpo_retr(-1, sd);
  7025. if( strcmp(command+1, "storagelist") == 0 )
  7026. {
  7027. location = "storage";
  7028. items = sd->status.storage.items;
  7029. size = MAX_STORAGE;
  7030. }
  7031. else
  7032. if( strcmp(command+1, "cartlist") == 0 )
  7033. {
  7034. location = "cart";
  7035. items = sd->status.cart;
  7036. size = MAX_CART;
  7037. }
  7038. else
  7039. if( strcmp(command+1, "itemlist") == 0 )
  7040. {
  7041. location = "inventory";
  7042. items = sd->status.inventory;
  7043. size = MAX_INVENTORY;
  7044. }
  7045. else
  7046. return 1;
  7047. StringBuf_Init(&buf);
  7048. count = 0; // total slots occupied
  7049. counter = 0; // total items found
  7050. for( i = 0; i < size; ++i )
  7051. {
  7052. const struct item* it = &items[i];
  7053. struct item_data* itd;
  7054. if( it->nameid == 0 || (itd = itemdb_search(it->nameid)) == NULL )
  7055. continue;
  7056. counter += it->amount;
  7057. count++;
  7058. if( count == 1 )
  7059. {
  7060. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  7061. clif_displaymessage(fd, StringBuf_Value(&buf));
  7062. StringBuf_Clear(&buf);
  7063. }
  7064. if( it->refine )
  7065. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7066. else
  7067. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7068. if( it->equip )
  7069. {
  7070. char equipstr[200];
  7071. strcpy(equipstr, " | equipped: ");
  7072. if( it->equip & EQP_GARMENT )
  7073. strcat(equipstr, "garment, ");
  7074. if( it->equip & EQP_ACC_L )
  7075. strcat(equipstr, "left accessory, ");
  7076. if( it->equip & EQP_ARMOR )
  7077. strcat(equipstr, "body/armor, ");
  7078. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7079. strcat(equipstr, "right hand, ");
  7080. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7081. strcat(equipstr, "left hand, ");
  7082. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7083. strcat(equipstr, "both hands, ");
  7084. if( it->equip & EQP_SHOES )
  7085. strcat(equipstr, "feet, ");
  7086. if( it->equip & EQP_ACC_R )
  7087. strcat(equipstr, "right accessory, ");
  7088. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7089. strcat(equipstr, "lower head, ");
  7090. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7091. strcat(equipstr, "top head, ");
  7092. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7093. strcat(equipstr, "lower/top head, ");
  7094. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7095. strcat(equipstr, "mid head, ");
  7096. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7097. strcat(equipstr, "lower/mid head, ");
  7098. if( (it->equip & EQP_HELM) == EQP_HELM )
  7099. strcat(equipstr, "lower/mid/top head, ");
  7100. // remove final ', '
  7101. equipstr[strlen(equipstr) - 2] = '\0';
  7102. StringBuf_AppendStr(&buf, equipstr);
  7103. }
  7104. clif_displaymessage(fd, StringBuf_Value(&buf));
  7105. StringBuf_Clear(&buf);
  7106. if( it->card[0] == CARD0_PET )
  7107. {// pet egg
  7108. if (it->card[3])
  7109. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7110. else
  7111. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7112. }
  7113. else
  7114. if(it->card[0] == CARD0_FORGE)
  7115. {// forged item
  7116. StringBuf_Printf(&buf, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f);
  7117. }
  7118. else
  7119. if(it->card[0] == CARD0_CREATE)
  7120. {// created item
  7121. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  7122. }
  7123. else
  7124. {// normal item
  7125. int counter2 = 0;
  7126. for( j = 0; j < itd->slot; ++j )
  7127. {
  7128. struct item_data* card;
  7129. if( it->card[j] == 0 || (card = itemdb_search(it->card[j])) == NULL )
  7130. continue;
  7131. counter2++;
  7132. if( counter2 == 1 )
  7133. StringBuf_AppendStr(&buf, " -> (card(s): ");
  7134. if( counter2 != 1 )
  7135. StringBuf_AppendStr(&buf, ", ");
  7136. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7137. }
  7138. if( counter2 > 0 )
  7139. StringBuf_AppendStr(&buf, ")");
  7140. }
  7141. if( StringBuf_Length(&buf) > 0 )
  7142. clif_displaymessage(fd, StringBuf_Value(&buf));
  7143. StringBuf_Clear(&buf);
  7144. }
  7145. if( count == 0 )
  7146. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  7147. else
  7148. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  7149. clif_displaymessage(fd, StringBuf_Value(&buf));
  7150. StringBuf_Destroy(&buf);
  7151. return 0;
  7152. }
  7153. int atcommand_stats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7154. {
  7155. char job_jobname[100];
  7156. char output[200];
  7157. int i;
  7158. struct {
  7159. const char* format;
  7160. int value;
  7161. } output_table[] = {
  7162. { "Base Level - %d", 0 },
  7163. { NULL, 0 },
  7164. { "Hp - %d", 0 },
  7165. { "MaxHp - %d", 0 },
  7166. { "Sp - %d", 0 },
  7167. { "MaxSp - %d", 0 },
  7168. { "Str - %3d", 0 },
  7169. { "Agi - %3d", 0 },
  7170. { "Vit - %3d", 0 },
  7171. { "Int - %3d", 0 },
  7172. { "Dex - %3d", 0 },
  7173. { "Luk - %3d", 0 },
  7174. { "Zeny - %d", 0 },
  7175. { "Free SK Points - %d", 0 },
  7176. { "JobChangeLvl - %d", 0 },
  7177. { NULL, 0 }
  7178. };
  7179. memset(job_jobname, '\0', sizeof(job_jobname));
  7180. memset(output, '\0', sizeof(output));
  7181. //direct array initialization with variables is not standard C compliant.
  7182. output_table[0].value = sd->status.base_level;
  7183. output_table[1].format = job_jobname;
  7184. output_table[1].value = sd->status.job_level;
  7185. output_table[2].value = sd->status.hp;
  7186. output_table[3].value = sd->status.max_hp;
  7187. output_table[4].value = sd->status.sp;
  7188. output_table[5].value = sd->status.max_sp;
  7189. output_table[6].value = sd->status.str;
  7190. output_table[7].value = sd->status.agi;
  7191. output_table[8].value = sd->status.vit;
  7192. output_table[9].value = sd->status.int_;
  7193. output_table[10].value = sd->status.dex;
  7194. output_table[11].value = sd->status.luk;
  7195. output_table[12].value = sd->status.zeny;
  7196. output_table[13].value = sd->status.skill_point;
  7197. output_table[14].value = sd->change_level;
  7198. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7199. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7200. clif_displaymessage(fd, output);
  7201. for (i = 0; output_table[i].format != NULL; i++) {
  7202. sprintf(output, output_table[i].format, output_table[i].value);
  7203. clif_displaymessage(fd, output);
  7204. }
  7205. return 0;
  7206. }
  7207. int atcommand_delitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7208. {
  7209. char item_name[100];
  7210. int i, number = 0, item_id, item_position, count;
  7211. struct item_data *item_data;
  7212. char output[200];
  7213. nullpo_retr(-1, sd);
  7214. memset(item_name, '\0', sizeof(item_name));
  7215. memset(output, '\0', sizeof(output));
  7216. if (!message || !*message || (
  7217. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 2 &&
  7218. sscanf(message, "%s %d", item_name, &number) < 2
  7219. ) || number < 1) {
  7220. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <item_name_or_ID> <quantity> <player>).");
  7221. return -1;
  7222. }
  7223. item_id = 0;
  7224. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  7225. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  7226. item_id = item_data->nameid;
  7227. if (item_id > 500) {
  7228. item_position = pc_search_inventory(sd, item_id);
  7229. if (item_position >= 0) {
  7230. count = 0;
  7231. for(i = 0; i < number && item_position >= 0; i++) {
  7232. //Logs (A)dmins items [Lupus]
  7233. if(log_config.enable_logs&0x400)
  7234. log_pick_pc(sd, "A", sd->status.inventory[item_position].nameid, -1, &sd->status.inventory[item_position]);
  7235. pc_delitem(sd, item_position, 1, 0);
  7236. count++;
  7237. item_position = pc_search_inventory(sd, item_id); // for next loop
  7238. }
  7239. sprintf(output, msg_txt(113), count); // %d item(s) removed by a GM.
  7240. clif_displaymessage(sd->fd, output);
  7241. if (number == count)
  7242. sprintf(output, msg_txt(114), count); // %d item(s) removed from the player.
  7243. else
  7244. sprintf(output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  7245. clif_displaymessage(fd, output);
  7246. } else {
  7247. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7248. return -1;
  7249. }
  7250. }
  7251. else
  7252. {
  7253. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7254. return -1;
  7255. }
  7256. return 0;
  7257. }
  7258. /*==========================================
  7259. * Custom Fonts
  7260. *------------------------------------------*/
  7261. int atcommand_font(const int fd, struct map_session_data *sd, const char *command, const char *message)
  7262. {
  7263. int font_id;
  7264. nullpo_retr(-1,sd);
  7265. font_id = atoi(message);
  7266. if( font_id == 0 )
  7267. {
  7268. if( sd->state.user_font )
  7269. {
  7270. sd->state.user_font = 0;
  7271. clif_displaymessage(fd, "Returning to normal font.");
  7272. clif_font_area(sd);
  7273. }
  7274. else
  7275. {
  7276. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  7277. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  7278. }
  7279. }
  7280. else if( font_id < 0 || font_id > 9 )
  7281. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  7282. else if( font_id != sd->state.user_font )
  7283. {
  7284. sd->state.user_font = font_id;
  7285. clif_font_area(sd);
  7286. clif_displaymessage(fd, "Font changed.");
  7287. }
  7288. else
  7289. clif_displaymessage(fd, "Already using this font.");
  7290. return 0;
  7291. }
  7292. /*==========================================
  7293. * atcommand_info[] structure definition
  7294. *------------------------------------------*/
  7295. AtCommandInfo atcommand_info[] = {
  7296. { "rura", 40,40, atcommand_mapmove },
  7297. { "warp", 40,40, atcommand_mapmove },
  7298. { "mapmove", 40,40, atcommand_mapmove }, // + /mm
  7299. { "where", 1,1, atcommand_where },
  7300. { "jumpto", 20,20, atcommand_jumpto }, // + /shift
  7301. { "warpto", 20,20, atcommand_jumpto },
  7302. { "goto", 20,20, atcommand_jumpto },
  7303. { "jump", 40,40, atcommand_jump },
  7304. { "who", 20,20, atcommand_who },
  7305. { "whois", 20,20, atcommand_who },
  7306. { "who2", 20,20, atcommand_who2 },
  7307. { "who3", 20,20, atcommand_who3 },
  7308. { "whomap", 20,20, atcommand_whomap },
  7309. { "whomap2", 20,20, atcommand_whomap2 },
  7310. { "whomap3", 20,20, atcommand_whomap3 },
  7311. { "whogm", 20,20, atcommand_whogm },
  7312. { "save", 40,40, atcommand_save },
  7313. { "return", 40,40, atcommand_load },
  7314. { "load", 40,40, atcommand_load },
  7315. { "speed", 40,40, atcommand_speed },
  7316. { "storage", 1,1, atcommand_storage },
  7317. { "gstorage", 50,50, atcommand_guildstorage },
  7318. { "option", 40,40, atcommand_option },
  7319. { "hide", 40,40, atcommand_hide }, // + /hide
  7320. { "jobchange", 40,40, atcommand_jobchange },
  7321. { "job", 40,40, atcommand_jobchange },
  7322. { "die", 1,1, atcommand_die },
  7323. { "kill", 60,60, atcommand_kill },
  7324. { "alive", 60,60, atcommand_alive },
  7325. { "kami", 40,40, atcommand_kami },
  7326. { "kamib", 40,40, atcommand_kami },
  7327. { "kamic", 40,40, atcommand_kami },
  7328. { "heal", 40,60, atcommand_heal },
  7329. { "item", 60,60, atcommand_item },
  7330. { "item2", 60,60, atcommand_item2 },
  7331. { "itemreset", 40,40, atcommand_itemreset },
  7332. { "blvl", 60,60, atcommand_baselevelup },
  7333. { "lvup", 60,60, atcommand_baselevelup },
  7334. { "blevel", 60,60, atcommand_baselevelup },
  7335. { "baselvl", 60,60, atcommand_baselevelup },
  7336. { "baselvup", 60,60, atcommand_baselevelup },
  7337. { "baselevel", 60,60, atcommand_baselevelup },
  7338. { "baselvlup", 60,60, atcommand_baselevelup },
  7339. { "jlvl", 60,60, atcommand_joblevelup },
  7340. { "jlevel", 60,60, atcommand_joblevelup },
  7341. { "joblvl", 60,60, atcommand_joblevelup },
  7342. { "joblevel", 60,60, atcommand_joblevelup },
  7343. { "joblvup", 60,60, atcommand_joblevelup },
  7344. { "joblvlup", 60,60, atcommand_joblevelup },
  7345. { "h", 20,20, atcommand_help },
  7346. { "help", 20,20, atcommand_help },
  7347. { "h2", 20,20, atcommand_help2 },
  7348. { "help2", 20,20, atcommand_help2 },
  7349. { "pvpoff", 40,40, atcommand_pvpoff },
  7350. { "pvpon", 40,40, atcommand_pvpon },
  7351. { "gvgoff", 40,40, atcommand_gvgoff },
  7352. { "gpvpoff", 40,40, atcommand_gvgoff },
  7353. { "gvgon", 40,40, atcommand_gvgon },
  7354. { "gpvpon", 40,40, atcommand_gvgon },
  7355. { "model", 20,20, atcommand_model },
  7356. { "go", 10,10, atcommand_go },
  7357. { "monster", 50,50, atcommand_monster },
  7358. { "spawn", 50,50, atcommand_monster },
  7359. { "monstersmall", 50,50, atcommand_monstersmall },
  7360. { "monsterbig", 50,50, atcommand_monsterbig },
  7361. { "killmonster", 60,60, atcommand_killmonster },
  7362. { "killmonster2", 40,40, atcommand_killmonster2 },
  7363. { "refine", 60,60, atcommand_refine },
  7364. { "produce", 60,60, atcommand_produce },
  7365. { "memo", 40,40, atcommand_memo },
  7366. { "gat", 99,99, atcommand_gat },
  7367. { "displaystatus", 99,99, atcommand_displaystatus },
  7368. { "stpoint", 60,60, atcommand_statuspoint },
  7369. { "skpoint", 60,60, atcommand_skillpoint },
  7370. { "zeny", 60,60, atcommand_zeny },
  7371. { "str", 60,60, atcommand_param },
  7372. { "agi", 60,60, atcommand_param },
  7373. { "vit", 60,60, atcommand_param },
  7374. { "int", 60,60, atcommand_param },
  7375. { "dex", 60,60, atcommand_param },
  7376. { "luk", 60,60, atcommand_param },
  7377. { "glvl", 60,60, atcommand_guildlevelup },
  7378. { "glevel", 60,60, atcommand_guildlevelup },
  7379. { "guildlvl", 60,60, atcommand_guildlevelup },
  7380. { "guildlvup", 60,60, atcommand_guildlevelup },
  7381. { "guildlevel", 60,60, atcommand_guildlevelup },
  7382. { "guildlvlup", 60,60, atcommand_guildlevelup },
  7383. { "makeegg", 60,60, atcommand_makeegg },
  7384. { "hatch", 60,60, atcommand_hatch },
  7385. { "petfriendly", 40,40, atcommand_petfriendly },
  7386. { "pethungry", 40,40, atcommand_pethungry },
  7387. { "petrename", 1,1, atcommand_petrename },
  7388. { "recall", 60,60, atcommand_recall }, // + /recall
  7389. { "night", 80,80, atcommand_night },
  7390. { "day", 80,80, atcommand_day },
  7391. { "doom", 80,80, atcommand_doom },
  7392. { "doommap", 80,80, atcommand_doommap },
  7393. { "raise", 80,80, atcommand_raise },
  7394. { "raisemap", 80,80, atcommand_raisemap },
  7395. { "kick", 20,20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7396. { "kickall", 99,99, atcommand_kickall },
  7397. { "allskill", 60,60, atcommand_allskill },
  7398. { "allskills", 60,60, atcommand_allskill },
  7399. { "skillall", 60,60, atcommand_allskill },
  7400. { "skillsall", 60,60, atcommand_allskill },
  7401. { "questskill", 40,40, atcommand_questskill },
  7402. { "lostskill", 40,40, atcommand_lostskill },
  7403. { "spiritball", 40,40, atcommand_spiritball },
  7404. { "party", 1,1, atcommand_party },
  7405. { "guild", 50,50, atcommand_guild },
  7406. { "agitstart", 60,60, atcommand_agitstart },
  7407. { "agitend", 60,60, atcommand_agitend },
  7408. { "mapexit", 99,99, atcommand_mapexit },
  7409. { "idsearch", 60,60, atcommand_idsearch },
  7410. { "broadcast", 40,40, atcommand_broadcast }, // + /b and /nb
  7411. { "localbroadcast", 40,40, atcommand_localbroadcast }, // + /lb and /nlb
  7412. { "recallall", 80,80, atcommand_recallall },
  7413. { "reloaditemdb", 99,99, atcommand_reloaditemdb },
  7414. { "reloadmobdb", 99,99, atcommand_reloadmobdb },
  7415. { "reloadskilldb", 99,99, atcommand_reloadskilldb },
  7416. { "reloadscript", 99,99, atcommand_reloadscript },
  7417. { "reloadatcommand", 99,99, atcommand_reloadatcommand },
  7418. { "reloadbattleconf", 99,99, atcommand_reloadbattleconf },
  7419. { "reloadstatusdb", 99,99, atcommand_reloadstatusdb },
  7420. { "reloadpcdb", 99,99, atcommand_reloadpcdb },
  7421. { "reloadmotd", 99,99, atcommand_reloadmotd },
  7422. { "mapinfo", 99,99, atcommand_mapinfo },
  7423. { "dye", 40,40, atcommand_dye },
  7424. { "ccolor", 40,40, atcommand_dye },
  7425. { "hairstyle", 40,40, atcommand_hair_style },
  7426. { "hstyle", 40,40, atcommand_hair_style },
  7427. { "haircolor", 40,40, atcommand_hair_color },
  7428. { "hcolor", 40,40, atcommand_hair_color },
  7429. { "statall", 60,60, atcommand_stat_all },
  7430. { "statsall", 60,60, atcommand_stat_all },
  7431. { "allstats", 60,60, atcommand_stat_all },
  7432. { "allstat", 60,60, atcommand_stat_all },
  7433. { "block", 60,60, atcommand_char_block },
  7434. { "charblock", 60,60, atcommand_char_block },
  7435. { "ban", 60,60, atcommand_char_ban },
  7436. { "banish", 60,60, atcommand_char_ban },
  7437. { "charban", 60,60, atcommand_char_ban },
  7438. { "charbanish", 60,60, atcommand_char_ban },
  7439. { "unblock", 60,60, atcommand_char_unblock },
  7440. { "charunblock", 60,60, atcommand_char_unblock },
  7441. { "unban", 60,60, atcommand_char_unban },
  7442. { "unbanish", 60,60, atcommand_char_unban },
  7443. { "charunban", 60,60, atcommand_char_unban },
  7444. { "charunbanish", 60,60, atcommand_char_unban },
  7445. { "mount", 20,20, atcommand_mount_peco },
  7446. { "mountpeco", 20,20, atcommand_mount_peco },
  7447. { "guildspy", 60,60, atcommand_guildspy },
  7448. { "partyspy", 60,60, atcommand_partyspy },
  7449. { "repairall", 60,60, atcommand_repairall },
  7450. { "guildrecall", 60,60, atcommand_guildrecall },
  7451. { "partyrecall", 60,60, atcommand_partyrecall },
  7452. { "nuke", 60,60, atcommand_nuke },
  7453. { "shownpc", 80,80, atcommand_shownpc },
  7454. { "hidenpc", 80,80, atcommand_hidenpc },
  7455. { "loadnpc", 80,80, atcommand_loadnpc },
  7456. { "unloadnpc", 80,80, atcommand_unloadnpc },
  7457. { "time", 1,1, atcommand_servertime },
  7458. { "date", 1,1, atcommand_servertime },
  7459. { "serverdate", 1,1, atcommand_servertime },
  7460. { "servertime", 1,1, atcommand_servertime },
  7461. { "jail", 60,60, atcommand_jail },
  7462. { "unjail", 60,60, atcommand_unjail },
  7463. { "discharge", 60,60, atcommand_unjail },
  7464. { "jailfor", 60,60, atcommand_jailfor },
  7465. { "jailtime", 1,1, atcommand_jailtime },
  7466. { "disguise", 20,20, atcommand_disguise },
  7467. { "undisguise", 20,20, atcommand_undisguise },
  7468. { "email", 1,1, atcommand_email },
  7469. { "effect", 40,40, atcommand_effect },
  7470. { "follow", 20,20, atcommand_follow },
  7471. { "addwarp", 60,60, atcommand_addwarp },
  7472. { "skillon", 80,80, atcommand_skillon },
  7473. { "skilloff", 80,80, atcommand_skilloff },
  7474. { "killer", 60,60, atcommand_killer },
  7475. { "npcmove", 80,80, atcommand_npcmove },
  7476. { "killable", 40,40, atcommand_killable },
  7477. { "dropall", 40,40, atcommand_dropall },
  7478. { "storeall", 40,40, atcommand_storeall },
  7479. { "skillid", 40,40, atcommand_skillid },
  7480. { "useskill", 40,40, atcommand_useskill },
  7481. { "displayskill", 99,99, atcommand_displayskill },
  7482. { "snow", 99,99, atcommand_snow },
  7483. { "sakura", 99,99, atcommand_sakura },
  7484. { "clouds", 99,99, atcommand_clouds },
  7485. { "clouds2", 99,99, atcommand_clouds2 },
  7486. { "fog", 99,99, atcommand_fog },
  7487. { "fireworks", 99,99, atcommand_fireworks },
  7488. { "leaves", 99,99, atcommand_leaves },
  7489. { "summon", 60,60, atcommand_summon },
  7490. { "adjgmlvl", 99,99, atcommand_adjgmlvl },
  7491. { "adjcmdlvl", 99,99, atcommand_adjcmdlvl },
  7492. { "trade", 60,60, atcommand_trade },
  7493. { "send", 99,99, atcommand_send },
  7494. { "setbattleflag", 99,99, atcommand_setbattleflag },
  7495. { "unmute", 80,80, atcommand_unmute },
  7496. { "clearweather", 99,99, atcommand_clearweather },
  7497. { "uptime", 1,1, atcommand_uptime },
  7498. { "changesex", 60,60, atcommand_changesex },
  7499. { "mute", 80,80, atcommand_mute },
  7500. { "refresh", 1,1, atcommand_refresh },
  7501. { "identify", 40,40, atcommand_identify },
  7502. { "gmotd", 20,20, atcommand_gmotd },
  7503. { "misceffect", 50,50, atcommand_misceffect },
  7504. { "mobsearch", 10,10, atcommand_mobsearch },
  7505. { "cleanmap", 40,40, atcommand_cleanmap },
  7506. { "npctalk", 20,20, atcommand_npctalk },
  7507. { "npctalkc", 20,20, atcommand_npctalk },
  7508. { "pettalk", 10,10, atcommand_pettalk },
  7509. { "users", 40,40, atcommand_users },
  7510. { "reset", 40,40, atcommand_reset },
  7511. { "skilltree", 40,40, atcommand_skilltree },
  7512. { "marry", 40,40, atcommand_marry },
  7513. { "divorce", 40,40, atcommand_divorce },
  7514. { "sound", 40,40, atcommand_sound },
  7515. { "undisguiseall", 99,99, atcommand_undisguiseall },
  7516. { "disguiseall", 99,99, atcommand_disguiseall },
  7517. { "changelook", 60,60, atcommand_changelook },
  7518. { "autoloot", 10,10, atcommand_autoloot },
  7519. { "alootid", 10,10, atcommand_autolootitem },
  7520. { "mobinfo", 1,1, atcommand_mobinfo },
  7521. { "monsterinfo", 1,1, atcommand_mobinfo },
  7522. { "mi", 1,1, atcommand_mobinfo },
  7523. { "exp", 1,1, atcommand_exp },
  7524. { "adopt", 40,40, atcommand_adopt },
  7525. { "version", 1,1, atcommand_version },
  7526. { "mutearea", 99,99, atcommand_mutearea },
  7527. { "stfu", 99,99, atcommand_mutearea },
  7528. { "rates", 1,1, atcommand_rates },
  7529. { "iteminfo", 1,1, atcommand_iteminfo },
  7530. { "ii", 1,1, atcommand_iteminfo },
  7531. { "whodrops", 1,1, atcommand_whodrops },
  7532. { "whereis", 10,10, atcommand_whereis },
  7533. { "mapflag", 99,99, atcommand_mapflag },
  7534. { "me", 20,20, atcommand_me },
  7535. { "monsterignore", 99,99, atcommand_monsterignore },
  7536. { "battleignore", 99,99, atcommand_monsterignore },
  7537. { "fakename", 20,20, atcommand_fakename },
  7538. { "size", 20,20, atcommand_size },
  7539. { "showexp", 10,10, atcommand_showexp},
  7540. { "showzeny", 10,10, atcommand_showzeny},
  7541. { "showdelay", 1,1, atcommand_showdelay},
  7542. { "autotrade", 10,10, atcommand_autotrade },
  7543. { "at", 10,10, atcommand_autotrade },
  7544. { "changegm", 10,10, atcommand_changegm },
  7545. { "changeleader", 10,10, atcommand_changeleader },
  7546. { "partyoption", 10,10, atcommand_partyoption},
  7547. { "invite", 1,1, atcommand_invite },
  7548. { "duel", 1,1, atcommand_duel },
  7549. { "leave", 1,1, atcommand_leave },
  7550. { "accept", 1,1, atcommand_accept },
  7551. { "reject", 1,1, atcommand_reject },
  7552. { "away", 1,1, atcommand_away },
  7553. { "aw", 1,1, atcommand_away },
  7554. { "main", 1,1, atcommand_main },
  7555. { "clone", 50,50, atcommand_clone },
  7556. { "slaveclone", 50,50, atcommand_clone },
  7557. { "evilclone", 50,50, atcommand_clone },
  7558. { "tonpc", 40,40, atcommand_tonpc },
  7559. { "commands", 1,1, atcommand_commands },
  7560. { "noask", 1,1, atcommand_noask },
  7561. { "request", 20,20, atcommand_request },
  7562. { "hlvl", 60,60, atcommand_homlevel },
  7563. { "hlevel", 60,60, atcommand_homlevel },
  7564. { "homlvl", 60,60, atcommand_homlevel },
  7565. { "homlvup", 60,60, atcommand_homlevel },
  7566. { "homlevel", 60,60, atcommand_homlevel },
  7567. { "homevolve", 60,60, atcommand_homevolution },
  7568. { "homevolution", 60,60, atcommand_homevolution },
  7569. { "makehomun", 60,60, atcommand_makehomun },
  7570. { "homfriendly", 60,60, atcommand_homfriendly },
  7571. { "homhungry", 60,60, atcommand_homhungry },
  7572. { "homtalk", 10,10, atcommand_homtalk },
  7573. { "hominfo", 1,1, atcommand_hominfo },
  7574. { "homstats", 1,1, atcommand_homstats },
  7575. { "homshuffle", 60,60, atcommand_homshuffle },
  7576. { "showmobs", 10,10, atcommand_showmobs },
  7577. { "feelreset", 10,10, atcommand_feelreset },
  7578. { "auction", 1,1, atcommand_auction },
  7579. { "mail", 1,1, atcommand_mail },
  7580. { "noks", 1,1, atcommand_ksprotection },
  7581. { "allowks", 40,40, atcommand_allowks },
  7582. { "cash", 60,60, atcommand_cash },
  7583. { "points", 60,60, atcommand_cash },
  7584. { "agitstart2", 60,60, atcommand_agitstart2 },
  7585. { "agitend2", 60,60, atcommand_agitend2 },
  7586. { "skreset", 60,60, atcommand_resetskill },
  7587. { "streset", 60,60, atcommand_resetstat },
  7588. { "storagelist", 40,40, atcommand_itemlist },
  7589. { "cartlist", 40,40, atcommand_itemlist },
  7590. { "itemlist", 40,40, atcommand_itemlist },
  7591. { "stats", 40,40, atcommand_stats },
  7592. { "delitem", 60,60, atcommand_delitem },
  7593. { "charcommands", 1,1, atcommand_commands },
  7594. { "font", 1,1, atcommand_font },
  7595. };
  7596. /*==========================================
  7597. * Command lookup functions
  7598. *------------------------------------------*/
  7599. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  7600. {
  7601. int i;
  7602. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  7603. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  7604. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7605. }
  7606. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  7607. {
  7608. int i;
  7609. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  7610. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7611. }
  7612. /*==========================================
  7613. * Retrieve the command's required gm level
  7614. *------------------------------------------*/
  7615. int get_atcommand_level(const AtCommandFunc func)
  7616. {
  7617. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  7618. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7619. }
  7620. /// Executes an at-command.
  7621. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7622. {
  7623. char charname[NAME_LENGTH], params[100];
  7624. char charname2[NAME_LENGTH], params2[100];
  7625. char command[100];
  7626. char output[200];
  7627. int x, y, z;
  7628. int lv = 0;
  7629. //Reconstructed message
  7630. char atcmd_msg[200];
  7631. TBL_PC * ssd = NULL; //sd for target
  7632. AtCommandInfo * info;
  7633. nullpo_retr(false, sd);
  7634. //Shouldn't happen
  7635. if( !message || !*message )
  7636. return false;
  7637. //Block NOCHAT but do not display it as a normal message
  7638. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7639. return true;
  7640. // skip 10/11-langtype's codepage indicator, if detected
  7641. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7642. message += 3;
  7643. //Should display as a normal message
  7644. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7645. return false;
  7646. // type value 0 = server invoked: bypass restrictions
  7647. // 1 = player invoked
  7648. if( type )
  7649. {
  7650. //Commands are disabled on maps flagged as 'nocommand'
  7651. if( map[sd->bl.m].nocommand && pc_isGM(sd) < map[sd->bl.m].nocommand )
  7652. {
  7653. clif_displaymessage(fd, msg_txt(143));
  7654. return false;
  7655. }
  7656. //Displays as a normal message for Non-GMs
  7657. if( battle_config.atc_gmonly != 0 && pc_isGM(sd) == 0 )
  7658. return false;
  7659. }
  7660. while (*message == charcommand_symbol)
  7661. {
  7662. //Checks to see if #command has a name or a name + parameters.
  7663. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7664. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7665. //z always has the value of the scan that was successful
  7666. z = ( x > 1 ) ? x : y;
  7667. if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) )
  7668. {
  7669. sprintf(output, "%s failed. Player not found.", command);
  7670. clif_displaymessage(fd, output);
  7671. return true;
  7672. }
  7673. //#command + name means the sufficient target was used and anything else after
  7674. //can be looked at by the actual command function since most scan to see if the
  7675. //right parameters are used.
  7676. if ( x > 2 ) {
  7677. sprintf(atcmd_msg, "%s %s", command, params);
  7678. break;
  7679. }
  7680. else if ( y > 2 ) {
  7681. sprintf(atcmd_msg, "%s %s", command, params2);
  7682. break;
  7683. }
  7684. //Regardless of what style the #command is used, if it's correct, it will always have
  7685. //this value if there is no parameter. Send it as just the #command
  7686. else if ( z == 2 ) {
  7687. sprintf(atcmd_msg, "%s", command);
  7688. break;
  7689. }
  7690. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7691. clif_displaymessage(fd, output);
  7692. return true;
  7693. }
  7694. if (*message == atcommand_symbol) {
  7695. //atcmd_msg is constructed above differently for charcommands
  7696. //it's copied from message if not a charcommand so it can
  7697. //pass through the rest of the code compatible with both symbols
  7698. sprintf(atcmd_msg, "%s", message);
  7699. }
  7700. //Clearing these to be used once more.
  7701. memset(command, '\0', sizeof(command));
  7702. memset(params, '\0', sizeof(params));
  7703. //check to see if any params exist within this command
  7704. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7705. params[0] = '\0';
  7706. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7707. info = get_atcommandinfo_byname(command);
  7708. if( info == NULL || info->func == NULL || ( type && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2)) ) )
  7709. {
  7710. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7711. clif_displaymessage(fd, output);
  7712. return true;
  7713. }
  7714. //Attempt to use the command
  7715. if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
  7716. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  7717. {
  7718. sprintf(output,msg_txt(154), command); // %s failed.
  7719. clif_displaymessage(fd, output);
  7720. }
  7721. if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
  7722. //Log atcommands
  7723. if( log_config.gm && info->level >= log_config.gm && *atcmd_msg == atcommand_symbol )
  7724. log_atcommand(sd, atcmd_msg);
  7725. //Log Charcommands
  7726. if( log_config.gm && info->level2 >= log_config.gm && *atcmd_msg == charcommand_symbol && ssd != NULL )
  7727. log_atcommand(sd, message);
  7728. return true;
  7729. }
  7730. /*==========================================
  7731. *
  7732. *------------------------------------------*/
  7733. int atcommand_config_read(const char* cfgName)
  7734. {
  7735. char line[1024], w1[1024], w2[1024], w3[1024];
  7736. AtCommandInfo* p;
  7737. FILE* fp;
  7738. if( (fp = fopen(cfgName, "r")) == NULL )
  7739. {
  7740. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  7741. return 1;
  7742. }
  7743. while( fgets(line, sizeof(line), fp) )
  7744. {
  7745. if( line[0] == '/' && line[1] == '/' )
  7746. continue;
  7747. if( (sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3)) != 3 && ( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2
  7748. && strcmpi(w1, "import") != 0 ) && strcmpi(w1, "command_symbol") != 0 && strcmpi(w1, "char_symbol") != 0 )
  7749. continue;
  7750. p = get_atcommandinfo_byname(w1);
  7751. if( p != NULL )
  7752. {
  7753. p->level = atoi(w2);
  7754. p->level = cap_value(p->level, 0, 100);
  7755. if( (sscanf(line, "%1023[^:]:%1023s", w1, w2) == 2) && (sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3)) != 3 )
  7756. {
  7757. ShowWarning("atcommand_conf: setting %s:%d is deprecated! Please see atcommand_athena.conf for the new setting format.\n",w1,atoi(w2));
  7758. ShowWarning("atcommand_conf: defaulting %s charcommand level to %d.\n",w1,atoi(w2));
  7759. p->level2 = atoi(w2);
  7760. }
  7761. else {
  7762. p->level2 = atoi(w3);
  7763. p->level2 = cap_value(p->level2, 0, 100);
  7764. }
  7765. }
  7766. else
  7767. if( strcmpi(w1, "import") == 0 )
  7768. atcommand_config_read(w2);
  7769. else
  7770. if( strcmpi(w1, "command_symbol") == 0 &&
  7771. w2[0] > 31 && // control characters
  7772. w2[0] != '/' && // symbol of standard ragnarok GM commands
  7773. w2[0] != '%' && // symbol of party chat speaking
  7774. w2[0] != '$' && // symbol of guild chat speaking
  7775. w2[0] != '#' ) // remote symbol
  7776. atcommand_symbol = w2[0];
  7777. else
  7778. if( strcmpi(w1, "char_symbol") == 0 &&
  7779. w2[0] > 31 &&
  7780. w2[0] != '/' &&
  7781. w2[0] != '%' &&
  7782. w2[0] != '$' &&
  7783. w2[0] != '@' )
  7784. charcommand_symbol = w2[0];
  7785. else
  7786. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  7787. }
  7788. fclose(fp);
  7789. return 0;
  7790. }
  7791. void do_init_atcommand()
  7792. {
  7793. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  7794. return;
  7795. }
  7796. void do_final_atcommand()
  7797. {
  7798. }
  7799. // commands that need to go _after_ the commands table
  7800. /*==========================================
  7801. * @commands Lists available @ commands to you
  7802. *------------------------------------------*/
  7803. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7804. {
  7805. char line_buff[CHATBOX_SIZE];
  7806. int i, gm_lvl = pc_isGM(sd), count = 0;
  7807. char* cur = line_buff;
  7808. memset(line_buff,' ',CHATBOX_SIZE);
  7809. line_buff[CHATBOX_SIZE-1] = 0;
  7810. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7811. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  7812. {
  7813. unsigned int slen;
  7814. if( gm_lvl < atcommand_info[i].level && stristr(command,"commands") )
  7815. continue;
  7816. if( gm_lvl < atcommand_info[i].level2 && stristr(command,"charcommands") )
  7817. continue;
  7818. slen = (unsigned int)strlen(atcommand_info[i].command);
  7819. // flush the text buffer if this command won't fit into it
  7820. if( slen + cur - line_buff >= CHATBOX_SIZE )
  7821. {
  7822. clif_displaymessage(fd,line_buff);
  7823. cur = line_buff;
  7824. memset(line_buff,' ',CHATBOX_SIZE);
  7825. line_buff[CHATBOX_SIZE-1] = 0;
  7826. }
  7827. memcpy(cur,atcommand_info[i].command,slen);
  7828. cur += slen+(10-slen%10);
  7829. count++;
  7830. }
  7831. clif_displaymessage(fd,line_buff);
  7832. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7833. clif_displaymessage(fd, atcmd_output);
  7834. return 0;
  7835. }