atcommand.c 259 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597
  1. // $Id: atcommand.c 148 2004-09-30 14:05:37Z MouseJstr $
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <math.h>
  7. #include "../common/socket.h"
  8. #include "../common/timer.h"
  9. #include "../common/nullpo.h"
  10. #include "log.h"
  11. #include "clif.h"
  12. #include "chrif.h"
  13. #include "intif.h"
  14. #include "itemdb.h"
  15. #include "map.h"
  16. #include "pc.h"
  17. #include "skill.h"
  18. #include "mob.h"
  19. #include "pet.h"
  20. #include "battle.h"
  21. #include "party.h"
  22. #include "guild.h"
  23. #include "atcommand.h"
  24. #include "script.h"
  25. #include "npc.h"
  26. #include "trade.h"
  27. #include "core.h"
  28. #ifndef TXT_ONLY
  29. #include "mail.h"
  30. #endif
  31. #define STATE_BLIND 0x10
  32. static char command_symbol = '@'; // first char of the commands (by [Yor])
  33. char msg_table[1000][256]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  34. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  35. ACMD_FUNC(broadcast);
  36. ACMD_FUNC(localbroadcast);
  37. ACMD_FUNC(rura);
  38. ACMD_FUNC(where);
  39. ACMD_FUNC(jumpto);
  40. ACMD_FUNC(jump);
  41. ACMD_FUNC(who);
  42. ACMD_FUNC(who2);
  43. ACMD_FUNC(who3);
  44. ACMD_FUNC(whomap);
  45. ACMD_FUNC(whomap2);
  46. ACMD_FUNC(whomap3);
  47. ACMD_FUNC(whogm); // by Yor
  48. ACMD_FUNC(whozeny); // [Valaris]
  49. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  50. ACMD_FUNC(save);
  51. ACMD_FUNC(load);
  52. ACMD_FUNC(speed);
  53. ACMD_FUNC(storage);
  54. ACMD_FUNC(guildstorage);
  55. ACMD_FUNC(option);
  56. ACMD_FUNC(hide);
  57. ACMD_FUNC(jobchange);
  58. ACMD_FUNC(die);
  59. ACMD_FUNC(kill);
  60. ACMD_FUNC(alive);
  61. ACMD_FUNC(kami);
  62. ACMD_FUNC(heal);
  63. ACMD_FUNC(item);
  64. ACMD_FUNC(item2);
  65. ACMD_FUNC(itemreset);
  66. ACMD_FUNC(itemcheck);
  67. ACMD_FUNC(baselevelup);
  68. ACMD_FUNC(joblevelup);
  69. ACMD_FUNC(help);
  70. ACMD_FUNC(gm);
  71. ACMD_FUNC(pvpoff);
  72. ACMD_FUNC(pvpon);
  73. ACMD_FUNC(gvgoff);
  74. ACMD_FUNC(gvgon);
  75. ACMD_FUNC(model);
  76. ACMD_FUNC(go);
  77. ACMD_FUNC(monster);
  78. ACMD_FUNC(monstersmall);
  79. ACMD_FUNC(monsterbig);
  80. ACMD_FUNC(spawn);
  81. ACMD_FUNC(killmonster);
  82. ACMD_FUNC(killmonster2);
  83. ACMD_FUNC(refine);
  84. ACMD_FUNC(produce);
  85. ACMD_FUNC(memo);
  86. ACMD_FUNC(gat);
  87. ACMD_FUNC(packet);
  88. ACMD_FUNC(statuspoint);
  89. ACMD_FUNC(skillpoint);
  90. ACMD_FUNC(zeny);
  91. ACMD_FUNC(param);
  92. ACMD_FUNC(guildlevelup);
  93. ACMD_FUNC(makeegg);
  94. ACMD_FUNC(hatch);
  95. ACMD_FUNC(petfriendly);
  96. ACMD_FUNC(pethungry);
  97. ACMD_FUNC(petrename);
  98. ACMD_FUNC(recall);
  99. ACMD_FUNC(recallall);
  100. ACMD_FUNC(revive);
  101. ACMD_FUNC(character_stats_all);
  102. ACMD_FUNC(character_save);
  103. ACMD_FUNC(night);
  104. ACMD_FUNC(day);
  105. ACMD_FUNC(doom);
  106. ACMD_FUNC(doommap);
  107. ACMD_FUNC(raise);
  108. ACMD_FUNC(raisemap);
  109. ACMD_FUNC(character_baselevel);
  110. ACMD_FUNC(character_joblevel);
  111. ACMD_FUNC(kick);
  112. ACMD_FUNC(kickall);
  113. ACMD_FUNC(allskill);
  114. ACMD_FUNC(questskill);
  115. ACMD_FUNC(charquestskill);
  116. ACMD_FUNC(lostskill);
  117. ACMD_FUNC(charlostskill);
  118. ACMD_FUNC(spiritball);
  119. ACMD_FUNC(party);
  120. ACMD_FUNC(guild);
  121. ACMD_FUNC(charskreset);
  122. ACMD_FUNC(charstreset);
  123. ACMD_FUNC(charreset);
  124. ACMD_FUNC(charstpoint);
  125. ACMD_FUNC(charmodel);
  126. ACMD_FUNC(charskpoint);
  127. ACMD_FUNC(agitstart);
  128. ACMD_FUNC(agitend);
  129. ACMD_FUNC(reloaditemdb);
  130. ACMD_FUNC(reloadmobdb);
  131. ACMD_FUNC(reloadskilldb);
  132. #ifndef TXT_ONLY
  133. ACMD_FUNC(rehash);// by Fr3DBr
  134. #else /* TXT_ONLY */
  135. ACMD_FUNC(reloadscript);
  136. #endif /* TXT_ONLY */
  137. ACMD_FUNC(reloadgmdb); // by Yor
  138. ACMD_FUNC(mapexit);
  139. ACMD_FUNC(idsearch);
  140. ACMD_FUNC(mapinfo);
  141. ACMD_FUNC(dye); //** by fritz
  142. ACMD_FUNC(hair_style); //** by fritz
  143. ACMD_FUNC(hair_color); //** by fritz
  144. ACMD_FUNC(stat_all); //** by fritz
  145. ACMD_FUNC(char_change_sex); // by Yor
  146. ACMD_FUNC(char_block); // by Yor
  147. ACMD_FUNC(char_ban); // by Yor
  148. ACMD_FUNC(char_unblock); // by Yor
  149. ACMD_FUNC(char_unban); // by Yor
  150. ACMD_FUNC(mount_peco); // by Valaris
  151. ACMD_FUNC(char_mount_peco); // by Yor
  152. ACMD_FUNC(guildspy); // [Syrus22]
  153. ACMD_FUNC(partyspy); // [Syrus22]
  154. ACMD_FUNC(repairall); // [Valaris]
  155. ACMD_FUNC(guildrecall); // by Yor
  156. ACMD_FUNC(partyrecall); // by Yor
  157. ACMD_FUNC(nuke); // [Valaris]
  158. ACMD_FUNC(enablenpc);
  159. ACMD_FUNC(disablenpc);
  160. ACMD_FUNC(servertime); // by Yor
  161. ACMD_FUNC(chardelitem); // by Yor
  162. ACMD_FUNC(jail); // by Yor
  163. ACMD_FUNC(unjail); // by Yor
  164. ACMD_FUNC(disguise); // [Valaris]
  165. ACMD_FUNC(undisguise); // by Yor
  166. ACMD_FUNC(chardisguise); // Kalaspuff
  167. ACMD_FUNC(charundisguise); // Kalaspuff
  168. ACMD_FUNC(email); // by Yor
  169. ACMD_FUNC(effect);//by Apple
  170. ACMD_FUNC(character_cart_list); // by Yor
  171. ACMD_FUNC(addwarp); // by MouseJstr
  172. ACMD_FUNC(follow); // by MouseJstr
  173. ACMD_FUNC(skillon); // by MouseJstr
  174. ACMD_FUNC(skilloff); // by MouseJstr
  175. ACMD_FUNC(killer); // by MouseJstr
  176. ACMD_FUNC(npcmove); // by MouseJstr
  177. ACMD_FUNC(killable); // by MouseJstr
  178. ACMD_FUNC(charkillable); // by MouseJstr
  179. ACMD_FUNC(dropall); // by MouseJstr
  180. ACMD_FUNC(chardropall); // by MouseJstr
  181. ACMD_FUNC(storeall); // by MouseJstr
  182. ACMD_FUNC(charstoreall); // by MouseJstr
  183. ACMD_FUNC(skillid); // by MouseJstr
  184. ACMD_FUNC(useskill); // by MouseJstr
  185. ACMD_FUNC(summon);
  186. ACMD_FUNC(rain);
  187. ACMD_FUNC(snow);
  188. ACMD_FUNC(sakura);
  189. ACMD_FUNC(fog);
  190. ACMD_FUNC(leaves);
  191. ACMD_FUNC(adjgmlvl); // by MouseJstr
  192. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  193. ACMD_FUNC(trade); // by MouseJstr
  194. ACMD_FUNC(send); // by davidsiaw
  195. ACMD_FUNC(setbattleflag); // by MouseJstr
  196. ACMD_FUNC(unmute); // [Valaris]
  197. ACMD_FUNC(clearweather); // Dexity
  198. ACMD_FUNC(uptime); // by MC Cameri
  199. ACMD_FUNC(changesex); // by MC Cameri
  200. ACMD_FUNC(mute); // celest
  201. ACMD_FUNC(refresh); // by MC Cameri
  202. ACMD_FUNC(petid); // by MC Cameri
  203. ACMD_FUNC(identify); // by MC Cameri
  204. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  205. ACMD_FUNC(misceffect); // by MC Cameri
  206. #ifndef TXT_ONLY
  207. ACMD_FUNC(checkmail); // [Valaris]
  208. ACMD_FUNC(listmail); // [Valaris]
  209. ACMD_FUNC(listnewmail); // [Valaris]
  210. ACMD_FUNC(readmail); // [Valaris]
  211. ACMD_FUNC(sendmail); // [Valaris]
  212. ACMD_FUNC(sendprioritymail); // [Valaris]
  213. ACMD_FUNC(deletemail); // [Valaris]
  214. ACMD_FUNC(sound); // [Valaris]
  215. ACMD_FUNC(refreshonline); // [Valaris]
  216. #endif /* TXT_ONLY */
  217. ACMD_FUNC(skilltree); // by MouseJstr
  218. ACMD_FUNC(marry); // by MouseJstr
  219. ACMD_FUNC(divorce); // by MouseJstr
  220. ACMD_FUNC(rings); // by MouseJstr
  221. ACMD_FUNC(grind); // by MouseJstr
  222. ACMD_FUNC(jumptoid); // by Dino9021
  223. ACMD_FUNC(jumptoid2); // by Dino9021
  224. ACMD_FUNC(recallid); // by Dino9021
  225. ACMD_FUNC(recallid2); // by Dino9021
  226. ACMD_FUNC(kickid); // by Dino9021
  227. ACMD_FUNC(kickid2); // by Dino9021
  228. ACMD_FUNC(reviveid); // by Dino9021
  229. ACMD_FUNC(reviveid2); // by Dino9021
  230. ACMD_FUNC(killid); // by Dino9021
  231. ACMD_FUNC(killid2); // by Dino9021
  232. ACMD_FUNC(charkillableid); // by Dino9021
  233. ACMD_FUNC(charkillableid2); // by Dino9021
  234. /*==========================================
  235. *AtCommandInfo atcommand_info[]構造体の定義
  236. *------------------------------------------
  237. */
  238. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  239. // to set default level, read atcommand_athena.conf first please.
  240. static AtCommandInfo atcommand_info[] = {
  241. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  242. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  243. { AtCommand_Where, "@where", 1, atcommand_where },
  244. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  245. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  246. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  247. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  248. { AtCommand_Who, "@who", 20, atcommand_who },
  249. { AtCommand_Who, "@whois", 20, atcommand_who },
  250. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  251. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  252. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  253. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  254. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  255. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  256. { AtCommand_Save, "@save", 40, atcommand_save },
  257. { AtCommand_Load, "@return", 40, atcommand_load },
  258. { AtCommand_Load, "@load", 40, atcommand_load },
  259. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  260. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  261. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  262. { AtCommand_Option, "@option", 40, atcommand_option },
  263. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  264. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  265. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  266. { AtCommand_Die, "@die", 1, atcommand_die },
  267. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  268. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  269. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  270. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  271. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  272. { AtCommand_Item, "@item", 60, atcommand_item },
  273. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  274. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  275. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  276. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  277. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  278. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  279. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  280. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  281. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  282. { AtCommand_H, "@h", 20, atcommand_help },
  283. { AtCommand_Help, "@help", 20, atcommand_help },
  284. { AtCommand_GM, "@gm", 100, atcommand_gm },
  285. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  286. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  287. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  288. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  289. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  290. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  291. { AtCommand_Model, "@model", 20, atcommand_model },
  292. { AtCommand_Go, "@go", 10, atcommand_go },
  293. { AtCommand_Spawn, "@monster", 50, atcommand_spawn },
  294. { AtCommand_Spawn, "@spawn", 50, atcommand_spawn },
  295. // { AtCommand_Spawn, "@summon", 50, atcommand_spawn },
  296. { AtCommand_Monster, "@monster2", 50, atcommand_monster },
  297. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  298. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  299. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  300. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  301. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  302. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  303. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  304. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  305. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  306. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  307. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  308. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  309. { AtCommand_Strength, "@str", 60, atcommand_param },
  310. { AtCommand_Agility, "@agi", 60, atcommand_param },
  311. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  312. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  313. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  314. { AtCommand_Luck, "@luk", 60, atcommand_param },
  315. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  316. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  317. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  318. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  319. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  320. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  321. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  322. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  323. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  324. { AtCommand_Night, "@night", 80, atcommand_night },
  325. { AtCommand_Day, "@day", 80, atcommand_day },
  326. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  327. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  328. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  329. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  330. { AtCommand_CharacterBaseLevel, "@charbaselvl", 60, atcommand_character_baselevel },
  331. { AtCommand_CharacterJobLevel, "@charjlvl", 60, atcommand_character_joblevel },
  332. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  333. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  334. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  335. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  336. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  337. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  338. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  339. { AtCommand_CharQuestSkill, "@charquestskill", 60, atcommand_charquestskill },
  340. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  341. { AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill },
  342. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  343. { AtCommand_Party, "@party", 1, atcommand_party },
  344. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  345. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  346. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  347. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  348. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  349. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  350. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  351. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  352. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  353. { AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset },
  354. { AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset },
  355. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  356. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  357. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  358. #ifndef TXT_ONLY
  359. { AtCommand_Rehash, "@rehash", 99, atcommand_rehash }, // admin command
  360. #else /* TXT_ONLY */
  361. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  362. #endif /* TXT_ONLY */
  363. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  364. { AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel },
  365. { AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint },
  366. { AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint },
  367. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  368. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  369. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  370. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  371. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  372. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  373. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  374. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  375. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  376. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  377. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  378. { AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex }, // by Yor
  379. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  380. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  381. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  382. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  383. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  384. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  385. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  386. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  387. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  388. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  389. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  390. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  391. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  392. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  393. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  394. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  395. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  396. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  397. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  398. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  399. { AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc }, // []
  400. { AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // []
  401. { AtCommand_ServerTime, "@time", 0, atcommand_servertime }, // by Yor
  402. { AtCommand_ServerTime, "@date", 0, atcommand_servertime }, // by Yor
  403. { AtCommand_ServerTime, "@server_date", 0, atcommand_servertime }, // by Yor
  404. { AtCommand_ServerTime, "@serverdate", 0, atcommand_servertime }, // by Yor
  405. { AtCommand_ServerTime, "@server_time", 0, atcommand_servertime }, // by Yor
  406. { AtCommand_ServerTime, "@servertime", 0, atcommand_servertime }, // by Yor
  407. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  408. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  409. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  410. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  411. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  412. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  413. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  414. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  415. { AtCommand_EMail, "@email", 0, atcommand_email }, // by Yor
  416. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  417. // { AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list }, // by Yor, now #itemlist
  418. // { AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list }, // by Yor, now #storagelist
  419. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  420. { AtCommand_Follow, "@follow", 10, atcommand_follow }, // by MouseJstr
  421. { AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp }, // by MouseJstr
  422. { AtCommand_SkillOn, "@skillon", 20, atcommand_skillon }, // by MouseJstr
  423. { AtCommand_SkillOff, "@skilloff", 20, atcommand_skilloff }, // by MouseJstr
  424. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  425. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  426. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  427. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  428. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  429. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  430. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  431. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  432. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  433. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  434. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  435. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  436. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  437. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  438. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  439. /*
  440. { AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle },
  441. { AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance },
  442. { AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect },
  443. */
  444. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  445. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  446. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  447. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  448. { AtCommand_Send, "@send", 60, atcommand_send },
  449. { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag },
  450. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  451. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  452. { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri
  453. { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri
  454. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  455. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  456. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  457. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy",40, atcommand_happyhappyjoyjoy }, // [Valaris]
  458. { AtCommand_Refresh, "@refresh", 0, atcommand_refresh }, // by MC Cameri
  459. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  460. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  461. { AtCommand_Gmotd, "@gmotd", 0, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  462. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  463. #ifndef TXT_ONLY // sql-only commands
  464. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  465. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  466. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  467. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  468. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  469. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  470. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  471. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  472. #endif /* TXT_ONLY */
  473. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  474. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  475. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  476. { AtCommand_Rings, "@rings", 40, atcommand_rings }, // [MouseJstr]
  477. { AtCommand_Grind, "@grind", 40, atcommand_grind }, // [MouseJstr]
  478. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  479. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  480. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  481. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  482. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  483. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  484. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  485. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  486. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  487. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  488. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  489. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  490. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  491. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  492. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  493. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  494. // add new commands before this line
  495. { AtCommand_Unknown, NULL, 1, NULL }
  496. };
  497. /*====================================================
  498. * This function return the name of the job (by [Yor])
  499. *----------------------------------------------------
  500. */
  501. char * job_name(int class) {
  502. switch (class) {
  503. case 0: return "Novice";
  504. case 1: return "Swordsman";
  505. case 2: return "Mage";
  506. case 3: return "Archer";
  507. case 4: return "Acolyte";
  508. case 5: return "Merchant";
  509. case 6: return "Thief";
  510. case 7: return "Knight";
  511. case 8: return "Priest";
  512. case 9: return "Wizard";
  513. case 10: return "Blacksmith";
  514. case 11: return "Hunter";
  515. case 12: return "Assassin";
  516. case 13: return "Knight 2";
  517. case 14: return "Crusader";
  518. case 15: return "Monk";
  519. case 16: return "Sage";
  520. case 17: return "Rogue";
  521. case 18: return "Alchemist";
  522. case 19: return "Bard";
  523. case 20: return "Dancer";
  524. case 21: return "Crusader 2";
  525. case 22: return "Wedding";
  526. case 23: return "Super Novice";
  527. case 4001: return "Novice High";
  528. case 4002: return "Swordsman High";
  529. case 4003: return "Mage High";
  530. case 4004: return "Archer High";
  531. case 4005: return "Acolyte High";
  532. case 4006: return "Merchant High";
  533. case 4007: return "Thief High";
  534. case 4008: return "Lord Knight";
  535. case 4009: return "High Priest";
  536. case 4010: return "High Wizard";
  537. case 4011: return "Whitesmith";
  538. case 4012: return "Sniper";
  539. case 4013: return "Assassin Cross";
  540. case 4014: return "Peko Knight";
  541. case 4015: return "Paladin";
  542. case 4016: return "Champion";
  543. case 4017: return "Professor";
  544. case 4018: return "Stalker";
  545. case 4019: return "Creator";
  546. case 4020: return "Clown";
  547. case 4021: return "Gypsy";
  548. case 4022: return "Peko Paladin";
  549. case 4023: return "Baby Novice";
  550. case 4024: return "Baby Swordsman";
  551. case 4025: return "Baby Mage";
  552. case 4026: return "Baby Archer";
  553. case 4027: return "Baby Acolyte";
  554. case 4028: return "Baby Merchant";
  555. case 4029: return "Baby Thief";
  556. case 4030: return "Baby Knight";
  557. case 4031: return "Baby Priest";
  558. case 4032: return "Baby Wizard";
  559. case 4033: return "Baby Blacksmith";
  560. case 4034: return "Baby Hunter";
  561. case 4035: return "Baby Assassin";
  562. case 4036: return "Baby Peco Knight";
  563. case 4037: return "Baby Crusader";
  564. case 4038: return "Baby Monk";
  565. case 4039: return "Baby Sage";
  566. case 4040: return "Baby Rogue";
  567. case 4041: return "Baby Alchemist";
  568. case 4042: return "Baby Bard";
  569. case 4043: return "Baby Dancer";
  570. case 4044: return "Baby Peco Crusader";
  571. case 4045: return "Super Baby";
  572. }
  573. return "Unknown Job";
  574. }
  575. /*==========================================
  576. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  577. *------------------------------------------
  578. */
  579. char *estr_lower(char *str)
  580. {
  581. int i;
  582. for (i=0; str[i]; i++)
  583. if ((str[i] >= 65) && (str[i] <= 90))
  584. str[i] += 32;
  585. return str;
  586. }
  587. // compare function for sorting high to lowest
  588. int hightolow_compare (const void * a, const void * b)
  589. {
  590. return ( *(int*)b - *(int*)a );
  591. }
  592. // compare function for sorting lowest to highest
  593. int lowtohigh_compare (const void * a, const void * b)
  594. {
  595. return ( *(int*)a - *(int*)b );
  596. }
  597. //-----------------------------------------------------------
  598. // Return the message string of the specified number by [Yor]
  599. //-----------------------------------------------------------
  600. char * msg_txt(int msg_number) {
  601. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])) &&
  602. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  603. return msg_table[msg_number];
  604. return "??";
  605. }
  606. //------------------------------------------------------------
  607. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  608. //------------------------------------------------------------
  609. int e_mail_check(unsigned char *email) {
  610. char ch;
  611. unsigned char* last_arobas;
  612. // athena limits
  613. if (strlen(email) < 3 || strlen(email) > 39)
  614. return 0;
  615. // part of RFC limits (official reference of e-mail description)
  616. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  617. return 0;
  618. if (email[strlen(email)-1] == '.')
  619. return 0;
  620. last_arobas = strrchr(email, '@');
  621. if (strstr(last_arobas, "@.") != NULL ||
  622. strstr(last_arobas, "..") != NULL)
  623. return 0;
  624. for(ch = 1; ch < 32; ch++) {
  625. if (strchr(last_arobas, ch) != NULL) {
  626. return 0;
  627. break;
  628. }
  629. }
  630. if (strchr(last_arobas, ' ') != NULL ||
  631. strchr(last_arobas, ';') != NULL)
  632. return 0;
  633. // all correct
  634. return 1;
  635. }
  636. /*==========================================
  637. * get_atcommand_level @コマンドの必要レベルを取得
  638. *------------------------------------------
  639. */
  640. int get_atcommand_level(const AtCommandType type) {
  641. int i;
  642. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  643. if (atcommand_info[i].type == type)
  644. return atcommand_info[i].level;
  645. return 100; // 100: command can not be used
  646. }
  647. /*==========================================
  648. *is_atcommand @コマンドに存在するかどうか確認する
  649. *------------------------------------------
  650. */
  651. AtCommandType
  652. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  653. const char* str = message;
  654. int s_flag = 0;
  655. AtCommandInfo info;
  656. AtCommandType type;
  657. nullpo_retr(AtCommand_None, sd);
  658. if (!battle_config.allow_atcommand_when_mute &&
  659. sd->sc_count && sd->sc_data[SC_NOCHAT].timer != -1) {
  660. return AtCommand_Unknown;
  661. }
  662. if (!message || !*message)
  663. return AtCommand_None;
  664. memset(&info, 0, sizeof(info));
  665. str += strlen(sd->status.name);
  666. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  667. if (*str == ':')
  668. s_flag = 1;
  669. str++;
  670. }
  671. if (!*str)
  672. return AtCommand_None;
  673. type = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  674. if (type != AtCommand_None) {
  675. char command[100];
  676. char output[200];
  677. const char* p = str;
  678. memset(command, '\0', sizeof(command));
  679. memset(output, '\0', sizeof(output));
  680. while (*p && !isspace(*p))
  681. p++;
  682. if (p - str >= sizeof(command)) // too long
  683. return AtCommand_Unknown;
  684. strncpy(command, str, p - str);
  685. while (isspace(*p))
  686. p++;
  687. if (type == AtCommand_Unknown || info.proc == NULL) {
  688. sprintf(output, msg_table[153], command); // %s is Unknown Command.
  689. clif_displaymessage(fd, output);
  690. } else {
  691. if (info.proc(fd, sd, command, p) != 0) {
  692. // Command can not be executed
  693. sprintf(output, msg_table[154], command); // %s failed.
  694. clif_displaymessage(fd, output);
  695. }
  696. }
  697. // ToDo: Fix Logs :)
  698. //if((log_config.gm) && (info.level >= log_config.gm))
  699. // log_atcommand(sd, message);
  700. return info.type;
  701. }
  702. return AtCommand_None;
  703. }
  704. /*==========================================
  705. *
  706. *------------------------------------------
  707. */
  708. AtCommandType atcommand(const int level, const char* message, struct AtCommandInfo* info) {
  709. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  710. if (!info)
  711. return AtCommand_None;
  712. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  713. return AtCommand_None;
  714. if (!p || !*p) {
  715. fprintf(stderr, "at command message is empty\n");
  716. return AtCommand_None;
  717. }
  718. if (*p == command_symbol) { // check first char.
  719. char command[101];
  720. int i = 0;
  721. memset(info, 0, sizeof(AtCommandInfo));
  722. sscanf(p, "%100s", command);
  723. command[sizeof(command)-1] = '\0';
  724. while (atcommand_info[i].type != AtCommand_Unknown) {
  725. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  726. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  727. break;
  728. }
  729. i++;
  730. }
  731. if (atcommand_info[i].type == AtCommand_Unknown) {
  732. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  733. if (level == 0)
  734. return AtCommand_None;
  735. else
  736. return AtCommand_Unknown;
  737. }
  738. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  739. } else {
  740. return AtCommand_None;
  741. }
  742. return info->type;
  743. }
  744. /*==========================================
  745. *
  746. *------------------------------------------
  747. */
  748. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  749. int flag = va_arg(ap, int);
  750. nullpo_retr(0, bl);
  751. if (flag)
  752. mob_damage(NULL, (struct mob_data *)bl, ((struct mob_data *)bl)->hp, 2);
  753. else
  754. mob_delete((struct mob_data *)bl);
  755. return 0;
  756. }
  757. #ifndef TXT_ONLY
  758. static int atkillnpc_sub(struct block_list *bl, va_list ap)
  759. {
  760. int flag = va_arg(ap,int);
  761. nullpo_retr(0, bl);
  762. npc_delete((struct npc_data *)bl);
  763. flag = 0;
  764. return 0;
  765. }
  766. void rehash( const int fd, struct map_session_data* sd )
  767. {
  768. int map_id = 0;
  769. int LOADED_MAPS = map_num;
  770. for (map_id = 0; map_id < LOADED_MAPS;map_id++) {
  771. if (map_id > LOADED_MAPS)
  772. break;
  773. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, 0);
  774. map_foreachinarea(atkillnpc_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_NPC, 0);
  775. }
  776. }
  777. #endif /* not TXT_ONLY */
  778. /*==========================================
  779. * Read Message Data
  780. *------------------------------------------
  781. */
  782. int msg_config_read(const char *cfgName) {
  783. int msg_number;
  784. char line[1024], w1[1024], w2[1024];
  785. FILE *fp;
  786. if ((fp = fopen(cfgName, "r")) == NULL) {
  787. printf("Messages file not found: %s\n", cfgName);
  788. return 1;
  789. }
  790. while(fgets(line, sizeof(line)-1, fp)) {
  791. if (line[0] == '/' && line[1] == '/')
  792. continue;
  793. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  794. if (strcmpi(w1, "import") == 0) {
  795. msg_config_read(w2);
  796. } else {
  797. msg_number = atoi(w1);
  798. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])))
  799. strcpy(msg_table[msg_number], w2);
  800. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  801. }
  802. }
  803. }
  804. fclose(fp);
  805. return 0;
  806. }
  807. /*==========================================
  808. *
  809. *------------------------------------------
  810. */
  811. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  812. int i;
  813. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  814. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  815. return &atcommand_info[i];
  816. return NULL;
  817. }
  818. /*==========================================
  819. *
  820. *------------------------------------------
  821. */
  822. int atcommand_config_read(const char *cfgName) {
  823. char line[1024], w1[1024], w2[1024];
  824. AtCommandInfo* p;
  825. FILE* fp;
  826. if ((fp = fopen(cfgName, "r")) == NULL) {
  827. printf("At commands configuration file not found: %s\n", cfgName);
  828. return 1;
  829. }
  830. while (fgets(line, sizeof(line)-1, fp)) {
  831. if (line[0] == '/' && line[1] == '/')
  832. continue;
  833. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  834. continue;
  835. p = get_atcommandinfo_byname(w1);
  836. if (p != NULL) {
  837. p->level = atoi(w2);
  838. if (p->level > 100)
  839. p->level = 100;
  840. else if (p->level < 0)
  841. p->level = 0;
  842. }
  843. if (strcmpi(w1, "import") == 0)
  844. atcommand_config_read(w2);
  845. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  846. w2[0] != '/' && // symbol of standard ragnarok GM commands
  847. w2[0] != '%' && // symbol of party chat speaking
  848. w2[0] != '#') // symbol of charcommand
  849. command_symbol = w2[0];
  850. }
  851. fclose(fp);
  852. return 0;
  853. }
  854. /*==========================================
  855. // @ command processing functions
  856. *------------------------------------------
  857. */
  858. /*==========================================
  859. * @send (used for testing packet sends from the client)
  860. *------------------------------------------
  861. */
  862. int atcommand_send(
  863. const int fd, struct map_session_data* sd,
  864. const char* command, const char* message)
  865. {
  866. int a = atoi(message);
  867. if (a)
  868. {
  869. unsigned char buf[1024];
  870. switch(a)
  871. {
  872. case 1:
  873. WBUFW(buf,0)=0x18d;
  874. case 2:
  875. WBUFW(buf,0)=0x18e;
  876. case 3:
  877. WBUFW(buf,0)=0x18f;
  878. case 4:
  879. WBUFW(buf,0)=0x190;
  880. }
  881. }
  882. return 0;
  883. }
  884. // @rura
  885. /*==========================================
  886. *
  887. *------------------------------------------
  888. */
  889. int atcommand_rura(
  890. const int fd, struct map_session_data* sd,
  891. const char* command, const char* message)
  892. {
  893. char map_name[100];
  894. int x = 0, y = 0;
  895. int m;
  896. nullpo_retr(-1, sd);
  897. memset(map_name, '\0', sizeof(map_name));
  898. if (!message || !*message || sscanf(message, "%99s %d %d", map_name, &x, &y) < 1) {
  899. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  900. return -1;
  901. }
  902. if (x <= 0)
  903. x = rand() % 399 + 1;
  904. if (y <= 0)
  905. y = rand() % 399 + 1;
  906. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  907. strcat(map_name, ".gat");
  908. if (x > 0 && x < 400 && y > 0 && y < 400) {
  909. m = map_mapname2mapid(map_name);
  910. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  911. clif_displaymessage(fd, "You are not authorised to warp you to this map.");
  912. return -1;
  913. }
  914. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  915. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  916. return -1;
  917. }
  918. if (pc_setpos(sd, map_name, x, y, 3) == 0)
  919. clif_displaymessage(fd, msg_table[0]); // Warped.
  920. else {
  921. clif_displaymessage(fd, msg_table[1]); // Map not found.
  922. return -1;
  923. }
  924. } else {
  925. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  926. return -1;
  927. }
  928. return 0;
  929. }
  930. /*==========================================
  931. *
  932. *------------------------------------------
  933. */
  934. int atcommand_where(
  935. const int fd, struct map_session_data* sd,
  936. const char* command, const char* message)
  937. {
  938. char character[100];
  939. char output[200];
  940. struct map_session_data *pl_sd = NULL;
  941. nullpo_retr(-1, sd);
  942. if (!message || !*message)
  943. return -1;
  944. memset(character, '\0', sizeof character);
  945. if (sscanf(message, "%99[^\n]", character) < 1)
  946. return -1;
  947. if(strncmp(sd->status.name,character,24)==0)
  948. return -1;
  949. if ((pl_sd = map_nick2sd(character)) == NULL) {
  950. snprintf(output, sizeof output, "%s %d %d",
  951. sd->mapname, sd->bl.x, sd->bl.y);
  952. clif_displaymessage(fd, output);
  953. return -1;
  954. }
  955. snprintf(output, sizeof output, "%s %s %d %d",
  956. character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  957. clif_displaymessage(fd, output);
  958. return 0;
  959. }
  960. /*==========================================
  961. *
  962. *------------------------------------------
  963. */
  964. int atcommand_jumpto(
  965. const int fd, struct map_session_data* sd,
  966. const char* command, const char* message)
  967. {
  968. char character[100];
  969. char output[200];
  970. struct map_session_data *pl_sd = NULL;
  971. nullpo_retr(-1, sd);
  972. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  973. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  974. return -1;
  975. }
  976. memset(character, '\0', sizeof character);
  977. if (sscanf(message, "%99[^\n]", character) < 1)
  978. return -1;
  979. if(strncmp(sd->status.name,character,24)==0) //Yourself mate? Tsk tsk tsk.
  980. return -1;
  981. if ((pl_sd = map_nick2sd(character)) != NULL) {
  982. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  983. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  984. return -1;
  985. }
  986. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  987. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  988. return -1;
  989. }
  990. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  991. sprintf(output, msg_table[4], character); // Jump to %s
  992. clif_displaymessage(fd, output);
  993. } else {
  994. clif_displaymessage(fd, msg_table[3]); // Character not found.
  995. return -1;
  996. }
  997. return 0;
  998. }
  999. /*==========================================
  1000. *
  1001. *------------------------------------------
  1002. */
  1003. int atcommand_jump(
  1004. const int fd, struct map_session_data* sd,
  1005. const char* command, const char* message)
  1006. {
  1007. char output[200];
  1008. int x = 0, y = 0;
  1009. nullpo_retr(-1, sd);
  1010. memset(output, '\0', sizeof(output));
  1011. sscanf(message, "%d %d", &x, &y);
  1012. if (x <= 0)
  1013. x = rand() % 399 + 1;
  1014. if (y <= 0)
  1015. y = rand() % 399 + 1;
  1016. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1017. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1018. clif_displaymessage(fd, "You are not authorised to warp you to your actual map.");
  1019. return -1;
  1020. }
  1021. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1022. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1023. return -1;
  1024. }
  1025. pc_setpos(sd, sd->mapname, x, y, 3);
  1026. sprintf(output, msg_table[5], x, y); // Jump to %d %d
  1027. clif_displaymessage(fd, output);
  1028. } else {
  1029. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1030. return -1;
  1031. }
  1032. return 0;
  1033. }
  1034. /*==========================================
  1035. *
  1036. *------------------------------------------
  1037. */
  1038. int atcommand_who(
  1039. const int fd, struct map_session_data* sd,
  1040. const char* command, const char* message)
  1041. {
  1042. char output[200];
  1043. struct map_session_data *pl_sd;
  1044. int i, j, count;
  1045. int pl_GM_level, GM_level;
  1046. char match_text[100];
  1047. char player_name[24];
  1048. nullpo_retr(-1, sd);
  1049. memset(output, '\0', sizeof(output));
  1050. memset(match_text, '\0', sizeof(match_text));
  1051. memset(player_name, '\0', sizeof(player_name));
  1052. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1053. strcpy(match_text, "");
  1054. for (j = 0; match_text[j]; j++)
  1055. match_text[j] = tolower(match_text[j]);
  1056. count = 0;
  1057. GM_level = pc_isGM(sd);
  1058. for (i = 0; i < fd_max; i++) {
  1059. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1060. pl_GM_level = pc_isGM(pl_sd);
  1061. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1062. memcpy(player_name, pl_sd->status.name, 24);
  1063. for (j = 0; player_name[j]; j++)
  1064. player_name[j] = tolower(player_name[j]);
  1065. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1066. if (pl_GM_level > 0)
  1067. sprintf(output, "(CID:%d/AID:%d) Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.char_id, pl_sd->status.account_id, pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1068. else
  1069. sprintf(output, "(CID:%d/AID:%d) Name: %s | Location: %s %d %d", pl_sd->status.char_id, pl_sd->status.account_id, pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1070. clif_displaymessage(fd, output);
  1071. count++;
  1072. }
  1073. }
  1074. }
  1075. }
  1076. if (count == 0)
  1077. clif_displaymessage(fd, msg_table[28]); // No player found.
  1078. else if (count == 1)
  1079. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1080. else {
  1081. sprintf(output, msg_table[30], count); // %d players found.
  1082. clif_displaymessage(fd, output);
  1083. }
  1084. return 0;
  1085. }
  1086. /*==========================================
  1087. *
  1088. *------------------------------------------
  1089. */
  1090. int atcommand_who2(
  1091. const int fd, struct map_session_data* sd,
  1092. const char* command, const char* message)
  1093. {
  1094. char output[200];
  1095. struct map_session_data *pl_sd;
  1096. int i, j, count;
  1097. int pl_GM_level, GM_level;
  1098. char match_text[100];
  1099. char player_name[24];
  1100. nullpo_retr(-1, sd);
  1101. memset(output, '\0', sizeof(output));
  1102. memset(match_text, '\0', sizeof(match_text));
  1103. memset(player_name, '\0', sizeof(player_name));
  1104. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1105. strcpy(match_text, "");
  1106. for (j = 0; match_text[j]; j++)
  1107. match_text[j] = tolower(match_text[j]);
  1108. count = 0;
  1109. GM_level = pc_isGM(sd);
  1110. for (i = 0; i < fd_max; i++) {
  1111. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1112. pl_GM_level = pc_isGM(pl_sd);
  1113. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1114. memcpy(player_name, pl_sd->status.name, 24);
  1115. for (j = 0; player_name[j]; j++)
  1116. player_name[j] = tolower(player_name[j]);
  1117. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1118. if (pl_GM_level > 0)
  1119. sprintf(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);
  1120. else
  1121. sprintf(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);
  1122. clif_displaymessage(fd, output);
  1123. count++;
  1124. }
  1125. }
  1126. }
  1127. }
  1128. if (count == 0)
  1129. clif_displaymessage(fd, msg_table[28]); // No player found.
  1130. else if (count == 1)
  1131. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1132. else {
  1133. sprintf(output, msg_table[30], count); // %d players found.
  1134. clif_displaymessage(fd, output);
  1135. }
  1136. return 0;
  1137. }
  1138. /*==========================================
  1139. *
  1140. *------------------------------------------
  1141. */
  1142. int atcommand_who3(
  1143. const int fd, struct map_session_data* sd,
  1144. const char* command, const char* message)
  1145. {
  1146. char temp0[100];
  1147. char temp1[100];
  1148. char output[200];
  1149. struct map_session_data *pl_sd;
  1150. int i, j, count;
  1151. int pl_GM_level, GM_level;
  1152. char match_text[100];
  1153. char player_name[24];
  1154. struct guild *g;
  1155. struct party *p;
  1156. nullpo_retr(-1, sd);
  1157. memset(temp0, '\0', sizeof(temp0));
  1158. memset(temp1, '\0', sizeof(temp1));
  1159. memset(output, '\0', sizeof(output));
  1160. memset(match_text, '\0', sizeof(match_text));
  1161. memset(player_name, '\0', sizeof(player_name));
  1162. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1163. strcpy(match_text, "");
  1164. for (j = 0; match_text[j]; j++)
  1165. match_text[j] = tolower(match_text[j]);
  1166. count = 0;
  1167. GM_level = pc_isGM(sd);
  1168. for (i = 0; i < fd_max; i++) {
  1169. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1170. pl_GM_level = pc_isGM(pl_sd);
  1171. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1172. memcpy(player_name, pl_sd->status.name, 24);
  1173. for (j = 0; player_name[j]; j++)
  1174. player_name[j] = tolower(player_name[j]);
  1175. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1176. g = guild_search(pl_sd->status.guild_id);
  1177. if (g == NULL)
  1178. sprintf(temp1, "None");
  1179. else
  1180. sprintf(temp1, "%s", g->name);
  1181. p = party_search(pl_sd->status.party_id);
  1182. if (p == NULL)
  1183. sprintf(temp0, "None");
  1184. else
  1185. sprintf(temp0, "%s", p->name);
  1186. if (pl_GM_level > 0)
  1187. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1188. else
  1189. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1190. clif_displaymessage(fd, output);
  1191. count++;
  1192. }
  1193. }
  1194. }
  1195. }
  1196. if (count == 0)
  1197. clif_displaymessage(fd, msg_table[28]); // No player found.
  1198. else if (count == 1)
  1199. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1200. else {
  1201. sprintf(output, msg_table[30], count); // %d players found.
  1202. clif_displaymessage(fd, output);
  1203. }
  1204. return 0;
  1205. }
  1206. /*==========================================
  1207. *
  1208. *------------------------------------------
  1209. */
  1210. int atcommand_whomap(
  1211. const int fd, struct map_session_data* sd,
  1212. const char* command, const char* message)
  1213. {
  1214. char output[200];
  1215. struct map_session_data *pl_sd;
  1216. int i, count;
  1217. int pl_GM_level, GM_level;
  1218. int map_id;
  1219. char map_name[100];
  1220. memset(output, '\0', sizeof(output));
  1221. memset(map_name, '\0', sizeof(map_name));
  1222. if (!message || !*message)
  1223. map_id = sd->bl.m;
  1224. else {
  1225. sscanf(message, "%99s", map_name);
  1226. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1227. strcat(map_name, ".gat");
  1228. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1229. map_id = sd->bl.m;
  1230. }
  1231. count = 0;
  1232. GM_level = pc_isGM(sd);
  1233. for (i = 0; i < fd_max; i++) {
  1234. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1235. pl_GM_level = pc_isGM(pl_sd);
  1236. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1237. if (pl_sd->bl.m == map_id) {
  1238. if (pl_GM_level > 0)
  1239. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1240. else
  1241. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1242. clif_displaymessage(fd, output);
  1243. count++;
  1244. }
  1245. }
  1246. }
  1247. }
  1248. if (count == 0)
  1249. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1250. else if (count == 1)
  1251. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1252. else {
  1253. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1254. }
  1255. clif_displaymessage(fd, output);
  1256. return 0;
  1257. }
  1258. /*==========================================
  1259. *
  1260. *------------------------------------------
  1261. */
  1262. int atcommand_whomap2(
  1263. const int fd, struct map_session_data* sd,
  1264. const char* command, const char* message)
  1265. {
  1266. char output[200];
  1267. struct map_session_data *pl_sd;
  1268. int i, count;
  1269. int pl_GM_level, GM_level;
  1270. int map_id = 0;
  1271. char map_name[100];
  1272. nullpo_retr(-1, sd);
  1273. memset(output, '\0', sizeof(output));
  1274. memset(map_name, '\0', sizeof(map_name));
  1275. if (!message || !*message)
  1276. map_id = sd->bl.m;
  1277. else {
  1278. sscanf(message, "%99s", map_name);
  1279. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1280. strcat(map_name, ".gat");
  1281. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1282. map_id = sd->bl.m;
  1283. }
  1284. count = 0;
  1285. GM_level = pc_isGM(sd);
  1286. for (i = 0; i < fd_max; i++) {
  1287. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1288. pl_GM_level = pc_isGM(pl_sd);
  1289. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1290. if (pl_sd->bl.m == map_id) {
  1291. if (pl_GM_level > 0)
  1292. sprintf(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);
  1293. else
  1294. sprintf(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);
  1295. clif_displaymessage(fd, output);
  1296. count++;
  1297. }
  1298. }
  1299. }
  1300. }
  1301. if (count == 0)
  1302. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1303. else if (count == 1)
  1304. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1305. else {
  1306. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1307. }
  1308. clif_displaymessage(fd, output);
  1309. return 0;
  1310. }
  1311. /*==========================================
  1312. *
  1313. *------------------------------------------
  1314. */
  1315. int atcommand_whomap3(
  1316. const int fd, struct map_session_data* sd,
  1317. const char* command, const char* message)
  1318. {
  1319. char temp0[100];
  1320. char temp1[100];
  1321. char output[200];
  1322. struct map_session_data *pl_sd;
  1323. int i, count;
  1324. int pl_GM_level, GM_level;
  1325. int map_id = 0;
  1326. char map_name[100];
  1327. struct guild *g;
  1328. struct party *p;
  1329. nullpo_retr(-1, sd);
  1330. memset(temp0, '\0', sizeof(temp0));
  1331. memset(temp1, '\0', sizeof(temp1));
  1332. memset(output, '\0', sizeof(output));
  1333. memset(map_name, '\0', sizeof(map_name));
  1334. if (!message || !*message)
  1335. map_id = sd->bl.m;
  1336. else {
  1337. sscanf(message, "%99s", map_name);
  1338. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1339. strcat(map_name, ".gat");
  1340. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1341. map_id = sd->bl.m;
  1342. }
  1343. count = 0;
  1344. GM_level = pc_isGM(sd);
  1345. for (i = 0; i < fd_max; i++) {
  1346. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1347. pl_GM_level = pc_isGM(pl_sd);
  1348. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1349. if (pl_sd->bl.m == map_id) {
  1350. g = guild_search(pl_sd->status.guild_id);
  1351. if (g == NULL)
  1352. sprintf(temp1, "None");
  1353. else
  1354. sprintf(temp1, "%s", g->name);
  1355. p = party_search(pl_sd->status.party_id);
  1356. if (p == NULL)
  1357. sprintf(temp0, "None");
  1358. else
  1359. sprintf(temp0, "%s", p->name);
  1360. if (pl_GM_level > 0)
  1361. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1362. else
  1363. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1364. clif_displaymessage(fd, output);
  1365. count++;
  1366. }
  1367. }
  1368. }
  1369. }
  1370. if (count == 0)
  1371. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1372. else if (count == 1)
  1373. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1374. else {
  1375. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1376. }
  1377. clif_displaymessage(fd, output);
  1378. return 0;
  1379. }
  1380. /*==========================================
  1381. *
  1382. *------------------------------------------
  1383. */
  1384. int atcommand_whogm(
  1385. const int fd, struct map_session_data* sd,
  1386. const char* command, const char* message)
  1387. {
  1388. char temp0[100];
  1389. char temp1[100];
  1390. char output[200];
  1391. struct map_session_data *pl_sd;
  1392. int i, j, count;
  1393. int pl_GM_level, GM_level;
  1394. char match_text[100];
  1395. char player_name[24];
  1396. struct guild *g;
  1397. struct party *p;
  1398. nullpo_retr(-1, sd);
  1399. memset(temp0, '\0', sizeof(temp0));
  1400. memset(temp1, '\0', sizeof(temp1));
  1401. memset(output, '\0', sizeof(output));
  1402. memset(match_text, '\0', sizeof(match_text));
  1403. memset(player_name, '\0', sizeof(player_name));
  1404. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1405. strcpy(match_text, "");
  1406. for (j = 0; match_text[j]; j++)
  1407. match_text[j] = tolower(match_text[j]);
  1408. count = 0;
  1409. GM_level = pc_isGM(sd);
  1410. for (i = 0; i < fd_max; i++) {
  1411. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1412. pl_GM_level = pc_isGM(pl_sd);
  1413. if (pl_GM_level > 0) {
  1414. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1415. memcpy(player_name, pl_sd->status.name, 24);
  1416. for (j = 0; player_name[j]; j++)
  1417. player_name[j] = tolower(player_name[j]);
  1418. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1419. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1420. clif_displaymessage(fd, output);
  1421. sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level);
  1422. clif_displaymessage(fd, output);
  1423. g = guild_search(pl_sd->status.guild_id);
  1424. if (g == NULL)
  1425. sprintf(temp1, "None");
  1426. else
  1427. sprintf(temp1, "%s", g->name);
  1428. p = party_search(pl_sd->status.party_id);
  1429. if (p == NULL)
  1430. sprintf(temp0, "None");
  1431. else
  1432. sprintf(temp0, "%s", p->name);
  1433. sprintf(output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1434. clif_displaymessage(fd, output);
  1435. count++;
  1436. }
  1437. }
  1438. }
  1439. }
  1440. }
  1441. if (count == 0)
  1442. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1443. else if (count == 1)
  1444. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1445. else {
  1446. sprintf(output, msg_table[152], count); // %d GMs found.
  1447. clif_displaymessage(fd, output);
  1448. }
  1449. return 0;
  1450. }
  1451. int atcommand_whozeny(
  1452. const int fd, struct map_session_data* sd,
  1453. const char* command, const char* message)
  1454. {
  1455. char output[200];
  1456. struct map_session_data *pl_sd;
  1457. int i, j, count,c;
  1458. char match_text[100];
  1459. char player_name[24];
  1460. int zeny[clif_countusers()];
  1461. int counted[clif_countusers()];
  1462. nullpo_retr(-1, sd);
  1463. memset(output, '\0', sizeof(output));
  1464. memset(match_text, '\0', sizeof(match_text));
  1465. memset(player_name, '\0', sizeof(player_name));
  1466. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1467. strcpy(match_text, "");
  1468. for (j = 0; match_text[j]; j++)
  1469. match_text[j] = tolower(match_text[j]);
  1470. count = 0;
  1471. for (i = 0; i < fd_max; i++) {
  1472. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1473. memcpy(player_name, pl_sd->status.name, 24);
  1474. for (j = 0; player_name[j]; j++)
  1475. player_name[j] = tolower(player_name[j]);
  1476. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1477. zeny[count]=pl_sd->status.zeny;
  1478. counted[i]=0;
  1479. count++;
  1480. }
  1481. }
  1482. }
  1483. qsort(zeny, count, sizeof(int), hightolow_compare);
  1484. for (c = 0; c < count && c < 50; c++) {
  1485. if(!zeny[c])
  1486. continue;
  1487. for (i = 0; i < fd_max; i++) {
  1488. if(!zeny[c])
  1489. continue;
  1490. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && zeny[c] && counted[i]==0) {
  1491. if(pl_sd->status.zeny==zeny[c]) {
  1492. sprintf(output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1493. clif_displaymessage(fd, output);
  1494. zeny[c]=0;
  1495. counted[i]=1;
  1496. }
  1497. }
  1498. }
  1499. }
  1500. if (count == 0)
  1501. clif_displaymessage(fd, msg_table[28]); // No player found.
  1502. else if (count == 1)
  1503. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1504. else {
  1505. sprintf(output, msg_table[30], count); // %d players found.
  1506. clif_displaymessage(fd, output);
  1507. }
  1508. return 0;
  1509. }
  1510. // cause random emote on all online players [Valaris]
  1511. int atcommand_happyhappyjoyjoy(
  1512. const int fd, struct map_session_data* sd,
  1513. const char* command, const char* message)
  1514. {
  1515. struct map_session_data *pl_sd;
  1516. int i,e;
  1517. nullpo_retr(-1, sd);
  1518. for (i = 0; i < fd_max; i++) {
  1519. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1520. e=rand()%40;
  1521. if(e==34)
  1522. e = 0;
  1523. clif_emotion(&pl_sd->bl,e);
  1524. }
  1525. }
  1526. return 0;
  1527. }
  1528. /*==========================================
  1529. *
  1530. *------------------------------------------
  1531. */
  1532. int atcommand_save(
  1533. const int fd, struct map_session_data* sd,
  1534. const char* command, const char* message)
  1535. {
  1536. nullpo_retr(-1, sd);
  1537. pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y);
  1538. if (sd->status.pet_id > 0 && sd->pd)
  1539. intif_save_petdata(sd->status.account_id, &sd->pet);
  1540. pc_makesavestatus(sd);
  1541. chrif_save(sd);
  1542. storage_storage_save(sd);
  1543. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1544. return 0;
  1545. }
  1546. /*==========================================
  1547. *
  1548. *------------------------------------------
  1549. */
  1550. int atcommand_load(
  1551. const int fd, struct map_session_data* sd,
  1552. const char* command, const char* message)
  1553. {
  1554. int m;
  1555. nullpo_retr(-1, sd);
  1556. m = map_mapname2mapid(sd->status.save_point.map);
  1557. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1558. clif_displaymessage(fd, "You are not authorised to warp you to your save map.");
  1559. return -1;
  1560. }
  1561. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1562. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1563. return -1;
  1564. }
  1565. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1566. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1567. return 0;
  1568. }
  1569. /*==========================================
  1570. *
  1571. *------------------------------------------
  1572. */
  1573. int atcommand_speed(
  1574. const int fd, struct map_session_data* sd,
  1575. const char* command, const char* message)
  1576. {
  1577. char output[200];
  1578. int speed;
  1579. nullpo_retr(-1, sd);
  1580. memset(output, '\0', sizeof(output));
  1581. if (!message || !*message) {
  1582. sprintf(output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1583. clif_displaymessage(fd, output);
  1584. return -1;
  1585. }
  1586. speed = atoi(message);
  1587. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1588. sd->speed = speed;
  1589. //sd->walktimer = x;
  1590. //この文を追加 by れ�
  1591. clif_updatestatus(sd, SP_SPEED);
  1592. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1593. } else {
  1594. sprintf(output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1595. clif_displaymessage(fd, output);
  1596. return -1;
  1597. }
  1598. return 0;
  1599. }
  1600. /*==========================================
  1601. *
  1602. *------------------------------------------
  1603. */
  1604. int atcommand_storage(
  1605. const int fd, struct map_session_data* sd,
  1606. const char* command, const char* message)
  1607. {
  1608. nullpo_retr(-1, sd);
  1609. storage_storageopen(sd);
  1610. return 0;
  1611. }
  1612. /*==========================================
  1613. *
  1614. *------------------------------------------
  1615. */
  1616. int atcommand_guildstorage(
  1617. const int fd, struct map_session_data* sd,
  1618. const char* command, const char* message)
  1619. {
  1620. nullpo_retr(-1, sd);
  1621. if (sd->status.guild_id > 0)
  1622. storage_guild_storageopen(sd);
  1623. return 0;
  1624. }
  1625. /*==========================================
  1626. *
  1627. *------------------------------------------
  1628. */
  1629. int atcommand_option(
  1630. const int fd, struct map_session_data* sd,
  1631. const char* command, const char* message)
  1632. {
  1633. int param1 = 0, param2 = 0, param3 = 0;
  1634. nullpo_retr(-1, sd);
  1635. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1636. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1637. return -1;
  1638. }
  1639. sd->opt1 = param1;
  1640. sd->opt2 = param2;
  1641. if (!(sd->status.option & CART_MASK) && param3 & CART_MASK) {
  1642. clif_cart_itemlist(sd);
  1643. clif_cart_equiplist(sd);
  1644. clif_updatestatus(sd, SP_CARTINFO);
  1645. }
  1646. sd->status.option = param3;
  1647. // fix pecopeco display
  1648. if (sd->status.class == 13 || sd->status.class == 21 || sd->status.class == 4014 || sd->status.class == 4022) {
  1649. if (!pc_isriding(sd)) { // sd have the new value...
  1650. if (sd->status.class == 13)
  1651. sd->status.class = sd->view_class = 7;
  1652. else if (sd->status.class == 21)
  1653. sd->status.class = sd->view_class = 14;
  1654. else if (sd->status.class == 4014)
  1655. sd->status.class = sd->view_class = 4008;
  1656. else if (sd->status.class == 4022)
  1657. sd->status.class = sd->view_class = 4015;
  1658. }
  1659. } else {
  1660. if (pc_isriding(sd)) { // sd have the new value...
  1661. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  1662. sd->status.option &= ~0x0020;
  1663. } else {
  1664. if (sd->status.class == 7)
  1665. sd->status.class = sd->view_class = 13;
  1666. else if (sd->status.class == 14)
  1667. sd->status.class = sd->view_class = 21;
  1668. else if (sd->status.class == 4008)
  1669. sd->status.class = sd->view_class = 4014;
  1670. else if (sd->status.class == 4015)
  1671. sd->status.class = sd->view_class = 4022;
  1672. else
  1673. sd->status.option &= ~0x0020;
  1674. }
  1675. }
  1676. }
  1677. clif_changeoption(&sd->bl);
  1678. pc_calcstatus(sd, 0);
  1679. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1680. return 0;
  1681. }
  1682. /*==========================================
  1683. *
  1684. *------------------------------------------
  1685. */
  1686. int atcommand_hide(
  1687. const int fd, struct map_session_data* sd,
  1688. const char* command, const char* message)
  1689. {
  1690. nullpo_retr(-1, sd);
  1691. if (sd->status.option & OPTION_HIDE) {
  1692. sd->status.option &= ~OPTION_HIDE;
  1693. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1694. } else {
  1695. sd->status.option |= OPTION_HIDE;
  1696. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1697. }
  1698. clif_changeoption(&sd->bl);
  1699. return 0;
  1700. }
  1701. /*==========================================
  1702. * 転職する upperを指定すると転生や養子にもなれる
  1703. *------------------------------------------
  1704. */
  1705. int atcommand_jobchange(
  1706. const int fd, struct map_session_data* sd,
  1707. const char* command, const char* message)
  1708. {
  1709. int job = 0, upper = -1;
  1710. nullpo_retr(-1, sd);
  1711. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1712. int i, found = 0;
  1713. const struct { char name[16]; int id; } jobs[] = {
  1714. { "novice", 0 },
  1715. { "swordsman", 1 },
  1716. { "mage", 2 },
  1717. { "archer", 3 },
  1718. { "acolyte", 4 },
  1719. { "merchant", 5 },
  1720. { "thief", 6 },
  1721. { "knight", 7 },
  1722. { "priest", 8 },
  1723. { "priestess", 8 },
  1724. { "wizard", 9 },
  1725. { "blacksmith", 10 },
  1726. { "hunter", 11 },
  1727. { "assassin", 12 },
  1728. { "crusader", 14 },
  1729. { "monk", 15 },
  1730. { "sage", 16 },
  1731. { "rogue", 17 },
  1732. { "alchemist", 18 },
  1733. { "bard", 19 },
  1734. { "dancer", 20 },
  1735. { "super novice", 23 },
  1736. { "supernovice", 23 },
  1737. { "high novice", 4001 },
  1738. { "swordsman high", 4002 },
  1739. { "mage high", 4003 },
  1740. { "archer high", 4004 },
  1741. { "acolyte high", 4005 },
  1742. { "merchant high", 4006 },
  1743. { "thief high", 4007 },
  1744. { "lord knight", 4008 },
  1745. { "high priest", 4009 },
  1746. { "high priestess", 4009 },
  1747. { "high wizard", 4010 },
  1748. { "whitesmith", 4011 },
  1749. { "sniper", 4012 },
  1750. { "assassin cross", 4013 },
  1751. { "paladin", 4015 },
  1752. { "champion", 4016 },
  1753. { "professor", 4017 },
  1754. { "stalker", 4018 },
  1755. { "creator", 4019 },
  1756. { "clown", 4020 },
  1757. { "gypsy", 4021 },
  1758. { "baby novice", 4023 },
  1759. { "baby swordsman", 4024 },
  1760. { "baby mage", 4025 },
  1761. { "baby archer", 4026 },
  1762. { "baby acolyte", 4027 },
  1763. { "baby merchant", 4028 },
  1764. { "baby thief", 4029 },
  1765. { "baby knight", 4030 },
  1766. { "baby priest", 4031 },
  1767. { "baby priestess", 4031 },
  1768. { "baby wizard", 4032 },
  1769. { "baby blacksmith",4033 },
  1770. { "baby hunter", 4034 },
  1771. { "baby assassin", 4035 },
  1772. { "baby crusader", 4037 },
  1773. { "baby monk", 4038 },
  1774. { "baby sage", 4039 },
  1775. { "baby rogue", 4040 },
  1776. { "baby alchemist", 4041 },
  1777. { "baby bard", 4042 },
  1778. { "baby dancer", 4043 },
  1779. { "super baby", 4045 },
  1780. };
  1781. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  1782. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1783. job = jobs[i].id;
  1784. upper = 0;
  1785. found = 1;
  1786. break;
  1787. }
  1788. }
  1789. if (!found) {
  1790. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  1791. return -1;
  1792. }
  1793. }
  1794. if (job == 37 ||job == 45)
  1795. return 0;
  1796. if ((job >= 0 && job < MAX_PC_CLASS)) {
  1797. int j;
  1798. // fix pecopeco display
  1799. if ((job != 13 && job != 21 && job != 4014 && job != 4022)) {
  1800. if (pc_isriding(sd)) {
  1801. if (sd->status.class == 13)
  1802. sd->status.class = sd->view_class = 7;
  1803. if (sd->status.class == 21)
  1804. sd->status.class = sd->view_class = 14;
  1805. if (sd->status.class == 4014)
  1806. sd->status.class = sd->view_class = 4008;
  1807. if (sd->status.class == 4022)
  1808. sd->status.class = sd->view_class = 4015;
  1809. sd->status.option &= ~0x0020;
  1810. clif_changeoption(&sd->bl);
  1811. pc_calcstatus(sd, 0);
  1812. }
  1813. } else {
  1814. if (!pc_isriding(sd)) {
  1815. if (job == 13)
  1816. job = 7;
  1817. if (job == 21)
  1818. job = 14;
  1819. if (job == 4014)
  1820. job = 4008;
  1821. if (job == 4022)
  1822. job = 4015;
  1823. }
  1824. }
  1825. for (j=0; j < MAX_INVENTORY; j++) {
  1826. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  1827. pc_unequipitem(sd, j, 3);
  1828. }
  1829. if (pc_jobchange(sd, job, upper) == 0)
  1830. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  1831. else {
  1832. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  1833. return -1;
  1834. }
  1835. } else {
  1836. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  1837. return -1;
  1838. }
  1839. return 0;
  1840. }
  1841. /*==========================================
  1842. *
  1843. *------------------------------------------
  1844. */
  1845. int atcommand_die(
  1846. const int fd, struct map_session_data* sd,
  1847. const char* command, const char* message)
  1848. {
  1849. nullpo_retr(-1, sd);
  1850. clif_specialeffect(&sd->bl,450,1);
  1851. pc_damage(NULL, sd, sd->status.hp + 1);
  1852. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  1853. return 0;
  1854. }
  1855. /*==========================================
  1856. *
  1857. *------------------------------------------
  1858. */
  1859. int atcommand_kill(
  1860. const int fd, struct map_session_data* sd,
  1861. const char* command, const char* message)
  1862. {
  1863. char character[100];
  1864. struct map_session_data *pl_sd;
  1865. nullpo_retr(-1, sd);
  1866. memset(character, '\0', sizeof(character));
  1867. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1868. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  1869. return -1;
  1870. }
  1871. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1872. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  1873. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  1874. clif_displaymessage(fd, msg_table[14]); // Character killed.
  1875. } else {
  1876. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1877. return -1;
  1878. }
  1879. } else {
  1880. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1881. return -1;
  1882. }
  1883. return 0;
  1884. }
  1885. /*==========================================
  1886. *
  1887. *------------------------------------------
  1888. */
  1889. int atcommand_alive(
  1890. const int fd, struct map_session_data* sd,
  1891. const char* command, const char* message)
  1892. {
  1893. nullpo_retr(-1, sd);
  1894. if (pc_isdead(sd)) {
  1895. sd->status.hp = sd->status.max_hp;
  1896. sd->status.sp = sd->status.max_sp;
  1897. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1898. pc_setstand(sd);
  1899. if (battle_config.pc_invincible_time > 0)
  1900. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  1901. clif_updatestatus(sd, SP_HP);
  1902. clif_updatestatus(sd, SP_SP);
  1903. clif_resurrection(&sd->bl, 1);
  1904. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  1905. return 0;
  1906. }
  1907. return -1;
  1908. }
  1909. /*==========================================
  1910. *
  1911. *------------------------------------------
  1912. */
  1913. int atcommand_kami(
  1914. const int fd, struct map_session_data* sd,
  1915. const char* command, const char* message)
  1916. {
  1917. char output[200];
  1918. nullpo_retr(-1, sd);
  1919. memset(output, '\0', sizeof(output));
  1920. if (!message || !*message) {
  1921. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1922. return -1;
  1923. }
  1924. sscanf(message, "%199[^\n]", output);
  1925. intif_GMmessage(output, strlen(output) + 1, (*(command + 5) == 'b') ? 0x10 : 0);
  1926. return 0;
  1927. }
  1928. /*==========================================
  1929. *
  1930. *------------------------------------------
  1931. */
  1932. int atcommand_heal(
  1933. const int fd, struct map_session_data* sd,
  1934. const char* command, const char* message)
  1935. {
  1936. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1937. nullpo_retr(-1, sd);
  1938. sscanf(message, "%d %d", &hp, &sp);
  1939. if (hp == 0 && sp == 0) {
  1940. hp = sd->status.max_hp - sd->status.hp;
  1941. sp = sd->status.max_sp - sd->status.sp;
  1942. } else {
  1943. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  1944. hp = sd->status.max_hp - sd->status.hp;
  1945. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  1946. hp = 1 - sd->status.hp;
  1947. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  1948. sp = sd->status.max_sp - sd->status.sp;
  1949. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  1950. sp = 1 - sd->status.sp;
  1951. }
  1952. if (hp > 0) // display like heal
  1953. clif_heal(fd, SP_HP, hp);
  1954. else if (hp < 0) // display like damage
  1955. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1956. if (sp > 0) // no display when we lost SP
  1957. clif_heal(fd, SP_SP, sp);
  1958. if (hp != 0 || sp != 0) {
  1959. pc_heal(sd, hp, sp);
  1960. if (hp >= 0 && sp >= 0)
  1961. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  1962. else
  1963. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  1964. } else {
  1965. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  1966. return -1;
  1967. }
  1968. return 0;
  1969. }
  1970. /*==========================================
  1971. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1972. *------------------------------------------
  1973. */
  1974. int atcommand_item(
  1975. const int fd, struct map_session_data* sd,
  1976. const char* command, const char* message)
  1977. {
  1978. char item_name[100];
  1979. int number = 0, item_id, flag;
  1980. struct item item_tmp;
  1981. struct item_data *item_data;
  1982. int get_count, i, pet_id;
  1983. nullpo_retr(-1, sd);
  1984. memset(item_name, '\0', sizeof(item_name));
  1985. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  1986. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1987. return -1;
  1988. }
  1989. if (number <= 0)
  1990. number = 1;
  1991. item_id = 0;
  1992. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1993. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1994. item_id = item_data->nameid;
  1995. if (item_id >= 500) {
  1996. get_count = number;
  1997. // check pet egg
  1998. pet_id = search_petDB_index(item_id, PET_EGG);
  1999. if (item_data->type == 4 || item_data->type == 5 ||
  2000. item_data->type == 7 || item_data->type == 8) {
  2001. get_count = 1;
  2002. }
  2003. for (i = 0; i < number; i += get_count) {
  2004. // if pet egg
  2005. if (pet_id >= 0) {
  2006. sd->catch_target_class = pet_db[pet_id].class;
  2007. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2008. pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
  2009. pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
  2010. 100, 0, 1, pet_db[pet_id].jname);
  2011. // if not pet egg
  2012. } else {
  2013. memset(&item_tmp, 0, sizeof(item_tmp));
  2014. item_tmp.nameid = item_id;
  2015. item_tmp.identify = 1;
  2016. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2017. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2018. }
  2019. }
  2020. clif_displaymessage(fd, msg_table[18]); // Item created.
  2021. } else {
  2022. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2023. return -1;
  2024. }
  2025. return 0;
  2026. }
  2027. /*==========================================
  2028. *
  2029. *------------------------------------------
  2030. */
  2031. int atcommand_item2(
  2032. const int fd, struct map_session_data* sd,
  2033. const char* command, const char* message)
  2034. {
  2035. struct item item_tmp;
  2036. struct item_data *item_data;
  2037. char item_name[100];
  2038. int item_id, number = 0;
  2039. int identify = 0, refine = 0, attr = 0;
  2040. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2041. int flag;
  2042. int loop, get_count, i;
  2043. nullpo_retr(-1, sd);
  2044. memset(item_name, '\0', sizeof(item_name));
  2045. if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
  2046. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2047. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2048. return -1;
  2049. }
  2050. if (number <= 0)
  2051. number = 1;
  2052. item_id = 0;
  2053. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2054. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2055. item_id = item_data->nameid;
  2056. if (item_id > 500) {
  2057. loop = 1;
  2058. get_count = number;
  2059. if (item_data->type == 4 || item_data->type == 5 ||
  2060. item_data->type == 7 || item_data->type == 8) {
  2061. loop = number;
  2062. get_count = 1;
  2063. if (item_data->type == 7) {
  2064. identify = 1;
  2065. refine = 0;
  2066. }
  2067. if (item_data->type == 8)
  2068. refine = 0;
  2069. if (refine > 10)
  2070. refine = 10;
  2071. } else {
  2072. identify = 1;
  2073. refine = attr = 0;
  2074. }
  2075. for (i = 0; i < loop; i++) {
  2076. memset(&item_tmp, 0, sizeof(item_tmp));
  2077. item_tmp.nameid = item_id;
  2078. item_tmp.identify = identify;
  2079. item_tmp.refine = refine;
  2080. item_tmp.attribute = attr;
  2081. item_tmp.card[0] = c1;
  2082. item_tmp.card[1] = c2;
  2083. item_tmp.card[2] = c3;
  2084. item_tmp.card[3] = c4;
  2085. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2086. clif_additem(sd, 0, 0, flag);
  2087. }
  2088. clif_displaymessage(fd, msg_table[18]); // Item created.
  2089. } else {
  2090. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2091. return -1;
  2092. }
  2093. return 0;
  2094. }
  2095. /*==========================================
  2096. *
  2097. *------------------------------------------
  2098. */
  2099. int atcommand_itemreset(
  2100. const int fd, struct map_session_data* sd,
  2101. const char* command, const char* message)
  2102. {
  2103. int i;
  2104. nullpo_retr(-1, sd);
  2105. for (i = 0; i < MAX_INVENTORY; i++) {
  2106. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0)
  2107. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2108. }
  2109. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2110. return 0;
  2111. }
  2112. /*==========================================
  2113. *
  2114. *------------------------------------------
  2115. */
  2116. int atcommand_itemcheck(
  2117. const int fd, struct map_session_data* sd,
  2118. const char* command, const char* message)
  2119. {
  2120. nullpo_retr(-1, sd);
  2121. pc_checkitem(sd);
  2122. return 0;
  2123. }
  2124. /*==========================================
  2125. *
  2126. *------------------------------------------
  2127. */
  2128. int atcommand_baselevelup(
  2129. const int fd, struct map_session_data* sd,
  2130. const char* command, const char* message)
  2131. {
  2132. int level, i;
  2133. nullpo_retr(-1, sd);
  2134. if (!message || !*message || (level = atoi(message)) == 0) {
  2135. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2136. return -1;
  2137. }
  2138. if (level > 0) {
  2139. if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  2140. clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher.
  2141. return -1;
  2142. } // End Addition
  2143. if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
  2144. level = battle_config.maximum_level - sd->status.base_level;
  2145. for (i = 1; i <= level; i++)
  2146. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2147. sd->status.base_level += level;
  2148. clif_updatestatus(sd, SP_BASELEVEL);
  2149. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2150. clif_updatestatus(sd, SP_STATUSPOINT);
  2151. pc_calcstatus(sd, 0);
  2152. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2153. clif_misceffect(&sd->bl, 0);
  2154. clif_displaymessage(fd, msg_table[21]); // Base level raised.
  2155. } else {
  2156. if (sd->status.base_level == 1) {
  2157. clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower.
  2158. return -1;
  2159. }
  2160. if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow
  2161. level = 1 - sd->status.base_level;
  2162. if (sd->status.status_point > 0) {
  2163. for (i = 0; i > level; i--)
  2164. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2165. if (sd->status.status_point < 0)
  2166. sd->status.status_point = 0;
  2167. clif_updatestatus(sd, SP_STATUSPOINT);
  2168. } // to add: remove status points from stats
  2169. sd->status.base_level += level;
  2170. clif_updatestatus(sd, SP_BASELEVEL);
  2171. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2172. pc_calcstatus(sd, 0);
  2173. clif_displaymessage(fd, msg_table[22]); // Base level lowered.
  2174. }
  2175. return 0;
  2176. }
  2177. /*==========================================
  2178. *
  2179. *------------------------------------------
  2180. */
  2181. int atcommand_joblevelup(
  2182. const int fd, struct map_session_data* sd,
  2183. const char* command, const char* message)
  2184. {
  2185. int up_level = 50, level;
  2186. struct pc_base_job s_class;
  2187. nullpo_retr(-1, sd);
  2188. s_class = pc_calc_base_job(sd->status.class);
  2189. if (!message || !*message || (level = atoi(message)) == 0) {
  2190. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2191. return -1;
  2192. }
  2193. if (s_class.job == 0)
  2194. up_level -= 40;
  2195. // super novices can go up to 99 [celest]
  2196. else if (s_class.job == 23)
  2197. up_level += 49;
  2198. else if (sd->status.class > 4007 && sd->status.class < 4023)
  2199. up_level += 20;
  2200. if (level > 0) {
  2201. if (sd->status.job_level == up_level) {
  2202. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2203. return -1;
  2204. }
  2205. if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow
  2206. level = up_level - sd->status.job_level;
  2207. sd->status.job_level += level;
  2208. clif_updatestatus(sd, SP_JOBLEVEL);
  2209. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2210. sd->status.skill_point += level;
  2211. clif_updatestatus(sd, SP_SKILLPOINT);
  2212. pc_calcstatus(sd, 0);
  2213. clif_misceffect(&sd->bl, 1);
  2214. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2215. } else {
  2216. if (sd->status.job_level == 1) {
  2217. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2218. return -1;
  2219. }
  2220. if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow
  2221. level = 1 - sd->status.job_level;
  2222. sd->status.job_level += level;
  2223. clif_updatestatus(sd, SP_JOBLEVEL);
  2224. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2225. if (sd->status.skill_point > 0) {
  2226. sd->status.skill_point += level;
  2227. if (sd->status.skill_point < 0)
  2228. sd->status.skill_point = 0;
  2229. clif_updatestatus(sd, SP_SKILLPOINT);
  2230. } // to add: remove status points from skills
  2231. pc_calcstatus(sd, 0);
  2232. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2233. }
  2234. return 0;
  2235. }
  2236. /*==========================================
  2237. *
  2238. *------------------------------------------
  2239. */
  2240. int atcommand_help(
  2241. const int fd, struct map_session_data* sd,
  2242. const char* command, const char* message)
  2243. {
  2244. char buf[2048], w1[2048], w2[2048];
  2245. int i, gm_level;
  2246. FILE* fp;
  2247. nullpo_retr(-1, sd);
  2248. memset(buf, '\0', sizeof(buf));
  2249. if ((fp = fopen(help_txt, "r")) != NULL) {
  2250. clif_displaymessage(fd, msg_table[26]); // Help commands:
  2251. gm_level = pc_isGM(sd);
  2252. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2253. if (buf[0] == '/' && buf[1] == '/')
  2254. continue;
  2255. for (i = 0; buf[i] != '\0'; i++) {
  2256. if (buf[i] == '\r' || buf[i] == '\n') {
  2257. buf[i] = '\0';
  2258. break;
  2259. }
  2260. }
  2261. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2262. clif_displaymessage(fd, buf);
  2263. else if (gm_level >= atoi(w1))
  2264. clif_displaymessage(fd, w2);
  2265. }
  2266. fclose(fp);
  2267. } else {
  2268. clif_displaymessage(fd, msg_table[27]); // File help.txt not found.
  2269. return -1;
  2270. }
  2271. return 0;
  2272. }
  2273. /*==========================================
  2274. *
  2275. *------------------------------------------
  2276. */
  2277. int atcommand_gm(
  2278. const int fd, struct map_session_data* sd,
  2279. const char* command, const char* message)
  2280. {
  2281. char password[100];
  2282. nullpo_retr(-1, sd);
  2283. memset(password, '\0', sizeof(password));
  2284. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2285. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2286. return -1;
  2287. }
  2288. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  2289. clif_displaymessage(fd, msg_table[50]); // You already have some GM powers.
  2290. return -1;
  2291. } else
  2292. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2293. return 0;
  2294. }
  2295. /*==========================================
  2296. *
  2297. *------------------------------------------
  2298. */
  2299. int atcommand_pvpoff(
  2300. const int fd, struct map_session_data* sd,
  2301. const char* command, const char* message)
  2302. {
  2303. struct map_session_data *pl_sd;
  2304. int i;
  2305. nullpo_retr(-1, sd);
  2306. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2307. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2308. return -1;
  2309. }
  2310. if (map[sd->bl.m].flag.pvp) {
  2311. map[sd->bl.m].flag.pvp = 0;
  2312. clif_send0199(sd->bl.m, 0);
  2313. for (i = 0; i < fd_max; i++) { //人数分ループ
  2314. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2315. if (sd->bl.m == pl_sd->bl.m) {
  2316. clif_pvpset(pl_sd, 0, 0, 2);
  2317. if (pl_sd->pvp_timer != -1) {
  2318. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2319. pl_sd->pvp_timer = -1;
  2320. }
  2321. }
  2322. }
  2323. }
  2324. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2325. } else {
  2326. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2327. return -1;
  2328. }
  2329. return 0;
  2330. }
  2331. /*==========================================
  2332. *
  2333. *------------------------------------------
  2334. */
  2335. int atcommand_pvpon(
  2336. const int fd, struct map_session_data* sd,
  2337. const char* command, const char* message)
  2338. {
  2339. struct map_session_data *pl_sd;
  2340. int i;
  2341. nullpo_retr(-1, sd);
  2342. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2343. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2344. return -1;
  2345. }
  2346. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2347. map[sd->bl.m].flag.pvp = 1;
  2348. clif_send0199(sd->bl.m, 1);
  2349. for (i = 0; i < fd_max; i++) {
  2350. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2351. if (sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2352. pl_sd->pvp_timer = add_timer(gettick() + 200,
  2353. pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2354. pl_sd->pvp_rank = 0;
  2355. pl_sd->pvp_lastusers = 0;
  2356. pl_sd->pvp_point = 5;
  2357. }
  2358. }
  2359. }
  2360. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2361. } else {
  2362. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2363. return -1;
  2364. }
  2365. return 0;
  2366. }
  2367. /*==========================================
  2368. *
  2369. *------------------------------------------
  2370. */
  2371. int atcommand_gvgoff(
  2372. const int fd, struct map_session_data* sd,
  2373. const char* command, const char* message)
  2374. {
  2375. nullpo_retr(-1, sd);
  2376. if (map[sd->bl.m].flag.gvg) {
  2377. map[sd->bl.m].flag.gvg = 0;
  2378. clif_send0199(sd->bl.m, 0);
  2379. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2380. } else {
  2381. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2382. return -1;
  2383. }
  2384. return 0;
  2385. }
  2386. /*==========================================
  2387. *
  2388. *------------------------------------------
  2389. */
  2390. int atcommand_gvgon(
  2391. const int fd, struct map_session_data* sd,
  2392. const char* command, const char* message)
  2393. {
  2394. nullpo_retr(-1, sd);
  2395. if (!map[sd->bl.m].flag.gvg) {
  2396. map[sd->bl.m].flag.gvg = 1;
  2397. clif_send0199(sd->bl.m, 3);
  2398. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2399. } else {
  2400. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2401. return -1;
  2402. }
  2403. return 0;
  2404. }
  2405. /*==========================================
  2406. *
  2407. *------------------------------------------
  2408. */
  2409. int atcommand_model(
  2410. const int fd, struct map_session_data* sd,
  2411. const char* command, const char* message)
  2412. {
  2413. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2414. char output[200];
  2415. nullpo_retr(-1, sd);
  2416. memset(output, '\0', sizeof(output));
  2417. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2418. sprintf(output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2419. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2420. clif_displaymessage(fd, output);
  2421. return -1;
  2422. }
  2423. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2424. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2425. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2426. //服の色変更
  2427. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2428. //服の色未実装職の判定
  2429. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2430. return -1;
  2431. } else {
  2432. pc_changelook(sd, LOOK_HAIR, hair_style);
  2433. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2434. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2435. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2436. }
  2437. } else {
  2438. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2439. return -1;
  2440. }
  2441. return 0;
  2442. }
  2443. /*==========================================
  2444. * @dye && @ccolor
  2445. *------------------------------------------
  2446. */
  2447. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2448. {
  2449. int cloth_color = 0;
  2450. char output[200];
  2451. nullpo_retr(-1, sd);
  2452. memset(output, '\0', sizeof(output));
  2453. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2454. sprintf(output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2455. clif_displaymessage(fd, output);
  2456. return -1;
  2457. }
  2458. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2459. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2460. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2461. return -1;
  2462. } else {
  2463. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2464. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2465. }
  2466. } else {
  2467. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2468. return -1;
  2469. }
  2470. return 0;
  2471. }
  2472. /*==========================================
  2473. * @hairstyle && @hstyle
  2474. *------------------------------------------
  2475. */
  2476. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2477. {
  2478. int hair_style = 0;
  2479. char output[200];
  2480. nullpo_retr(-1, sd);
  2481. memset(output, '\0', sizeof(output));
  2482. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2483. sprintf(output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2484. clif_displaymessage(fd, output);
  2485. return -1;
  2486. }
  2487. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2488. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2489. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2490. return -1;
  2491. } else {
  2492. pc_changelook(sd, LOOK_HAIR, hair_style);
  2493. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2494. }
  2495. } else {
  2496. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2497. return -1;
  2498. }
  2499. return 0;
  2500. }
  2501. /*==========================================
  2502. * @charhairstyle by [MouseJstr]
  2503. *------------------------------------------
  2504. */
  2505. int
  2506. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2507. const char* command, const char* message)
  2508. {
  2509. nullpo_retr(-1, sd);
  2510. return 0;
  2511. }
  2512. /*==========================================
  2513. * @haircolor && @hcolor
  2514. *------------------------------------------
  2515. */
  2516. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2517. {
  2518. int hair_color = 0;
  2519. char output[200];
  2520. nullpo_retr(-1, sd);
  2521. memset(output, '\0', sizeof(output));
  2522. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2523. sprintf(output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2524. clif_displaymessage(fd, output);
  2525. return -1;
  2526. }
  2527. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2528. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2529. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2530. return -1;
  2531. } else {
  2532. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2533. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2534. }
  2535. } else {
  2536. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2537. return -1;
  2538. }
  2539. return 0;
  2540. }
  2541. /*==========================================
  2542. * @go [city_number/city_name]: improved by [yor] to add city names and help
  2543. *------------------------------------------
  2544. */
  2545. int atcommand_go(
  2546. const int fd, struct map_session_data* sd,
  2547. const char* command, const char* message)
  2548. {
  2549. int i;
  2550. int town;
  2551. char map_name[100];
  2552. char output[200];
  2553. int m;
  2554. const struct { char map[16]; int x, y; } data[] = {
  2555. { "prontera.gat", 156, 191 }, // 0=Prontera
  2556. { "morocc.gat", 156, 93 }, // 1=Morroc
  2557. { "geffen.gat", 119, 59 }, // 2=Geffen
  2558. { "payon.gat", 162, 233 }, // 3=Payon
  2559. { "alberta.gat", 192, 147 }, // 4=Alberta
  2560. { "izlude.gat", 128, 114 }, // 5=Izlude
  2561. { "aldebaran.gat",140, 131 }, // 6=Al de Baran
  2562. { "xmas.gat", 147, 134 }, // 7=Lutie
  2563. { "comodo.gat", 209, 143 }, // 8=Comodo
  2564. { "yuno.gat", 157, 51 }, // 9=Yuno
  2565. { "amatsu.gat", 198, 84 }, // 10=Amatsu
  2566. { "gonryun.gat", 160, 120 }, // 11=Gon Ryun
  2567. { "umbala.gat", 89, 157 }, // 12=Umbala
  2568. { "niflheim.gat", 21, 153 }, // 13=Niflheim
  2569. { "louyang.gat", 217, 40 }, // 14=Lou Yang
  2570. { "new_1-1.gat", 53, 111 }, // 15=Start point
  2571. { "sec_pri.gat", 23, 61 }, // 16=Prison
  2572. { "jawaii.gat", 249, 127 }, // 17=Jawaii
  2573. { "ayothaya.gat", 151, 117 }, // 18=Ayothaya
  2574. };
  2575. nullpo_retr(-1, sd);
  2576. if(map[sd->bl.m].flag.nogo) {
  2577. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2578. return 0;
  2579. }
  2580. memset(map_name, '\0', sizeof(map_name));
  2581. memset(output, '\0', sizeof(output));
  2582. // get the number
  2583. town = atoi(message);
  2584. // if no value, display all value
  2585. if (!message || !*message || sscanf(message, "%99s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2586. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2587. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2588. clif_displaymessage(fd, "-3=(Memo point 2) 4=Alberta 11=Gon Ryun");
  2589. clif_displaymessage(fd, "-2=(Memo point 1) 5=Izlude 12=Umbala");
  2590. clif_displaymessage(fd, "-1=(Memo point 0) 6=Al de Baran 13=Niflheim");
  2591. clif_displaymessage(fd, " 0=Prontera 7=Lutie 14=Lou Yang");
  2592. clif_displaymessage(fd, " 1=Morroc 8=Comodo 15=Start point");
  2593. clif_displaymessage(fd, " 2=Geffen 9=Yuno 16=Prison");
  2594. clif_displaymessage(fd, " 3=Payon 10=Amatsu 17=Jawaii");
  2595. clif_displaymessage(fd, " 18=Ayothaya");
  2596. return -1;
  2597. } else {
  2598. // get possible name of the city and add .gat if not in the name
  2599. map_name[sizeof(map_name)-1] = '\0';
  2600. for (i = 0; map_name[i]; i++)
  2601. map_name[i] = tolower(map_name[i]);
  2602. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  2603. strcat(map_name, ".gat");
  2604. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2605. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2606. town = 0;
  2607. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2608. town = 1;
  2609. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2610. town = 2;
  2611. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2612. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2613. town = 3;
  2614. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2615. town = 4;
  2616. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2617. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2618. town = 5;
  2619. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2620. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2621. town = 6;
  2622. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2623. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2624. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2625. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2626. town = 7;
  2627. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2628. town = 8;
  2629. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2630. town = 9;
  2631. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2632. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2633. town = 10;
  2634. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2635. town = 11;
  2636. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2637. town = 12;
  2638. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2639. town = 13;
  2640. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2641. town = 14;
  2642. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2643. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2644. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2645. town = 15;
  2646. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2647. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2648. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2649. town = 16;
  2650. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2651. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2652. town = 17;
  2653. } else if (strncmp(map_name, "ayothaya.gat", 4) == 0 || // 3 first characters
  2654. strncmp(map_name, "ayotaya.gat", 4) == 0) { // writing error (3 first characters)
  2655. town = 18;
  2656. }
  2657. if (town >= -3 && town <= -1) {
  2658. if (sd->status.memo_point[-town-1].map[0]) {
  2659. m = map_mapname2mapid(sd->status.memo_point[-town-1].map);
  2660. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2661. clif_displaymessage(fd, "You are not authorised to warp you to this memo map.");
  2662. return -1;
  2663. }
  2664. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2665. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2666. return -1;
  2667. }
  2668. if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
  2669. clif_displaymessage(fd, msg_table[0]); // Warped.
  2670. } else {
  2671. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2672. return -1;
  2673. }
  2674. } else {
  2675. sprintf(output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2676. clif_displaymessage(fd, output);
  2677. return -1;
  2678. }
  2679. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2680. m = map_mapname2mapid((char *)data[town].map);
  2681. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2682. clif_displaymessage(fd, "You are not authorised to warp you to this destination map.");
  2683. return -1;
  2684. }
  2685. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2686. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2687. return -1;
  2688. }
  2689. if (pc_setpos(sd, (char *)data[town].map, data[town].x, data[town].y, 3) == 0) {
  2690. clif_displaymessage(fd, msg_table[0]); // Warped.
  2691. } else {
  2692. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2693. return -1;
  2694. }
  2695. } else { // if you arrive here, you have an error in town variable when reading of names
  2696. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2697. return -1;
  2698. }
  2699. }
  2700. return 0;
  2701. }
  2702. /*==========================================
  2703. *
  2704. *------------------------------------------
  2705. */
  2706. int atcommand_monster(
  2707. const int fd, struct map_session_data* sd,
  2708. const char* command, const char* message)
  2709. {
  2710. char name[100];
  2711. char monster[100];
  2712. char output[200];
  2713. int mob_id;
  2714. int number = 0;
  2715. int x = 0, y = 0;
  2716. int count;
  2717. int i, j, k;
  2718. int mx, my, range;
  2719. nullpo_retr(-1, sd);
  2720. memset(name, '\0', sizeof(name));
  2721. memset(monster, '\0', sizeof(monster));
  2722. memset(output, '\0', sizeof(output));
  2723. if (!message || !*message ||
  2724. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2725. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2726. sscanf(message, "%99s %99s %d %d %d", name, monster, &number, &x, &y) < 2)) {
  2727. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2728. return -1;
  2729. }
  2730. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2731. mob_id = mobdb_checkid(atoi(monster));
  2732. if (mob_id == 0) {
  2733. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2734. return -1;
  2735. }
  2736. if (mob_id == 1288) {
  2737. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2738. return -1;
  2739. }
  2740. if (number <= 0)
  2741. number = 1;
  2742. if (strlen(name) < 1)
  2743. strcpy(name, "--ja--");
  2744. // 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
  2745. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2746. number = battle_config.atc_spawn_quantity_limit;
  2747. if (battle_config.etc_log)
  2748. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2749. count = 0;
  2750. range = sqrt(number) / 2;
  2751. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2752. for (i = 0; i < number; i++) {
  2753. j = 0;
  2754. k = 0;
  2755. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2756. if (x <= 0)
  2757. mx = sd->bl.x + (rand() % range - (range / 2));
  2758. else
  2759. mx = x;
  2760. if (y <= 0)
  2761. my = sd->bl.y + (rand() % range - (range / 2));
  2762. else
  2763. my = y;
  2764. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2765. }
  2766. count += (k != 0) ? 1 : 0;
  2767. }
  2768. if (count != 0)
  2769. if (number == count)
  2770. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2771. else {
  2772. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2773. clif_displaymessage(fd, output);
  2774. }
  2775. else {
  2776. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2777. return -1;
  2778. }
  2779. return 0;
  2780. }
  2781. /*==========================================
  2782. *
  2783. *------------------------------------------
  2784. */
  2785. int atcommand_spawn(
  2786. const int fd, struct map_session_data* sd,
  2787. const char* command, const char* message) {
  2788. char name[100];
  2789. char monster[100];
  2790. char output[200];
  2791. int mob_id;
  2792. int number = 0;
  2793. int x = 0, y = 0;
  2794. int count;
  2795. int i, j, k;
  2796. int mx, my, range;
  2797. nullpo_retr(-1, sd);
  2798. memset(name, '\0', sizeof(name));
  2799. memset(monster, '\0', sizeof(monster));
  2800. memset(output, '\0', sizeof(output));
  2801. if (!message || !*message ||
  2802. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2803. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2804. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1)) {
  2805. clif_displaymessage(fd, msg_table[143]); // Give a monster name/id please.
  2806. return -1;
  2807. }
  2808. // If monster identifier/name argument is a name
  2809. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2810. mob_id = mobdb_checkid(atoi(monster));
  2811. if (mob_id == 0) {
  2812. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2813. return -1;
  2814. }
  2815. if (mob_id == 1288) {
  2816. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2817. return -1;
  2818. }
  2819. if (number <= 0)
  2820. number = 1;
  2821. if (strlen(name) < 1)
  2822. strcpy(name, "--ja--");
  2823. // 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
  2824. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2825. number = battle_config.atc_spawn_quantity_limit;
  2826. if (battle_config.etc_log)
  2827. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2828. count = 0;
  2829. range = sqrt(number) / 2;
  2830. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2831. for (i = 0; i < number; i++) {
  2832. j = 0;
  2833. k = 0;
  2834. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2835. if (x <= 0)
  2836. mx = sd->bl.x + (rand() % range - (range / 2));
  2837. else
  2838. mx = x;
  2839. if (y <= 0)
  2840. my = sd->bl.y + (rand() % range - (range / 2));
  2841. else
  2842. my = y;
  2843. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2844. }
  2845. count += (k != 0) ? 1 : 0;
  2846. }
  2847. if (count != 0)
  2848. if (number == count)
  2849. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2850. else {
  2851. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2852. clif_displaymessage(fd, output);
  2853. }
  2854. else {
  2855. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2856. return -1;
  2857. }
  2858. return 0;
  2859. }
  2860. // small monster spawning [Valaris]
  2861. int atcommand_monstersmall(
  2862. const int fd, struct map_session_data* sd,
  2863. const char* command, const char* message) {
  2864. char name[100] = "";
  2865. char monster[100] = "";
  2866. int mob_id = 0;
  2867. int number = 0;
  2868. int x = 0;
  2869. int y = 0;
  2870. int count;
  2871. int i;
  2872. nullpo_retr(-1, sd);
  2873. if (!message || !*message) {
  2874. clif_displaymessage(fd, "Give a monster name/id please.");
  2875. return 0;
  2876. }
  2877. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2878. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2879. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2880. clif_displaymessage(fd, "Give a monster name/id please.");
  2881. return 0;
  2882. }
  2883. // If monster identifier/name argument is a name
  2884. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2885. mob_id = atoi(monster);
  2886. if (mob_id == 0) {
  2887. clif_displaymessage(fd, "Monster name hasn't been found.");
  2888. return 0;
  2889. }
  2890. if (mob_id == 1288) {
  2891. clif_displaymessage(fd, "Cannot spawn emperium.");
  2892. return 0;
  2893. }
  2894. if (mob_id > 2000) {
  2895. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2896. return 0;
  2897. }
  2898. if (number <= 0)
  2899. number = 1;
  2900. if (strlen(name) < 1)
  2901. strcpy(name, "--ja--");
  2902. // 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
  2903. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2904. number = battle_config.atc_spawn_quantity_limit;
  2905. count = 0;
  2906. for (i = 0; i < number; i++) {
  2907. int mx, my;
  2908. if (x <= 0)
  2909. mx = sd->bl.x + (rand() % 11 - 5);
  2910. else
  2911. mx = x;
  2912. if (y <= 0)
  2913. my = sd->bl.y + (rand() % 11 - 5);
  2914. else
  2915. my = y;
  2916. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2000, 1, "") != 0) ? 1 : 0;
  2917. }
  2918. if (count != 0)
  2919. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2920. else
  2921. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2922. return 0;
  2923. }
  2924. // big monster spawning [Valaris]
  2925. int atcommand_monsterbig(
  2926. const int fd, struct map_session_data* sd,
  2927. const char* command, const char* message) {
  2928. char name[100] = "";
  2929. char monster[100] = "";
  2930. int mob_id = 0;
  2931. int number = 0;
  2932. int x = 0;
  2933. int y = 0;
  2934. int count;
  2935. int i;
  2936. nullpo_retr(-1, sd);
  2937. if (!message || !*message) {
  2938. clif_displaymessage(fd, "Give a monster name/id please.");
  2939. return 0;
  2940. }
  2941. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2942. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2943. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2944. clif_displaymessage(fd, "Give a monster name/id please.");
  2945. return 0;
  2946. }
  2947. // If monster identifier/name argument is a name
  2948. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2949. mob_id = atoi(monster);
  2950. if (mob_id == 0) {
  2951. clif_displaymessage(fd, "Monster name hasn't been found.");
  2952. return 0;
  2953. }
  2954. if (mob_id == 1288) {
  2955. clif_displaymessage(fd, "Cannot spawn emperium.");
  2956. return 0;
  2957. }
  2958. if (mob_id > 2000) {
  2959. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2960. return 0;
  2961. }
  2962. if (number <= 0)
  2963. number = 1;
  2964. if (strlen(name) < 1)
  2965. strcpy(name, "--ja--");
  2966. // 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
  2967. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2968. number = battle_config.atc_spawn_quantity_limit;
  2969. count = 0;
  2970. for (i = 0; i < number; i++) {
  2971. int mx, my;
  2972. if (x <= 0)
  2973. mx = sd->bl.x + (rand() % 11 - 5);
  2974. else
  2975. mx = x;
  2976. if (y <= 0)
  2977. my = sd->bl.y + (rand() % 11 - 5);
  2978. else
  2979. my = y;
  2980. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+4000, 1, "") != 0) ? 1 : 0;
  2981. }
  2982. if (count != 0)
  2983. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2984. else
  2985. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2986. return 0;
  2987. }
  2988. /*==========================================
  2989. *
  2990. *------------------------------------------
  2991. */
  2992. void atcommand_killmonster_sub(
  2993. const int fd, struct map_session_data* sd, const char* message,
  2994. const int drop)
  2995. {
  2996. int map_id;
  2997. char map_name[100];
  2998. if (!sd) return;
  2999. memset(map_name, '\0', sizeof(map_name));
  3000. if (!message || !*message || sscanf(message, "%99s", map_name) < 1)
  3001. map_id = sd->bl.m;
  3002. else {
  3003. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  3004. strcat(map_name, ".gat");
  3005. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3006. map_id = sd->bl.m;
  3007. }
  3008. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, drop);
  3009. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3010. return;
  3011. }
  3012. /*==========================================
  3013. *
  3014. *------------------------------------------
  3015. */
  3016. int atcommand_killmonster(
  3017. const int fd, struct map_session_data* sd,
  3018. const char* command, const char* message)
  3019. {
  3020. if (!sd) return 0;
  3021. atcommand_killmonster_sub(fd, sd, message, 1);
  3022. return 0;
  3023. }
  3024. /*==========================================
  3025. *
  3026. *------------------------------------------
  3027. */
  3028. int atcommand_killmonster2(
  3029. const int fd, struct map_session_data* sd,
  3030. const char* command, const char* message)
  3031. {
  3032. if (!sd) return 0;
  3033. atcommand_killmonster_sub(fd, sd, message, 0);
  3034. return 0;
  3035. }
  3036. /*==========================================
  3037. *
  3038. *------------------------------------------
  3039. */
  3040. int atcommand_refine(
  3041. const int fd, struct map_session_data* sd,
  3042. const char* command, const char* message)
  3043. {
  3044. int i, position = 0, refine = 0, current_position, final_refine;
  3045. int count;
  3046. char output[200];
  3047. nullpo_retr(-1, sd);
  3048. memset(output, '\0', sizeof(output));
  3049. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3050. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3051. return -1;
  3052. }
  3053. if (refine < -10)
  3054. refine = -10;
  3055. else if (refine > 10)
  3056. refine = 10;
  3057. else if (refine == 0)
  3058. refine = 1;
  3059. count = 0;
  3060. for (i = 0; i < MAX_INVENTORY; i++) {
  3061. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3062. (sd->status.inventory[i].equip & position ||
  3063. (sd->status.inventory[i].equip && !position))) {
  3064. final_refine = sd->status.inventory[i].refine + refine;
  3065. if (final_refine > 10)
  3066. final_refine = 10;
  3067. else if (final_refine < 0)
  3068. final_refine = 0;
  3069. if (sd->status.inventory[i].refine != final_refine) {
  3070. sd->status.inventory[i].refine = final_refine;
  3071. current_position = sd->status.inventory[i].equip;
  3072. pc_unequipitem(sd, i, 3);
  3073. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3074. clif_delitem(sd, i, 1);
  3075. clif_additem(sd, i, 1, 0);
  3076. pc_equipitem(sd, i, current_position);
  3077. clif_misceffect((struct block_list*)&sd->bl, 3);
  3078. count++;
  3079. }
  3080. }
  3081. }
  3082. if (count == 0)
  3083. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3084. else if (count == 1)
  3085. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3086. else {
  3087. sprintf(output, msg_table[168], count); // %d items have been refined!
  3088. clif_displaymessage(fd, output);
  3089. }
  3090. return 0;
  3091. }
  3092. /*==========================================
  3093. *
  3094. *------------------------------------------
  3095. */
  3096. int atcommand_produce(
  3097. const int fd, struct map_session_data* sd,
  3098. const char* command, const char* message)
  3099. {
  3100. char item_name[100];
  3101. int item_id, attribute = 0, star = 0;
  3102. int flag = 0;
  3103. struct item_data *item_data;
  3104. struct item tmp_item;
  3105. char output[200];
  3106. nullpo_retr(-1, sd);
  3107. memset(output, '\0', sizeof(output));
  3108. memset(item_name, '\0', sizeof(item_name));
  3109. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3110. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3111. return -1;
  3112. }
  3113. item_id = 0;
  3114. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3115. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3116. item_id = item_data->nameid;
  3117. if (itemdb_exists(item_id) &&
  3118. (item_id <= 500 || item_id > 1099) &&
  3119. (item_id < 4001 || item_id > 4148) &&
  3120. (item_id < 7001 || item_id > 10019) &&
  3121. itemdb_isequip(item_id)) {
  3122. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3123. attribute = ATTRIBUTE_NORMAL;
  3124. if (star < MIN_STAR || star > MAX_STAR)
  3125. star = 0;
  3126. memset(&tmp_item, 0, sizeof tmp_item);
  3127. tmp_item.nameid = item_id;
  3128. tmp_item.amount = 1;
  3129. tmp_item.identify = 1;
  3130. tmp_item.card[0] = 0x00ff;
  3131. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3132. *((unsigned long *)(&tmp_item.card[2])) = sd->char_id;
  3133. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3134. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3135. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3136. clif_additem(sd, 0, 0, flag);
  3137. } else {
  3138. if (battle_config.error_log)
  3139. printf("@produce NOT WEAPON [%d]\n", item_id);
  3140. if (item_id != 0 && itemdb_exists(item_id))
  3141. sprintf(output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3142. else
  3143. sprintf(output, msg_table[170]); // This item is not an equipment.
  3144. clif_displaymessage(fd, output);
  3145. return -1;
  3146. }
  3147. return 0;
  3148. }
  3149. /*==========================================
  3150. * Sub-function to display actual memo points
  3151. *------------------------------------------
  3152. */
  3153. void atcommand_memo_sub(struct map_session_data* sd) {
  3154. int i;
  3155. char output[200];
  3156. if (!sd) return;
  3157. memset(output, '\0', sizeof(output));
  3158. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3159. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3160. if (sd->status.memo_point[i].map[0])
  3161. sprintf(output, "%d - %s (%d,%d)", i, sd->status.memo_point[i].map, sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  3162. else
  3163. sprintf(output, msg_table[171], i); // %d - void
  3164. clif_displaymessage(sd->fd, output);
  3165. }
  3166. return;
  3167. }
  3168. /*==========================================
  3169. *
  3170. *------------------------------------------
  3171. */
  3172. int atcommand_memo(
  3173. const int fd, struct map_session_data* sd,
  3174. const char* command, const char* message)
  3175. {
  3176. int position = 0;
  3177. char output[200];
  3178. nullpo_retr(-1, sd);
  3179. memset(output, '\0', sizeof(output));
  3180. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3181. atcommand_memo_sub(sd);
  3182. else {
  3183. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3184. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3185. clif_displaymessage(fd, "You are not authorised to memo this map.");
  3186. return -1;
  3187. }
  3188. if (sd->status.memo_point[position].map[0]) {
  3189. sprintf(output, msg_table[172], position, sd->status.memo_point[position].map, sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
  3190. clif_displaymessage(fd, output);
  3191. }
  3192. memcpy(sd->status.memo_point[position].map, map[sd->bl.m].name, 24);
  3193. sd->status.memo_point[position].x = sd->bl.x;
  3194. sd->status.memo_point[position].y = sd->bl.y;
  3195. clif_skill_memo(sd, 0);
  3196. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3197. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3198. atcommand_memo_sub(sd);
  3199. } else {
  3200. sprintf(output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3201. clif_displaymessage(fd, output);
  3202. atcommand_memo_sub(sd);
  3203. return -1;
  3204. }
  3205. }
  3206. return 0;
  3207. }
  3208. /*==========================================
  3209. *
  3210. *------------------------------------------
  3211. */
  3212. int atcommand_gat(
  3213. const int fd, struct map_session_data* sd,
  3214. const char* command, const char* message)
  3215. {
  3216. char output[200];
  3217. int y;
  3218. nullpo_retr(-1, sd);
  3219. memset(output, '\0', sizeof(output));
  3220. for (y = 2; y >= -2; y--) {
  3221. sprintf(output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3222. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3223. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y),
  3224. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y),
  3225. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y),
  3226. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y),
  3227. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y));
  3228. clif_displaymessage(fd, output);
  3229. }
  3230. return 0;
  3231. }
  3232. /*==========================================
  3233. *
  3234. *------------------------------------------
  3235. */
  3236. int atcommand_packet(
  3237. const int fd, struct map_session_data* sd,
  3238. const char* command, const char* message)
  3239. {
  3240. int x = 0, y = 0;
  3241. nullpo_retr(-1, sd);
  3242. if (!message || !*message || sscanf(message, "%d %d", &x, &y) < 2) {
  3243. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3244. return -1;
  3245. }
  3246. clif_status_change(&sd->bl, x, y);
  3247. return 0;
  3248. }
  3249. /*==========================================
  3250. * @stpoint (Rewritten by [Yor])
  3251. *------------------------------------------
  3252. */
  3253. int atcommand_statuspoint(
  3254. const int fd, struct map_session_data* sd,
  3255. const char* command, const char* message)
  3256. {
  3257. int point, new_status_point;
  3258. if (!message || !*message || (point = atoi(message)) == 0) {
  3259. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3260. return -1;
  3261. }
  3262. new_status_point = (int)sd->status.status_point + point;
  3263. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3264. new_status_point = 0x7FFF;
  3265. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3266. new_status_point = 0;
  3267. if (new_status_point != (int)sd->status.status_point) {
  3268. sd->status.status_point = (short)new_status_point;
  3269. clif_updatestatus(sd, SP_STATUSPOINT);
  3270. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3271. } else {
  3272. if (point < 0)
  3273. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3274. else
  3275. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3276. return -1;
  3277. }
  3278. return 0;
  3279. }
  3280. /*==========================================
  3281. * @skpoint (Rewritten by [Yor])
  3282. *------------------------------------------
  3283. */
  3284. int atcommand_skillpoint(
  3285. const int fd, struct map_session_data* sd,
  3286. const char* command, const char* message)
  3287. {
  3288. int point, new_skill_point;
  3289. nullpo_retr(-1, sd);
  3290. if (!message || !*message || (point = atoi(message)) == 0) {
  3291. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3292. return -1;
  3293. }
  3294. new_skill_point = (int)sd->status.skill_point + point;
  3295. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3296. new_skill_point = 0x7FFF;
  3297. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3298. new_skill_point = 0;
  3299. if (new_skill_point != (int)sd->status.skill_point) {
  3300. sd->status.skill_point = (short)new_skill_point;
  3301. clif_updatestatus(sd, SP_SKILLPOINT);
  3302. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3303. } else {
  3304. if (point < 0)
  3305. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3306. else
  3307. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3308. return -1;
  3309. }
  3310. return 0;
  3311. }
  3312. /*==========================================
  3313. * @zeny (Rewritten by [Yor])
  3314. *------------------------------------------
  3315. */
  3316. int atcommand_zeny(
  3317. const int fd, struct map_session_data* sd,
  3318. const char* command, const char* message)
  3319. {
  3320. int zeny, new_zeny;
  3321. nullpo_retr(-1, sd);
  3322. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3323. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3324. return -1;
  3325. }
  3326. new_zeny = sd->status.zeny + zeny;
  3327. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3328. new_zeny = MAX_ZENY;
  3329. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3330. new_zeny = 0;
  3331. if (new_zeny != sd->status.zeny) {
  3332. sd->status.zeny = new_zeny;
  3333. clif_updatestatus(sd, SP_ZENY);
  3334. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3335. } else {
  3336. if (zeny < 0)
  3337. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3338. else
  3339. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3340. return -1;
  3341. }
  3342. return 0;
  3343. }
  3344. /*==========================================
  3345. *
  3346. *------------------------------------------
  3347. */
  3348. int atcommand_param(
  3349. const int fd, struct map_session_data* sd,
  3350. const char* command, const char* message)
  3351. {
  3352. int i, index, value = 0, new_value;
  3353. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3354. short* status[] = {
  3355. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3356. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3357. };
  3358. char output[200];
  3359. nullpo_retr(-1, sd);
  3360. memset(output, '\0', sizeof(output));
  3361. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3362. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3363. clif_displaymessage(fd, output);
  3364. return -1;
  3365. }
  3366. index = -1;
  3367. for (i = 0; param[i] != NULL; i++) {
  3368. if (strcmpi(command, param[i]) == 0) {
  3369. index = i;
  3370. break;
  3371. }
  3372. }
  3373. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3374. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3375. clif_displaymessage(fd, output);
  3376. return -1;
  3377. }
  3378. new_value = (int)*status[index] + value;
  3379. if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
  3380. new_value = battle_config.max_parameter;
  3381. else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3382. new_value = 1;
  3383. if (new_value != (int)*status[index]) {
  3384. *status[index] = new_value;
  3385. clif_updatestatus(sd, SP_STR + index);
  3386. clif_updatestatus(sd, SP_USTR + index);
  3387. pc_calcstatus(sd, 0);
  3388. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3389. } else {
  3390. if (value < 0)
  3391. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3392. else
  3393. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3394. return -1;
  3395. }
  3396. return 0;
  3397. }
  3398. /*==========================================
  3399. *
  3400. *------------------------------------------
  3401. */
  3402. //** Stat all by fritz (rewritten by [Yor])
  3403. int atcommand_stat_all(
  3404. const int fd, struct map_session_data* sd,
  3405. const char* command, const char* message)
  3406. {
  3407. int index, count, value = 0, new_value;
  3408. short* status[] = {
  3409. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3410. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3411. };
  3412. nullpo_retr(-1, sd);
  3413. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3414. value = battle_config.max_parameter;
  3415. count = 0;
  3416. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3417. new_value = (int)*status[index] + value;
  3418. if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
  3419. new_value = battle_config.max_parameter;
  3420. else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3421. new_value = 1;
  3422. if (new_value != (int)*status[index]) {
  3423. *status[index] = new_value;
  3424. clif_updatestatus(sd, SP_STR + index);
  3425. clif_updatestatus(sd, SP_USTR + index);
  3426. pc_calcstatus(sd, 0);
  3427. count++;
  3428. }
  3429. }
  3430. if (count > 0) // if at least 1 stat modified
  3431. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3432. else {
  3433. if (value < 0)
  3434. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3435. else
  3436. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3437. return -1;
  3438. }
  3439. return 0;
  3440. }
  3441. /*==========================================
  3442. *
  3443. *------------------------------------------
  3444. */
  3445. int atcommand_guildlevelup(
  3446. const int fd, struct map_session_data* sd,
  3447. const char* command, const char* message)
  3448. {
  3449. int level = 0;
  3450. short added_level;
  3451. struct guild *guild_info;
  3452. nullpo_retr(-1, sd);
  3453. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3454. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3455. return -1;
  3456. }
  3457. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3458. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3459. return -1;
  3460. }
  3461. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3462. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3463. return -1;
  3464. }
  3465. added_level = (short)level;
  3466. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3467. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3468. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3469. added_level = 1 - guild_info->guild_lv;
  3470. if (added_level != 0) {
  3471. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3472. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3473. } else {
  3474. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3475. return -1;
  3476. }
  3477. return 0;
  3478. }
  3479. /*==========================================
  3480. *
  3481. *------------------------------------------
  3482. */
  3483. int atcommand_makeegg(
  3484. const int fd, struct map_session_data* sd,
  3485. const char* command, const char* message)
  3486. {
  3487. struct item_data *item_data;
  3488. int id, pet_id;
  3489. nullpo_retr(-1, sd);
  3490. if (!message || !*message) {
  3491. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3492. return -1;
  3493. }
  3494. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3495. id = item_data->nameid;
  3496. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3497. id = atoi(message);
  3498. pet_id = search_petDB_index(id, PET_CLASS);
  3499. if (pet_id < 0)
  3500. pet_id = search_petDB_index(id, PET_EGG);
  3501. if (pet_id >= 0) {
  3502. sd->catch_target_class = pet_db[pet_id].class;
  3503. intif_create_pet(
  3504. sd->status.account_id, sd->status.char_id,
  3505. pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
  3506. pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
  3507. 100, 0, 1, pet_db[pet_id].jname);
  3508. } else {
  3509. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3510. return -1;
  3511. }
  3512. return 0;
  3513. }
  3514. /*==========================================
  3515. *
  3516. *------------------------------------------
  3517. */
  3518. int atcommand_hatch(
  3519. const int fd, struct map_session_data* sd,
  3520. const char* command, const char* message)
  3521. {
  3522. nullpo_retr(-1, sd);
  3523. if (sd->status.pet_id <= 0)
  3524. clif_sendegg(sd);
  3525. else {
  3526. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3527. return -1;
  3528. }
  3529. return 0;
  3530. }
  3531. /*==========================================
  3532. *
  3533. *------------------------------------------
  3534. */
  3535. int atcommand_petfriendly(
  3536. const int fd, struct map_session_data* sd,
  3537. const char* command, const char* message)
  3538. {
  3539. int friendly;
  3540. int t;
  3541. nullpo_retr(-1, sd);
  3542. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3543. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3544. return -1;
  3545. }
  3546. if (sd->status.pet_id > 0 && sd->pd) {
  3547. if (friendly >= 0 && friendly <= 1000) {
  3548. if (friendly != sd->pet.intimate) {
  3549. t = sd->pet.intimate;
  3550. sd->pet.intimate = friendly;
  3551. clif_send_petstatus(sd);
  3552. if (battle_config.pet_status_support) {
  3553. if ((sd->pet.intimate > 0 && t <= 0) ||
  3554. (sd->pet.intimate <= 0 && t > 0)) {
  3555. if (sd->bl.prev != NULL)
  3556. pc_calcstatus(sd, 0);
  3557. else
  3558. pc_calcstatus(sd, 2);
  3559. }
  3560. }
  3561. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3562. } else {
  3563. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3564. return -1;
  3565. }
  3566. } else {
  3567. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3568. return -1;
  3569. }
  3570. } else {
  3571. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3572. return -1;
  3573. }
  3574. return 0;
  3575. }
  3576. /*==========================================
  3577. *
  3578. *------------------------------------------
  3579. */
  3580. int atcommand_pethungry(
  3581. const int fd, struct map_session_data* sd,
  3582. const char* command, const char* message)
  3583. {
  3584. int hungry;
  3585. nullpo_retr(-1, sd);
  3586. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3587. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3588. return -1;
  3589. }
  3590. if (sd->status.pet_id > 0 && sd->pd) {
  3591. if (hungry >= 0 && hungry <= 100) {
  3592. if (hungry != sd->pet.hungry) {
  3593. sd->pet.hungry = hungry;
  3594. clif_send_petstatus(sd);
  3595. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3596. } else {
  3597. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3598. return -1;
  3599. }
  3600. } else {
  3601. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3602. return -1;
  3603. }
  3604. } else {
  3605. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3606. return -1;
  3607. }
  3608. return 0;
  3609. }
  3610. /*==========================================
  3611. *
  3612. *------------------------------------------
  3613. */
  3614. int atcommand_petrename(
  3615. const int fd, struct map_session_data* sd,
  3616. const char* command, const char* message)
  3617. {
  3618. nullpo_retr(-1, sd);
  3619. if (sd->status.pet_id > 0 && sd->pd) {
  3620. if (sd->pet.rename_flag != 0) {
  3621. sd->pet.rename_flag = 0;
  3622. intif_save_petdata(sd->status.account_id, &sd->pet);
  3623. clif_send_petstatus(sd);
  3624. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3625. } else {
  3626. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3627. return -1;
  3628. }
  3629. } else {
  3630. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3631. return -1;
  3632. }
  3633. return 0;
  3634. }
  3635. /*==========================================
  3636. *
  3637. *------------------------------------------
  3638. */
  3639. int
  3640. atcommand_recall(
  3641. const int fd, struct map_session_data* sd,
  3642. const char* command, const char* message)
  3643. {
  3644. char character[100];
  3645. char output[200];
  3646. struct map_session_data *pl_sd = NULL;
  3647. nullpo_retr(-1, sd);
  3648. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3649. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3650. return -1;
  3651. }
  3652. memset(character, '\0', sizeof character);
  3653. if(sscanf(message, "%99[^\n]", character) < 1)
  3654. return -1;
  3655. if(strncmp(sd->status.name,character,24)==0)
  3656. return -1;
  3657. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3658. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3659. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3660. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3661. return -1;
  3662. }
  3663. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3664. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  3665. return -1;
  3666. }
  3667. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  3668. sprintf(output, msg_table[46], character); // %s recalled!
  3669. clif_displaymessage(fd, output);
  3670. } else {
  3671. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3672. return -1;
  3673. }
  3674. } else {
  3675. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3676. return -1;
  3677. }
  3678. return 0;
  3679. }
  3680. /*==========================================
  3681. *
  3682. *------------------------------------------
  3683. */
  3684. int atcommand_revive(
  3685. const int fd, struct map_session_data* sd,
  3686. const char* command, const char* message)
  3687. {
  3688. char character[100];
  3689. struct map_session_data *pl_sd;
  3690. nullpo_retr(-1, sd);
  3691. memset(character, '\0', sizeof(character));
  3692. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3693. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3694. return -1;
  3695. }
  3696. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3697. if (pc_isdead(pl_sd)) {
  3698. pl_sd->status.hp = pl_sd->status.max_hp;
  3699. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3700. pc_setstand(pl_sd);
  3701. if (battle_config.pc_invincible_time > 0)
  3702. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3703. clif_updatestatus(pl_sd, SP_HP);
  3704. clif_updatestatus(pl_sd, SP_SP);
  3705. clif_resurrection(&pl_sd->bl, 1);
  3706. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3707. return 0;
  3708. }
  3709. return -1;
  3710. } else {
  3711. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3712. return -1;
  3713. }
  3714. return 0;
  3715. }
  3716. /*==========================================
  3717. * charchangesex command (usage: charchangesex <player_name>)
  3718. *------------------------------------------
  3719. */
  3720. int atcommand_char_change_sex(
  3721. const int fd, struct map_session_data* sd,
  3722. const char* command, const char* message)
  3723. {
  3724. char character[100];
  3725. nullpo_retr(-1, sd);
  3726. memset(character, '\0', sizeof(character));
  3727. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3728. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  3729. return -1;
  3730. }
  3731. // check player name
  3732. if (strlen(character) < 4) {
  3733. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3734. return -1;
  3735. } else if (strlen(character) > 23) {
  3736. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3737. return -1;
  3738. } else {
  3739. chrif_char_ask_name(sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
  3740. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3741. }
  3742. return 0;
  3743. }
  3744. /*==========================================
  3745. * charblock command (usage: charblock <player_name>)
  3746. * This command do a definitiv ban on a player
  3747. *------------------------------------------
  3748. */
  3749. int atcommand_char_block(
  3750. const int fd, struct map_session_data* sd,
  3751. const char* command, const char* message)
  3752. {
  3753. char character[100];
  3754. nullpo_retr(-1, sd);
  3755. memset(character, '\0', sizeof(character));
  3756. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3757. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3758. return -1;
  3759. }
  3760. // check player name
  3761. if (strlen(character) < 4) {
  3762. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3763. return -1;
  3764. } else if (strlen(character) > 23) {
  3765. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3766. return -1;
  3767. } else {
  3768. chrif_char_ask_name(sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3769. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3770. }
  3771. return 0;
  3772. }
  3773. /*==========================================
  3774. * charban command (usage: charban <time> <player_name>)
  3775. * This command do a limited ban on a player
  3776. * Time is done as follows:
  3777. * Adjustment value (-1, 1, +1, etc...)
  3778. * Modified element:
  3779. * a or y: year
  3780. * m: month
  3781. * j or d: day
  3782. * h: hour
  3783. * mn: minute
  3784. * s: second
  3785. * <example> @ban +1m-2mn1s-6y test_player
  3786. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3787. *------------------------------------------
  3788. */
  3789. int atcommand_char_ban(
  3790. const int fd, struct map_session_data* sd,
  3791. const char* command, const char* message)
  3792. {
  3793. char modif[100], character[100];
  3794. char * modif_p;
  3795. int year, month, day, hour, minute, second, value;
  3796. nullpo_retr(-1, sd);
  3797. memset(modif, '\0', sizeof(modif));
  3798. memset(character, '\0', sizeof(character));
  3799. if (!message || !*message || sscanf(message, "%s %99[^\n]", modif, character) < 2) {
  3800. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3801. return -1;
  3802. }
  3803. modif[sizeof(modif)-1] = '\0';
  3804. character[sizeof(character)-1] = '\0';
  3805. modif_p = modif;
  3806. year = month = day = hour = minute = second = 0;
  3807. while (modif_p[0] != '\0') {
  3808. value = atoi(modif_p);
  3809. if (value == 0)
  3810. modif_p++;
  3811. else {
  3812. if (modif_p[0] == '-' || modif_p[0] == '+')
  3813. modif_p++;
  3814. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3815. modif_p++;
  3816. if (modif_p[0] == 's') {
  3817. second = value;
  3818. modif_p++;
  3819. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3820. minute = value;
  3821. modif_p = modif_p + 2;
  3822. } else if (modif_p[0] == 'h') {
  3823. hour = value;
  3824. modif_p++;
  3825. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3826. day = value;
  3827. modif_p++;
  3828. } else if (modif_p[0] == 'm') {
  3829. month = value;
  3830. modif_p++;
  3831. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3832. year = value;
  3833. modif_p++;
  3834. } else if (modif_p[0] != '\0') {
  3835. modif_p++;
  3836. }
  3837. }
  3838. }
  3839. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3840. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  3841. return -1;
  3842. }
  3843. // check player name
  3844. if (strlen(character) < 4) {
  3845. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3846. return -1;
  3847. } else if (strlen(character) > 23) {
  3848. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3849. return -1;
  3850. } else {
  3851. chrif_char_ask_name(sd->status.account_id, character, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3852. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3853. }
  3854. return 0;
  3855. }
  3856. /*==========================================
  3857. * charunblock command (usage: charunblock <player_name>)
  3858. *------------------------------------------
  3859. */
  3860. int atcommand_char_unblock(
  3861. const int fd, struct map_session_data* sd,
  3862. const char* command, const char* message)
  3863. {
  3864. char character[100];
  3865. nullpo_retr(-1, sd);
  3866. memset(character, '\0', sizeof(character));
  3867. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3868. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3869. return -1;
  3870. }
  3871. // check player name
  3872. if (strlen(character) < 4) {
  3873. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3874. return -1;
  3875. } else if (strlen(character) > 23) {
  3876. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3877. return -1;
  3878. } else {
  3879. // send answer to login server via char-server
  3880. chrif_char_ask_name(sd->status.account_id, character, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3881. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3882. }
  3883. return 0;
  3884. }
  3885. /*==========================================
  3886. * charunban command (usage: charunban <player_name>)
  3887. *------------------------------------------
  3888. */
  3889. int atcommand_char_unban(
  3890. const int fd, struct map_session_data* sd,
  3891. const char* command, const char* message)
  3892. {
  3893. char character[100];
  3894. nullpo_retr(-1, sd);
  3895. memset(character, '\0', sizeof(character));
  3896. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3897. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3898. return -1;
  3899. }
  3900. // check player name
  3901. if (strlen(character) < 4) {
  3902. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3903. return -1;
  3904. } else if (strlen(character) > 23) {
  3905. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3906. return -1;
  3907. } else {
  3908. // send answer to login server via char-server
  3909. chrif_char_ask_name(sd->status.account_id, character, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3910. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3911. }
  3912. return 0;
  3913. }
  3914. /*==========================================
  3915. *
  3916. *------------------------------------------
  3917. */
  3918. int atcommand_night(
  3919. const int fd, struct map_session_data* sd,
  3920. const char* command, const char* message)
  3921. {
  3922. struct map_session_data *pl_sd;
  3923. int i;
  3924. nullpo_retr(-1, sd);
  3925. if (night_flag != 1) {
  3926. night_flag = 1; // 0=day, 1=night [Yor]
  3927. for(i = 0; i < fd_max; i++) {
  3928. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !map[sd->bl.m].flag.indoors) {
  3929. //pl_sd->opt2 |= STATE_BLIND;
  3930. //clif_changeoption(&pl_sd->bl);
  3931. if (battle_config.night_darkness_level > 0)
  3932. clif_specialeffect(&pl_sd->bl, 474 + battle_config.night_darkness_level, 0);
  3933. else {
  3934. //clif_specialeffect(&pl_sd->bl, 483, 0); // default darkness level
  3935. pl_sd->opt2 |= STATE_BLIND;
  3936. clif_changeoption(&pl_sd->bl);
  3937. }
  3938. clif_displaymessage(pl_sd->fd, msg_table[59]); // Night has fallen.
  3939. }
  3940. }
  3941. } else {
  3942. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  3943. return -1;
  3944. }
  3945. return 0;
  3946. }
  3947. /*==========================================
  3948. *
  3949. *------------------------------------------
  3950. */
  3951. int atcommand_day(
  3952. const int fd, struct map_session_data* sd,
  3953. const char* command, const char* message)
  3954. {
  3955. struct map_session_data *pl_sd;
  3956. int i;
  3957. nullpo_retr(-1, sd);
  3958. if (night_flag != 0) {
  3959. night_flag = 0; // 0=day, 1=night [Yor]
  3960. for(i = 0; i < fd_max; i++) {
  3961. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  3962. pl_sd->opt2 &= ~STATE_BLIND;
  3963. clif_changeoption(&pl_sd->bl);
  3964. clif_displaymessage(pl_sd->fd, msg_table[60]); // Day has arrived.
  3965. }
  3966. }
  3967. } else {
  3968. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  3969. return -1;
  3970. }
  3971. return 0;
  3972. }
  3973. /*==========================================
  3974. *
  3975. *------------------------------------------
  3976. */
  3977. int atcommand_doom(
  3978. const int fd, struct map_session_data* sd,
  3979. const char* command, const char* message)
  3980. {
  3981. struct map_session_data *pl_sd;
  3982. int i;
  3983. nullpo_retr(-1, sd);
  3984. clif_specialeffect(&sd->bl,450,2);
  3985. for(i = 0; i < fd_max; i++) {
  3986. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd &&
  3987. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  3988. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  3989. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  3990. }
  3991. }
  3992. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  3993. return 0;
  3994. }
  3995. /*==========================================
  3996. *
  3997. *------------------------------------------
  3998. */
  3999. int atcommand_doommap(
  4000. const int fd, struct map_session_data* sd,
  4001. const char* command, const char* message)
  4002. {
  4003. struct map_session_data *pl_sd;
  4004. int i;
  4005. nullpo_retr(-1, sd);
  4006. clif_specialeffect(&sd->bl,450,3);
  4007. for (i = 0; i < fd_max; i++) {
  4008. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd && sd->bl.m == pl_sd->bl.m &&
  4009. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4010. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4011. // clif_specialeffect(&pl_sd->bl,450,1);
  4012. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4013. }
  4014. }
  4015. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4016. return 0;
  4017. }
  4018. /*==========================================
  4019. *
  4020. *------------------------------------------
  4021. */
  4022. static void atcommand_raise_sub(struct map_session_data* sd)
  4023. {
  4024. if (sd && sd->state.auth && pc_isdead(sd)) {
  4025. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4026. sd->status.hp = sd->status.max_hp;
  4027. sd->status.sp = sd->status.max_sp;
  4028. pc_setstand(sd);
  4029. clif_updatestatus(sd, SP_HP);
  4030. clif_updatestatus(sd, SP_SP);
  4031. clif_resurrection(&sd->bl, 1);
  4032. if (battle_config.pc_invincible_time > 0)
  4033. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4034. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4035. }
  4036. }
  4037. /*==========================================
  4038. *
  4039. *------------------------------------------
  4040. */
  4041. int atcommand_raise(
  4042. const int fd, struct map_session_data* sd,
  4043. const char* command, const char* message)
  4044. {
  4045. int i;
  4046. nullpo_retr(-1, sd);
  4047. for (i = 0; i < fd_max; i++) {
  4048. if (session[i])
  4049. atcommand_raise_sub(session[i]->session_data);
  4050. }
  4051. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4052. return 0;
  4053. }
  4054. /*==========================================
  4055. *
  4056. *------------------------------------------
  4057. */
  4058. int atcommand_raisemap(
  4059. const int fd, struct map_session_data* sd,
  4060. const char* command, const char* message)
  4061. {
  4062. struct map_session_data *pl_sd;
  4063. int i;
  4064. nullpo_retr(-1, sd);
  4065. for (i = 0; i < fd_max; i++) {
  4066. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->bl.m == pl_sd->bl.m)
  4067. atcommand_raise_sub(pl_sd);
  4068. }
  4069. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4070. return 0;
  4071. }
  4072. /*==========================================
  4073. * atcommand_character_baselevel @charbaselvlで対象キャラのレベルを上げる
  4074. *------------------------------------------
  4075. */
  4076. int atcommand_character_baselevel(
  4077. const int fd, struct map_session_data* sd,
  4078. const char* command, const char* message)
  4079. {
  4080. struct map_session_data *pl_sd;
  4081. char character[100];
  4082. int level = 0, i;
  4083. nullpo_retr(-1, sd);
  4084. memset(character, '\0', sizeof(character));
  4085. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4086. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charbaselvl <#> <nickname>).");
  4087. return -1;
  4088. }
  4089. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4090. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  4091. if (level > 0) {
  4092. if (pl_sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  4093. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  4094. return 0;
  4095. } // End Addition
  4096. if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
  4097. level = battle_config.maximum_level - pl_sd->status.base_level;
  4098. for (i = 1; i <= level; i++)
  4099. pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5;
  4100. pl_sd->status.base_level += level;
  4101. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4102. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4103. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4104. pc_calcstatus(pl_sd, 0);
  4105. pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp);
  4106. clif_misceffect(&pl_sd->bl, 0);
  4107. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  4108. } else {
  4109. if (pl_sd->status.base_level == 1) {
  4110. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  4111. return -1;
  4112. }
  4113. if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) // fix negativ overflow
  4114. level = 1 - pl_sd->status.base_level;
  4115. if (pl_sd->status.status_point > 0) {
  4116. for (i = 0; i > level; i--)
  4117. pl_sd->status.status_point -= (pl_sd->status.base_level + i + 14) / 5;
  4118. if (pl_sd->status.status_point < 0)
  4119. pl_sd->status.status_point = 0;
  4120. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4121. } // to add: remove status points from stats
  4122. pl_sd->status.base_level += level;
  4123. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4124. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4125. pc_calcstatus(pl_sd, 0);
  4126. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  4127. }
  4128. } else {
  4129. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4130. return -1;
  4131. }
  4132. } else {
  4133. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4134. return -1;
  4135. }
  4136. return 0; //正常終了
  4137. }
  4138. /*==========================================
  4139. * atcommand_character_joblevel @charjoblvlで対象キャラのJobレベルを上げる
  4140. *------------------------------------------
  4141. */
  4142. int atcommand_character_joblevel(
  4143. const int fd, struct map_session_data* sd,
  4144. const char* command, const char* message)
  4145. {
  4146. struct map_session_data *pl_sd;
  4147. char character[100];
  4148. int max_level = 50, level = 0;
  4149. //転生や養子の場合の元の職業を算出する
  4150. struct pc_base_job pl_s_class;
  4151. nullpo_retr(-1, sd);
  4152. memset(character, '\0', sizeof(character));
  4153. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4154. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charjlvl <#> <nickname>).");
  4155. return -1;
  4156. }
  4157. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4158. pl_s_class = pc_calc_base_job(pl_sd->status.class);
  4159. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  4160. if (pl_s_class.job == 0)
  4161. max_level -= 40;
  4162. // super novices can go up to 99 [celest]
  4163. else if (pl_s_class.job == 23)
  4164. max_level += 49;
  4165. else if (pl_sd->status.class > 4007 && pl_sd->status.class < 4023)
  4166. max_level += 20;
  4167. if (level > 0) {
  4168. if (pl_sd->status.job_level == max_level) {
  4169. clif_displaymessage(fd, msg_table[67]); // Character's job level can't go any higher.
  4170. return -1;
  4171. }
  4172. if (pl_sd->status.job_level + level > max_level)
  4173. level = max_level - pl_sd->status.job_level;
  4174. pl_sd->status.job_level += level;
  4175. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4176. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4177. pl_sd->status.skill_point += level;
  4178. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4179. pc_calcstatus(pl_sd, 0);
  4180. clif_misceffect(&pl_sd->bl, 1);
  4181. clif_displaymessage(fd, msg_table[68]); // character's job level raised.
  4182. } else {
  4183. if (pl_sd->status.job_level == 1) {
  4184. clif_displaymessage(fd, msg_table[194]); // Character's job level can't go any lower.
  4185. return -1;
  4186. }
  4187. if (pl_sd->status.job_level + level < 1)
  4188. level = 1 - pl_sd->status.job_level;
  4189. pl_sd->status.job_level += level;
  4190. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4191. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4192. if (pl_sd->status.skill_point > 0) {
  4193. pl_sd->status.skill_point += level;
  4194. if (pl_sd->status.skill_point < 0)
  4195. pl_sd->status.skill_point = 0;
  4196. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4197. } // to add: remove status points from skills
  4198. pc_calcstatus(pl_sd, 0);
  4199. clif_displaymessage(fd, msg_table[69]); // Character's job level lowered.
  4200. }
  4201. } else {
  4202. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4203. return -1;
  4204. }
  4205. } else {
  4206. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4207. return -1;
  4208. }
  4209. return 0;
  4210. }
  4211. /*==========================================
  4212. *
  4213. *------------------------------------------
  4214. */
  4215. int atcommand_kick(
  4216. const int fd, struct map_session_data* sd,
  4217. const char* command, const char* message)
  4218. {
  4219. struct map_session_data *pl_sd;
  4220. char character[100];
  4221. nullpo_retr(-1, sd);
  4222. memset(character, '\0', sizeof(character));
  4223. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4224. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4225. return -1;
  4226. }
  4227. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4228. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4229. clif_GM_kick(sd, pl_sd, 1);
  4230. else {
  4231. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4232. return -1;
  4233. }
  4234. } else {
  4235. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4236. return -1;
  4237. }
  4238. return 0;
  4239. }
  4240. /*==========================================
  4241. *
  4242. *------------------------------------------
  4243. */
  4244. int atcommand_kickall(
  4245. const int fd, struct map_session_data* sd,
  4246. const char* command, const char* message)
  4247. {
  4248. struct map_session_data *pl_sd;
  4249. int i;
  4250. nullpo_retr(-1, sd);
  4251. for (i = 0; i < fd_max; i++) {
  4252. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4253. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4254. if (sd->status.account_id != pl_sd->status.account_id)
  4255. clif_GM_kick(sd, pl_sd, 0);
  4256. }
  4257. }
  4258. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4259. return 0;
  4260. }
  4261. /*==========================================
  4262. *
  4263. *------------------------------------------
  4264. */
  4265. int atcommand_allskill(
  4266. const int fd, struct map_session_data* sd,
  4267. const char* command, const char* message)
  4268. {
  4269. nullpo_retr(-1, sd);
  4270. pc_allskillup(sd); // all skills
  4271. sd->status.skill_point = 0; // 0 skill points
  4272. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4273. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4274. return 0;
  4275. }
  4276. /*==========================================
  4277. *
  4278. *------------------------------------------
  4279. */
  4280. int atcommand_questskill(
  4281. const int fd, struct map_session_data* sd,
  4282. const char* command, const char* message)
  4283. {
  4284. int skill_id;
  4285. nullpo_retr(-1, sd);
  4286. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4287. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4288. return -1;
  4289. }
  4290. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4291. if (skill_get_inf2(skill_id) & 0x01) {
  4292. if (pc_checkskill(sd, skill_id) == 0) {
  4293. pc_skill(sd, skill_id, 1, 0);
  4294. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4295. } else {
  4296. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4297. return -1;
  4298. }
  4299. } else {
  4300. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4301. return -1;
  4302. }
  4303. } else {
  4304. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4305. return -1;
  4306. }
  4307. return 0;
  4308. }
  4309. /*==========================================
  4310. *
  4311. *------------------------------------------
  4312. */
  4313. int atcommand_charquestskill(
  4314. const int fd, struct map_session_data* sd,
  4315. const char* command, const char* message)
  4316. {
  4317. char character[100];
  4318. struct map_session_data *pl_sd;
  4319. int skill_id = 0;
  4320. nullpo_retr(-1, sd);
  4321. memset(character, '\0', sizeof(character));
  4322. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4323. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charquestskill <#:0+> <char_name>).");
  4324. return -1;
  4325. }
  4326. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4327. if (skill_get_inf2(skill_id) & 0x01) {
  4328. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4329. if (pc_checkskill(pl_sd, skill_id) == 0) {
  4330. pc_skill(pl_sd, skill_id, 1, 0);
  4331. clif_displaymessage(fd, msg_table[199]); // This player has learned the skill.
  4332. } else {
  4333. clif_displaymessage(fd, msg_table[200]); // This player already has this quest skill.
  4334. return -1;
  4335. }
  4336. } else {
  4337. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4338. return -1;
  4339. }
  4340. } else {
  4341. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4342. return -1;
  4343. }
  4344. } else {
  4345. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4346. return -1;
  4347. }
  4348. return 0;
  4349. }
  4350. /*==========================================
  4351. *
  4352. *------------------------------------------
  4353. */
  4354. int atcommand_lostskill(
  4355. const int fd, struct map_session_data* sd,
  4356. const char* command, const char* message)
  4357. {
  4358. int skill_id;
  4359. nullpo_retr(-1, sd);
  4360. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4361. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4362. return -1;
  4363. }
  4364. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4365. if (skill_get_inf2(skill_id) & 0x01) {
  4366. if (pc_checkskill(sd, skill_id) > 0) {
  4367. sd->status.skill[skill_id].lv = 0;
  4368. sd->status.skill[skill_id].flag = 0;
  4369. clif_skillinfoblock(sd);
  4370. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4371. } else {
  4372. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4373. return -1;
  4374. }
  4375. } else {
  4376. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4377. return -1;
  4378. }
  4379. } else {
  4380. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4381. return -1;
  4382. }
  4383. return 0;
  4384. }
  4385. /*==========================================
  4386. *
  4387. *------------------------------------------
  4388. */
  4389. int atcommand_charlostskill(
  4390. const int fd, struct map_session_data* sd,
  4391. const char* command, const char* message)
  4392. {
  4393. char character[100];
  4394. struct map_session_data *pl_sd;
  4395. int skill_id = 0;
  4396. nullpo_retr(-1, sd);
  4397. memset(character, '\0', sizeof(character));
  4398. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4399. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  4400. return -1;
  4401. }
  4402. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4403. if (skill_get_inf2(skill_id) & 0x01) {
  4404. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4405. if (pc_checkskill(pl_sd, skill_id) > 0) {
  4406. pl_sd->status.skill[skill_id].lv = 0;
  4407. pl_sd->status.skill[skill_id].flag = 0;
  4408. clif_skillinfoblock(pl_sd);
  4409. clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill.
  4410. } else {
  4411. clif_displaymessage(fd, msg_table[203]); // This player doesn't have this quest skill.
  4412. return -1;
  4413. }
  4414. } else {
  4415. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4416. return -1;
  4417. }
  4418. } else {
  4419. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4420. return -1;
  4421. }
  4422. } else {
  4423. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4424. return -1;
  4425. }
  4426. return 0;
  4427. }
  4428. /*==========================================
  4429. *
  4430. *------------------------------------------
  4431. */
  4432. int atcommand_spiritball(
  4433. const int fd, struct map_session_data* sd,
  4434. const char* command, const char* message)
  4435. {
  4436. int number;
  4437. nullpo_retr(-1, sd);
  4438. if (!message || !*message || (number = atoi(message)) < 0) {
  4439. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4440. return -1;
  4441. }
  4442. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4443. if (number > 500)
  4444. number = 500;
  4445. if (number >= 0 && number <= 0x7FFF) {
  4446. if (sd->spiritball != number || number > 499) {
  4447. if (sd->spiritball > 0)
  4448. pc_delspiritball(sd, sd->spiritball, 1);
  4449. sd->spiritball = number;
  4450. clif_spiritball(sd);
  4451. // no message, player can look the difference
  4452. if (number > 1000)
  4453. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4454. } else {
  4455. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4456. return -1;
  4457. }
  4458. } else {
  4459. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4460. return -1;
  4461. }
  4462. return 0;
  4463. }
  4464. /*==========================================
  4465. *
  4466. *------------------------------------------
  4467. */
  4468. int atcommand_party(
  4469. const int fd, struct map_session_data* sd,
  4470. const char* command, const char* message)
  4471. {
  4472. char party[100];
  4473. nullpo_retr(-1, sd);
  4474. memset(party, '\0', sizeof(party));
  4475. if (!message || !*message || sscanf(message, "%99[^\n]", party) < 1) {
  4476. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4477. return -1;
  4478. }
  4479. party_create(sd, party);
  4480. return 0;
  4481. }
  4482. /*==========================================
  4483. *
  4484. *------------------------------------------
  4485. */
  4486. int atcommand_guild(
  4487. const int fd, struct map_session_data* sd,
  4488. const char* command, const char* message)
  4489. {
  4490. char guild[100];
  4491. int prev;
  4492. nullpo_retr(-1, sd);
  4493. memset(guild, '\0', sizeof(guild));
  4494. if (!message || !*message || sscanf(message, "%99[^\n]", guild) < 1) {
  4495. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4496. return -1;
  4497. }
  4498. prev = battle_config.guild_emperium_check;
  4499. battle_config.guild_emperium_check = 0;
  4500. guild_create(sd, guild);
  4501. battle_config.guild_emperium_check = prev;
  4502. return 0;
  4503. }
  4504. /*==========================================
  4505. *
  4506. *------------------------------------------
  4507. */
  4508. int atcommand_agitstart(
  4509. const int fd, struct map_session_data* sd,
  4510. const char* command, const char* message)
  4511. {
  4512. nullpo_retr(-1, sd);
  4513. if (agit_flag == 1) {
  4514. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4515. return -1;
  4516. }
  4517. agit_flag = 1;
  4518. guild_agit_start();
  4519. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4520. return 0;
  4521. }
  4522. /*==========================================
  4523. *
  4524. *------------------------------------------
  4525. */
  4526. int atcommand_agitend(
  4527. const int fd, struct map_session_data* sd,
  4528. const char* command, const char* message)
  4529. {
  4530. nullpo_retr(-1, sd);
  4531. if (agit_flag == 0) {
  4532. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4533. return -1;
  4534. }
  4535. agit_flag = 0;
  4536. guild_agit_end();
  4537. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4538. return 0;
  4539. }
  4540. /*==========================================
  4541. * @mapexitでマップサーバーを終了させる
  4542. *------------------------------------------
  4543. */
  4544. int atcommand_mapexit(
  4545. const int fd, struct map_session_data* sd,
  4546. const char* command, const char* message)
  4547. {
  4548. struct map_session_data *pl_sd;
  4549. int i;
  4550. nullpo_retr(-1, sd);
  4551. for (i = 0; i < fd_max; i++) {
  4552. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4553. if (sd->status.account_id != pl_sd->status.account_id)
  4554. clif_GM_kick(sd, pl_sd, 0);
  4555. }
  4556. }
  4557. clif_GM_kick(sd, sd, 0);
  4558. runflag = 0;
  4559. return 0;
  4560. }
  4561. /*==========================================
  4562. * idsearch <part_of_name>: revrited by [Yor]
  4563. *------------------------------------------
  4564. */
  4565. int atcommand_idsearch(
  4566. const int fd, struct map_session_data* sd,
  4567. const char* command, const char* message)
  4568. {
  4569. char item_name[100];
  4570. char output[200];
  4571. int i, match;
  4572. struct item_data *item;
  4573. nullpo_retr(-1, sd);
  4574. memset(item_name, '\0', sizeof(item_name));
  4575. memset(output, '\0', sizeof(output));
  4576. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4577. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4578. return -1;
  4579. }
  4580. sprintf(output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4581. clif_displaymessage(fd, output);
  4582. match = 0;
  4583. for(i = 0; i < 20000; i++) {
  4584. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4585. match++;
  4586. sprintf(output, msg_table[78], item->jname, item->nameid); // %s: %d
  4587. clif_displaymessage(fd, output);
  4588. }
  4589. }
  4590. sprintf(output, msg_table[79], match); // It is %d affair above.
  4591. clif_displaymessage(fd, output);
  4592. return 0;
  4593. }
  4594. /*==========================================
  4595. * Character Skill Reset
  4596. *------------------------------------------
  4597. */
  4598. int atcommand_charskreset(
  4599. const int fd, struct map_session_data* sd,
  4600. const char* command, const char* message)
  4601. {
  4602. char character[100];
  4603. char output[200];
  4604. struct map_session_data *pl_sd;
  4605. nullpo_retr(-1, sd);
  4606. memset(character, '\0', sizeof(character));
  4607. memset(output, '\0', sizeof(output));
  4608. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4609. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  4610. return -1;
  4611. }
  4612. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4613. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  4614. pc_resetskill(pl_sd);
  4615. sprintf(output, msg_table[206], character); // '%s' skill points reseted!
  4616. clif_displaymessage(fd, output);
  4617. } else {
  4618. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4619. return -1;
  4620. }
  4621. } else {
  4622. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4623. return -1;
  4624. }
  4625. return 0;
  4626. }
  4627. /*==========================================
  4628. * Character Stat Reset
  4629. *------------------------------------------
  4630. */
  4631. int atcommand_charstreset(
  4632. const int fd, struct map_session_data* sd,
  4633. const char* command, const char* message)
  4634. {
  4635. char character[100];
  4636. char output[200];
  4637. struct map_session_data *pl_sd;
  4638. nullpo_retr(-1, sd);
  4639. memset(character, '\0', sizeof(character));
  4640. memset(output, '\0', sizeof(output));
  4641. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4642. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  4643. return -1;
  4644. }
  4645. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4646. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  4647. pc_resetstate(pl_sd);
  4648. sprintf(output, msg_table[207], character); // '%s' stats points reseted!
  4649. clif_displaymessage(fd, output);
  4650. } else {
  4651. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4652. return -1;
  4653. }
  4654. } else {
  4655. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4656. return -1;
  4657. }
  4658. return 0;
  4659. }
  4660. /*==========================================
  4661. * Character Model by chbrules
  4662. *------------------------------------------
  4663. */
  4664. int atcommand_charmodel(
  4665. const int fd, struct map_session_data* sd,
  4666. const char* command, const char* message)
  4667. {
  4668. int hair_style = 0, hair_color = 0, cloth_color = 0;
  4669. struct map_session_data *pl_sd;
  4670. char character[100];
  4671. char output[200];
  4672. nullpo_retr(-1, sd);
  4673. memset(character, '\0', sizeof(character));
  4674. memset(output, '\0', sizeof(output));
  4675. if (!message || !*message || sscanf(message, "%d %d %d %99[^\n]", &hair_style, &hair_color, &cloth_color, character) < 4 || hair_style < 0 || hair_color < 0 || cloth_color < 0) {
  4676. sprintf(output, "Please, enter a valid model and a player name (usage: @charmodel <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d> <name>).",
  4677. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  4678. clif_displaymessage(fd, output);
  4679. return -1;
  4680. }
  4681. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4682. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  4683. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  4684. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  4685. if (cloth_color != 0 &&
  4686. pl_sd->status.sex == 1 &&
  4687. (pl_sd->status.class == 12 || pl_sd->status.class == 17)) {
  4688. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  4689. return -1;
  4690. } else {
  4691. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  4692. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  4693. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  4694. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  4695. }
  4696. } else {
  4697. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4698. return -1;
  4699. }
  4700. } else {
  4701. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4702. return -1;
  4703. }
  4704. return 0;
  4705. }
  4706. /*==========================================
  4707. * Character Skill Point (Rewritten by [Yor])
  4708. *------------------------------------------
  4709. */
  4710. int atcommand_charskpoint(
  4711. const int fd, struct map_session_data* sd,
  4712. const char* command, const char* message)
  4713. {
  4714. struct map_session_data *pl_sd;
  4715. char character[100];
  4716. int new_skill_point;
  4717. int point = 0;
  4718. nullpo_retr(-1, sd);
  4719. memset(character, '\0', sizeof(character));
  4720. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4721. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  4722. return -1;
  4723. }
  4724. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4725. new_skill_point = (int)pl_sd->status.skill_point + point;
  4726. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  4727. new_skill_point = 0x7FFF;
  4728. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  4729. new_skill_point = 0;
  4730. if (new_skill_point != (int)pl_sd->status.skill_point) {
  4731. pl_sd->status.skill_point = new_skill_point;
  4732. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4733. clif_displaymessage(fd, msg_table[209]); // Character's number of skill points changed!
  4734. } else {
  4735. if (point < 0)
  4736. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4737. else
  4738. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4739. return -1;
  4740. }
  4741. } else {
  4742. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4743. return -1;
  4744. }
  4745. return 0;
  4746. }
  4747. /*==========================================
  4748. * Character Status Point (rewritten by [Yor])
  4749. *------------------------------------------
  4750. */
  4751. int atcommand_charstpoint(
  4752. const int fd, struct map_session_data* sd,
  4753. const char* command, const char* message)
  4754. {
  4755. struct map_session_data *pl_sd;
  4756. char character[100];
  4757. int new_status_point;
  4758. int point = 0;
  4759. nullpo_retr(-1, sd);
  4760. memset(character, '\0', sizeof(character));
  4761. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4762. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  4763. return -1;
  4764. }
  4765. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4766. new_status_point = (int)pl_sd->status.status_point + point;
  4767. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  4768. new_status_point = 0x7FFF;
  4769. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  4770. new_status_point = 0;
  4771. if (new_status_point != (int)pl_sd->status.status_point) {
  4772. pl_sd->status.status_point = new_status_point;
  4773. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4774. clif_displaymessage(fd, msg_table[210]); // Character's number of status points changed!
  4775. } else {
  4776. if (point < 0)
  4777. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4778. else
  4779. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4780. return -1;
  4781. }
  4782. } else {
  4783. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4784. return -1;
  4785. }
  4786. return 0;
  4787. }
  4788. /*==========================================
  4789. * Recall All Characters Online To Your Location
  4790. *------------------------------------------
  4791. */
  4792. int atcommand_recallall(
  4793. const int fd, struct map_session_data* sd,
  4794. const char* command, const char* message)
  4795. {
  4796. struct map_session_data *pl_sd;
  4797. int i;
  4798. int count;
  4799. char output[200];
  4800. nullpo_retr(-1, sd);
  4801. memset(output, '\0', sizeof(output));
  4802. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4803. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4804. return -1;
  4805. }
  4806. count = 0;
  4807. for (i = 0; i < fd_max; i++) {
  4808. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id &&
  4809. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4810. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4811. count++;
  4812. else
  4813. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4814. }
  4815. }
  4816. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4817. if (count) {
  4818. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4819. clif_displaymessage(fd, output);
  4820. }
  4821. return 0;
  4822. }
  4823. /*==========================================
  4824. * Recall online characters of a guild to your location
  4825. *------------------------------------------
  4826. */
  4827. int atcommand_guildrecall(
  4828. const int fd, struct map_session_data* sd,
  4829. const char* command, const char* message)
  4830. {
  4831. struct map_session_data *pl_sd;
  4832. int i;
  4833. char guild_name[100];
  4834. char output[200];
  4835. struct guild *g;
  4836. int count;
  4837. nullpo_retr(-1, sd);
  4838. memset(guild_name, '\0', sizeof(guild_name));
  4839. memset(output, '\0', sizeof(output));
  4840. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  4841. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4842. return -1;
  4843. }
  4844. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4845. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4846. return -1;
  4847. }
  4848. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4849. (g = guild_search(atoi(message))) != NULL) {
  4850. count = 0;
  4851. for (i = 0; i < fd_max; i++) {
  4852. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4853. sd->status.account_id != pl_sd->status.account_id &&
  4854. pl_sd->status.guild_id == g->guild_id) {
  4855. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4856. count++;
  4857. else
  4858. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4859. }
  4860. }
  4861. sprintf(output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4862. clif_displaymessage(fd, output);
  4863. if (count) {
  4864. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4865. clif_displaymessage(fd, output);
  4866. }
  4867. } else {
  4868. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4869. return -1;
  4870. }
  4871. return 0;
  4872. }
  4873. /*==========================================
  4874. * Recall online characters of a party to your location
  4875. *------------------------------------------
  4876. */
  4877. int atcommand_partyrecall(
  4878. const int fd, struct map_session_data* sd,
  4879. const char* command, const char* message)
  4880. {
  4881. int i;
  4882. struct map_session_data *pl_sd;
  4883. char party_name[100];
  4884. char output[200];
  4885. struct party *p;
  4886. int count;
  4887. nullpo_retr(-1, sd);
  4888. memset(party_name, '\0', sizeof(party_name));
  4889. memset(output, '\0', sizeof(output));
  4890. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  4891. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4892. return -1;
  4893. }
  4894. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4895. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4896. return -1;
  4897. }
  4898. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4899. (p = party_search(atoi(message))) != NULL) {
  4900. count = 0;
  4901. for (i = 0; i < fd_max; i++) {
  4902. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4903. sd->status.account_id != pl_sd->status.account_id &&
  4904. pl_sd->status.party_id == p->party_id) {
  4905. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4906. count++;
  4907. else
  4908. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4909. }
  4910. }
  4911. sprintf(output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4912. clif_displaymessage(fd, output);
  4913. if (count) {
  4914. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4915. clif_displaymessage(fd, output);
  4916. }
  4917. } else {
  4918. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4919. return -1;
  4920. }
  4921. return 0;
  4922. }
  4923. /*==========================================
  4924. *
  4925. *------------------------------------------
  4926. */
  4927. int atcommand_reloaditemdb(
  4928. const int fd, struct map_session_data* sd,
  4929. const char* command, const char* message)
  4930. {
  4931. nullpo_retr(-1, sd);
  4932. itemdb_reload();
  4933. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4934. return 0;
  4935. }
  4936. /*==========================================
  4937. *
  4938. *------------------------------------------
  4939. */
  4940. int atcommand_reloadmobdb(
  4941. const int fd, struct map_session_data* sd,
  4942. const char* command, const char* message)
  4943. {
  4944. nullpo_retr(-1, sd);
  4945. mob_reload();
  4946. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4947. return 0;
  4948. }
  4949. /*==========================================
  4950. *
  4951. *------------------------------------------
  4952. */
  4953. int atcommand_reloadskilldb(
  4954. const int fd, struct map_session_data* sd,
  4955. const char* command, const char* message)
  4956. {
  4957. nullpo_retr(-1, sd);
  4958. skill_reload();
  4959. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4960. return 0;
  4961. }
  4962. /*==========================================
  4963. *
  4964. *------------------------------------------
  4965. */
  4966. #ifndef TXT_ONLY
  4967. int atcommand_rehash(
  4968. #else /* TXT_ONLY */
  4969. int atcommand_reloadscript(
  4970. #endif /* TXT_ONLY */
  4971. const int fd, struct map_session_data* sd,
  4972. const char* command, const char* message)
  4973. {
  4974. nullpo_retr(-1, sd);
  4975. #ifndef TXT_ONLY
  4976. atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." );
  4977. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4978. rehash( fd, sd );
  4979. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4980. #endif /* not TXT_ONLY */
  4981. do_init_npc();
  4982. do_init_script();
  4983. npc_event_do_oninit();
  4984. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4985. return 0;
  4986. }
  4987. /*==========================================
  4988. *
  4989. *------------------------------------------
  4990. */
  4991. int atcommand_reloadgmdb( // by [Yor]
  4992. const int fd, struct map_session_data* sd,
  4993. const char* command, const char* message)
  4994. {
  4995. nullpo_retr(-1, sd);
  4996. chrif_reloadGMdb();
  4997. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4998. return 0;
  4999. }
  5000. /*==========================================
  5001. * @mapinfo <map name> [0-3] by MC_Cameri
  5002. * => Shows information about the map [map name]
  5003. * 0 = no additional information
  5004. * 1 = Show users in that map and their location
  5005. * 2 = Shows NPCs in that map
  5006. * 3 = Shows the shops/chats in that map (not implemented)
  5007. *------------------------------------------
  5008. */
  5009. int atcommand_mapinfo(
  5010. const int fd, struct map_session_data* sd,
  5011. const char* command, const char* message)
  5012. {
  5013. struct map_session_data *pl_sd;
  5014. struct npc_data *nd = NULL;
  5015. struct chat_data *cd = NULL;
  5016. char output[200], map_name[100];
  5017. char direction[12];
  5018. int m_id, i, chat_num, list = 0;
  5019. nullpo_retr(-1, sd);
  5020. memset(output, '\0', sizeof(output));
  5021. memset(map_name, '\0', sizeof(map_name));
  5022. memset(direction, '\0', sizeof(direction));
  5023. sscanf(message, "%d %99[^\n]", &list, map_name);
  5024. if (list < 0 || list > 3) {
  5025. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5026. return -1;
  5027. }
  5028. if (map_name[0] == '\0')
  5029. strcpy(map_name, sd->mapname);
  5030. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  5031. strcat(map_name, ".gat");
  5032. if ((m_id = map_mapname2mapid(map_name)) < 0) {
  5033. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5034. return -1;
  5035. }
  5036. clif_displaymessage(fd, "------ Map Info ------");
  5037. sprintf(output, "Map Name: %s", map_name);
  5038. clif_displaymessage(fd, output);
  5039. sprintf(output, "Players In Map: %d", map[m_id].users);
  5040. clif_displaymessage(fd, output);
  5041. sprintf(output, "NPCs In Map: %d", map[m_id].npc_num);
  5042. clif_displaymessage(fd, output);
  5043. chat_num = 0;
  5044. for (i = 0; i < fd_max; i++) {
  5045. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5046. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5047. chat_num++;
  5048. }
  5049. }
  5050. sprintf(output, "Chats In Map: %d", chat_num);
  5051. clif_displaymessage(fd, output);
  5052. clif_displaymessage(fd, "------ Map Flags ------");
  5053. sprintf(output, "Player vs Player: %s | No Guild: %s | No Party: %s",
  5054. (map[m_id].flag.pvp) ? "True" : "False",
  5055. (map[m_id].flag.pvp_noguild) ? "True" : "False",
  5056. (map[m_id].flag.pvp_noparty) ? "True" : "False");
  5057. clif_displaymessage(fd, output);
  5058. sprintf(output, "Guild vs Guild: %s | No Party: %s", (map[m_id].flag.gvg) ? "True" : "False", (map[m_id].flag.gvg_noparty) ? "True" : "False");
  5059. clif_displaymessage(fd, output);
  5060. sprintf(output, "No Dead Branch: %s", (map[m_id].flag.nobranch) ? "True" : "False");
  5061. clif_displaymessage(fd, output);
  5062. sprintf(output, "No Memo: %s", (map[m_id].flag.nomemo) ? "True" : "False");
  5063. clif_displaymessage(fd, output);
  5064. sprintf(output, "No Penalty: %s", (map[m_id].flag.nopenalty) ? "True" : "False");
  5065. clif_displaymessage(fd, output);
  5066. sprintf(output, "No Return: %s", (map[m_id].flag.noreturn) ? "True" : "False");
  5067. clif_displaymessage(fd, output);
  5068. sprintf(output, "No Save: %s", (map[m_id].flag.nosave) ? "True" : "False");
  5069. clif_displaymessage(fd, output);
  5070. sprintf(output, "No Teleport: %s", (map[m_id].flag.noteleport) ? "True" : "False");
  5071. clif_displaymessage(fd, output);
  5072. sprintf(output, "No Monster Teleport: %s", (map[m_id].flag.monster_noteleport) ? "True" : "False");
  5073. clif_displaymessage(fd, output);
  5074. sprintf(output, "No Zeny Penalty: %s", (map[m_id].flag.nozenypenalty) ? "True" : "False");
  5075. clif_displaymessage(fd, output);
  5076. switch (list) {
  5077. case 0:
  5078. // Do nothing. It's list 0, no additional display.
  5079. break;
  5080. case 1:
  5081. clif_displaymessage(fd, "----- Players in Map -----");
  5082. for (i = 0; i < fd_max; i++) {
  5083. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && strcmp(pl_sd->mapname, map_name) == 0) {
  5084. sprintf(output, "Player '%s' (session #%d) | Location: %d,%d",
  5085. pl_sd->status.name, i, pl_sd->bl.x, pl_sd->bl.y);
  5086. clif_displaymessage(fd, output);
  5087. }
  5088. }
  5089. break;
  5090. case 2:
  5091. clif_displaymessage(fd, "----- NPCs in Map -----");
  5092. for (i = 0; i < map[m_id].npc_num;) {
  5093. nd = map[m_id].npc[i];
  5094. switch(nd->dir) {
  5095. case 0: strcpy(direction, "North"); break;
  5096. case 1: strcpy(direction, "North West"); break;
  5097. case 2: strcpy(direction, "West"); break;
  5098. case 3: strcpy(direction, "South West"); break;
  5099. case 4: strcpy(direction, "South"); break;
  5100. case 5: strcpy(direction, "South East"); break;
  5101. case 6: strcpy(direction, "East"); break;
  5102. case 7: strcpy(direction, "North East"); break;
  5103. case 9: strcpy(direction, "North"); break;
  5104. default: strcpy(direction, "Unknown"); break;
  5105. }
  5106. sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5107. ++i, nd->name, direction, nd->class, nd->bl.x, nd->bl.y);
  5108. clif_displaymessage(fd, output);
  5109. }
  5110. break;
  5111. case 3:
  5112. clif_displaymessage(fd, "----- Chats in Map -----");
  5113. for (i = 0; i < fd_max; i++) {
  5114. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5115. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5116. strcmp(pl_sd->mapname, map_name) == 0 &&
  5117. cd->usersd[0] == pl_sd) {
  5118. sprintf(output, "Chat %d: %s | Player: %s | Location: %d %d",
  5119. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5120. clif_displaymessage(fd, output);
  5121. sprintf(output, " Users: %d/%d | Password: %s | Public: %s",
  5122. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5123. clif_displaymessage(fd, output);
  5124. }
  5125. }
  5126. break;
  5127. default: // normally impossible to arrive here
  5128. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5129. return -1;
  5130. break;
  5131. }
  5132. return 0;
  5133. }
  5134. /*==========================================
  5135. *
  5136. *------------------------------------------
  5137. */
  5138. int atcommand_mount_peco(
  5139. const int fd, struct map_session_data* sd,
  5140. const char* command, const char* message)
  5141. {
  5142. nullpo_retr(-1, sd);
  5143. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5144. clif_displaymessage(fd, msg_table[212]); // Cannot mount a Peco while in disguise.
  5145. return -1;
  5146. }
  5147. if (!pc_isriding(sd)) { // if actually no peco
  5148. if (sd->status.class == 7 || sd->status.class == 14 || sd->status.class == 4008 || sd->status.class == 4015) {
  5149. if (sd->status.class == 7)
  5150. sd->status.class = sd->view_class = 13;
  5151. else if (sd->status.class == 14)
  5152. sd->status.class = sd->view_class = 21;
  5153. else if (sd->status.class == 4008)
  5154. sd->status.class = sd->view_class = 4014;
  5155. else if (sd->status.class == 4015)
  5156. sd->status.class = sd->view_class = 4022;
  5157. pc_setoption(sd, sd->status.option | 0x0020);
  5158. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5159. } else {
  5160. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5161. return -1;
  5162. }
  5163. } else {
  5164. if (sd->status.class == 13)
  5165. sd->status.class = sd->view_class = 7;
  5166. else if (sd->status.class == 21)
  5167. sd->status.class = sd->view_class = 14;
  5168. else if (sd->status.class == 4014)
  5169. sd->status.class = sd->view_class = 4008;
  5170. else if (sd->status.class == 4022)
  5171. sd->status.class = sd->view_class = 4015;
  5172. pc_setoption(sd, sd->status.option & ~0x0020);
  5173. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5174. }
  5175. return 0;
  5176. }
  5177. /*==========================================
  5178. *
  5179. *------------------------------------------
  5180. */
  5181. int atcommand_char_mount_peco(
  5182. const int fd, struct map_session_data* sd,
  5183. const char* command, const char* message)
  5184. {
  5185. char character[100];
  5186. struct map_session_data *pl_sd;
  5187. nullpo_retr(-1, sd);
  5188. memset(character, '\0', sizeof(character));
  5189. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5190. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5191. return -1;
  5192. }
  5193. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5194. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5195. clif_displaymessage(fd, msg_table[215]); // This player cannot mount a Peco while in disguise.
  5196. return -1;
  5197. }
  5198. if (!pc_isriding(pl_sd)) { // if actually no peco
  5199. if (pl_sd->status.class == 7 || pl_sd->status.class == 14 || pl_sd->status.class == 4008 || pl_sd->status.class == 4015) {
  5200. if (pl_sd->status.class == 7)
  5201. pl_sd->status.class = pl_sd->view_class = 13;
  5202. else if (pl_sd->status.class == 14)
  5203. pl_sd->status.class = pl_sd->view_class = 21;
  5204. else if (pl_sd->status.class == 4008)
  5205. pl_sd->status.class = pl_sd->view_class = 4014;
  5206. else if (pl_sd->status.class == 4015)
  5207. pl_sd->status.class = pl_sd->view_class = 4022;
  5208. pc_setoption(pl_sd, pl_sd->status.option | 0x0020);
  5209. clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco.
  5210. } else {
  5211. clif_displaymessage(fd, msg_table[217]); // This player can not mount a peco with his/her job.
  5212. return -1;
  5213. }
  5214. } else {
  5215. if (pl_sd->status.class == 13)
  5216. pl_sd->status.class = pl_sd->view_class = 7;
  5217. else if (pl_sd->status.class == 21)
  5218. pl_sd->status.class = pl_sd->view_class = 14;
  5219. else if (pl_sd->status.class == 4014)
  5220. pl_sd->status.class = pl_sd->view_class = 4008;
  5221. else if (pl_sd->status.class == 4022)
  5222. pl_sd->status.class = pl_sd->view_class = 4015;
  5223. pc_setoption(pl_sd, pl_sd->status.option & ~0x0020);
  5224. clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco.
  5225. }
  5226. } else {
  5227. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5228. return -1;
  5229. }
  5230. return 0;
  5231. }
  5232. /*==========================================
  5233. *Spy Commands by Syrus22
  5234. *------------------------------------------
  5235. */
  5236. int atcommand_guildspy(
  5237. const int fd, struct map_session_data* sd,
  5238. const char* command, const char* message)
  5239. {
  5240. char guild_name[100];
  5241. char output[200];
  5242. struct guild *g;
  5243. nullpo_retr(-1, sd);
  5244. memset(guild_name, '\0', sizeof(guild_name));
  5245. memset(output, '\0', sizeof(output));
  5246. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  5247. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5248. return -1;
  5249. }
  5250. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5251. (g = guild_search(atoi(message))) != NULL) {
  5252. if (sd->guildspy == g->guild_id) {
  5253. sd->guildspy = 0;
  5254. sprintf(output, msg_table[103], g->name); // No longer spying on the %s guild.
  5255. clif_displaymessage(fd, output);
  5256. } else {
  5257. sd->guildspy = g->guild_id;
  5258. sprintf(output, msg_table[104], g->name); // Spying on the %s guild.
  5259. clif_displaymessage(fd, output);
  5260. }
  5261. } else {
  5262. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5263. return -1;
  5264. }
  5265. return 0;
  5266. }
  5267. /*==========================================
  5268. *
  5269. *------------------------------------------
  5270. */
  5271. int atcommand_partyspy(
  5272. const int fd, struct map_session_data* sd,
  5273. const char* command, const char* message)
  5274. {
  5275. char party_name[100];
  5276. char output[200];
  5277. struct party *p;
  5278. nullpo_retr(-1, sd);
  5279. memset(party_name, '\0', sizeof(party_name));
  5280. memset(output, '\0', sizeof(output));
  5281. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  5282. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5283. return -1;
  5284. }
  5285. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5286. (p = party_search(atoi(message))) != NULL) {
  5287. if (sd->partyspy == p->party_id) {
  5288. sd->partyspy = 0;
  5289. sprintf(output, msg_table[105], p->name); // No longer spying on the %s party.
  5290. clif_displaymessage(fd, output);
  5291. } else {
  5292. sd->partyspy = p->party_id;
  5293. sprintf(output, msg_table[106], p->name); // Spying on the %s party.
  5294. clif_displaymessage(fd, output);
  5295. }
  5296. } else {
  5297. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5298. return -1;
  5299. }
  5300. return 0;
  5301. }
  5302. /*==========================================
  5303. * @repairall [Valaris]
  5304. *------------------------------------------
  5305. */
  5306. int atcommand_repairall(
  5307. const int fd, struct map_session_data* sd,
  5308. const char* command, const char* message)
  5309. {
  5310. int count, i;
  5311. nullpo_retr(-1, sd);
  5312. count = 0;
  5313. for (i = 0; i < MAX_INVENTORY; i++) {
  5314. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5315. sd->status.inventory[i].attribute = 0;
  5316. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5317. count++;
  5318. }
  5319. }
  5320. if (count > 0) {
  5321. clif_misceffect(&sd->bl, 3);
  5322. clif_equiplist(sd);
  5323. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5324. } else {
  5325. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5326. return -1;
  5327. }
  5328. return 0;
  5329. }
  5330. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5331. int atcommand_nuke(
  5332. const int fd, struct map_session_data* sd,
  5333. const char* command, const char* message)
  5334. {
  5335. char character[100];
  5336. struct map_session_data *pl_sd;
  5337. nullpo_retr(-1, sd);
  5338. memset(character, '\0', sizeof(character));
  5339. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5340. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5341. return -1;
  5342. }
  5343. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5344. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5345. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5346. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5347. } else {
  5348. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5349. return -1;
  5350. }
  5351. } else {
  5352. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5353. return -1;
  5354. }
  5355. return 0;
  5356. }
  5357. /*==========================================
  5358. *
  5359. *------------------------------------------
  5360. */
  5361. int atcommand_enablenpc(const int fd, struct map_session_data* sd,
  5362. const char* command, const char* message)
  5363. {
  5364. char NPCname[100];
  5365. nullpo_retr(-1, sd);
  5366. memset(NPCname, '\0', sizeof(NPCname));
  5367. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5368. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcon <NPC_name>).");
  5369. return -1;
  5370. }
  5371. if (npc_name2id(NPCname) != NULL) {
  5372. npc_enable(NPCname, 1);
  5373. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5374. } else {
  5375. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5376. return -1;
  5377. }
  5378. return 0;
  5379. }
  5380. /*==========================================
  5381. *
  5382. *------------------------------------------
  5383. */
  5384. int atcommand_disablenpc(const int fd, struct map_session_data* sd,
  5385. const char* command, const char* message)
  5386. {
  5387. char NPCname[100];
  5388. nullpo_retr(-1, sd);
  5389. memset(NPCname, '\0', sizeof(NPCname));
  5390. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5391. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5392. return -1;
  5393. }
  5394. if (npc_name2id(NPCname) != NULL) {
  5395. npc_enable(NPCname, 0);
  5396. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5397. } else {
  5398. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5399. return -1;
  5400. }
  5401. return 0;
  5402. }
  5403. /*==========================================
  5404. * time in txt for time command (by [Yor])
  5405. *------------------------------------------
  5406. */
  5407. char * txt_time(unsigned int duration) {
  5408. int days, hours, minutes, seconds;
  5409. char temp[256];
  5410. static char temp1[256];
  5411. memset(temp, '\0', sizeof(temp));
  5412. memset(temp1, '\0', sizeof(temp1));
  5413. if (duration < 0)
  5414. duration = 0;
  5415. days = duration / (60 * 60 * 24);
  5416. duration = duration - (60 * 60 * 24 * days);
  5417. hours = duration / (60 * 60);
  5418. duration = duration - (60 * 60 * hours);
  5419. minutes = duration / 60;
  5420. seconds = duration - (60 * minutes);
  5421. if (days < 2)
  5422. sprintf(temp, msg_table[219], days); // %d day
  5423. else
  5424. sprintf(temp, msg_table[220], days); // %d days
  5425. if (hours < 2)
  5426. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5427. else
  5428. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5429. if (minutes < 2)
  5430. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5431. else
  5432. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5433. if (seconds < 2)
  5434. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5435. else
  5436. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5437. return temp1;
  5438. }
  5439. /*==========================================
  5440. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5441. * Calculation management of GM modification (@day/@night GM commands) is done
  5442. *------------------------------------------
  5443. */
  5444. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5445. const char* command, const char* message)
  5446. {
  5447. struct TimerData * timer_data;
  5448. struct TimerData * timer_data2;
  5449. time_t time_server; // variable for number of seconds (used with time() function)
  5450. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5451. char temp[256];
  5452. nullpo_retr(-1, sd);
  5453. memset(temp, '\0', sizeof(temp));
  5454. time(&time_server); // get time in seconds since 1/1/1970
  5455. datetime = localtime(&time_server); // convert seconds in structure
  5456. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5457. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5458. clif_displaymessage(fd, temp);
  5459. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5460. if (night_flag == 0)
  5461. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5462. else
  5463. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5464. } else if (battle_config.night_duration == 0)
  5465. if (night_flag == 1) { // we start with night
  5466. timer_data = get_timer(day_timer_tid);
  5467. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5468. clif_displaymessage(fd, temp);
  5469. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5470. } else
  5471. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5472. else if (battle_config.day_duration == 0)
  5473. if (night_flag == 0) { // we start with day
  5474. timer_data = get_timer(night_timer_tid);
  5475. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5476. clif_displaymessage(fd, temp);
  5477. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5478. } else
  5479. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5480. else {
  5481. if (night_flag == 0) {
  5482. timer_data = get_timer(night_timer_tid);
  5483. timer_data2 = get_timer(day_timer_tid);
  5484. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5485. clif_displaymessage(fd, temp);
  5486. if (timer_data->tick > timer_data2->tick)
  5487. sprintf(temp, msg_table[237], txt_time((timer_data->interval - abs(timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5488. else
  5489. sprintf(temp, msg_table[237], txt_time(abs(timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in night for %s.
  5490. clif_displaymessage(fd, temp);
  5491. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5492. clif_displaymessage(fd, temp);
  5493. } else {
  5494. timer_data = get_timer(day_timer_tid);
  5495. timer_data2 = get_timer(night_timer_tid);
  5496. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5497. clif_displaymessage(fd, temp);
  5498. if (timer_data->tick > timer_data2->tick)
  5499. sprintf(temp, msg_table[239], txt_time((timer_data->interval - abs(timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5500. else
  5501. sprintf(temp, msg_table[239], txt_time(abs(timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5502. clif_displaymessage(fd, temp);
  5503. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5504. clif_displaymessage(fd, temp);
  5505. }
  5506. }
  5507. return 0;
  5508. }
  5509. /*==========================================
  5510. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5511. * removes <quantity> item from a character
  5512. * item can be equiped or not.
  5513. * Inspired from a old command created by RoVeRT
  5514. *------------------------------------------
  5515. */
  5516. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5517. const char* command, const char* message)
  5518. {
  5519. struct map_session_data *pl_sd;
  5520. char character[100];
  5521. char item_name[100];
  5522. int i, number = 0, item_id, item_position, count;
  5523. char output[200];
  5524. struct item_data *item_data;
  5525. nullpo_retr(-1, sd);
  5526. memset(character, '\0', sizeof(character));
  5527. memset(item_name, '\0', sizeof(item_name));
  5528. memset(output, '\0', sizeof(output));
  5529. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, character) < 3 || number < 1) {
  5530. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5531. return -1;
  5532. }
  5533. item_id = 0;
  5534. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5535. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5536. item_id = item_data->nameid;
  5537. if (item_id > 500) {
  5538. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5539. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5540. item_position = pc_search_inventory(pl_sd, item_id);
  5541. if (item_position >= 0) {
  5542. count = 0;
  5543. for(i = 0; i < number && item_position >= 0; i++) {
  5544. pc_delitem(pl_sd, item_position, 1, 0);
  5545. count++;
  5546. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5547. }
  5548. sprintf(output, msg_table[113], count); // %d item(s) removed by a GM.
  5549. clif_displaymessage(pl_sd->fd, output);
  5550. if (number == count)
  5551. sprintf(output, msg_table[114], count); // %d item(s) removed from the player.
  5552. else
  5553. sprintf(output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5554. clif_displaymessage(fd, output);
  5555. } else {
  5556. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5557. return -1;
  5558. }
  5559. } else {
  5560. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5561. return -1;
  5562. }
  5563. } else {
  5564. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5565. return -1;
  5566. }
  5567. } else {
  5568. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5569. return -1;
  5570. }
  5571. return 0;
  5572. }
  5573. /*==========================================
  5574. * @jail <char_name> by [Yor]
  5575. * Special warp! No check with nowarp and nowarpto flag
  5576. *------------------------------------------
  5577. */
  5578. int atcommand_jail(
  5579. const int fd, struct map_session_data* sd,
  5580. const char* command, const char* message)
  5581. {
  5582. char character[100];
  5583. struct map_session_data *pl_sd;
  5584. int x, y;
  5585. nullpo_retr(-1, sd);
  5586. memset(character, '\0', sizeof(character));
  5587. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5588. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5589. return -1;
  5590. }
  5591. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5592. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5593. switch(rand() % 2) {
  5594. case 0:
  5595. x = 24;
  5596. y = 75;
  5597. break;
  5598. default:
  5599. x = 49;
  5600. y = 75;
  5601. break;
  5602. }
  5603. if (pc_setpos(pl_sd, "sec_pri.gat", x, y, 3) == 0) {
  5604. pc_setsavepoint(pl_sd, "sec_pri.gat", x, y); // Save Char Respawn Point in the jail room [Lupus]
  5605. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5606. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5607. } else {
  5608. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5609. return -1;
  5610. }
  5611. } else {
  5612. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5613. return -1;
  5614. }
  5615. } else {
  5616. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5617. return -1;
  5618. }
  5619. return 0;
  5620. }
  5621. /*==========================================
  5622. * @unjail/@discharge <char_name> by [Yor]
  5623. * Special warp! No check with nowarp and nowarpto flag
  5624. *------------------------------------------
  5625. */
  5626. int atcommand_unjail(
  5627. const int fd, struct map_session_data* sd,
  5628. const char* command, const char* message)
  5629. {
  5630. char character[100];
  5631. struct map_session_data *pl_sd;
  5632. memset(character, '\0', sizeof(character));
  5633. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5634. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5635. return -1;
  5636. }
  5637. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5638. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5639. if (pl_sd->bl.m != map_mapname2mapid("sec_pri.gat")) {
  5640. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5641. return -1;
  5642. } else if (pc_setpos(pl_sd, "prontera.gat", 156, 191, 3) == 0) {
  5643. pc_setsavepoint(pl_sd, "prontera.gat", 156, 191); // Save char respawn point in Prontera
  5644. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5645. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5646. } else {
  5647. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5648. return -1;
  5649. }
  5650. } else {
  5651. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5652. return -1;
  5653. }
  5654. } else {
  5655. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5656. return -1;
  5657. }
  5658. return 0;
  5659. }
  5660. /*==========================================
  5661. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5662. *------------------------------------------
  5663. */
  5664. int atcommand_disguise(
  5665. const int fd, struct map_session_data* sd,
  5666. const char* command, const char* message)
  5667. {
  5668. int mob_id = 0;
  5669. nullpo_retr(-1, sd);
  5670. if (!message || !*message) {
  5671. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5672. return -1;
  5673. }
  5674. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5675. mob_id = atoi(message);
  5676. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5677. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5678. (mob_id >= 813 && mob_id <= 834) || // NPC
  5679. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5680. if (pc_isriding(sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5681. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5682. return -1;
  5683. }
  5684. sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5685. sd->disguise = mob_id;
  5686. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5687. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5688. } else {
  5689. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5690. return -1;
  5691. }
  5692. return 0;
  5693. }
  5694. /*==========================================
  5695. * @undisguise by [Yor]
  5696. *------------------------------------------
  5697. */
  5698. int atcommand_undisguise(
  5699. const int fd, struct map_session_data* sd,
  5700. const char* command, const char* message)
  5701. {
  5702. nullpo_retr(-1, sd);
  5703. if (sd->disguise) {
  5704. clif_clearchar(&sd->bl, 9);
  5705. sd->disguise = 0;
  5706. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5707. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5708. } else {
  5709. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5710. return -1;
  5711. }
  5712. return 0;
  5713. }
  5714. /*==========================================
  5715. * @broadcast by [Valaris]
  5716. *------------------------------------------
  5717. */
  5718. int atcommand_broadcast(
  5719. const int fd, struct map_session_data* sd,
  5720. const char* command, const char* message)
  5721. {
  5722. char output[200];
  5723. nullpo_retr(-1, sd);
  5724. memset(output, '\0', sizeof(output));
  5725. if (!message || !*message) {
  5726. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5727. return -1;
  5728. }
  5729. sprintf(output, "%s : %s", sd->status.name, message);
  5730. intif_GMmessage(output, strlen(output) + 1, 0);
  5731. return 0;
  5732. }
  5733. /*==========================================
  5734. * @localbroadcast by [Valaris]
  5735. *------------------------------------------
  5736. */
  5737. int atcommand_localbroadcast(
  5738. const int fd, struct map_session_data* sd,
  5739. const char* command, const char* message)
  5740. {
  5741. char output[200];
  5742. nullpo_retr(-1, sd);
  5743. memset(output, '\0', sizeof(output));
  5744. if (!message || !*message) {
  5745. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5746. return -1;
  5747. }
  5748. sprintf(output, "%s : %s", sd->status.name, message);
  5749. clif_GMmessage(&sd->bl, output, strlen(output) + 1, 1); // 1: ALL_SAMEMAP
  5750. return 0;
  5751. }
  5752. /*==========================================
  5753. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5754. *------------------------------------------
  5755. */
  5756. int atcommand_chardisguise(
  5757. const int fd, struct map_session_data* sd,
  5758. const char* command, const char* message)
  5759. {
  5760. int mob_id;
  5761. char character[100];
  5762. char mob_name[100];
  5763. struct map_session_data* pl_sd;
  5764. nullpo_retr(-1, sd);
  5765. memset(character, '\0', sizeof(character));
  5766. memset(mob_name, '\0', sizeof(mob_name));
  5767. if (!message || !*message || sscanf(message, "%s %99[^\n]", mob_name, character) < 2) {
  5768. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5769. return -1;
  5770. }
  5771. if ((mob_id = mobdb_searchname(mob_name)) == 0) // check name first (to avoid possible name begining by a number)
  5772. mob_id = atoi(mob_name);
  5773. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5774. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5775. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5776. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5777. (mob_id >= 813 && mob_id <= 834) || // NPC
  5778. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5779. if (pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5780. clif_displaymessage(fd, msg_table[228]); // Character cannot wear disguise while riding a Peco.
  5781. return -1;
  5782. }
  5783. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5784. pl_sd->disguise = mob_id;
  5785. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5786. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5787. } else {
  5788. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5789. return -1;
  5790. }
  5791. } else {
  5792. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5793. return -1;
  5794. }
  5795. } else {
  5796. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5797. return -1;
  5798. }
  5799. return 0;
  5800. }
  5801. /*==========================================
  5802. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5803. *------------------------------------------
  5804. */
  5805. int atcommand_charundisguise(
  5806. const int fd, struct map_session_data* sd,
  5807. const char* command, const char* message)
  5808. {
  5809. char character[100];
  5810. struct map_session_data* pl_sd;
  5811. nullpo_retr(-1, sd);
  5812. memset(character, '\0', sizeof(character));
  5813. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5814. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5815. return -1;
  5816. }
  5817. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5818. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5819. if (pl_sd->disguise) {
  5820. clif_clearchar(&pl_sd->bl, 9);
  5821. pl_sd->disguise = 0;
  5822. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5823. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5824. } else {
  5825. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5826. return -1;
  5827. }
  5828. } else {
  5829. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5830. return -1;
  5831. }
  5832. } else {
  5833. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5834. return -1;
  5835. }
  5836. return 0;
  5837. }
  5838. /*==========================================
  5839. * @email <actual@email> <new@email> by [Yor]
  5840. *------------------------------------------
  5841. */
  5842. int atcommand_email(
  5843. const int fd, struct map_session_data* sd,
  5844. const char* command, const char* message)
  5845. {
  5846. char actual_email[100];
  5847. char new_email[100];
  5848. nullpo_retr(-1, sd);
  5849. memset(actual_email, '\0', sizeof(actual_email));
  5850. memset(new_email, '\0', sizeof(new_email));
  5851. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5852. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5853. return -1;
  5854. }
  5855. if (e_mail_check(actual_email) == 0) {
  5856. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5857. return -1;
  5858. } else if (e_mail_check(new_email) == 0) {
  5859. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5860. return -1;
  5861. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5862. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5863. return -1;
  5864. } else if (strcmpi(actual_email, new_email) == 0) {
  5865. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5866. return -1;
  5867. } else {
  5868. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5869. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5870. }
  5871. return 0;
  5872. }
  5873. /*==========================================
  5874. *@effect
  5875. *------------------------------------------
  5876. */
  5877. int atcommand_effect(
  5878. const int fd, struct map_session_data* sd,
  5879. const char* command, const char* message)
  5880. {
  5881. struct map_session_data *pl_sd;
  5882. int type = 0, flag = 0, i;
  5883. nullpo_retr(-1, sd);
  5884. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5885. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5886. return -1;
  5887. }
  5888. if(flag <=0){
  5889. clif_specialeffect(&sd->bl, type, flag);
  5890. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5891. }
  5892. else{
  5893. for (i = 0; i < fd_max; i++) {
  5894. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  5895. clif_specialeffect(&pl_sd->bl, type, flag);
  5896. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5897. }
  5898. }
  5899. }
  5900. return 0;
  5901. }
  5902. /*==========================================
  5903. * @charcartlist <character>: Displays the items list of a player's cart.
  5904. *------------------------------------------
  5905. */
  5906. int
  5907. atcommand_character_cart_list(
  5908. const int fd, struct map_session_data* sd,
  5909. const char* command, const char* message)
  5910. {
  5911. struct map_session_data *pl_sd;
  5912. struct item_data *item_data, *item_temp;
  5913. int i, j, count, counter, counter2;
  5914. char character[100], output[200], outputtmp[200];
  5915. nullpo_retr(-1, sd);
  5916. memset(character, '\0', sizeof(character));
  5917. memset(output, '\0', sizeof(output));
  5918. memset(outputtmp, '\0', sizeof(outputtmp));
  5919. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5920. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5921. return -1;
  5922. }
  5923. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5924. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5925. counter = 0;
  5926. count = 0;
  5927. for (i = 0; i < MAX_CART; i++) {
  5928. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5929. counter = counter + pl_sd->status.cart[i].amount;
  5930. count++;
  5931. if (count == 1) {
  5932. sprintf(output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  5933. clif_displaymessage(fd, output);
  5934. }
  5935. if (pl_sd->status.cart[i].refine)
  5936. sprintf(output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  5937. else
  5938. sprintf(output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  5939. clif_displaymessage(fd, output);
  5940. memset(output, '\0', sizeof(output));
  5941. counter2 = 0;
  5942. for (j = 0; j < item_data->slot; j++) {
  5943. if (pl_sd->status.cart[i].card[j]) {
  5944. if ((item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  5945. if (output[0] == '\0')
  5946. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  5947. else
  5948. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  5949. strcat(output, outputtmp);
  5950. }
  5951. }
  5952. }
  5953. if (output[0] != '\0') {
  5954. output[strlen(output) - 2] = ')';
  5955. output[strlen(output) - 1] = '\0';
  5956. clif_displaymessage(fd, output);
  5957. }
  5958. }
  5959. }
  5960. if (count == 0)
  5961. clif_displaymessage(fd, "No item found in the cart of this player.");
  5962. else {
  5963. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  5964. clif_displaymessage(fd, output);
  5965. }
  5966. } else {
  5967. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5968. return -1;
  5969. }
  5970. } else {
  5971. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5972. return -1;
  5973. }
  5974. return 0;
  5975. }
  5976. /*==========================================
  5977. * @killer by MouseJstr
  5978. * enable killing players even when not in pvp
  5979. *------------------------------------------
  5980. */
  5981. int
  5982. atcommand_killer(
  5983. const int fd, struct map_session_data* sd,
  5984. const char* command, const char* message)
  5985. {
  5986. nullpo_retr(-1, sd);
  5987. sd->special_state.killer = !sd->special_state.killer;
  5988. if(sd->special_state.killer)
  5989. clif_displaymessage(fd, msg_table[241]);
  5990. else
  5991. clif_displaymessage(fd, msg_table[242]);
  5992. return 0;
  5993. }
  5994. /*==========================================
  5995. * @killable by MouseJstr
  5996. * enable other people killing you
  5997. *------------------------------------------
  5998. */
  5999. int
  6000. atcommand_killable(
  6001. const int fd, struct map_session_data* sd,
  6002. const char* command, const char* message)
  6003. {
  6004. nullpo_retr(-1, sd);
  6005. sd->special_state.killable = !sd->special_state.killable;
  6006. if(sd->special_state.killable)
  6007. clif_displaymessage(fd, msg_table[242]);
  6008. else
  6009. clif_displaymessage(fd, msg_table[241]);
  6010. return 0;
  6011. }
  6012. /*==========================================
  6013. * @charkillable by MouseJstr
  6014. * enable another player to be killed
  6015. *------------------------------------------
  6016. */
  6017. int
  6018. atcommand_charkillable(
  6019. const int fd, struct map_session_data* sd,
  6020. const char* command, const char* message)
  6021. {
  6022. struct map_session_data *pl_sd = NULL;
  6023. nullpo_retr(-1, sd);
  6024. if (!message || !*message)
  6025. return -1;
  6026. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6027. return -1;
  6028. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6029. if(pl_sd->special_state.killable)
  6030. clif_displaymessage(fd, "The player is now killable");
  6031. else
  6032. clif_displaymessage(fd, "The player is no longer killable");
  6033. return 0;
  6034. }
  6035. /*==========================================
  6036. * @skillon by MouseJstr
  6037. * turn skills on for the map
  6038. *------------------------------------------
  6039. */
  6040. int
  6041. atcommand_skillon(
  6042. const int fd, struct map_session_data* sd,
  6043. const char* command, const char* message)
  6044. {
  6045. nullpo_retr(-1, sd);
  6046. map[sd->bl.m].flag.noskill = 0;
  6047. clif_displaymessage(fd, msg_table[244]);
  6048. return 0;
  6049. }
  6050. /*==========================================
  6051. * @skilloff by MouseJstr
  6052. * Turn skills off on the map
  6053. *------------------------------------------
  6054. */
  6055. int
  6056. atcommand_skilloff(
  6057. const int fd, struct map_session_data* sd,
  6058. const char* command, const char* message)
  6059. {
  6060. nullpo_retr(-1, sd);
  6061. map[sd->bl.m].flag.noskill = 1;
  6062. clif_displaymessage(fd, msg_table[243]);
  6063. return 0;
  6064. }
  6065. /*==========================================
  6066. * @npcmove by MouseJstr
  6067. *
  6068. * move a npc
  6069. *------------------------------------------
  6070. */
  6071. int
  6072. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6073. const char* command, const char* message)
  6074. {
  6075. char character[100];
  6076. int x = 0, y = 0;
  6077. struct npc_data *nd = 0;
  6078. nullpo_retr(-1, sd);
  6079. if (!message || !*message)
  6080. return -1;
  6081. memset(character, '\0', sizeof character);
  6082. if (sscanf(message, "%d %d %99[^\n]", &x, &y, character) < 3) {
  6083. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6084. return -1;
  6085. }
  6086. nullpo_retr(-1, (nd = npc_name2id(character)));
  6087. npc_enable(character, 0);
  6088. nd->bl.x = x;
  6089. nd->bl.y = y;
  6090. npc_enable(character, 1);
  6091. return 0;
  6092. }
  6093. /*==========================================
  6094. * @addwarp by MouseJstr
  6095. *
  6096. * Create a new static warp point.
  6097. *------------------------------------------
  6098. */
  6099. int
  6100. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6101. const char* command, const char* message)
  6102. {
  6103. char w1[64], w3[64], w4[64];
  6104. char map[30], output[200];
  6105. int x,y,ret;
  6106. nullpo_retr(-1, sd);
  6107. if (!message || !*message)
  6108. return -1;
  6109. if (sscanf(message, "%99s %d %d[^\n]", map, &x, &y ) < 3)
  6110. return -1;
  6111. sprintf(w1,"%s,%d,%d", sd->mapname, sd->bl.x, sd->bl.y);
  6112. sprintf(w3,"%s%d%d%d%d", map,sd->bl.x, sd->bl.y, x, y);
  6113. sprintf(w4,"1,1,%s.gat,%d,%d", map, x, y);
  6114. ret = npc_parse_warp(w1, "warp", w3, w4);
  6115. sprintf(output, "New warp NPC => %s",w3);
  6116. clif_displaymessage(fd, output);
  6117. return ret;
  6118. }
  6119. /*==========================================
  6120. * @follow by [MouseJstr]
  6121. *
  6122. * Follow a player .. staying no more then 5 spaces away
  6123. *------------------------------------------
  6124. */
  6125. int
  6126. atcommand_follow(const int fd, struct map_session_data* sd,
  6127. const char* command, const char* message)
  6128. {
  6129. struct map_session_data *pl_sd = NULL;
  6130. nullpo_retr(-1, sd);
  6131. if (!message || !*message)
  6132. return -1;
  6133. if((pl_sd=map_nick2sd((char *) message)) != NULL)
  6134. pc_follow(sd, pl_sd->bl.id);
  6135. else
  6136. return 1;
  6137. return 0;
  6138. }
  6139. /*==========================================
  6140. * @dropall by [MouseJstr]
  6141. *
  6142. * Drop all your possession on the ground
  6143. *------------------------------------------
  6144. */
  6145. int
  6146. atcommand_dropall(const int fd, struct map_session_data* sd,
  6147. const char* command, const char* message)
  6148. {
  6149. int i;
  6150. nullpo_retr(-1, sd);
  6151. for (i = 0; i < MAX_INVENTORY; i++) {
  6152. if (sd->status.inventory[i].amount) {
  6153. if(sd->status.inventory[i].equip != 0)
  6154. pc_unequipitem(sd, i, 3);
  6155. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6156. }
  6157. }
  6158. return 0;
  6159. }
  6160. /*==========================================
  6161. * @chardropall by [MouseJstr]
  6162. *
  6163. * Throw all the characters possessions on the ground. Normally
  6164. * done in response to them being disrespectful of a GM
  6165. *------------------------------------------
  6166. */
  6167. int
  6168. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6169. const char* command, const char* message)
  6170. {
  6171. int i;
  6172. struct map_session_data *pl_sd = NULL;
  6173. nullpo_retr(-1, sd);
  6174. if (!message || !*message)
  6175. return -1;
  6176. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6177. return -1;
  6178. for (i = 0; i < MAX_INVENTORY; i++) {
  6179. if (pl_sd->status.inventory[i].amount) {
  6180. if(pl_sd->status.inventory[i].equip != 0)
  6181. pc_unequipitem(pl_sd, i, 3);
  6182. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6183. }
  6184. }
  6185. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6186. clif_displaymessage(fd, "It is done");
  6187. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6188. return 0;
  6189. }
  6190. /*==========================================
  6191. * @storeall by [MouseJstr]
  6192. *
  6193. * Put everything into storage to simplify your inventory to make
  6194. * debugging easie
  6195. *------------------------------------------
  6196. */
  6197. int
  6198. atcommand_storeall(const int fd, struct map_session_data* sd,
  6199. const char* command, const char* message)
  6200. {
  6201. int i;
  6202. nullpo_retr(-1, sd);
  6203. if (storage_storageopen(sd) == 1) {
  6204. clif_displaymessage(fd, "run this command again..");
  6205. return 0;
  6206. }
  6207. for (i = 0; i < MAX_INVENTORY; i++) {
  6208. if (sd->status.inventory[i].amount) {
  6209. if(sd->status.inventory[i].equip != 0)
  6210. pc_unequipitem(sd, i, 3);
  6211. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6212. }
  6213. }
  6214. storage_storageclose(sd);
  6215. clif_displaymessage(fd, "It is done");
  6216. return 0;
  6217. }
  6218. /*==========================================
  6219. * @charstoreall by [MouseJstr]
  6220. *
  6221. * A way to screw with players who piss you off
  6222. *------------------------------------------
  6223. */
  6224. int
  6225. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6226. const char* command, const char* message)
  6227. {
  6228. int i;
  6229. struct map_session_data *pl_sd = NULL;
  6230. nullpo_retr(-1, sd);
  6231. if (!message || !*message)
  6232. return -1;
  6233. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6234. return -1;
  6235. if (storage_storageopen(pl_sd) == 1) {
  6236. clif_displaymessage(fd, "Had to open the characters storage window...");
  6237. clif_displaymessage(fd, "run this command again..");
  6238. return 0;
  6239. }
  6240. for (i = 0; i < MAX_INVENTORY; i++) {
  6241. if (pl_sd->status.inventory[i].amount) {
  6242. if(pl_sd->status.inventory[i].equip != 0)
  6243. pc_unequipitem(pl_sd, i, 3);
  6244. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6245. }
  6246. }
  6247. storage_storageclose(pl_sd);
  6248. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6249. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6250. clif_displaymessage(pl_sd->fd, " -- the management");
  6251. clif_displaymessage(fd, "It is done");
  6252. return 0;
  6253. }
  6254. /*==========================================
  6255. * @skillid by [MouseJstr]
  6256. *
  6257. * lookup a skill by name
  6258. *------------------------------------------
  6259. */
  6260. int
  6261. atcommand_skillid(const int fd, struct map_session_data* sd,
  6262. const char* command, const char* message)
  6263. {
  6264. int skillen = 0, idx = 0;
  6265. nullpo_retr(-1, sd);
  6266. if (!message || !*message)
  6267. return -1;
  6268. skillen = strlen(message);
  6269. while (skill_names[idx].id != 0) {
  6270. if ((strnicmp(skill_names[idx].name, message, skillen) == 0) ||
  6271. (strnicmp(skill_names[idx].desc, message, skillen) == 0)) {
  6272. char output[255];
  6273. sprintf(output, "skill %d: %s", skill_names[idx].id, skill_names[idx].desc);
  6274. clif_displaymessage(fd, output);
  6275. }
  6276. idx++;
  6277. }
  6278. return 0;
  6279. }
  6280. /*==========================================
  6281. * @useskill by [MouseJstr]
  6282. *
  6283. * A way of using skills without having to find them in the skills menu
  6284. *------------------------------------------
  6285. */
  6286. int
  6287. atcommand_useskill(const int fd, struct map_session_data* sd,
  6288. const char* command, const char* message)
  6289. {
  6290. struct map_session_data *pl_sd = NULL;
  6291. int skillnum;
  6292. int skilllv;
  6293. int inf;
  6294. char target[255];
  6295. nullpo_retr(-1, sd);
  6296. if (!message || !*message)
  6297. return -1;
  6298. if(sscanf(message, "%d %d %s", &skillnum, &skilllv, target) != 3) {
  6299. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6300. return -1;
  6301. }
  6302. if((pl_sd=map_nick2sd(target)) == NULL) {
  6303. return -1;
  6304. }
  6305. inf = skill_get_inf(skillnum);
  6306. if ((inf == 2) || (inf == 1))
  6307. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6308. else
  6309. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6310. return 0;
  6311. }
  6312. /*==========================================
  6313. * @skilltree by [MouseJstr]
  6314. *
  6315. * prints the skill tree for a player required to get to a skill
  6316. *------------------------------------------
  6317. */
  6318. int
  6319. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6320. const char* command, const char* message)
  6321. {
  6322. struct map_session_data *pl_sd = NULL;
  6323. int skillnum, skillidx = -1;
  6324. int meets = 1, j, c=0, s=0;
  6325. struct pc_base_job s_class;
  6326. char target[255], *tbl;
  6327. char output[255];
  6328. struct skill_tree_entry *ent;
  6329. nullpo_retr(-1, sd);
  6330. if (!message || !*message)
  6331. return -1;
  6332. if(sscanf(message, "%d %[^\r\n]", &skillnum, target) != 2) {
  6333. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6334. return -1;
  6335. }
  6336. if((pl_sd=map_nick2sd(target)) == NULL)
  6337. return -1;
  6338. s_class = pc_calc_base_job(pl_sd->status.class);
  6339. c = s_class.job;
  6340. s = s_class.upper;
  6341. c = pc_calc_skilltree_normalize_job(c, pl_sd);
  6342. tbl = job_name(c);
  6343. sprintf(output, "Player is using %s %s skill tree (%d basic points)",
  6344. s_class.upper ? "upper" : "lower",
  6345. tbl, pc_checkskill(pl_sd, 1));
  6346. clif_displaymessage(fd, output);
  6347. for (j = 0; j < MAX_SKILL; j++) {
  6348. if (skill_tree[s][c][j].id == skillnum) {
  6349. skillidx = j;
  6350. break;
  6351. }
  6352. }
  6353. if (skillidx == -1) {
  6354. sprintf(output, "I do not believe the player can use that skill");
  6355. clif_displaymessage(fd, output);
  6356. return 0;
  6357. }
  6358. ent = &skill_tree[s][c][skillidx];
  6359. for(j=0;j<5;j++)
  6360. if( ent->need[j].id &&
  6361. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6362. {
  6363. int idx = 0;
  6364. char *desc;
  6365. while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id)
  6366. idx++;
  6367. if (skill_names[idx].id == 0)
  6368. desc = "Unknown skill";
  6369. else
  6370. desc = skill_names[idx].desc;
  6371. sprintf(output, "player requires level %d of skill %s",
  6372. ent->need[j].lv, desc);
  6373. clif_displaymessage(fd, output);
  6374. meets = 0;
  6375. }
  6376. if (meets == 1) {
  6377. sprintf(output, "I believe the player meets all the requirements for that skill");
  6378. clif_displaymessage(fd, output);
  6379. }
  6380. return 0;
  6381. }
  6382. /*==========================================
  6383. * @marry by [MouseJstr]
  6384. *
  6385. * Marry two players
  6386. *------------------------------------------
  6387. */
  6388. int
  6389. atcommand_marry(const int fd, struct map_session_data* sd,
  6390. const char* command, const char* message)
  6391. {
  6392. struct map_session_data *pl_sd1 = NULL;
  6393. struct map_session_data *pl_sd2 = NULL;
  6394. char player1[255], player2[255];
  6395. nullpo_retr(-1, sd);
  6396. if (!message || !*message)
  6397. return -1;
  6398. if (sscanf(message, "%[^,],%[^\r\n]", player1, player2) != 2) {
  6399. clif_displaymessage(fd, "usage: @marry <player1> <player2>.");
  6400. return -1;
  6401. }
  6402. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6403. sprintf(player2, "Cannot find player %s online", player1);
  6404. clif_displaymessage(fd, player2);
  6405. return -1;
  6406. }
  6407. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6408. sprintf(player1, "Cannot find player %s online", player2);
  6409. clif_displaymessage(fd, player1);
  6410. return -1;
  6411. }
  6412. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6413. clif_displaymessage(fd, "They are married.. wish them well");
  6414. return 0;
  6415. } else
  6416. return -1;
  6417. }
  6418. /*==========================================
  6419. * @divorce by [MouseJstr]
  6420. *
  6421. * divorce two players
  6422. *------------------------------------------
  6423. */
  6424. int
  6425. atcommand_divorce(const int fd, struct map_session_data* sd,
  6426. const char* command, const char* message)
  6427. {
  6428. struct map_session_data *pl_sd = NULL;
  6429. nullpo_retr(-1, sd);
  6430. if (!message || !*message)
  6431. return -1;
  6432. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6433. return pc_divorce(pl_sd);
  6434. clif_displaymessage(fd, "They are now divorced.");
  6435. } else
  6436. clif_displaymessage(fd, "The divorce has failed.. talk to the judge..");
  6437. return 0;
  6438. }
  6439. /*==========================================
  6440. * @rings by [MouseJstr]
  6441. *
  6442. * Give two players rings
  6443. *------------------------------------------
  6444. */
  6445. int
  6446. atcommand_rings(const int fd, struct map_session_data* sd,
  6447. const char* command, const char* message)
  6448. {
  6449. struct item item_tmp;
  6450. int flag;
  6451. memset(&item_tmp, 0, sizeof(item_tmp));
  6452. item_tmp.nameid = 2634;
  6453. item_tmp.identify = 1;
  6454. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6455. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6456. item_tmp.nameid = 2635;
  6457. item_tmp.identify = 1;
  6458. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6459. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6460. clif_displaymessage(fd, "You have rings! Give them to the lovers.");
  6461. return 0;
  6462. }
  6463. /*==========================================
  6464. * @grind by [MouseJstr]
  6465. *------------------------------------------
  6466. */
  6467. int
  6468. atcommand_grind(const int fd, struct map_session_data* sd,
  6469. const char* command, const char* message)
  6470. {
  6471. struct map_session_data *pl_sd = NULL;
  6472. int skillnum;
  6473. int inf;
  6474. char target[255];
  6475. nullpo_retr(-1, sd);
  6476. if (!message || !*message)
  6477. return -1;
  6478. if(sscanf(message, "%s", target) != 1) {
  6479. clif_displaymessage(fd, "Usage: @grind <target>");
  6480. return -1;
  6481. }
  6482. if((pl_sd=map_nick2sd(target)) == NULL)
  6483. return -1;
  6484. for (skillnum = 1; skillnum < 500; skillnum++) {
  6485. sd->status.sp = sd->status.max_sp;
  6486. atcommand_alive(fd, sd, command, message);
  6487. inf = skill_get_inf(skillnum);
  6488. if ((inf == 2) || (inf == 1))
  6489. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6490. else
  6491. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6492. }
  6493. return 0;
  6494. }
  6495. /*==========================================
  6496. * It is made to rain.
  6497. *------------------------------------------
  6498. */
  6499. int
  6500. atcommand_rain(
  6501. const int fd, struct map_session_data* sd,
  6502. const char* command, const char* message)
  6503. {
  6504. int effno = 0;
  6505. nullpo_retr(-1, sd);
  6506. effno = 161;
  6507. if (map[sd->bl.m].flag.rain) {
  6508. map[sd->bl.m].flag.rain=0;
  6509. clif_displaymessage(fd, "The rain has stopped.");
  6510. } else {
  6511. map[sd->bl.m].flag.rain=1;
  6512. clif_specialeffect(&sd->bl,effno,2);
  6513. clif_displaymessage(fd, "It is made to rain.");
  6514. }
  6515. return 0;
  6516. }
  6517. /*==========================================
  6518. * It is made to snow.
  6519. *------------------------------------------
  6520. */
  6521. int
  6522. atcommand_snow(
  6523. const int fd, struct map_session_data* sd,
  6524. const char* command, const char* message)
  6525. {
  6526. int effno = 0;
  6527. effno = 162;
  6528. nullpo_retr(-1, sd);
  6529. if (map[sd->bl.m].flag.snow) {
  6530. map[sd->bl.m].flag.snow=0;
  6531. clif_displaymessage(fd, "Snow has stopped falling.");
  6532. } else {
  6533. map[sd->bl.m].flag.snow=1;
  6534. clif_specialeffect(&sd->bl,effno,2);
  6535. clif_displaymessage(fd, "It is made to snow.");
  6536. }
  6537. return 0;
  6538. }
  6539. /*==========================================
  6540. * Cherry tree snowstorm is made to fall. (Sakura)
  6541. *------------------------------------------
  6542. */
  6543. int
  6544. atcommand_sakura(
  6545. const int fd, struct map_session_data* sd,
  6546. const char* command, const char* message)
  6547. {
  6548. int effno = 0;
  6549. effno = 163;
  6550. nullpo_retr(-1, sd);
  6551. if (map[sd->bl.m].flag.sakura) {
  6552. map[sd->bl.m].flag.sakura=0;
  6553. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6554. } else {
  6555. map[sd->bl.m].flag.sakura=1;
  6556. clif_specialeffect(&sd->bl,effno,2);
  6557. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6558. }
  6559. return 0;
  6560. }
  6561. /*==========================================
  6562. * Fog hangs over.
  6563. *------------------------------------------
  6564. */
  6565. int
  6566. atcommand_fog(
  6567. const int fd, struct map_session_data* sd,
  6568. const char* command, const char* message)
  6569. {
  6570. int effno = 0;
  6571. effno = 233;
  6572. nullpo_retr(-1, sd);
  6573. if (map[sd->bl.m].flag.fog) {
  6574. map[sd->bl.m].flag.fog=0;
  6575. clif_displaymessage(fd, "The fog has gone.");
  6576. } else {
  6577. map[sd->bl.m].flag.fog=1;
  6578. clif_specialeffect(&sd->bl,effno,2);
  6579. clif_displaymessage(fd, "Fog hangs over.");
  6580. }
  6581. return 0;
  6582. }
  6583. /*==========================================
  6584. * Fallen leaves fall.
  6585. *------------------------------------------
  6586. */
  6587. int
  6588. atcommand_leaves(
  6589. const int fd, struct map_session_data* sd,
  6590. const char* command, const char* message)
  6591. {
  6592. int effno = 0;
  6593. effno = 333;
  6594. nullpo_retr(-1, sd);
  6595. if (map[sd->bl.m].flag.leaves) {
  6596. map[sd->bl.m].flag.leaves=0;
  6597. clif_displaymessage(fd, "Leaves no longer fall.");
  6598. } else {
  6599. map[sd->bl.m].flag.leaves=1;
  6600. clif_specialeffect(&sd->bl,effno,2);
  6601. clif_displaymessage(fd, "Fallen leaves fall.");
  6602. }
  6603. return 0;
  6604. }
  6605. /*==========================================
  6606. * Clearing Weather Effects by Dexity
  6607. *------------------------------------------
  6608. */
  6609. int
  6610. atcommand_clearweather(
  6611. const int fd, struct map_session_data* sd,
  6612. const char* command, const char* message)
  6613. {
  6614. //int effno = 0;
  6615. nullpo_retr(-1, sd);
  6616. map[sd->bl.m].flag.rain=0;
  6617. map[sd->bl.m].flag.snow=0;
  6618. map[sd->bl.m].flag.sakura=0;
  6619. map[sd->bl.m].flag.fog=0;
  6620. map[sd->bl.m].flag.leaves=0;
  6621. //clif_specialeffect(&sd->bl,effno,2); // not required. [celest]
  6622. return 0;
  6623. }
  6624. /*==========================================
  6625. *
  6626. *------------------------------------------
  6627. */
  6628. int
  6629. atcommand_summon(
  6630. const int fd, struct map_session_data* sd,
  6631. const char* command, const char* message)
  6632. {
  6633. char name[100];
  6634. int mob_id = 0;
  6635. int x = 0;
  6636. int y = 0;
  6637. int id = 0;
  6638. struct mob_data *md;
  6639. unsigned int tick=gettick();
  6640. nullpo_retr(-1, sd);
  6641. if (!message || !*message)
  6642. return -1;
  6643. if (sscanf(message, "%99s", name) < 1)
  6644. return -1;
  6645. if ((mob_id = atoi(name)) == 0)
  6646. mob_id = mobdb_searchname(name);
  6647. if(mob_id == 0)
  6648. return -1;
  6649. x = sd->bl.x + (rand() % 10 - 5);
  6650. y = sd->bl.y + (rand() % 10 - 5);
  6651. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  6652. if((md=(struct mob_data *)map_id2bl(id))){
  6653. md->master_id=sd->bl.id;
  6654. md->state.special_mob_ai=1;
  6655. md->mode=mob_db[md->class].mode|0x04;
  6656. md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0);
  6657. clif_misceffect2(&md->bl,344);
  6658. }
  6659. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  6660. return 0;
  6661. }
  6662. /*==========================================
  6663. * @adjcmdlvl by [MouseJstr]
  6664. *
  6665. * Temp adjust the GM level required to use a GM command
  6666. *
  6667. * Used during beta testing to allow players to use GM commands
  6668. * for short periods of time
  6669. *------------------------------------------
  6670. */
  6671. int
  6672. atcommand_adjcmdlvl(
  6673. const int fd, struct map_session_data* sd,
  6674. const char* command, const char* message)
  6675. {
  6676. int i, newlev;
  6677. char cmd[100];
  6678. nullpo_retr(-1, sd);
  6679. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  6680. clif_displaymessage(fd, "usage: @adjcmdlvl <lvl> <command>.");
  6681. return -1;
  6682. }
  6683. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  6684. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  6685. atcommand_info[i].level = newlev;
  6686. clif_displaymessage(fd, "@command level changed.");
  6687. return 0;
  6688. }
  6689. clif_displaymessage(fd, "@command not found.");
  6690. return -1;
  6691. }
  6692. /*==========================================
  6693. * @adjgmlvl by [MouseJstr]
  6694. *
  6695. * Create a temp GM
  6696. *
  6697. * Used during beta testing to allow players to use GM commands
  6698. * for short periods of time
  6699. *------------------------------------------
  6700. */
  6701. int
  6702. atcommand_adjgmlvl(
  6703. const int fd, struct map_session_data* sd,
  6704. const char* command, const char* message)
  6705. {
  6706. int newlev;
  6707. char user[100];
  6708. struct map_session_data *pl_sd;
  6709. nullpo_retr(-1, sd);
  6710. if (!message || !*message || sscanf(message, "%d %[^\r\n]", &newlev, user) != 2) {
  6711. clif_displaymessage(fd, "usage: @adjgmlvl <lvl> <user>.");
  6712. return -1;
  6713. }
  6714. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  6715. return -1;
  6716. pc_set_gm_level(pl_sd->status.account_id, newlev);
  6717. return 0;
  6718. }
  6719. /*==========================================
  6720. * @trade by [MouseJstr]
  6721. *
  6722. * Open a trade window with a remote player
  6723. *
  6724. * If I have to jump to a remote player one more time, I am
  6725. * gonna scream!
  6726. *------------------------------------------
  6727. */
  6728. int
  6729. atcommand_trade(
  6730. const int fd, struct map_session_data* sd,
  6731. const char* command, const char* message)
  6732. {
  6733. struct map_session_data *pl_sd = NULL;
  6734. nullpo_retr(-1, sd);
  6735. if (!message || !*message)
  6736. return -1;
  6737. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6738. trade_traderequest(sd, pl_sd->bl.id);
  6739. return 0;
  6740. }
  6741. return -1;
  6742. }
  6743. /*==========================================
  6744. * @setbattleflag by [MouseJstr]
  6745. *
  6746. * set a battle_config flag without having to reboot
  6747. */
  6748. int
  6749. atcommand_setbattleflag(
  6750. const int fd, struct map_session_data* sd,
  6751. const char* command, const char* message)
  6752. {
  6753. char flag[128], value[128];
  6754. nullpo_retr(-1, sd);
  6755. if (!message || !*message || sscanf(message, "%s %s", flag, value) != 2) {
  6756. clif_displaymessage(fd, "usage: @setbattleflag <flag> <value>.");
  6757. return -1;
  6758. }
  6759. if (battle_set_value(flag, value) == 0)
  6760. clif_displaymessage(fd, "unknown battle_config flag");
  6761. else
  6762. clif_displaymessage(fd, "battle_config set as requested");
  6763. return 0;
  6764. }
  6765. /*===========================
  6766. * @unmute [Valaris]
  6767. *===========================
  6768. */
  6769. int atcommand_unmute(
  6770. const int fd, struct map_session_data* sd,
  6771. const char* command, const char* message)
  6772. {
  6773. struct map_session_data *pl_sd = NULL;
  6774. nullpo_retr(-1, sd);
  6775. if (!message || !*message)
  6776. return -1;
  6777. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6778. if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) {
  6779. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  6780. skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  6781. clif_displaymessage(sd->fd,"Player unmuted");
  6782. }
  6783. else
  6784. clif_displaymessage(sd->fd,"Player is not muted");
  6785. }
  6786. return 0;
  6787. }
  6788. /*==========================================
  6789. * @uptime by MC Cameri
  6790. *------------------------------------------
  6791. */
  6792. int
  6793. atcommand_uptime(
  6794. const int fd, struct map_session_data* sd,
  6795. const char* command, const char* message)
  6796. {
  6797. char output[200];
  6798. long seconds = 0, day = 24*60*60, hour = 60*60,
  6799. minute = 60, days = 0, hours = 0, minutes = 0;
  6800. nullpo_retr(-1, sd);
  6801. seconds = (gettick()-ticks)/CLOCKS_PER_SEC;
  6802. days = seconds/day;
  6803. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6804. hours = seconds/hour;
  6805. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6806. minutes = seconds/minute;
  6807. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6808. snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds);
  6809. clif_displaymessage(fd,output);
  6810. return 0;
  6811. }
  6812. /*==========================================
  6813. * @changesex <sex>
  6814. * => Changes one's sex. Argument sex can be
  6815. * 0 or 1, m or f, male or female.
  6816. *------------------------------------------
  6817. */
  6818. int
  6819. atcommand_changesex(
  6820. const int fd, struct map_session_data* sd,
  6821. const char* command, const char* message)
  6822. {
  6823. nullpo_retr(-1, sd);
  6824. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  6825. return 0;
  6826. }
  6827. /*================================================
  6828. * @mute - Mutes a player for a set amount of time
  6829. *------------------------------------------------
  6830. */
  6831. int atcommand_mute(
  6832. const int fd, struct map_session_data* sd,
  6833. const char* command, const char* message)
  6834. {
  6835. struct map_session_data *pl_sd = NULL;
  6836. char character[100];
  6837. int manner;
  6838. nullpo_retr(-1, sd);
  6839. if (!message || !*message || sscanf(message, "%d %99[^\n]", &manner, character) < 1) {
  6840. clif_displaymessage(fd, "usage: @mute <time> <character name>.");
  6841. return -1;
  6842. }
  6843. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6844. pl_sd->status.manner -= manner;
  6845. if(pl_sd->status.manner < 0)
  6846. skill_status_change_start(&pl_sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  6847. }
  6848. else {
  6849. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6850. return -1;
  6851. }
  6852. return 0;
  6853. }
  6854. /*==========================================
  6855. * @refresh (like @jumpto <<yourself>>)
  6856. *------------------------------------------
  6857. */
  6858. int atcommand_refresh(
  6859. const int fd, struct map_session_data* sd,
  6860. const char* command, const char* message)
  6861. {
  6862. nullpo_retr(-1, sd);
  6863. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  6864. return 0;
  6865. }
  6866. /*==========================================
  6867. * @petid <part of pet name>
  6868. * => Displays a list of matching pets.
  6869. *------------------------------------------
  6870. */
  6871. int
  6872. atcommand_petid(const int fd, struct map_session_data* sd,
  6873. const char* command, const char* message)
  6874. {
  6875. char searchtext[100];
  6876. char temp0[100];
  6877. char temp1[100];
  6878. int cnt = 0, i = 0;
  6879. nullpo_retr(-1, sd);
  6880. if (!message || !*message)
  6881. return -1;
  6882. if (sscanf(message, "%99s", searchtext) < 1)
  6883. return -1;
  6884. estr_lower(searchtext);
  6885. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  6886. clif_displaymessage(fd,temp0);
  6887. while (i < MAX_PET_DB) {
  6888. strcpy(temp1,pet_db[i].name);
  6889. strcpy(temp1, estr_lower(temp1));
  6890. strcpy(temp0,pet_db[i].jname);
  6891. strcpy(temp0, estr_lower(temp1));
  6892. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  6893. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class,
  6894. pet_db[i].jname);
  6895. if (cnt >= 100) { // Only if there are custom pets
  6896. clif_displaymessage(fd, "Be more specific, can't send more than"
  6897. " 100 results.");
  6898. } else {
  6899. clif_displaymessage(fd, temp0);
  6900. }
  6901. cnt++;
  6902. }
  6903. i++;
  6904. }
  6905. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  6906. clif_displaymessage(fd, temp0);
  6907. return 0;
  6908. }
  6909. /*==========================================
  6910. * @identify
  6911. * => GM's magnifier.
  6912. *------------------------------------------
  6913. */
  6914. int
  6915. atcommand_identify(
  6916. const int fd, struct map_session_data* sd,
  6917. const char* command, const char* message)
  6918. {
  6919. int i,num;
  6920. nullpo_retr(-1, sd);
  6921. for(i=num=0;i<MAX_INVENTORY;i++){
  6922. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6923. num++;
  6924. }
  6925. }
  6926. if (num > 0) {
  6927. clif_item_identify_list(sd);
  6928. } else {
  6929. clif_displaymessage(fd,"There are no items to appraise.");
  6930. }
  6931. return 0;
  6932. }
  6933. /*==========================================
  6934. * @gmotd (Global MOTD)
  6935. * by davidsiaw :P
  6936. *------------------------------------------
  6937. */
  6938. int
  6939. atcommand_gmotd(
  6940. const int fd, struct map_session_data* sd,
  6941. const char* command, const char* message)
  6942. {
  6943. char buf[256];
  6944. FILE *fp;
  6945. nullpo_retr(-1, sd);
  6946. if( (fp = fopen(motd_txt, "r"))!=NULL){
  6947. while (fgets(buf, 250, fp) != NULL){
  6948. int i;
  6949. for( i=0; buf[i]; i++){
  6950. if( buf[i]=='\r' || buf[i]=='\n'){
  6951. buf[i]=0;
  6952. break;
  6953. }
  6954. }
  6955. intif_GMmessage(buf,strlen(buf)+1,8);
  6956. }
  6957. fclose(fp);
  6958. }
  6959. return 0;
  6960. }
  6961. int atcommand_misceffect(
  6962. const int fd, struct map_session_data* sd,
  6963. const char* command, const char* message)
  6964. {
  6965. int effect = 0;
  6966. nullpo_retr(-1, sd);
  6967. if (!message || !*message)
  6968. return -1;
  6969. if (sscanf(message, "%d", &effect) < 1)
  6970. return -1;
  6971. clif_misceffect(&sd->bl,effect);
  6972. return 0;
  6973. }
  6974. int charid2sessionid(int charid)
  6975. {
  6976. int i;
  6977. int session_id=0;
  6978. struct map_session_data *pl_sd = NULL;
  6979. for(i=0;i<fd_max;i++){
  6980. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  6981. if (pl_sd->status.char_id==charid) { session_id = i; break; }
  6982. }
  6983. }
  6984. return session_id;
  6985. }
  6986. int accountid2sessionid(int accountid)
  6987. {
  6988. int i;
  6989. int session_id=0;
  6990. struct map_session_data *pl_sd = NULL;
  6991. for(i=0;i<fd_max;i++){
  6992. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  6993. if (pl_sd->status.account_id==accountid) { session_id = i; break; }
  6994. }
  6995. }
  6996. return session_id;
  6997. }
  6998. /*==========================================
  6999. * Jump to a player by PID number
  7000. * Original by Dino9021
  7001. * Added in by nsstrunks
  7002. *------------------------------------------
  7003. */
  7004. int atcommand_jumptoid(
  7005. const int fd, struct map_session_data* sd,
  7006. const char* command, const char* message)
  7007. {
  7008. char character[100];
  7009. char output[200];
  7010. int cid=0;
  7011. int session_id=0;
  7012. struct map_session_data *pl_sd;
  7013. memset(character, '\0', sizeof(character));
  7014. memset(output, '\0', sizeof(output));
  7015. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7016. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7017. return -1;
  7018. }
  7019. cid=atoi(message);
  7020. if ((session_id=charid2sessionid(cid))!=0)
  7021. {
  7022. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7023. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7024. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7025. return -1;
  7026. }
  7027. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7028. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7029. return -1;
  7030. }
  7031. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7032. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7033. clif_displaymessage(fd, output);
  7034. } else {
  7035. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7036. return -1;
  7037. }
  7038. }
  7039. else
  7040. {
  7041. clif_displaymessage(fd,msg_table[3]);
  7042. }
  7043. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7044. return 0;
  7045. }
  7046. /*==========================================
  7047. * Jump to a player by PID number
  7048. * Original by Dino9021
  7049. * Added in by nsstrunks
  7050. *------------------------------------------
  7051. */
  7052. int atcommand_jumptoid2(
  7053. const int fd, struct map_session_data* sd,
  7054. const char* command, const char* message)
  7055. {
  7056. char character[100];
  7057. char output[200];
  7058. int aid=0;
  7059. int session_id=0;
  7060. struct map_session_data *pl_sd;
  7061. memset(character, '\0', sizeof(character));
  7062. memset(output, '\0', sizeof(output));
  7063. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7064. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7065. return -1;
  7066. }
  7067. aid=atoi(message);
  7068. if ((session_id=accountid2sessionid(aid))!=0)
  7069. {
  7070. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7071. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7072. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7073. return -1;
  7074. }
  7075. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7076. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7077. return -1;
  7078. }
  7079. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7080. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7081. clif_displaymessage(fd, output);
  7082. } else {
  7083. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7084. return -1;
  7085. }
  7086. }
  7087. else
  7088. {
  7089. clif_displaymessage(fd,msg_table[3]);
  7090. }
  7091. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7092. return 0;
  7093. }
  7094. /*==========================================
  7095. * Recall a player by PID number
  7096. * Original by Dino9021
  7097. * Added in by nsstrunks
  7098. *------------------------------------------
  7099. */
  7100. int atcommand_recallid(
  7101. const int fd, struct map_session_data* sd,
  7102. const char* command, const char* message)
  7103. {
  7104. char character[100];
  7105. char output[200];
  7106. int cid=0;
  7107. int session_id=0;
  7108. struct map_session_data *pl_sd;
  7109. memset(character, '\0', sizeof(character));
  7110. memset(output, '\0', sizeof(output));
  7111. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7112. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7113. return -1;
  7114. }
  7115. cid=atoi(message);
  7116. if ((session_id=charid2sessionid(cid))!=0)
  7117. {
  7118. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7119. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7120. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7121. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7122. return -1;
  7123. }
  7124. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7125. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7126. return -1;
  7127. }
  7128. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7129. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7130. clif_displaymessage(fd, output);
  7131. } else {
  7132. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7133. return -1;
  7134. }
  7135. } else {
  7136. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7137. return -1;
  7138. }
  7139. }
  7140. else
  7141. {
  7142. clif_displaymessage(fd,msg_table[3]);
  7143. }
  7144. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7145. return 0;
  7146. }
  7147. /*==========================================
  7148. * Recall a player by PID number
  7149. * Original by Dino9021
  7150. * Added in by nsstrunks
  7151. *------------------------------------------
  7152. */
  7153. int atcommand_recallid2(
  7154. const int fd, struct map_session_data* sd,
  7155. const char* command, const char* message)
  7156. {
  7157. char character[100];
  7158. char output[200];
  7159. int aid=0;
  7160. int session_id=0;
  7161. struct map_session_data *pl_sd;
  7162. memset(character, '\0', sizeof(character));
  7163. memset(output, '\0', sizeof(output));
  7164. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7165. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7166. return -1;
  7167. }
  7168. aid=atoi(message);
  7169. if ((session_id=accountid2sessionid(aid))!=0)
  7170. {
  7171. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7172. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7173. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7174. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7175. return -1;
  7176. }
  7177. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7178. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7179. return -1;
  7180. }
  7181. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7182. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7183. clif_displaymessage(fd, output);
  7184. } else {
  7185. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7186. return -1;
  7187. }
  7188. } else {
  7189. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7190. return -1;
  7191. }
  7192. }
  7193. else
  7194. {
  7195. clif_displaymessage(fd,msg_table[3]);
  7196. }
  7197. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7198. return 0;
  7199. }
  7200. /*==========================================
  7201. * Kick a player by PID number
  7202. * Original by Dino9021
  7203. * Added in by nsstrunks
  7204. *------------------------------------------
  7205. */
  7206. int atcommand_kickid(
  7207. const int fd, struct map_session_data* sd,
  7208. const char* command, const char* message)
  7209. {
  7210. struct map_session_data *pl_sd;
  7211. char character[100];
  7212. int cid=0;
  7213. int session_id=0;
  7214. memset(character, '\0', sizeof(character));
  7215. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7216. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7217. return -1;
  7218. }
  7219. cid=atoi(message);
  7220. if ((session_id=charid2sessionid(cid))!=0)
  7221. {
  7222. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7223. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7224. clif_GM_kick(sd, pl_sd, 1);
  7225. else {
  7226. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7227. return -1;
  7228. }
  7229. } else {
  7230. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7231. return -1;
  7232. }
  7233. }
  7234. else
  7235. {
  7236. clif_displaymessage(fd,msg_table[3]);
  7237. }
  7238. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7239. return 0;
  7240. }
  7241. /*==========================================
  7242. * Kick a player by PID number
  7243. * Original by Dino9021
  7244. * Added in by nsstrunks
  7245. *------------------------------------------
  7246. */
  7247. int atcommand_kickid2(
  7248. const int fd, struct map_session_data* sd,
  7249. const char* command, const char* message)
  7250. {
  7251. struct map_session_data *pl_sd;
  7252. char character[100];
  7253. int aid=0;
  7254. int session_id=0;
  7255. memset(character, '\0', sizeof(character));
  7256. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7257. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7258. return -1;
  7259. }
  7260. aid=atoi(message);
  7261. if ((session_id=accountid2sessionid(aid))!=0)
  7262. {
  7263. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7264. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7265. clif_GM_kick(sd, pl_sd, 1);
  7266. else {
  7267. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7268. return -1;
  7269. }
  7270. } else {
  7271. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7272. return -1;
  7273. }
  7274. }
  7275. else
  7276. {
  7277. clif_displaymessage(fd,msg_table[3]);
  7278. }
  7279. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7280. return 0;
  7281. }
  7282. /*==========================================
  7283. * Revive a player by PID number
  7284. * Original by Dino9021
  7285. * Added in by nsstrunks
  7286. *------------------------------------------
  7287. */
  7288. int atcommand_reviveid(
  7289. const int fd, struct map_session_data* sd,
  7290. const char* command, const char* message)
  7291. {
  7292. char character[100];
  7293. int cid=0;
  7294. int session_id=0;
  7295. struct map_session_data *pl_sd;
  7296. memset(character, '\0', sizeof(character));
  7297. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7298. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7299. return -1;
  7300. }
  7301. cid=atoi(message);
  7302. if ((session_id=charid2sessionid(cid))!=0)
  7303. {
  7304. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7305. pl_sd->status.hp = pl_sd->status.max_hp;
  7306. pc_setstand(pl_sd);
  7307. if (battle_config.pc_invincible_time > 0)
  7308. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7309. clif_updatestatus(pl_sd, SP_HP);
  7310. clif_updatestatus(pl_sd, SP_SP);
  7311. clif_resurrection(&pl_sd->bl, 1);
  7312. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7313. } else {
  7314. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7315. return -1;
  7316. }
  7317. }
  7318. else
  7319. {
  7320. clif_displaymessage(fd,msg_table[3]);
  7321. }
  7322. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7323. return 0;
  7324. }
  7325. /*==========================================
  7326. * Revive a player by PID number
  7327. * Original by Dino9021
  7328. * Added in by nsstrunks
  7329. *------------------------------------------
  7330. */
  7331. int atcommand_reviveid2(
  7332. const int fd, struct map_session_data* sd,
  7333. const char* command, const char* message)
  7334. {
  7335. char character[100];
  7336. int aid=0;
  7337. int session_id=0;
  7338. struct map_session_data *pl_sd;
  7339. memset(character, '\0', sizeof(character));
  7340. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7341. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7342. return -1;
  7343. }
  7344. aid=atoi(message);
  7345. if ((session_id=accountid2sessionid(aid))!=0)
  7346. {
  7347. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7348. pl_sd->status.hp = pl_sd->status.max_hp;
  7349. pc_setstand(pl_sd);
  7350. if (battle_config.pc_invincible_time > 0)
  7351. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7352. clif_updatestatus(pl_sd, SP_HP);
  7353. clif_updatestatus(pl_sd, SP_SP);
  7354. clif_resurrection(&pl_sd->bl, 1);
  7355. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7356. } else {
  7357. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7358. return -1;
  7359. }
  7360. }
  7361. else
  7362. {
  7363. clif_displaymessage(fd,msg_table[3]);
  7364. }
  7365. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7366. return 0;
  7367. }
  7368. /*==========================================
  7369. * Kill a player by PID number
  7370. * Original by Dino9021
  7371. * Added in by nsstrunks
  7372. *------------------------------------------
  7373. */
  7374. int atcommand_killid(
  7375. const int fd, struct map_session_data* sd,
  7376. const char* command, const char* message)
  7377. {
  7378. char character[100];
  7379. int cid=0;
  7380. int session_id=0;
  7381. struct map_session_data *pl_sd;
  7382. memset(character, '\0', sizeof(character));
  7383. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7384. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7385. return -1;
  7386. }
  7387. cid=atoi(message);
  7388. if ((session_id=charid2sessionid(cid))!=0)
  7389. {
  7390. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7391. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7392. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7393. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7394. } else {
  7395. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7396. return -1;
  7397. }
  7398. } else {
  7399. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7400. return -1;
  7401. }
  7402. }
  7403. else
  7404. {
  7405. clif_displaymessage(fd,msg_table[3]);
  7406. }
  7407. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7408. return 0;
  7409. }
  7410. /*==========================================
  7411. * Kill a player by PID number
  7412. * Original by Dino9021
  7413. * Added in by nsstrunks
  7414. *------------------------------------------
  7415. */
  7416. int atcommand_killid2(
  7417. const int fd, struct map_session_data* sd,
  7418. const char* command, const char* message)
  7419. {
  7420. char character[100];
  7421. int aid=0;
  7422. int session_id=0;
  7423. struct map_session_data *pl_sd;
  7424. memset(character, '\0', sizeof(character));
  7425. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7426. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7427. return -1;
  7428. }
  7429. aid=atoi(message);
  7430. if ((session_id=accountid2sessionid(aid))!=0)
  7431. {
  7432. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7433. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7434. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7435. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7436. } else {
  7437. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7438. return -1;
  7439. }
  7440. } else {
  7441. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7442. return -1;
  7443. }
  7444. }
  7445. else
  7446. {
  7447. clif_displaymessage(fd,msg_table[3]);
  7448. }
  7449. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7450. return 0;
  7451. }
  7452. /*==========================================
  7453. * Make a player killable, by PID
  7454. * Original by Dino9021
  7455. * Added in by nsstrunks
  7456. *------------------------------------------
  7457. */
  7458. int
  7459. atcommand_charkillableid(
  7460. const int fd, struct map_session_data* sd,
  7461. const char* command, const char* message)
  7462. {
  7463. struct map_session_data *pl_sd = NULL;
  7464. int cid=0;
  7465. int session_id=0;
  7466. if (!message || (cid = atoi(message)) == 0 || !*message)
  7467. return -1;
  7468. cid=atoi(message);
  7469. if ((session_id=charid2sessionid(cid))!=0)
  7470. {
  7471. if((pl_sd=session[session_id]->session_data) == NULL)
  7472. return -1;
  7473. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7474. if(pl_sd->special_state.killable)
  7475. clif_displaymessage(fd, "The player is now killable");
  7476. else
  7477. clif_displaymessage(fd, "The player is no longer killable");
  7478. }
  7479. else
  7480. {
  7481. clif_displaymessage(fd,msg_table[3]);
  7482. }
  7483. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7484. return 0;
  7485. }
  7486. /*==========================================
  7487. * Make a player killable, by PID
  7488. * Original by Dino9021
  7489. * Added in by nsstrunks
  7490. *------------------------------------------
  7491. */
  7492. int
  7493. atcommand_charkillableid2(
  7494. const int fd, struct map_session_data* sd,
  7495. const char* command, const char* message)
  7496. {
  7497. struct map_session_data *pl_sd = NULL;
  7498. int aid=0;
  7499. int session_id=0;
  7500. if (!message || (aid = atoi(message)) == 0 || !*message)
  7501. return -1;
  7502. aid=atoi(message);
  7503. if ((session_id=accountid2sessionid(aid))!=0)
  7504. {
  7505. if((pl_sd=session[session_id]->session_data) == NULL)
  7506. return -1;
  7507. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7508. if(pl_sd->special_state.killable)
  7509. clif_displaymessage(fd, "The player is now killable");
  7510. else
  7511. clif_displaymessage(fd, "The player is no longer killable");
  7512. }
  7513. else
  7514. {
  7515. clif_displaymessage(fd,msg_table[3]);
  7516. }
  7517. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7518. return 0;
  7519. }
  7520. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7521. /*==========================================
  7522. * Mail System commands by [Valaris]
  7523. *------------------------------------------
  7524. */
  7525. int atcommand_listmail(
  7526. const int fd, struct map_session_data* sd,
  7527. const char* command, const char* message)
  7528. {
  7529. if(!battle_config.mail_system)
  7530. return 0;
  7531. nullpo_retr(-1, sd);
  7532. if(strlen(command)==12)
  7533. mail_check(sd,3);
  7534. else if(strlen(command)==9)
  7535. mail_check(sd,2);
  7536. else
  7537. mail_check(sd,1);
  7538. return 0;
  7539. }
  7540. int atcommand_readmail(
  7541. const int fd, struct map_session_data* sd,
  7542. const char* command, const char* message)
  7543. {
  7544. if(!battle_config.mail_system)
  7545. return 0;
  7546. nullpo_retr(-1, sd);
  7547. if (!message || !*message) {
  7548. clif_displaymessage(sd->fd,"You must specify a message number.");
  7549. return 0;
  7550. }
  7551. if(strlen(command)==11)
  7552. mail_delete(sd,atoi(message));
  7553. else
  7554. mail_read(sd,atoi(message));
  7555. return 0;
  7556. }
  7557. int atcommand_sendmail(
  7558. const int fd, struct map_session_data* sd,
  7559. const char* command, const char* message)
  7560. {
  7561. char name[24],text[80];
  7562. if(!battle_config.mail_system)
  7563. return 0;
  7564. nullpo_retr(-1, sd);
  7565. if (!message || !*message) {
  7566. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7567. return 0;
  7568. }
  7569. if ((sscanf(message, "\"%[^\"]\" %79[^\n]", name, text) < 2) &&
  7570. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7571. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7572. return 0;
  7573. }
  7574. if(strlen(command)==17)
  7575. mail_send(sd,name,text,1);
  7576. else
  7577. mail_send(sd,name,text,0);
  7578. return 0;
  7579. }
  7580. /*==========================================
  7581. * Refresh online command for SQL [Valaris]
  7582. * Will refresh and check online column of
  7583. * players and set correctly.
  7584. *------------------------------------------
  7585. */
  7586. int atcommand_refreshonline(
  7587. const int fd, struct map_session_data* sd,
  7588. const char* command, const char* message)
  7589. {
  7590. nullpo_retr(-1, sd);
  7591. char_online_check();
  7592. return 0;
  7593. }
  7594. #endif /* end sql only */