atcommand.c 266 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858
  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 "../common/mmo.h"
  11. #include "log.h"
  12. #include "clif.h"
  13. #include "chrif.h"
  14. #include "intif.h"
  15. #include "itemdb.h"
  16. #include "map.h"
  17. #include "pc.h"
  18. #include "status.h"
  19. #include "skill.h"
  20. #include "mob.h"
  21. #include "pet.h"
  22. #include "battle.h"
  23. #include "party.h"
  24. #include "guild.h"
  25. #include "atcommand.h"
  26. #include "script.h"
  27. #include "npc.h"
  28. #include "trade.h"
  29. #include "core.h"
  30. #ifndef TXT_ONLY
  31. #include "mail.h"
  32. #endif
  33. #define STATE_BLIND 0x10
  34. static char command_symbol = '@'; // first char of the commands (by [Yor])
  35. char msg_table[1000][256]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  36. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  37. ACMD_FUNC(broadcast);
  38. ACMD_FUNC(localbroadcast);
  39. ACMD_FUNC(rura);
  40. ACMD_FUNC(where);
  41. ACMD_FUNC(jumpto);
  42. ACMD_FUNC(jump);
  43. ACMD_FUNC(who);
  44. ACMD_FUNC(who2);
  45. ACMD_FUNC(who3);
  46. ACMD_FUNC(whomap);
  47. ACMD_FUNC(whomap2);
  48. ACMD_FUNC(whomap3);
  49. ACMD_FUNC(whogm); // by Yor
  50. ACMD_FUNC(whozeny); // [Valaris]
  51. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  52. ACMD_FUNC(save);
  53. ACMD_FUNC(load);
  54. ACMD_FUNC(speed);
  55. ACMD_FUNC(storage);
  56. ACMD_FUNC(guildstorage);
  57. ACMD_FUNC(option);
  58. ACMD_FUNC(hide);
  59. ACMD_FUNC(jobchange);
  60. ACMD_FUNC(die);
  61. ACMD_FUNC(kill);
  62. ACMD_FUNC(alive);
  63. ACMD_FUNC(kami);
  64. ACMD_FUNC(heal);
  65. ACMD_FUNC(item);
  66. ACMD_FUNC(item2);
  67. ACMD_FUNC(itemreset);
  68. ACMD_FUNC(itemcheck);
  69. ACMD_FUNC(baselevelup);
  70. ACMD_FUNC(joblevelup);
  71. ACMD_FUNC(help);
  72. ACMD_FUNC(gm);
  73. ACMD_FUNC(pvpoff);
  74. ACMD_FUNC(pvpon);
  75. ACMD_FUNC(gvgoff);
  76. ACMD_FUNC(gvgon);
  77. ACMD_FUNC(model);
  78. ACMD_FUNC(go);
  79. ACMD_FUNC(monster);
  80. ACMD_FUNC(monstersmall);
  81. ACMD_FUNC(monsterbig);
  82. ACMD_FUNC(spawn);
  83. ACMD_FUNC(killmonster);
  84. ACMD_FUNC(killmonster2);
  85. ACMD_FUNC(refine);
  86. ACMD_FUNC(produce);
  87. ACMD_FUNC(memo);
  88. ACMD_FUNC(gat);
  89. ACMD_FUNC(packet);
  90. ACMD_FUNC(statuspoint);
  91. ACMD_FUNC(skillpoint);
  92. ACMD_FUNC(zeny);
  93. ACMD_FUNC(param);
  94. ACMD_FUNC(guildlevelup);
  95. ACMD_FUNC(makeegg);
  96. ACMD_FUNC(hatch);
  97. ACMD_FUNC(petfriendly);
  98. ACMD_FUNC(pethungry);
  99. ACMD_FUNC(petrename);
  100. ACMD_FUNC(recall);
  101. ACMD_FUNC(recallall);
  102. ACMD_FUNC(revive);
  103. ACMD_FUNC(character_stats_all);
  104. ACMD_FUNC(character_save);
  105. ACMD_FUNC(night);
  106. ACMD_FUNC(day);
  107. ACMD_FUNC(doom);
  108. ACMD_FUNC(doommap);
  109. ACMD_FUNC(raise);
  110. ACMD_FUNC(raisemap);
  111. ACMD_FUNC(character_baselevel);
  112. ACMD_FUNC(character_joblevel);
  113. ACMD_FUNC(kick);
  114. ACMD_FUNC(kickall);
  115. ACMD_FUNC(allskill);
  116. ACMD_FUNC(questskill);
  117. ACMD_FUNC(charquestskill);
  118. ACMD_FUNC(lostskill);
  119. ACMD_FUNC(charlostskill);
  120. ACMD_FUNC(spiritball);
  121. ACMD_FUNC(party);
  122. ACMD_FUNC(guild);
  123. ACMD_FUNC(charskreset);
  124. ACMD_FUNC(charstreset);
  125. ACMD_FUNC(charreset);
  126. ACMD_FUNC(charstpoint);
  127. ACMD_FUNC(charmodel);
  128. ACMD_FUNC(charskpoint);
  129. ACMD_FUNC(agitstart);
  130. ACMD_FUNC(agitend);
  131. ACMD_FUNC(reloaditemdb);
  132. ACMD_FUNC(reloadmobdb);
  133. ACMD_FUNC(reloadskilldb);
  134. ACMD_FUNC(reloadscript);
  135. ACMD_FUNC(reloadgmdb); // by Yor
  136. ACMD_FUNC(mapexit);
  137. ACMD_FUNC(idsearch);
  138. ACMD_FUNC(mapinfo);
  139. ACMD_FUNC(dye); //** by fritz
  140. ACMD_FUNC(hair_style); //** by fritz
  141. ACMD_FUNC(hair_color); //** by fritz
  142. ACMD_FUNC(stat_all); //** by fritz
  143. ACMD_FUNC(char_change_sex); // by Yor
  144. ACMD_FUNC(char_block); // by Yor
  145. ACMD_FUNC(char_ban); // by Yor
  146. ACMD_FUNC(char_unblock); // by Yor
  147. ACMD_FUNC(char_unban); // by Yor
  148. ACMD_FUNC(mount_peco); // by Valaris
  149. ACMD_FUNC(char_mount_peco); // by Yor
  150. ACMD_FUNC(guildspy); // [Syrus22]
  151. ACMD_FUNC(partyspy); // [Syrus22]
  152. ACMD_FUNC(repairall); // [Valaris]
  153. ACMD_FUNC(guildrecall); // by Yor
  154. ACMD_FUNC(partyrecall); // by Yor
  155. ACMD_FUNC(nuke); // [Valaris]
  156. ACMD_FUNC(enablenpc);
  157. ACMD_FUNC(disablenpc);
  158. ACMD_FUNC(servertime); // by Yor
  159. ACMD_FUNC(chardelitem); // by Yor
  160. ACMD_FUNC(jail); // by Yor
  161. ACMD_FUNC(unjail); // by Yor
  162. ACMD_FUNC(disguise); // [Valaris]
  163. ACMD_FUNC(undisguise); // by Yor
  164. ACMD_FUNC(chardisguise); // Kalaspuff
  165. ACMD_FUNC(charundisguise); // Kalaspuff
  166. ACMD_FUNC(email); // by Yor
  167. ACMD_FUNC(effect);//by Apple
  168. ACMD_FUNC(character_cart_list); // by Yor
  169. ACMD_FUNC(addwarp); // by MouseJstr
  170. ACMD_FUNC(follow); // by MouseJstr
  171. ACMD_FUNC(skillon); // by MouseJstr
  172. ACMD_FUNC(skilloff); // by MouseJstr
  173. ACMD_FUNC(killer); // by MouseJstr
  174. ACMD_FUNC(npcmove); // by MouseJstr
  175. ACMD_FUNC(killable); // by MouseJstr
  176. ACMD_FUNC(charkillable); // by MouseJstr
  177. ACMD_FUNC(dropall); // by MouseJstr
  178. ACMD_FUNC(chardropall); // by MouseJstr
  179. ACMD_FUNC(storeall); // by MouseJstr
  180. ACMD_FUNC(charstoreall); // by MouseJstr
  181. ACMD_FUNC(skillid); // by MouseJstr
  182. ACMD_FUNC(useskill); // by MouseJstr
  183. ACMD_FUNC(summon);
  184. ACMD_FUNC(rain);
  185. ACMD_FUNC(snow);
  186. ACMD_FUNC(sakura);
  187. ACMD_FUNC(fog);
  188. ACMD_FUNC(leaves);
  189. ACMD_FUNC(adjgmlvl); // by MouseJstr
  190. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  191. ACMD_FUNC(trade); // by MouseJstr
  192. ACMD_FUNC(send); // by davidsiaw
  193. ACMD_FUNC(setbattleflag); // by MouseJstr
  194. ACMD_FUNC(unmute); // [Valaris]
  195. ACMD_FUNC(clearweather); // Dexity
  196. ACMD_FUNC(uptime); // by MC Cameri
  197. ACMD_FUNC(changesex); // by MC Cameri
  198. ACMD_FUNC(mute); // celest
  199. ACMD_FUNC(refresh); // by MC Cameri
  200. ACMD_FUNC(petid); // by MC Cameri
  201. ACMD_FUNC(identify); // by MC Cameri
  202. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  203. ACMD_FUNC(misceffect); // by MC Cameri
  204. ACMD_FUNC(mobsearch);
  205. ACMD_FUNC(cleanmap);
  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(grind2); // by MouseJstr
  223. #ifdef DMALLOC
  224. ACMD_FUNC(dmstart); // by MouseJstr
  225. ACMD_FUNC(dmtick); // by MouseJstr
  226. #endif
  227. ACMD_FUNC(jumptoid); // by Dino9021
  228. ACMD_FUNC(jumptoid2); // by Dino9021
  229. ACMD_FUNC(recallid); // by Dino9021
  230. ACMD_FUNC(recallid2); // by Dino9021
  231. ACMD_FUNC(kickid); // by Dino9021
  232. ACMD_FUNC(kickid2); // by Dino9021
  233. ACMD_FUNC(reviveid); // by Dino9021
  234. ACMD_FUNC(reviveid2); // by Dino9021
  235. ACMD_FUNC(killid); // by Dino9021
  236. ACMD_FUNC(killid2); // by Dino9021
  237. ACMD_FUNC(charkillableid); // by Dino9021
  238. ACMD_FUNC(charkillableid2); // by Dino9021
  239. ACMD_FUNC(sound);
  240. ACMD_FUNC(undisguiseall);
  241. ACMD_FUNC(disguiseall);
  242. /*==========================================
  243. *AtCommandInfo atcommand_info[]構造体の定義
  244. *------------------------------------------
  245. */
  246. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  247. // to set default level, read atcommand_athena.conf first please.
  248. static AtCommandInfo atcommand_info[] = {
  249. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  250. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  251. { AtCommand_Where, "@where", 1, atcommand_where },
  252. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  253. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  254. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  255. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  256. { AtCommand_Who, "@who", 20, atcommand_who },
  257. { AtCommand_Who, "@whois", 20, atcommand_who },
  258. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  259. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  260. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  261. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  262. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  263. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  264. { AtCommand_Save, "@save", 40, atcommand_save },
  265. { AtCommand_Load, "@return", 40, atcommand_load },
  266. { AtCommand_Load, "@load", 40, atcommand_load },
  267. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  268. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  269. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  270. { AtCommand_Option, "@option", 40, atcommand_option },
  271. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  272. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  273. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  274. { AtCommand_Die, "@die", 1, atcommand_die },
  275. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  276. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  277. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  278. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  279. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  280. { AtCommand_Item, "@item", 60, atcommand_item },
  281. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  282. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  283. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  284. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  285. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  286. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  287. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  288. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  289. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  290. { AtCommand_H, "@h", 20, atcommand_help },
  291. { AtCommand_Help, "@help", 20, atcommand_help },
  292. { AtCommand_GM, "@gm", 100, atcommand_gm },
  293. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  294. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  295. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  296. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  297. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  298. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  299. { AtCommand_Model, "@model", 20, atcommand_model },
  300. { AtCommand_Go, "@go", 10, atcommand_go },
  301. { AtCommand_Spawn, "@monster", 50, atcommand_spawn },
  302. { AtCommand_Spawn, "@spawn", 50, atcommand_spawn },
  303. // { AtCommand_Spawn, "@summon", 50, atcommand_spawn },
  304. { AtCommand_Monster, "@monster2", 50, atcommand_monster },
  305. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  306. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  307. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  308. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  309. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  310. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  311. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  312. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  313. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  314. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  315. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  316. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  317. { AtCommand_Strength, "@str", 60, atcommand_param },
  318. { AtCommand_Agility, "@agi", 60, atcommand_param },
  319. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  320. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  321. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  322. { AtCommand_Luck, "@luk", 60, atcommand_param },
  323. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  324. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  325. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  326. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  327. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  328. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  329. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  330. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  331. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  332. { AtCommand_Night, "@night", 80, atcommand_night },
  333. { AtCommand_Day, "@day", 80, atcommand_day },
  334. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  335. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  336. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  337. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  338. { AtCommand_CharacterBaseLevel, "@charbaselvl", 60, atcommand_character_baselevel },
  339. { AtCommand_CharacterJobLevel, "@charjlvl", 60, atcommand_character_joblevel },
  340. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  341. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  342. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  343. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  344. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  345. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  346. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  347. { AtCommand_CharQuestSkill, "@charquestskill", 60, atcommand_charquestskill },
  348. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  349. { AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill },
  350. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  351. { AtCommand_Party, "@party", 1, atcommand_party },
  352. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  353. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  354. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  355. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  356. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  357. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  358. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  359. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  360. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  361. { AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset },
  362. { AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset },
  363. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  364. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  365. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  366. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  367. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  368. { AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel },
  369. { AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint },
  370. { AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint },
  371. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  372. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  373. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  374. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  375. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  376. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  377. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  378. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  379. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  380. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  381. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  382. // { AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex }, // by Yor
  383. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  384. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  385. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  386. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  387. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  388. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  389. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  390. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  391. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  392. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  393. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  394. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  395. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  396. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  397. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  398. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  399. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  400. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  401. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  402. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  403. { AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc }, // []
  404. { AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // []
  405. { AtCommand_ServerTime, "@time", 0, atcommand_servertime }, // by Yor
  406. { AtCommand_ServerTime, "@date", 0, atcommand_servertime }, // by Yor
  407. { AtCommand_ServerTime, "@server_date", 0, atcommand_servertime }, // by Yor
  408. { AtCommand_ServerTime, "@serverdate", 0, atcommand_servertime }, // by Yor
  409. { AtCommand_ServerTime, "@server_time", 0, atcommand_servertime }, // by Yor
  410. { AtCommand_ServerTime, "@servertime", 0, atcommand_servertime }, // by Yor
  411. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  412. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  413. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  414. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  415. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  416. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  417. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  418. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  419. { AtCommand_EMail, "@email", 0, atcommand_email }, // by Yor
  420. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  421. // { AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list }, // by Yor, now #itemlist
  422. // { AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list }, // by Yor, now #storagelist
  423. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  424. { AtCommand_Follow, "@follow", 10, atcommand_follow }, // by MouseJstr
  425. { AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp }, // by MouseJstr
  426. { AtCommand_SkillOn, "@skillon", 20, atcommand_skillon }, // by MouseJstr
  427. { AtCommand_SkillOff, "@skilloff", 20, atcommand_skilloff }, // by MouseJstr
  428. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  429. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  430. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  431. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  432. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  433. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  434. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  435. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  436. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  437. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  438. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  439. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  440. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  441. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  442. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  443. /*
  444. { AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle },
  445. { AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance },
  446. { AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect },
  447. */
  448. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  449. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  450. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  451. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  452. { AtCommand_Send, "@send", 60, atcommand_send },
  453. { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag },
  454. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  455. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  456. { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri
  457. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri
  458. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  459. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  460. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  461. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy",40, atcommand_happyhappyjoyjoy }, // [Valaris]
  462. { AtCommand_Refresh, "@refresh", 0, atcommand_refresh }, // by MC Cameri
  463. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  464. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  465. { AtCommand_Gmotd, "@gmotd", 0, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  466. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  467. { AtCommand_MobSearch, "@mobsearch", 0, atcommand_mobsearch },
  468. { AtCommand_CleanMap, "@cleanmap", 0, atcommand_cleanmap },
  469. #ifndef TXT_ONLY // sql-only commands
  470. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  471. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  472. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  473. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  474. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  475. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  476. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  477. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  478. #endif /* TXT_ONLY */
  479. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  480. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  481. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  482. { AtCommand_Rings, "@rings", 40, atcommand_rings }, // [MouseJstr]
  483. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  484. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  485. #ifdef DMALLOC
  486. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  487. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  488. #endif
  489. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  490. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  491. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  492. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  493. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  494. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  495. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  496. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  497. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  498. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  499. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  500. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  501. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  502. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  503. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  504. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  505. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  506. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  507. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  508. // add new commands before this line
  509. { AtCommand_Unknown, NULL, 1, NULL }
  510. };
  511. /*====================================================
  512. * This function return the name of the job (by [Yor])
  513. *----------------------------------------------------
  514. */
  515. char * job_name(int class_) {
  516. switch (class_) {
  517. case 0: return "Novice";
  518. case 1: return "Swordsman";
  519. case 2: return "Mage";
  520. case 3: return "Archer";
  521. case 4: return "Acolyte";
  522. case 5: return "Merchant";
  523. case 6: return "Thief";
  524. case 7: return "Knight";
  525. case 8: return "Priest";
  526. case 9: return "Wizard";
  527. case 10: return "Blacksmith";
  528. case 11: return "Hunter";
  529. case 12: return "Assassin";
  530. case 13: return "Knight 2";
  531. case 14: return "Crusader";
  532. case 15: return "Monk";
  533. case 16: return "Sage";
  534. case 17: return "Rogue";
  535. case 18: return "Alchemist";
  536. case 19: return "Bard";
  537. case 20: return "Dancer";
  538. case 21: return "Crusader 2";
  539. case 22: return "Wedding";
  540. case 23: return "Super Novice";
  541. case 4001: return "Novice High";
  542. case 4002: return "Swordsman High";
  543. case 4003: return "Mage High";
  544. case 4004: return "Archer High";
  545. case 4005: return "Acolyte High";
  546. case 4006: return "Merchant High";
  547. case 4007: return "Thief High";
  548. case 4008: return "Lord Knight";
  549. case 4009: return "High Priest";
  550. case 4010: return "High Wizard";
  551. case 4011: return "Whitesmith";
  552. case 4012: return "Sniper";
  553. case 4013: return "Assassin Cross";
  554. case 4014: return "Peko Knight";
  555. case 4015: return "Paladin";
  556. case 4016: return "Champion";
  557. case 4017: return "Professor";
  558. case 4018: return "Stalker";
  559. case 4019: return "Creator";
  560. case 4020: return "Clown";
  561. case 4021: return "Gypsy";
  562. case 4022: return "Peko Paladin";
  563. case 4023: return "Baby Novice";
  564. case 4024: return "Baby Swordsman";
  565. case 4025: return "Baby Mage";
  566. case 4026: return "Baby Archer";
  567. case 4027: return "Baby Acolyte";
  568. case 4028: return "Baby Merchant";
  569. case 4029: return "Baby Thief";
  570. case 4030: return "Baby Knight";
  571. case 4031: return "Baby Priest";
  572. case 4032: return "Baby Wizard";
  573. case 4033: return "Baby Blacksmith";
  574. case 4034: return "Baby Hunter";
  575. case 4035: return "Baby Assassin";
  576. case 4036: return "Baby Peco Knight";
  577. case 4037: return "Baby Crusader";
  578. case 4038: return "Baby Monk";
  579. case 4039: return "Baby Sage";
  580. case 4040: return "Baby Rogue";
  581. case 4041: return "Baby Alchemist";
  582. case 4042: return "Baby Bard";
  583. case 4043: return "Baby Dancer";
  584. case 4044: return "Baby Peco Crusader";
  585. case 4045: return "Super Baby";
  586. }
  587. return "Unknown Job";
  588. }
  589. /*==========================================
  590. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  591. *------------------------------------------
  592. */
  593. char *estr_lower(char *str)
  594. {
  595. int i;
  596. for (i=0; str[i]; i++)
  597. if ((str[i] >= 65) && (str[i] <= 90))
  598. str[i] += 32;
  599. return str;
  600. }
  601. // compare function for sorting high to lowest
  602. int hightolow_compare (const void * a, const void * b)
  603. {
  604. return ( *(int*)b - *(int*)a );
  605. }
  606. // compare function for sorting lowest to highest
  607. int lowtohigh_compare (const void * a, const void * b)
  608. {
  609. return ( *(int*)a - *(int*)b );
  610. }
  611. //-----------------------------------------------------------
  612. // Return the message string of the specified number by [Yor]
  613. //-----------------------------------------------------------
  614. char * msg_txt(int msg_number) {
  615. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])) &&
  616. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  617. return msg_table[msg_number];
  618. return "??";
  619. }
  620. //------------------------------------------------------------
  621. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  622. //------------------------------------------------------------
  623. int e_mail_check(unsigned char *email) {
  624. char ch;
  625. unsigned char* last_arobas;
  626. // athena limits
  627. if (strlen(email) < 3 || strlen(email) > 39)
  628. return 0;
  629. // part of RFC limits (official reference of e-mail description)
  630. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  631. return 0;
  632. if (email[strlen(email)-1] == '.')
  633. return 0;
  634. last_arobas = strrchr(email, '@');
  635. if (strstr(last_arobas, "@.") != NULL ||
  636. strstr(last_arobas, "..") != NULL)
  637. return 0;
  638. for(ch = 1; ch < 32; ch++) {
  639. if (strchr(last_arobas, ch) != NULL) {
  640. return 0;
  641. break;
  642. }
  643. }
  644. if (strchr(last_arobas, ' ') != NULL ||
  645. strchr(last_arobas, ';') != NULL)
  646. return 0;
  647. // all correct
  648. return 1;
  649. }
  650. /*==========================================
  651. * get_atcommand_level @コマンドの必要レベルを取得
  652. *------------------------------------------
  653. */
  654. int get_atcommand_level(const AtCommandType type) {
  655. int i;
  656. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  657. if (atcommand_info[i].type == type)
  658. return atcommand_info[i].level;
  659. return 100; // 100: command can not be used
  660. }
  661. /*==========================================
  662. *is_atcommand @コマンドに存在するかどうか確認する
  663. *------------------------------------------
  664. */
  665. AtCommandType
  666. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  667. const char* str = message;
  668. int s_flag = 0;
  669. AtCommandInfo info;
  670. AtCommandType type;
  671. nullpo_retr(AtCommand_None, sd);
  672. if (!battle_config.allow_atcommand_when_mute &&
  673. sd->sc_count && sd->sc_data[SC_NOCHAT].timer != -1) {
  674. return AtCommand_Unknown;
  675. }
  676. if (!message || !*message)
  677. return AtCommand_None;
  678. memset(&info, 0, sizeof(info));
  679. str += strlen(sd->status.name);
  680. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  681. if (*str == ':')
  682. s_flag = 1;
  683. str++;
  684. }
  685. if (!*str)
  686. return AtCommand_None;
  687. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  688. if (type != AtCommand_None) {
  689. char command[100];
  690. char output[200];
  691. const char* p = str;
  692. memset(command, '\0', sizeof(command));
  693. memset(output, '\0', sizeof(output));
  694. while (*p && !isspace(*p))
  695. p++;
  696. if (p - str >= sizeof(command)) // too long
  697. return AtCommand_Unknown;
  698. strncpy(command, str, p - str);
  699. while (isspace(*p))
  700. p++;
  701. if (type == AtCommand_Unknown || info.proc == NULL) {
  702. sprintf(output, msg_table[153], command); // %s is Unknown Command.
  703. clif_displaymessage(fd, output);
  704. } else {
  705. if (info.proc(fd, sd, command, p) != 0) {
  706. // Command can not be executed
  707. sprintf(output, msg_table[154], command); // %s failed.
  708. clif_displaymessage(fd, output);
  709. }
  710. }
  711. return info.type;
  712. }
  713. return AtCommand_None;
  714. }
  715. /*==========================================
  716. *
  717. *------------------------------------------
  718. */
  719. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  720. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  721. if (!info)
  722. return AtCommand_None;
  723. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  724. return AtCommand_None;
  725. if (!p || !*p) {
  726. fprintf(stderr, "at command message is empty\n");
  727. return AtCommand_None;
  728. }
  729. if (*p == command_symbol) { // check first char.
  730. char command[101];
  731. int i = 0;
  732. memset(info, 0, sizeof(AtCommandInfo));
  733. sscanf(p, "%100s", command);
  734. command[sizeof(command)-1] = '\0';
  735. while (atcommand_info[i].type != AtCommand_Unknown) {
  736. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  737. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  738. break;
  739. }
  740. i++;
  741. }
  742. if (atcommand_info[i].type == AtCommand_Unknown) {
  743. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  744. if (level == 0)
  745. return AtCommand_None;
  746. else
  747. return AtCommand_Unknown;
  748. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  749. log_atcommand(sd, message);
  750. }
  751. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  752. } else {
  753. return AtCommand_None;
  754. }
  755. return info->type;
  756. }
  757. /*==========================================
  758. *
  759. *------------------------------------------
  760. */
  761. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  762. int flag = va_arg(ap, int);
  763. nullpo_retr(0, bl);
  764. if (flag)
  765. mob_damage(NULL, (struct mob_data *)bl, ((struct mob_data *)bl)->hp, 2);
  766. else
  767. mob_delete((struct mob_data *)bl);
  768. return 0;
  769. }
  770. /*==========================================
  771. * Mob search
  772. *------------------------------------------
  773. */
  774. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  775. {
  776. int mob_id,fd;
  777. static int number=0;
  778. struct mob_data *md;
  779. char output[128];
  780. nullpo_retr(0, bl);
  781. if(!ap){
  782. number=0;
  783. return 0;
  784. }
  785. mob_id = va_arg(ap,int);
  786. fd = va_arg(ap,int);
  787. md = (struct mob_data *)bl;
  788. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  789. snprintf(output, sizeof output, "%2d[%3d:%3d] %s",
  790. ++number,bl->x, bl->y,md->name);
  791. clif_displaymessage(fd, output);
  792. }
  793. return 0;
  794. }
  795. /*==========================================
  796. * cleanmap
  797. *------------------------------------------
  798. */
  799. static int atcommand_cleanmap_sub(struct block_list *bl,va_list ap)
  800. {
  801. struct flooritem_data *fitem;
  802. nullpo_retr(0, bl);
  803. fitem = (struct flooritem_data *)bl;
  804. if(fitem==NULL || fitem->bl.type!=BL_ITEM){
  805. if(battle_config.error_log)
  806. printf("map_clearflooritem_timer : error\n");
  807. return 1;
  808. }
  809. delete_timer(fitem->cleartimer,map_clearflooritem_timer);
  810. if(fitem->item_data.card[0] == (short)0xff00)
  811. intif_delete_petdata(*((long *)(&fitem->item_data.card[1])));
  812. clif_clearflooritem(fitem,0);
  813. map_delobject(fitem->bl.id);
  814. return 0;
  815. }
  816. static int atkillnpc_sub(struct block_list *bl, va_list ap)
  817. {
  818. int flag = va_arg(ap,int);
  819. nullpo_retr(0, bl);
  820. npc_delete((struct npc_data *)bl);
  821. flag = 0;
  822. return 0;
  823. }
  824. void rehash( const int fd, struct map_session_data* sd )
  825. {
  826. int map_id = 0;
  827. int LOADED_MAPS = map_num;
  828. for (map_id = 0; map_id < LOADED_MAPS;map_id++) {
  829. if (map_id > LOADED_MAPS)
  830. break;
  831. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, 0);
  832. map_foreachinarea(atkillnpc_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_NPC, 0);
  833. }
  834. }
  835. /*==========================================
  836. * Read Message Data
  837. *------------------------------------------
  838. */
  839. int msg_config_read(const char *cfgName) {
  840. int msg_number;
  841. char line[1024], w1[1024], w2[1024];
  842. FILE *fp;
  843. if ((fp = fopen(cfgName, "r")) == NULL) {
  844. printf("Messages file not found: %s\n", cfgName);
  845. return 1;
  846. }
  847. while(fgets(line, sizeof(line)-1, fp)) {
  848. if (line[0] == '/' && line[1] == '/')
  849. continue;
  850. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  851. if (strcmpi(w1, "import") == 0) {
  852. msg_config_read(w2);
  853. } else {
  854. msg_number = atoi(w1);
  855. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])))
  856. strcpy(msg_table[msg_number], w2);
  857. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  858. }
  859. }
  860. }
  861. fclose(fp);
  862. return 0;
  863. }
  864. /*==========================================
  865. *
  866. *------------------------------------------
  867. */
  868. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  869. int i;
  870. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  871. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  872. return &atcommand_info[i];
  873. return NULL;
  874. }
  875. /*==========================================
  876. *
  877. *------------------------------------------
  878. */
  879. int atcommand_config_read(const char *cfgName) {
  880. char line[1024], w1[1024], w2[1024];
  881. AtCommandInfo* p;
  882. FILE* fp;
  883. if ((fp = fopen(cfgName, "r")) == NULL) {
  884. printf("At commands configuration file not found: %s\n", cfgName);
  885. return 1;
  886. }
  887. while (fgets(line, sizeof(line)-1, fp)) {
  888. if (line[0] == '/' && line[1] == '/')
  889. continue;
  890. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  891. continue;
  892. p = get_atcommandinfo_byname(w1);
  893. if (p != NULL) {
  894. p->level = atoi(w2);
  895. if (p->level > 100)
  896. p->level = 100;
  897. else if (p->level < 0)
  898. p->level = 0;
  899. }
  900. if (strcmpi(w1, "import") == 0)
  901. atcommand_config_read(w2);
  902. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  903. w2[0] != '/' && // symbol of standard ragnarok GM commands
  904. w2[0] != '%' && // symbol of party chat speaking
  905. w2[0] != '#') // symbol of charcommand
  906. command_symbol = w2[0];
  907. }
  908. fclose(fp);
  909. return 0;
  910. }
  911. /*==========================================
  912. // @ command processing functions
  913. *------------------------------------------
  914. */
  915. /*==========================================
  916. * @send (used for testing packet sends from the client)
  917. *------------------------------------------
  918. */
  919. int atcommand_send(
  920. const int fd, struct map_session_data* sd,
  921. const char* command, const char* message)
  922. {
  923. int a = atoi(message);
  924. if (a)
  925. {
  926. unsigned char buf[1024];
  927. switch(a)
  928. {
  929. case 1:
  930. WBUFW(buf,0)=0x18d;
  931. case 2:
  932. WBUFW(buf,0)=0x18e;
  933. case 3:
  934. WBUFW(buf,0)=0x18f;
  935. case 4:
  936. WBUFW(buf,0)=0x190;
  937. }
  938. }
  939. return 0;
  940. }
  941. // @rura
  942. /*==========================================
  943. *
  944. *------------------------------------------
  945. */
  946. int atcommand_rura(
  947. const int fd, struct map_session_data* sd,
  948. const char* command, const char* message)
  949. {
  950. char map_name[100];
  951. int x = 0, y = 0;
  952. int m;
  953. nullpo_retr(-1, sd);
  954. memset(map_name, '\0', sizeof(map_name));
  955. if (!message || !*message || sscanf(message, "%99s %d %d", map_name, &x, &y) < 1) {
  956. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  957. return -1;
  958. }
  959. if (x <= 0)
  960. x = rand() % 399 + 1;
  961. if (y <= 0)
  962. y = rand() % 399 + 1;
  963. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  964. strcat(map_name, ".gat");
  965. if (x > 0 && x < 400 && y > 0 && y < 400) {
  966. m = map_mapname2mapid(map_name);
  967. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  968. clif_displaymessage(fd, "You are not authorised to warp you to this map.");
  969. return -1;
  970. }
  971. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  972. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  973. return -1;
  974. }
  975. if (pc_setpos(sd, map_name, x, y, 3) == 0)
  976. clif_displaymessage(fd, msg_table[0]); // Warped.
  977. else {
  978. clif_displaymessage(fd, msg_table[1]); // Map not found.
  979. return -1;
  980. }
  981. } else {
  982. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  983. return -1;
  984. }
  985. return 0;
  986. }
  987. /*==========================================
  988. *
  989. *------------------------------------------
  990. */
  991. int atcommand_where(
  992. const int fd, struct map_session_data* sd,
  993. const char* command, const char* message)
  994. {
  995. char character[100];
  996. char output[200];
  997. struct map_session_data *pl_sd = NULL;
  998. nullpo_retr(-1, sd);
  999. if (!message || !*message)
  1000. return -1;
  1001. memset(character, '\0', sizeof character);
  1002. if (sscanf(message, "%99[^\n]", character) < 1)
  1003. return -1;
  1004. if(strncmp(sd->status.name,character,24)==0)
  1005. return -1;
  1006. if ((pl_sd = map_nick2sd(character)) == NULL) {
  1007. snprintf(output, sizeof output, "%s %d %d",
  1008. sd->mapname, sd->bl.x, sd->bl.y);
  1009. clif_displaymessage(fd, output);
  1010. return -1;
  1011. }
  1012. snprintf(output, sizeof output, "%s %s %d %d",
  1013. character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1014. clif_displaymessage(fd, output);
  1015. return 0;
  1016. }
  1017. /*==========================================
  1018. *
  1019. *------------------------------------------
  1020. */
  1021. int atcommand_jumpto(
  1022. const int fd, struct map_session_data* sd,
  1023. const char* command, const char* message)
  1024. {
  1025. char character[100];
  1026. char output[200];
  1027. struct map_session_data *pl_sd = NULL;
  1028. nullpo_retr(-1, sd);
  1029. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1030. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1031. return -1;
  1032. }
  1033. memset(character, '\0', sizeof character);
  1034. if (sscanf(message, "%99[^\n]", character) < 1)
  1035. return -1;
  1036. if(strncmp(sd->status.name,character,24)==0) //Yourself mate? Tsk tsk tsk.
  1037. return -1;
  1038. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1039. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1040. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  1041. return -1;
  1042. }
  1043. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1044. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1045. return -1;
  1046. }
  1047. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  1048. sprintf(output, msg_table[4], character); // Jump to %s
  1049. clif_displaymessage(fd, output);
  1050. } else {
  1051. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1052. return -1;
  1053. }
  1054. return 0;
  1055. }
  1056. /*==========================================
  1057. *
  1058. *------------------------------------------
  1059. */
  1060. int atcommand_jump(
  1061. const int fd, struct map_session_data* sd,
  1062. const char* command, const char* message)
  1063. {
  1064. char output[200];
  1065. int x = 0, y = 0;
  1066. nullpo_retr(-1, sd);
  1067. memset(output, '\0', sizeof(output));
  1068. sscanf(message, "%d %d", &x, &y);
  1069. if (x <= 0)
  1070. x = rand() % 399 + 1;
  1071. if (y <= 0)
  1072. y = rand() % 399 + 1;
  1073. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1074. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1075. clif_displaymessage(fd, "You are not authorised to warp you to your actual map.");
  1076. return -1;
  1077. }
  1078. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1079. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1080. return -1;
  1081. }
  1082. pc_setpos(sd, sd->mapname, x, y, 3);
  1083. sprintf(output, msg_table[5], x, y); // Jump to %d %d
  1084. clif_displaymessage(fd, output);
  1085. } else {
  1086. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1087. return -1;
  1088. }
  1089. return 0;
  1090. }
  1091. /*==========================================
  1092. *
  1093. *------------------------------------------
  1094. */
  1095. int atcommand_who(
  1096. const int fd, struct map_session_data* sd,
  1097. const char* command, const char* message)
  1098. {
  1099. char output[200];
  1100. struct map_session_data *pl_sd;
  1101. int i, j, count;
  1102. int pl_GM_level, GM_level;
  1103. char match_text[100];
  1104. char player_name[24];
  1105. nullpo_retr(-1, sd);
  1106. memset(output, '\0', sizeof(output));
  1107. memset(match_text, '\0', sizeof(match_text));
  1108. memset(player_name, '\0', sizeof(player_name));
  1109. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1110. strcpy(match_text, "");
  1111. for (j = 0; match_text[j]; j++)
  1112. match_text[j] = tolower(match_text[j]);
  1113. count = 0;
  1114. GM_level = pc_isGM(sd);
  1115. for (i = 0; i < fd_max; i++) {
  1116. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1117. pl_GM_level = pc_isGM(pl_sd);
  1118. 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
  1119. memcpy(player_name, pl_sd->status.name, 24);
  1120. for (j = 0; player_name[j]; j++)
  1121. player_name[j] = tolower(player_name[j]);
  1122. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1123. if (pl_GM_level > 0)
  1124. 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);
  1125. else
  1126. 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);
  1127. clif_displaymessage(fd, output);
  1128. count++;
  1129. }
  1130. }
  1131. }
  1132. }
  1133. if (count == 0)
  1134. clif_displaymessage(fd, msg_table[28]); // No player found.
  1135. else if (count == 1)
  1136. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1137. else {
  1138. sprintf(output, msg_table[30], count); // %d players found.
  1139. clif_displaymessage(fd, output);
  1140. }
  1141. return 0;
  1142. }
  1143. /*==========================================
  1144. *
  1145. *------------------------------------------
  1146. */
  1147. int atcommand_who2(
  1148. const int fd, struct map_session_data* sd,
  1149. const char* command, const char* message)
  1150. {
  1151. char output[200];
  1152. struct map_session_data *pl_sd;
  1153. int i, j, count;
  1154. int pl_GM_level, GM_level;
  1155. char match_text[100];
  1156. char player_name[24];
  1157. nullpo_retr(-1, sd);
  1158. memset(output, '\0', sizeof(output));
  1159. memset(match_text, '\0', sizeof(match_text));
  1160. memset(player_name, '\0', sizeof(player_name));
  1161. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1162. strcpy(match_text, "");
  1163. for (j = 0; match_text[j]; j++)
  1164. match_text[j] = tolower(match_text[j]);
  1165. count = 0;
  1166. GM_level = pc_isGM(sd);
  1167. for (i = 0; i < fd_max; i++) {
  1168. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1169. pl_GM_level = pc_isGM(pl_sd);
  1170. 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
  1171. memcpy(player_name, pl_sd->status.name, 24);
  1172. for (j = 0; player_name[j]; j++)
  1173. player_name[j] = tolower(player_name[j]);
  1174. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1175. if (pl_GM_level > 0)
  1176. 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);
  1177. else
  1178. 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);
  1179. clif_displaymessage(fd, output);
  1180. count++;
  1181. }
  1182. }
  1183. }
  1184. }
  1185. if (count == 0)
  1186. clif_displaymessage(fd, msg_table[28]); // No player found.
  1187. else if (count == 1)
  1188. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1189. else {
  1190. sprintf(output, msg_table[30], count); // %d players found.
  1191. clif_displaymessage(fd, output);
  1192. }
  1193. return 0;
  1194. }
  1195. /*==========================================
  1196. *
  1197. *------------------------------------------
  1198. */
  1199. int atcommand_who3(
  1200. const int fd, struct map_session_data* sd,
  1201. const char* command, const char* message)
  1202. {
  1203. char temp0[100];
  1204. char temp1[100];
  1205. char output[200];
  1206. struct map_session_data *pl_sd;
  1207. int i, j, count;
  1208. int pl_GM_level, GM_level;
  1209. char match_text[100];
  1210. char player_name[24];
  1211. struct guild *g;
  1212. struct party *p;
  1213. nullpo_retr(-1, sd);
  1214. memset(temp0, '\0', sizeof(temp0));
  1215. memset(temp1, '\0', sizeof(temp1));
  1216. memset(output, '\0', sizeof(output));
  1217. memset(match_text, '\0', sizeof(match_text));
  1218. memset(player_name, '\0', sizeof(player_name));
  1219. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1220. strcpy(match_text, "");
  1221. for (j = 0; match_text[j]; j++)
  1222. match_text[j] = tolower(match_text[j]);
  1223. count = 0;
  1224. GM_level = pc_isGM(sd);
  1225. for (i = 0; i < fd_max; i++) {
  1226. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1227. pl_GM_level = pc_isGM(pl_sd);
  1228. 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
  1229. memcpy(player_name, pl_sd->status.name, 24);
  1230. for (j = 0; player_name[j]; j++)
  1231. player_name[j] = tolower(player_name[j]);
  1232. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1233. g = guild_search(pl_sd->status.guild_id);
  1234. if (g == NULL)
  1235. sprintf(temp1, "None");
  1236. else
  1237. sprintf(temp1, "%s", g->name);
  1238. p = party_search(pl_sd->status.party_id);
  1239. if (p == NULL)
  1240. sprintf(temp0, "None");
  1241. else
  1242. sprintf(temp0, "%s", p->name);
  1243. if (pl_GM_level > 0)
  1244. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1245. else
  1246. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1247. clif_displaymessage(fd, output);
  1248. count++;
  1249. }
  1250. }
  1251. }
  1252. }
  1253. if (count == 0)
  1254. clif_displaymessage(fd, msg_table[28]); // No player found.
  1255. else if (count == 1)
  1256. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1257. else {
  1258. sprintf(output, msg_table[30], count); // %d players found.
  1259. clif_displaymessage(fd, output);
  1260. }
  1261. return 0;
  1262. }
  1263. /*==========================================
  1264. *
  1265. *------------------------------------------
  1266. */
  1267. int atcommand_whomap(
  1268. const int fd, struct map_session_data* sd,
  1269. const char* command, const char* message)
  1270. {
  1271. char output[200];
  1272. struct map_session_data *pl_sd;
  1273. int i, count;
  1274. int pl_GM_level, GM_level;
  1275. int map_id;
  1276. char map_name[100];
  1277. memset(output, '\0', sizeof(output));
  1278. memset(map_name, '\0', sizeof(map_name));
  1279. if (!message || !*message)
  1280. map_id = sd->bl.m;
  1281. else {
  1282. sscanf(message, "%99s", map_name);
  1283. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1284. strcat(map_name, ".gat");
  1285. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1286. map_id = sd->bl.m;
  1287. }
  1288. count = 0;
  1289. GM_level = pc_isGM(sd);
  1290. for (i = 0; i < fd_max; i++) {
  1291. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1292. pl_GM_level = pc_isGM(pl_sd);
  1293. 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
  1294. if (pl_sd->bl.m == map_id) {
  1295. if (pl_GM_level > 0)
  1296. 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);
  1297. else
  1298. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1299. clif_displaymessage(fd, output);
  1300. count++;
  1301. }
  1302. }
  1303. }
  1304. }
  1305. if (count == 0)
  1306. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1307. else if (count == 1)
  1308. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1309. else {
  1310. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1311. }
  1312. clif_displaymessage(fd, output);
  1313. return 0;
  1314. }
  1315. /*==========================================
  1316. *
  1317. *------------------------------------------
  1318. */
  1319. int atcommand_whomap2(
  1320. const int fd, struct map_session_data* sd,
  1321. const char* command, const char* message)
  1322. {
  1323. char output[200];
  1324. struct map_session_data *pl_sd;
  1325. int i, count;
  1326. int pl_GM_level, GM_level;
  1327. int map_id = 0;
  1328. char map_name[100];
  1329. nullpo_retr(-1, sd);
  1330. memset(output, '\0', sizeof(output));
  1331. memset(map_name, '\0', sizeof(map_name));
  1332. if (!message || !*message)
  1333. map_id = sd->bl.m;
  1334. else {
  1335. sscanf(message, "%99s", map_name);
  1336. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1337. strcat(map_name, ".gat");
  1338. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1339. map_id = sd->bl.m;
  1340. }
  1341. count = 0;
  1342. GM_level = pc_isGM(sd);
  1343. for (i = 0; i < fd_max; i++) {
  1344. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1345. pl_GM_level = pc_isGM(pl_sd);
  1346. 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
  1347. if (pl_sd->bl.m == map_id) {
  1348. if (pl_GM_level > 0)
  1349. 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);
  1350. else
  1351. 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);
  1352. clif_displaymessage(fd, output);
  1353. count++;
  1354. }
  1355. }
  1356. }
  1357. }
  1358. if (count == 0)
  1359. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1360. else if (count == 1)
  1361. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1362. else {
  1363. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1364. }
  1365. clif_displaymessage(fd, output);
  1366. return 0;
  1367. }
  1368. /*==========================================
  1369. *
  1370. *------------------------------------------
  1371. */
  1372. int atcommand_whomap3(
  1373. const int fd, struct map_session_data* sd,
  1374. const char* command, const char* message)
  1375. {
  1376. char temp0[100];
  1377. char temp1[100];
  1378. char output[200];
  1379. struct map_session_data *pl_sd;
  1380. int i, count;
  1381. int pl_GM_level, GM_level;
  1382. int map_id = 0;
  1383. char map_name[100];
  1384. struct guild *g;
  1385. struct party *p;
  1386. nullpo_retr(-1, sd);
  1387. memset(temp0, '\0', sizeof(temp0));
  1388. memset(temp1, '\0', sizeof(temp1));
  1389. memset(output, '\0', sizeof(output));
  1390. memset(map_name, '\0', sizeof(map_name));
  1391. if (!message || !*message)
  1392. map_id = sd->bl.m;
  1393. else {
  1394. sscanf(message, "%99s", map_name);
  1395. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1396. strcat(map_name, ".gat");
  1397. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1398. map_id = sd->bl.m;
  1399. }
  1400. count = 0;
  1401. GM_level = pc_isGM(sd);
  1402. for (i = 0; i < fd_max; i++) {
  1403. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1404. pl_GM_level = pc_isGM(pl_sd);
  1405. 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
  1406. if (pl_sd->bl.m == map_id) {
  1407. g = guild_search(pl_sd->status.guild_id);
  1408. if (g == NULL)
  1409. sprintf(temp1, "None");
  1410. else
  1411. sprintf(temp1, "%s", g->name);
  1412. p = party_search(pl_sd->status.party_id);
  1413. if (p == NULL)
  1414. sprintf(temp0, "None");
  1415. else
  1416. sprintf(temp0, "%s", p->name);
  1417. if (pl_GM_level > 0)
  1418. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1419. else
  1420. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1421. clif_displaymessage(fd, output);
  1422. count++;
  1423. }
  1424. }
  1425. }
  1426. }
  1427. if (count == 0)
  1428. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1429. else if (count == 1)
  1430. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1431. else {
  1432. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1433. }
  1434. clif_displaymessage(fd, output);
  1435. return 0;
  1436. }
  1437. /*==========================================
  1438. *
  1439. *------------------------------------------
  1440. */
  1441. int atcommand_whogm(
  1442. const int fd, struct map_session_data* sd,
  1443. const char* command, const char* message)
  1444. {
  1445. char temp0[100];
  1446. char temp1[100];
  1447. char output[200];
  1448. struct map_session_data *pl_sd;
  1449. int i, j, count;
  1450. int pl_GM_level, GM_level;
  1451. char match_text[100];
  1452. char player_name[24];
  1453. struct guild *g;
  1454. struct party *p;
  1455. nullpo_retr(-1, sd);
  1456. memset(temp0, '\0', sizeof(temp0));
  1457. memset(temp1, '\0', sizeof(temp1));
  1458. memset(output, '\0', sizeof(output));
  1459. memset(match_text, '\0', sizeof(match_text));
  1460. memset(player_name, '\0', sizeof(player_name));
  1461. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1462. strcpy(match_text, "");
  1463. for (j = 0; match_text[j]; j++)
  1464. match_text[j] = tolower(match_text[j]);
  1465. count = 0;
  1466. GM_level = pc_isGM(sd);
  1467. for (i = 0; i < fd_max; i++) {
  1468. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1469. pl_GM_level = pc_isGM(pl_sd);
  1470. if (pl_GM_level > 0) {
  1471. 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
  1472. memcpy(player_name, pl_sd->status.name, 24);
  1473. for (j = 0; player_name[j]; j++)
  1474. player_name[j] = tolower(player_name[j]);
  1475. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1476. 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);
  1477. clif_displaymessage(fd, output);
  1478. sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1479. clif_displaymessage(fd, output);
  1480. g = guild_search(pl_sd->status.guild_id);
  1481. if (g == NULL)
  1482. sprintf(temp1, "None");
  1483. else
  1484. sprintf(temp1, "%s", g->name);
  1485. p = party_search(pl_sd->status.party_id);
  1486. if (p == NULL)
  1487. sprintf(temp0, "None");
  1488. else
  1489. sprintf(temp0, "%s", p->name);
  1490. sprintf(output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1491. clif_displaymessage(fd, output);
  1492. count++;
  1493. }
  1494. }
  1495. }
  1496. }
  1497. }
  1498. if (count == 0)
  1499. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1500. else if (count == 1)
  1501. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1502. else {
  1503. sprintf(output, msg_table[152], count); // %d GMs found.
  1504. clif_displaymessage(fd, output);
  1505. }
  1506. return 0;
  1507. }
  1508. int atcommand_whozeny(
  1509. const int fd, struct map_session_data* sd,
  1510. const char* command, const char* message)
  1511. {
  1512. char output[200];
  1513. struct map_session_data *pl_sd;
  1514. int i, j, count,c;
  1515. char match_text[100];
  1516. char player_name[24];
  1517. //int zeny[clif_countusers()];
  1518. //int counted[clif_countusers()];
  1519. int *zeny = (int *)aCallocA(clif_countusers(), sizeof(int));
  1520. int *counted = (int *)aCallocA(clif_countusers(), sizeof(int));
  1521. nullpo_retr(-1, sd);
  1522. memset(output, '\0', sizeof(output));
  1523. memset(match_text, '\0', sizeof(match_text));
  1524. memset(player_name, '\0', sizeof(player_name));
  1525. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1526. strcpy(match_text, "");
  1527. for (j = 0; match_text[j]; j++)
  1528. match_text[j] = tolower(match_text[j]);
  1529. count = 0;
  1530. for (i = 0; i < fd_max; i++) {
  1531. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1532. memcpy(player_name, pl_sd->status.name, 24);
  1533. for (j = 0; player_name[j]; j++)
  1534. player_name[j] = tolower(player_name[j]);
  1535. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1536. zeny[count]=pl_sd->status.zeny;
  1537. counted[i]=0;
  1538. count++;
  1539. }
  1540. }
  1541. }
  1542. qsort(zeny, count, sizeof(int), hightolow_compare);
  1543. for (c = 0; c < count && c < 50; c++) {
  1544. if(!zeny[c])
  1545. continue;
  1546. for (i = 0; i < fd_max; i++) {
  1547. if(!zeny[c])
  1548. continue;
  1549. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && zeny[c] && counted[i]==0) {
  1550. if(pl_sd->status.zeny==zeny[c]) {
  1551. sprintf(output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1552. clif_displaymessage(fd, output);
  1553. zeny[c]=0;
  1554. counted[i]=1;
  1555. }
  1556. }
  1557. }
  1558. }
  1559. if (count == 0)
  1560. clif_displaymessage(fd, msg_table[28]); // No player found.
  1561. else if (count == 1)
  1562. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1563. else {
  1564. sprintf(output, msg_table[30], count); // %d players found.
  1565. clif_displaymessage(fd, output);
  1566. }
  1567. free(zeny);
  1568. free(counted);
  1569. return 0;
  1570. }
  1571. // cause random emote on all online players [Valaris]
  1572. int atcommand_happyhappyjoyjoy(
  1573. const int fd, struct map_session_data* sd,
  1574. const char* command, const char* message)
  1575. {
  1576. struct map_session_data *pl_sd;
  1577. int i,e;
  1578. nullpo_retr(-1, sd);
  1579. for (i = 0; i < fd_max; i++) {
  1580. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1581. e=rand()%40;
  1582. if(e==34)
  1583. e = 0;
  1584. clif_emotion(&pl_sd->bl,e);
  1585. }
  1586. }
  1587. return 0;
  1588. }
  1589. /*==========================================
  1590. *
  1591. *------------------------------------------
  1592. */
  1593. int atcommand_save(
  1594. const int fd, struct map_session_data* sd,
  1595. const char* command, const char* message)
  1596. {
  1597. nullpo_retr(-1, sd);
  1598. pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y);
  1599. if (sd->status.pet_id > 0 && sd->pd)
  1600. intif_save_petdata(sd->status.account_id, &sd->pet);
  1601. pc_makesavestatus(sd);
  1602. chrif_save(sd);
  1603. storage_storage_save(sd);
  1604. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1605. return 0;
  1606. }
  1607. /*==========================================
  1608. *
  1609. *------------------------------------------
  1610. */
  1611. int atcommand_load(
  1612. const int fd, struct map_session_data* sd,
  1613. const char* command, const char* message)
  1614. {
  1615. int m;
  1616. nullpo_retr(-1, sd);
  1617. m = map_mapname2mapid(sd->status.save_point.map);
  1618. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1619. clif_displaymessage(fd, "You are not authorised to warp you to your save map.");
  1620. return -1;
  1621. }
  1622. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1623. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1624. return -1;
  1625. }
  1626. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1627. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1628. return 0;
  1629. }
  1630. /*==========================================
  1631. *
  1632. *------------------------------------------
  1633. */
  1634. int atcommand_speed(
  1635. const int fd, struct map_session_data* sd,
  1636. const char* command, const char* message)
  1637. {
  1638. char output[200];
  1639. int speed;
  1640. nullpo_retr(-1, sd);
  1641. memset(output, '\0', sizeof(output));
  1642. if (!message || !*message) {
  1643. sprintf(output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1644. clif_displaymessage(fd, output);
  1645. return -1;
  1646. }
  1647. speed = atoi(message);
  1648. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1649. sd->speed = speed;
  1650. //sd->walktimer = x;
  1651. //この文を追加 by れ�
  1652. clif_updatestatus(sd, SP_SPEED);
  1653. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1654. } else {
  1655. sprintf(output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1656. clif_displaymessage(fd, output);
  1657. return -1;
  1658. }
  1659. return 0;
  1660. }
  1661. /*==========================================
  1662. *
  1663. *------------------------------------------
  1664. */
  1665. int atcommand_storage(
  1666. const int fd, struct map_session_data* sd,
  1667. const char* command, const char* message)
  1668. {
  1669. nullpo_retr(-1, sd);
  1670. storage_storageopen(sd);
  1671. return 0;
  1672. }
  1673. /*==========================================
  1674. *
  1675. *------------------------------------------
  1676. */
  1677. int atcommand_guildstorage(
  1678. const int fd, struct map_session_data* sd,
  1679. const char* command, const char* message)
  1680. {
  1681. nullpo_retr(-1, sd);
  1682. if (sd->status.guild_id > 0)
  1683. storage_guild_storageopen(sd);
  1684. return 0;
  1685. }
  1686. /*==========================================
  1687. *
  1688. *------------------------------------------
  1689. */
  1690. int atcommand_option(
  1691. const int fd, struct map_session_data* sd,
  1692. const char* command, const char* message)
  1693. {
  1694. int param1 = 0, param2 = 0, param3 = 0;
  1695. nullpo_retr(-1, sd);
  1696. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1697. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1698. return -1;
  1699. }
  1700. sd->opt1 = param1;
  1701. sd->opt2 = param2;
  1702. if (!(sd->status.option & CART_MASK) && param3 & CART_MASK) {
  1703. clif_cart_itemlist(sd);
  1704. clif_cart_equiplist(sd);
  1705. clif_updatestatus(sd, SP_CARTINFO);
  1706. }
  1707. sd->status.option = param3;
  1708. // fix pecopeco display
  1709. if (sd->status.class_ == 13 || sd->status.class_ == 21 || sd->status.class_ == 4014 || sd->status.class_ == 4022) {
  1710. if (!pc_isriding(sd)) { // sd have the new value...
  1711. if (sd->status.class_ == 13)
  1712. sd->status.class_ = sd->view_class = 7;
  1713. else if (sd->status.class_ == 21)
  1714. sd->status.class_ = sd->view_class = 14;
  1715. else if (sd->status.class_ == 4014)
  1716. sd->status.class_ = sd->view_class = 4008;
  1717. else if (sd->status.class_ == 4022)
  1718. sd->status.class_ = sd->view_class = 4015;
  1719. }
  1720. } else {
  1721. if (pc_isriding(sd)) { // sd have the new value...
  1722. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  1723. sd->status.option &= ~0x0020;
  1724. } else {
  1725. if (sd->status.class_ == 7)
  1726. sd->status.class_ = sd->view_class = 13;
  1727. else if (sd->status.class_ == 14)
  1728. sd->status.class_ = sd->view_class = 21;
  1729. else if (sd->status.class_ == 4008)
  1730. sd->status.class_ = sd->view_class = 4014;
  1731. else if (sd->status.class_ == 4015)
  1732. sd->status.class_ = sd->view_class = 4022;
  1733. else
  1734. sd->status.option &= ~0x0020;
  1735. }
  1736. }
  1737. }
  1738. clif_changeoption(&sd->bl);
  1739. status_calc_pc(sd, 0);
  1740. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1741. return 0;
  1742. }
  1743. /*==========================================
  1744. *
  1745. *------------------------------------------
  1746. */
  1747. int atcommand_hide(
  1748. const int fd, struct map_session_data* sd,
  1749. const char* command, const char* message)
  1750. {
  1751. nullpo_retr(-1, sd);
  1752. if (sd->status.option & OPTION_HIDE) {
  1753. sd->status.option &= ~OPTION_HIDE;
  1754. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1755. } else {
  1756. sd->status.option |= OPTION_HIDE;
  1757. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1758. }
  1759. clif_changeoption(&sd->bl);
  1760. return 0;
  1761. }
  1762. /*==========================================
  1763. * 転職する upperを指定すると転生や養子にもなれる
  1764. *------------------------------------------
  1765. */
  1766. int atcommand_jobchange(
  1767. const int fd, struct map_session_data* sd,
  1768. const char* command, const char* message)
  1769. {
  1770. int job = 0, upper = 0;
  1771. nullpo_retr(-1, sd);
  1772. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1773. int i, found = 0;
  1774. const struct { char name[16]; int id; } jobs[] = {
  1775. { "novice", 0 },
  1776. { "swordsman", 1 },
  1777. { "mage", 2 },
  1778. { "archer", 3 },
  1779. { "acolyte", 4 },
  1780. { "merchant", 5 },
  1781. { "thief", 6 },
  1782. { "knight", 7 },
  1783. { "priest", 8 },
  1784. { "priestess", 8 },
  1785. { "wizard", 9 },
  1786. { "blacksmith", 10 },
  1787. { "hunter", 11 },
  1788. { "assassin", 12 },
  1789. { "crusader", 14 },
  1790. { "monk", 15 },
  1791. { "sage", 16 },
  1792. { "rogue", 17 },
  1793. { "alchemist", 18 },
  1794. { "bard", 19 },
  1795. { "dancer", 20 },
  1796. { "super novice", 23 },
  1797. { "supernovice", 23 },
  1798. { "high novice", 4001 },
  1799. { "swordsman high", 4002 },
  1800. { "mage high", 4003 },
  1801. { "archer high", 4004 },
  1802. { "acolyte high", 4005 },
  1803. { "merchant high", 4006 },
  1804. { "thief high", 4007 },
  1805. { "lord knight", 4008 },
  1806. { "high priest", 4009 },
  1807. { "high priestess", 4009 },
  1808. { "high wizard", 4010 },
  1809. { "whitesmith", 4011 },
  1810. { "sniper", 4012 },
  1811. { "assassin cross", 4013 },
  1812. { "paladin", 4015 },
  1813. { "champion", 4016 },
  1814. { "professor", 4017 },
  1815. { "stalker", 4018 },
  1816. { "creator", 4019 },
  1817. { "clown", 4020 },
  1818. { "gypsy", 4021 },
  1819. { "baby novice", 4023 },
  1820. { "baby swordsman", 4024 },
  1821. { "baby mage", 4025 },
  1822. { "baby archer", 4026 },
  1823. { "baby acolyte", 4027 },
  1824. { "baby merchant", 4028 },
  1825. { "baby thief", 4029 },
  1826. { "baby knight", 4030 },
  1827. { "baby priest", 4031 },
  1828. { "baby priestess", 4031 },
  1829. { "baby wizard", 4032 },
  1830. { "baby blacksmith",4033 },
  1831. { "baby hunter", 4034 },
  1832. { "baby assassin", 4035 },
  1833. { "baby crusader", 4037 },
  1834. { "baby monk", 4038 },
  1835. { "baby sage", 4039 },
  1836. { "baby rogue", 4040 },
  1837. { "baby alchemist", 4041 },
  1838. { "baby bard", 4042 },
  1839. { "baby dancer", 4043 },
  1840. { "super baby", 4045 },
  1841. };
  1842. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  1843. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1844. job = jobs[i].id;
  1845. upper = 0;
  1846. found = 1;
  1847. break;
  1848. }
  1849. }
  1850. if (!found) {
  1851. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  1852. return -1;
  1853. }
  1854. }
  1855. if (job == 37 ||job == 45)
  1856. return 0;
  1857. if ((job >= 0 && job < MAX_PC_CLASS)) {
  1858. int j;
  1859. // fix pecopeco display
  1860. if ((job != 13 && job != 21 && job != 4014 && job != 4022)) {
  1861. if (pc_isriding(sd)) {
  1862. if (sd->status.class_ == 13)
  1863. sd->status.class_ = sd->view_class = 7;
  1864. if (sd->status.class_ == 21)
  1865. sd->status.class_ = sd->view_class = 14;
  1866. if (sd->status.class_ == 4014)
  1867. sd->status.class_ = sd->view_class = 4008;
  1868. if (sd->status.class_ == 4022)
  1869. sd->status.class_ = sd->view_class = 4015;
  1870. sd->status.option &= ~0x0020;
  1871. clif_changeoption(&sd->bl);
  1872. status_calc_pc(sd, 0);
  1873. }
  1874. } else {
  1875. if (!pc_isriding(sd)) {
  1876. if (job == 13)
  1877. job = 7;
  1878. if (job == 21)
  1879. job = 14;
  1880. if (job == 4014)
  1881. job = 4008;
  1882. if (job == 4022)
  1883. job = 4015;
  1884. }
  1885. }
  1886. for (j=0; j < MAX_INVENTORY; j++) {
  1887. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  1888. pc_unequipitem(sd, j, 3);
  1889. }
  1890. if (pc_jobchange(sd, job, upper) == 0)
  1891. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  1892. else {
  1893. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  1894. return -1;
  1895. }
  1896. } else {
  1897. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  1898. return -1;
  1899. }
  1900. return 0;
  1901. }
  1902. /*==========================================
  1903. *
  1904. *------------------------------------------
  1905. */
  1906. int atcommand_die(
  1907. const int fd, struct map_session_data* sd,
  1908. const char* command, const char* message)
  1909. {
  1910. nullpo_retr(-1, sd);
  1911. clif_specialeffect(&sd->bl,450,1);
  1912. pc_damage(NULL, sd, sd->status.hp + 1);
  1913. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  1914. return 0;
  1915. }
  1916. /*==========================================
  1917. *
  1918. *------------------------------------------
  1919. */
  1920. int atcommand_kill(
  1921. const int fd, struct map_session_data* sd,
  1922. const char* command, const char* message)
  1923. {
  1924. char character[100];
  1925. struct map_session_data *pl_sd;
  1926. nullpo_retr(-1, sd);
  1927. memset(character, '\0', sizeof(character));
  1928. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1929. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  1930. return -1;
  1931. }
  1932. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1933. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  1934. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  1935. clif_displaymessage(fd, msg_table[14]); // Character killed.
  1936. } else {
  1937. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1938. return -1;
  1939. }
  1940. } else {
  1941. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1942. return -1;
  1943. }
  1944. return 0;
  1945. }
  1946. /*==========================================
  1947. *
  1948. *------------------------------------------
  1949. */
  1950. int atcommand_alive(
  1951. const int fd, struct map_session_data* sd,
  1952. const char* command, const char* message)
  1953. {
  1954. nullpo_retr(-1, sd);
  1955. if (pc_isdead(sd)) {
  1956. sd->status.hp = sd->status.max_hp;
  1957. sd->status.sp = sd->status.max_sp;
  1958. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1959. pc_setstand(sd);
  1960. if (battle_config.pc_invincible_time > 0)
  1961. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  1962. clif_updatestatus(sd, SP_HP);
  1963. clif_updatestatus(sd, SP_SP);
  1964. clif_resurrection(&sd->bl, 1);
  1965. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  1966. return 0;
  1967. }
  1968. return -1;
  1969. }
  1970. /*==========================================
  1971. *
  1972. *------------------------------------------
  1973. */
  1974. int atcommand_kami(
  1975. const int fd, struct map_session_data* sd,
  1976. const char* command, const char* message)
  1977. {
  1978. char output[200];
  1979. nullpo_retr(-1, sd);
  1980. memset(output, '\0', sizeof(output));
  1981. if (!message || !*message) {
  1982. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1983. return -1;
  1984. }
  1985. sscanf(message, "%199[^\n]", output);
  1986. intif_GMmessage(output, strlen(output) + 1, (*(command + 5) == 'b') ? 0x10 : 0);
  1987. return 0;
  1988. }
  1989. /*==========================================
  1990. *
  1991. *------------------------------------------
  1992. */
  1993. int atcommand_heal(
  1994. const int fd, struct map_session_data* sd,
  1995. const char* command, const char* message)
  1996. {
  1997. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1998. nullpo_retr(-1, sd);
  1999. sscanf(message, "%d %d", &hp, &sp);
  2000. if (hp == 0 && sp == 0) {
  2001. hp = sd->status.max_hp - sd->status.hp;
  2002. sp = sd->status.max_sp - sd->status.sp;
  2003. } else {
  2004. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2005. hp = sd->status.max_hp - sd->status.hp;
  2006. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2007. hp = 1 - sd->status.hp;
  2008. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2009. sp = sd->status.max_sp - sd->status.sp;
  2010. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2011. sp = 1 - sd->status.sp;
  2012. }
  2013. if (hp > 0) // display like heal
  2014. clif_heal(fd, SP_HP, hp);
  2015. else if (hp < 0) // display like damage
  2016. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2017. if (sp > 0) // no display when we lost SP
  2018. clif_heal(fd, SP_SP, sp);
  2019. if (hp != 0 || sp != 0) {
  2020. pc_heal(sd, hp, sp);
  2021. if (hp >= 0 && sp >= 0)
  2022. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2023. else
  2024. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2025. } else {
  2026. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2027. return -1;
  2028. }
  2029. return 0;
  2030. }
  2031. /*==========================================
  2032. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2033. *------------------------------------------
  2034. */
  2035. int atcommand_item(
  2036. const int fd, struct map_session_data* sd,
  2037. const char* command, const char* message)
  2038. {
  2039. char item_name[100];
  2040. int number = 0, item_id, flag;
  2041. struct item item_tmp;
  2042. struct item_data *item_data;
  2043. int get_count, i, pet_id;
  2044. nullpo_retr(-1, sd);
  2045. memset(item_name, '\0', sizeof(item_name));
  2046. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2047. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  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. get_count = number;
  2058. // check pet egg
  2059. pet_id = search_petDB_index(item_id, PET_EGG);
  2060. if (item_data->type == 4 || item_data->type == 5 ||
  2061. item_data->type == 7 || item_data->type == 8) {
  2062. get_count = 1;
  2063. }
  2064. for (i = 0; i < number; i += get_count) {
  2065. // if pet egg
  2066. if (pet_id >= 0) {
  2067. sd->catch_target_class = pet_db[pet_id].class_;
  2068. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2069. (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv,
  2070. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2071. 100, 0, 1, pet_db[pet_id].jname);
  2072. // if not pet egg
  2073. } else {
  2074. memset(&item_tmp, 0, sizeof(item_tmp));
  2075. item_tmp.nameid = item_id;
  2076. item_tmp.identify = 1;
  2077. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2078. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2079. }
  2080. }
  2081. clif_displaymessage(fd, msg_table[18]); // Item created.
  2082. } else {
  2083. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2084. return -1;
  2085. }
  2086. return 0;
  2087. }
  2088. /*==========================================
  2089. *
  2090. *------------------------------------------
  2091. */
  2092. int atcommand_item2(
  2093. const int fd, struct map_session_data* sd,
  2094. const char* command, const char* message)
  2095. {
  2096. struct item item_tmp;
  2097. struct item_data *item_data;
  2098. char item_name[100];
  2099. int item_id, number = 0;
  2100. int identify = 0, refine = 0, attr = 0;
  2101. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2102. int flag;
  2103. int loop, get_count, i;
  2104. nullpo_retr(-1, sd);
  2105. memset(item_name, '\0', sizeof(item_name));
  2106. 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) {
  2107. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2108. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2109. return -1;
  2110. }
  2111. if (number <= 0)
  2112. number = 1;
  2113. item_id = 0;
  2114. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2115. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2116. item_id = item_data->nameid;
  2117. if (item_id > 500) {
  2118. loop = 1;
  2119. get_count = number;
  2120. if (item_data->type == 4 || item_data->type == 5 ||
  2121. item_data->type == 7 || item_data->type == 8) {
  2122. loop = number;
  2123. get_count = 1;
  2124. if (item_data->type == 7) {
  2125. identify = 1;
  2126. refine = 0;
  2127. }
  2128. if (item_data->type == 8)
  2129. refine = 0;
  2130. if (refine > 10)
  2131. refine = 10;
  2132. } else {
  2133. identify = 1;
  2134. refine = attr = 0;
  2135. }
  2136. for (i = 0; i < loop; i++) {
  2137. memset(&item_tmp, 0, sizeof(item_tmp));
  2138. item_tmp.nameid = item_id;
  2139. item_tmp.identify = identify;
  2140. item_tmp.refine = refine;
  2141. item_tmp.attribute = attr;
  2142. item_tmp.card[0] = c1;
  2143. item_tmp.card[1] = c2;
  2144. item_tmp.card[2] = c3;
  2145. item_tmp.card[3] = c4;
  2146. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2147. clif_additem(sd, 0, 0, flag);
  2148. }
  2149. clif_displaymessage(fd, msg_table[18]); // Item created.
  2150. } else {
  2151. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2152. return -1;
  2153. }
  2154. return 0;
  2155. }
  2156. /*==========================================
  2157. *
  2158. *------------------------------------------
  2159. */
  2160. int atcommand_itemreset(
  2161. const int fd, struct map_session_data* sd,
  2162. const char* command, const char* message)
  2163. {
  2164. int i;
  2165. nullpo_retr(-1, sd);
  2166. for (i = 0; i < MAX_INVENTORY; i++) {
  2167. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0)
  2168. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2169. }
  2170. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2171. return 0;
  2172. }
  2173. /*==========================================
  2174. *
  2175. *------------------------------------------
  2176. */
  2177. int atcommand_itemcheck(
  2178. const int fd, struct map_session_data* sd,
  2179. const char* command, const char* message)
  2180. {
  2181. nullpo_retr(-1, sd);
  2182. pc_checkitem(sd);
  2183. return 0;
  2184. }
  2185. /*==========================================
  2186. *
  2187. *------------------------------------------
  2188. */
  2189. int atcommand_baselevelup(
  2190. const int fd, struct map_session_data* sd,
  2191. const char* command, const char* message)
  2192. {
  2193. int level, i;
  2194. nullpo_retr(-1, sd);
  2195. if (!message || !*message || (level = atoi(message)) == 0) {
  2196. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2197. return -1;
  2198. }
  2199. if (level > 0) {
  2200. if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  2201. clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher.
  2202. return -1;
  2203. } // End Addition
  2204. if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
  2205. level = battle_config.maximum_level - sd->status.base_level;
  2206. for (i = 1; i <= level; i++)
  2207. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2208. sd->status.base_level += level;
  2209. clif_updatestatus(sd, SP_BASELEVEL);
  2210. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2211. clif_updatestatus(sd, SP_STATUSPOINT);
  2212. status_calc_pc(sd, 0);
  2213. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2214. clif_misceffect(&sd->bl, 0);
  2215. clif_displaymessage(fd, msg_table[21]); // Base level raised.
  2216. } else {
  2217. if (sd->status.base_level == 1) {
  2218. clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower.
  2219. return -1;
  2220. }
  2221. if (level < -(int)battle_config.maximum_level || level < (1 - (int)sd->status.base_level)) // fix negativ overflow
  2222. level = 1 - sd->status.base_level;
  2223. if (sd->status.status_point > 0) {
  2224. for (i = 0; i > level; i--)
  2225. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2226. if (sd->status.status_point < 0)
  2227. sd->status.status_point = 0;
  2228. clif_updatestatus(sd, SP_STATUSPOINT);
  2229. } // to add: remove status points from stats
  2230. sd->status.base_level += level;
  2231. clif_updatestatus(sd, SP_BASELEVEL);
  2232. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2233. status_calc_pc(sd, 0);
  2234. clif_displaymessage(fd, msg_table[22]); // Base level lowered.
  2235. }
  2236. return 0;
  2237. }
  2238. /*==========================================
  2239. *
  2240. *------------------------------------------
  2241. */
  2242. int atcommand_joblevelup(
  2243. const int fd, struct map_session_data* sd,
  2244. const char* command, const char* message)
  2245. {
  2246. unsigned int up_level = 50;
  2247. int level;
  2248. struct pc_base_job s_class;
  2249. nullpo_retr(-1, sd);
  2250. s_class = pc_calc_base_job(sd->status.class_);
  2251. if (!message || !*message || (level = atoi(message)) == 0) {
  2252. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2253. return -1;
  2254. }
  2255. if (s_class.job == 0)
  2256. up_level -= 40;
  2257. // super novices can go up to 99 [celest]
  2258. else if (s_class.job == 23)
  2259. up_level += 49;
  2260. else if (sd->status.class_ > 4007 && sd->status.class_ < 4023)
  2261. up_level += 20;
  2262. if (level > 0) {
  2263. if (sd->status.job_level == up_level) {
  2264. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2265. return -1;
  2266. }
  2267. if ((unsigned int)level > up_level || (unsigned int)level > (up_level - sd->status.job_level)) // fix positiv overflow
  2268. level = up_level - sd->status.job_level;
  2269. sd->status.job_level += level;
  2270. clif_updatestatus(sd, SP_JOBLEVEL);
  2271. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2272. sd->status.skill_point += level;
  2273. clif_updatestatus(sd, SP_SKILLPOINT);
  2274. status_calc_pc(sd, 0);
  2275. clif_misceffect(&sd->bl, 1);
  2276. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2277. } else {
  2278. if (sd->status.job_level == 1) {
  2279. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2280. return -1;
  2281. }
  2282. if (level < -(int)up_level || level < (1 - (int)sd->status.job_level)) // fix negativ overflow
  2283. level = 1 - sd->status.job_level;
  2284. sd->status.job_level += level;
  2285. clif_updatestatus(sd, SP_JOBLEVEL);
  2286. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2287. if (sd->status.skill_point > 0) {
  2288. sd->status.skill_point += level;
  2289. if (sd->status.skill_point < 0)
  2290. sd->status.skill_point = 0;
  2291. clif_updatestatus(sd, SP_SKILLPOINT);
  2292. } // to add: remove status points from skills
  2293. status_calc_pc(sd, 0);
  2294. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2295. }
  2296. return 0;
  2297. }
  2298. /*==========================================
  2299. *
  2300. *------------------------------------------
  2301. */
  2302. int atcommand_help(
  2303. const int fd, struct map_session_data* sd,
  2304. const char* command, const char* message)
  2305. {
  2306. char buf[2048], w1[2048], w2[2048];
  2307. int i, gm_level;
  2308. FILE* fp;
  2309. nullpo_retr(-1, sd);
  2310. memset(buf, '\0', sizeof(buf));
  2311. if ((fp = fopen(help_txt, "r")) != NULL) {
  2312. clif_displaymessage(fd, msg_table[26]); // Help commands:
  2313. gm_level = pc_isGM(sd);
  2314. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2315. if (buf[0] == '/' && buf[1] == '/')
  2316. continue;
  2317. for (i = 0; buf[i] != '\0'; i++) {
  2318. if (buf[i] == '\r' || buf[i] == '\n') {
  2319. buf[i] = '\0';
  2320. break;
  2321. }
  2322. }
  2323. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2324. clif_displaymessage(fd, buf);
  2325. else if (gm_level >= atoi(w1))
  2326. clif_displaymessage(fd, w2);
  2327. }
  2328. fclose(fp);
  2329. } else {
  2330. clif_displaymessage(fd, msg_table[27]); // File help.txt not found.
  2331. return -1;
  2332. }
  2333. return 0;
  2334. }
  2335. /*==========================================
  2336. *
  2337. *------------------------------------------
  2338. */
  2339. int atcommand_gm(
  2340. const int fd, struct map_session_data* sd,
  2341. const char* command, const char* message)
  2342. {
  2343. char password[100];
  2344. nullpo_retr(-1, sd);
  2345. memset(password, '\0', sizeof(password));
  2346. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2347. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2348. return -1;
  2349. }
  2350. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  2351. clif_displaymessage(fd, msg_table[50]); // You already have some GM powers.
  2352. return -1;
  2353. } else
  2354. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2355. return 0;
  2356. }
  2357. /*==========================================
  2358. *
  2359. *------------------------------------------
  2360. */
  2361. int atcommand_pvpoff(
  2362. const int fd, struct map_session_data* sd,
  2363. const char* command, const char* message)
  2364. {
  2365. struct map_session_data *pl_sd;
  2366. int i;
  2367. nullpo_retr(-1, sd);
  2368. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2369. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2370. return -1;
  2371. }
  2372. if (map[sd->bl.m].flag.pvp) {
  2373. map[sd->bl.m].flag.pvp = 0;
  2374. clif_send0199(sd->bl.m, 0);
  2375. for (i = 0; i < fd_max; i++) { //人数分ループ
  2376. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2377. if (sd->bl.m == pl_sd->bl.m) {
  2378. clif_pvpset(pl_sd, 0, 0, 2);
  2379. if (pl_sd->pvp_timer != -1) {
  2380. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2381. pl_sd->pvp_timer = -1;
  2382. }
  2383. }
  2384. }
  2385. }
  2386. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2387. } else {
  2388. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2389. return -1;
  2390. }
  2391. return 0;
  2392. }
  2393. /*==========================================
  2394. *
  2395. *------------------------------------------
  2396. */
  2397. int atcommand_pvpon(
  2398. const int fd, struct map_session_data* sd,
  2399. const char* command, const char* message)
  2400. {
  2401. struct map_session_data *pl_sd;
  2402. int i;
  2403. nullpo_retr(-1, sd);
  2404. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2405. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2406. return -1;
  2407. }
  2408. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2409. map[sd->bl.m].flag.pvp = 1;
  2410. clif_send0199(sd->bl.m, 1);
  2411. for (i = 0; i < fd_max; i++) {
  2412. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2413. if (sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2414. pl_sd->pvp_timer = add_timer(gettick() + 200,
  2415. pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2416. pl_sd->pvp_rank = 0;
  2417. pl_sd->pvp_lastusers = 0;
  2418. pl_sd->pvp_point = 5;
  2419. }
  2420. }
  2421. }
  2422. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2423. } else {
  2424. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2425. return -1;
  2426. }
  2427. return 0;
  2428. }
  2429. /*==========================================
  2430. *
  2431. *------------------------------------------
  2432. */
  2433. int atcommand_gvgoff(
  2434. const int fd, struct map_session_data* sd,
  2435. const char* command, const char* message)
  2436. {
  2437. nullpo_retr(-1, sd);
  2438. if (map[sd->bl.m].flag.gvg) {
  2439. map[sd->bl.m].flag.gvg = 0;
  2440. clif_send0199(sd->bl.m, 0);
  2441. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2442. } else {
  2443. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2444. return -1;
  2445. }
  2446. return 0;
  2447. }
  2448. /*==========================================
  2449. *
  2450. *------------------------------------------
  2451. */
  2452. int atcommand_gvgon(
  2453. const int fd, struct map_session_data* sd,
  2454. const char* command, const char* message)
  2455. {
  2456. nullpo_retr(-1, sd);
  2457. if (!map[sd->bl.m].flag.gvg) {
  2458. map[sd->bl.m].flag.gvg = 1;
  2459. clif_send0199(sd->bl.m, 3);
  2460. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2461. } else {
  2462. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2463. return -1;
  2464. }
  2465. return 0;
  2466. }
  2467. /*==========================================
  2468. *
  2469. *------------------------------------------
  2470. */
  2471. int atcommand_model(
  2472. const int fd, struct map_session_data* sd,
  2473. const char* command, const char* message)
  2474. {
  2475. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2476. char output[200];
  2477. nullpo_retr(-1, sd);
  2478. memset(output, '\0', sizeof(output));
  2479. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2480. sprintf(output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2481. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2482. clif_displaymessage(fd, output);
  2483. return -1;
  2484. }
  2485. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2486. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2487. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2488. //服の色変更
  2489. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2490. //服の色未実装職の判定
  2491. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2492. return -1;
  2493. } else {
  2494. pc_changelook(sd, LOOK_HAIR, hair_style);
  2495. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2496. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2497. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2498. }
  2499. } else {
  2500. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2501. return -1;
  2502. }
  2503. return 0;
  2504. }
  2505. /*==========================================
  2506. * @dye && @ccolor
  2507. *------------------------------------------
  2508. */
  2509. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2510. {
  2511. int cloth_color = 0;
  2512. char output[200];
  2513. nullpo_retr(-1, sd);
  2514. memset(output, '\0', sizeof(output));
  2515. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2516. sprintf(output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2517. clif_displaymessage(fd, output);
  2518. return -1;
  2519. }
  2520. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2521. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2522. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2523. } else {
  2524. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2525. return -1;
  2526. }
  2527. return 0;
  2528. }
  2529. /*==========================================
  2530. * @hairstyle && @hstyle
  2531. *------------------------------------------
  2532. */
  2533. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2534. {
  2535. int hair_style = 0;
  2536. char output[200];
  2537. nullpo_retr(-1, sd);
  2538. memset(output, '\0', sizeof(output));
  2539. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2540. sprintf(output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2541. clif_displaymessage(fd, output);
  2542. return -1;
  2543. }
  2544. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2545. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2546. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2547. return -1;
  2548. } else {
  2549. pc_changelook(sd, LOOK_HAIR, hair_style);
  2550. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2551. }
  2552. } else {
  2553. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2554. return -1;
  2555. }
  2556. return 0;
  2557. }
  2558. /*==========================================
  2559. * @charhairstyle by [MouseJstr]
  2560. *------------------------------------------
  2561. */
  2562. int
  2563. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2564. const char* command, const char* message)
  2565. {
  2566. nullpo_retr(-1, sd);
  2567. return 0;
  2568. }
  2569. /*==========================================
  2570. * @haircolor && @hcolor
  2571. *------------------------------------------
  2572. */
  2573. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2574. {
  2575. int hair_color = 0;
  2576. char output[200];
  2577. nullpo_retr(-1, sd);
  2578. memset(output, '\0', sizeof(output));
  2579. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2580. sprintf(output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2581. clif_displaymessage(fd, output);
  2582. return -1;
  2583. }
  2584. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2585. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2586. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2587. return -1;
  2588. } else {
  2589. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2590. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2591. }
  2592. } else {
  2593. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2594. return -1;
  2595. }
  2596. return 0;
  2597. }
  2598. /*==========================================
  2599. * @go [city_number/city_name]: improved by [yor] to add city names and help
  2600. *------------------------------------------
  2601. */
  2602. int atcommand_go(
  2603. const int fd, struct map_session_data* sd,
  2604. const char* command, const char* message)
  2605. {
  2606. int i;
  2607. int town;
  2608. char map_name[100];
  2609. char output[200];
  2610. int m;
  2611. const struct { char map[16]; int x, y; } data[] = {
  2612. { "prontera.gat", 156, 191 }, // 0=Prontera
  2613. { "morocc.gat", 156, 93 }, // 1=Morroc
  2614. { "geffen.gat", 119, 59 }, // 2=Geffen
  2615. { "payon.gat", 162, 233 }, // 3=Payon
  2616. { "alberta.gat", 192, 147 }, // 4=Alberta
  2617. { "izlude.gat", 128, 114 }, // 5=Izlude
  2618. { "aldebaran.gat",140, 131 }, // 6=Al de Baran
  2619. { "xmas.gat", 147, 134 }, // 7=Lutie
  2620. { "comodo.gat", 209, 143 }, // 8=Comodo
  2621. { "yuno.gat", 157, 51 }, // 9=Yuno
  2622. { "amatsu.gat", 198, 84 }, // 10=Amatsu
  2623. { "gonryun.gat", 160, 120 }, // 11=Gon Ryun
  2624. { "umbala.gat", 89, 157 }, // 12=Umbala
  2625. { "niflheim.gat", 21, 153 }, // 13=Niflheim
  2626. { "louyang.gat", 217, 40 }, // 14=Lou Yang
  2627. { "new_1-1.gat", 53, 111 }, // 15=Start point
  2628. { "sec_pri.gat", 23, 61 }, // 16=Prison
  2629. { "jawaii.gat", 249, 127 }, // 17=Jawaii
  2630. { "ayothaya.gat", 151, 117 }, // 18=Ayothaya
  2631. };
  2632. nullpo_retr(-1, sd);
  2633. if(map[sd->bl.m].flag.nogo) {
  2634. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2635. return 0;
  2636. }
  2637. memset(map_name, '\0', sizeof(map_name));
  2638. memset(output, '\0', sizeof(output));
  2639. // get the number
  2640. town = atoi(message);
  2641. // if no value, display all value
  2642. if (!message || !*message || sscanf(message, "%99s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2643. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2644. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2645. clif_displaymessage(fd, "-3=(Memo point 2) 4=Alberta 11=Gon Ryun");
  2646. clif_displaymessage(fd, "-2=(Memo point 1) 5=Izlude 12=Umbala");
  2647. clif_displaymessage(fd, "-1=(Memo point 0) 6=Al de Baran 13=Niflheim");
  2648. clif_displaymessage(fd, " 0=Prontera 7=Lutie 14=Lou Yang");
  2649. clif_displaymessage(fd, " 1=Morroc 8=Comodo 15=Start point");
  2650. clif_displaymessage(fd, " 2=Geffen 9=Yuno 16=Prison");
  2651. clif_displaymessage(fd, " 3=Payon 10=Amatsu 17=Jawaii");
  2652. clif_displaymessage(fd, " 18=Ayothaya");
  2653. return -1;
  2654. } else {
  2655. // get possible name of the city and add .gat if not in the name
  2656. map_name[sizeof(map_name)-1] = '\0';
  2657. for (i = 0; map_name[i]; i++)
  2658. map_name[i] = tolower(map_name[i]);
  2659. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  2660. strcat(map_name, ".gat");
  2661. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2662. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2663. town = 0;
  2664. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2665. town = 1;
  2666. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2667. town = 2;
  2668. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2669. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2670. town = 3;
  2671. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2672. town = 4;
  2673. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2674. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2675. town = 5;
  2676. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2677. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2678. town = 6;
  2679. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2680. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2681. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2682. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2683. town = 7;
  2684. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2685. town = 8;
  2686. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2687. town = 9;
  2688. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2689. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2690. town = 10;
  2691. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2692. town = 11;
  2693. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2694. town = 12;
  2695. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2696. town = 13;
  2697. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2698. town = 14;
  2699. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2700. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2701. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2702. town = 15;
  2703. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2704. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2705. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2706. town = 16;
  2707. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2708. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2709. town = 17;
  2710. } else if (strncmp(map_name, "ayothaya.gat", 4) == 0 || // 3 first characters
  2711. strncmp(map_name, "ayotaya.gat", 4) == 0) { // writing error (3 first characters)
  2712. town = 18;
  2713. }
  2714. if (town >= -3 && town <= -1) {
  2715. if (sd->status.memo_point[-town-1].map[0]) {
  2716. m = map_mapname2mapid(sd->status.memo_point[-town-1].map);
  2717. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2718. clif_displaymessage(fd, "You are not authorised to warp you to this memo map.");
  2719. return -1;
  2720. }
  2721. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2722. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2723. return -1;
  2724. }
  2725. 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) {
  2726. clif_displaymessage(fd, msg_table[0]); // Warped.
  2727. } else {
  2728. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2729. return -1;
  2730. }
  2731. } else {
  2732. sprintf(output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2733. clif_displaymessage(fd, output);
  2734. return -1;
  2735. }
  2736. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2737. m = map_mapname2mapid((char *)data[town].map);
  2738. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2739. clif_displaymessage(fd, "You are not authorised to warp you to this destination map.");
  2740. return -1;
  2741. }
  2742. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2743. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2744. return -1;
  2745. }
  2746. if (pc_setpos(sd, (char *)data[town].map, data[town].x, data[town].y, 3) == 0) {
  2747. clif_displaymessage(fd, msg_table[0]); // Warped.
  2748. } else {
  2749. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2750. return -1;
  2751. }
  2752. } else { // if you arrive here, you have an error in town variable when reading of names
  2753. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2754. return -1;
  2755. }
  2756. }
  2757. return 0;
  2758. }
  2759. /*==========================================
  2760. *
  2761. *------------------------------------------
  2762. */
  2763. int atcommand_monster(
  2764. const int fd, struct map_session_data* sd,
  2765. const char* command, const char* message)
  2766. {
  2767. char name[100];
  2768. char monster[100];
  2769. char output[200];
  2770. int mob_id;
  2771. int number = 0;
  2772. int x = 0, y = 0;
  2773. int count;
  2774. int i, j, k;
  2775. int mx, my, range;
  2776. nullpo_retr(-1, sd);
  2777. memset(name, '\0', sizeof(name));
  2778. memset(monster, '\0', sizeof(monster));
  2779. memset(output, '\0', sizeof(output));
  2780. if (!message || !*message ||
  2781. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2782. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2783. sscanf(message, "%99s %99s %d %d %d", name, monster, &number, &x, &y) < 2)) {
  2784. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2785. return -1;
  2786. }
  2787. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2788. mob_id = mobdb_checkid(atoi(monster));
  2789. if (mob_id == 0) {
  2790. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2791. return -1;
  2792. }
  2793. if (mob_id == 1288) {
  2794. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2795. return -1;
  2796. }
  2797. if (number <= 0)
  2798. number = 1;
  2799. if (strlen(name) < 1)
  2800. strcpy(name, "--ja--");
  2801. // 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
  2802. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2803. number = battle_config.atc_spawn_quantity_limit;
  2804. if (battle_config.etc_log)
  2805. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2806. count = 0;
  2807. range = (int)sqrt(number) / 2;
  2808. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2809. for (i = 0; i < number; i++) {
  2810. j = 0;
  2811. k = 0;
  2812. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2813. if (x <= 0)
  2814. mx = sd->bl.x + (rand() % range - (range / 2));
  2815. else
  2816. mx = x;
  2817. if (y <= 0)
  2818. my = sd->bl.y + (rand() % range - (range / 2));
  2819. else
  2820. my = y;
  2821. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2822. }
  2823. count += (k != 0) ? 1 : 0;
  2824. }
  2825. if (count != 0)
  2826. if (number == count)
  2827. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2828. else {
  2829. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2830. clif_displaymessage(fd, output);
  2831. }
  2832. else {
  2833. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2834. return -1;
  2835. }
  2836. return 0;
  2837. }
  2838. /*==========================================
  2839. *
  2840. *------------------------------------------
  2841. */
  2842. int atcommand_spawn(
  2843. const int fd, struct map_session_data* sd,
  2844. const char* command, const char* message) {
  2845. char name[100];
  2846. char monster[100];
  2847. char output[200];
  2848. int mob_id;
  2849. int number = 0;
  2850. int x = 0, y = 0;
  2851. int count;
  2852. int i, j, k;
  2853. int mx, my, range;
  2854. nullpo_retr(-1, sd);
  2855. memset(name, '\0', sizeof(name));
  2856. memset(monster, '\0', sizeof(monster));
  2857. memset(output, '\0', sizeof(output));
  2858. if (!message || !*message ||
  2859. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2860. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2861. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1)) {
  2862. clif_displaymessage(fd, msg_table[143]); // Give a monster name/id please.
  2863. return -1;
  2864. }
  2865. // If monster identifier/name argument is a name
  2866. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2867. mob_id = mobdb_checkid(atoi(monster));
  2868. if (mob_id == 0) {
  2869. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2870. return -1;
  2871. }
  2872. if (mob_id == 1288) {
  2873. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2874. return -1;
  2875. }
  2876. if (number <= 0)
  2877. number = 1;
  2878. if (strlen(name) < 1)
  2879. strcpy(name, "--ja--");
  2880. // 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
  2881. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2882. number = battle_config.atc_spawn_quantity_limit;
  2883. if (battle_config.etc_log)
  2884. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2885. count = 0;
  2886. range = (int)sqrt(number) / 2;
  2887. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2888. for (i = 0; i < number; i++) {
  2889. j = 0;
  2890. k = 0;
  2891. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2892. if (x <= 0)
  2893. mx = sd->bl.x + (rand() % range - (range / 2));
  2894. else
  2895. mx = x;
  2896. if (y <= 0)
  2897. my = sd->bl.y + (rand() % range - (range / 2));
  2898. else
  2899. my = y;
  2900. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2901. }
  2902. count += (k != 0) ? 1 : 0;
  2903. }
  2904. if (count != 0)
  2905. if (number == count)
  2906. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2907. else {
  2908. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2909. clif_displaymessage(fd, output);
  2910. }
  2911. else {
  2912. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2913. return -1;
  2914. }
  2915. return 0;
  2916. }
  2917. // small monster spawning [Valaris]
  2918. int atcommand_monstersmall(
  2919. const int fd, struct map_session_data* sd,
  2920. const char* command, const char* message) {
  2921. char name[100] = "";
  2922. char monster[100] = "";
  2923. int mob_id = 0;
  2924. int number = 0;
  2925. int x = 0;
  2926. int y = 0;
  2927. int count;
  2928. int i;
  2929. nullpo_retr(-1, sd);
  2930. if (!message || !*message) {
  2931. clif_displaymessage(fd, "Give a monster name/id please.");
  2932. return 0;
  2933. }
  2934. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2935. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2936. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2937. clif_displaymessage(fd, "Give a monster name/id please.");
  2938. return 0;
  2939. }
  2940. // If monster identifier/name argument is a name
  2941. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2942. mob_id = atoi(monster);
  2943. if (mob_id == 0) {
  2944. clif_displaymessage(fd, "Monster name hasn't been found.");
  2945. return 0;
  2946. }
  2947. if (mob_id == 1288) {
  2948. clif_displaymessage(fd, "Cannot spawn emperium.");
  2949. return 0;
  2950. }
  2951. if (mob_id > 2000) {
  2952. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2953. return 0;
  2954. }
  2955. if (number <= 0)
  2956. number = 1;
  2957. if (strlen(name) < 1)
  2958. strcpy(name, "--ja--");
  2959. // 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
  2960. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2961. number = battle_config.atc_spawn_quantity_limit;
  2962. count = 0;
  2963. for (i = 0; i < number; i++) {
  2964. int mx, my;
  2965. if (x <= 0)
  2966. mx = sd->bl.x + (rand() % 11 - 5);
  2967. else
  2968. mx = x;
  2969. if (y <= 0)
  2970. my = sd->bl.y + (rand() % 11 - 5);
  2971. else
  2972. my = y;
  2973. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2000, 1, "") != 0) ? 1 : 0;
  2974. }
  2975. if (count != 0)
  2976. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2977. else
  2978. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2979. return 0;
  2980. }
  2981. // big monster spawning [Valaris]
  2982. int atcommand_monsterbig(
  2983. const int fd, struct map_session_data* sd,
  2984. const char* command, const char* message) {
  2985. char name[100] = "";
  2986. char monster[100] = "";
  2987. int mob_id = 0;
  2988. int number = 0;
  2989. int x = 0;
  2990. int y = 0;
  2991. int count;
  2992. int i;
  2993. nullpo_retr(-1, sd);
  2994. if (!message || !*message) {
  2995. clif_displaymessage(fd, "Give a monster name/id please.");
  2996. return 0;
  2997. }
  2998. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2999. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3000. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  3001. clif_displaymessage(fd, "Give a monster name/id please.");
  3002. return 0;
  3003. }
  3004. // If monster identifier/name argument is a name
  3005. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3006. mob_id = atoi(monster);
  3007. if (mob_id == 0) {
  3008. clif_displaymessage(fd, "Monster name hasn't been found.");
  3009. return 0;
  3010. }
  3011. if (mob_id == 1288) {
  3012. clif_displaymessage(fd, "Cannot spawn emperium.");
  3013. return 0;
  3014. }
  3015. if (mob_id > 2000) {
  3016. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3017. return 0;
  3018. }
  3019. if (number <= 0)
  3020. number = 1;
  3021. if (strlen(name) < 1)
  3022. strcpy(name, "--ja--");
  3023. // 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
  3024. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3025. number = battle_config.atc_spawn_quantity_limit;
  3026. count = 0;
  3027. for (i = 0; i < number; i++) {
  3028. int mx, my;
  3029. if (x <= 0)
  3030. mx = sd->bl.x + (rand() % 11 - 5);
  3031. else
  3032. mx = x;
  3033. if (y <= 0)
  3034. my = sd->bl.y + (rand() % 11 - 5);
  3035. else
  3036. my = y;
  3037. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+4000, 1, "") != 0) ? 1 : 0;
  3038. }
  3039. if (count != 0)
  3040. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3041. else
  3042. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3043. return 0;
  3044. }
  3045. /*==========================================
  3046. *
  3047. *------------------------------------------
  3048. */
  3049. void atcommand_killmonster_sub(
  3050. const int fd, struct map_session_data* sd, const char* message,
  3051. const int drop)
  3052. {
  3053. int map_id;
  3054. char map_name[100];
  3055. if (!sd) return;
  3056. memset(map_name, '\0', sizeof(map_name));
  3057. if (!message || !*message || sscanf(message, "%99s", map_name) < 1)
  3058. map_id = sd->bl.m;
  3059. else {
  3060. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  3061. strcat(map_name, ".gat");
  3062. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3063. map_id = sd->bl.m;
  3064. }
  3065. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, drop);
  3066. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3067. return;
  3068. }
  3069. /*==========================================
  3070. *
  3071. *------------------------------------------
  3072. */
  3073. int atcommand_killmonster(
  3074. const int fd, struct map_session_data* sd,
  3075. const char* command, const char* message)
  3076. {
  3077. if (!sd) return 0;
  3078. atcommand_killmonster_sub(fd, sd, message, 1);
  3079. return 0;
  3080. }
  3081. /*==========================================
  3082. *
  3083. *------------------------------------------
  3084. */
  3085. int atcommand_killmonster2(
  3086. const int fd, struct map_session_data* sd,
  3087. const char* command, const char* message)
  3088. {
  3089. if (!sd) return 0;
  3090. atcommand_killmonster_sub(fd, sd, message, 0);
  3091. return 0;
  3092. }
  3093. /*==========================================
  3094. *
  3095. *------------------------------------------
  3096. */
  3097. int atcommand_refine(
  3098. const int fd, struct map_session_data* sd,
  3099. const char* command, const char* message)
  3100. {
  3101. int i, position = 0, refine = 0, current_position, final_refine;
  3102. int count;
  3103. char output[200];
  3104. nullpo_retr(-1, sd);
  3105. memset(output, '\0', sizeof(output));
  3106. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3107. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3108. return -1;
  3109. }
  3110. if (refine < -10)
  3111. refine = -10;
  3112. else if (refine > 10)
  3113. refine = 10;
  3114. else if (refine == 0)
  3115. refine = 1;
  3116. count = 0;
  3117. for (i = 0; i < MAX_INVENTORY; i++) {
  3118. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3119. (sd->status.inventory[i].equip & position ||
  3120. (sd->status.inventory[i].equip && !position))) {
  3121. final_refine = sd->status.inventory[i].refine + refine;
  3122. if (final_refine > 10)
  3123. final_refine = 10;
  3124. else if (final_refine < 0)
  3125. final_refine = 0;
  3126. if (sd->status.inventory[i].refine != final_refine) {
  3127. sd->status.inventory[i].refine = final_refine;
  3128. current_position = sd->status.inventory[i].equip;
  3129. pc_unequipitem(sd, i, 3);
  3130. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3131. clif_delitem(sd, i, 1);
  3132. clif_additem(sd, i, 1, 0);
  3133. pc_equipitem(sd, i, current_position);
  3134. clif_misceffect((struct block_list*)&sd->bl, 3);
  3135. count++;
  3136. }
  3137. }
  3138. }
  3139. if (count == 0)
  3140. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3141. else if (count == 1)
  3142. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3143. else {
  3144. sprintf(output, msg_table[168], count); // %d items have been refined!
  3145. clif_displaymessage(fd, output);
  3146. }
  3147. return 0;
  3148. }
  3149. /*==========================================
  3150. *
  3151. *------------------------------------------
  3152. */
  3153. int atcommand_produce(
  3154. const int fd, struct map_session_data* sd,
  3155. const char* command, const char* message)
  3156. {
  3157. char item_name[100];
  3158. int item_id, attribute = 0, star = 0;
  3159. int flag = 0;
  3160. struct item_data *item_data;
  3161. struct item tmp_item;
  3162. char output[200];
  3163. nullpo_retr(-1, sd);
  3164. memset(output, '\0', sizeof(output));
  3165. memset(item_name, '\0', sizeof(item_name));
  3166. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3167. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3168. return -1;
  3169. }
  3170. item_id = 0;
  3171. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3172. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3173. item_id = item_data->nameid;
  3174. if (itemdb_exists(item_id) &&
  3175. (item_id <= 500 || item_id > 1099) &&
  3176. (item_id < 4001 || item_id > 4148) &&
  3177. (item_id < 7001 || item_id > 10019) &&
  3178. itemdb_isequip(item_id)) {
  3179. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3180. attribute = ATTRIBUTE_NORMAL;
  3181. if (star < MIN_STAR || star > MAX_STAR)
  3182. star = 0;
  3183. memset(&tmp_item, 0, sizeof tmp_item);
  3184. tmp_item.nameid = item_id;
  3185. tmp_item.amount = 1;
  3186. tmp_item.identify = 1;
  3187. tmp_item.card[0] = 0x00ff;
  3188. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3189. *((unsigned long *)(&tmp_item.card[2])) = sd->char_id;
  3190. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3191. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3192. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3193. clif_additem(sd, 0, 0, flag);
  3194. } else {
  3195. if (battle_config.error_log)
  3196. printf("@produce NOT WEAPON [%d]\n", item_id);
  3197. if (item_id != 0 && itemdb_exists(item_id))
  3198. sprintf(output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3199. else
  3200. sprintf(output, msg_table[170]); // This item is not an equipment.
  3201. clif_displaymessage(fd, output);
  3202. return -1;
  3203. }
  3204. return 0;
  3205. }
  3206. /*==========================================
  3207. * Sub-function to display actual memo points
  3208. *------------------------------------------
  3209. */
  3210. void atcommand_memo_sub(struct map_session_data* sd) {
  3211. int i;
  3212. char output[200];
  3213. if (!sd) return;
  3214. memset(output, '\0', sizeof(output));
  3215. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3216. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3217. if (sd->status.memo_point[i].map[0])
  3218. 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);
  3219. else
  3220. sprintf(output, msg_table[171], i); // %d - void
  3221. clif_displaymessage(sd->fd, output);
  3222. }
  3223. return;
  3224. }
  3225. /*==========================================
  3226. *
  3227. *------------------------------------------
  3228. */
  3229. int atcommand_memo(
  3230. const int fd, struct map_session_data* sd,
  3231. const char* command, const char* message)
  3232. {
  3233. int position = 0;
  3234. char output[200];
  3235. nullpo_retr(-1, sd);
  3236. memset(output, '\0', sizeof(output));
  3237. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3238. atcommand_memo_sub(sd);
  3239. else {
  3240. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3241. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3242. clif_displaymessage(fd, "You are not authorised to memo this map.");
  3243. return -1;
  3244. }
  3245. if (sd->status.memo_point[position].map[0]) {
  3246. 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).
  3247. clif_displaymessage(fd, output);
  3248. }
  3249. memcpy(sd->status.memo_point[position].map, map[sd->bl.m].name, 24);
  3250. sd->status.memo_point[position].x = sd->bl.x;
  3251. sd->status.memo_point[position].y = sd->bl.y;
  3252. clif_skill_memo(sd, 0);
  3253. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3254. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3255. atcommand_memo_sub(sd);
  3256. } else {
  3257. sprintf(output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3258. clif_displaymessage(fd, output);
  3259. atcommand_memo_sub(sd);
  3260. return -1;
  3261. }
  3262. }
  3263. return 0;
  3264. }
  3265. /*==========================================
  3266. *
  3267. *------------------------------------------
  3268. */
  3269. int atcommand_gat(
  3270. const int fd, struct map_session_data* sd,
  3271. const char* command, const char* message)
  3272. {
  3273. char output[200];
  3274. int y;
  3275. nullpo_retr(-1, sd);
  3276. memset(output, '\0', sizeof(output));
  3277. for (y = 2; y >= -2; y--) {
  3278. sprintf(output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3279. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3280. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y,CELL_CHKTYPE),
  3281. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y,CELL_CHKTYPE),
  3282. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y,CELL_CHKTYPE),
  3283. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y,CELL_CHKTYPE),
  3284. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y,CELL_CHKTYPE));
  3285. clif_displaymessage(fd, output);
  3286. }
  3287. return 0;
  3288. }
  3289. /*==========================================
  3290. *
  3291. *------------------------------------------
  3292. */
  3293. int atcommand_packet(
  3294. const int fd, struct map_session_data* sd,
  3295. const char* command, const char* message)
  3296. {
  3297. int x = 0, y = 0;
  3298. nullpo_retr(-1, sd);
  3299. if (!message || !*message || sscanf(message, "%d %d", &x, &y) < 2) {
  3300. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3301. return -1;
  3302. }
  3303. clif_status_change(&sd->bl, x, y);
  3304. return 0;
  3305. }
  3306. /*==========================================
  3307. * @stpoint (Rewritten by [Yor])
  3308. *------------------------------------------
  3309. */
  3310. int atcommand_statuspoint(
  3311. const int fd, struct map_session_data* sd,
  3312. const char* command, const char* message)
  3313. {
  3314. int point, new_status_point;
  3315. if (!message || !*message || (point = atoi(message)) == 0) {
  3316. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3317. return -1;
  3318. }
  3319. new_status_point = (int)sd->status.status_point + point;
  3320. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3321. new_status_point = 0x7FFF;
  3322. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3323. new_status_point = 0;
  3324. if (new_status_point != (int)sd->status.status_point) {
  3325. sd->status.status_point = (short)new_status_point;
  3326. clif_updatestatus(sd, SP_STATUSPOINT);
  3327. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3328. } else {
  3329. if (point < 0)
  3330. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3331. else
  3332. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3333. return -1;
  3334. }
  3335. return 0;
  3336. }
  3337. /*==========================================
  3338. * @skpoint (Rewritten by [Yor])
  3339. *------------------------------------------
  3340. */
  3341. int atcommand_skillpoint(
  3342. const int fd, struct map_session_data* sd,
  3343. const char* command, const char* message)
  3344. {
  3345. int point, new_skill_point;
  3346. nullpo_retr(-1, sd);
  3347. if (!message || !*message || (point = atoi(message)) == 0) {
  3348. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3349. return -1;
  3350. }
  3351. new_skill_point = (int)sd->status.skill_point + point;
  3352. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3353. new_skill_point = 0x7FFF;
  3354. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3355. new_skill_point = 0;
  3356. if (new_skill_point != (int)sd->status.skill_point) {
  3357. sd->status.skill_point = (short)new_skill_point;
  3358. clif_updatestatus(sd, SP_SKILLPOINT);
  3359. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3360. } else {
  3361. if (point < 0)
  3362. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3363. else
  3364. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3365. return -1;
  3366. }
  3367. return 0;
  3368. }
  3369. /*==========================================
  3370. * @zeny (Rewritten by [Yor])
  3371. *------------------------------------------
  3372. */
  3373. int atcommand_zeny(
  3374. const int fd, struct map_session_data* sd,
  3375. const char* command, const char* message)
  3376. {
  3377. int zeny, new_zeny;
  3378. nullpo_retr(-1, sd);
  3379. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3380. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3381. return -1;
  3382. }
  3383. new_zeny = sd->status.zeny + zeny;
  3384. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3385. new_zeny = MAX_ZENY;
  3386. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3387. new_zeny = 0;
  3388. if (new_zeny != sd->status.zeny) {
  3389. sd->status.zeny = new_zeny;
  3390. clif_updatestatus(sd, SP_ZENY);
  3391. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3392. } else {
  3393. if (zeny < 0)
  3394. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3395. else
  3396. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3397. return -1;
  3398. }
  3399. return 0;
  3400. }
  3401. /*==========================================
  3402. *
  3403. *------------------------------------------
  3404. */
  3405. int atcommand_param(
  3406. const int fd, struct map_session_data* sd,
  3407. const char* command, const char* message)
  3408. {
  3409. int i, index, value = 0, new_value;
  3410. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3411. short* status[] = {
  3412. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3413. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3414. };
  3415. char output[200];
  3416. nullpo_retr(-1, sd);
  3417. memset(output, '\0', sizeof(output));
  3418. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3419. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3420. clif_displaymessage(fd, output);
  3421. return -1;
  3422. }
  3423. index = -1;
  3424. for (i = 0; param[i] != NULL; i++) {
  3425. if (strcmpi(command, param[i]) == 0) {
  3426. index = i;
  3427. break;
  3428. }
  3429. }
  3430. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3431. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3432. clif_displaymessage(fd, output);
  3433. return -1;
  3434. }
  3435. new_value = (int)*status[index] + value;
  3436. if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow
  3437. new_value = battle_config.max_parameter;
  3438. else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3439. new_value = 1;
  3440. if (new_value != (int)*status[index]) {
  3441. *status[index] = new_value;
  3442. clif_updatestatus(sd, SP_STR + index);
  3443. clif_updatestatus(sd, SP_USTR + index);
  3444. status_calc_pc(sd, 0);
  3445. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3446. } else {
  3447. if (value < 0)
  3448. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3449. else
  3450. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3451. return -1;
  3452. }
  3453. return 0;
  3454. }
  3455. /*==========================================
  3456. *
  3457. *------------------------------------------
  3458. */
  3459. //** Stat all by fritz (rewritten by [Yor])
  3460. int atcommand_stat_all(
  3461. const int fd, struct map_session_data* sd,
  3462. const char* command, const char* message)
  3463. {
  3464. int index, count, value = 0, new_value;
  3465. short* status[] = {
  3466. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3467. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3468. };
  3469. nullpo_retr(-1, sd);
  3470. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3471. value = battle_config.max_parameter;
  3472. count = 0;
  3473. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3474. new_value = (int)*status[index] + value;
  3475. if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow
  3476. new_value = battle_config.max_parameter;
  3477. else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3478. new_value = 1;
  3479. if (new_value != (int)*status[index]) {
  3480. *status[index] = new_value;
  3481. clif_updatestatus(sd, SP_STR + index);
  3482. clif_updatestatus(sd, SP_USTR + index);
  3483. status_calc_pc(sd, 0);
  3484. count++;
  3485. }
  3486. }
  3487. if (count > 0) // if at least 1 stat modified
  3488. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3489. else {
  3490. if (value < 0)
  3491. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3492. else
  3493. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3494. return -1;
  3495. }
  3496. return 0;
  3497. }
  3498. /*==========================================
  3499. *
  3500. *------------------------------------------
  3501. */
  3502. int atcommand_guildlevelup(
  3503. const int fd, struct map_session_data* sd,
  3504. const char* command, const char* message)
  3505. {
  3506. int level = 0;
  3507. short added_level;
  3508. struct guild *guild_info;
  3509. nullpo_retr(-1, sd);
  3510. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3511. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3512. return -1;
  3513. }
  3514. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3515. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3516. return -1;
  3517. }
  3518. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3519. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3520. return -1;
  3521. }
  3522. added_level = (short)level;
  3523. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3524. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3525. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3526. added_level = 1 - guild_info->guild_lv;
  3527. if (added_level != 0) {
  3528. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3529. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3530. } else {
  3531. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3532. return -1;
  3533. }
  3534. return 0;
  3535. }
  3536. /*==========================================
  3537. *
  3538. *------------------------------------------
  3539. */
  3540. int atcommand_makeegg(
  3541. const int fd, struct map_session_data* sd,
  3542. const char* command, const char* message)
  3543. {
  3544. struct item_data *item_data;
  3545. int id, pet_id;
  3546. nullpo_retr(-1, sd);
  3547. if (!message || !*message) {
  3548. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3549. return -1;
  3550. }
  3551. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3552. id = item_data->nameid;
  3553. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3554. id = atoi(message);
  3555. pet_id = search_petDB_index(id, PET_CLASS);
  3556. if (pet_id < 0)
  3557. pet_id = search_petDB_index(id, PET_EGG);
  3558. if (pet_id >= 0) {
  3559. sd->catch_target_class = pet_db[pet_id].class_;
  3560. intif_create_pet(
  3561. sd->status.account_id, sd->status.char_id,
  3562. (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv,
  3563. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3564. 100, 0, 1, pet_db[pet_id].jname);
  3565. } else {
  3566. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3567. return -1;
  3568. }
  3569. return 0;
  3570. }
  3571. /*==========================================
  3572. *
  3573. *------------------------------------------
  3574. */
  3575. int atcommand_hatch(
  3576. const int fd, struct map_session_data* sd,
  3577. const char* command, const char* message)
  3578. {
  3579. nullpo_retr(-1, sd);
  3580. if (sd->status.pet_id <= 0)
  3581. clif_sendegg(sd);
  3582. else {
  3583. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3584. return -1;
  3585. }
  3586. return 0;
  3587. }
  3588. /*==========================================
  3589. *
  3590. *------------------------------------------
  3591. */
  3592. int atcommand_petfriendly(
  3593. const int fd, struct map_session_data* sd,
  3594. const char* command, const char* message)
  3595. {
  3596. int friendly;
  3597. int t;
  3598. nullpo_retr(-1, sd);
  3599. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3600. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3601. return -1;
  3602. }
  3603. if (sd->status.pet_id > 0 && sd->pd) {
  3604. if (friendly >= 0 && friendly <= 1000) {
  3605. if (friendly != sd->pet.intimate) {
  3606. t = sd->pet.intimate;
  3607. sd->pet.intimate = friendly;
  3608. clif_send_petstatus(sd);
  3609. if (battle_config.pet_status_support) {
  3610. if ((sd->pet.intimate > 0 && t <= 0) ||
  3611. (sd->pet.intimate <= 0 && t > 0)) {
  3612. if (sd->bl.prev != NULL)
  3613. status_calc_pc(sd, 0);
  3614. else
  3615. status_calc_pc(sd, 2);
  3616. }
  3617. }
  3618. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3619. } else {
  3620. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3621. return -1;
  3622. }
  3623. } else {
  3624. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3625. return -1;
  3626. }
  3627. } else {
  3628. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3629. return -1;
  3630. }
  3631. return 0;
  3632. }
  3633. /*==========================================
  3634. *
  3635. *------------------------------------------
  3636. */
  3637. int atcommand_pethungry(
  3638. const int fd, struct map_session_data* sd,
  3639. const char* command, const char* message)
  3640. {
  3641. int hungry;
  3642. nullpo_retr(-1, sd);
  3643. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3644. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3645. return -1;
  3646. }
  3647. if (sd->status.pet_id > 0 && sd->pd) {
  3648. if (hungry >= 0 && hungry <= 100) {
  3649. if (hungry != sd->pet.hungry) {
  3650. sd->pet.hungry = hungry;
  3651. clif_send_petstatus(sd);
  3652. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3653. } else {
  3654. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3655. return -1;
  3656. }
  3657. } else {
  3658. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3659. return -1;
  3660. }
  3661. } else {
  3662. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3663. return -1;
  3664. }
  3665. return 0;
  3666. }
  3667. /*==========================================
  3668. *
  3669. *------------------------------------------
  3670. */
  3671. int atcommand_petrename(
  3672. const int fd, struct map_session_data* sd,
  3673. const char* command, const char* message)
  3674. {
  3675. nullpo_retr(-1, sd);
  3676. if (sd->status.pet_id > 0 && sd->pd) {
  3677. if (sd->pet.rename_flag != 0) {
  3678. sd->pet.rename_flag = 0;
  3679. intif_save_petdata(sd->status.account_id, &sd->pet);
  3680. clif_send_petstatus(sd);
  3681. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3682. } else {
  3683. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3684. return -1;
  3685. }
  3686. } else {
  3687. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3688. return -1;
  3689. }
  3690. return 0;
  3691. }
  3692. /*==========================================
  3693. *
  3694. *------------------------------------------
  3695. */
  3696. int
  3697. atcommand_recall(
  3698. const int fd, struct map_session_data* sd,
  3699. const char* command, const char* message)
  3700. {
  3701. char character[100];
  3702. char output[200];
  3703. struct map_session_data *pl_sd = NULL;
  3704. nullpo_retr(-1, sd);
  3705. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3706. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3707. return -1;
  3708. }
  3709. memset(character, '\0', sizeof character);
  3710. if(sscanf(message, "%99[^\n]", character) < 1)
  3711. return -1;
  3712. if(strncmp(sd->status.name,character,24)==0)
  3713. return -1;
  3714. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3715. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3716. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3717. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3718. return -1;
  3719. }
  3720. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3721. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  3722. return -1;
  3723. }
  3724. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  3725. sprintf(output, msg_table[46], character); // %s recalled!
  3726. clif_displaymessage(fd, output);
  3727. } else {
  3728. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3729. return -1;
  3730. }
  3731. } else {
  3732. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3733. return -1;
  3734. }
  3735. return 0;
  3736. }
  3737. /*==========================================
  3738. *
  3739. *------------------------------------------
  3740. */
  3741. int atcommand_revive(
  3742. const int fd, struct map_session_data* sd,
  3743. const char* command, const char* message)
  3744. {
  3745. char character[100];
  3746. struct map_session_data *pl_sd;
  3747. nullpo_retr(-1, sd);
  3748. memset(character, '\0', sizeof(character));
  3749. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3750. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3751. return -1;
  3752. }
  3753. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3754. if (pc_isdead(pl_sd)) {
  3755. pl_sd->status.hp = pl_sd->status.max_hp;
  3756. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3757. pc_setstand(pl_sd);
  3758. if (battle_config.pc_invincible_time > 0)
  3759. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3760. clif_updatestatus(pl_sd, SP_HP);
  3761. clif_updatestatus(pl_sd, SP_SP);
  3762. clif_resurrection(&pl_sd->bl, 1);
  3763. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3764. return 0;
  3765. }
  3766. return -1;
  3767. } else {
  3768. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3769. return -1;
  3770. }
  3771. return 0;
  3772. }
  3773. /*==========================================
  3774. * charchangesex command (usage: charchangesex <player_name>)
  3775. *------------------------------------------
  3776. */
  3777. int atcommand_char_change_sex(
  3778. const int fd, struct map_session_data* sd,
  3779. const char* command, const char* message)
  3780. {
  3781. char character[100];
  3782. nullpo_retr(-1, sd);
  3783. memset(character, '\0', sizeof(character));
  3784. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3785. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  3786. return -1;
  3787. }
  3788. // check player name
  3789. if (strlen(character) < 4) {
  3790. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3791. return -1;
  3792. } else if (strlen(character) > 23) {
  3793. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3794. return -1;
  3795. } else {
  3796. chrif_char_ask_name(sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
  3797. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3798. }
  3799. return 0;
  3800. }
  3801. /*==========================================
  3802. * charblock command (usage: charblock <player_name>)
  3803. * This command do a definitiv ban on a player
  3804. *------------------------------------------
  3805. */
  3806. int atcommand_char_block(
  3807. const int fd, struct map_session_data* sd,
  3808. const char* command, const char* message)
  3809. {
  3810. char character[100];
  3811. nullpo_retr(-1, sd);
  3812. memset(character, '\0', sizeof(character));
  3813. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3814. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3815. return -1;
  3816. }
  3817. // check player name
  3818. if (strlen(character) < 4) {
  3819. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3820. return -1;
  3821. } else if (strlen(character) > 23) {
  3822. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3823. return -1;
  3824. } else {
  3825. chrif_char_ask_name(sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3826. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3827. }
  3828. return 0;
  3829. }
  3830. /*==========================================
  3831. * charban command (usage: charban <time> <player_name>)
  3832. * This command do a limited ban on a player
  3833. * Time is done as follows:
  3834. * Adjustment value (-1, 1, +1, etc...)
  3835. * Modified element:
  3836. * a or y: year
  3837. * m: month
  3838. * j or d: day
  3839. * h: hour
  3840. * mn: minute
  3841. * s: second
  3842. * <example> @ban +1m-2mn1s-6y test_player
  3843. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3844. *------------------------------------------
  3845. */
  3846. int atcommand_char_ban(
  3847. const int fd, struct map_session_data* sd,
  3848. const char* command, const char* message)
  3849. {
  3850. char modif[100], character[100];
  3851. char * modif_p;
  3852. int year, month, day, hour, minute, second, value;
  3853. nullpo_retr(-1, sd);
  3854. memset(modif, '\0', sizeof(modif));
  3855. memset(character, '\0', sizeof(character));
  3856. if (!message || !*message || sscanf(message, "%s %99[^\n]", modif, character) < 2) {
  3857. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3858. return -1;
  3859. }
  3860. modif[sizeof(modif)-1] = '\0';
  3861. character[sizeof(character)-1] = '\0';
  3862. modif_p = modif;
  3863. year = month = day = hour = minute = second = 0;
  3864. while (modif_p[0] != '\0') {
  3865. value = atoi(modif_p);
  3866. if (value == 0)
  3867. modif_p++;
  3868. else {
  3869. if (modif_p[0] == '-' || modif_p[0] == '+')
  3870. modif_p++;
  3871. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3872. modif_p++;
  3873. if (modif_p[0] == 's') {
  3874. second = value;
  3875. modif_p++;
  3876. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3877. minute = value;
  3878. modif_p = modif_p + 2;
  3879. } else if (modif_p[0] == 'h') {
  3880. hour = value;
  3881. modif_p++;
  3882. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3883. day = value;
  3884. modif_p++;
  3885. } else if (modif_p[0] == 'm') {
  3886. month = value;
  3887. modif_p++;
  3888. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3889. year = value;
  3890. modif_p++;
  3891. } else if (modif_p[0] != '\0') {
  3892. modif_p++;
  3893. }
  3894. }
  3895. }
  3896. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3897. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  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. chrif_char_ask_name(sd->status.account_id, character, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3909. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3910. }
  3911. return 0;
  3912. }
  3913. /*==========================================
  3914. * charunblock command (usage: charunblock <player_name>)
  3915. *------------------------------------------
  3916. */
  3917. int atcommand_char_unblock(
  3918. const int fd, struct map_session_data* sd,
  3919. const char* command, const char* message)
  3920. {
  3921. char character[100];
  3922. nullpo_retr(-1, sd);
  3923. memset(character, '\0', sizeof(character));
  3924. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3925. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3926. return -1;
  3927. }
  3928. // check player name
  3929. if (strlen(character) < 4) {
  3930. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3931. return -1;
  3932. } else if (strlen(character) > 23) {
  3933. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3934. return -1;
  3935. } else {
  3936. // send answer to login server via char-server
  3937. chrif_char_ask_name(sd->status.account_id, character, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3938. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3939. }
  3940. return 0;
  3941. }
  3942. /*==========================================
  3943. * charunban command (usage: charunban <player_name>)
  3944. *------------------------------------------
  3945. */
  3946. int atcommand_char_unban(
  3947. const int fd, struct map_session_data* sd,
  3948. const char* command, const char* message)
  3949. {
  3950. char character[100];
  3951. nullpo_retr(-1, sd);
  3952. memset(character, '\0', sizeof(character));
  3953. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3954. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3955. return -1;
  3956. }
  3957. // check player name
  3958. if (strlen(character) < 4) {
  3959. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3960. return -1;
  3961. } else if (strlen(character) > 23) {
  3962. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3963. return -1;
  3964. } else {
  3965. // send answer to login server via char-server
  3966. chrif_char_ask_name(sd->status.account_id, character, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3967. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3968. }
  3969. return 0;
  3970. }
  3971. /*==========================================
  3972. *
  3973. *------------------------------------------
  3974. */
  3975. int atcommand_night(
  3976. const int fd, struct map_session_data* sd,
  3977. const char* command, const char* message)
  3978. {
  3979. struct map_session_data *pl_sd;
  3980. int i;
  3981. nullpo_retr(-1, sd);
  3982. if (night_flag != 1) {
  3983. night_flag = 1; // 0=day, 1=night [Yor]
  3984. for(i = 0; i < fd_max; i++) {
  3985. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !map[sd->bl.m].flag.indoors) {
  3986. //pl_sd->opt2 |= STATE_BLIND;
  3987. //clif_changeoption(&pl_sd->bl);
  3988. if (battle_config.night_darkness_level > 0)
  3989. clif_specialeffect(&pl_sd->bl, 474 + battle_config.night_darkness_level, 0);
  3990. else {
  3991. //clif_specialeffect(&pl_sd->bl, 483, 0); // default darkness level
  3992. pl_sd->opt2 |= STATE_BLIND;
  3993. clif_changeoption(&pl_sd->bl);
  3994. }
  3995. clif_displaymessage(pl_sd->fd, msg_table[59]); // Night has fallen.
  3996. }
  3997. }
  3998. } else {
  3999. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4000. return -1;
  4001. }
  4002. return 0;
  4003. }
  4004. /*==========================================
  4005. *
  4006. *------------------------------------------
  4007. */
  4008. int atcommand_day(
  4009. const int fd, struct map_session_data* sd,
  4010. const char* command, const char* message)
  4011. {
  4012. struct map_session_data *pl_sd;
  4013. int i;
  4014. nullpo_retr(-1, sd);
  4015. if (night_flag != 0) {
  4016. night_flag = 0; // 0=day, 1=night [Yor]
  4017. for(i = 0; i < fd_max; i++) {
  4018. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4019. pl_sd->opt2 &= ~STATE_BLIND;
  4020. clif_changeoption(&pl_sd->bl);
  4021. clif_displaymessage(pl_sd->fd, msg_table[60]); // Day has arrived.
  4022. }
  4023. }
  4024. } else {
  4025. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4026. return -1;
  4027. }
  4028. return 0;
  4029. }
  4030. /*==========================================
  4031. *
  4032. *------------------------------------------
  4033. */
  4034. int atcommand_doom(
  4035. const int fd, struct map_session_data* sd,
  4036. const char* command, const char* message)
  4037. {
  4038. struct map_session_data *pl_sd;
  4039. int i;
  4040. nullpo_retr(-1, sd);
  4041. clif_specialeffect(&sd->bl,450,2);
  4042. for(i = 0; i < fd_max; i++) {
  4043. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd &&
  4044. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4045. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4046. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4047. }
  4048. }
  4049. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4050. return 0;
  4051. }
  4052. /*==========================================
  4053. *
  4054. *------------------------------------------
  4055. */
  4056. int atcommand_doommap(
  4057. const int fd, struct map_session_data* sd,
  4058. const char* command, const char* message)
  4059. {
  4060. struct map_session_data *pl_sd;
  4061. int i;
  4062. nullpo_retr(-1, sd);
  4063. clif_specialeffect(&sd->bl,450,3);
  4064. for (i = 0; i < fd_max; i++) {
  4065. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd && sd->bl.m == pl_sd->bl.m &&
  4066. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4067. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4068. // clif_specialeffect(&pl_sd->bl,450,1);
  4069. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4070. }
  4071. }
  4072. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4073. return 0;
  4074. }
  4075. /*==========================================
  4076. *
  4077. *------------------------------------------
  4078. */
  4079. static void atcommand_raise_sub(struct map_session_data* sd)
  4080. {
  4081. if (sd && sd->state.auth && pc_isdead(sd)) {
  4082. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4083. sd->status.hp = sd->status.max_hp;
  4084. sd->status.sp = sd->status.max_sp;
  4085. pc_setstand(sd);
  4086. clif_updatestatus(sd, SP_HP);
  4087. clif_updatestatus(sd, SP_SP);
  4088. clif_resurrection(&sd->bl, 1);
  4089. if (battle_config.pc_invincible_time > 0)
  4090. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4091. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4092. }
  4093. }
  4094. /*==========================================
  4095. *
  4096. *------------------------------------------
  4097. */
  4098. int atcommand_raise(
  4099. const int fd, struct map_session_data* sd,
  4100. const char* command, const char* message)
  4101. {
  4102. int i;
  4103. nullpo_retr(-1, sd);
  4104. for (i = 0; i < fd_max; i++) {
  4105. if (session[i])
  4106. atcommand_raise_sub(session[i]->session_data);
  4107. }
  4108. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4109. return 0;
  4110. }
  4111. /*==========================================
  4112. *
  4113. *------------------------------------------
  4114. */
  4115. int atcommand_raisemap(
  4116. const int fd, struct map_session_data* sd,
  4117. const char* command, const char* message)
  4118. {
  4119. struct map_session_data *pl_sd;
  4120. int i;
  4121. nullpo_retr(-1, sd);
  4122. for (i = 0; i < fd_max; i++) {
  4123. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->bl.m == pl_sd->bl.m)
  4124. atcommand_raise_sub(pl_sd);
  4125. }
  4126. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4127. return 0;
  4128. }
  4129. /*==========================================
  4130. * atcommand_character_baselevel @charbaselvlで対象キャラのレベルを上げる
  4131. *------------------------------------------
  4132. */
  4133. int atcommand_character_baselevel(
  4134. const int fd, struct map_session_data* sd,
  4135. const char* command, const char* message)
  4136. {
  4137. struct map_session_data *pl_sd;
  4138. char character[100];
  4139. int level = 0, i;
  4140. nullpo_retr(-1, sd);
  4141. memset(character, '\0', sizeof(character));
  4142. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4143. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charbaselvl <#> <nickname>).");
  4144. return -1;
  4145. }
  4146. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4147. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  4148. if (level > 0) {
  4149. if (pl_sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  4150. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  4151. return 0;
  4152. } // End Addition
  4153. if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
  4154. level = battle_config.maximum_level - pl_sd->status.base_level;
  4155. for (i = 1; i <= level; i++)
  4156. pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5;
  4157. pl_sd->status.base_level += level;
  4158. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4159. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4160. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4161. status_calc_pc(pl_sd, 0);
  4162. pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp);
  4163. clif_misceffect(&pl_sd->bl, 0);
  4164. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  4165. } else {
  4166. if (pl_sd->status.base_level == 1) {
  4167. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  4168. return -1;
  4169. }
  4170. if (level < -(int)battle_config.maximum_level || level < (1 - (int)pl_sd->status.base_level)) // fix negativ overflow
  4171. level = 1 - pl_sd->status.base_level;
  4172. if (pl_sd->status.status_point > 0) {
  4173. for (i = 0; i > level; i--)
  4174. pl_sd->status.status_point -= (pl_sd->status.base_level + i + 14) / 5;
  4175. if (pl_sd->status.status_point < 0)
  4176. pl_sd->status.status_point = 0;
  4177. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4178. } // to add: remove status points from stats
  4179. pl_sd->status.base_level += level;
  4180. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4181. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4182. status_calc_pc(pl_sd, 0);
  4183. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  4184. }
  4185. } else {
  4186. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4187. return -1;
  4188. }
  4189. } else {
  4190. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4191. return -1;
  4192. }
  4193. return 0; //正常終了
  4194. }
  4195. /*==========================================
  4196. * atcommand_character_joblevel @charjoblvlで対象キャラのJobレベルを上げる
  4197. *------------------------------------------
  4198. */
  4199. int atcommand_character_joblevel(
  4200. const int fd, struct map_session_data* sd,
  4201. const char* command, const char* message)
  4202. {
  4203. struct map_session_data *pl_sd;
  4204. char character[100];
  4205. unsigned int max_level = 50;
  4206. int level = 0;
  4207. //転生や養子の場合の元の職業を算出する
  4208. struct pc_base_job pl_s_class;
  4209. nullpo_retr(-1, sd);
  4210. memset(character, '\0', sizeof(character));
  4211. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4212. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charjlvl <#> <nickname>).");
  4213. return -1;
  4214. }
  4215. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4216. pl_s_class = pc_calc_base_job(pl_sd->status.class_);
  4217. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  4218. if (pl_s_class.job == 0)
  4219. max_level -= 40;
  4220. // super novices can go up to 99 [celest]
  4221. else if (pl_s_class.job == 23)
  4222. max_level += 49;
  4223. else if (pl_sd->status.class_ > 4007 && pl_sd->status.class_ < 4023)
  4224. max_level += 20;
  4225. if (level > 0) {
  4226. if (pl_sd->status.job_level == max_level) {
  4227. clif_displaymessage(fd, msg_table[67]); // Character's job level can't go any higher.
  4228. return -1;
  4229. }
  4230. if (pl_sd->status.job_level + level > max_level)
  4231. level = max_level - pl_sd->status.job_level;
  4232. pl_sd->status.job_level += level;
  4233. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4234. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4235. pl_sd->status.skill_point += level;
  4236. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4237. status_calc_pc(pl_sd, 0);
  4238. clif_misceffect(&pl_sd->bl, 1);
  4239. clif_displaymessage(fd, msg_table[68]); // character's job level raised.
  4240. } else {
  4241. if (pl_sd->status.job_level == 1) {
  4242. clif_displaymessage(fd, msg_table[194]); // Character's job level can't go any lower.
  4243. return -1;
  4244. }
  4245. if (pl_sd->status.job_level + level < 1)
  4246. level = 1 - pl_sd->status.job_level;
  4247. pl_sd->status.job_level += level;
  4248. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4249. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4250. if (pl_sd->status.skill_point > 0) {
  4251. pl_sd->status.skill_point += level;
  4252. if (pl_sd->status.skill_point < 0)
  4253. pl_sd->status.skill_point = 0;
  4254. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4255. } // to add: remove status points from skills
  4256. status_calc_pc(pl_sd, 0);
  4257. clif_displaymessage(fd, msg_table[69]); // Character's job level lowered.
  4258. }
  4259. } else {
  4260. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4261. return -1;
  4262. }
  4263. } else {
  4264. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4265. return -1;
  4266. }
  4267. return 0;
  4268. }
  4269. /*==========================================
  4270. *
  4271. *------------------------------------------
  4272. */
  4273. int atcommand_kick(
  4274. const int fd, struct map_session_data* sd,
  4275. const char* command, const char* message)
  4276. {
  4277. struct map_session_data *pl_sd;
  4278. char character[100];
  4279. nullpo_retr(-1, sd);
  4280. memset(character, '\0', sizeof(character));
  4281. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4282. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4283. return -1;
  4284. }
  4285. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4286. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4287. clif_GM_kick(sd, pl_sd, 1);
  4288. else {
  4289. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4290. return -1;
  4291. }
  4292. } else {
  4293. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4294. return -1;
  4295. }
  4296. return 0;
  4297. }
  4298. /*==========================================
  4299. *
  4300. *------------------------------------------
  4301. */
  4302. int atcommand_kickall(
  4303. const int fd, struct map_session_data* sd,
  4304. const char* command, const char* message)
  4305. {
  4306. struct map_session_data *pl_sd;
  4307. int i;
  4308. nullpo_retr(-1, sd);
  4309. for (i = 0; i < fd_max; i++) {
  4310. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4311. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4312. if (sd->status.account_id != pl_sd->status.account_id)
  4313. clif_GM_kick(sd, pl_sd, 0);
  4314. }
  4315. }
  4316. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4317. return 0;
  4318. }
  4319. /*==========================================
  4320. *
  4321. *------------------------------------------
  4322. */
  4323. int atcommand_allskill(
  4324. const int fd, struct map_session_data* sd,
  4325. const char* command, const char* message)
  4326. {
  4327. nullpo_retr(-1, sd);
  4328. pc_allskillup(sd); // all skills
  4329. sd->status.skill_point = 0; // 0 skill points
  4330. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4331. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4332. return 0;
  4333. }
  4334. /*==========================================
  4335. *
  4336. *------------------------------------------
  4337. */
  4338. int atcommand_questskill(
  4339. const int fd, struct map_session_data* sd,
  4340. const char* command, const char* message)
  4341. {
  4342. int skill_id;
  4343. nullpo_retr(-1, sd);
  4344. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4345. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4346. return -1;
  4347. }
  4348. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4349. if (skill_get_inf2(skill_id) & 0x01) {
  4350. if (pc_checkskill(sd, skill_id) == 0) {
  4351. pc_skill(sd, skill_id, 1, 0);
  4352. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4353. } else {
  4354. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4355. return -1;
  4356. }
  4357. } else {
  4358. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4359. return -1;
  4360. }
  4361. } else {
  4362. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4363. return -1;
  4364. }
  4365. return 0;
  4366. }
  4367. /*==========================================
  4368. *
  4369. *------------------------------------------
  4370. */
  4371. int atcommand_charquestskill(
  4372. const int fd, struct map_session_data* sd,
  4373. const char* command, const char* message)
  4374. {
  4375. char character[100];
  4376. struct map_session_data *pl_sd;
  4377. int skill_id = 0;
  4378. nullpo_retr(-1, sd);
  4379. memset(character, '\0', sizeof(character));
  4380. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4381. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charquestskill <#:0+> <char_name>).");
  4382. return -1;
  4383. }
  4384. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4385. if (skill_get_inf2(skill_id) & 0x01) {
  4386. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4387. if (pc_checkskill(pl_sd, skill_id) == 0) {
  4388. pc_skill(pl_sd, skill_id, 1, 0);
  4389. clif_displaymessage(fd, msg_table[199]); // This player has learned the skill.
  4390. } else {
  4391. clif_displaymessage(fd, msg_table[200]); // This player already has this quest skill.
  4392. return -1;
  4393. }
  4394. } else {
  4395. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4396. return -1;
  4397. }
  4398. } else {
  4399. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4400. return -1;
  4401. }
  4402. } else {
  4403. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4404. return -1;
  4405. }
  4406. return 0;
  4407. }
  4408. /*==========================================
  4409. *
  4410. *------------------------------------------
  4411. */
  4412. int atcommand_lostskill(
  4413. const int fd, struct map_session_data* sd,
  4414. const char* command, const char* message)
  4415. {
  4416. int skill_id;
  4417. nullpo_retr(-1, sd);
  4418. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4419. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4420. return -1;
  4421. }
  4422. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4423. if (skill_get_inf2(skill_id) & 0x01) {
  4424. if (pc_checkskill(sd, skill_id) > 0) {
  4425. sd->status.skill[skill_id].lv = 0;
  4426. sd->status.skill[skill_id].flag = 0;
  4427. clif_skillinfoblock(sd);
  4428. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4429. } else {
  4430. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4431. return -1;
  4432. }
  4433. } else {
  4434. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4435. return -1;
  4436. }
  4437. } else {
  4438. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4439. return -1;
  4440. }
  4441. return 0;
  4442. }
  4443. /*==========================================
  4444. *
  4445. *------------------------------------------
  4446. */
  4447. int atcommand_charlostskill(
  4448. const int fd, struct map_session_data* sd,
  4449. const char* command, const char* message)
  4450. {
  4451. char character[100];
  4452. struct map_session_data *pl_sd;
  4453. int skill_id = 0;
  4454. nullpo_retr(-1, sd);
  4455. memset(character, '\0', sizeof(character));
  4456. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4457. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  4458. return -1;
  4459. }
  4460. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4461. if (skill_get_inf2(skill_id) & 0x01) {
  4462. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4463. if (pc_checkskill(pl_sd, skill_id) > 0) {
  4464. pl_sd->status.skill[skill_id].lv = 0;
  4465. pl_sd->status.skill[skill_id].flag = 0;
  4466. clif_skillinfoblock(pl_sd);
  4467. clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill.
  4468. } else {
  4469. clif_displaymessage(fd, msg_table[203]); // This player doesn't have this quest skill.
  4470. return -1;
  4471. }
  4472. } else {
  4473. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4474. return -1;
  4475. }
  4476. } else {
  4477. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4478. return -1;
  4479. }
  4480. } else {
  4481. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4482. return -1;
  4483. }
  4484. return 0;
  4485. }
  4486. /*==========================================
  4487. *
  4488. *------------------------------------------
  4489. */
  4490. int atcommand_spiritball(
  4491. const int fd, struct map_session_data* sd,
  4492. const char* command, const char* message)
  4493. {
  4494. int number;
  4495. nullpo_retr(-1, sd);
  4496. if (!message || !*message || (number = atoi(message)) < 0) {
  4497. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4498. return -1;
  4499. }
  4500. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4501. if (number > 500)
  4502. number = 500;
  4503. if (number >= 0 && number <= 0x7FFF) {
  4504. if (sd->spiritball != number || number > 499) {
  4505. if (sd->spiritball > 0)
  4506. pc_delspiritball(sd, sd->spiritball, 1);
  4507. sd->spiritball = number;
  4508. clif_spiritball(sd);
  4509. // no message, player can look the difference
  4510. if (number > 1000)
  4511. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4512. } else {
  4513. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4514. return -1;
  4515. }
  4516. } else {
  4517. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4518. return -1;
  4519. }
  4520. return 0;
  4521. }
  4522. /*==========================================
  4523. *
  4524. *------------------------------------------
  4525. */
  4526. int atcommand_party(
  4527. const int fd, struct map_session_data* sd,
  4528. const char* command, const char* message)
  4529. {
  4530. char party[100];
  4531. nullpo_retr(-1, sd);
  4532. memset(party, '\0', sizeof(party));
  4533. if (!message || !*message || sscanf(message, "%99[^\n]", party) < 1) {
  4534. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4535. return -1;
  4536. }
  4537. party_create(sd, party);
  4538. return 0;
  4539. }
  4540. /*==========================================
  4541. *
  4542. *------------------------------------------
  4543. */
  4544. int atcommand_guild(
  4545. const int fd, struct map_session_data* sd,
  4546. const char* command, const char* message)
  4547. {
  4548. char guild[100];
  4549. int prev;
  4550. nullpo_retr(-1, sd);
  4551. memset(guild, '\0', sizeof(guild));
  4552. if (!message || !*message || sscanf(message, "%99[^\n]", guild) < 1) {
  4553. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4554. return -1;
  4555. }
  4556. prev = battle_config.guild_emperium_check;
  4557. battle_config.guild_emperium_check = 0;
  4558. guild_create(sd, guild);
  4559. battle_config.guild_emperium_check = prev;
  4560. return 0;
  4561. }
  4562. /*==========================================
  4563. *
  4564. *------------------------------------------
  4565. */
  4566. int atcommand_agitstart(
  4567. const int fd, struct map_session_data* sd,
  4568. const char* command, const char* message)
  4569. {
  4570. nullpo_retr(-1, sd);
  4571. if (agit_flag == 1) {
  4572. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4573. return -1;
  4574. }
  4575. agit_flag = 1;
  4576. guild_agit_start();
  4577. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4578. return 0;
  4579. }
  4580. /*==========================================
  4581. *
  4582. *------------------------------------------
  4583. */
  4584. int atcommand_agitend(
  4585. const int fd, struct map_session_data* sd,
  4586. const char* command, const char* message)
  4587. {
  4588. nullpo_retr(-1, sd);
  4589. if (agit_flag == 0) {
  4590. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4591. return -1;
  4592. }
  4593. agit_flag = 0;
  4594. guild_agit_end();
  4595. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4596. return 0;
  4597. }
  4598. /*==========================================
  4599. * @mapexitでマップサーバーを終了させる
  4600. *------------------------------------------
  4601. */
  4602. int atcommand_mapexit(
  4603. const int fd, struct map_session_data* sd,
  4604. const char* command, const char* message)
  4605. {
  4606. struct map_session_data *pl_sd;
  4607. int i;
  4608. nullpo_retr(-1, sd);
  4609. for (i = 0; i < fd_max; i++) {
  4610. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4611. if (sd->status.account_id != pl_sd->status.account_id)
  4612. clif_GM_kick(sd, pl_sd, 0);
  4613. }
  4614. }
  4615. clif_GM_kick(sd, sd, 0);
  4616. runflag = 0;
  4617. return 0;
  4618. }
  4619. /*==========================================
  4620. * idsearch <part_of_name>: revrited by [Yor]
  4621. *------------------------------------------
  4622. */
  4623. int atcommand_idsearch(
  4624. const int fd, struct map_session_data* sd,
  4625. const char* command, const char* message)
  4626. {
  4627. char item_name[100];
  4628. char output[200];
  4629. unsigned int i, match;
  4630. struct item_data *item;
  4631. nullpo_retr(-1, sd);
  4632. memset(item_name, '\0', sizeof(item_name));
  4633. memset(output, '\0', sizeof(output));
  4634. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4635. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4636. return -1;
  4637. }
  4638. sprintf(output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4639. clif_displaymessage(fd, output);
  4640. match = 0;
  4641. for(i = 0; i < 20000; i++) {
  4642. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4643. match++;
  4644. sprintf(output, msg_table[78], item->jname, item->nameid); // %s: %d
  4645. clif_displaymessage(fd, output);
  4646. }
  4647. }
  4648. sprintf(output, msg_table[79], match); // It is %d affair above.
  4649. clif_displaymessage(fd, output);
  4650. return 0;
  4651. }
  4652. /*==========================================
  4653. * Character Skill Reset
  4654. *------------------------------------------
  4655. */
  4656. int atcommand_charskreset(
  4657. const int fd, struct map_session_data* sd,
  4658. const char* command, const char* message)
  4659. {
  4660. char character[100];
  4661. char output[200];
  4662. struct map_session_data *pl_sd;
  4663. nullpo_retr(-1, sd);
  4664. memset(character, '\0', sizeof(character));
  4665. memset(output, '\0', sizeof(output));
  4666. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4667. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  4668. return -1;
  4669. }
  4670. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4671. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  4672. pc_resetskill(pl_sd);
  4673. sprintf(output, msg_table[206], character); // '%s' skill points reseted!
  4674. clif_displaymessage(fd, output);
  4675. } else {
  4676. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4677. return -1;
  4678. }
  4679. } else {
  4680. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4681. return -1;
  4682. }
  4683. return 0;
  4684. }
  4685. /*==========================================
  4686. * Character Stat Reset
  4687. *------------------------------------------
  4688. */
  4689. int atcommand_charstreset(
  4690. const int fd, struct map_session_data* sd,
  4691. const char* command, const char* message)
  4692. {
  4693. char character[100];
  4694. char output[200];
  4695. struct map_session_data *pl_sd;
  4696. nullpo_retr(-1, sd);
  4697. memset(character, '\0', sizeof(character));
  4698. memset(output, '\0', sizeof(output));
  4699. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4700. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  4701. return -1;
  4702. }
  4703. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4704. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  4705. pc_resetstate(pl_sd);
  4706. sprintf(output, msg_table[207], character); // '%s' stats points reseted!
  4707. clif_displaymessage(fd, output);
  4708. } else {
  4709. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4710. return -1;
  4711. }
  4712. } else {
  4713. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4714. return -1;
  4715. }
  4716. return 0;
  4717. }
  4718. /*==========================================
  4719. * Character Model by chbrules
  4720. *------------------------------------------
  4721. */
  4722. int atcommand_charmodel(
  4723. const int fd, struct map_session_data* sd,
  4724. const char* command, const char* message)
  4725. {
  4726. int hair_style = 0, hair_color = 0, cloth_color = 0;
  4727. struct map_session_data *pl_sd;
  4728. char character[100];
  4729. char output[200];
  4730. nullpo_retr(-1, sd);
  4731. memset(character, '\0', sizeof(character));
  4732. memset(output, '\0', sizeof(output));
  4733. 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) {
  4734. 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>).",
  4735. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  4736. clif_displaymessage(fd, output);
  4737. return -1;
  4738. }
  4739. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4740. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  4741. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  4742. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  4743. if (cloth_color != 0 &&
  4744. pl_sd->status.sex == 1 &&
  4745. (pl_sd->status.class_ == 12 || pl_sd->status.class_ == 17)) {
  4746. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  4747. return -1;
  4748. } else {
  4749. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  4750. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  4751. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  4752. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  4753. }
  4754. } else {
  4755. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4756. return -1;
  4757. }
  4758. } else {
  4759. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4760. return -1;
  4761. }
  4762. return 0;
  4763. }
  4764. /*==========================================
  4765. * Character Skill Point (Rewritten by [Yor])
  4766. *------------------------------------------
  4767. */
  4768. int atcommand_charskpoint(
  4769. const int fd, struct map_session_data* sd,
  4770. const char* command, const char* message)
  4771. {
  4772. struct map_session_data *pl_sd;
  4773. char character[100];
  4774. int new_skill_point;
  4775. int point = 0;
  4776. nullpo_retr(-1, sd);
  4777. memset(character, '\0', sizeof(character));
  4778. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4779. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  4780. return -1;
  4781. }
  4782. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4783. new_skill_point = (int)pl_sd->status.skill_point + point;
  4784. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  4785. new_skill_point = 0x7FFF;
  4786. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  4787. new_skill_point = 0;
  4788. if (new_skill_point != (int)pl_sd->status.skill_point) {
  4789. pl_sd->status.skill_point = new_skill_point;
  4790. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4791. clif_displaymessage(fd, msg_table[209]); // Character's number of skill points changed!
  4792. } else {
  4793. if (point < 0)
  4794. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4795. else
  4796. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4797. return -1;
  4798. }
  4799. } else {
  4800. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4801. return -1;
  4802. }
  4803. return 0;
  4804. }
  4805. /*==========================================
  4806. * Character Status Point (rewritten by [Yor])
  4807. *------------------------------------------
  4808. */
  4809. int atcommand_charstpoint(
  4810. const int fd, struct map_session_data* sd,
  4811. const char* command, const char* message)
  4812. {
  4813. struct map_session_data *pl_sd;
  4814. char character[100];
  4815. int new_status_point;
  4816. int point = 0;
  4817. nullpo_retr(-1, sd);
  4818. memset(character, '\0', sizeof(character));
  4819. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4820. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  4821. return -1;
  4822. }
  4823. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4824. new_status_point = (int)pl_sd->status.status_point + point;
  4825. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  4826. new_status_point = 0x7FFF;
  4827. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  4828. new_status_point = 0;
  4829. if (new_status_point != (int)pl_sd->status.status_point) {
  4830. pl_sd->status.status_point = new_status_point;
  4831. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4832. clif_displaymessage(fd, msg_table[210]); // Character's number of status points changed!
  4833. } else {
  4834. if (point < 0)
  4835. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4836. else
  4837. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4838. return -1;
  4839. }
  4840. } else {
  4841. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4842. return -1;
  4843. }
  4844. return 0;
  4845. }
  4846. /*==========================================
  4847. * Recall All Characters Online To Your Location
  4848. *------------------------------------------
  4849. */
  4850. int atcommand_recallall(
  4851. const int fd, struct map_session_data* sd,
  4852. const char* command, const char* message)
  4853. {
  4854. struct map_session_data *pl_sd;
  4855. int i;
  4856. int count;
  4857. char output[200];
  4858. nullpo_retr(-1, sd);
  4859. memset(output, '\0', sizeof(output));
  4860. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4861. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4862. return -1;
  4863. }
  4864. count = 0;
  4865. for (i = 0; i < fd_max; i++) {
  4866. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id &&
  4867. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4868. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4869. count++;
  4870. else
  4871. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4872. }
  4873. }
  4874. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4875. if (count) {
  4876. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4877. clif_displaymessage(fd, output);
  4878. }
  4879. return 0;
  4880. }
  4881. /*==========================================
  4882. * Recall online characters of a guild to your location
  4883. *------------------------------------------
  4884. */
  4885. int atcommand_guildrecall(
  4886. const int fd, struct map_session_data* sd,
  4887. const char* command, const char* message)
  4888. {
  4889. struct map_session_data *pl_sd;
  4890. int i;
  4891. char guild_name[100];
  4892. char output[200];
  4893. struct guild *g;
  4894. int count;
  4895. nullpo_retr(-1, sd);
  4896. memset(guild_name, '\0', sizeof(guild_name));
  4897. memset(output, '\0', sizeof(output));
  4898. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  4899. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4900. return -1;
  4901. }
  4902. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4903. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4904. return -1;
  4905. }
  4906. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4907. (g = guild_search(atoi(message))) != NULL) {
  4908. count = 0;
  4909. for (i = 0; i < fd_max; i++) {
  4910. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4911. sd->status.account_id != pl_sd->status.account_id &&
  4912. pl_sd->status.guild_id == g->guild_id) {
  4913. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4914. count++;
  4915. else
  4916. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4917. }
  4918. }
  4919. sprintf(output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4920. clif_displaymessage(fd, output);
  4921. if (count) {
  4922. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4923. clif_displaymessage(fd, output);
  4924. }
  4925. } else {
  4926. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4927. return -1;
  4928. }
  4929. return 0;
  4930. }
  4931. /*==========================================
  4932. * Recall online characters of a party to your location
  4933. *------------------------------------------
  4934. */
  4935. int atcommand_partyrecall(
  4936. const int fd, struct map_session_data* sd,
  4937. const char* command, const char* message)
  4938. {
  4939. int i;
  4940. struct map_session_data *pl_sd;
  4941. char party_name[100];
  4942. char output[200];
  4943. struct party *p;
  4944. int count;
  4945. nullpo_retr(-1, sd);
  4946. memset(party_name, '\0', sizeof(party_name));
  4947. memset(output, '\0', sizeof(output));
  4948. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  4949. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4950. return -1;
  4951. }
  4952. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4953. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4954. return -1;
  4955. }
  4956. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4957. (p = party_search(atoi(message))) != NULL) {
  4958. count = 0;
  4959. for (i = 0; i < fd_max; i++) {
  4960. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4961. sd->status.account_id != pl_sd->status.account_id &&
  4962. pl_sd->status.party_id == p->party_id) {
  4963. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4964. count++;
  4965. else
  4966. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4967. }
  4968. }
  4969. sprintf(output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4970. clif_displaymessage(fd, output);
  4971. if (count) {
  4972. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4973. clif_displaymessage(fd, output);
  4974. }
  4975. } else {
  4976. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4977. return -1;
  4978. }
  4979. return 0;
  4980. }
  4981. /*==========================================
  4982. *
  4983. *------------------------------------------
  4984. */
  4985. int atcommand_reloaditemdb(
  4986. const int fd, struct map_session_data* sd,
  4987. const char* command, const char* message)
  4988. {
  4989. nullpo_retr(-1, sd);
  4990. itemdb_reload();
  4991. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4992. return 0;
  4993. }
  4994. /*==========================================
  4995. *
  4996. *------------------------------------------
  4997. */
  4998. int atcommand_reloadmobdb(
  4999. const int fd, struct map_session_data* sd,
  5000. const char* command, const char* message)
  5001. {
  5002. nullpo_retr(-1, sd);
  5003. mob_reload();
  5004. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  5005. return 0;
  5006. }
  5007. /*==========================================
  5008. *
  5009. *------------------------------------------
  5010. */
  5011. int atcommand_reloadskilldb(
  5012. const int fd, struct map_session_data* sd,
  5013. const char* command, const char* message)
  5014. {
  5015. nullpo_retr(-1, sd);
  5016. skill_reload();
  5017. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  5018. return 0;
  5019. }
  5020. /*==========================================
  5021. *
  5022. *------------------------------------------
  5023. */
  5024. int atcommand_reloadscript(
  5025. const int fd, struct map_session_data* sd,
  5026. const char* command, const char* message)
  5027. {
  5028. nullpo_retr(-1, sd);
  5029. atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." );
  5030. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  5031. rehash( fd, sd );
  5032. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  5033. do_init_npc();
  5034. do_init_script();
  5035. npc_event_do_oninit();
  5036. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  5037. return 0;
  5038. }
  5039. /*==========================================
  5040. *
  5041. *------------------------------------------
  5042. */
  5043. int atcommand_reloadgmdb( // by [Yor]
  5044. const int fd, struct map_session_data* sd,
  5045. const char* command, const char* message)
  5046. {
  5047. nullpo_retr(-1, sd);
  5048. chrif_reloadGMdb();
  5049. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  5050. return 0;
  5051. }
  5052. /*==========================================
  5053. * @mapinfo <map name> [0-3] by MC_Cameri
  5054. * => Shows information about the map [map name]
  5055. * 0 = no additional information
  5056. * 1 = Show users in that map and their location
  5057. * 2 = Shows NPCs in that map
  5058. * 3 = Shows the shops/chats in that map (not implemented)
  5059. *------------------------------------------
  5060. */
  5061. int atcommand_mapinfo(
  5062. const int fd, struct map_session_data* sd,
  5063. const char* command, const char* message)
  5064. {
  5065. struct map_session_data *pl_sd;
  5066. struct npc_data *nd = NULL;
  5067. struct chat_data *cd = NULL;
  5068. char output[200], map_name[100];
  5069. char direction[12];
  5070. int m_id, i, chat_num, list = 0;
  5071. nullpo_retr(-1, sd);
  5072. memset(output, '\0', sizeof(output));
  5073. memset(map_name, '\0', sizeof(map_name));
  5074. memset(direction, '\0', sizeof(direction));
  5075. sscanf(message, "%d %99[^\n]", &list, map_name);
  5076. if (list < 0 || list > 3) {
  5077. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5078. return -1;
  5079. }
  5080. if (map_name[0] == '\0')
  5081. strcpy(map_name, sd->mapname);
  5082. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  5083. strcat(map_name, ".gat");
  5084. if ((m_id = map_mapname2mapid(map_name)) < 0) {
  5085. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5086. return -1;
  5087. }
  5088. clif_displaymessage(fd, "------ Map Info ------");
  5089. sprintf(output, "Map Name: %s", map_name);
  5090. clif_displaymessage(fd, output);
  5091. sprintf(output, "Players In Map: %d", map[m_id].users);
  5092. clif_displaymessage(fd, output);
  5093. sprintf(output, "NPCs In Map: %d", map[m_id].npc_num);
  5094. clif_displaymessage(fd, output);
  5095. chat_num = 0;
  5096. for (i = 0; i < fd_max; i++) {
  5097. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5098. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5099. chat_num++;
  5100. }
  5101. }
  5102. sprintf(output, "Chats In Map: %d", chat_num);
  5103. clif_displaymessage(fd, output);
  5104. clif_displaymessage(fd, "------ Map Flags ------");
  5105. sprintf(output, "Player vs Player: %s | No Guild: %s | No Party: %s",
  5106. (map[m_id].flag.pvp) ? "True" : "False",
  5107. (map[m_id].flag.pvp_noguild) ? "True" : "False",
  5108. (map[m_id].flag.pvp_noparty) ? "True" : "False");
  5109. clif_displaymessage(fd, output);
  5110. sprintf(output, "Guild vs Guild: %s | No Party: %s", (map[m_id].flag.gvg) ? "True" : "False", (map[m_id].flag.gvg_noparty) ? "True" : "False");
  5111. clif_displaymessage(fd, output);
  5112. sprintf(output, "No Dead Branch: %s", (map[m_id].flag.nobranch) ? "True" : "False");
  5113. clif_displaymessage(fd, output);
  5114. sprintf(output, "No Memo: %s", (map[m_id].flag.nomemo) ? "True" : "False");
  5115. clif_displaymessage(fd, output);
  5116. sprintf(output, "No Penalty: %s", (map[m_id].flag.nopenalty) ? "True" : "False");
  5117. clif_displaymessage(fd, output);
  5118. sprintf(output, "No Return: %s", (map[m_id].flag.noreturn) ? "True" : "False");
  5119. clif_displaymessage(fd, output);
  5120. sprintf(output, "No Save: %s", (map[m_id].flag.nosave) ? "True" : "False");
  5121. clif_displaymessage(fd, output);
  5122. sprintf(output, "No Teleport: %s", (map[m_id].flag.noteleport) ? "True" : "False");
  5123. clif_displaymessage(fd, output);
  5124. sprintf(output, "No Monster Teleport: %s", (map[m_id].flag.monster_noteleport) ? "True" : "False");
  5125. clif_displaymessage(fd, output);
  5126. sprintf(output, "No Zeny Penalty: %s", (map[m_id].flag.nozenypenalty) ? "True" : "False");
  5127. clif_displaymessage(fd, output);
  5128. switch (list) {
  5129. case 0:
  5130. // Do nothing. It's list 0, no additional display.
  5131. break;
  5132. case 1:
  5133. clif_displaymessage(fd, "----- Players in Map -----");
  5134. for (i = 0; i < fd_max; i++) {
  5135. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && strcmp(pl_sd->mapname, map_name) == 0) {
  5136. sprintf(output, "Player '%s' (session #%d) | Location: %d,%d",
  5137. pl_sd->status.name, i, pl_sd->bl.x, pl_sd->bl.y);
  5138. clif_displaymessage(fd, output);
  5139. }
  5140. }
  5141. break;
  5142. case 2:
  5143. clif_displaymessage(fd, "----- NPCs in Map -----");
  5144. for (i = 0; i < map[m_id].npc_num;) {
  5145. nd = map[m_id].npc[i];
  5146. switch(nd->dir) {
  5147. case 0: strcpy(direction, "North"); break;
  5148. case 1: strcpy(direction, "North West"); break;
  5149. case 2: strcpy(direction, "West"); break;
  5150. case 3: strcpy(direction, "South West"); break;
  5151. case 4: strcpy(direction, "South"); break;
  5152. case 5: strcpy(direction, "South East"); break;
  5153. case 6: strcpy(direction, "East"); break;
  5154. case 7: strcpy(direction, "North East"); break;
  5155. case 9: strcpy(direction, "North"); break;
  5156. default: strcpy(direction, "Unknown"); break;
  5157. }
  5158. sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5159. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5160. clif_displaymessage(fd, output);
  5161. }
  5162. break;
  5163. case 3:
  5164. clif_displaymessage(fd, "----- Chats in Map -----");
  5165. for (i = 0; i < fd_max; i++) {
  5166. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5167. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5168. strcmp(pl_sd->mapname, map_name) == 0 &&
  5169. cd->usersd[0] == pl_sd) {
  5170. sprintf(output, "Chat %d: %s | Player: %s | Location: %d %d",
  5171. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5172. clif_displaymessage(fd, output);
  5173. sprintf(output, " Users: %d/%d | Password: %s | Public: %s",
  5174. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5175. clif_displaymessage(fd, output);
  5176. }
  5177. }
  5178. break;
  5179. default: // normally impossible to arrive here
  5180. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5181. return -1;
  5182. break;
  5183. }
  5184. return 0;
  5185. }
  5186. /*==========================================
  5187. *
  5188. *------------------------------------------
  5189. */
  5190. int atcommand_mount_peco(
  5191. const int fd, struct map_session_data* sd,
  5192. const char* command, const char* message)
  5193. {
  5194. nullpo_retr(-1, sd);
  5195. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5196. clif_displaymessage(fd, msg_table[212]); // Cannot mount a Peco while in disguise.
  5197. return -1;
  5198. }
  5199. if (!pc_isriding(sd)) { // if actually no peco
  5200. if (sd->status.class_ == 7 || sd->status.class_ == 14 || sd->status.class_ == 4008 || sd->status.class_ == 4015) {
  5201. if (sd->status.class_ == 7)
  5202. sd->status.class_ = sd->view_class = 13;
  5203. else if (sd->status.class_ == 14)
  5204. sd->status.class_ = sd->view_class = 21;
  5205. else if (sd->status.class_ == 4008)
  5206. sd->status.class_ = sd->view_class = 4014;
  5207. else if (sd->status.class_ == 4015)
  5208. sd->status.class_ = sd->view_class = 4022;
  5209. pc_setoption(sd, sd->status.option | 0x0020);
  5210. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5211. } else {
  5212. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5213. return -1;
  5214. }
  5215. } else {
  5216. if (sd->status.class_ == 13)
  5217. sd->status.class_ = sd->view_class = 7;
  5218. else if (sd->status.class_ == 21)
  5219. sd->status.class_ = sd->view_class = 14;
  5220. else if (sd->status.class_ == 4014)
  5221. sd->status.class_ = sd->view_class = 4008;
  5222. else if (sd->status.class_ == 4022)
  5223. sd->status.class_ = sd->view_class = 4015;
  5224. pc_setoption(sd, sd->status.option & ~0x0020);
  5225. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5226. }
  5227. return 0;
  5228. }
  5229. /*==========================================
  5230. *
  5231. *------------------------------------------
  5232. */
  5233. int atcommand_char_mount_peco(
  5234. const int fd, struct map_session_data* sd,
  5235. const char* command, const char* message)
  5236. {
  5237. char character[100];
  5238. struct map_session_data *pl_sd;
  5239. nullpo_retr(-1, sd);
  5240. memset(character, '\0', sizeof(character));
  5241. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5242. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5243. return -1;
  5244. }
  5245. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5246. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5247. clif_displaymessage(fd, msg_table[215]); // This player cannot mount a Peco while in disguise.
  5248. return -1;
  5249. }
  5250. if (!pc_isriding(pl_sd)) { // if actually no peco
  5251. if (pl_sd->status.class_ == 7 || pl_sd->status.class_ == 14 || pl_sd->status.class_ == 4008 || pl_sd->status.class_ == 4015) {
  5252. if (pl_sd->status.class_ == 7)
  5253. pl_sd->status.class_ = pl_sd->view_class = 13;
  5254. else if (pl_sd->status.class_ == 14)
  5255. pl_sd->status.class_ = pl_sd->view_class = 21;
  5256. else if (pl_sd->status.class_ == 4008)
  5257. pl_sd->status.class_ = pl_sd->view_class = 4014;
  5258. else if (pl_sd->status.class_ == 4015)
  5259. pl_sd->status.class_ = pl_sd->view_class = 4022;
  5260. pc_setoption(pl_sd, pl_sd->status.option | 0x0020);
  5261. clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco.
  5262. } else {
  5263. clif_displaymessage(fd, msg_table[217]); // This player can not mount a peco with his/her job.
  5264. return -1;
  5265. }
  5266. } else {
  5267. if (pl_sd->status.class_ == 13)
  5268. pl_sd->status.class_ = pl_sd->view_class = 7;
  5269. else if (pl_sd->status.class_ == 21)
  5270. pl_sd->status.class_ = pl_sd->view_class = 14;
  5271. else if (pl_sd->status.class_ == 4014)
  5272. pl_sd->status.class_ = pl_sd->view_class = 4008;
  5273. else if (pl_sd->status.class_ == 4022)
  5274. pl_sd->status.class_ = pl_sd->view_class = 4015;
  5275. pc_setoption(pl_sd, pl_sd->status.option & ~0x0020);
  5276. clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco.
  5277. }
  5278. } else {
  5279. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5280. return -1;
  5281. }
  5282. return 0;
  5283. }
  5284. /*==========================================
  5285. *Spy Commands by Syrus22
  5286. *------------------------------------------
  5287. */
  5288. int atcommand_guildspy(
  5289. const int fd, struct map_session_data* sd,
  5290. const char* command, const char* message)
  5291. {
  5292. char guild_name[100];
  5293. char output[200];
  5294. struct guild *g;
  5295. nullpo_retr(-1, sd);
  5296. memset(guild_name, '\0', sizeof(guild_name));
  5297. memset(output, '\0', sizeof(output));
  5298. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  5299. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5300. return -1;
  5301. }
  5302. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5303. (g = guild_search(atoi(message))) != NULL) {
  5304. if (sd->guildspy == g->guild_id) {
  5305. sd->guildspy = 0;
  5306. sprintf(output, msg_table[103], g->name); // No longer spying on the %s guild.
  5307. clif_displaymessage(fd, output);
  5308. } else {
  5309. sd->guildspy = g->guild_id;
  5310. sprintf(output, msg_table[104], g->name); // Spying on the %s guild.
  5311. clif_displaymessage(fd, output);
  5312. }
  5313. } else {
  5314. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5315. return -1;
  5316. }
  5317. return 0;
  5318. }
  5319. /*==========================================
  5320. *
  5321. *------------------------------------------
  5322. */
  5323. int atcommand_partyspy(
  5324. const int fd, struct map_session_data* sd,
  5325. const char* command, const char* message)
  5326. {
  5327. char party_name[100];
  5328. char output[200];
  5329. struct party *p;
  5330. nullpo_retr(-1, sd);
  5331. memset(party_name, '\0', sizeof(party_name));
  5332. memset(output, '\0', sizeof(output));
  5333. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  5334. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5335. return -1;
  5336. }
  5337. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5338. (p = party_search(atoi(message))) != NULL) {
  5339. if (sd->partyspy == p->party_id) {
  5340. sd->partyspy = 0;
  5341. sprintf(output, msg_table[105], p->name); // No longer spying on the %s party.
  5342. clif_displaymessage(fd, output);
  5343. } else {
  5344. sd->partyspy = p->party_id;
  5345. sprintf(output, msg_table[106], p->name); // Spying on the %s party.
  5346. clif_displaymessage(fd, output);
  5347. }
  5348. } else {
  5349. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5350. return -1;
  5351. }
  5352. return 0;
  5353. }
  5354. /*==========================================
  5355. * @repairall [Valaris]
  5356. *------------------------------------------
  5357. */
  5358. int atcommand_repairall(
  5359. const int fd, struct map_session_data* sd,
  5360. const char* command, const char* message)
  5361. {
  5362. int count, i;
  5363. nullpo_retr(-1, sd);
  5364. count = 0;
  5365. for (i = 0; i < MAX_INVENTORY; i++) {
  5366. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5367. sd->status.inventory[i].attribute = 0;
  5368. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5369. count++;
  5370. }
  5371. }
  5372. if (count > 0) {
  5373. clif_misceffect(&sd->bl, 3);
  5374. clif_equiplist(sd);
  5375. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5376. } else {
  5377. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5378. return -1;
  5379. }
  5380. return 0;
  5381. }
  5382. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5383. int atcommand_nuke(
  5384. const int fd, struct map_session_data* sd,
  5385. const char* command, const char* message)
  5386. {
  5387. char character[100];
  5388. struct map_session_data *pl_sd;
  5389. nullpo_retr(-1, sd);
  5390. memset(character, '\0', sizeof(character));
  5391. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5392. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5393. return -1;
  5394. }
  5395. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5396. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5397. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5398. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5399. } else {
  5400. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5401. return -1;
  5402. }
  5403. } else {
  5404. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5405. return -1;
  5406. }
  5407. return 0;
  5408. }
  5409. /*==========================================
  5410. *
  5411. *------------------------------------------
  5412. */
  5413. int atcommand_enablenpc(const int fd, struct map_session_data* sd,
  5414. const char* command, const char* message)
  5415. {
  5416. char NPCname[100];
  5417. nullpo_retr(-1, sd);
  5418. memset(NPCname, '\0', sizeof(NPCname));
  5419. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5420. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5421. return -1;
  5422. }
  5423. if (npc_name2id(NPCname) != NULL) {
  5424. npc_enable(NPCname, 1);
  5425. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5426. } else {
  5427. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5428. return -1;
  5429. }
  5430. return 0;
  5431. }
  5432. /*==========================================
  5433. *
  5434. *------------------------------------------
  5435. */
  5436. int atcommand_disablenpc(const int fd, struct map_session_data* sd,
  5437. const char* command, const char* message)
  5438. {
  5439. char NPCname[100];
  5440. nullpo_retr(-1, sd);
  5441. memset(NPCname, '\0', sizeof(NPCname));
  5442. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5443. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5444. return -1;
  5445. }
  5446. if (npc_name2id(NPCname) != NULL) {
  5447. npc_enable(NPCname, 0);
  5448. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5449. } else {
  5450. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5451. return -1;
  5452. }
  5453. return 0;
  5454. }
  5455. /*==========================================
  5456. * time in txt for time command (by [Yor])
  5457. *------------------------------------------
  5458. */
  5459. char * txt_time(unsigned int duration) {
  5460. int days, hours, minutes, seconds;
  5461. char temp[256];
  5462. static char temp1[256];
  5463. memset(temp, '\0', sizeof(temp));
  5464. memset(temp1, '\0', sizeof(temp1));
  5465. if (duration < 0)
  5466. duration = 0;
  5467. days = duration / (60 * 60 * 24);
  5468. duration = duration - (60 * 60 * 24 * days);
  5469. hours = duration / (60 * 60);
  5470. duration = duration - (60 * 60 * hours);
  5471. minutes = duration / 60;
  5472. seconds = duration - (60 * minutes);
  5473. if (days < 2)
  5474. sprintf(temp, msg_table[219], days); // %d day
  5475. else
  5476. sprintf(temp, msg_table[220], days); // %d days
  5477. if (hours < 2)
  5478. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5479. else
  5480. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5481. if (minutes < 2)
  5482. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5483. else
  5484. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5485. if (seconds < 2)
  5486. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5487. else
  5488. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5489. return temp1;
  5490. }
  5491. /*==========================================
  5492. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5493. * Calculation management of GM modification (@day/@night GM commands) is done
  5494. *------------------------------------------
  5495. */
  5496. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5497. const char* command, const char* message)
  5498. {
  5499. struct TimerData * timer_data;
  5500. struct TimerData * timer_data2;
  5501. time_t time_server; // variable for number of seconds (used with time() function)
  5502. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5503. char temp[256];
  5504. nullpo_retr(-1, sd);
  5505. memset(temp, '\0', sizeof(temp));
  5506. time(&time_server); // get time in seconds since 1/1/1970
  5507. datetime = localtime(&time_server); // convert seconds in structure
  5508. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5509. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5510. clif_displaymessage(fd, temp);
  5511. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5512. if (night_flag == 0)
  5513. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5514. else
  5515. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5516. } else if (battle_config.night_duration == 0)
  5517. if (night_flag == 1) { // we start with night
  5518. timer_data = get_timer(day_timer_tid);
  5519. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5520. clif_displaymessage(fd, temp);
  5521. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5522. } else
  5523. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5524. else if (battle_config.day_duration == 0)
  5525. if (night_flag == 0) { // we start with day
  5526. timer_data = get_timer(night_timer_tid);
  5527. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5528. clif_displaymessage(fd, temp);
  5529. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5530. } else
  5531. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5532. else {
  5533. if (night_flag == 0) {
  5534. timer_data = get_timer(night_timer_tid);
  5535. timer_data2 = get_timer(day_timer_tid);
  5536. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5537. clif_displaymessage(fd, temp);
  5538. if (timer_data->tick > timer_data2->tick)
  5539. 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.
  5540. else
  5541. 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.
  5542. clif_displaymessage(fd, temp);
  5543. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5544. clif_displaymessage(fd, temp);
  5545. } else {
  5546. timer_data = get_timer(day_timer_tid);
  5547. timer_data2 = get_timer(night_timer_tid);
  5548. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5549. clif_displaymessage(fd, temp);
  5550. if (timer_data->tick > timer_data2->tick)
  5551. 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.
  5552. else
  5553. 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.
  5554. clif_displaymessage(fd, temp);
  5555. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5556. clif_displaymessage(fd, temp);
  5557. }
  5558. }
  5559. return 0;
  5560. }
  5561. /*==========================================
  5562. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5563. * removes <quantity> item from a character
  5564. * item can be equiped or not.
  5565. * Inspired from a old command created by RoVeRT
  5566. *------------------------------------------
  5567. */
  5568. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5569. const char* command, const char* message)
  5570. {
  5571. struct map_session_data *pl_sd;
  5572. char character[100];
  5573. char item_name[100];
  5574. int i, number = 0, item_id, item_position, count;
  5575. char output[200];
  5576. struct item_data *item_data;
  5577. nullpo_retr(-1, sd);
  5578. memset(character, '\0', sizeof(character));
  5579. memset(item_name, '\0', sizeof(item_name));
  5580. memset(output, '\0', sizeof(output));
  5581. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, character) < 3 || number < 1) {
  5582. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5583. return -1;
  5584. }
  5585. item_id = 0;
  5586. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5587. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5588. item_id = item_data->nameid;
  5589. if (item_id > 500) {
  5590. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5591. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5592. item_position = pc_search_inventory(pl_sd, item_id);
  5593. if (item_position >= 0) {
  5594. count = 0;
  5595. for(i = 0; i < number && item_position >= 0; i++) {
  5596. pc_delitem(pl_sd, item_position, 1, 0);
  5597. count++;
  5598. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5599. }
  5600. sprintf(output, msg_table[113], count); // %d item(s) removed by a GM.
  5601. clif_displaymessage(pl_sd->fd, output);
  5602. if (number == count)
  5603. sprintf(output, msg_table[114], count); // %d item(s) removed from the player.
  5604. else
  5605. sprintf(output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5606. clif_displaymessage(fd, output);
  5607. } else {
  5608. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  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. } else {
  5620. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5621. return -1;
  5622. }
  5623. return 0;
  5624. }
  5625. /*==========================================
  5626. * @jail <char_name> by [Yor]
  5627. * Special warp! No check with nowarp and nowarpto flag
  5628. *------------------------------------------
  5629. */
  5630. int atcommand_jail(
  5631. const int fd, struct map_session_data* sd,
  5632. const char* command, const char* message)
  5633. {
  5634. char character[100];
  5635. struct map_session_data *pl_sd;
  5636. int x, y;
  5637. nullpo_retr(-1, sd);
  5638. memset(character, '\0', sizeof(character));
  5639. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5640. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5641. return -1;
  5642. }
  5643. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5644. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5645. switch(rand() % 2) {
  5646. case 0:
  5647. x = 24;
  5648. y = 75;
  5649. break;
  5650. default:
  5651. x = 49;
  5652. y = 75;
  5653. break;
  5654. }
  5655. if (pc_setpos(pl_sd, "sec_pri.gat", x, y, 3) == 0) {
  5656. pc_setsavepoint(pl_sd, "sec_pri.gat", x, y); // Save Char Respawn Point in the jail room [Lupus]
  5657. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5658. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5659. } else {
  5660. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5661. return -1;
  5662. }
  5663. } else {
  5664. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5665. return -1;
  5666. }
  5667. } else {
  5668. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5669. return -1;
  5670. }
  5671. return 0;
  5672. }
  5673. /*==========================================
  5674. * @unjail/@discharge <char_name> by [Yor]
  5675. * Special warp! No check with nowarp and nowarpto flag
  5676. *------------------------------------------
  5677. */
  5678. int atcommand_unjail(
  5679. const int fd, struct map_session_data* sd,
  5680. const char* command, const char* message)
  5681. {
  5682. char character[100];
  5683. struct map_session_data *pl_sd;
  5684. memset(character, '\0', sizeof(character));
  5685. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5686. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5687. return -1;
  5688. }
  5689. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5690. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5691. if (pl_sd->bl.m != map_mapname2mapid("sec_pri.gat")) {
  5692. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5693. return -1;
  5694. } else if (pc_setpos(pl_sd, "prontera.gat", 156, 191, 3) == 0) {
  5695. pc_setsavepoint(pl_sd, "prontera.gat", 156, 191); // Save char respawn point in Prontera
  5696. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5697. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5698. } else {
  5699. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5700. return -1;
  5701. }
  5702. } else {
  5703. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5704. return -1;
  5705. }
  5706. } else {
  5707. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5708. return -1;
  5709. }
  5710. return 0;
  5711. }
  5712. /*==========================================
  5713. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5714. *------------------------------------------
  5715. */
  5716. int atcommand_disguise(
  5717. const int fd, struct map_session_data* sd,
  5718. const char* command, const char* message)
  5719. {
  5720. int mob_id = 0;
  5721. nullpo_retr(-1, sd);
  5722. if (!message || !*message) {
  5723. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5724. return -1;
  5725. }
  5726. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5727. mob_id = atoi(message);
  5728. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5729. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5730. (mob_id >= 813 && mob_id <= 834) || // NPC
  5731. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5732. if (pc_isriding(sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5733. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5734. return -1;
  5735. }
  5736. sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5737. sd->disguise = mob_id;
  5738. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5739. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5740. } else {
  5741. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5742. return -1;
  5743. }
  5744. return 0;
  5745. }
  5746. /*==========================================
  5747. * DisguiseAll
  5748. *------------------------------------------
  5749. */
  5750. int atcommand_disguiseall(
  5751. const int fd, struct map_session_data* sd,
  5752. const char* command, const char* message)
  5753. {
  5754. int mob_id=0, i=0;
  5755. struct map_session_data *pl_sd;
  5756. nullpo_retr(-1, sd);
  5757. if (!message || !*message) {
  5758. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5759. return -1;
  5760. }
  5761. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5762. mob_id = atoi(message);
  5763. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5764. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5765. (mob_id >= 813 && mob_id <= 834) || // NPC
  5766. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5767. for(i=0; i < fd_max; i++) {
  5768. if(session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  5769. if(pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5770. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5771. } else {
  5772. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5773. pl_sd->disguise = mob_id;
  5774. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5775. }
  5776. }
  5777. }
  5778. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5779. } else {
  5780. return -1;
  5781. }
  5782. return 0;
  5783. }
  5784. /*==========================================
  5785. * @undisguise by [Yor]
  5786. *------------------------------------------
  5787. */
  5788. int atcommand_undisguise(
  5789. const int fd, struct map_session_data* sd,
  5790. const char* command, const char* message)
  5791. {
  5792. nullpo_retr(-1, sd);
  5793. if (sd->disguise) {
  5794. clif_clearchar(&sd->bl, 9);
  5795. sd->disguise = 0;
  5796. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5797. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5798. } else {
  5799. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5800. return -1;
  5801. }
  5802. return 0;
  5803. }
  5804. /*==========================================
  5805. * UndisguiseAll
  5806. *------------------------------------------
  5807. */
  5808. int atcommand_undisguiseall(
  5809. const int fd, struct map_session_data* sd,
  5810. const char* command, const char* message)
  5811. {
  5812. struct map_session_data *pl_sd;
  5813. int i;
  5814. nullpo_retr(-1, sd);
  5815. for(i=0; i < fd_max; i++) {
  5816. if(session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && pl_sd->disguise) {
  5817. clif_clearchar(&pl_sd->bl, 9);
  5818. pl_sd->disguise = 0;
  5819. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5820. }
  5821. }
  5822. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5823. return 0;
  5824. }
  5825. /*==========================================
  5826. * @broadcast by [Valaris]
  5827. *------------------------------------------
  5828. */
  5829. int atcommand_broadcast(
  5830. const int fd, struct map_session_data* sd,
  5831. const char* command, const char* message)
  5832. {
  5833. char output[200];
  5834. nullpo_retr(-1, sd);
  5835. memset(output, '\0', sizeof(output));
  5836. if (!message || !*message) {
  5837. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5838. return -1;
  5839. }
  5840. sprintf(output, "%s : %s", sd->status.name, message);
  5841. intif_GMmessage(output, strlen(output) + 1, 0);
  5842. return 0;
  5843. }
  5844. /*==========================================
  5845. * @localbroadcast by [Valaris]
  5846. *------------------------------------------
  5847. */
  5848. int atcommand_localbroadcast(
  5849. const int fd, struct map_session_data* sd,
  5850. const char* command, const char* message)
  5851. {
  5852. char output[200];
  5853. nullpo_retr(-1, sd);
  5854. memset(output, '\0', sizeof(output));
  5855. if (!message || !*message) {
  5856. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5857. return -1;
  5858. }
  5859. sprintf(output, "%s : %s", sd->status.name, message);
  5860. clif_GMmessage(&sd->bl, output, strlen(output) + 1, 1); // 1: ALL_SAMEMAP
  5861. return 0;
  5862. }
  5863. /*==========================================
  5864. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5865. *------------------------------------------
  5866. */
  5867. int atcommand_chardisguise(
  5868. const int fd, struct map_session_data* sd,
  5869. const char* command, const char* message)
  5870. {
  5871. int mob_id;
  5872. char character[100];
  5873. char mob_name[100];
  5874. struct map_session_data* pl_sd;
  5875. nullpo_retr(-1, sd);
  5876. memset(character, '\0', sizeof(character));
  5877. memset(mob_name, '\0', sizeof(mob_name));
  5878. if (!message || !*message || sscanf(message, "%s %99[^\n]", mob_name, character) < 2) {
  5879. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5880. return -1;
  5881. }
  5882. if ((mob_id = mobdb_searchname(mob_name)) == 0) // check name first (to avoid possible name begining by a number)
  5883. mob_id = atoi(mob_name);
  5884. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5885. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5886. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5887. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5888. (mob_id >= 813 && mob_id <= 834) || // NPC
  5889. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5890. if (pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5891. clif_displaymessage(fd, msg_table[228]); // Character cannot wear disguise while riding a Peco.
  5892. return -1;
  5893. }
  5894. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5895. pl_sd->disguise = mob_id;
  5896. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5897. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5898. } else {
  5899. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5900. return -1;
  5901. }
  5902. } else {
  5903. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5904. return -1;
  5905. }
  5906. } else {
  5907. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5908. return -1;
  5909. }
  5910. return 0;
  5911. }
  5912. /*==========================================
  5913. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5914. *------------------------------------------
  5915. */
  5916. int atcommand_charundisguise(
  5917. const int fd, struct map_session_data* sd,
  5918. const char* command, const char* message)
  5919. {
  5920. char character[100];
  5921. struct map_session_data* pl_sd;
  5922. nullpo_retr(-1, sd);
  5923. memset(character, '\0', sizeof(character));
  5924. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5925. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5926. return -1;
  5927. }
  5928. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5929. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5930. if (pl_sd->disguise) {
  5931. clif_clearchar(&pl_sd->bl, 9);
  5932. pl_sd->disguise = 0;
  5933. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5934. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5935. } else {
  5936. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5937. return -1;
  5938. }
  5939. } else {
  5940. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5941. return -1;
  5942. }
  5943. } else {
  5944. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5945. return -1;
  5946. }
  5947. return 0;
  5948. }
  5949. /*==========================================
  5950. * @email <actual@email> <new@email> by [Yor]
  5951. *------------------------------------------
  5952. */
  5953. int atcommand_email(
  5954. const int fd, struct map_session_data* sd,
  5955. const char* command, const char* message)
  5956. {
  5957. char actual_email[100];
  5958. char new_email[100];
  5959. nullpo_retr(-1, sd);
  5960. memset(actual_email, '\0', sizeof(actual_email));
  5961. memset(new_email, '\0', sizeof(new_email));
  5962. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5963. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5964. return -1;
  5965. }
  5966. if (e_mail_check(actual_email) == 0) {
  5967. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5968. return -1;
  5969. } else if (e_mail_check(new_email) == 0) {
  5970. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5971. return -1;
  5972. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5973. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5974. return -1;
  5975. } else if (strcmpi(actual_email, new_email) == 0) {
  5976. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5977. return -1;
  5978. } else {
  5979. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5980. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5981. }
  5982. return 0;
  5983. }
  5984. /*==========================================
  5985. *@effect
  5986. *------------------------------------------
  5987. */
  5988. int atcommand_effect(
  5989. const int fd, struct map_session_data* sd,
  5990. const char* command, const char* message)
  5991. {
  5992. struct map_session_data *pl_sd;
  5993. int type = 0, flag = 0, i;
  5994. nullpo_retr(-1, sd);
  5995. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5996. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5997. return -1;
  5998. }
  5999. if(flag <=0){
  6000. clif_specialeffect(&sd->bl, type, flag);
  6001. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  6002. }
  6003. else{
  6004. for (i = 0; i < fd_max; i++) {
  6005. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  6006. clif_specialeffect(&pl_sd->bl, type, flag);
  6007. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  6008. }
  6009. }
  6010. }
  6011. return 0;
  6012. }
  6013. /*==========================================
  6014. * @charcartlist <character>: Displays the items list of a player's cart.
  6015. *------------------------------------------
  6016. */
  6017. int
  6018. atcommand_character_cart_list(
  6019. const int fd, struct map_session_data* sd,
  6020. const char* command, const char* message)
  6021. {
  6022. struct map_session_data *pl_sd;
  6023. struct item_data *item_data, *item_temp;
  6024. int i, j, count, counter, counter2;
  6025. char character[100], output[200], outputtmp[200];
  6026. nullpo_retr(-1, sd);
  6027. memset(character, '\0', sizeof(character));
  6028. memset(output, '\0', sizeof(output));
  6029. memset(outputtmp, '\0', sizeof(outputtmp));
  6030. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  6031. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6032. return -1;
  6033. }
  6034. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6035. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6036. counter = 0;
  6037. count = 0;
  6038. for (i = 0; i < MAX_CART; i++) {
  6039. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6040. counter = counter + pl_sd->status.cart[i].amount;
  6041. count++;
  6042. if (count == 1) {
  6043. sprintf(output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6044. clif_displaymessage(fd, output);
  6045. }
  6046. if (pl_sd->status.cart[i].refine)
  6047. 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);
  6048. else
  6049. 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);
  6050. clif_displaymessage(fd, output);
  6051. memset(output, '\0', sizeof(output));
  6052. counter2 = 0;
  6053. for (j = 0; j < item_data->slot; j++) {
  6054. if (pl_sd->status.cart[i].card[j]) {
  6055. if ((item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6056. if (output[0] == '\0')
  6057. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6058. else
  6059. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6060. strcat(output, outputtmp);
  6061. }
  6062. }
  6063. }
  6064. if (output[0] != '\0') {
  6065. output[strlen(output) - 2] = ')';
  6066. output[strlen(output) - 1] = '\0';
  6067. clif_displaymessage(fd, output);
  6068. }
  6069. }
  6070. }
  6071. if (count == 0)
  6072. clif_displaymessage(fd, "No item found in the cart of this player.");
  6073. else {
  6074. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6075. clif_displaymessage(fd, output);
  6076. }
  6077. } else {
  6078. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6079. return -1;
  6080. }
  6081. } else {
  6082. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6083. return -1;
  6084. }
  6085. return 0;
  6086. }
  6087. /*==========================================
  6088. * @killer by MouseJstr
  6089. * enable killing players even when not in pvp
  6090. *------------------------------------------
  6091. */
  6092. int
  6093. atcommand_killer(
  6094. const int fd, struct map_session_data* sd,
  6095. const char* command, const char* message)
  6096. {
  6097. nullpo_retr(-1, sd);
  6098. sd->special_state.killer = !sd->special_state.killer;
  6099. if(sd->special_state.killer)
  6100. clif_displaymessage(fd, msg_table[241]);
  6101. else
  6102. clif_displaymessage(fd, msg_table[242]);
  6103. return 0;
  6104. }
  6105. /*==========================================
  6106. * @killable by MouseJstr
  6107. * enable other people killing you
  6108. *------------------------------------------
  6109. */
  6110. int
  6111. atcommand_killable(
  6112. const int fd, struct map_session_data* sd,
  6113. const char* command, const char* message)
  6114. {
  6115. nullpo_retr(-1, sd);
  6116. sd->special_state.killable = !sd->special_state.killable;
  6117. if(sd->special_state.killable)
  6118. clif_displaymessage(fd, msg_table[242]);
  6119. else
  6120. clif_displaymessage(fd, msg_table[241]);
  6121. return 0;
  6122. }
  6123. /*==========================================
  6124. * @charkillable by MouseJstr
  6125. * enable another player to be killed
  6126. *------------------------------------------
  6127. */
  6128. int
  6129. atcommand_charkillable(
  6130. const int fd, struct map_session_data* sd,
  6131. const char* command, const char* message)
  6132. {
  6133. struct map_session_data *pl_sd = NULL;
  6134. nullpo_retr(-1, sd);
  6135. if (!message || !*message)
  6136. return -1;
  6137. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6138. return -1;
  6139. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6140. if(pl_sd->special_state.killable)
  6141. clif_displaymessage(fd, "The player is now killable");
  6142. else
  6143. clif_displaymessage(fd, "The player is no longer killable");
  6144. return 0;
  6145. }
  6146. /*==========================================
  6147. * @skillon by MouseJstr
  6148. * turn skills on for the map
  6149. *------------------------------------------
  6150. */
  6151. int
  6152. atcommand_skillon(
  6153. const int fd, struct map_session_data* sd,
  6154. const char* command, const char* message)
  6155. {
  6156. nullpo_retr(-1, sd);
  6157. map[sd->bl.m].flag.noskill = 0;
  6158. clif_displaymessage(fd, msg_table[244]);
  6159. return 0;
  6160. }
  6161. /*==========================================
  6162. * @skilloff by MouseJstr
  6163. * Turn skills off on the map
  6164. *------------------------------------------
  6165. */
  6166. int
  6167. atcommand_skilloff(
  6168. const int fd, struct map_session_data* sd,
  6169. const char* command, const char* message)
  6170. {
  6171. nullpo_retr(-1, sd);
  6172. map[sd->bl.m].flag.noskill = 1;
  6173. clif_displaymessage(fd, msg_table[243]);
  6174. return 0;
  6175. }
  6176. /*==========================================
  6177. * @npcmove by MouseJstr
  6178. *
  6179. * move a npc
  6180. *------------------------------------------
  6181. */
  6182. int
  6183. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6184. const char* command, const char* message)
  6185. {
  6186. char character[100];
  6187. int x = 0, y = 0;
  6188. struct npc_data *nd = 0;
  6189. nullpo_retr(-1, sd);
  6190. if (!message || !*message)
  6191. return -1;
  6192. memset(character, '\0', sizeof character);
  6193. if (sscanf(message, "%d %d %99[^\n]", &x, &y, character) < 3) {
  6194. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6195. return -1;
  6196. }
  6197. nullpo_retr(-1, (nd = npc_name2id(character)));
  6198. npc_enable(character, 0);
  6199. nd->bl.x = x;
  6200. nd->bl.y = y;
  6201. npc_enable(character, 1);
  6202. return 0;
  6203. }
  6204. /*==========================================
  6205. * @addwarp by MouseJstr
  6206. *
  6207. * Create a new static warp point.
  6208. *------------------------------------------
  6209. */
  6210. int
  6211. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6212. const char* command, const char* message)
  6213. {
  6214. char w1[64], w3[64], w4[64];
  6215. char map[30], output[200];
  6216. int x,y,ret;
  6217. nullpo_retr(-1, sd);
  6218. if (!message || !*message)
  6219. return -1;
  6220. if (sscanf(message, "%99s %d %d[^\n]", map, &x, &y ) < 3)
  6221. return -1;
  6222. sprintf(w1,"%s,%d,%d", sd->mapname, sd->bl.x, sd->bl.y);
  6223. sprintf(w3,"%s%d%d%d%d", map,sd->bl.x, sd->bl.y, x, y);
  6224. sprintf(w4,"1,1,%s.gat,%d,%d", map, x, y);
  6225. ret = npc_parse_warp(w1, "warp", w3, w4);
  6226. sprintf(output, "New warp NPC => %s",w3);
  6227. clif_displaymessage(fd, output);
  6228. return ret;
  6229. }
  6230. /*==========================================
  6231. * @follow by [MouseJstr]
  6232. *
  6233. * Follow a player .. staying no more then 5 spaces away
  6234. *------------------------------------------
  6235. */
  6236. int
  6237. atcommand_follow(const int fd, struct map_session_data* sd,
  6238. const char* command, const char* message)
  6239. {
  6240. struct map_session_data *pl_sd = NULL;
  6241. nullpo_retr(-1, sd);
  6242. if (!message || !*message)
  6243. return -1;
  6244. if((pl_sd=map_nick2sd((char *) message)) != NULL)
  6245. pc_follow(sd, pl_sd->bl.id);
  6246. else
  6247. return 1;
  6248. return 0;
  6249. }
  6250. /*==========================================
  6251. * @dropall by [MouseJstr]
  6252. *
  6253. * Drop all your possession on the ground
  6254. *------------------------------------------
  6255. */
  6256. int
  6257. atcommand_dropall(const int fd, struct map_session_data* sd,
  6258. const char* command, const char* message)
  6259. {
  6260. int i;
  6261. nullpo_retr(-1, sd);
  6262. for (i = 0; i < MAX_INVENTORY; i++) {
  6263. if (sd->status.inventory[i].amount) {
  6264. if(sd->status.inventory[i].equip != 0)
  6265. pc_unequipitem(sd, i, 3);
  6266. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6267. }
  6268. }
  6269. return 0;
  6270. }
  6271. /*==========================================
  6272. * @chardropall by [MouseJstr]
  6273. *
  6274. * Throw all the characters possessions on the ground. Normally
  6275. * done in response to them being disrespectful of a GM
  6276. *------------------------------------------
  6277. */
  6278. int
  6279. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6280. const char* command, const char* message)
  6281. {
  6282. int i;
  6283. struct map_session_data *pl_sd = NULL;
  6284. nullpo_retr(-1, sd);
  6285. if (!message || !*message)
  6286. return -1;
  6287. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6288. return -1;
  6289. for (i = 0; i < MAX_INVENTORY; i++) {
  6290. if (pl_sd->status.inventory[i].amount) {
  6291. if(pl_sd->status.inventory[i].equip != 0)
  6292. pc_unequipitem(pl_sd, i, 3);
  6293. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6294. }
  6295. }
  6296. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6297. clif_displaymessage(fd, "It is done");
  6298. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6299. return 0;
  6300. }
  6301. /*==========================================
  6302. * @storeall by [MouseJstr]
  6303. *
  6304. * Put everything into storage to simplify your inventory to make
  6305. * debugging easie
  6306. *------------------------------------------
  6307. */
  6308. int
  6309. atcommand_storeall(const int fd, struct map_session_data* sd,
  6310. const char* command, const char* message)
  6311. {
  6312. int i;
  6313. nullpo_retr(-1, sd);
  6314. if (storage_storageopen(sd) == 1) {
  6315. clif_displaymessage(fd, "run this command again..");
  6316. return 0;
  6317. }
  6318. for (i = 0; i < MAX_INVENTORY; i++) {
  6319. if (sd->status.inventory[i].amount) {
  6320. if(sd->status.inventory[i].equip != 0)
  6321. pc_unequipitem(sd, i, 3);
  6322. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6323. }
  6324. }
  6325. storage_storageclose(sd);
  6326. clif_displaymessage(fd, "It is done");
  6327. return 0;
  6328. }
  6329. /*==========================================
  6330. * @charstoreall by [MouseJstr]
  6331. *
  6332. * A way to screw with players who piss you off
  6333. *------------------------------------------
  6334. */
  6335. int
  6336. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6337. const char* command, const char* message)
  6338. {
  6339. int i;
  6340. struct map_session_data *pl_sd = NULL;
  6341. nullpo_retr(-1, sd);
  6342. if (!message || !*message)
  6343. return -1;
  6344. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6345. return -1;
  6346. if (storage_storageopen(pl_sd) == 1) {
  6347. clif_displaymessage(fd, "Had to open the characters storage window...");
  6348. clif_displaymessage(fd, "run this command again..");
  6349. return 0;
  6350. }
  6351. for (i = 0; i < MAX_INVENTORY; i++) {
  6352. if (pl_sd->status.inventory[i].amount) {
  6353. if(pl_sd->status.inventory[i].equip != 0)
  6354. pc_unequipitem(pl_sd, i, 3);
  6355. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6356. }
  6357. }
  6358. storage_storageclose(pl_sd);
  6359. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6360. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6361. clif_displaymessage(pl_sd->fd, " -- the management");
  6362. clif_displaymessage(fd, "It is done");
  6363. return 0;
  6364. }
  6365. /*==========================================
  6366. * @skillid by [MouseJstr]
  6367. *
  6368. * lookup a skill by name
  6369. *------------------------------------------
  6370. */
  6371. int
  6372. atcommand_skillid(const int fd, struct map_session_data* sd,
  6373. const char* command, const char* message)
  6374. {
  6375. int skillen = 0, idx = 0;
  6376. nullpo_retr(-1, sd);
  6377. if (!message || !*message)
  6378. return -1;
  6379. skillen = strlen(message);
  6380. while (skill_names[idx].id != 0) {
  6381. if ((strnicmp(skill_names[idx].name, message, skillen) == 0) ||
  6382. (strnicmp(skill_names[idx].desc, message, skillen) == 0)) {
  6383. char output[255];
  6384. sprintf(output, "skill %d: %s", skill_names[idx].id, skill_names[idx].desc);
  6385. clif_displaymessage(fd, output);
  6386. }
  6387. idx++;
  6388. }
  6389. return 0;
  6390. }
  6391. /*==========================================
  6392. * @useskill by [MouseJstr]
  6393. *
  6394. * A way of using skills without having to find them in the skills menu
  6395. *------------------------------------------
  6396. */
  6397. int
  6398. atcommand_useskill(const int fd, struct map_session_data* sd,
  6399. const char* command, const char* message)
  6400. {
  6401. struct map_session_data *pl_sd = NULL;
  6402. int skillnum;
  6403. int skilllv;
  6404. int inf;
  6405. char target[255];
  6406. nullpo_retr(-1, sd);
  6407. if (!message || !*message)
  6408. return -1;
  6409. if(sscanf(message, "%d %d %s", &skillnum, &skilllv, target) != 3) {
  6410. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6411. return -1;
  6412. }
  6413. if((pl_sd=map_nick2sd(target)) == NULL) {
  6414. return -1;
  6415. }
  6416. inf = skill_get_inf(skillnum);
  6417. if ((inf == 2) || (inf == 1))
  6418. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6419. else
  6420. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6421. return 0;
  6422. }
  6423. /*==========================================
  6424. * @skilltree by [MouseJstr]
  6425. *
  6426. * prints the skill tree for a player required to get to a skill
  6427. *------------------------------------------
  6428. */
  6429. int
  6430. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6431. const char* command, const char* message)
  6432. {
  6433. struct map_session_data *pl_sd = NULL;
  6434. int skillnum, skillidx = -1;
  6435. int meets = 1, j, c=0, s=0;
  6436. struct pc_base_job s_class;
  6437. char target[255], *tbl;
  6438. char output[255];
  6439. struct skill_tree_entry *ent;
  6440. nullpo_retr(-1, sd);
  6441. if (!message || !*message)
  6442. return -1;
  6443. if(sscanf(message, "%d %[^\r\n]", &skillnum, target) != 2) {
  6444. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6445. return -1;
  6446. }
  6447. if((pl_sd=map_nick2sd(target)) == NULL)
  6448. return -1;
  6449. s_class = pc_calc_base_job(pl_sd->status.class_);
  6450. c = s_class.job;
  6451. s = s_class.upper;
  6452. c = pc_calc_skilltree_normalize_job(c, pl_sd);
  6453. tbl = job_name(c);
  6454. sprintf(output, "Player is using %s %s skill tree (%d basic points)",
  6455. s_class.upper ? "upper" : "lower",
  6456. tbl, pc_checkskill(pl_sd, 1));
  6457. clif_displaymessage(fd, output);
  6458. for (j = 0; skill_tree[s][c][j].id != 0; j++) {
  6459. if (skill_tree[s][c][j].id == skillnum) {
  6460. skillidx = j;
  6461. break;
  6462. }
  6463. }
  6464. if (skillidx == -1) {
  6465. sprintf(output, "I do not believe the player can use that skill");
  6466. clif_displaymessage(fd, output);
  6467. return 0;
  6468. }
  6469. ent = &skill_tree[s][c][skillidx];
  6470. for(j=0;j<5;j++)
  6471. if( ent->need[j].id &&
  6472. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6473. {
  6474. int idx = 0;
  6475. char *desc;
  6476. while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id)
  6477. idx++;
  6478. if (skill_names[idx].id == 0)
  6479. desc = "Unknown skill";
  6480. else
  6481. desc = skill_names[idx].desc;
  6482. sprintf(output, "player requires level %d of skill %s",
  6483. ent->need[j].lv, desc);
  6484. clif_displaymessage(fd, output);
  6485. meets = 0;
  6486. }
  6487. if (meets == 1) {
  6488. sprintf(output, "I believe the player meets all the requirements for that skill");
  6489. clif_displaymessage(fd, output);
  6490. }
  6491. return 0;
  6492. }
  6493. /*==========================================
  6494. * @marry by [MouseJstr]
  6495. *
  6496. * Marry two players
  6497. *------------------------------------------
  6498. */
  6499. int
  6500. atcommand_marry(const int fd, struct map_session_data* sd,
  6501. const char* command, const char* message)
  6502. {
  6503. struct map_session_data *pl_sd1 = NULL;
  6504. struct map_session_data *pl_sd2 = NULL;
  6505. char player1[255], player2[255];
  6506. nullpo_retr(-1, sd);
  6507. if (!message || !*message)
  6508. return -1;
  6509. if (sscanf(message, "%[^,],%[^\r\n]", player1, player2) != 2) {
  6510. clif_displaymessage(fd, "usage: @marry <player1> <player2>.");
  6511. return -1;
  6512. }
  6513. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6514. sprintf(player2, "Cannot find player %s online", player1);
  6515. clif_displaymessage(fd, player2);
  6516. return -1;
  6517. }
  6518. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6519. sprintf(player1, "Cannot find player %s online", player2);
  6520. clif_displaymessage(fd, player1);
  6521. return -1;
  6522. }
  6523. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6524. clif_displaymessage(fd, "They are married.. wish them well");
  6525. return 0;
  6526. } else
  6527. return -1;
  6528. }
  6529. /*==========================================
  6530. * @divorce by [MouseJstr]
  6531. *
  6532. * divorce two players
  6533. *------------------------------------------
  6534. */
  6535. int
  6536. atcommand_divorce(const int fd, struct map_session_data* sd,
  6537. const char* command, const char* message)
  6538. {
  6539. struct map_session_data *pl_sd = NULL;
  6540. nullpo_retr(-1, sd);
  6541. if (!message || !*message)
  6542. return -1;
  6543. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6544. return pc_divorce(pl_sd);
  6545. clif_displaymessage(fd, "They are now divorced.");
  6546. } else
  6547. clif_displaymessage(fd, "The divorce has failed.. talk to the judge..");
  6548. return 0;
  6549. }
  6550. /*==========================================
  6551. * @rings by [MouseJstr]
  6552. *
  6553. * Give two players rings
  6554. *------------------------------------------
  6555. */
  6556. int
  6557. atcommand_rings(const int fd, struct map_session_data* sd,
  6558. const char* command, const char* message)
  6559. {
  6560. struct item item_tmp;
  6561. int flag;
  6562. memset(&item_tmp, 0, sizeof(item_tmp));
  6563. item_tmp.nameid = 2634;
  6564. item_tmp.identify = 1;
  6565. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6566. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6567. item_tmp.nameid = 2635;
  6568. item_tmp.identify = 1;
  6569. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6570. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6571. clif_displaymessage(fd, "You have rings! Give them to the lovers.");
  6572. return 0;
  6573. }
  6574. #ifdef DMALLOC
  6575. unsigned long dmark_;
  6576. int
  6577. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6578. const char* command, const char* message)
  6579. {
  6580. dmark_ = dmalloc_mark();
  6581. clif_displaymessage(fd, "debug mark set");
  6582. return 0;
  6583. }
  6584. int
  6585. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6586. const char* command, const char* message)
  6587. {
  6588. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6589. dmark_ = dmalloc_mark();
  6590. clif_displaymessage(fd, "malloc changes logged");
  6591. return 0;
  6592. }
  6593. #endif
  6594. /*==========================================
  6595. * @grind by [MouseJstr]
  6596. *------------------------------------------
  6597. */
  6598. int
  6599. atcommand_grind(const int fd, struct map_session_data* sd,
  6600. const char* command, const char* message)
  6601. {
  6602. struct map_session_data *pl_sd = NULL;
  6603. int skillnum;
  6604. int inf;
  6605. char target[255];
  6606. nullpo_retr(-1, sd);
  6607. if (!message || !*message)
  6608. return -1;
  6609. if(sscanf(message, "%s", target) != 1) {
  6610. clif_displaymessage(fd, "Usage: @grind <target>");
  6611. return -1;
  6612. }
  6613. if((pl_sd=map_nick2sd(target)) == NULL)
  6614. return -1;
  6615. for (skillnum = 1; skillnum < 500; skillnum++) {
  6616. sd->status.sp = sd->status.max_sp;
  6617. atcommand_alive(fd, sd, command, message);
  6618. inf = skill_get_inf(skillnum);
  6619. if ((inf == 2) || (inf == 1))
  6620. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6621. else
  6622. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6623. }
  6624. return 0;
  6625. }
  6626. /*==========================================
  6627. * @grind2 by [MouseJstr]
  6628. *------------------------------------------
  6629. */
  6630. int
  6631. atcommand_grind2(const int fd, struct map_session_data* sd,
  6632. const char* command, const char* message)
  6633. {
  6634. int i, x, y, id;
  6635. for (i = 1000; i <2000; i++) {
  6636. x = sd->bl.x + (rand() % 10 - 5);
  6637. y = sd->bl.y + (rand() % 10 - 5);
  6638. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6639. }
  6640. return 0;
  6641. }
  6642. /*==========================================
  6643. * It is made to rain.
  6644. *------------------------------------------
  6645. */
  6646. int
  6647. atcommand_rain(
  6648. const int fd, struct map_session_data* sd,
  6649. const char* command, const char* message)
  6650. {
  6651. int effno = 0;
  6652. nullpo_retr(-1, sd);
  6653. effno = 161;
  6654. if (map[sd->bl.m].flag.rain) {
  6655. map[sd->bl.m].flag.rain=0;
  6656. clif_displaymessage(fd, "The rain has stopped.");
  6657. } else {
  6658. map[sd->bl.m].flag.rain=1;
  6659. clif_specialeffect(&sd->bl,effno,2);
  6660. clif_displaymessage(fd, "It is made to rain.");
  6661. }
  6662. return 0;
  6663. }
  6664. /*==========================================
  6665. * It is made to snow.
  6666. *------------------------------------------
  6667. */
  6668. int
  6669. atcommand_snow(
  6670. const int fd, struct map_session_data* sd,
  6671. const char* command, const char* message)
  6672. {
  6673. int effno = 0;
  6674. effno = 162;
  6675. nullpo_retr(-1, sd);
  6676. if (map[sd->bl.m].flag.snow) {
  6677. map[sd->bl.m].flag.snow=0;
  6678. clif_displaymessage(fd, "Snow has stopped falling.");
  6679. } else {
  6680. map[sd->bl.m].flag.snow=1;
  6681. clif_specialeffect(&sd->bl,effno,2);
  6682. clif_displaymessage(fd, "It is made to snow.");
  6683. }
  6684. return 0;
  6685. }
  6686. /*==========================================
  6687. * Cherry tree snowstorm is made to fall. (Sakura)
  6688. *------------------------------------------
  6689. */
  6690. int
  6691. atcommand_sakura(
  6692. const int fd, struct map_session_data* sd,
  6693. const char* command, const char* message)
  6694. {
  6695. int effno = 0;
  6696. effno = 163;
  6697. nullpo_retr(-1, sd);
  6698. if (map[sd->bl.m].flag.sakura) {
  6699. map[sd->bl.m].flag.sakura=0;
  6700. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6701. } else {
  6702. map[sd->bl.m].flag.sakura=1;
  6703. clif_specialeffect(&sd->bl,effno,2);
  6704. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6705. }
  6706. return 0;
  6707. }
  6708. /*==========================================
  6709. * Fog hangs over.
  6710. *------------------------------------------
  6711. */
  6712. int
  6713. atcommand_fog(
  6714. const int fd, struct map_session_data* sd,
  6715. const char* command, const char* message)
  6716. {
  6717. int effno = 0;
  6718. effno = 233;
  6719. nullpo_retr(-1, sd);
  6720. if (map[sd->bl.m].flag.fog) {
  6721. map[sd->bl.m].flag.fog=0;
  6722. clif_displaymessage(fd, "The fog has gone.");
  6723. } else {
  6724. map[sd->bl.m].flag.fog=1;
  6725. clif_specialeffect(&sd->bl,effno,2);
  6726. clif_displaymessage(fd, "Fog hangs over.");
  6727. }
  6728. return 0;
  6729. }
  6730. /*==========================================
  6731. * Fallen leaves fall.
  6732. *------------------------------------------
  6733. */
  6734. int
  6735. atcommand_leaves(
  6736. const int fd, struct map_session_data* sd,
  6737. const char* command, const char* message)
  6738. {
  6739. int effno = 0;
  6740. effno = 333;
  6741. nullpo_retr(-1, sd);
  6742. if (map[sd->bl.m].flag.leaves) {
  6743. map[sd->bl.m].flag.leaves=0;
  6744. clif_displaymessage(fd, "Leaves no longer fall.");
  6745. } else {
  6746. map[sd->bl.m].flag.leaves=1;
  6747. clif_specialeffect(&sd->bl,effno,2);
  6748. clif_displaymessage(fd, "Fallen leaves fall.");
  6749. }
  6750. return 0;
  6751. }
  6752. /*==========================================
  6753. * Clearing Weather Effects by Dexity
  6754. *------------------------------------------
  6755. */
  6756. int
  6757. atcommand_clearweather(
  6758. const int fd, struct map_session_data* sd,
  6759. const char* command, const char* message)
  6760. {
  6761. //int effno = 0;
  6762. nullpo_retr(-1, sd);
  6763. map[sd->bl.m].flag.rain=0;
  6764. map[sd->bl.m].flag.snow=0;
  6765. map[sd->bl.m].flag.sakura=0;
  6766. map[sd->bl.m].flag.fog=0;
  6767. map[sd->bl.m].flag.leaves=0;
  6768. //clif_specialeffect(&sd->bl,effno,2); // not required. [celest]
  6769. return 0;
  6770. }
  6771. /*===============================================================
  6772. * Sound Command - plays a sound for everyone! [Codemaster]
  6773. *---------------------------------------------------------------
  6774. */
  6775. int
  6776. atcommand_sound(
  6777. const int fd, struct map_session_data *sd,
  6778. const char *command, const char *message)
  6779. {
  6780. char sound_file[100];
  6781. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6782. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6783. return -1;
  6784. }
  6785. memset(sound_file, '\0', sizeof(sound_file));
  6786. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6787. return -1;
  6788. if(strstr(sound_file, ".wav") == NULL)
  6789. strcat(sound_file, ".wav");
  6790. clif_soundeffectall(&sd->bl, sound_file,0);
  6791. return 0;
  6792. }
  6793. /*==========================================
  6794. * MOB Search
  6795. *------------------------------------------
  6796. */
  6797. int
  6798. atcommand_mobsearch(
  6799. const int fd, struct map_session_data* sd,
  6800. const char* command, const char* message)
  6801. {
  6802. char mob_name[100];
  6803. char output[100];
  6804. int mob_id,map_id = 0;
  6805. nullpo_retr(-1, sd);
  6806. if (sscanf(message, "%99s", mob_name) < 0)
  6807. return -1;
  6808. if ((mob_id = atoi(mob_name)) == 0)
  6809. mob_id = mobdb_searchname(mob_name);
  6810. if(mob_id !=-1 && (mob_id <= 1000 || mob_id >= 2000)){
  6811. snprintf(output, sizeof output, "Invalid mob id %s!",mob_name);
  6812. clif_displaymessage(fd, output);
  6813. return 0;
  6814. }
  6815. if(mob_id == atoi(mob_name) && mob_db[mob_id].jname)
  6816. strcpy(mob_name,mob_db[mob_id].jname); // --ja--
  6817. // strcpy(mob_name,mob_db[mob_id].name); // --en--
  6818. map_id = sd->bl.m;
  6819. snprintf(output, sizeof output, "Mob Search... %s %s",
  6820. mob_name, sd->mapname);
  6821. clif_displaymessage(fd, output);
  6822. map_foreachinarea(atmobsearch_sub, map_id, 0, 0,
  6823. map[map_id].xs, map[map_id].ys, BL_MOB, mob_id, fd);
  6824. atmobsearch_sub(&sd->bl,0); // 番号リセット
  6825. return 0;
  6826. }
  6827. /*==========================================
  6828. * ドロップアイテムの掃除
  6829. *------------------------------------------
  6830. */
  6831. int
  6832. atcommand_cleanmap(
  6833. const int fd, struct map_session_data* sd,
  6834. const char* command, const char* message)
  6835. {
  6836. int i=0;
  6837. map_foreachinarea(atcommand_cleanmap_sub,sd->bl.m,
  6838. sd->bl.x-AREA_SIZE*2,sd->bl.y-AREA_SIZE*2,
  6839. sd->bl.x+AREA_SIZE*2,sd->bl.y+AREA_SIZE*2,
  6840. BL_ITEM,sd,&i);
  6841. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  6842. return 0;
  6843. }
  6844. /*==========================================
  6845. *
  6846. *------------------------------------------
  6847. */
  6848. int
  6849. atcommand_summon(
  6850. const int fd, struct map_session_data* sd,
  6851. const char* command, const char* message)
  6852. {
  6853. char name[100];
  6854. int mob_id = 0;
  6855. int x = 0;
  6856. int y = 0;
  6857. int id = 0;
  6858. struct mob_data *md;
  6859. unsigned int tick=gettick();
  6860. nullpo_retr(-1, sd);
  6861. if (!message || !*message)
  6862. return -1;
  6863. if (sscanf(message, "%99s", name) < 1)
  6864. return -1;
  6865. if ((mob_id = atoi(name)) == 0)
  6866. mob_id = mobdb_searchname(name);
  6867. if(mob_id == 0)
  6868. return -1;
  6869. x = sd->bl.x + (rand() % 10 - 5);
  6870. y = sd->bl.y + (rand() % 10 - 5);
  6871. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  6872. if((md=(struct mob_data *)map_id2bl(id))){
  6873. md->master_id=sd->bl.id;
  6874. md->state.special_mob_ai=1;
  6875. md->mode=mob_db[md->class_].mode|0x04;
  6876. md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0);
  6877. clif_misceffect2(&md->bl,344);
  6878. }
  6879. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  6880. return 0;
  6881. }
  6882. /*==========================================
  6883. * @adjcmdlvl by [MouseJstr]
  6884. *
  6885. * Temp adjust the GM level required to use a GM command
  6886. *
  6887. * Used during beta testing to allow players to use GM commands
  6888. * for short periods of time
  6889. *------------------------------------------
  6890. */
  6891. int
  6892. atcommand_adjcmdlvl(
  6893. const int fd, struct map_session_data* sd,
  6894. const char* command, const char* message)
  6895. {
  6896. int i, newlev;
  6897. char cmd[100];
  6898. nullpo_retr(-1, sd);
  6899. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  6900. clif_displaymessage(fd, "usage: @adjcmdlvl <lvl> <command>.");
  6901. return -1;
  6902. }
  6903. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  6904. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  6905. atcommand_info[i].level = newlev;
  6906. clif_displaymessage(fd, "@command level changed.");
  6907. return 0;
  6908. }
  6909. clif_displaymessage(fd, "@command not found.");
  6910. return -1;
  6911. }
  6912. /*==========================================
  6913. * @adjgmlvl by [MouseJstr]
  6914. *
  6915. * Create a temp GM
  6916. *
  6917. * Used during beta testing to allow players to use GM commands
  6918. * for short periods of time
  6919. *------------------------------------------
  6920. */
  6921. int
  6922. atcommand_adjgmlvl(
  6923. const int fd, struct map_session_data* sd,
  6924. const char* command, const char* message)
  6925. {
  6926. int newlev;
  6927. char user[100];
  6928. struct map_session_data *pl_sd;
  6929. nullpo_retr(-1, sd);
  6930. if (!message || !*message || sscanf(message, "%d %[^\r\n]", &newlev, user) != 2) {
  6931. clif_displaymessage(fd, "usage: @adjgmlvl <lvl> <user>.");
  6932. return -1;
  6933. }
  6934. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  6935. return -1;
  6936. pc_set_gm_level(pl_sd->status.account_id, newlev);
  6937. return 0;
  6938. }
  6939. /*==========================================
  6940. * @trade by [MouseJstr]
  6941. *
  6942. * Open a trade window with a remote player
  6943. *
  6944. * If I have to jump to a remote player one more time, I am
  6945. * gonna scream!
  6946. *------------------------------------------
  6947. */
  6948. int
  6949. atcommand_trade(
  6950. const int fd, struct map_session_data* sd,
  6951. const char* command, const char* message)
  6952. {
  6953. struct map_session_data *pl_sd = NULL;
  6954. nullpo_retr(-1, sd);
  6955. if (!message || !*message)
  6956. return -1;
  6957. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6958. trade_traderequest(sd, pl_sd->bl.id);
  6959. return 0;
  6960. }
  6961. return -1;
  6962. }
  6963. /*==========================================
  6964. * @setbattleflag by [MouseJstr]
  6965. *
  6966. * set a battle_config flag without having to reboot
  6967. */
  6968. int
  6969. atcommand_setbattleflag(
  6970. const int fd, struct map_session_data* sd,
  6971. const char* command, const char* message)
  6972. {
  6973. char flag[128], value[128];
  6974. nullpo_retr(-1, sd);
  6975. if (!message || !*message || sscanf(message, "%s %s", flag, value) != 2) {
  6976. clif_displaymessage(fd, "usage: @setbattleflag <flag> <value>.");
  6977. return -1;
  6978. }
  6979. if (battle_set_value(flag, value) == 0)
  6980. clif_displaymessage(fd, "unknown battle_config flag");
  6981. else
  6982. clif_displaymessage(fd, "battle_config set as requested");
  6983. return 0;
  6984. }
  6985. /*===========================
  6986. * @unmute [Valaris]
  6987. *===========================
  6988. */
  6989. int atcommand_unmute(
  6990. const int fd, struct map_session_data* sd,
  6991. const char* command, const char* message)
  6992. {
  6993. struct map_session_data *pl_sd = NULL;
  6994. nullpo_retr(-1, sd);
  6995. if (!message || !*message)
  6996. return -1;
  6997. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6998. if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) {
  6999. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7000. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7001. clif_displaymessage(sd->fd,"Player unmuted");
  7002. }
  7003. else
  7004. clif_displaymessage(sd->fd,"Player is not muted");
  7005. }
  7006. return 0;
  7007. }
  7008. /*==========================================
  7009. * @uptime by MC Cameri
  7010. *------------------------------------------
  7011. */
  7012. int
  7013. atcommand_uptime(
  7014. const int fd, struct map_session_data* sd,
  7015. const char* command, const char* message)
  7016. {
  7017. char output[200];
  7018. long seconds = 0, day = 24*60*60, hour = 60*60,
  7019. minute = 60, days = 0, hours = 0, minutes = 0;
  7020. nullpo_retr(-1, sd);
  7021. seconds = (gettick()-ticks)/CLOCKS_PER_SEC;
  7022. days = seconds/day;
  7023. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7024. hours = seconds/hour;
  7025. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7026. minutes = seconds/minute;
  7027. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7028. snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds);
  7029. clif_displaymessage(fd,output);
  7030. return 0;
  7031. }
  7032. /*==========================================
  7033. * @changesex <sex>
  7034. * => Changes one's sex. Argument sex can be
  7035. * 0 or 1, m or f, male or female.
  7036. *------------------------------------------
  7037. */
  7038. int
  7039. atcommand_changesex(
  7040. const int fd, struct map_session_data* sd,
  7041. const char* command, const char* message)
  7042. {
  7043. nullpo_retr(-1, sd);
  7044. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7045. return 0;
  7046. }
  7047. /*================================================
  7048. * @mute - Mutes a player for a set amount of time
  7049. *------------------------------------------------
  7050. */
  7051. int atcommand_mute(
  7052. const int fd, struct map_session_data* sd,
  7053. const char* command, const char* message)
  7054. {
  7055. struct map_session_data *pl_sd = NULL;
  7056. char character[100];
  7057. int manner;
  7058. nullpo_retr(-1, sd);
  7059. if (!message || !*message || sscanf(message, "%d %99[^\n]", &manner, character) < 1) {
  7060. clif_displaymessage(fd, "usage: @mute <time> <character name>.");
  7061. return -1;
  7062. }
  7063. if ((pl_sd = map_nick2sd(character)) != NULL) {
  7064. pl_sd->status.manner -= manner;
  7065. if(pl_sd->status.manner < 0)
  7066. status_change_start(&pl_sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  7067. }
  7068. else {
  7069. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7070. return -1;
  7071. }
  7072. return 0;
  7073. }
  7074. /*==========================================
  7075. * @refresh (like @jumpto <<yourself>>)
  7076. *------------------------------------------
  7077. */
  7078. int atcommand_refresh(
  7079. const int fd, struct map_session_data* sd,
  7080. const char* command, const char* message)
  7081. {
  7082. nullpo_retr(-1, sd);
  7083. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  7084. return 0;
  7085. }
  7086. /*==========================================
  7087. * @petid <part of pet name>
  7088. * => Displays a list of matching pets.
  7089. *------------------------------------------
  7090. */
  7091. int
  7092. atcommand_petid(const int fd, struct map_session_data* sd,
  7093. const char* command, const char* message)
  7094. {
  7095. char searchtext[100];
  7096. char temp0[100];
  7097. char temp1[100];
  7098. int cnt = 0, i = 0;
  7099. nullpo_retr(-1, sd);
  7100. if (!message || !*message)
  7101. return -1;
  7102. if (sscanf(message, "%99s", searchtext) < 1)
  7103. return -1;
  7104. estr_lower(searchtext);
  7105. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7106. clif_displaymessage(fd,temp0);
  7107. while (i < MAX_PET_DB) {
  7108. strcpy(temp1,pet_db[i].name);
  7109. strcpy(temp1, estr_lower(temp1));
  7110. strcpy(temp0,pet_db[i].jname);
  7111. strcpy(temp0, estr_lower(temp1));
  7112. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7113. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7114. pet_db[i].jname);
  7115. if (cnt >= 100) { // Only if there are custom pets
  7116. clif_displaymessage(fd, "Be more specific, can't send more than"
  7117. " 100 results.");
  7118. } else {
  7119. clif_displaymessage(fd, temp0);
  7120. }
  7121. cnt++;
  7122. }
  7123. i++;
  7124. }
  7125. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7126. clif_displaymessage(fd, temp0);
  7127. return 0;
  7128. }
  7129. /*==========================================
  7130. * @identify
  7131. * => GM's magnifier.
  7132. *------------------------------------------
  7133. */
  7134. int
  7135. atcommand_identify(
  7136. const int fd, struct map_session_data* sd,
  7137. const char* command, const char* message)
  7138. {
  7139. int i,num;
  7140. nullpo_retr(-1, sd);
  7141. for(i=num=0;i<MAX_INVENTORY;i++){
  7142. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7143. num++;
  7144. }
  7145. }
  7146. if (num > 0) {
  7147. clif_item_identify_list(sd);
  7148. } else {
  7149. clif_displaymessage(fd,"There are no items to appraise.");
  7150. }
  7151. return 0;
  7152. }
  7153. /*==========================================
  7154. * @gmotd (Global MOTD)
  7155. * by davidsiaw :P
  7156. *------------------------------------------
  7157. */
  7158. int
  7159. atcommand_gmotd(
  7160. const int fd, struct map_session_data* sd,
  7161. const char* command, const char* message)
  7162. {
  7163. char buf[256];
  7164. FILE *fp;
  7165. nullpo_retr(-1, sd);
  7166. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7167. while (fgets(buf, 250, fp) != NULL){
  7168. int i;
  7169. for( i=0; buf[i]; i++){
  7170. if( buf[i]=='\r' || buf[i]=='\n'){
  7171. buf[i]=0;
  7172. break;
  7173. }
  7174. }
  7175. intif_GMmessage(buf,strlen(buf)+1,8);
  7176. }
  7177. fclose(fp);
  7178. }
  7179. return 0;
  7180. }
  7181. int atcommand_misceffect(
  7182. const int fd, struct map_session_data* sd,
  7183. const char* command, const char* message)
  7184. {
  7185. int effect = 0;
  7186. nullpo_retr(-1, sd);
  7187. if (!message || !*message)
  7188. return -1;
  7189. if (sscanf(message, "%d", &effect) < 1)
  7190. return -1;
  7191. clif_misceffect(&sd->bl,effect);
  7192. return 0;
  7193. }
  7194. int charid2sessionid(int charid)
  7195. {
  7196. int i;
  7197. int session_id=0;
  7198. struct map_session_data *pl_sd = NULL;
  7199. for(i=0;i<fd_max;i++){
  7200. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  7201. if (pl_sd->status.char_id==charid) { session_id = i; break; }
  7202. }
  7203. }
  7204. return session_id;
  7205. }
  7206. int accountid2sessionid(int accountid)
  7207. {
  7208. int i;
  7209. int session_id=0;
  7210. struct map_session_data *pl_sd = NULL;
  7211. for(i=0;i<fd_max;i++){
  7212. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  7213. if (pl_sd->status.account_id==accountid) { session_id = i; break; }
  7214. }
  7215. }
  7216. return session_id;
  7217. }
  7218. /*==========================================
  7219. * Jump to a player by PID number
  7220. * Original by Dino9021
  7221. * Added in by nsstrunks
  7222. *------------------------------------------
  7223. */
  7224. int atcommand_jumptoid(
  7225. const int fd, struct map_session_data* sd,
  7226. const char* command, const char* message)
  7227. {
  7228. char character[100];
  7229. char output[200];
  7230. int cid=0;
  7231. int session_id=0;
  7232. struct map_session_data *pl_sd;
  7233. memset(character, '\0', sizeof(character));
  7234. memset(output, '\0', sizeof(output));
  7235. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7236. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7237. return -1;
  7238. }
  7239. cid=atoi(message);
  7240. if ((session_id=charid2sessionid(cid))!=0)
  7241. {
  7242. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7243. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7244. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7245. return -1;
  7246. }
  7247. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7248. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7249. return -1;
  7250. }
  7251. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7252. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7253. clif_displaymessage(fd, output);
  7254. } else {
  7255. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7256. return -1;
  7257. }
  7258. }
  7259. else
  7260. {
  7261. clif_displaymessage(fd,msg_table[3]);
  7262. }
  7263. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7264. return 0;
  7265. }
  7266. /*==========================================
  7267. * Jump to a player by PID number
  7268. * Original by Dino9021
  7269. * Added in by nsstrunks
  7270. *------------------------------------------
  7271. */
  7272. int atcommand_jumptoid2(
  7273. const int fd, struct map_session_data* sd,
  7274. const char* command, const char* message)
  7275. {
  7276. char character[100];
  7277. char output[200];
  7278. int aid=0;
  7279. int session_id=0;
  7280. struct map_session_data *pl_sd;
  7281. memset(character, '\0', sizeof(character));
  7282. memset(output, '\0', sizeof(output));
  7283. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7284. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7285. return -1;
  7286. }
  7287. aid=atoi(message);
  7288. if ((session_id=accountid2sessionid(aid))!=0)
  7289. {
  7290. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7291. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7292. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7293. return -1;
  7294. }
  7295. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7296. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7297. return -1;
  7298. }
  7299. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7300. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7301. clif_displaymessage(fd, output);
  7302. } else {
  7303. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7304. return -1;
  7305. }
  7306. }
  7307. else
  7308. {
  7309. clif_displaymessage(fd,msg_table[3]);
  7310. }
  7311. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7312. return 0;
  7313. }
  7314. /*==========================================
  7315. * Recall a player by PID number
  7316. * Original by Dino9021
  7317. * Added in by nsstrunks
  7318. *------------------------------------------
  7319. */
  7320. int atcommand_recallid(
  7321. const int fd, struct map_session_data* sd,
  7322. const char* command, const char* message)
  7323. {
  7324. char character[100];
  7325. char output[200];
  7326. int cid=0;
  7327. int session_id=0;
  7328. struct map_session_data *pl_sd;
  7329. memset(character, '\0', sizeof(character));
  7330. memset(output, '\0', sizeof(output));
  7331. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7332. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7333. return -1;
  7334. }
  7335. cid=atoi(message);
  7336. if ((session_id=charid2sessionid(cid))!=0)
  7337. {
  7338. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7339. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7340. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7341. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7342. return -1;
  7343. }
  7344. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7345. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7346. return -1;
  7347. }
  7348. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7349. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7350. clif_displaymessage(fd, output);
  7351. } else {
  7352. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7353. return -1;
  7354. }
  7355. } else {
  7356. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7357. return -1;
  7358. }
  7359. }
  7360. else
  7361. {
  7362. clif_displaymessage(fd,msg_table[3]);
  7363. }
  7364. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7365. return 0;
  7366. }
  7367. /*==========================================
  7368. * Recall a player by PID number
  7369. * Original by Dino9021
  7370. * Added in by nsstrunks
  7371. *------------------------------------------
  7372. */
  7373. int atcommand_recallid2(
  7374. const int fd, struct map_session_data* sd,
  7375. const char* command, const char* message)
  7376. {
  7377. char character[100];
  7378. char output[200];
  7379. int aid=0;
  7380. int session_id=0;
  7381. struct map_session_data *pl_sd;
  7382. memset(character, '\0', sizeof(character));
  7383. memset(output, '\0', sizeof(output));
  7384. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7385. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7386. return -1;
  7387. }
  7388. aid=atoi(message);
  7389. if ((session_id=accountid2sessionid(aid))!=0)
  7390. {
  7391. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7392. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7393. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7394. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7395. return -1;
  7396. }
  7397. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7398. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7399. return -1;
  7400. }
  7401. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7402. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7403. clif_displaymessage(fd, output);
  7404. } else {
  7405. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7406. return -1;
  7407. }
  7408. } else {
  7409. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7410. return -1;
  7411. }
  7412. }
  7413. else
  7414. {
  7415. clif_displaymessage(fd,msg_table[3]);
  7416. }
  7417. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7418. return 0;
  7419. }
  7420. /*==========================================
  7421. * Kick a player by PID number
  7422. * Original by Dino9021
  7423. * Added in by nsstrunks
  7424. *------------------------------------------
  7425. */
  7426. int atcommand_kickid(
  7427. const int fd, struct map_session_data* sd,
  7428. const char* command, const char* message)
  7429. {
  7430. struct map_session_data *pl_sd;
  7431. char character[100];
  7432. int cid=0;
  7433. int session_id=0;
  7434. memset(character, '\0', sizeof(character));
  7435. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7436. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7437. return -1;
  7438. }
  7439. cid=atoi(message);
  7440. if ((session_id=charid2sessionid(cid))!=0)
  7441. {
  7442. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7443. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7444. clif_GM_kick(sd, pl_sd, 1);
  7445. else {
  7446. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7447. return -1;
  7448. }
  7449. } else {
  7450. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7451. return -1;
  7452. }
  7453. }
  7454. else
  7455. {
  7456. clif_displaymessage(fd,msg_table[3]);
  7457. }
  7458. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7459. return 0;
  7460. }
  7461. /*==========================================
  7462. * Kick a player by PID number
  7463. * Original by Dino9021
  7464. * Added in by nsstrunks
  7465. *------------------------------------------
  7466. */
  7467. int atcommand_kickid2(
  7468. const int fd, struct map_session_data* sd,
  7469. const char* command, const char* message)
  7470. {
  7471. struct map_session_data *pl_sd;
  7472. char character[100];
  7473. int aid=0;
  7474. int session_id=0;
  7475. memset(character, '\0', sizeof(character));
  7476. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7477. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7478. return -1;
  7479. }
  7480. aid=atoi(message);
  7481. if ((session_id=accountid2sessionid(aid))!=0)
  7482. {
  7483. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7484. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7485. clif_GM_kick(sd, pl_sd, 1);
  7486. else {
  7487. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7488. return -1;
  7489. }
  7490. } else {
  7491. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7492. return -1;
  7493. }
  7494. }
  7495. else
  7496. {
  7497. clif_displaymessage(fd,msg_table[3]);
  7498. }
  7499. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7500. return 0;
  7501. }
  7502. /*==========================================
  7503. * Revive a player by PID number
  7504. * Original by Dino9021
  7505. * Added in by nsstrunks
  7506. *------------------------------------------
  7507. */
  7508. int atcommand_reviveid(
  7509. const int fd, struct map_session_data* sd,
  7510. const char* command, const char* message)
  7511. {
  7512. char character[100];
  7513. int cid=0;
  7514. int session_id=0;
  7515. struct map_session_data *pl_sd;
  7516. memset(character, '\0', sizeof(character));
  7517. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7518. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7519. return -1;
  7520. }
  7521. cid=atoi(message);
  7522. if ((session_id=charid2sessionid(cid))!=0)
  7523. {
  7524. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7525. pl_sd->status.hp = pl_sd->status.max_hp;
  7526. pc_setstand(pl_sd);
  7527. if (battle_config.pc_invincible_time > 0)
  7528. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7529. clif_updatestatus(pl_sd, SP_HP);
  7530. clif_updatestatus(pl_sd, SP_SP);
  7531. clif_resurrection(&pl_sd->bl, 1);
  7532. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7533. } else {
  7534. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7535. return -1;
  7536. }
  7537. }
  7538. else
  7539. {
  7540. clif_displaymessage(fd,msg_table[3]);
  7541. }
  7542. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7543. return 0;
  7544. }
  7545. /*==========================================
  7546. * Revive a player by PID number
  7547. * Original by Dino9021
  7548. * Added in by nsstrunks
  7549. *------------------------------------------
  7550. */
  7551. int atcommand_reviveid2(
  7552. const int fd, struct map_session_data* sd,
  7553. const char* command, const char* message)
  7554. {
  7555. char character[100];
  7556. int aid=0;
  7557. int session_id=0;
  7558. struct map_session_data *pl_sd;
  7559. memset(character, '\0', sizeof(character));
  7560. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7561. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7562. return -1;
  7563. }
  7564. aid=atoi(message);
  7565. if ((session_id=accountid2sessionid(aid))!=0)
  7566. {
  7567. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7568. pl_sd->status.hp = pl_sd->status.max_hp;
  7569. pc_setstand(pl_sd);
  7570. if (battle_config.pc_invincible_time > 0)
  7571. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7572. clif_updatestatus(pl_sd, SP_HP);
  7573. clif_updatestatus(pl_sd, SP_SP);
  7574. clif_resurrection(&pl_sd->bl, 1);
  7575. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7576. } else {
  7577. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7578. return -1;
  7579. }
  7580. }
  7581. else
  7582. {
  7583. clif_displaymessage(fd,msg_table[3]);
  7584. }
  7585. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7586. return 0;
  7587. }
  7588. /*==========================================
  7589. * Kill a player by PID number
  7590. * Original by Dino9021
  7591. * Added in by nsstrunks
  7592. *------------------------------------------
  7593. */
  7594. int atcommand_killid(
  7595. const int fd, struct map_session_data* sd,
  7596. const char* command, const char* message)
  7597. {
  7598. char character[100];
  7599. int cid=0;
  7600. int session_id=0;
  7601. struct map_session_data *pl_sd;
  7602. memset(character, '\0', sizeof(character));
  7603. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7604. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7605. return -1;
  7606. }
  7607. cid=atoi(message);
  7608. if ((session_id=charid2sessionid(cid))!=0)
  7609. {
  7610. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7611. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7612. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7613. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7614. } else {
  7615. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7616. return -1;
  7617. }
  7618. } else {
  7619. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7620. return -1;
  7621. }
  7622. }
  7623. else
  7624. {
  7625. clif_displaymessage(fd,msg_table[3]);
  7626. }
  7627. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7628. return 0;
  7629. }
  7630. /*==========================================
  7631. * Kill a player by PID number
  7632. * Original by Dino9021
  7633. * Added in by nsstrunks
  7634. *------------------------------------------
  7635. */
  7636. int atcommand_killid2(
  7637. const int fd, struct map_session_data* sd,
  7638. const char* command, const char* message)
  7639. {
  7640. char character[100];
  7641. int aid=0;
  7642. int session_id=0;
  7643. struct map_session_data *pl_sd;
  7644. memset(character, '\0', sizeof(character));
  7645. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7646. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7647. return -1;
  7648. }
  7649. aid=atoi(message);
  7650. if ((session_id=accountid2sessionid(aid))!=0)
  7651. {
  7652. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7653. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7654. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7655. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7656. } else {
  7657. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7658. return -1;
  7659. }
  7660. } else {
  7661. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7662. return -1;
  7663. }
  7664. }
  7665. else
  7666. {
  7667. clif_displaymessage(fd,msg_table[3]);
  7668. }
  7669. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7670. return 0;
  7671. }
  7672. /*==========================================
  7673. * Make a player killable, by PID
  7674. * Original by Dino9021
  7675. * Added in by nsstrunks
  7676. *------------------------------------------
  7677. */
  7678. int
  7679. atcommand_charkillableid(
  7680. const int fd, struct map_session_data* sd,
  7681. const char* command, const char* message)
  7682. {
  7683. struct map_session_data *pl_sd = NULL;
  7684. int cid=0;
  7685. int session_id=0;
  7686. if (!message || (cid = atoi(message)) == 0 || !*message)
  7687. return -1;
  7688. cid=atoi(message);
  7689. if ((session_id=charid2sessionid(cid))!=0)
  7690. {
  7691. if((pl_sd=session[session_id]->session_data) == NULL)
  7692. return -1;
  7693. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7694. if(pl_sd->special_state.killable)
  7695. clif_displaymessage(fd, "The player is now killable");
  7696. else
  7697. clif_displaymessage(fd, "The player is no longer killable");
  7698. }
  7699. else
  7700. {
  7701. clif_displaymessage(fd,msg_table[3]);
  7702. }
  7703. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7704. return 0;
  7705. }
  7706. /*==========================================
  7707. * Make a player killable, by PID
  7708. * Original by Dino9021
  7709. * Added in by nsstrunks
  7710. *------------------------------------------
  7711. */
  7712. int
  7713. atcommand_charkillableid2(
  7714. const int fd, struct map_session_data* sd,
  7715. const char* command, const char* message)
  7716. {
  7717. struct map_session_data *pl_sd = NULL;
  7718. int aid=0;
  7719. int session_id=0;
  7720. if (!message || (aid = atoi(message)) == 0 || !*message)
  7721. return -1;
  7722. aid=atoi(message);
  7723. if ((session_id=accountid2sessionid(aid))!=0)
  7724. {
  7725. if((pl_sd=session[session_id]->session_data) == NULL)
  7726. return -1;
  7727. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7728. if(pl_sd->special_state.killable)
  7729. clif_displaymessage(fd, "The player is now killable");
  7730. else
  7731. clif_displaymessage(fd, "The player is no longer killable");
  7732. }
  7733. else
  7734. {
  7735. clif_displaymessage(fd,msg_table[3]);
  7736. }
  7737. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7738. return 0;
  7739. }
  7740. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7741. /*==========================================
  7742. * Mail System commands by [Valaris]
  7743. *------------------------------------------
  7744. */
  7745. int atcommand_listmail(
  7746. const int fd, struct map_session_data* sd,
  7747. const char* command, const char* message)
  7748. {
  7749. if(!battle_config.mail_system)
  7750. return 0;
  7751. nullpo_retr(-1, sd);
  7752. if(strlen(command)==12)
  7753. mail_check(sd,3);
  7754. else if(strlen(command)==9)
  7755. mail_check(sd,2);
  7756. else
  7757. mail_check(sd,1);
  7758. return 0;
  7759. }
  7760. int atcommand_readmail(
  7761. const int fd, struct map_session_data* sd,
  7762. const char* command, const char* message)
  7763. {
  7764. if(!battle_config.mail_system)
  7765. return 0;
  7766. nullpo_retr(-1, sd);
  7767. if (!message || !*message) {
  7768. clif_displaymessage(sd->fd,"You must specify a message number.");
  7769. return 0;
  7770. }
  7771. if(strlen(command)==11)
  7772. mail_delete(sd,atoi(message));
  7773. else
  7774. mail_read(sd,atoi(message));
  7775. return 0;
  7776. }
  7777. int atcommand_sendmail(
  7778. const int fd, struct map_session_data* sd,
  7779. const char* command, const char* message)
  7780. {
  7781. char name[24],text[80];
  7782. if(!battle_config.mail_system)
  7783. return 0;
  7784. nullpo_retr(-1, sd);
  7785. if (!message || !*message) {
  7786. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7787. return 0;
  7788. }
  7789. if ((sscanf(message, "\"%[^\"]\" %79[^\n]", name, text) < 2) &&
  7790. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7791. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7792. return 0;
  7793. }
  7794. if(strlen(command)==17)
  7795. mail_send(sd,name,text,1);
  7796. else
  7797. mail_send(sd,name,text,0);
  7798. return 0;
  7799. }
  7800. /*==========================================
  7801. * Refresh online command for SQL [Valaris]
  7802. * Will refresh and check online column of
  7803. * players and set correctly.
  7804. *------------------------------------------
  7805. */
  7806. int atcommand_refreshonline(
  7807. const int fd, struct map_session_data* sd,
  7808. const char* command, const char* message)
  7809. {
  7810. nullpo_retr(-1, sd);
  7811. char_online_check();
  7812. return 0;
  7813. }
  7814. #endif /* end sql only */