atcommand.c 306 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include "../common/socket.h"
  9. #include "../common/timer.h"
  10. #include "../common/nullpo.h"
  11. #include "../common/mmo.h"
  12. #include "../common/core.h"
  13. #include "../common/showmsg.h"
  14. #include "log.h"
  15. #include "clif.h"
  16. #include "chrif.h"
  17. #include "intif.h"
  18. #include "itemdb.h"
  19. #include "map.h"
  20. #include "pc.h"
  21. #include "status.h"
  22. #include "skill.h"
  23. #include "mob.h"
  24. #include "pet.h"
  25. #include "battle.h"
  26. #include "party.h"
  27. #include "guild.h"
  28. #include "atcommand.h"
  29. #include "script.h"
  30. #include "npc.h"
  31. #include "trade.h"
  32. #ifndef TXT_ONLY
  33. #include "mail.h"
  34. #endif
  35. static char command_symbol = '@'; // first char of the commands (by [Yor])
  36. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  37. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  38. ACMD_FUNC(broadcast);
  39. ACMD_FUNC(localbroadcast);
  40. ACMD_FUNC(rura);
  41. ACMD_FUNC(where);
  42. ACMD_FUNC(jumpto);
  43. ACMD_FUNC(jump);
  44. ACMD_FUNC(who);
  45. ACMD_FUNC(who2);
  46. ACMD_FUNC(who3);
  47. ACMD_FUNC(whomap);
  48. ACMD_FUNC(whomap2);
  49. ACMD_FUNC(whomap3);
  50. ACMD_FUNC(whogm); // by Yor
  51. ACMD_FUNC(whozeny); // [Valaris]
  52. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  53. ACMD_FUNC(save);
  54. ACMD_FUNC(load);
  55. ACMD_FUNC(speed);
  56. ACMD_FUNC(storage);
  57. ACMD_FUNC(guildstorage);
  58. ACMD_FUNC(option);
  59. ACMD_FUNC(hide);
  60. ACMD_FUNC(jobchange);
  61. ACMD_FUNC(die);
  62. ACMD_FUNC(kill);
  63. ACMD_FUNC(alive);
  64. ACMD_FUNC(kami);
  65. ACMD_FUNC(heal);
  66. ACMD_FUNC(item);
  67. ACMD_FUNC(item2);
  68. ACMD_FUNC(itemreset);
  69. ACMD_FUNC(itemcheck);
  70. ACMD_FUNC(baselevelup);
  71. ACMD_FUNC(joblevelup);
  72. ACMD_FUNC(help);
  73. ACMD_FUNC(help2);
  74. ACMD_FUNC(gm);
  75. ACMD_FUNC(pvpoff);
  76. ACMD_FUNC(pvpon);
  77. ACMD_FUNC(gvgoff);
  78. ACMD_FUNC(gvgon);
  79. ACMD_FUNC(model);
  80. ACMD_FUNC(go);
  81. ACMD_FUNC(monster);
  82. ACMD_FUNC(monstersmall);
  83. ACMD_FUNC(monsterbig);
  84. ACMD_FUNC(spawn);
  85. ACMD_FUNC(killmonster);
  86. ACMD_FUNC(killmonster2);
  87. ACMD_FUNC(refine);
  88. ACMD_FUNC(produce);
  89. ACMD_FUNC(memo);
  90. ACMD_FUNC(gat);
  91. ACMD_FUNC(packet);
  92. ACMD_FUNC(waterlevel);
  93. ACMD_FUNC(statuspoint);
  94. ACMD_FUNC(skillpoint);
  95. ACMD_FUNC(zeny);
  96. ACMD_FUNC(param);
  97. ACMD_FUNC(guildlevelup);
  98. ACMD_FUNC(makeegg);
  99. ACMD_FUNC(hatch);
  100. ACMD_FUNC(petfriendly);
  101. ACMD_FUNC(pethungry);
  102. ACMD_FUNC(petrename);
  103. ACMD_FUNC(recall);
  104. ACMD_FUNC(recallall);
  105. ACMD_FUNC(revive);
  106. ACMD_FUNC(night);
  107. ACMD_FUNC(day);
  108. ACMD_FUNC(doom);
  109. ACMD_FUNC(doommap);
  110. ACMD_FUNC(raise);
  111. ACMD_FUNC(raisemap);
  112. ACMD_FUNC(kick);
  113. ACMD_FUNC(kickall);
  114. ACMD_FUNC(allskill);
  115. ACMD_FUNC(questskill);
  116. ACMD_FUNC(lostskill);
  117. ACMD_FUNC(spiritball);
  118. ACMD_FUNC(party);
  119. ACMD_FUNC(guild);
  120. ACMD_FUNC(agitstart);
  121. ACMD_FUNC(agitend);
  122. ACMD_FUNC(reloaditemdb);
  123. ACMD_FUNC(reloadmobdb);
  124. ACMD_FUNC(reloadskilldb);
  125. ACMD_FUNC(reloadscript);
  126. ACMD_FUNC(reloadgmdb); // by Yor
  127. ACMD_FUNC(reloadatcommand);
  128. ACMD_FUNC(reloadbattleconf);
  129. ACMD_FUNC(reloadstatusdb);
  130. ACMD_FUNC(reloadpcdb);
  131. ACMD_FUNC(reloadmotd); // [Valaris]
  132. ACMD_FUNC(mapexit);
  133. ACMD_FUNC(idsearch);
  134. ACMD_FUNC(mapinfo);
  135. ACMD_FUNC(dye); //** by fritz
  136. ACMD_FUNC(hair_style); //** by fritz
  137. ACMD_FUNC(hair_color); //** by fritz
  138. ACMD_FUNC(stat_all); //** by fritz
  139. ACMD_FUNC(char_block); // by Yor
  140. ACMD_FUNC(char_ban); // by Yor
  141. ACMD_FUNC(char_unblock); // by Yor
  142. ACMD_FUNC(char_unban); // by Yor
  143. ACMD_FUNC(mount_peco); // by Valaris
  144. ACMD_FUNC(char_mount_peco); // by Yor
  145. ACMD_FUNC(guildspy); // [Syrus22]
  146. ACMD_FUNC(partyspy); // [Syrus22]
  147. ACMD_FUNC(repairall); // [Valaris]
  148. ACMD_FUNC(guildrecall); // by Yor
  149. ACMD_FUNC(partyrecall); // by Yor
  150. ACMD_FUNC(nuke); // [Valaris]
  151. ACMD_FUNC(shownpc);
  152. ACMD_FUNC(hidenpc);
  153. ACMD_FUNC(loadnpc);
  154. ACMD_FUNC(unloadnpc);
  155. ACMD_FUNC(servertime); // by Yor
  156. ACMD_FUNC(chardelitem); // by Yor
  157. ACMD_FUNC(jail); // by Yor
  158. ACMD_FUNC(unjail); // by Yor
  159. ACMD_FUNC(disguise); // [Valaris]
  160. ACMD_FUNC(undisguise); // by Yor
  161. ACMD_FUNC(chardisguise); // Kalaspuff
  162. ACMD_FUNC(charundisguise); // Kalaspuff
  163. ACMD_FUNC(email); // by Yor
  164. ACMD_FUNC(effect);//by Apple
  165. ACMD_FUNC(character_cart_list); // by Yor
  166. ACMD_FUNC(addwarp); // by MouseJstr
  167. ACMD_FUNC(follow); // by MouseJstr
  168. ACMD_FUNC(skillon); // by MouseJstr
  169. ACMD_FUNC(skilloff); // by MouseJstr
  170. ACMD_FUNC(killer); // by MouseJstr
  171. ACMD_FUNC(npcmove); // by MouseJstr
  172. ACMD_FUNC(killable); // by MouseJstr
  173. ACMD_FUNC(charkillable); // by MouseJstr
  174. ACMD_FUNC(dropall); // by MouseJstr
  175. ACMD_FUNC(chardropall); // by MouseJstr
  176. ACMD_FUNC(storeall); // by MouseJstr
  177. ACMD_FUNC(charstoreall); // by MouseJstr
  178. ACMD_FUNC(skillid); // by MouseJstr
  179. ACMD_FUNC(useskill); // by MouseJstr
  180. ACMD_FUNC(summon);
  181. ACMD_FUNC(rain);
  182. ACMD_FUNC(snow);
  183. ACMD_FUNC(sakura);
  184. ACMD_FUNC(clouds);
  185. ACMD_FUNC(clouds2); // [Valaris]
  186. ACMD_FUNC(fog);
  187. ACMD_FUNC(fireworks);
  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. ACMD_FUNC(npctalk);
  207. ACMD_FUNC(pettalk);
  208. ACMD_FUNC(users);
  209. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  210. #ifndef TXT_ONLY
  211. ACMD_FUNC(checkmail); // [Valaris]
  212. ACMD_FUNC(listmail); // [Valaris]
  213. ACMD_FUNC(listnewmail); // [Valaris]
  214. ACMD_FUNC(readmail); // [Valaris]
  215. ACMD_FUNC(sendmail); // [Valaris]
  216. ACMD_FUNC(sendprioritymail); // [Valaris]
  217. ACMD_FUNC(deletemail); // [Valaris]
  218. ACMD_FUNC(refreshonline); // [Valaris]
  219. #endif /* TXT_ONLY */
  220. ACMD_FUNC(skilltree); // by MouseJstr
  221. ACMD_FUNC(marry); // by MouseJstr
  222. ACMD_FUNC(divorce); // by MouseJstr
  223. ACMD_FUNC(grind); // by MouseJstr
  224. ACMD_FUNC(grind2); // by MouseJstr
  225. #ifdef DMALLOC
  226. ACMD_FUNC(dmstart); // by MouseJstr
  227. ACMD_FUNC(dmtick); // by MouseJstr
  228. #endif
  229. ACMD_FUNC(jumptoid); // by Dino9021
  230. ACMD_FUNC(jumptoid2); // by Dino9021
  231. ACMD_FUNC(recallid); // by Dino9021
  232. ACMD_FUNC(recallid2); // by Dino9021
  233. ACMD_FUNC(kickid); // by Dino9021
  234. ACMD_FUNC(kickid2); // by Dino9021
  235. ACMD_FUNC(reviveid); // by Dino9021
  236. ACMD_FUNC(reviveid2); // by Dino9021
  237. ACMD_FUNC(killid); // by Dino9021
  238. ACMD_FUNC(killid2); // by Dino9021
  239. ACMD_FUNC(charkillableid); // by Dino9021
  240. ACMD_FUNC(charkillableid2); // by Dino9021
  241. ACMD_FUNC(sound);
  242. ACMD_FUNC(undisguiseall);
  243. ACMD_FUNC(disguiseall);
  244. ACMD_FUNC(changelook);
  245. ACMD_FUNC(mobinfo); //by Lupus
  246. ACMD_FUNC(exp); // by Skotlex
  247. ACMD_FUNC(adopt); // by Veider
  248. ACMD_FUNC(version); // by Ancyker
  249. ACMD_FUNC(mutearea); // by MouseJstr
  250. ACMD_FUNC(shuffle); // by MouseJstr
  251. ACMD_FUNC(rates); // by MouseJstr
  252. ACMD_FUNC(iteminfo); // Lupus
  253. ACMD_FUNC(mapflag); // Lupus
  254. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  255. ACMD_FUNC(monsterignore); // [Valaris]
  256. ACMD_FUNC(fakename); //[Valaris]
  257. ACMD_FUNC(size); //[Valaris]
  258. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  259. ACMD_FUNC(showzeny);
  260. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  261. ACMD_FUNC(autotrade);// durf
  262. ACMD_FUNC(changeleader);// [Skotlex]
  263. ACMD_FUNC(changegm);// durf
  264. // Duel [LuzZza]
  265. ACMD_FUNC(invite);
  266. ACMD_FUNC(duel);
  267. ACMD_FUNC(leave);
  268. ACMD_FUNC(accept);
  269. ACMD_FUNC(reject);
  270. ACMD_FUNC(away); // LuzZza
  271. ACMD_FUNC(main); // LuzZza
  272. ACMD_FUNC(clone); // [Valaris]
  273. /*==========================================
  274. *AtCommandInfo atcommand_info[]構造体の定義
  275. *------------------------------------------
  276. */
  277. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  278. // to set default level, read atcommand_athena.conf first please.
  279. static AtCommandInfo atcommand_info[] = {
  280. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  281. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  282. { AtCommand_Where, "@where", 1, atcommand_where },
  283. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  284. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  285. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  286. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  287. { AtCommand_Who, "@who", 20, atcommand_who },
  288. { AtCommand_Who, "@whois", 20, atcommand_who },
  289. { AtCommand_Who, "@w", 20, atcommand_who },
  290. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  291. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  292. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  293. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  294. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  295. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  296. { AtCommand_Save, "@save", 40, atcommand_save },
  297. { AtCommand_Load, "@return", 40, atcommand_load },
  298. { AtCommand_Load, "@load", 40, atcommand_load },
  299. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  300. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  301. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  302. { AtCommand_Option, "@option", 40, atcommand_option },
  303. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  304. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  305. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  306. { AtCommand_Die, "@die", 1, atcommand_die },
  307. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  308. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  309. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  310. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  311. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  312. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  313. { AtCommand_Item, "@item", 60, atcommand_item },
  314. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  315. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  316. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  317. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  318. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  319. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  320. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  321. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  322. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  323. { AtCommand_H, "@h", 20, atcommand_help },
  324. { AtCommand_Help, "@help", 20, atcommand_help },
  325. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  326. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  327. { AtCommand_GM, "@gm", 100,atcommand_gm },
  328. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  329. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  330. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  331. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  332. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  333. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  334. { AtCommand_Model, "@model", 20, atcommand_model },
  335. { AtCommand_Go, "@go", 10, atcommand_go },
  336. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  337. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  338. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  339. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  340. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  341. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  342. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  343. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  344. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  345. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  346. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  347. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  348. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  349. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  350. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  351. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  352. { AtCommand_Strength, "@str", 60, atcommand_param },
  353. { AtCommand_Agility, "@agi", 60, atcommand_param },
  354. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  355. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  356. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  357. { AtCommand_Luck, "@luk", 60, atcommand_param },
  358. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  359. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  360. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  361. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  362. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  363. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  364. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  365. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  366. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  367. { AtCommand_Night, "@night", 80, atcommand_night },
  368. { AtCommand_Day, "@day", 80, atcommand_day },
  369. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  370. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  371. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  372. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  373. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  374. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  375. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  376. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  377. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  378. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  379. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  380. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  381. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  382. { AtCommand_Party, "@party", 1, atcommand_party },
  383. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  384. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  385. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  386. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  387. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  388. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  389. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  390. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  391. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  392. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  393. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  394. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  395. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  396. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  397. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  398. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  399. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  400. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  401. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  402. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  403. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  404. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  405. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  406. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  407. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  408. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  409. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  410. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  411. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  412. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  413. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  414. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  415. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  416. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  417. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  418. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  419. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  420. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  421. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  422. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  423. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  424. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  425. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  426. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  427. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  428. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  429. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  430. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  431. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  432. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  433. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  434. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  435. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  436. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  437. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  438. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  439. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  440. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  441. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  442. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  443. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  444. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  445. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  446. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  447. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  448. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  449. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  450. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  451. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  452. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  453. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  454. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  455. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  456. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  457. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  458. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  459. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  460. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  461. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  462. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  463. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  464. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  465. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  466. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  467. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  468. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  469. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  470. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  471. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  472. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  473. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  474. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  475. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  476. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  477. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  478. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  479. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  480. { AtCommand_Send, "@send", 60, atcommand_send },
  481. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  482. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  483. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  484. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  485. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken]
  486. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  487. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  488. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  489. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  490. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  491. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  492. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  493. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  494. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  495. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  496. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  497. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  498. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  499. { AtCommand_Users, "@users", 40, atcommand_users },
  500. { AtCommand_ResetState, "/reset", 40, NULL },
  501. #ifndef TXT_ONLY // sql-only commands
  502. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  503. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  504. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  505. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  506. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  507. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  508. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  509. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  510. #endif /* TXT_ONLY */
  511. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  512. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  513. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  514. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  515. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  516. #ifdef DMALLOC
  517. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  518. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  519. #endif
  520. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  521. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  522. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  523. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  524. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  525. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  526. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  527. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  528. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  529. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  530. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  531. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  532. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  533. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  534. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  535. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  536. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  537. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  538. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  539. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  540. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  541. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  542. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  543. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  544. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  545. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  546. { AtCommand_Version, "@version", 1, atcommand_version },
  547. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  548. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  549. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  550. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  551. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  552. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  553. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  554. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  555. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  556. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  557. { AtCommand_Size, "@size", 20, atcommand_size },
  558. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  559. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  560. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  561. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  562. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  563. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  564. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  565. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  566. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  567. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  568. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  569. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  570. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  571. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  572. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  573. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  574. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  575. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  576. // add new commands before this line
  577. { AtCommand_Unknown, NULL, 1, NULL }
  578. };
  579. /*=========================================
  580. * Generic variables
  581. *-----------------------------------------
  582. */
  583. char atcmd_output[200];
  584. char atcmd_player_name[100];
  585. char atcmd_temp[100];
  586. /*==========================================
  587. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  588. *------------------------------------------
  589. */
  590. char *estr_lower(char *str)
  591. {
  592. int i;
  593. for (i=0; str[i]; i++)
  594. if ((str[i] >= 65) && (str[i] <= 90))
  595. str[i] += 32;
  596. return str;
  597. }
  598. // compare function for sorting high to lowest
  599. int hightolow_compare (const void * a, const void * b)
  600. {
  601. return ( *(int*)b - *(int*)a );
  602. }
  603. // compare function for sorting lowest to highest
  604. int lowtohigh_compare (const void * a, const void * b)
  605. {
  606. return ( *(int*)a - *(int*)b );
  607. }
  608. //-----------------------------------------------------------
  609. // Return the message string of the specified number by [Yor]
  610. //-----------------------------------------------------------
  611. char * msg_txt(int msg_number) {
  612. if (msg_number >= 0 && msg_number < MAX_MSG &&
  613. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  614. return msg_table[msg_number];
  615. return "??";
  616. }
  617. //-----------------------------------------------------------
  618. // Returns Players title (from msg_athena.conf) [Lupus]
  619. //-----------------------------------------------------------
  620. char * player_title_txt(int level) {
  621. if (level < battle_config.title_lvl1)
  622. return ""; //w/o any titles
  623. if (level >= battle_config.title_lvl8)
  624. sprintf(atcmd_temp, msg_table[332], level);
  625. else
  626. if (level >= battle_config.title_lvl7)
  627. sprintf(atcmd_temp, msg_table[331], level);
  628. else
  629. if (level >= battle_config.title_lvl6)
  630. sprintf(atcmd_temp, msg_table[330], level);
  631. else
  632. if (level >= battle_config.title_lvl5)
  633. sprintf(atcmd_temp, msg_table[329], level);
  634. else
  635. if (level >= battle_config.title_lvl4)
  636. sprintf(atcmd_temp, msg_table[328], level);
  637. else
  638. if (level >= battle_config.title_lvl3)
  639. sprintf(atcmd_temp, msg_table[327], level);
  640. else
  641. if (level >= battle_config.title_lvl2)
  642. sprintf(atcmd_temp, msg_table[326], level);
  643. else
  644. sprintf(atcmd_temp, msg_table[325], level); //lvl1
  645. return atcmd_temp;
  646. }
  647. //------------------------------------------------------------
  648. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  649. //------------------------------------------------------------
  650. int e_mail_check(char *email) {
  651. char ch;
  652. char* last_arobas;
  653. // athena limits
  654. if (strlen(email) < 3 || strlen(email) > 39)
  655. return 0;
  656. // part of RFC limits (official reference of e-mail description)
  657. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  658. return 0;
  659. if (email[strlen(email)-1] == '.')
  660. return 0;
  661. last_arobas = strrchr(email, '@');
  662. if (strstr(last_arobas, "@.") != NULL ||
  663. strstr(last_arobas, "..") != NULL)
  664. return 0;
  665. for(ch = 1; ch < 32; ch++) {
  666. if (strchr(last_arobas, ch) != NULL) {
  667. return 0;
  668. break;
  669. }
  670. }
  671. if (strchr(last_arobas, ' ') != NULL ||
  672. strchr(last_arobas, ';') != NULL)
  673. return 0;
  674. // all correct
  675. return 1;
  676. }
  677. /*==========================================
  678. * get_atcommand_level @コマンドの必要レベルを取得
  679. *------------------------------------------
  680. */
  681. int get_atcommand_level(const AtCommandType type) {
  682. int i;
  683. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  684. if (atcommand_info[i].type == type)
  685. return atcommand_info[i].level;
  686. return 100; // 100: command can not be used
  687. }
  688. /*==========================================
  689. *is_atcommand @コマンドに存在するかどうか確認する
  690. *------------------------------------------
  691. */
  692. AtCommandType
  693. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  694. const char* str = message;
  695. int s_flag = 0;
  696. AtCommandInfo info;
  697. AtCommandType type;
  698. nullpo_retr(AtCommand_None, sd);
  699. if (!battle_config.allow_atcommand_when_mute &&
  700. sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1) {
  701. return AtCommand_Unknown;
  702. }
  703. if (!message || !*message)
  704. return AtCommand_None;
  705. memset(&info, 0, sizeof(info));
  706. str += strlen(sd->status.name);
  707. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  708. if (*str == ':')
  709. s_flag = 1;
  710. str++;
  711. }
  712. if (!*str)
  713. return AtCommand_None;
  714. if (map[sd->bl.m].flag.nocommand &&
  715. (gmlvl > 0? gmlvl:pc_isGM(sd)) < battle_config.gm_skilluncond)
  716. { //Command not allowed on this map.
  717. sprintf(atcmd_output, msg_table[143]);
  718. clif_displaymessage(fd, atcmd_output);
  719. return AtCommand_None;
  720. }
  721. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  722. if (type != AtCommand_None) {
  723. char command[100];
  724. const char* p = str;
  725. memset(command, '\0', sizeof(command));
  726. memset(atcmd_output, '\0', sizeof(atcmd_output));
  727. while (*p && !isspace(*p))
  728. p++;
  729. if (p - str >= sizeof(command)) // too long
  730. return AtCommand_Unknown;
  731. strncpy(command, str, p - str);
  732. while (isspace(*p))
  733. p++;
  734. if (type == AtCommand_Unknown || info.proc == NULL) {
  735. sprintf(atcmd_output, msg_table[153], command); // %s is Unknown Command.
  736. clif_displaymessage(fd, atcmd_output);
  737. } else {
  738. if (info.proc(fd, sd, command, p) != 0) {
  739. // Command can not be executed
  740. sprintf(atcmd_output, msg_table[154], command); // %s failed.
  741. clif_displaymessage(fd, atcmd_output);
  742. }
  743. }
  744. return info.type;
  745. }
  746. return AtCommand_None;
  747. }
  748. /*==========================================
  749. *
  750. *------------------------------------------
  751. */
  752. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  753. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  754. if (!info)
  755. return AtCommand_None;
  756. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  757. return AtCommand_None;
  758. if (!p || !*p) {
  759. ShowError("at command message is empty\n");
  760. return AtCommand_None;
  761. }
  762. if (*p == command_symbol) { // check first char.
  763. char command[101];
  764. int i = 0;
  765. memset(info, 0, sizeof(AtCommandInfo));
  766. sscanf(p, "%100s", command);
  767. command[sizeof(command)-1] = '\0';
  768. while (atcommand_info[i].type != AtCommand_Unknown) {
  769. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  770. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  771. break;
  772. }
  773. i++;
  774. }
  775. if (atcommand_info[i].type == AtCommand_Unknown) {
  776. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  777. if (level == 0)
  778. return AtCommand_None;
  779. else
  780. return AtCommand_Unknown;
  781. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  782. log_atcommand(sd, message);
  783. }
  784. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  785. } else {
  786. return AtCommand_None;
  787. }
  788. return info->type;
  789. }
  790. /*==========================================
  791. * Read Message Data
  792. *------------------------------------------
  793. */
  794. int msg_config_read(const char *cfgName) {
  795. int msg_number;
  796. char line[1024], w1[1024], w2[1024];
  797. FILE *fp;
  798. static int called = 1;
  799. if ((fp = fopen(cfgName, "r")) == NULL) {
  800. ShowError("Messages file not found: %s\n", cfgName);
  801. return 1;
  802. }
  803. if ((--called) == 0)
  804. memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
  805. while(fgets(line, sizeof(line)-1, fp)) {
  806. if (line[0] == '/' && line[1] == '/')
  807. continue;
  808. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  809. if (strcmpi(w1, "import") == 0) {
  810. msg_config_read(w2);
  811. } else {
  812. msg_number = atoi(w1);
  813. if (msg_number >= 0 && msg_number < MAX_MSG) {
  814. if (msg_table[msg_number] != NULL)
  815. aFree(msg_table[msg_number]);
  816. msg_table[msg_number] = (char *)aCalloc(strlen(w2) + 1, sizeof (char));
  817. strcpy(msg_table[msg_number],w2);
  818. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  819. }
  820. }
  821. }
  822. }
  823. fclose(fp);
  824. return 0;
  825. }
  826. /*==========================================
  827. * Cleanup Message Data
  828. *------------------------------------------
  829. */
  830. void do_final_msg (void) {
  831. int i;
  832. for (i = 0; i < MAX_MSG; i++)
  833. aFree(msg_table[i]);
  834. return;
  835. }
  836. /*==========================================
  837. *
  838. *------------------------------------------
  839. */
  840. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  841. int i;
  842. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  843. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  844. return &atcommand_info[i];
  845. return NULL;
  846. }
  847. /*==========================================
  848. *
  849. *------------------------------------------
  850. */
  851. int atcommand_config_read(const char *cfgName) {
  852. char line[1024], w1[1024], w2[1024];
  853. AtCommandInfo* p;
  854. FILE* fp;
  855. if ((fp = fopen(cfgName, "r")) == NULL) {
  856. ShowError("At commands configuration file not found: %s\n", cfgName);
  857. return 1;
  858. }
  859. while (fgets(line, sizeof(line)-1, fp)) {
  860. if (line[0] == '/' && line[1] == '/')
  861. continue;
  862. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  863. continue;
  864. p = get_atcommandinfo_byname(w1);
  865. if (p != NULL) {
  866. p->level = atoi(w2);
  867. if (p->level > 100)
  868. p->level = 100;
  869. else if (p->level < 0)
  870. p->level = 0;
  871. }
  872. if (strcmpi(w1, "import") == 0)
  873. atcommand_config_read(w2);
  874. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  875. w2[0] != '/' && // symbol of standard ragnarok GM commands
  876. w2[0] != '%' && // symbol of party chat speaking
  877. w2[0] != '$' && // symbol of guild chat
  878. w2[0] != '#') // symbol of charcommand
  879. command_symbol = w2[0];
  880. }
  881. fclose(fp);
  882. return 0;
  883. }
  884. /*==========================================
  885. * Duel organizing functions [LuzZza]
  886. *------------------------------------------
  887. */
  888. void duel_msg_foreach_sameduel_wos(
  889. const unsigned int did, struct map_session_data* sd, char *output)
  890. {
  891. int i;
  892. struct map_session_data* msg_sd;
  893. for(i=0; i<fd_max; i++)
  894. if(session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  895. && msg_sd->state.auth && msg_sd->duel_group == did && msg_sd != sd)
  896. clif_disp_onlyself(msg_sd, output, strlen(output));
  897. return;
  898. }
  899. void duel_savetime(struct map_session_data* sd) {
  900. time_t timer;
  901. struct tm *t;
  902. time(&timer);
  903. t = localtime(&timer);
  904. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  905. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  906. return;
  907. }
  908. int duel_checktime(struct map_session_data* sd) {
  909. int diff;
  910. time_t timer;
  911. struct tm *t;
  912. time(&timer);
  913. t = localtime(&timer);
  914. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  915. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  916. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  917. }
  918. int duel_showinfo(
  919. const unsigned int did, struct map_session_data* sd)
  920. {
  921. int i, p=0;
  922. char output[256];
  923. struct map_session_data* msg_sd;
  924. if(duel_list[did].max_players_limit > 0)
  925. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  926. did, duel_count,
  927. duel_list[did].members_count,
  928. duel_list[did].members_count + duel_list[did].invites_count,
  929. duel_list[did].max_players_limit);
  930. else
  931. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  932. did, duel_count,
  933. duel_list[did].members_count,
  934. duel_list[did].members_count + duel_list[did].invites_count);
  935. clif_disp_onlyself(sd, output, strlen(output));
  936. for(i=0; i<fd_max; i++)
  937. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  938. && msg_sd->state.auth && msg_sd->duel_group == did) {
  939. sprintf(output, " %d. %s", ++p, (unsigned char *) msg_sd->status.name);
  940. clif_disp_onlyself(sd, output, strlen(output));
  941. }
  942. return 0;
  943. }
  944. int duel_create(
  945. struct map_session_data* sd, const unsigned int maxpl)
  946. {
  947. int i=1;
  948. char output[256];
  949. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  950. if(i == MAX_DUEL) return 0;
  951. duel_count++;
  952. sd->duel_group = i;
  953. duel_list[i].members_count++;
  954. duel_list[i].invites_count = 0;
  955. duel_list[i].max_players_limit = maxpl;
  956. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  957. clif_disp_onlyself(sd, output, strlen(output));
  958. clif_set0199(sd->fd, 1);
  959. //clif_misceffect2(&sd->bl, 159);
  960. return i;
  961. }
  962. int duel_invite(
  963. const unsigned int did, struct map_session_data* sd,
  964. struct map_session_data* target_sd)
  965. {
  966. char output[256];
  967. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  968. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  969. duel_msg_foreach_sameduel_wos(did, sd, output);
  970. target_sd->duel_invite = did;
  971. duel_list[did].invites_count++;
  972. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  973. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  974. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  975. return 0;
  976. }
  977. int duel_leave(
  978. const unsigned int did, struct map_session_data* sd)
  979. {
  980. int i;
  981. char output[256];
  982. struct map_session_data* msg_sd;
  983. // " <- Player %s has left duel --"
  984. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  985. duel_msg_foreach_sameduel_wos(did, sd, output);
  986. duel_list[did].members_count--;
  987. if(duel_list[did].members_count == 0) {
  988. for (i=0; i<fd_max; i++)
  989. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  990. && msg_sd->state.auth && msg_sd->duel_invite == did && msg_sd != sd) {
  991. msg_sd->duel_invite = 0;
  992. }
  993. duel_count--;
  994. }
  995. sd->duel_group = 0;
  996. duel_savetime(sd);
  997. clif_set0199(sd->fd, 0);
  998. return 0;
  999. }
  1000. int duel_accept(
  1001. const unsigned int did, struct map_session_data* sd)
  1002. {
  1003. char output[256];
  1004. // " -> Player %s has accepted duel --"
  1005. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  1006. duel_msg_foreach_sameduel_wos(did, sd, output);
  1007. duel_list[did].members_count++;
  1008. sd->duel_group = sd->duel_invite;
  1009. duel_list[did].invites_count--;
  1010. sd->duel_invite = 0;
  1011. clif_set0199(sd->fd, 1);
  1012. //clif_misceffect2(&sd->bl, 159);
  1013. return 0;
  1014. }
  1015. int duel_reject(
  1016. const unsigned int did, struct map_session_data* sd)
  1017. {
  1018. char output[256];
  1019. // " -- Player %s has rejected duel --"
  1020. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1021. duel_msg_foreach_sameduel_wos(did, sd, output);
  1022. duel_list[did].invites_count--;
  1023. sd->duel_invite = 0;
  1024. return 0;
  1025. }
  1026. /*==========================================
  1027. // @ command processing functions
  1028. *------------------------------------------
  1029. */
  1030. /*==========================================
  1031. * @send (used for testing packet sends from the client)
  1032. *------------------------------------------
  1033. */
  1034. int atcommand_send(
  1035. const int fd, struct map_session_data* sd,
  1036. const char* command, const char* message)
  1037. {
  1038. int i,type=0;
  1039. int info[20];
  1040. if (!message || !*message || sscanf(message, "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &type, &info[1], &info[2], &info[3], &info[4], &info[5], &info[6], &info[7], &info[8], &info[9], &info[10], &info[11], &info[12], &info[13], &info[14], &info[15], &info[16], &info[17], &info[18], &info[19], &info[20]) < 1) {
  1041. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1042. return -1;
  1043. }
  1044. if (type > 0 && type < MAX_PACKET_DB) {
  1045. switch (type)
  1046. {
  1047. case 0x209: {
  1048. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1049. WFIFOW(fd,0) = 0x209;
  1050. WFIFOW(fd,2) = 2;
  1051. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1052. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1053. break;
  1054. }
  1055. case 0x1b1:
  1056. case 0x1c2:
  1057. //case xxx:
  1058. // add others here
  1059. // break;
  1060. default: {
  1061. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1062. WFIFOW(fd,0) = type;
  1063. for(i=1;i<=sizeof(info);i++)
  1064. if(info[i])
  1065. WFIFOW(fd,i) = info[i];
  1066. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1067. break;
  1068. }
  1069. }
  1070. sprintf (atcmd_output, msg_table[258], type, type);
  1071. clif_displaymessage(fd, atcmd_output);
  1072. } else {
  1073. clif_displaymessage(fd, msg_table[259]);
  1074. }
  1075. return 0;
  1076. }
  1077. // @rura
  1078. /*==========================================
  1079. *
  1080. *------------------------------------------
  1081. */
  1082. int atcommand_rura(
  1083. const int fd, struct map_session_data* sd,
  1084. const char* command, const char* message)
  1085. {
  1086. char map_name[MAP_NAME_LENGTH];
  1087. unsigned short mapindex;
  1088. int x = 0, y = 0;
  1089. int m = -1;
  1090. nullpo_retr(-1, sd);
  1091. memset(map_name, '\0', sizeof(map_name));
  1092. if (!message || !*message || sscanf(message, "%15s %d %d", map_name, &x, &y) < 1) {
  1093. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1094. return -1;
  1095. }
  1096. if (x <= 0)
  1097. x = rand() % 399 + 1;
  1098. if (y <= 0)
  1099. y = rand() % 399 + 1;
  1100. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1101. strcat(map_name, ".gat");
  1102. mapindex = mapindex_name2id(map_name);
  1103. if (mapindex)
  1104. m = map_mapindex2mapid(mapindex);
  1105. if (!mapindex || m < 0) {
  1106. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1107. return -1;
  1108. }
  1109. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1110. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1111. clif_displaymessage(fd, msg_table[247]);
  1112. return -1;
  1113. }
  1114. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1115. clif_displaymessage(fd, msg_table[248]);
  1116. return -1;
  1117. }
  1118. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1119. clif_displaymessage(fd, msg_table[0]); // Warped.
  1120. else {
  1121. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1122. return -1;
  1123. }
  1124. } else {
  1125. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1126. return -1;
  1127. }
  1128. return 0;
  1129. }
  1130. /*==========================================
  1131. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1132. *------------------------------------------
  1133. */
  1134. int atcommand_where(
  1135. const int fd, struct map_session_data* sd,
  1136. const char* command, const char* message)
  1137. {
  1138. struct map_session_data *pl_sd = NULL;
  1139. int GM_level, pl_GM_level;
  1140. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1141. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1142. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1143. return -1;
  1144. }
  1145. pl_sd = map_nick2sd(atcmd_player_name);
  1146. nullpo_retr(-1, sd);
  1147. if (pl_sd == NULL)
  1148. return -1;
  1149. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  1150. return -1;
  1151. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1152. pl_GM_level = pc_isGM(pl_sd);
  1153. if (battle_config.hide_GM_session) {
  1154. if(!(GM_level >= pl_GM_level)) {
  1155. if (!(battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid)) {
  1156. return -1;
  1157. }
  1158. }
  1159. }
  1160. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1161. atcmd_player_name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1162. clif_displaymessage(fd, atcmd_output);
  1163. return 0;
  1164. }
  1165. /*==========================================
  1166. *
  1167. *------------------------------------------
  1168. */
  1169. int atcommand_jumpto(
  1170. const int fd, struct map_session_data* sd,
  1171. const char* command, const char* message)
  1172. {
  1173. struct map_session_data *pl_sd = NULL;
  1174. nullpo_retr(-1, sd);
  1175. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1176. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1177. return -1;
  1178. }
  1179. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1180. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1181. return -1;
  1182. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1183. return -1;
  1184. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1185. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1186. clif_displaymessage(fd, msg_table[247]);
  1187. return -1;
  1188. }
  1189. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1190. clif_displaymessage(fd, msg_table[248]);
  1191. return -1;
  1192. }
  1193. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1194. sprintf(atcmd_output, msg_table[4], atcmd_player_name); // Jump to %s
  1195. clif_displaymessage(fd, atcmd_output);
  1196. } else {
  1197. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1198. return -1;
  1199. }
  1200. return 0;
  1201. }
  1202. /*==========================================
  1203. *
  1204. *------------------------------------------
  1205. */
  1206. int atcommand_jump(
  1207. const int fd, struct map_session_data* sd,
  1208. const char* command, const char* message)
  1209. {
  1210. int x = 0, y = 0;
  1211. nullpo_retr(-1, sd);
  1212. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1213. sscanf(message, "%d %d", &x, &y);
  1214. if (x <= 0) //If coordinates are 'wrong', random jump.
  1215. x = -1;
  1216. if (y <= 0)
  1217. y = -1;
  1218. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarp || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1219. clif_displaymessage(fd, msg_table[248]);
  1220. return -1;
  1221. }
  1222. pc_setpos(sd, sd->mapindex, x, y, 3);
  1223. sprintf(atcmd_output, msg_table[5], sd->bl.x, sd->bl.y); // Jump to %d %d
  1224. clif_displaymessage(fd, atcmd_output);
  1225. return 0;
  1226. }
  1227. /*==========================================
  1228. * @who3 = Player name, his location
  1229. *------------------------------------------
  1230. */
  1231. int atcommand_who3(
  1232. const int fd, struct map_session_data* sd,
  1233. const char* command, const char* message)
  1234. {
  1235. char temp0[100];
  1236. struct map_session_data *pl_sd, **pl_allsd;
  1237. int i, j, count, users;
  1238. int pl_GM_level, GM_level;
  1239. char match_text[100];
  1240. char player_name[NAME_LENGTH];
  1241. nullpo_retr(-1, sd);
  1242. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1243. memset(match_text, '\0', sizeof(match_text));
  1244. memset(player_name, '\0', sizeof(player_name));
  1245. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1246. strcpy(match_text, "");
  1247. for (j = 0; match_text[j]; j++)
  1248. match_text[j] = tolower(match_text[j]);
  1249. count = 0;
  1250. GM_level = pc_isGM(sd);
  1251. pl_allsd = map_getallusers(&users);
  1252. for (i = 0; i < users; i++) {
  1253. if ((pl_sd = pl_allsd[i])) {
  1254. pl_GM_level = pc_isGM(pl_sd);
  1255. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1256. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1257. for (j = 0; player_name[j]; j++)
  1258. player_name[j] = tolower(player_name[j]);
  1259. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1260. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1261. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1262. } else {
  1263. atcmd_output[0]=0;
  1264. }
  1265. //Player name
  1266. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1267. strcat(atcmd_output,temp0);
  1268. //Player title, if exists
  1269. if (pl_GM_level > 0) {
  1270. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1271. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1272. strcat(atcmd_output,temp0);
  1273. }
  1274. //Players Location: map x y
  1275. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1276. strcat(atcmd_output,temp0);
  1277. clif_displaymessage(fd, atcmd_output);
  1278. count++;
  1279. }
  1280. }
  1281. }
  1282. }
  1283. if (count == 0)
  1284. clif_displaymessage(fd, msg_table[28]); // No player found.
  1285. else if (count == 1)
  1286. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1287. else {
  1288. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1289. clif_displaymessage(fd, atcmd_output);
  1290. }
  1291. return 0;
  1292. }
  1293. /*==========================================
  1294. * Player name, BLevel, Job,
  1295. *------------------------------------------
  1296. */
  1297. int atcommand_who2(
  1298. const int fd, struct map_session_data* sd,
  1299. const char* command, const char* message)
  1300. {
  1301. char temp0[100];
  1302. struct map_session_data *pl_sd, **pl_allsd;
  1303. int i, j, count, users;
  1304. int pl_GM_level, GM_level;
  1305. char match_text[100];
  1306. char player_name[NAME_LENGTH];
  1307. nullpo_retr(-1, sd);
  1308. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1309. memset(match_text, '\0', sizeof(match_text));
  1310. memset(player_name, '\0', sizeof(player_name));
  1311. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1312. strcpy(match_text, "");
  1313. for (j = 0; match_text[j]; j++)
  1314. match_text[j] = tolower(match_text[j]);
  1315. count = 0;
  1316. GM_level = pc_isGM(sd);
  1317. pl_allsd = map_getallusers(&users);
  1318. for (i = 0; i < users; i++) {
  1319. if ((pl_sd = pl_allsd[i])) {
  1320. pl_GM_level = pc_isGM(pl_sd);
  1321. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1322. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1323. for (j = 0; player_name[j]; j++)
  1324. player_name[j] = tolower(player_name[j]);
  1325. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1326. //Players Name
  1327. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1328. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1329. //Player title, if exists
  1330. if (pl_GM_level > 0) {
  1331. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1332. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1333. strcat(atcmd_output,temp0);
  1334. }
  1335. //Players Base Level / Job name
  1336. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1337. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1338. strcat(atcmd_output,temp0);
  1339. clif_displaymessage(fd, atcmd_output);
  1340. count++;
  1341. }
  1342. }
  1343. }
  1344. }
  1345. if (count == 0)
  1346. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1347. else if (count == 1)
  1348. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1349. else {
  1350. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1351. clif_displaymessage(fd, atcmd_output);
  1352. }
  1353. return 0;
  1354. }
  1355. /*==========================================
  1356. * Player name, Playrs Party / Guild name
  1357. *------------------------------------------
  1358. */
  1359. int atcommand_who(
  1360. const int fd, struct map_session_data* sd,
  1361. const char* command, const char* message)
  1362. {
  1363. char temp0[100];
  1364. struct map_session_data *pl_sd, **pl_allsd;
  1365. int i, j, count, users;
  1366. int pl_GM_level, GM_level;
  1367. char match_text[100];
  1368. char player_name[NAME_LENGTH];
  1369. struct guild *g;
  1370. struct party *p;
  1371. nullpo_retr(-1, sd);
  1372. memset(temp0, '\0', sizeof(temp0));
  1373. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1374. memset(match_text, '\0', sizeof(match_text));
  1375. memset(player_name, '\0', sizeof(player_name));
  1376. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1377. strcpy(match_text, "");
  1378. for (j = 0; match_text[j]; j++)
  1379. match_text[j] = tolower(match_text[j]);
  1380. count = 0;
  1381. GM_level = pc_isGM(sd);
  1382. pl_allsd = map_getallusers(&users);
  1383. for (i = 0; i < users; i++) {
  1384. if ((pl_sd = pl_allsd[i])) {
  1385. pl_GM_level = pc_isGM(pl_sd);
  1386. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1387. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1388. for (j = 0; player_name[j]; j++)
  1389. player_name[j] = tolower(player_name[j]);
  1390. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1391. g = guild_search(pl_sd->status.guild_id);
  1392. p = party_search(pl_sd->status.party_id);
  1393. //Players Name
  1394. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1395. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1396. //Player title, if exists
  1397. if (pl_GM_level > 0) {
  1398. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1399. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1400. strcat(atcmd_output,temp0);
  1401. }
  1402. //Players Party if exists
  1403. if (p != NULL) {
  1404. //sprintf(temp0," | Party: '%s'", p->name);
  1405. sprintf(temp0, msg_txt(335), p->name);
  1406. strcat(atcmd_output,temp0);
  1407. }
  1408. //Players Guild if exists
  1409. if (g != NULL) {
  1410. //sprintf(temp0," | Guild: '%s'", g->name);
  1411. sprintf(temp0, msg_txt(336), g->name);
  1412. strcat(atcmd_output,temp0);
  1413. }
  1414. clif_displaymessage(fd, atcmd_output);
  1415. count++;
  1416. }
  1417. }
  1418. }
  1419. }
  1420. if (count == 0)
  1421. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1422. else if (count == 1)
  1423. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1424. else {
  1425. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1426. clif_displaymessage(fd, atcmd_output);
  1427. }
  1428. return 0;
  1429. }
  1430. /*==========================================
  1431. *
  1432. *------------------------------------------
  1433. */
  1434. int atcommand_whomap3(
  1435. const int fd, struct map_session_data* sd,
  1436. const char* command, const char* message)
  1437. {
  1438. struct map_session_data *pl_sd, **pl_allsd;
  1439. int i, count, users;
  1440. int pl_GM_level, GM_level;
  1441. int map_id;
  1442. char map_name[MAP_NAME_LENGTH];
  1443. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1444. memset(map_name, '\0', sizeof(map_name));
  1445. if (!message || !*message)
  1446. map_id = sd->bl.m;
  1447. else {
  1448. sscanf(message, "%15s", map_name);
  1449. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1450. strcat(map_name, ".gat");
  1451. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1452. map_id = sd->bl.m;
  1453. }
  1454. count = 0;
  1455. GM_level = pc_isGM(sd);
  1456. pl_allsd = map_getallusers(&users);
  1457. for (i = 0; i < users; i++) {
  1458. if ((pl_sd = pl_allsd[i])) {
  1459. pl_GM_level = pc_isGM(pl_sd);
  1460. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1461. if (pl_sd->bl.m == map_id) {
  1462. if (pl_GM_level > 0)
  1463. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1464. else
  1465. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1466. clif_displaymessage(fd, atcmd_output);
  1467. count++;
  1468. }
  1469. }
  1470. }
  1471. }
  1472. if (count == 0)
  1473. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1474. else if (count == 1)
  1475. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1476. else {
  1477. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1478. }
  1479. clif_displaymessage(fd, atcmd_output);
  1480. return 0;
  1481. }
  1482. /*==========================================
  1483. *
  1484. *------------------------------------------
  1485. */
  1486. int atcommand_whomap2(
  1487. const int fd, struct map_session_data* sd,
  1488. const char* command, const char* message)
  1489. {
  1490. struct map_session_data *pl_sd, **pl_allsd;
  1491. int i, count, users;
  1492. int pl_GM_level, GM_level;
  1493. int map_id = 0;
  1494. char map_name[MAP_NAME_LENGTH];
  1495. nullpo_retr(-1, sd);
  1496. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1497. memset(map_name, '\0', sizeof(map_name));
  1498. if (!message || !*message)
  1499. map_id = sd->bl.m;
  1500. else {
  1501. sscanf(message, "%15s", map_name);
  1502. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1503. strcat(map_name, ".gat");
  1504. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1505. map_id = sd->bl.m;
  1506. }
  1507. count = 0;
  1508. GM_level = pc_isGM(sd);
  1509. pl_allsd = map_getallusers(&users);
  1510. for (i = 0; i < users; i++) {
  1511. if ((pl_sd = pl_allsd[i])) {
  1512. pl_GM_level = pc_isGM(pl_sd);
  1513. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1514. if (pl_sd->bl.m == map_id) {
  1515. if (pl_GM_level > 0)
  1516. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1517. else
  1518. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1519. clif_displaymessage(fd, atcmd_output);
  1520. count++;
  1521. }
  1522. }
  1523. }
  1524. }
  1525. if (count == 0)
  1526. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1527. else if (count == 1)
  1528. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1529. else {
  1530. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1531. }
  1532. clif_displaymessage(fd, atcmd_output);
  1533. return 0;
  1534. }
  1535. /*==========================================
  1536. *
  1537. *------------------------------------------
  1538. */
  1539. int atcommand_whomap(
  1540. const int fd, struct map_session_data* sd,
  1541. const char* command, const char* message)
  1542. {
  1543. char temp0[100];
  1544. char temp1[100];
  1545. struct map_session_data *pl_sd, **pl_allsd;
  1546. int i, count, users;
  1547. int pl_GM_level, GM_level;
  1548. int map_id = 0;
  1549. char map_name[MAP_NAME_LENGTH];
  1550. struct guild *g;
  1551. struct party *p;
  1552. nullpo_retr(-1, sd);
  1553. memset(temp0, '\0', sizeof(temp0));
  1554. memset(temp1, '\0', sizeof(temp1));
  1555. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1556. memset(map_name, '\0', sizeof(map_name));
  1557. if (!message || !*message)
  1558. map_id = sd->bl.m;
  1559. else {
  1560. sscanf(message, "%15s", map_name);
  1561. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1562. strcat(map_name, ".gat");
  1563. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1564. map_id = sd->bl.m;
  1565. }
  1566. count = 0;
  1567. GM_level = pc_isGM(sd);
  1568. pl_allsd = map_getallusers(&users);
  1569. for (i = 0; i < users; i++) {
  1570. if ((pl_sd = pl_allsd[i])) {
  1571. pl_GM_level = pc_isGM(pl_sd);
  1572. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1573. if (pl_sd->bl.m == map_id) {
  1574. g = guild_search(pl_sd->status.guild_id);
  1575. if (g == NULL)
  1576. sprintf(temp1, "None");
  1577. else
  1578. sprintf(temp1, "%s", g->name);
  1579. p = party_search(pl_sd->status.party_id);
  1580. if (p == NULL)
  1581. sprintf(temp0, "None");
  1582. else
  1583. sprintf(temp0, "%s", p->name);
  1584. if (pl_GM_level > 0)
  1585. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1586. else
  1587. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1588. clif_displaymessage(fd, atcmd_output);
  1589. count++;
  1590. }
  1591. }
  1592. }
  1593. }
  1594. if (count == 0)
  1595. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1596. else if (count == 1)
  1597. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1598. else {
  1599. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1600. }
  1601. clif_displaymessage(fd, atcmd_output);
  1602. return 0;
  1603. }
  1604. /*==========================================
  1605. *
  1606. *------------------------------------------
  1607. */
  1608. int atcommand_whogm(
  1609. const int fd, struct map_session_data* sd,
  1610. const char* command, const char* message)
  1611. {
  1612. char temp0[100];
  1613. char temp1[100];
  1614. struct map_session_data *pl_sd, **pl_allsd;
  1615. int i, j, count, users;
  1616. int pl_GM_level, GM_level;
  1617. char match_text[100];
  1618. char player_name[NAME_LENGTH];
  1619. struct guild *g;
  1620. struct party *p;
  1621. nullpo_retr(-1, sd);
  1622. memset(temp0, '\0', sizeof(temp0));
  1623. memset(temp1, '\0', sizeof(temp1));
  1624. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1625. memset(match_text, '\0', sizeof(match_text));
  1626. memset(player_name, '\0', sizeof(player_name));
  1627. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1628. strcpy(match_text, "");
  1629. for (j = 0; match_text[j]; j++)
  1630. match_text[j] = tolower(match_text[j]);
  1631. count = 0;
  1632. GM_level = pc_isGM(sd);
  1633. pl_allsd = map_getallusers(&users);
  1634. for (i = 0; i < users; i++) {
  1635. if ((pl_sd = pl_allsd[i])) {
  1636. pl_GM_level = pc_isGM(pl_sd);
  1637. if (pl_GM_level > 0) {
  1638. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1639. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1640. for (j = 0; player_name[j]; j++)
  1641. player_name[j] = tolower(player_name[j]);
  1642. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1643. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1644. clif_displaymessage(fd, atcmd_output);
  1645. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1646. clif_displaymessage(fd, atcmd_output);
  1647. g = guild_search(pl_sd->status.guild_id);
  1648. if (g == NULL)
  1649. sprintf(temp1, "None");
  1650. else
  1651. sprintf(temp1, "%s", g->name);
  1652. p = party_search(pl_sd->status.party_id);
  1653. if (p == NULL)
  1654. sprintf(temp0, "None");
  1655. else
  1656. sprintf(temp0, "%s", p->name);
  1657. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1658. clif_displaymessage(fd, atcmd_output);
  1659. count++;
  1660. }
  1661. }
  1662. }
  1663. }
  1664. }
  1665. if (count == 0)
  1666. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1667. else if (count == 1)
  1668. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1669. else {
  1670. sprintf(atcmd_output, msg_table[152], count); // %d GMs found.
  1671. clif_displaymessage(fd, atcmd_output);
  1672. }
  1673. return 0;
  1674. }
  1675. int atcommand_whozeny(
  1676. const int fd, struct map_session_data* sd,
  1677. const char* command, const char* message)
  1678. {
  1679. struct map_session_data *pl_sd, **pl_allsd;
  1680. int i, j, count,c, users;
  1681. char match_text[100];
  1682. char player_name[NAME_LENGTH];
  1683. int *zeny;
  1684. int *counted;
  1685. nullpo_retr(-1, sd);
  1686. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1687. memset(match_text, '\0', sizeof(match_text));
  1688. memset(player_name, '\0', sizeof(player_name));
  1689. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1690. strcpy(match_text, "");
  1691. for (j = 0; match_text[j]; j++)
  1692. match_text[j] = tolower(match_text[j]);
  1693. count = 0;
  1694. pl_allsd = map_getallusers(&users);
  1695. if (users < 1)
  1696. {
  1697. clif_displaymessage(fd, msg_table[28]); // No player found.
  1698. return 0;
  1699. }
  1700. zeny = (int *)aCallocA(users, sizeof(int));
  1701. counted = (int *)aCallocA(users, sizeof(int));
  1702. for (i = 0; i < users; i++) {
  1703. if ((pl_sd = pl_allsd[i])) {
  1704. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1705. for (j = 0; player_name[j]; j++)
  1706. player_name[j] = tolower(player_name[j]);
  1707. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1708. zeny[count]=pl_sd->status.zeny;
  1709. counted[i]=0;
  1710. count++;
  1711. }
  1712. }
  1713. }
  1714. qsort(zeny, count, sizeof(int), hightolow_compare);
  1715. for (c = 0; c < count && c < 50; c++) {
  1716. if(!zeny[c])
  1717. continue;
  1718. for (i = 0; i < users; i++) {
  1719. if(!zeny[c])
  1720. continue;
  1721. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1722. if(pl_sd->status.zeny==zeny[c]) {
  1723. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1724. clif_displaymessage(fd, atcmd_output);
  1725. zeny[c]=0;
  1726. counted[i]=1;
  1727. }
  1728. }
  1729. }
  1730. }
  1731. if (count == 0)
  1732. clif_displaymessage(fd, msg_table[28]); // No player found.
  1733. else if (count == 1)
  1734. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1735. else {
  1736. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1737. clif_displaymessage(fd, atcmd_output);
  1738. }
  1739. aFree(zeny);
  1740. aFree(counted);
  1741. return 0;
  1742. }
  1743. // cause random emote on all online players [Valaris]
  1744. int atcommand_happyhappyjoyjoy(
  1745. const int fd, struct map_session_data* sd,
  1746. const char* command, const char* message)
  1747. {
  1748. struct map_session_data *pl_sd, **pl_allsd;
  1749. int i,e, users;
  1750. nullpo_retr(-1, sd);
  1751. pl_allsd = map_getallusers(&users);
  1752. for (i = 0; i < users; i++) {
  1753. if ((pl_sd = pl_allsd[i])) {
  1754. e=rand()%40;
  1755. if(e==34)
  1756. e = 0;
  1757. clif_emotion(&pl_sd->bl,e);
  1758. }
  1759. }
  1760. return 0;
  1761. }
  1762. /*==========================================
  1763. *
  1764. *------------------------------------------
  1765. */
  1766. int atcommand_save(
  1767. const int fd, struct map_session_data* sd,
  1768. const char* command, const char* message)
  1769. {
  1770. nullpo_retr(-1, sd);
  1771. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1772. if (sd->status.pet_id > 0 && sd->pd)
  1773. intif_save_petdata(sd->status.account_id, &sd->pet);
  1774. chrif_save(sd,0);
  1775. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1776. return 0;
  1777. }
  1778. /*==========================================
  1779. *
  1780. *------------------------------------------
  1781. */
  1782. int atcommand_load(
  1783. const int fd, struct map_session_data* sd,
  1784. const char* command, const char* message)
  1785. {
  1786. int m;
  1787. nullpo_retr(-1, sd);
  1788. m = map_mapindex2mapid(sd->status.save_point.map);
  1789. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1790. clif_displaymessage(fd, msg_table[249]);
  1791. return -1;
  1792. }
  1793. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1794. clif_displaymessage(fd, msg_table[248]);
  1795. return -1;
  1796. }
  1797. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1798. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1799. return 0;
  1800. }
  1801. /*==========================================
  1802. *
  1803. *------------------------------------------
  1804. */
  1805. int atcommand_speed(
  1806. const int fd, struct map_session_data* sd,
  1807. const char* command, const char* message)
  1808. {
  1809. int speed;
  1810. nullpo_retr(-1, sd);
  1811. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1812. if (!message || !*message) {
  1813. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1814. clif_displaymessage(fd, atcmd_output);
  1815. return -1;
  1816. }
  1817. speed = atoi(message);
  1818. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1819. sd->speed = speed;
  1820. //sd->walktimer = x;
  1821. //この文を追加 by れ�
  1822. clif_updatestatus(sd, SP_SPEED);
  1823. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1824. } else {
  1825. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1826. clif_displaymessage(fd, atcmd_output);
  1827. return -1;
  1828. }
  1829. return 0;
  1830. }
  1831. /*==========================================
  1832. *
  1833. *------------------------------------------
  1834. */
  1835. int atcommand_storage(
  1836. const int fd, struct map_session_data* sd,
  1837. const char* command, const char* message)
  1838. {
  1839. struct storage *stor; //changes from Freya/Yor
  1840. nullpo_retr(-1, sd);
  1841. if (sd->state.storage_flag) {
  1842. clif_displaymessage(fd, msg_table[250]);
  1843. return -1;
  1844. }
  1845. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1846. clif_displaymessage(fd, msg_table[250]);
  1847. return -1;
  1848. }
  1849. storage_storageopen(sd);
  1850. return 0;
  1851. }
  1852. /*==========================================
  1853. *
  1854. *------------------------------------------
  1855. */
  1856. int atcommand_guildstorage(
  1857. const int fd, struct map_session_data* sd,
  1858. const char* command, const char* message)
  1859. {
  1860. struct storage *stor; //changes from Freya/Yor
  1861. nullpo_retr(-1, sd);
  1862. if (sd->status.guild_id > 0) {
  1863. if (sd->state.storage_flag) {
  1864. clif_displaymessage(fd, msg_table[251]);
  1865. return -1;
  1866. }
  1867. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1868. clif_displaymessage(fd, msg_table[251]);
  1869. return -1;
  1870. }
  1871. storage_guild_storageopen(sd);
  1872. } else {
  1873. clif_displaymessage(fd, msg_table[252]);
  1874. return -1;
  1875. }
  1876. return 0;
  1877. }
  1878. /*==========================================
  1879. *
  1880. *------------------------------------------
  1881. */
  1882. int atcommand_option(
  1883. const int fd, struct map_session_data* sd,
  1884. const char* command, const char* message)
  1885. {
  1886. int param1 = 0, param2 = 0, param3 = 0;
  1887. nullpo_retr(-1, sd);
  1888. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1889. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1890. return -1;
  1891. }
  1892. sd->sc.opt1 = param1;
  1893. sd->sc.opt2 = param2;
  1894. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1895. if (sd->status.class_ == JOB_BABY_MERCHANT)
  1896. clif_cart_itemlist(sd);
  1897. clif_cart_equiplist(sd);
  1898. clif_updatestatus(sd, SP_CARTINFO);
  1899. }
  1900. pc_setoption(sd, param3);
  1901. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1902. return 0;
  1903. }
  1904. /*==========================================
  1905. *
  1906. *------------------------------------------
  1907. */
  1908. int atcommand_hide(
  1909. const int fd, struct map_session_data* sd,
  1910. const char* command, const char* message)
  1911. {
  1912. nullpo_retr(-1, sd);
  1913. if (sd->sc.option & OPTION_INVISIBLE) {
  1914. sd->sc.option &= ~OPTION_INVISIBLE;
  1915. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1916. } else {
  1917. sd->sc.option |= OPTION_INVISIBLE;
  1918. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1919. }
  1920. clif_changeoption(&sd->bl);
  1921. return 0;
  1922. }
  1923. /*==========================================
  1924. * 転職する upperを指定すると転生や養子にもなれる
  1925. *------------------------------------------
  1926. */
  1927. int atcommand_jobchange(
  1928. const int fd, struct map_session_data* sd,
  1929. const char* command, const char* message)
  1930. {
  1931. int job = 0, upper = 0;
  1932. nullpo_retr(-1, sd);
  1933. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1934. int i, found = 0;
  1935. const struct { char name[16]; int id; } jobs[] = {
  1936. { "novice", 0 },
  1937. { "swordsman", 1 },
  1938. { "mage", 2 },
  1939. { "archer", 3 },
  1940. { "acolyte", 4 },
  1941. { "merchant", 5 },
  1942. { "thief", 6 },
  1943. { "knight", 7 },
  1944. { "priest", 8 },
  1945. { "priestess", 8 },
  1946. { "wizard", 9 },
  1947. { "blacksmith", 10 },
  1948. { "hunter", 11 },
  1949. { "assassin", 12 },
  1950. { "crusader", 14 },
  1951. { "monk", 15 },
  1952. { "sage", 16 },
  1953. { "rogue", 17 },
  1954. { "alchemist", 18 },
  1955. { "bard", 19 },
  1956. { "dancer", 20 },
  1957. { "super novice", 23 },
  1958. { "supernovice", 23 },
  1959. { "gunslinger", 24 },
  1960. { "gunner", 24 },
  1961. { "ninja", 25 },
  1962. { "high novice", 4001 },
  1963. { "swordsman high", 4002 },
  1964. { "mage high", 4003 },
  1965. { "archer high", 4004 },
  1966. { "acolyte high", 4005 },
  1967. { "merchant high", 4006 },
  1968. { "thief high", 4007 },
  1969. { "lord knight", 4008 },
  1970. { "high priest", 4009 },
  1971. { "high priestess", 4009 },
  1972. { "high wizard", 4010 },
  1973. { "whitesmith", 4011 },
  1974. { "sniper", 4012 },
  1975. { "assassin cross", 4013 },
  1976. { "paladin", 4015 },
  1977. { "champion", 4016 },
  1978. { "professor", 4017 },
  1979. { "stalker", 4018 },
  1980. { "creator", 4019 },
  1981. { "clown", 4020 },
  1982. { "gypsy", 4021 },
  1983. { "baby novice", 4023 },
  1984. { "baby swordsman", 4024 },
  1985. { "baby mage", 4025 },
  1986. { "baby archer", 4026 },
  1987. { "baby acolyte", 4027 },
  1988. { "baby merchant", 4028 },
  1989. { "baby thief", 4029 },
  1990. { "baby knight", 4030 },
  1991. { "baby priest", 4031 },
  1992. { "baby priestess", 4031 },
  1993. { "baby wizard", 4032 },
  1994. { "baby blacksmith",4033 },
  1995. { "baby hunter", 4034 },
  1996. { "baby assassin", 4035 },
  1997. { "baby crusader", 4037 },
  1998. { "baby monk", 4038 },
  1999. { "baby sage", 4039 },
  2000. { "baby rogue", 4040 },
  2001. { "baby alchemist", 4041 },
  2002. { "baby bard", 4042 },
  2003. { "baby dancer", 4043 },
  2004. { "super baby", 4045 },
  2005. { "taekwon", 4046 },
  2006. { "taekwon boy", 4046 },
  2007. { "taekwon girl", 4046 },
  2008. { "star gladiator", 4047 },
  2009. { "soul linker", 4049 },
  2010. };
  2011. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2012. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2013. job = jobs[i].id;
  2014. upper = 0;
  2015. found = 1;
  2016. break;
  2017. }
  2018. }
  2019. if (!found) {
  2020. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2021. return -1;
  2022. }
  2023. }
  2024. if (job == 37 ||job == 45)
  2025. return 0;
  2026. if ((job >= 0 && job < MAX_PC_CLASS))
  2027. {
  2028. int j;
  2029. for (j=0; j < MAX_INVENTORY; j++) {
  2030. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2031. pc_unequipitem(sd, j, 3);
  2032. }
  2033. if (pc_jobchange(sd, job, upper) == 0)
  2034. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  2035. else {
  2036. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  2037. return -1;
  2038. }
  2039. } else {
  2040. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2041. return -1;
  2042. }
  2043. return 0;
  2044. }
  2045. /*==========================================
  2046. *
  2047. *------------------------------------------
  2048. */
  2049. int atcommand_die(
  2050. const int fd, struct map_session_data* sd,
  2051. const char* command, const char* message)
  2052. {
  2053. nullpo_retr(-1, sd);
  2054. clif_specialeffect(&sd->bl,450,1);
  2055. pc_damage(NULL, sd, sd->status.hp);
  2056. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  2057. return 0;
  2058. }
  2059. /*==========================================
  2060. *
  2061. *------------------------------------------
  2062. */
  2063. int atcommand_kill(
  2064. const int fd, struct map_session_data* sd,
  2065. const char* command, const char* message)
  2066. {
  2067. struct map_session_data *pl_sd;
  2068. nullpo_retr(-1, sd);
  2069. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2070. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2071. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2072. return -1;
  2073. }
  2074. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2075. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2076. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  2077. clif_displaymessage(fd, msg_table[14]); // Character killed.
  2078. } else {
  2079. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  2080. return -1;
  2081. }
  2082. } else {
  2083. clif_displaymessage(fd, msg_table[3]); // Character not found.
  2084. return -1;
  2085. }
  2086. return 0;
  2087. }
  2088. /*==========================================
  2089. *
  2090. *------------------------------------------
  2091. */
  2092. int atcommand_alive(
  2093. const int fd, struct map_session_data* sd,
  2094. const char* command, const char* message)
  2095. {
  2096. nullpo_retr(-1, sd);
  2097. if (pc_isdead(sd)) {
  2098. sd->status.hp = sd->status.max_hp;
  2099. sd->status.sp = sd->status.max_sp;
  2100. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2101. pc_setstand(sd);
  2102. if (battle_config.pc_invincible_time > 0)
  2103. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  2104. clif_updatestatus(sd, SP_HP);
  2105. clif_updatestatus(sd, SP_SP);
  2106. clif_resurrection(&sd->bl, 1);
  2107. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  2108. return 0;
  2109. }
  2110. return -1;
  2111. }
  2112. /*==========================================
  2113. * +kamic [LuzZza]
  2114. *------------------------------------------
  2115. */
  2116. int atcommand_kami(
  2117. const int fd, struct map_session_data* sd,
  2118. const char* command, const char* message)
  2119. {
  2120. unsigned long color=0;
  2121. nullpo_retr(-1, sd);
  2122. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2123. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2124. if (!message || !*message) {
  2125. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2126. return -1;
  2127. }
  2128. sscanf(message, "%199[^\n]", atcmd_output);
  2129. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2130. } else {
  2131. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2132. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2133. return -1;
  2134. }
  2135. if(color < 0 || color > 0xFFFFFF) {
  2136. clif_displaymessage(fd, "Invalid color.");
  2137. return -1;
  2138. }
  2139. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2140. }
  2141. return 0;
  2142. }
  2143. /*==========================================
  2144. *
  2145. *------------------------------------------
  2146. */
  2147. int atcommand_heal(
  2148. const int fd, struct map_session_data* sd,
  2149. const char* command, const char* message)
  2150. {
  2151. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2152. nullpo_retr(-1, sd);
  2153. sscanf(message, "%d %d", &hp, &sp);
  2154. if (hp == 0 && sp == 0) {
  2155. hp = sd->status.max_hp - sd->status.hp;
  2156. sp = sd->status.max_sp - sd->status.sp;
  2157. } else {
  2158. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2159. hp = sd->status.max_hp - sd->status.hp;
  2160. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2161. hp = 1 - sd->status.hp;
  2162. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2163. sp = sd->status.max_sp - sd->status.sp;
  2164. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2165. sp = 1 - sd->status.sp;
  2166. }
  2167. if (hp > 0) // display like heal
  2168. clif_heal(fd, SP_HP, hp);
  2169. else if (hp < 0) // display like damage
  2170. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2171. if (sp > 0) // no display when we lost SP
  2172. clif_heal(fd, SP_SP, sp);
  2173. if (hp != 0 || sp != 0) {
  2174. pc_heal(sd, hp, sp);
  2175. if (hp >= 0 && sp >= 0)
  2176. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2177. else
  2178. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2179. } else {
  2180. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2181. return -1;
  2182. }
  2183. return 0;
  2184. }
  2185. /*==========================================
  2186. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2187. *------------------------------------------
  2188. */
  2189. int atcommand_item(
  2190. const int fd, struct map_session_data* sd,
  2191. const char* command, const char* message)
  2192. {
  2193. char item_name[100];
  2194. int number = 0, item_id, flag;
  2195. struct item item_tmp;
  2196. struct item_data *item_data;
  2197. int get_count, i, pet_id;
  2198. nullpo_retr(-1, sd);
  2199. memset(item_name, '\0', sizeof(item_name));
  2200. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2201. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2202. return -1;
  2203. }
  2204. if (number <= 0)
  2205. number = 1;
  2206. item_id = 0;
  2207. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2208. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2209. item_id = item_data->nameid;
  2210. if (item_id >= 500) {
  2211. get_count = number;
  2212. // check pet egg
  2213. pet_id = search_petDB_index(item_id, PET_EGG);
  2214. if (item_data->type == 4 || item_data->type == 5 ||
  2215. item_data->type == 7 || item_data->type == 8) {
  2216. get_count = 1;
  2217. }
  2218. for (i = 0; i < number; i += get_count) {
  2219. // if pet egg
  2220. if (pet_id >= 0) {
  2221. sd->catch_target_class = pet_db[pet_id].class_;
  2222. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2223. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2224. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2225. 100, 0, 1, pet_db[pet_id].jname);
  2226. // if not pet egg
  2227. } else {
  2228. memset(&item_tmp, 0, sizeof(item_tmp));
  2229. item_tmp.nameid = item_id;
  2230. item_tmp.identify = 1;
  2231. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2232. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2233. }
  2234. }
  2235. //Logs (A)dmins items [Lupus]
  2236. if(log_config.pick > 0 ) {
  2237. log_pick(sd, "A", 0, item_id, number, NULL);
  2238. }
  2239. //Logs
  2240. clif_displaymessage(fd, msg_table[18]); // Item created.
  2241. } else {
  2242. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2243. return -1;
  2244. }
  2245. return 0;
  2246. }
  2247. /*==========================================
  2248. *
  2249. *------------------------------------------
  2250. */
  2251. int atcommand_item2(
  2252. const int fd, struct map_session_data* sd,
  2253. const char* command, const char* message)
  2254. {
  2255. struct item item_tmp;
  2256. struct item_data *item_data;
  2257. char item_name[100];
  2258. int item_id, number = 0;
  2259. int identify = 0, refine = 0, attr = 0;
  2260. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2261. int flag;
  2262. int loop, get_count, i;
  2263. nullpo_retr(-1, sd);
  2264. memset(item_name, '\0', sizeof(item_name));
  2265. 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) {
  2266. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2267. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2268. return -1;
  2269. }
  2270. if (number <= 0)
  2271. number = 1;
  2272. item_id = 0;
  2273. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2274. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2275. item_id = item_data->nameid;
  2276. if (item_id > 500) {
  2277. loop = 1;
  2278. get_count = number;
  2279. if (item_data->type == 4 || item_data->type == 5 ||
  2280. item_data->type == 7 || item_data->type == 8) {
  2281. loop = number;
  2282. get_count = 1;
  2283. if (item_data->type == 7) {
  2284. identify = 1;
  2285. refine = 0;
  2286. }
  2287. if (item_data->type == 8)
  2288. refine = 0;
  2289. if (refine > 10)
  2290. refine = 10;
  2291. } else {
  2292. identify = 1;
  2293. refine = attr = 0;
  2294. }
  2295. for (i = 0; i < loop; i++) {
  2296. memset(&item_tmp, 0, sizeof(item_tmp));
  2297. item_tmp.nameid = item_id;
  2298. item_tmp.identify = identify;
  2299. item_tmp.refine = refine;
  2300. item_tmp.attribute = attr;
  2301. item_tmp.card[0] = c1;
  2302. item_tmp.card[1] = c2;
  2303. item_tmp.card[2] = c3;
  2304. item_tmp.card[3] = c4;
  2305. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2306. clif_additem(sd, 0, 0, flag);
  2307. }
  2308. //Logs (A)dmins items [Lupus]
  2309. if(log_config.pick > 0 ) {
  2310. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2311. }
  2312. //Logs
  2313. clif_displaymessage(fd, msg_table[18]); // Item created.
  2314. } else {
  2315. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2316. return -1;
  2317. }
  2318. return 0;
  2319. }
  2320. /*==========================================
  2321. *
  2322. *------------------------------------------
  2323. */
  2324. int atcommand_itemreset(
  2325. const int fd, struct map_session_data* sd,
  2326. const char* command, const char* message)
  2327. {
  2328. int i;
  2329. nullpo_retr(-1, sd);
  2330. for (i = 0; i < MAX_INVENTORY; i++) {
  2331. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2332. //Logs (A)dmins items [Lupus]
  2333. if(log_config.pick > 0 ) {
  2334. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2335. }
  2336. //Logs
  2337. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2338. }
  2339. }
  2340. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2341. return 0;
  2342. }
  2343. /*==========================================
  2344. *
  2345. *------------------------------------------
  2346. */
  2347. int atcommand_itemcheck(
  2348. const int fd, struct map_session_data* sd,
  2349. const char* command, const char* message)
  2350. {
  2351. nullpo_retr(-1, sd);
  2352. pc_checkitem(sd);
  2353. return 0;
  2354. }
  2355. /*==========================================
  2356. * Atcommand @lvlup
  2357. *------------------------------------------
  2358. */
  2359. int atcommand_baselevelup(
  2360. const int fd, struct map_session_data* sd,
  2361. const char* command, const char* message)
  2362. {
  2363. int level=0, i=0;
  2364. nullpo_retr(-1, sd);
  2365. level = atoi(message);
  2366. if (!message || !*message || !level) {
  2367. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2368. return -1;
  2369. }
  2370. if (level > 0) {
  2371. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2372. clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
  2373. return -1;
  2374. } /* End Addition */
  2375. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2376. level = pc_maxbaselv(sd) - sd->status.base_level;
  2377. for (i = 1; i <= level; i++)
  2378. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2379. sd->status.base_level += (unsigned int)level;
  2380. clif_updatestatus(sd, SP_BASELEVEL);
  2381. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2382. clif_updatestatus(sd, SP_STATUSPOINT);
  2383. status_calc_pc(sd, 0);
  2384. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2385. clif_misceffect(&sd->bl, 0);
  2386. clif_displaymessage(fd, msg_table[21]); /* Base level raised. */
  2387. } else {
  2388. if (sd->status.base_level == 1) {
  2389. clif_displaymessage(fd, msg_table[158]); /* Base level can't go any lower. */
  2390. return -1;
  2391. }
  2392. level*=-1;
  2393. if ((unsigned int)level >= sd->status.base_level)
  2394. level = sd->status.base_level-1;
  2395. if (sd->status.status_point > 0) {
  2396. for (i = 0; i > -level; i--)
  2397. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2398. if (sd->status.status_point < 0)
  2399. sd->status.status_point = 0;
  2400. clif_updatestatus(sd, SP_STATUSPOINT);
  2401. } /* to add: remove status points from stats */
  2402. sd->status.base_level -= (unsigned int)level;
  2403. clif_updatestatus(sd, SP_BASELEVEL);
  2404. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2405. status_calc_pc(sd, 0);
  2406. clif_displaymessage(fd, msg_table[22]); /* Base level lowered. */
  2407. }
  2408. return 0;
  2409. }
  2410. /*==========================================
  2411. *
  2412. *------------------------------------------
  2413. */
  2414. int atcommand_joblevelup(
  2415. const int fd, struct map_session_data* sd,
  2416. const char* command, const char* message)
  2417. {
  2418. int level=0;
  2419. nullpo_retr(-1, sd);
  2420. level = atoi(message);
  2421. if (!message || !*message || !level) {
  2422. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2423. return -1;
  2424. }
  2425. if (level > 0) {
  2426. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2427. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2428. return -1;
  2429. }
  2430. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2431. level = pc_maxjoblv(sd) - sd->status.job_level;
  2432. sd->status.job_level += (unsigned int)level;
  2433. clif_updatestatus(sd, SP_JOBLEVEL);
  2434. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2435. sd->status.skill_point += level;
  2436. clif_updatestatus(sd, SP_SKILLPOINT);
  2437. status_calc_pc(sd, 0);
  2438. clif_misceffect(&sd->bl, 1);
  2439. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2440. } else {
  2441. if (sd->status.job_level == 1) {
  2442. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2443. return -1;
  2444. }
  2445. level *=-1;
  2446. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2447. level = sd->status.job_level-1;
  2448. sd->status.job_level -= (unsigned int)level;
  2449. clif_updatestatus(sd, SP_JOBLEVEL);
  2450. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2451. if (sd->status.skill_point < level)
  2452. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2453. sd->status.skill_point -= level;
  2454. if (sd->status.skill_point < 0)
  2455. sd->status.skill_point = 0;
  2456. clif_updatestatus(sd, SP_SKILLPOINT);
  2457. status_calc_pc(sd, 0);
  2458. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2459. }
  2460. return 0;
  2461. }
  2462. /*==========================================
  2463. * @help
  2464. *------------------------------------------
  2465. */
  2466. int atcommand_help(
  2467. const int fd, struct map_session_data* sd,
  2468. const char* command, const char* message)
  2469. {
  2470. char buf[2048], w1[2048], w2[2048];
  2471. int i, gm_level;
  2472. FILE* fp;
  2473. nullpo_retr(-1, sd);
  2474. memset(buf, '\0', sizeof(buf));
  2475. if ((fp = fopen(help_txt, "r")) != NULL) {
  2476. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2477. gm_level = pc_isGM(sd);
  2478. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2479. if (buf[0] == '/' && buf[1] == '/')
  2480. continue;
  2481. for (i = 0; buf[i] != '\0'; i++) {
  2482. if (buf[i] == '\r' || buf[i] == '\n') {
  2483. buf[i] = '\0';
  2484. break;
  2485. }
  2486. }
  2487. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2488. clif_displaymessage(fd, buf);
  2489. else if (gm_level >= atoi(w1))
  2490. clif_displaymessage(fd, w2);
  2491. }
  2492. fclose(fp);
  2493. } else {
  2494. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2495. return -1;
  2496. }
  2497. return 0;
  2498. }
  2499. /*==========================================
  2500. * @help2 - Char commands [Kayla]
  2501. *------------------------------------------
  2502. */
  2503. int atcommand_help2(
  2504. const int fd, struct map_session_data* sd,
  2505. const char* command, const char* message)
  2506. {
  2507. char buf[2048], w1[2048], w2[2048];
  2508. int i, gm_level;
  2509. FILE* fp;
  2510. nullpo_retr(-1, sd);
  2511. memset(buf, '\0', sizeof(buf));
  2512. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2513. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2514. gm_level = pc_isGM(sd);
  2515. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2516. if (buf[0] == '/' && buf[1] == '/')
  2517. continue;
  2518. for (i = 0; buf[i] != '\0'; i++) {
  2519. if (buf[i] == '\r' || buf[i] == '\n') {
  2520. buf[i] = '\0';
  2521. break;
  2522. }
  2523. }
  2524. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2525. clif_displaymessage(fd, buf);
  2526. else if (gm_level >= atoi(w1))
  2527. clif_displaymessage(fd, w2);
  2528. }
  2529. fclose(fp);
  2530. } else {
  2531. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2532. return -1;
  2533. }
  2534. return 0;
  2535. }
  2536. /*==========================================
  2537. * @gm
  2538. *------------------------------------------
  2539. */
  2540. int atcommand_gm(
  2541. const int fd, struct map_session_data* sd,
  2542. const char* command, const char* message)
  2543. {
  2544. char password[100];
  2545. nullpo_retr(-1, sd);
  2546. memset(password, '\0', sizeof(password));
  2547. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2548. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2549. return -1;
  2550. }
  2551. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2552. clif_displaymessage(fd, msg_table[50]); /* You already have some GM powers. */
  2553. return -1;
  2554. } else
  2555. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2556. return 0;
  2557. }
  2558. /*==========================================
  2559. *
  2560. *------------------------------------------
  2561. */
  2562. int atcommand_pvpoff(
  2563. const int fd, struct map_session_data* sd,
  2564. const char* command, const char* message)
  2565. {
  2566. struct map_session_data *pl_sd, **pl_allsd;
  2567. int i, users;
  2568. nullpo_retr(-1, sd);
  2569. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2570. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2571. return -1;
  2572. }
  2573. if (map[sd->bl.m].flag.pvp) {
  2574. map[sd->bl.m].flag.pvp = 0;
  2575. clif_send0199(sd->bl.m, 0);
  2576. pl_allsd = map_getallusers(&users);
  2577. for (i = 0; i < users; i++) { //人数分ループ
  2578. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2579. clif_pvpset(pl_sd, 0, 0, 2);
  2580. if (pl_sd->pvp_timer != -1) {
  2581. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2582. pl_sd->pvp_timer = -1;
  2583. }
  2584. }
  2585. }
  2586. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2587. } else {
  2588. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2589. return -1;
  2590. }
  2591. return 0;
  2592. }
  2593. /*==========================================
  2594. *
  2595. *------------------------------------------
  2596. */
  2597. int atcommand_pvpon(
  2598. const int fd, struct map_session_data* sd,
  2599. const char* command, const char* message)
  2600. {
  2601. struct map_session_data *pl_sd, **pl_allsd;
  2602. int i, users;
  2603. nullpo_retr(-1, sd);
  2604. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2605. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2606. return -1;
  2607. }
  2608. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2609. map[sd->bl.m].flag.pvp = 1;
  2610. clif_send0199(sd->bl.m, 1);
  2611. pl_allsd = map_getallusers(&users);
  2612. for (i = 0; i < users; i++) {
  2613. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2614. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2615. pl_sd->pvp_rank = 0;
  2616. pl_sd->pvp_lastusers = 0;
  2617. pl_sd->pvp_point = 5;
  2618. pl_sd->pvp_won = 0;
  2619. pl_sd->pvp_lost = 0;
  2620. }
  2621. }
  2622. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2623. } else {
  2624. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2625. return -1;
  2626. }
  2627. return 0;
  2628. }
  2629. /*==========================================
  2630. *
  2631. *------------------------------------------
  2632. */
  2633. int atcommand_gvgoff(
  2634. const int fd, struct map_session_data* sd,
  2635. const char* command, const char* message)
  2636. {
  2637. nullpo_retr(-1, sd);
  2638. if (map[sd->bl.m].flag.gvg) {
  2639. map[sd->bl.m].flag.gvg = 0;
  2640. clif_send0199(sd->bl.m, 0);
  2641. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2642. } else {
  2643. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2644. return -1;
  2645. }
  2646. return 0;
  2647. }
  2648. /*==========================================
  2649. *
  2650. *------------------------------------------
  2651. */
  2652. int atcommand_gvgon(
  2653. const int fd, struct map_session_data* sd,
  2654. const char* command, const char* message)
  2655. {
  2656. nullpo_retr(-1, sd);
  2657. if (!map[sd->bl.m].flag.gvg) {
  2658. map[sd->bl.m].flag.gvg = 1;
  2659. clif_send0199(sd->bl.m, 3);
  2660. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2661. } else {
  2662. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2663. return -1;
  2664. }
  2665. return 0;
  2666. }
  2667. /*==========================================
  2668. *
  2669. *------------------------------------------
  2670. */
  2671. int atcommand_model(
  2672. const int fd, struct map_session_data* sd,
  2673. const char* command, const char* message)
  2674. {
  2675. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2676. nullpo_retr(-1, sd);
  2677. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2678. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2679. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2680. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2681. clif_displaymessage(fd, atcmd_output);
  2682. return -1;
  2683. }
  2684. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2685. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2686. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2687. /* Removed because this check is TOO strange. [Skotlex]
  2688. //秒フ色変更
  2689. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2690. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2691. //秒フ色未実装職の判定
  2692. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2693. return -1;
  2694. } else {
  2695. */
  2696. pc_changelook(sd, LOOK_HAIR, hair_style);
  2697. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2698. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2699. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2700. // }
  2701. } else {
  2702. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2703. return -1;
  2704. }
  2705. return 0;
  2706. }
  2707. /*==========================================
  2708. * @dye && @ccolor
  2709. *------------------------------------------
  2710. */
  2711. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2712. {
  2713. int cloth_color = 0;
  2714. nullpo_retr(-1, sd);
  2715. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2716. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2717. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2718. clif_displaymessage(fd, atcmd_output);
  2719. return -1;
  2720. }
  2721. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2722. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2723. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2724. } else {
  2725. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2726. return -1;
  2727. }
  2728. return 0;
  2729. }
  2730. /*==========================================
  2731. * @hairstyle && @hstyle
  2732. *------------------------------------------
  2733. */
  2734. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2735. {
  2736. int hair_style = 0;
  2737. nullpo_retr(-1, sd);
  2738. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2739. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2740. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2741. clif_displaymessage(fd, atcmd_output);
  2742. return -1;
  2743. }
  2744. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2745. /* Removed because this check is TOO strange. [Skotlex]
  2746. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2747. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2748. return -1;
  2749. } else {
  2750. */
  2751. pc_changelook(sd, LOOK_HAIR, hair_style);
  2752. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2753. // }
  2754. } else {
  2755. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2756. return -1;
  2757. }
  2758. return 0;
  2759. }
  2760. /*==========================================
  2761. * @charhairstyle by [MouseJstr]
  2762. *------------------------------------------
  2763. */
  2764. int
  2765. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2766. const char* command, const char* message)
  2767. {
  2768. nullpo_retr(-1, sd);
  2769. return 0;
  2770. }
  2771. /*==========================================
  2772. * @haircolor && @hcolor
  2773. *------------------------------------------
  2774. */
  2775. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2776. {
  2777. int hair_color = 0;
  2778. nullpo_retr(-1, sd);
  2779. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2780. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2781. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2782. clif_displaymessage(fd, atcmd_output);
  2783. return -1;
  2784. }
  2785. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2786. /* Removed for being such a strange check. [Skotlex]
  2787. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2788. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2789. return -1;
  2790. } else {
  2791. */
  2792. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2793. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2794. // }
  2795. } else {
  2796. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2797. return -1;
  2798. }
  2799. return 0;
  2800. }
  2801. /*==========================================
  2802. * @go [city_number or city_name] - Updated by Harbin
  2803. *------------------------------------------
  2804. */
  2805. int atcommand_go(
  2806. const int fd, struct map_session_data* sd,
  2807. const char* command, const char* message)
  2808. {
  2809. int i;
  2810. int town;
  2811. char map_name[MAP_NAME_LENGTH];
  2812. int m;
  2813. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2814. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2815. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2816. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2817. { MAP_PAYON, 162, 233 }, // 3=Payon
  2818. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2819. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2820. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2821. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2822. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2823. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2824. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2825. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2826. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2827. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2828. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2829. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2830. { MAP_JAIL, 23, 61 }, // 16=Prison
  2831. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2832. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2833. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2834. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2835. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2836. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2837. };
  2838. nullpo_retr(-1, sd);
  2839. if(map[sd->bl.m].flag.nogo) {
  2840. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2841. return 0;
  2842. }
  2843. memset(map_name, '\0', sizeof(map_name));
  2844. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2845. // get the number
  2846. town = atoi(message);
  2847. // if no value, display all value
  2848. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2849. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2850. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2851. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2852. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2853. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2854. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2855. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2856. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2857. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2858. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2859. return -1;
  2860. } else {
  2861. // get possible name of the city and add .gat if not in the name
  2862. map_name[MAP_NAME_LENGTH-1] = '\0';
  2863. for (i = 0; map_name[i]; i++)
  2864. map_name[i] = tolower(map_name[i]);
  2865. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2866. strcat(map_name, ".gat");
  2867. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2868. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2869. town = 0;
  2870. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2871. town = 1;
  2872. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2873. town = 2;
  2874. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2875. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2876. town = 3;
  2877. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2878. town = 4;
  2879. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2880. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2881. town = 5;
  2882. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2883. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2884. town = 6;
  2885. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2886. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2887. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2888. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2889. town = 7;
  2890. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2891. town = 8;
  2892. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2893. town = 9;
  2894. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2895. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2896. town = 10;
  2897. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2898. town = 11;
  2899. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2900. town = 12;
  2901. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2902. town = 13;
  2903. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2904. town = 14;
  2905. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2906. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2907. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2908. town = 15;
  2909. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2910. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2911. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2912. town = 16;
  2913. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2914. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2915. town = 17;
  2916. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2917. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2918. town = 18;
  2919. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  2920. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  2921. town = 19;
  2922. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2923. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2924. town = 20;
  2925. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  2926. town = 21;
  2927. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2928. town = 22;
  2929. }
  2930. if (town >= -3 && town <= -1) {
  2931. if (sd->status.memo_point[-town-1].map) {
  2932. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2933. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2934. clif_displaymessage(fd, msg_table[247]);
  2935. return -1;
  2936. }
  2937. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2938. clif_displaymessage(fd, msg_table[248]);
  2939. return -1;
  2940. }
  2941. 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) {
  2942. clif_displaymessage(fd, msg_table[0]); // Warped.
  2943. } else {
  2944. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2945. return -1;
  2946. }
  2947. } else {
  2948. sprintf(atcmd_output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2949. clif_displaymessage(fd, atcmd_output);
  2950. return -1;
  2951. }
  2952. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2953. m = map_mapname2mapid((char *)data[town].map);
  2954. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2955. clif_displaymessage(fd, msg_table[247]);
  2956. return -1;
  2957. }
  2958. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2959. clif_displaymessage(fd, msg_table[248]);
  2960. return -1;
  2961. }
  2962. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2963. clif_displaymessage(fd, msg_table[0]); // Warped.
  2964. } else {
  2965. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2966. return -1;
  2967. }
  2968. } else { // if you arrive here, you have an error in town variable when reading of names
  2969. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2970. return -1;
  2971. }
  2972. }
  2973. return 0;
  2974. }
  2975. /*==========================================
  2976. *
  2977. *------------------------------------------
  2978. */
  2979. int atcommand_monster(
  2980. const int fd, struct map_session_data* sd,
  2981. const char* command, const char* message)
  2982. {
  2983. char name[NAME_LENGTH];
  2984. char monster[NAME_LENGTH];
  2985. int mob_id;
  2986. int number = 0;
  2987. int x = 0, y = 0;
  2988. int count;
  2989. int i, j, k;
  2990. int mx, my, range;
  2991. nullpo_retr(-1, sd);
  2992. memset(name, '\0', sizeof(name));
  2993. memset(monster, '\0', sizeof(monster));
  2994. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2995. if (!message || !*message) {
  2996. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2997. return -1;
  2998. }
  2999. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) > 1 ||
  3000. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) > 1) {
  3001. //All data can be left as it is.
  3002. } else if ((count=sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y)) > 1) {
  3003. //Here, it is possible name was not given and we are using monster for it.
  3004. if (count < 3) //Blank mob's name.
  3005. name[0] = '\0';
  3006. } else if (sscanf(message, "%23s %23s %d %d %d", name, monster, &number, &x, &y) > 1) {
  3007. //All data can be left as it is.
  3008. } else if (sscanf(message, "%23s", monster) > 0) {
  3009. //As before, name may be already filled.
  3010. name[0] = '\0';
  3011. } else {
  3012. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3013. return -1;
  3014. }
  3015. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3016. mob_id = mobdb_checkid(atoi(monster));
  3017. if (mob_id == 0) {
  3018. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3019. return -1;
  3020. }
  3021. if (mob_id == MOBID_EMPERIUM) {
  3022. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  3023. return -1;
  3024. }
  3025. if (number <= 0)
  3026. number = 1;
  3027. if (strlen(name) < 1)
  3028. strcpy(name, "--ja--");
  3029. // 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
  3030. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3031. number = battle_config.atc_spawn_quantity_limit;
  3032. if (battle_config.etc_log)
  3033. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  3034. count = 0;
  3035. range = (int)sqrt(number) / 2;
  3036. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  3037. for (i = 0; i < number; i++) {
  3038. j = 0;
  3039. k = 0;
  3040. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  3041. if (x <= 0)
  3042. mx = sd->bl.x + (rand() % range - (range / 2));
  3043. else
  3044. mx = x;
  3045. if (y <= 0)
  3046. my = sd->bl.y + (rand() % range - (range / 2));
  3047. else
  3048. my = y;
  3049. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  3050. }
  3051. count += (k != 0) ? 1 : 0;
  3052. }
  3053. if (count != 0)
  3054. if (number == count)
  3055. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  3056. else {
  3057. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  3058. clif_displaymessage(fd, atcmd_output);
  3059. }
  3060. else {
  3061. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3062. return -1;
  3063. }
  3064. return 0;
  3065. }
  3066. // small monster spawning [Valaris]
  3067. int atcommand_monstersmall(
  3068. const int fd, struct map_session_data* sd,
  3069. const char* command, const char* message) {
  3070. char name[NAME_LENGTH] = "";
  3071. char monster[NAME_LENGTH] = "";
  3072. int mob_id = 0;
  3073. int number = 0;
  3074. int x = 0;
  3075. int y = 0;
  3076. int count;
  3077. int i;
  3078. nullpo_retr(-1, sd);
  3079. if (!message || !*message) {
  3080. clif_displaymessage(fd, "Give a monster name/id please.");
  3081. return -1;
  3082. }
  3083. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3084. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3085. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3086. clif_displaymessage(fd, "Give a monster name/id please.");
  3087. return -1;
  3088. }
  3089. // If monster identifier/name argument is a name
  3090. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3091. mob_id = atoi(monster);
  3092. if (mob_id == 0) {
  3093. clif_displaymessage(fd, msg_table[40]);
  3094. return -1;
  3095. }
  3096. if (mob_id == MOBID_EMPERIUM) {
  3097. clif_displaymessage(fd, msg_table[83]);
  3098. return -1;
  3099. }
  3100. if (mobdb_checkid(mob_id) == 0) {
  3101. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3102. return -1;
  3103. }
  3104. if (number <= 0)
  3105. number = 1;
  3106. if (strlen(name) < 1)
  3107. strcpy(name, "--ja--");
  3108. // 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
  3109. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3110. number = battle_config.atc_spawn_quantity_limit;
  3111. count = 0;
  3112. for (i = 0; i < number; i++) {
  3113. int mx, my;
  3114. if (x <= 0)
  3115. mx = sd->bl.x + (rand() % 11 - 5);
  3116. else
  3117. mx = x;
  3118. if (y <= 0)
  3119. my = sd->bl.y + (rand() % 11 - 5);
  3120. else
  3121. my = y;
  3122. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3123. }
  3124. if (count != 0)
  3125. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3126. else
  3127. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3128. return 0;
  3129. }
  3130. // big monster spawning [Valaris]
  3131. int atcommand_monsterbig(
  3132. const int fd, struct map_session_data* sd,
  3133. const char* command, const char* message) {
  3134. char name[NAME_LENGTH] = "";
  3135. char monster[NAME_LENGTH] = "";
  3136. int mob_id = 0;
  3137. int number = 0;
  3138. int x = 0;
  3139. int y = 0;
  3140. int count;
  3141. int i;
  3142. nullpo_retr(-1, sd);
  3143. if (!message || !*message) {
  3144. clif_displaymessage(fd, "Give a monster name/id please.");
  3145. return -1;
  3146. }
  3147. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3148. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3149. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3150. clif_displaymessage(fd, "Give a monster name/id please.");
  3151. return -1;
  3152. }
  3153. // If monster identifier/name argument is a name
  3154. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3155. mob_id = atoi(monster);
  3156. if (mob_id == 0) {
  3157. clif_displaymessage(fd, msg_table[40]);
  3158. return -1;
  3159. }
  3160. if (mob_id == MOBID_EMPERIUM) {
  3161. clif_displaymessage(fd, msg_table[83]);
  3162. return -1;
  3163. }
  3164. if (mobdb_checkid(mob_id) == 0) {
  3165. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3166. return -1;
  3167. }
  3168. if (number <= 0)
  3169. number = 1;
  3170. if (strlen(name) < 1)
  3171. strcpy(name, "--ja--");
  3172. // 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
  3173. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3174. number = battle_config.atc_spawn_quantity_limit;
  3175. count = 0;
  3176. for (i = 0; i < number; i++) {
  3177. int mx, my;
  3178. if (x <= 0)
  3179. mx = sd->bl.x + (rand() % 11 - 5);
  3180. else
  3181. mx = x;
  3182. if (y <= 0)
  3183. my = sd->bl.y + (rand() % 11 - 5);
  3184. else
  3185. my = y;
  3186. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2*MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3187. }
  3188. if (count != 0)
  3189. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3190. else
  3191. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3192. return 0;
  3193. }
  3194. /*==========================================
  3195. *
  3196. *------------------------------------------
  3197. */
  3198. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3199. struct mob_data *md;
  3200. int flag;
  3201. nullpo_retr(0, ap);
  3202. nullpo_retr(0, md=(struct mob_data *)bl);
  3203. flag = va_arg(ap, int);
  3204. if (flag)
  3205. mob_damage(NULL, md, md->hp, 2);
  3206. else
  3207. mob_delete(md);
  3208. return 0;
  3209. }
  3210. void atcommand_killmonster_sub(
  3211. const int fd, struct map_session_data* sd, const char* message,
  3212. const int drop)
  3213. {
  3214. int map_id;
  3215. char map_name[MAP_NAME_LENGTH];
  3216. if (!sd) return;
  3217. memset(map_name, '\0', sizeof(map_name));
  3218. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3219. map_id = sd->bl.m;
  3220. else {
  3221. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3222. strcat(map_name, ".gat");
  3223. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3224. map_id = sd->bl.m;
  3225. }
  3226. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3227. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3228. return;
  3229. }
  3230. /*==========================================
  3231. *
  3232. *------------------------------------------
  3233. */
  3234. int atcommand_killmonster(
  3235. const int fd, struct map_session_data* sd,
  3236. const char* command, const char* message)
  3237. {
  3238. if (!sd) return 0;
  3239. atcommand_killmonster_sub(fd, sd, message, 1);
  3240. return 0;
  3241. }
  3242. /*==========================================
  3243. *
  3244. *------------------------------------------
  3245. */
  3246. int atcommand_killmonster2(
  3247. const int fd, struct map_session_data* sd,
  3248. const char* command, const char* message)
  3249. {
  3250. if (!sd) return 0;
  3251. atcommand_killmonster_sub(fd, sd, message, 0);
  3252. return 0;
  3253. }
  3254. /*==========================================
  3255. *
  3256. *------------------------------------------
  3257. */
  3258. int atcommand_refine(
  3259. const int fd, struct map_session_data* sd,
  3260. const char* command, const char* message)
  3261. {
  3262. int i, position = 0, refine = 0, current_position, final_refine;
  3263. int count;
  3264. nullpo_retr(-1, sd);
  3265. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3266. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3267. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3268. return -1;
  3269. }
  3270. if (refine < -10)
  3271. refine = -10;
  3272. else if (refine > 10)
  3273. refine = 10;
  3274. else if (refine == 0)
  3275. refine = 1;
  3276. count = 0;
  3277. for (i = 0; i < MAX_INVENTORY; i++) {
  3278. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3279. (sd->status.inventory[i].equip & position ||
  3280. (sd->status.inventory[i].equip && !position))) {
  3281. final_refine = sd->status.inventory[i].refine + refine;
  3282. if (final_refine > 10)
  3283. final_refine = 10;
  3284. else if (final_refine < 0)
  3285. final_refine = 0;
  3286. if (sd->status.inventory[i].refine != final_refine) {
  3287. sd->status.inventory[i].refine = final_refine;
  3288. current_position = sd->status.inventory[i].equip;
  3289. pc_unequipitem(sd, i, 3);
  3290. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3291. clif_delitem(sd, i, 1);
  3292. clif_additem(sd, i, 1, 0);
  3293. pc_equipitem(sd, i, current_position);
  3294. clif_misceffect((struct block_list*)&sd->bl, 3);
  3295. count++;
  3296. }
  3297. }
  3298. }
  3299. if (count == 0)
  3300. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3301. else if (count == 1)
  3302. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3303. else {
  3304. sprintf(atcmd_output, msg_table[168], count); // %d items have been refined!
  3305. clif_displaymessage(fd, atcmd_output);
  3306. }
  3307. return 0;
  3308. }
  3309. /*==========================================
  3310. *
  3311. *------------------------------------------
  3312. */
  3313. int atcommand_produce(
  3314. const int fd, struct map_session_data* sd,
  3315. const char* command, const char* message)
  3316. {
  3317. char item_name[100];
  3318. int item_id, attribute = 0, star = 0;
  3319. int flag = 0;
  3320. struct item_data *item_data;
  3321. struct item tmp_item;
  3322. nullpo_retr(-1, sd);
  3323. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3324. memset(item_name, '\0', sizeof(item_name));
  3325. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3326. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3327. return -1;
  3328. }
  3329. item_id = 0;
  3330. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3331. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3332. item_id = item_data->nameid;
  3333. if (itemdb_exists(item_id) &&
  3334. (item_id <= 500 || item_id > 1099) &&
  3335. (item_id < 4001 || item_id > 4148) &&
  3336. (item_id < 7001 || item_id > 10019) &&
  3337. itemdb_isequip(item_id)) {
  3338. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3339. attribute = ATTRIBUTE_NORMAL;
  3340. if (star < MIN_STAR || star > MAX_STAR)
  3341. star = 0;
  3342. memset(&tmp_item, 0, sizeof tmp_item);
  3343. tmp_item.nameid = item_id;
  3344. tmp_item.amount = 1;
  3345. tmp_item.identify = 1;
  3346. tmp_item.card[0] = 0x00ff;
  3347. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3348. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3349. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3350. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3351. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3352. //Logs (A)dmins items [Lupus]
  3353. if(log_config.pick > 0 ) {
  3354. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3355. }
  3356. //Logs
  3357. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3358. clif_additem(sd, 0, 0, flag);
  3359. } else {
  3360. if (battle_config.error_log)
  3361. ShowError("@produce NOT WEAPON [%d]\n", item_id);
  3362. if (item_id != 0 && itemdb_exists(item_id))
  3363. sprintf(atcmd_output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3364. else
  3365. sprintf(atcmd_output, msg_table[170]); // This item is not an equipment.
  3366. clif_displaymessage(fd, atcmd_output);
  3367. return -1;
  3368. }
  3369. return 0;
  3370. }
  3371. /*==========================================
  3372. * Sub-function to display actual memo points
  3373. *------------------------------------------
  3374. */
  3375. void atcommand_memo_sub(struct map_session_data* sd) {
  3376. int i;
  3377. if (!sd) return;
  3378. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3379. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3380. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3381. if (sd->status.memo_point[i].map)
  3382. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  3383. else
  3384. sprintf(atcmd_output, msg_table[171], i); // %d - void
  3385. clif_displaymessage(sd->fd, atcmd_output);
  3386. }
  3387. return;
  3388. }
  3389. /*==========================================
  3390. *
  3391. *------------------------------------------
  3392. */
  3393. int atcommand_memo(
  3394. const int fd, struct map_session_data* sd,
  3395. const char* command, const char* message)
  3396. {
  3397. int position = 0;
  3398. nullpo_retr(-1, sd);
  3399. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3400. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3401. atcommand_memo_sub(sd);
  3402. else {
  3403. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3404. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3405. clif_displaymessage(fd, msg_table[253]);
  3406. return -1;
  3407. }
  3408. if (sd->status.memo_point[position].map) {
  3409. sprintf(atcmd_output, msg_table[172], position, mapindex_id2name(sd->status.memo_point[position].map), sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
  3410. clif_displaymessage(fd, atcmd_output);
  3411. }
  3412. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3413. sd->status.memo_point[position].x = sd->bl.x;
  3414. sd->status.memo_point[position].y = sd->bl.y;
  3415. clif_skill_memo(sd, 0);
  3416. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3417. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3418. atcommand_memo_sub(sd);
  3419. } else {
  3420. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3421. clif_displaymessage(fd, atcmd_output);
  3422. atcommand_memo_sub(sd);
  3423. return -1;
  3424. }
  3425. }
  3426. return 0;
  3427. }
  3428. /*==========================================
  3429. *
  3430. *------------------------------------------
  3431. */
  3432. int atcommand_gat(
  3433. const int fd, struct map_session_data* sd,
  3434. const char* command, const char* message)
  3435. {
  3436. int y;
  3437. nullpo_retr(-1, sd);
  3438. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3439. for (y = 2; y >= -2; y--) {
  3440. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3441. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3442. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3443. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3444. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3445. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3446. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3447. clif_displaymessage(fd, atcmd_output);
  3448. }
  3449. return 0;
  3450. }
  3451. /*==========================================
  3452. *
  3453. *------------------------------------------
  3454. */
  3455. int atcommand_packet(
  3456. const int fd, struct map_session_data* sd,
  3457. const char* command, const char* message)
  3458. {
  3459. static int packet_mode = 0;
  3460. int i, x = 0, y = 0;
  3461. nullpo_retr(-1, sd);
  3462. if (strstr(command, "packetmode")) {
  3463. packet_mode = atoi(message);
  3464. clif_displaymessage(fd, "Packet mode changed.");
  3465. return 0;
  3466. }
  3467. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3468. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3469. return -1;
  3470. }
  3471. if (i == 1) y = 1;
  3472. switch (packet_mode)
  3473. {
  3474. case 0:
  3475. clif_status_change(&sd->bl, x, y);
  3476. break;
  3477. case 1:
  3478. sd->status.skill[sd->cloneskill_id].id=0;
  3479. sd->status.skill[sd->cloneskill_id].lv=0;
  3480. sd->status.skill[sd->cloneskill_id].flag=0;
  3481. sd->cloneskill_id = x;
  3482. sd->status.skill[x].id = x;
  3483. sd->status.skill[x].lv = skill_get_max(x);
  3484. sd->status.skill[x].flag = 13;//cloneskill flag
  3485. clif_skillinfoblock(sd);
  3486. break;
  3487. case 2:
  3488. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3489. case 3:
  3490. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3491. default:
  3492. break;
  3493. //added later
  3494. }
  3495. return 0;
  3496. }
  3497. /*==========================================
  3498. * @waterlevel [Skotlex]
  3499. *------------------------------------------
  3500. */
  3501. int atcommand_waterlevel(
  3502. const int fd, struct map_session_data* sd,
  3503. const char* command, const char* message)
  3504. {
  3505. int newlevel;
  3506. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3507. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3508. clif_displaymessage(fd, atcmd_output);
  3509. return 0;
  3510. }
  3511. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3512. if (newlevel > 0)
  3513. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3514. else
  3515. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3516. clif_displaymessage(fd, atcmd_output);
  3517. } else {
  3518. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3519. clif_displaymessage(fd, atcmd_output);
  3520. }
  3521. return 0;
  3522. }
  3523. /*==========================================
  3524. * @stpoint (Rewritten by [Yor])
  3525. *------------------------------------------
  3526. */
  3527. int atcommand_statuspoint(
  3528. const int fd, struct map_session_data* sd,
  3529. const char* command, const char* message)
  3530. {
  3531. int point, new_status_point;
  3532. if (!message || !*message || (point = atoi(message)) == 0) {
  3533. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3534. return -1;
  3535. }
  3536. new_status_point = (int)sd->status.status_point + point;
  3537. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3538. new_status_point = 0x7FFF;
  3539. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3540. new_status_point = 0;
  3541. if (new_status_point != (int)sd->status.status_point) {
  3542. sd->status.status_point = (short)new_status_point;
  3543. clif_updatestatus(sd, SP_STATUSPOINT);
  3544. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3545. } else {
  3546. if (point < 0)
  3547. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3548. else
  3549. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3550. return -1;
  3551. }
  3552. return 0;
  3553. }
  3554. /*==========================================
  3555. * @skpoint (Rewritten by [Yor])
  3556. *------------------------------------------
  3557. */
  3558. int atcommand_skillpoint(
  3559. const int fd, struct map_session_data* sd,
  3560. const char* command, const char* message)
  3561. {
  3562. int point, new_skill_point;
  3563. nullpo_retr(-1, sd);
  3564. if (!message || !*message || (point = atoi(message)) == 0) {
  3565. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3566. return -1;
  3567. }
  3568. new_skill_point = (int)sd->status.skill_point + point;
  3569. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3570. new_skill_point = 0x7FFF;
  3571. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3572. new_skill_point = 0;
  3573. if (new_skill_point != (int)sd->status.skill_point) {
  3574. sd->status.skill_point = (short)new_skill_point;
  3575. clif_updatestatus(sd, SP_SKILLPOINT);
  3576. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3577. } else {
  3578. if (point < 0)
  3579. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3580. else
  3581. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3582. return -1;
  3583. }
  3584. return 0;
  3585. }
  3586. /*==========================================
  3587. * @zeny (Rewritten by [Yor])
  3588. *------------------------------------------
  3589. */
  3590. int atcommand_zeny(
  3591. const int fd, struct map_session_data* sd,
  3592. const char* command, const char* message)
  3593. {
  3594. int zeny, new_zeny;
  3595. nullpo_retr(-1, sd);
  3596. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3597. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3598. return -1;
  3599. }
  3600. new_zeny = sd->status.zeny + zeny;
  3601. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3602. new_zeny = MAX_ZENY;
  3603. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3604. new_zeny = 0;
  3605. if (new_zeny != sd->status.zeny) {
  3606. sd->status.zeny = new_zeny;
  3607. clif_updatestatus(sd, SP_ZENY);
  3608. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3609. } else {
  3610. if (zeny < 0)
  3611. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3612. else
  3613. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3614. return -1;
  3615. }
  3616. return 0;
  3617. }
  3618. /*==========================================
  3619. *
  3620. *------------------------------------------
  3621. */
  3622. int atcommand_param(
  3623. const int fd, struct map_session_data* sd,
  3624. const char* command, const char* message)
  3625. {
  3626. int i, index, value = 0, new_value;
  3627. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3628. short* status[] = {
  3629. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3630. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3631. };
  3632. nullpo_retr(-1, sd);
  3633. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3634. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3635. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3636. clif_displaymessage(fd, atcmd_output);
  3637. return -1;
  3638. }
  3639. index = -1;
  3640. for (i = 0; param[i] != NULL; i++) {
  3641. if (strcmpi(command, param[i]) == 0) {
  3642. index = i;
  3643. break;
  3644. }
  3645. }
  3646. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3647. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3648. clif_displaymessage(fd, atcmd_output);
  3649. return -1;
  3650. }
  3651. new_value = (int)*status[index] + value;
  3652. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3653. new_value = pc_maxparameter(sd);
  3654. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negativ overflow
  3655. new_value = 1;
  3656. if (new_value != (int)*status[index]) {
  3657. *status[index] = new_value;
  3658. clif_updatestatus(sd, SP_STR + index);
  3659. clif_updatestatus(sd, SP_USTR + index);
  3660. status_calc_pc(sd, 0);
  3661. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3662. } else {
  3663. if (value < 0)
  3664. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3665. else
  3666. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3667. return -1;
  3668. }
  3669. return 0;
  3670. }
  3671. /*==========================================
  3672. *
  3673. *------------------------------------------
  3674. */
  3675. //** Stat all by fritz (rewritten by [Yor])
  3676. int atcommand_stat_all(
  3677. const int fd, struct map_session_data* sd,
  3678. const char* command, const char* message)
  3679. {
  3680. int index, count, value = 0, new_value;
  3681. short* status[] = {
  3682. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3683. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3684. };
  3685. nullpo_retr(-1, sd);
  3686. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3687. value = pc_maxparameter(sd);
  3688. count = 0;
  3689. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3690. new_value = (int)*status[index] + value;
  3691. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3692. new_value = pc_maxparameter(sd);
  3693. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negative overflow
  3694. new_value = 1;
  3695. if (new_value != (int)*status[index]) {
  3696. *status[index] = new_value;
  3697. clif_updatestatus(sd, SP_STR + index);
  3698. clif_updatestatus(sd, SP_USTR + index);
  3699. status_calc_pc(sd, 0);
  3700. count++;
  3701. }
  3702. }
  3703. if (count > 0) // if at least 1 stat modified
  3704. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3705. else {
  3706. if (value < 0)
  3707. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3708. else
  3709. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3710. return -1;
  3711. }
  3712. return 0;
  3713. }
  3714. /*==========================================
  3715. *
  3716. *------------------------------------------
  3717. */
  3718. int atcommand_guildlevelup(
  3719. const int fd, struct map_session_data* sd,
  3720. const char* command, const char* message)
  3721. {
  3722. int level = 0;
  3723. short added_level;
  3724. struct guild *guild_info;
  3725. nullpo_retr(-1, sd);
  3726. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3727. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3728. return -1;
  3729. }
  3730. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3731. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3732. return -1;
  3733. }
  3734. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3735. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3736. return -1;
  3737. }
  3738. added_level = (short)level;
  3739. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3740. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3741. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3742. added_level = 1 - guild_info->guild_lv;
  3743. if (added_level != 0) {
  3744. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3745. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3746. } else {
  3747. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3748. return -1;
  3749. }
  3750. return 0;
  3751. }
  3752. /*==========================================
  3753. *
  3754. *------------------------------------------
  3755. */
  3756. int atcommand_makeegg(
  3757. const int fd, struct map_session_data* sd,
  3758. const char* command, const char* message)
  3759. {
  3760. struct item_data *item_data;
  3761. int id, pet_id;
  3762. nullpo_retr(-1, sd);
  3763. if (!message || !*message) {
  3764. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3765. return -1;
  3766. }
  3767. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3768. id = item_data->nameid;
  3769. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3770. id = atoi(message);
  3771. pet_id = search_petDB_index(id, PET_CLASS);
  3772. if (pet_id < 0)
  3773. pet_id = search_petDB_index(id, PET_EGG);
  3774. if (pet_id >= 0) {
  3775. sd->catch_target_class = pet_db[pet_id].class_;
  3776. intif_create_pet(
  3777. sd->status.account_id, sd->status.char_id,
  3778. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3779. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3780. 100, 0, 1, pet_db[pet_id].jname);
  3781. } else {
  3782. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3783. return -1;
  3784. }
  3785. return 0;
  3786. }
  3787. /*==========================================
  3788. *
  3789. *------------------------------------------
  3790. */
  3791. int atcommand_hatch(
  3792. const int fd, struct map_session_data* sd,
  3793. const char* command, const char* message)
  3794. {
  3795. nullpo_retr(-1, sd);
  3796. if (sd->status.pet_id <= 0)
  3797. clif_sendegg(sd);
  3798. else {
  3799. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3800. return -1;
  3801. }
  3802. return 0;
  3803. }
  3804. /*==========================================
  3805. *
  3806. *------------------------------------------
  3807. */
  3808. int atcommand_petfriendly(
  3809. const int fd, struct map_session_data* sd,
  3810. const char* command, const char* message)
  3811. {
  3812. int friendly;
  3813. int t;
  3814. nullpo_retr(-1, sd);
  3815. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3816. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3817. return -1;
  3818. }
  3819. if (sd->status.pet_id > 0 && sd->pd) {
  3820. if (friendly >= 0 && friendly <= 1000) {
  3821. if (friendly != sd->pet.intimate) {
  3822. t = sd->pet.intimate;
  3823. sd->pet.intimate = friendly;
  3824. clif_send_petstatus(sd);
  3825. if (battle_config.pet_status_support) {
  3826. if ((sd->pet.intimate > 0 && t <= 0) ||
  3827. (sd->pet.intimate <= 0 && t > 0)) {
  3828. if (sd->bl.prev != NULL)
  3829. status_calc_pc(sd, 0);
  3830. else
  3831. status_calc_pc(sd, 2);
  3832. }
  3833. }
  3834. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3835. } else {
  3836. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3837. return -1;
  3838. }
  3839. } else {
  3840. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3841. return -1;
  3842. }
  3843. } else {
  3844. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3845. return -1;
  3846. }
  3847. return 0;
  3848. }
  3849. /*==========================================
  3850. *
  3851. *------------------------------------------
  3852. */
  3853. int atcommand_pethungry(
  3854. const int fd, struct map_session_data* sd,
  3855. const char* command, const char* message)
  3856. {
  3857. int hungry;
  3858. nullpo_retr(-1, sd);
  3859. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3860. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3861. return -1;
  3862. }
  3863. if (sd->status.pet_id > 0 && sd->pd) {
  3864. if (hungry >= 0 && hungry <= 100) {
  3865. if (hungry != sd->pet.hungry) {
  3866. sd->pet.hungry = hungry;
  3867. clif_send_petstatus(sd);
  3868. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3869. } else {
  3870. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3871. return -1;
  3872. }
  3873. } else {
  3874. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3875. return -1;
  3876. }
  3877. } else {
  3878. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3879. return -1;
  3880. }
  3881. return 0;
  3882. }
  3883. /*==========================================
  3884. *
  3885. *------------------------------------------
  3886. */
  3887. int atcommand_petrename(
  3888. const int fd, struct map_session_data* sd,
  3889. const char* command, const char* message)
  3890. {
  3891. nullpo_retr(-1, sd);
  3892. if (sd->status.pet_id > 0 && sd->pd) {
  3893. if (sd->pet.rename_flag != 0) {
  3894. sd->pet.rename_flag = 0;
  3895. intif_save_petdata(sd->status.account_id, &sd->pet);
  3896. clif_send_petstatus(sd);
  3897. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3898. } else {
  3899. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3900. return -1;
  3901. }
  3902. } else {
  3903. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3904. return -1;
  3905. }
  3906. return 0;
  3907. }
  3908. /*==========================================
  3909. *
  3910. *------------------------------------------
  3911. */
  3912. int
  3913. atcommand_recall(
  3914. const int fd, struct map_session_data* sd,
  3915. const char* command, const char* message)
  3916. {
  3917. struct map_session_data *pl_sd = NULL;
  3918. nullpo_retr(-1, sd);
  3919. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3920. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3921. return -1;
  3922. }
  3923. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3924. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3925. return -1;
  3926. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3927. return -1;
  3928. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3929. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3930. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3931. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3932. return -1;
  3933. }
  3934. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3935. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3936. return -1;
  3937. }
  3938. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3939. sprintf(atcmd_output, msg_table[46], atcmd_player_name); // %s recalled!
  3940. clif_displaymessage(fd, atcmd_output);
  3941. } else {
  3942. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3943. return -1;
  3944. }
  3945. } else {
  3946. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3947. return -1;
  3948. }
  3949. return 0;
  3950. }
  3951. /*==========================================
  3952. *
  3953. *------------------------------------------
  3954. */
  3955. int atcommand_revive(
  3956. const int fd, struct map_session_data* sd,
  3957. const char* command, const char* message)
  3958. {
  3959. struct map_session_data *pl_sd;
  3960. nullpo_retr(-1, sd);
  3961. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3962. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3963. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3964. return -1;
  3965. }
  3966. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3967. if (pc_isdead(pl_sd)) {
  3968. pl_sd->status.hp = pl_sd->status.max_hp;
  3969. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3970. pc_setstand(pl_sd);
  3971. if (battle_config.pc_invincible_time > 0)
  3972. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3973. clif_updatestatus(pl_sd, SP_HP);
  3974. clif_updatestatus(pl_sd, SP_SP);
  3975. clif_resurrection(&pl_sd->bl, 1);
  3976. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3977. return 0;
  3978. }
  3979. return -1;
  3980. } else {
  3981. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3982. return -1;
  3983. }
  3984. return 0;
  3985. }
  3986. /*==========================================
  3987. * charblock command (usage: charblock <player_name>)
  3988. * This command do a definitiv ban on a player
  3989. *------------------------------------------
  3990. */
  3991. int atcommand_char_block(
  3992. const int fd, struct map_session_data* sd,
  3993. const char* command, const char* message)
  3994. {
  3995. nullpo_retr(-1, sd);
  3996. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3997. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  3998. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3999. return -1;
  4000. }
  4001. // check player name
  4002. if (strlen(atcmd_player_name) < 4) {
  4003. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4004. return -1;
  4005. } else if (strlen(atcmd_player_name) > 23) {
  4006. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4007. return -1;
  4008. } else {
  4009. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4010. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4011. }
  4012. return 0;
  4013. }
  4014. /*==========================================
  4015. * charban command (usage: charban <time> <player_name>)
  4016. * This command do a limited ban on a player
  4017. * Time is done as follows:
  4018. * Adjustment value (-1, 1, +1, etc...)
  4019. * Modified element:
  4020. * a or y: year
  4021. * m: month
  4022. * j or d: day
  4023. * h: hour
  4024. * mn: minute
  4025. * s: second
  4026. * <example> @ban +1m-2mn1s-6y test_player
  4027. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4028. *------------------------------------------
  4029. */
  4030. int atcommand_char_ban(
  4031. const int fd, struct map_session_data* sd,
  4032. const char* command, const char* message)
  4033. {
  4034. char * modif_p;
  4035. int year, month, day, hour, minute, second, value;
  4036. nullpo_retr(-1, sd);
  4037. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4038. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4039. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4040. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4041. return -1;
  4042. }
  4043. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4044. modif_p = atcmd_output;
  4045. year = month = day = hour = minute = second = 0;
  4046. while (modif_p[0] != '\0') {
  4047. value = atoi(modif_p);
  4048. if (value == 0)
  4049. modif_p++;
  4050. else {
  4051. if (modif_p[0] == '-' || modif_p[0] == '+')
  4052. modif_p++;
  4053. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4054. modif_p++;
  4055. if (modif_p[0] == 's') {
  4056. second = value;
  4057. modif_p++;
  4058. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4059. minute = value;
  4060. modif_p = modif_p + 2;
  4061. } else if (modif_p[0] == 'h') {
  4062. hour = value;
  4063. modif_p++;
  4064. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4065. day = value;
  4066. modif_p++;
  4067. } else if (modif_p[0] == 'm') {
  4068. month = value;
  4069. modif_p++;
  4070. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4071. year = value;
  4072. modif_p++;
  4073. } else if (modif_p[0] != '\0') {
  4074. modif_p++;
  4075. }
  4076. }
  4077. }
  4078. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4079. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  4080. return -1;
  4081. }
  4082. // check player name
  4083. if (strlen(atcmd_player_name) < 4) {
  4084. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4085. return -1;
  4086. } else if (strlen(atcmd_player_name) > 23) {
  4087. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4088. return -1;
  4089. } else {
  4090. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4091. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4092. }
  4093. return 0;
  4094. }
  4095. /*==========================================
  4096. * charunblock command (usage: charunblock <player_name>)
  4097. *------------------------------------------
  4098. */
  4099. int atcommand_char_unblock(
  4100. const int fd, struct map_session_data* sd,
  4101. const char* command, const char* message)
  4102. {
  4103. nullpo_retr(-1, sd);
  4104. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4105. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4106. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4107. return -1;
  4108. }
  4109. // check player name
  4110. if (strlen(atcmd_player_name) < 4) {
  4111. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4112. return -1;
  4113. } else if (strlen(atcmd_player_name) > 23) {
  4114. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4115. return -1;
  4116. } else {
  4117. // send answer to login server via char-server
  4118. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4119. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4120. }
  4121. return 0;
  4122. }
  4123. /*==========================================
  4124. * charunban command (usage: charunban <player_name>)
  4125. *------------------------------------------
  4126. */
  4127. int atcommand_char_unban(
  4128. const int fd, struct map_session_data* sd,
  4129. const char* command, const char* message)
  4130. {
  4131. nullpo_retr(-1, sd);
  4132. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4133. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4134. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4135. return -1;
  4136. }
  4137. // check player name
  4138. if (strlen(atcmd_player_name) < 4) {
  4139. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4140. return -1;
  4141. } else if (strlen(atcmd_player_name) > 23) {
  4142. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4143. return -1;
  4144. } else {
  4145. // send answer to login server via char-server
  4146. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4147. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4148. }
  4149. return 0;
  4150. }
  4151. /*==========================================
  4152. *
  4153. *------------------------------------------
  4154. */
  4155. int atcommand_night(
  4156. const int fd, struct map_session_data* sd,
  4157. const char* command, const char* message)
  4158. {
  4159. nullpo_retr(-1, sd);
  4160. if (night_flag != 1) {
  4161. map_night_timer(night_timer_tid, 0, 0, 1);
  4162. } else {
  4163. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4164. return -1;
  4165. }
  4166. return 0;
  4167. }
  4168. /*==========================================
  4169. *
  4170. *------------------------------------------
  4171. */
  4172. int atcommand_day(
  4173. const int fd, struct map_session_data* sd,
  4174. const char* command, const char* message)
  4175. {
  4176. nullpo_retr(-1, sd);
  4177. if (night_flag != 0) {
  4178. map_day_timer(day_timer_tid, 0, 0, 1);
  4179. } else {
  4180. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4181. return -1;
  4182. }
  4183. return 0;
  4184. }
  4185. /*==========================================
  4186. *
  4187. *------------------------------------------
  4188. */
  4189. int atcommand_doom(
  4190. const int fd, struct map_session_data* sd,
  4191. const char* command, const char* message)
  4192. {
  4193. struct map_session_data *pl_sd, **pl_allsd;
  4194. int i, users;
  4195. nullpo_retr(-1, sd);
  4196. clif_specialeffect(&sd->bl,450,2);
  4197. pl_allsd = map_getallusers(&users);
  4198. for(i = 0; i < users; i++) {
  4199. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4200. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4201. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4202. }
  4203. }
  4204. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4205. return 0;
  4206. }
  4207. /*==========================================
  4208. *
  4209. *------------------------------------------
  4210. */
  4211. int atcommand_doommap(
  4212. const int fd, struct map_session_data* sd,
  4213. const char* command, const char* message)
  4214. {
  4215. struct map_session_data *pl_sd, **pl_allsd;
  4216. int i, users;
  4217. nullpo_retr(-1, sd);
  4218. clif_specialeffect(&sd->bl,450,3);
  4219. pl_allsd = map_getallusers(&users);
  4220. for (i = 0; i < users; i++) {
  4221. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4222. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4223. {
  4224. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4225. // clif_specialeffect(&pl_sd->bl,450,1);
  4226. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4227. }
  4228. }
  4229. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4230. return 0;
  4231. }
  4232. /*==========================================
  4233. *
  4234. *------------------------------------------
  4235. */
  4236. static void atcommand_raise_sub(struct map_session_data* sd)
  4237. {
  4238. if (sd && sd->state.auth && pc_isdead(sd)) {
  4239. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4240. sd->status.hp = sd->status.max_hp;
  4241. sd->status.sp = sd->status.max_sp;
  4242. pc_setstand(sd);
  4243. clif_updatestatus(sd, SP_HP);
  4244. clif_updatestatus(sd, SP_SP);
  4245. clif_resurrection(&sd->bl, 1);
  4246. if (battle_config.pc_invincible_time > 0)
  4247. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4248. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4249. }
  4250. }
  4251. /*==========================================
  4252. *
  4253. *------------------------------------------
  4254. */
  4255. int atcommand_raise(
  4256. const int fd, struct map_session_data* sd,
  4257. const char* command, const char* message)
  4258. {
  4259. int i, users;
  4260. struct map_session_data **all_sd;
  4261. nullpo_retr(-1, sd);
  4262. all_sd = map_getallusers(&users);
  4263. for (i = 0; i < users; i++) {
  4264. atcommand_raise_sub(all_sd[i]);
  4265. }
  4266. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4267. return 0;
  4268. }
  4269. /*==========================================
  4270. *
  4271. *------------------------------------------
  4272. */
  4273. int atcommand_raisemap(
  4274. const int fd, struct map_session_data* sd,
  4275. const char* command, const char* message)
  4276. {
  4277. struct map_session_data **pl_allsd;
  4278. int i, users;
  4279. nullpo_retr(-1, sd);
  4280. pl_allsd = map_getallusers(&users);
  4281. for (i = 0; i < users; i++) {
  4282. if (sd->bl.m == pl_allsd[i]->bl.m)
  4283. atcommand_raise_sub(pl_allsd[i]);
  4284. }
  4285. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4286. return 0;
  4287. }
  4288. /*==========================================
  4289. *
  4290. *------------------------------------------
  4291. */
  4292. int atcommand_kick(
  4293. const int fd, struct map_session_data* sd,
  4294. const char* command, const char* message)
  4295. {
  4296. struct map_session_data *pl_sd;
  4297. nullpo_retr(-1, sd);
  4298. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4299. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4300. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4301. return -1;
  4302. }
  4303. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4304. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4305. clif_GM_kick(sd, pl_sd, 1);
  4306. else {
  4307. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4308. return -1;
  4309. }
  4310. } else {
  4311. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4312. return -1;
  4313. }
  4314. return 0;
  4315. }
  4316. /*==========================================
  4317. *
  4318. *------------------------------------------
  4319. */
  4320. int atcommand_kickall(
  4321. const int fd, struct map_session_data* sd,
  4322. const char* command, const char* message)
  4323. {
  4324. struct map_session_data *pl_sd, **pl_allsd;
  4325. int i, users;
  4326. nullpo_retr(-1, sd);
  4327. pl_allsd = map_getallusers(&users);
  4328. for (i = 0; i < users; i++) {
  4329. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4330. if (sd->status.account_id != pl_sd->status.account_id)
  4331. clif_GM_kick(sd, pl_sd, 0);
  4332. }
  4333. }
  4334. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4335. return 0;
  4336. }
  4337. /*==========================================
  4338. *
  4339. *------------------------------------------
  4340. */
  4341. int atcommand_allskill(
  4342. const int fd, struct map_session_data* sd,
  4343. const char* command, const char* message)
  4344. {
  4345. nullpo_retr(-1, sd);
  4346. pc_allskillup(sd); // all skills
  4347. sd->status.skill_point = 0; // 0 skill points
  4348. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4349. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4350. return 0;
  4351. }
  4352. /*==========================================
  4353. *
  4354. *------------------------------------------
  4355. */
  4356. int atcommand_questskill(
  4357. const int fd, struct map_session_data* sd,
  4358. const char* command, const char* message)
  4359. {
  4360. int skill_id;
  4361. nullpo_retr(-1, sd);
  4362. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4363. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4364. return -1;
  4365. }
  4366. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4367. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4368. if (pc_checkskill(sd, skill_id) == 0) {
  4369. pc_skill(sd, skill_id, 1, 0);
  4370. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4371. } else {
  4372. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4373. return -1;
  4374. }
  4375. } else {
  4376. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4377. return -1;
  4378. }
  4379. } else {
  4380. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4381. return -1;
  4382. }
  4383. return 0;
  4384. }
  4385. /*==========================================
  4386. *
  4387. *------------------------------------------
  4388. */
  4389. int atcommand_lostskill(
  4390. const int fd, struct map_session_data* sd,
  4391. const char* command, const char* message)
  4392. {
  4393. int skill_id;
  4394. nullpo_retr(-1, sd);
  4395. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4396. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4397. return -1;
  4398. }
  4399. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4400. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4401. if (pc_checkskill(sd, skill_id) > 0) {
  4402. sd->status.skill[skill_id].lv = 0;
  4403. sd->status.skill[skill_id].flag = 0;
  4404. clif_skillinfoblock(sd);
  4405. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4406. } else {
  4407. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4408. return -1;
  4409. }
  4410. } else {
  4411. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4412. return -1;
  4413. }
  4414. } else {
  4415. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4416. return -1;
  4417. }
  4418. return 0;
  4419. }
  4420. /*==========================================
  4421. *
  4422. *------------------------------------------
  4423. */
  4424. int atcommand_spiritball(
  4425. const int fd, struct map_session_data* sd,
  4426. const char* command, const char* message)
  4427. {
  4428. int number;
  4429. nullpo_retr(-1, sd);
  4430. if (!message || !*message || (number = atoi(message)) < 0) {
  4431. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4432. return -1;
  4433. }
  4434. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4435. if (number > 500)
  4436. number = 500;
  4437. if (number >= 0 && number <= 0x7FFF) {
  4438. if (sd->spiritball != number || number > 499) {
  4439. if (sd->spiritball > 0)
  4440. pc_delspiritball(sd, sd->spiritball, 1);
  4441. sd->spiritball = number;
  4442. clif_spiritball(sd);
  4443. // no message, player can look the difference
  4444. if (number > 1000)
  4445. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4446. } else {
  4447. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4448. return -1;
  4449. }
  4450. } else {
  4451. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4452. return -1;
  4453. }
  4454. return 0;
  4455. }
  4456. /*==========================================
  4457. *
  4458. *------------------------------------------
  4459. */
  4460. int atcommand_party(
  4461. const int fd, struct map_session_data* sd,
  4462. const char* command, const char* message)
  4463. {
  4464. char party[NAME_LENGTH];
  4465. nullpo_retr(-1, sd);
  4466. memset(party, '\0', sizeof(party));
  4467. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4468. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4469. return -1;
  4470. }
  4471. party_create(sd, party, 0, 0);
  4472. return 0;
  4473. }
  4474. /*==========================================
  4475. *
  4476. *------------------------------------------
  4477. */
  4478. int atcommand_guild(
  4479. const int fd, struct map_session_data* sd,
  4480. const char* command, const char* message)
  4481. {
  4482. char guild[NAME_LENGTH];
  4483. int prev;
  4484. nullpo_retr(-1, sd);
  4485. memset(guild, '\0', sizeof(guild));
  4486. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4487. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4488. return -1;
  4489. }
  4490. prev = battle_config.guild_emperium_check;
  4491. battle_config.guild_emperium_check = 0;
  4492. guild_create(sd, guild);
  4493. battle_config.guild_emperium_check = prev;
  4494. return 0;
  4495. }
  4496. /*==========================================
  4497. *
  4498. *------------------------------------------
  4499. */
  4500. int atcommand_agitstart(
  4501. const int fd, struct map_session_data* sd,
  4502. const char* command, const char* message)
  4503. {
  4504. nullpo_retr(-1, sd);
  4505. if (agit_flag == 1) {
  4506. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4507. return -1;
  4508. }
  4509. agit_flag = 1;
  4510. guild_agit_start();
  4511. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4512. return 0;
  4513. }
  4514. /*==========================================
  4515. *
  4516. *------------------------------------------
  4517. */
  4518. int atcommand_agitend(
  4519. const int fd, struct map_session_data* sd,
  4520. const char* command, const char* message)
  4521. {
  4522. nullpo_retr(-1, sd);
  4523. if (agit_flag == 0) {
  4524. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4525. return -1;
  4526. }
  4527. agit_flag = 0;
  4528. guild_agit_end();
  4529. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4530. return 0;
  4531. }
  4532. /*==========================================
  4533. * @mapexitでマップサーバーを終了させる
  4534. *------------------------------------------
  4535. */
  4536. int atcommand_mapexit(
  4537. const int fd, struct map_session_data* sd,
  4538. const char* command, const char* message)
  4539. {
  4540. struct map_session_data *pl_sd, **pl_allsd;
  4541. int i, users;
  4542. nullpo_retr(-1, sd);
  4543. pl_allsd = map_getallusers(&users);
  4544. for (i = 0; i < users; i++) {
  4545. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4546. clif_GM_kick(sd, pl_sd, 0);
  4547. }
  4548. clif_GM_kick(sd, sd, 0);
  4549. flush_fifos();
  4550. runflag = 0;
  4551. return 0;
  4552. }
  4553. /*==========================================
  4554. * idsearch <part_of_name>: revrited by [Yor]
  4555. *------------------------------------------
  4556. */
  4557. int atcommand_idsearch(
  4558. const int fd, struct map_session_data* sd,
  4559. const char* command, const char* message)
  4560. {
  4561. char item_name[100];
  4562. unsigned int i, match;
  4563. struct item_data *item;
  4564. nullpo_retr(-1, sd);
  4565. memset(item_name, '\0', sizeof(item_name));
  4566. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4567. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4568. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4569. return -1;
  4570. }
  4571. sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4572. clif_displaymessage(fd, atcmd_output);
  4573. match = 0;
  4574. for(i = 0; i < 20000; i++) {
  4575. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4576. match++;
  4577. sprintf(atcmd_output, msg_table[78], item->jname, item->nameid); // %s: %d
  4578. clif_displaymessage(fd, atcmd_output);
  4579. }
  4580. }
  4581. sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
  4582. clif_displaymessage(fd, atcmd_output);
  4583. return 0;
  4584. }
  4585. /*==========================================
  4586. * Recall All Characters Online To Your Location
  4587. *------------------------------------------
  4588. */
  4589. int atcommand_recallall(
  4590. const int fd, struct map_session_data* sd,
  4591. const char* command, const char* message)
  4592. {
  4593. struct map_session_data *pl_sd, **pl_allsd;
  4594. int i;
  4595. int count, users;
  4596. nullpo_retr(-1, sd);
  4597. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4598. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4599. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4600. return -1;
  4601. }
  4602. count = 0;
  4603. pl_allsd = map_getallusers(&users);
  4604. for (i = 0; i < users; i++) {
  4605. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4606. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4607. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4608. count++;
  4609. else {
  4610. if (pc_isdead(pl_sd)) { //Wake them up
  4611. pc_setstand(pl_sd);
  4612. pc_setrestartvalue(pl_sd,1);
  4613. }
  4614. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4615. }
  4616. }
  4617. }
  4618. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4619. if (count) {
  4620. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4621. clif_displaymessage(fd, atcmd_output);
  4622. }
  4623. return 0;
  4624. }
  4625. /*==========================================
  4626. * Recall online characters of a guild to your location
  4627. *------------------------------------------
  4628. */
  4629. int atcommand_guildrecall(
  4630. const int fd, struct map_session_data* sd,
  4631. const char* command, const char* message)
  4632. {
  4633. struct map_session_data *pl_sd, **pl_allsd;
  4634. int i, users, count;
  4635. char guild_name[NAME_LENGTH];
  4636. struct guild *g;
  4637. nullpo_retr(-1, sd);
  4638. memset(guild_name, '\0', sizeof(guild_name));
  4639. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4640. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4641. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4642. return -1;
  4643. }
  4644. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4645. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4646. return -1;
  4647. }
  4648. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4649. (g = guild_search(atoi(message))) != NULL) {
  4650. count = 0;
  4651. pl_allsd = map_getallusers(&users);
  4652. for (i = 0; i < users; i++) {
  4653. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4654. pl_sd->status.guild_id == g->guild_id) {
  4655. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4656. continue; //Skip GMs greater than you.
  4657. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4658. count++;
  4659. else
  4660. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4661. }
  4662. }
  4663. sprintf(atcmd_output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4664. clif_displaymessage(fd, atcmd_output);
  4665. if (count) {
  4666. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4667. clif_displaymessage(fd, atcmd_output);
  4668. }
  4669. } else {
  4670. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4671. return -1;
  4672. }
  4673. return 0;
  4674. }
  4675. /*==========================================
  4676. * Recall online characters of a party to your location
  4677. *------------------------------------------
  4678. */
  4679. int atcommand_partyrecall(
  4680. const int fd, struct map_session_data* sd,
  4681. const char* command, const char* message)
  4682. {
  4683. int i;
  4684. struct map_session_data *pl_sd, **pl_allsd;
  4685. char party_name[NAME_LENGTH];
  4686. struct party *p;
  4687. int count, users;
  4688. nullpo_retr(-1, sd);
  4689. memset(party_name, '\0', sizeof(party_name));
  4690. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4691. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4692. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4693. return -1;
  4694. }
  4695. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4696. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4697. return -1;
  4698. }
  4699. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4700. (p = party_search(atoi(message))) != NULL) {
  4701. count = 0;
  4702. pl_allsd = map_getallusers(&users);
  4703. for (i = 0; i < users; i++) {
  4704. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4705. pl_sd->status.party_id == p->party_id) {
  4706. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4707. continue; //Skip GMs greater than you.
  4708. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4709. count++;
  4710. else
  4711. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4712. }
  4713. }
  4714. sprintf(atcmd_output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4715. clif_displaymessage(fd, atcmd_output);
  4716. if (count) {
  4717. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4718. clif_displaymessage(fd, atcmd_output);
  4719. }
  4720. } else {
  4721. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4722. return -1;
  4723. }
  4724. return 0;
  4725. }
  4726. /*==========================================
  4727. *
  4728. *------------------------------------------
  4729. */
  4730. int atcommand_reloaditemdb(
  4731. const int fd, struct map_session_data* sd,
  4732. const char* command, const char* message)
  4733. {
  4734. nullpo_retr(-1, sd);
  4735. itemdb_reload();
  4736. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4737. return 0;
  4738. }
  4739. /*==========================================
  4740. *
  4741. *------------------------------------------
  4742. */
  4743. int atcommand_reloadmobdb(
  4744. const int fd, struct map_session_data* sd,
  4745. const char* command, const char* message)
  4746. {
  4747. nullpo_retr(-1, sd);
  4748. mob_reload();
  4749. do_final_pet();
  4750. read_petdb();
  4751. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4752. return 0;
  4753. }
  4754. /*==========================================
  4755. *
  4756. *------------------------------------------
  4757. */
  4758. int atcommand_reloadskilldb(
  4759. const int fd, struct map_session_data* sd,
  4760. const char* command, const char* message)
  4761. {
  4762. nullpo_retr(-1, sd);
  4763. skill_reload();
  4764. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4765. return 0;
  4766. }
  4767. /*==========================================
  4768. * @reloadatcommand
  4769. * atcommand_athena.conf のリロード
  4770. *------------------------------------------
  4771. */
  4772. int
  4773. atcommand_reloadatcommand(
  4774. const int fd, struct map_session_data* sd,
  4775. const char* command, const char* message)
  4776. {
  4777. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4778. clif_displaymessage(fd, msg_table[254]);
  4779. return 0;
  4780. }
  4781. /*==========================================
  4782. * @reloadbattleconf
  4783. * battle_athena.conf のリロード
  4784. *------------------------------------------
  4785. */
  4786. int
  4787. atcommand_reloadbattleconf(
  4788. const int fd, struct map_session_data* sd,
  4789. const char* command, const char* message)
  4790. {
  4791. battle_config_read(BATTLE_CONF_FILENAME);
  4792. mob_reload(); //Needed as well so rate changes take effect.
  4793. clif_displaymessage(fd, msg_table[255]);
  4794. return 0;
  4795. }
  4796. /*==========================================
  4797. * @reloadstatusdb
  4798. * job_db1.txt job_db2.txt job_db2-2.txt
  4799. * refine_db.txt size_fix.txt
  4800. * のリロード
  4801. *------------------------------------------
  4802. */
  4803. int
  4804. atcommand_reloadstatusdb(
  4805. const int fd, struct map_session_data* sd,
  4806. const char* command, const char* message)
  4807. {
  4808. status_readdb();
  4809. clif_displaymessage(fd, msg_table[256]);
  4810. return 0;
  4811. }
  4812. /*==========================================
  4813. * @reloadpcdb
  4814. * exp.txt skill_tree.txt attr_fix.txt
  4815. * のリロード
  4816. *------------------------------------------
  4817. */
  4818. int
  4819. atcommand_reloadpcdb(
  4820. const int fd, struct map_session_data* sd,
  4821. const char* command, const char* message)
  4822. {
  4823. pc_readdb();
  4824. clif_displaymessage(fd, msg_table[257]);
  4825. return 0;
  4826. }
  4827. /*==========================================
  4828. * @reloadmotd [Valaris]
  4829. * Reloads motd.txt
  4830. *------------------------------------------
  4831. */
  4832. int
  4833. atcommand_reloadmotd(
  4834. const int fd, struct map_session_data* sd,
  4835. const char* command, const char* message)
  4836. {
  4837. pc_read_motd();
  4838. clif_displaymessage(fd, msg_table[268]);
  4839. return 0;
  4840. }
  4841. /*==========================================
  4842. *
  4843. *------------------------------------------
  4844. */
  4845. int atcommand_reloadscript(
  4846. const int fd, struct map_session_data* sd,
  4847. const char* command, const char* message)
  4848. {
  4849. nullpo_retr(-1, sd);
  4850. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4851. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4852. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4853. flush_fifos();
  4854. //do_init_npc();
  4855. script_reload();
  4856. npc_reload();
  4857. npc_event_do_oninit();
  4858. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4859. return 0;
  4860. }
  4861. /*==========================================
  4862. *
  4863. *------------------------------------------
  4864. */
  4865. int atcommand_reloadgmdb( // by [Yor]
  4866. const int fd, struct map_session_data* sd,
  4867. const char* command, const char* message)
  4868. {
  4869. nullpo_retr(-1, sd);
  4870. chrif_reloadGMdb();
  4871. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4872. return 0;
  4873. }
  4874. /*==========================================
  4875. * @mapinfo <map name> [0-3] by MC_Cameri
  4876. * => Shows information about the map [map name]
  4877. * 0 = no additional information
  4878. * 1 = Show users in that map and their location
  4879. * 2 = Shows NPCs in that map
  4880. * 3 = Shows the shops/chats in that map (not implemented)
  4881. *------------------------------------------
  4882. */
  4883. int atcommand_mapinfo(
  4884. const int fd, struct map_session_data* sd,
  4885. const char* command, const char* message)
  4886. {
  4887. struct map_session_data *pl_sd, **pl_allsd;
  4888. struct npc_data *nd = NULL;
  4889. struct chat_data *cd = NULL;
  4890. char direction[12];
  4891. int m_id, i, chat_num, users, list = 0;
  4892. unsigned short m_index;
  4893. nullpo_retr(-1, sd);
  4894. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4895. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4896. memset(direction, '\0', sizeof(direction));
  4897. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4898. if (list < 0 || list > 3) {
  4899. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4900. return -1;
  4901. }
  4902. if (atcmd_player_name[0] == '\0') {
  4903. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4904. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4905. m_id = map_mapindex2mapid(sd->mapindex);
  4906. } else {
  4907. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4908. strcat(atcmd_player_name, ".gat");
  4909. m_id = map_mapname2mapid(atcmd_player_name);
  4910. }
  4911. if (m_id < 0) {
  4912. clif_displaymessage(fd, msg_table[1]); // Map not found.
  4913. return -1;
  4914. }
  4915. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4916. clif_displaymessage(fd, "------ Map Info ------");
  4917. chat_num = 0;
  4918. pl_allsd = map_getallusers(&users);
  4919. for (i = 0; i < users; i++) {
  4920. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4921. chat_num++;
  4922. }
  4923. }
  4924. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
  4925. clif_displaymessage(fd, atcmd_output);
  4926. if (map[m_id].flag.alias)
  4927. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4928. clif_displaymessage(fd, "------ Map Flags ------");
  4929. strcpy(atcmd_output,"PvP Flags: ");
  4930. if (map[m_id].flag.pvp)
  4931. strcat(atcmd_output, "Pvp ON | ");
  4932. if (map[m_id].flag.nopvp)
  4933. strcat(atcmd_output, "NoPvp | ");
  4934. if (map[m_id].flag.pvp_noguild)
  4935. strcat(atcmd_output, "NoGuild | ");
  4936. if (map[m_id].flag.pvp_noparty)
  4937. strcat(atcmd_output, "NoParty | ");
  4938. if (map[m_id].flag.pvp_nightmaredrop)
  4939. strcat(atcmd_output, "NightmareDrop | ");
  4940. if (map[m_id].flag.pvp_nocalcrank)
  4941. strcat(atcmd_output, "NoCalcRank | ");
  4942. clif_displaymessage(fd, atcmd_output);
  4943. strcpy(atcmd_output,"GvG Flags: ");
  4944. if (map[m_id].flag.gvg)
  4945. strcat(atcmd_output, "GvG ON | ");
  4946. if (map[m_id].flag.gvg_dungeon)
  4947. strcat(atcmd_output, "GvG Dungeon | ");
  4948. if (map[m_id].flag.gvg_castle)
  4949. strcat(atcmd_output, "GvG Castle | ");
  4950. if (map[m_id].flag.gvg_noparty)
  4951. strcat(atcmd_output, "NoParty | ");
  4952. clif_displaymessage(fd, atcmd_output);
  4953. strcpy(atcmd_output,"Teleport Flags: ");
  4954. if (map[m_id].flag.noteleport)
  4955. strcat(atcmd_output, "NoTeleport | ");
  4956. if (map[m_id].flag.monster_noteleport)
  4957. strcat(atcmd_output, "Monster NoTeleport | ");
  4958. if (map[m_id].flag.nowarp)
  4959. strcat(atcmd_output, "NoWarp | ");
  4960. if (map[m_id].flag.nowarpto)
  4961. strcat(atcmd_output, "NoWarpTo | ");
  4962. if (map[m_id].flag.noreturn)
  4963. strcat(atcmd_output, "NoReturn | ");
  4964. if (map[m_id].flag.nogo)
  4965. strcat(atcmd_output, "NoGo | ");
  4966. if (map[m_id].flag.nomemo)
  4967. strcat(atcmd_output, "NoMemo | ");
  4968. clif_displaymessage(fd, atcmd_output);
  4969. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4970. clif_displaymessage(fd, atcmd_output);
  4971. if (map[m_id].flag.nosave) {
  4972. if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4973. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4974. else
  4975. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4976. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4977. clif_displaymessage(fd, atcmd_output);
  4978. }
  4979. strcpy(atcmd_output,"Weather Flags: ");
  4980. if (map[m_id].flag.snow)
  4981. strcat(atcmd_output, "Snow | ");
  4982. if (map[m_id].flag.fog)
  4983. strcat(atcmd_output, "Fog | ");
  4984. if (map[m_id].flag.sakura)
  4985. strcat(atcmd_output, "Sakura | ");
  4986. if (map[m_id].flag.clouds)
  4987. strcat(atcmd_output, "Clouds | ");
  4988. if (map[m_id].flag.clouds2)
  4989. strcat(atcmd_output, "Clouds2 | ");
  4990. if (map[m_id].flag.fireworks)
  4991. strcat(atcmd_output, "Fireworks | ");
  4992. if (map[m_id].flag.leaves)
  4993. strcat(atcmd_output, "Leaves | ");
  4994. if (map[m_id].flag.rain)
  4995. strcat(atcmd_output, "Rain | ");
  4996. if (map[m_id].flag.indoors)
  4997. strcat(atcmd_output, "Indoors | ");
  4998. if (map[m_id].flag.nightenabled)
  4999. strcat(atcmd_output, "Displays Night | ");
  5000. clif_displaymessage(fd, atcmd_output);
  5001. strcpy(atcmd_output,"Other Flags: ");
  5002. if (map[m_id].flag.nobranch)
  5003. strcat(atcmd_output, "NoBranch | ");
  5004. if (map[m_id].flag.notrade)
  5005. strcat(atcmd_output, "NoTrade | ");
  5006. if (map[m_id].flag.noskill)
  5007. strcat(atcmd_output, "NoSkill | ");
  5008. if (map[m_id].flag.noicewall)
  5009. strcat(atcmd_output, "NoIcewall | ");
  5010. if (map[m_id].flag.nocommand)
  5011. strcat(atcmd_output, "NoCommand | ");
  5012. clif_displaymessage(fd, atcmd_output);
  5013. strcpy(atcmd_output,"Other Flags: ");
  5014. if (map[m_id].flag.nobaseexp)
  5015. strcat(atcmd_output, "NoBaseEXP | ");
  5016. if (map[m_id].flag.nojobexp)
  5017. strcat(atcmd_output, "NoJobEXP | ");
  5018. if (map[m_id].flag.nomobloot)
  5019. strcat(atcmd_output, "NoMobLoot | ");
  5020. if (map[m_id].flag.nomvploot)
  5021. strcat(atcmd_output, "NoMVPLoot | ");
  5022. clif_displaymessage(fd, atcmd_output);
  5023. switch (list) {
  5024. case 0:
  5025. // Do nothing. It's list 0, no additional display.
  5026. break;
  5027. case 1:
  5028. clif_displaymessage(fd, "----- Players in Map -----");
  5029. for (i = 0; i < users; i++) {
  5030. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5031. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5032. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5033. clif_displaymessage(fd, atcmd_output);
  5034. }
  5035. }
  5036. break;
  5037. case 2:
  5038. clif_displaymessage(fd, "----- NPCs in Map -----");
  5039. for (i = 0; i < map[m_id].npc_num;) {
  5040. nd = map[m_id].npc[i];
  5041. switch(nd->dir) {
  5042. case 0: strcpy(direction, "North"); break;
  5043. case 1: strcpy(direction, "North West"); break;
  5044. case 2: strcpy(direction, "West"); break;
  5045. case 3: strcpy(direction, "South West"); break;
  5046. case 4: strcpy(direction, "South"); break;
  5047. case 5: strcpy(direction, "South East"); break;
  5048. case 6: strcpy(direction, "East"); break;
  5049. case 7: strcpy(direction, "North East"); break;
  5050. case 9: strcpy(direction, "North"); break;
  5051. default: strcpy(direction, "Unknown"); break;
  5052. }
  5053. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5054. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5055. clif_displaymessage(fd, atcmd_output);
  5056. }
  5057. break;
  5058. case 3:
  5059. clif_displaymessage(fd, "----- Chats in Map -----");
  5060. for (i = 0; i < users; i++) {
  5061. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5062. pl_sd->mapindex == m_index &&
  5063. cd->usersd[0] == pl_sd) {
  5064. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5065. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5066. clif_displaymessage(fd, atcmd_output);
  5067. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5068. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5069. clif_displaymessage(fd, atcmd_output);
  5070. }
  5071. }
  5072. break;
  5073. default: // normally impossible to arrive here
  5074. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5075. return -1;
  5076. break;
  5077. }
  5078. return 0;
  5079. }
  5080. /*==========================================
  5081. *
  5082. *------------------------------------------
  5083. */
  5084. int atcommand_mount_peco(
  5085. const int fd, struct map_session_data* sd,
  5086. const char* command, const char* message)
  5087. {
  5088. nullpo_retr(-1, sd);
  5089. if (!pc_isriding(sd)) { // if actually no peco
  5090. if (pc_checkskill(sd, KN_RIDING)) {
  5091. pc_setoption(sd, sd->sc.option | 0x0020);
  5092. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5093. } else {
  5094. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5095. return -1;
  5096. }
  5097. } else { //Dismount
  5098. pc_setoption(sd, sd->sc.option & ~0x0020);
  5099. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5100. }
  5101. return 0;
  5102. }
  5103. /*==========================================
  5104. *
  5105. *------------------------------------------
  5106. */
  5107. int atcommand_char_mount_peco(
  5108. const int fd, struct map_session_data* sd,
  5109. const char* command, const char* message)
  5110. {
  5111. struct map_session_data *pl_sd;
  5112. nullpo_retr(-1, sd);
  5113. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5114. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5115. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5116. return -1;
  5117. }
  5118. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5119. if (!pc_isriding(pl_sd)) { // if actually no peco
  5120. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5121. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5122. clif_displaymessage(fd, msg_table[216]); // Mounted Peco.
  5123. } else {
  5124. clif_displaymessage(fd, msg_table[217]); // You can not mount a peco with your job.
  5125. return -1;
  5126. }
  5127. } else { //Dismount
  5128. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5129. clif_displaymessage(fd, msg_table[218]); // Unmounted Peco.
  5130. }
  5131. } else {
  5132. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5133. return -1;
  5134. }
  5135. return 0;
  5136. }
  5137. /*==========================================
  5138. *Spy Commands by Syrus22
  5139. *------------------------------------------
  5140. */
  5141. int atcommand_guildspy(
  5142. const int fd, struct map_session_data* sd,
  5143. const char* command, const char* message)
  5144. {
  5145. char guild_name[NAME_LENGTH];
  5146. struct guild *g;
  5147. nullpo_retr(-1, sd);
  5148. memset(guild_name, '\0', sizeof(guild_name));
  5149. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5150. if (!enable_spy)
  5151. {
  5152. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5153. return -1;
  5154. }
  5155. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5156. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5157. return -1;
  5158. }
  5159. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5160. (g = guild_search(atoi(message))) != NULL) {
  5161. if (sd->guildspy == g->guild_id) {
  5162. sd->guildspy = 0;
  5163. sprintf(atcmd_output, msg_table[103], g->name); // No longer spying on the %s guild.
  5164. clif_displaymessage(fd, atcmd_output);
  5165. } else {
  5166. sd->guildspy = g->guild_id;
  5167. sprintf(atcmd_output, msg_table[104], g->name); // Spying on the %s guild.
  5168. clif_displaymessage(fd, atcmd_output);
  5169. }
  5170. } else {
  5171. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5172. return -1;
  5173. }
  5174. return 0;
  5175. }
  5176. /*==========================================
  5177. *
  5178. *------------------------------------------
  5179. */
  5180. int atcommand_partyspy(
  5181. const int fd, struct map_session_data* sd,
  5182. const char* command, const char* message)
  5183. {
  5184. char party_name[NAME_LENGTH];
  5185. struct party *p;
  5186. nullpo_retr(-1, sd);
  5187. memset(party_name, '\0', sizeof(party_name));
  5188. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5189. if (!enable_spy)
  5190. {
  5191. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5192. return -1;
  5193. }
  5194. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5195. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5196. return -1;
  5197. }
  5198. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5199. (p = party_search(atoi(message))) != NULL) {
  5200. if (sd->partyspy == p->party_id) {
  5201. sd->partyspy = 0;
  5202. sprintf(atcmd_output, msg_table[105], p->name); // No longer spying on the %s party.
  5203. clif_displaymessage(fd, atcmd_output);
  5204. } else {
  5205. sd->partyspy = p->party_id;
  5206. sprintf(atcmd_output, msg_table[106], p->name); // Spying on the %s party.
  5207. clif_displaymessage(fd, atcmd_output);
  5208. }
  5209. } else {
  5210. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5211. return -1;
  5212. }
  5213. return 0;
  5214. }
  5215. /*==========================================
  5216. * @repairall [Valaris]
  5217. *------------------------------------------
  5218. */
  5219. int atcommand_repairall(
  5220. const int fd, struct map_session_data* sd,
  5221. const char* command, const char* message)
  5222. {
  5223. int count, i;
  5224. nullpo_retr(-1, sd);
  5225. count = 0;
  5226. for (i = 0; i < MAX_INVENTORY; i++) {
  5227. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5228. sd->status.inventory[i].attribute = 0;
  5229. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5230. count++;
  5231. }
  5232. }
  5233. if (count > 0) {
  5234. clif_misceffect(&sd->bl, 3);
  5235. clif_equiplist(sd);
  5236. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5237. } else {
  5238. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5239. return -1;
  5240. }
  5241. return 0;
  5242. }
  5243. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5244. int atcommand_nuke(
  5245. const int fd, struct map_session_data* sd,
  5246. const char* command, const char* message)
  5247. {
  5248. struct map_session_data *pl_sd;
  5249. nullpo_retr(-1, sd);
  5250. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5251. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5252. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5253. return -1;
  5254. }
  5255. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5256. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5257. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5258. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5259. } else {
  5260. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5261. return -1;
  5262. }
  5263. } else {
  5264. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5265. return -1;
  5266. }
  5267. return 0;
  5268. }
  5269. /*==========================================
  5270. *
  5271. *------------------------------------------
  5272. */
  5273. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5274. const char* command, const char* message)
  5275. {
  5276. char NPCname[NAME_LENGTH];
  5277. nullpo_retr(-1, sd);
  5278. memset(NPCname, '\0', sizeof(NPCname));
  5279. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5280. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5281. return -1;
  5282. }
  5283. if (npc_name2id(NPCname) != NULL) {
  5284. npc_enable(NPCname, 1);
  5285. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5286. } else {
  5287. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5288. return -1;
  5289. }
  5290. return 0;
  5291. }
  5292. /*==========================================
  5293. *
  5294. *------------------------------------------
  5295. */
  5296. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5297. const char* command, const char* message)
  5298. {
  5299. char NPCname[NAME_LENGTH];
  5300. nullpo_retr(-1, sd);
  5301. memset(NPCname, '\0', sizeof(NPCname));
  5302. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5303. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5304. return -1;
  5305. }
  5306. if (npc_name2id(NPCname) != NULL) {
  5307. npc_enable(NPCname, 0);
  5308. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5309. } else {
  5310. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5311. return -1;
  5312. }
  5313. return 0;
  5314. }
  5315. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5316. const char* command, const char* message)
  5317. {
  5318. FILE *fp;
  5319. if (!message || !*message) {
  5320. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5321. return -1;
  5322. }
  5323. // check if script file exists
  5324. if ((fp = fopen(message, "r")) == NULL) {
  5325. clif_displaymessage(fd, msg_table[261]);
  5326. return -1;
  5327. }
  5328. fclose(fp);
  5329. // add to list of script sources and run it
  5330. npc_addsrcfile((char *)message);
  5331. npc_parsesrcfile((char *)message);
  5332. clif_displaymessage(fd, msg_table[262]);
  5333. return 0;
  5334. }
  5335. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5336. const char* command, const char* message)
  5337. {
  5338. struct npc_data *nd;
  5339. char NPCname[NAME_LENGTH];
  5340. nullpo_retr(-1, sd);
  5341. memset(NPCname, '\0', sizeof(NPCname));
  5342. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5343. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5344. return -1;
  5345. }
  5346. if ((nd = npc_name2id(NPCname)) != NULL) {
  5347. npc_unload(nd);
  5348. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5349. } else {
  5350. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5351. return -1;
  5352. }
  5353. return 0;
  5354. }
  5355. /*==========================================
  5356. * time in txt for time command (by [Yor])
  5357. *------------------------------------------
  5358. */
  5359. char * txt_time(unsigned int duration) {
  5360. int days, hours, minutes, seconds;
  5361. char temp[256];
  5362. static char temp1[256];
  5363. memset(temp, '\0', sizeof(temp));
  5364. memset(temp1, '\0', sizeof(temp1));
  5365. if (duration < 0)
  5366. duration = 0;
  5367. days = duration / (60 * 60 * 24);
  5368. duration = duration - (60 * 60 * 24 * days);
  5369. hours = duration / (60 * 60);
  5370. duration = duration - (60 * 60 * hours);
  5371. minutes = duration / 60;
  5372. seconds = duration - (60 * minutes);
  5373. if (days < 2)
  5374. sprintf(temp, msg_table[219], days); // %d day
  5375. else
  5376. sprintf(temp, msg_table[220], days); // %d days
  5377. if (hours < 2)
  5378. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5379. else
  5380. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5381. if (minutes < 2)
  5382. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5383. else
  5384. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5385. if (seconds < 2)
  5386. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5387. else
  5388. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5389. return temp1;
  5390. }
  5391. /*==========================================
  5392. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5393. * Calculation management of GM modification (@day/@night GM commands) is done
  5394. *------------------------------------------
  5395. */
  5396. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5397. const char* command, const char* message)
  5398. {
  5399. struct TimerData * timer_data;
  5400. struct TimerData * timer_data2;
  5401. time_t time_server; // variable for number of seconds (used with time() function)
  5402. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5403. char temp[256];
  5404. nullpo_retr(-1, sd);
  5405. memset(temp, '\0', sizeof(temp));
  5406. time(&time_server); // get time in seconds since 1/1/1970
  5407. datetime = localtime(&time_server); // convert seconds in structure
  5408. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5409. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5410. clif_displaymessage(fd, temp);
  5411. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5412. if (night_flag == 0)
  5413. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5414. else
  5415. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5416. } else if (battle_config.night_duration == 0)
  5417. if (night_flag == 1) { // we start with night
  5418. timer_data = get_timer(day_timer_tid);
  5419. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5420. clif_displaymessage(fd, temp);
  5421. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5422. } else
  5423. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5424. else if (battle_config.day_duration == 0)
  5425. if (night_flag == 0) { // we start with day
  5426. timer_data = get_timer(night_timer_tid);
  5427. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5428. clif_displaymessage(fd, temp);
  5429. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5430. } else
  5431. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5432. else {
  5433. if (night_flag == 0) {
  5434. timer_data = get_timer(night_timer_tid);
  5435. timer_data2 = get_timer(day_timer_tid);
  5436. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5437. clif_displaymessage(fd, temp);
  5438. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5439. sprintf(temp, msg_table[237], txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5440. else
  5441. sprintf(temp, msg_table[237], txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5442. clif_displaymessage(fd, temp);
  5443. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5444. clif_displaymessage(fd, temp);
  5445. } else {
  5446. timer_data = get_timer(day_timer_tid);
  5447. timer_data2 = get_timer(night_timer_tid);
  5448. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5449. clif_displaymessage(fd, temp);
  5450. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5451. sprintf(temp, msg_table[239], txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5452. else
  5453. sprintf(temp, msg_table[239], txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5454. clif_displaymessage(fd, temp);
  5455. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5456. clif_displaymessage(fd, temp);
  5457. }
  5458. }
  5459. return 0;
  5460. }
  5461. /*==========================================
  5462. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5463. * removes <quantity> item from a character
  5464. * item can be equiped or not.
  5465. * Inspired from a old command created by RoVeRT
  5466. *------------------------------------------
  5467. */
  5468. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5469. const char* command, const char* message)
  5470. {
  5471. struct map_session_data *pl_sd;
  5472. char item_name[100];
  5473. int i, number = 0, item_id, item_position, count;
  5474. struct item_data *item_data;
  5475. nullpo_retr(-1, sd);
  5476. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5477. memset(item_name, '\0', sizeof(item_name));
  5478. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5479. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5480. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5481. return -1;
  5482. }
  5483. item_id = 0;
  5484. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5485. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5486. item_id = item_data->nameid;
  5487. if (item_id > 500) {
  5488. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5489. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5490. item_position = pc_search_inventory(pl_sd, item_id);
  5491. if (item_position >= 0) {
  5492. count = 0;
  5493. for(i = 0; i < number && item_position >= 0; i++) {
  5494. //Logs (A)dmins items [Lupus]
  5495. if(log_config.pick > 0 ) {
  5496. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5497. }
  5498. //Logs
  5499. pc_delitem(pl_sd, item_position, 1, 0);
  5500. count++;
  5501. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5502. }
  5503. sprintf(atcmd_output, msg_table[113], count); // %d item(s) removed by a GM.
  5504. clif_displaymessage(pl_sd->fd, atcmd_output);
  5505. if (number == count)
  5506. sprintf(atcmd_output, msg_table[114], count); // %d item(s) removed from the player.
  5507. else
  5508. sprintf(atcmd_output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5509. clif_displaymessage(fd, atcmd_output);
  5510. } else {
  5511. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5512. return -1;
  5513. }
  5514. } else {
  5515. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5516. return -1;
  5517. }
  5518. } else {
  5519. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5520. return -1;
  5521. }
  5522. } else {
  5523. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5524. return -1;
  5525. }
  5526. return 0;
  5527. }
  5528. /*==========================================
  5529. * @jail <char_name> by [Yor]
  5530. * Special warp! No check with nowarp and nowarpto flag
  5531. *------------------------------------------
  5532. */
  5533. int atcommand_jail(
  5534. const int fd, struct map_session_data* sd,
  5535. const char* command, const char* message)
  5536. {
  5537. struct map_session_data *pl_sd;
  5538. int x, y;
  5539. unsigned short m_index;
  5540. nullpo_retr(-1, sd);
  5541. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5542. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5543. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5544. return -1;
  5545. }
  5546. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5547. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5548. switch(rand() % 2) {
  5549. case 0:
  5550. x = 24;
  5551. y = 75;
  5552. break;
  5553. default:
  5554. x = 49;
  5555. y = 75;
  5556. break;
  5557. }
  5558. m_index = mapindex_name2id(MAP_JAIL);
  5559. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0) {
  5560. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5561. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5562. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5563. } else {
  5564. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5565. return -1;
  5566. }
  5567. } else {
  5568. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5569. return -1;
  5570. }
  5571. } else {
  5572. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5573. return -1;
  5574. }
  5575. return 0;
  5576. }
  5577. /*==========================================
  5578. * @unjail/@discharge <char_name> by [Yor]
  5579. * Special warp! No check with nowarp and nowarpto flag
  5580. *------------------------------------------
  5581. */
  5582. int atcommand_unjail(
  5583. const int fd, struct map_session_data* sd,
  5584. const char* command, const char* message)
  5585. {
  5586. struct map_session_data *pl_sd;
  5587. unsigned short m_index;
  5588. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5589. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5590. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5591. return -1;
  5592. }
  5593. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5594. m_index = mapindex_name2id(MAP_PRONTERA);
  5595. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5596. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5597. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5598. return -1;
  5599. } else if (pc_setpos(pl_sd, m_index, 0, 0, 3) == 0) { //old coords: 156,191
  5600. pc_setsavepoint(pl_sd, m_index, 0, 0); // Save char respawn point in Prontera
  5601. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5602. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5603. } else {
  5604. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5605. return -1;
  5606. }
  5607. } else {
  5608. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5609. return -1;
  5610. }
  5611. } else {
  5612. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5613. return -1;
  5614. }
  5615. return 0;
  5616. }
  5617. /*==========================================
  5618. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5619. *------------------------------------------
  5620. */
  5621. int atcommand_disguise(
  5622. const int fd, struct map_session_data* sd,
  5623. const char* command, const char* message)
  5624. {
  5625. int id = 0;
  5626. nullpo_retr(-1, sd);
  5627. if (!message || !*message) {
  5628. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5629. return -1;
  5630. }
  5631. if ((id = atoi(message)) > 0)
  5632. { //Acquired an ID
  5633. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5634. id = 0; //Invalid id for either mobs or npcs.
  5635. } else { //Acquired a Name
  5636. if ((id = mobdb_searchname(message)) == 0)
  5637. {
  5638. struct npc_data* nd = npc_name2id(message);
  5639. if (nd != NULL)
  5640. id = nd->n;
  5641. }
  5642. }
  5643. if (id == 0)
  5644. { // Monster/NPC name/id hasn't been found.
  5645. clif_displaymessage(fd, msg_table[123]);
  5646. return -1;
  5647. }
  5648. /* The previous way....
  5649. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5650. mob_id = atoi(message);
  5651. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5652. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5653. (mob_id >= 813 && mob_id <= 858) || // NPC
  5654. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5655. */
  5656. pc_stop_walking(sd,0);
  5657. clif_clearchar(&sd->bl, 0);
  5658. sd->disguise = id;
  5659. sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5660. clif_changeoption(&sd->bl);
  5661. clif_spawnpc(sd);
  5662. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5663. return 0;
  5664. }
  5665. /*==========================================
  5666. * DisguiseAll
  5667. *------------------------------------------
  5668. */
  5669. int atcommand_disguiseall(
  5670. const int fd, struct map_session_data* sd,
  5671. const char* command, const char* message)
  5672. {
  5673. int mob_id=0, i=0, users;
  5674. struct map_session_data *pl_sd, **pl_allsd;
  5675. nullpo_retr(-1, sd);
  5676. if (!message || !*message) {
  5677. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5678. return -1;
  5679. }
  5680. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5681. mob_id = atoi(message);
  5682. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5683. pl_allsd = map_getallusers(&users);
  5684. for(i=0; i < users; i++) {
  5685. if((pl_sd = pl_allsd[i])) {
  5686. pc_stop_walking(pl_sd,0);
  5687. clif_clearchar(&pl_sd->bl, 0);
  5688. pl_sd->disguise = mob_id;
  5689. pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5690. clif_changeoption(&pl_sd->bl);
  5691. clif_spawnpc(pl_sd);
  5692. }
  5693. }
  5694. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5695. } else {
  5696. return -1;
  5697. }
  5698. return 0;
  5699. }
  5700. /*==========================================
  5701. * @undisguise by [Yor]
  5702. *------------------------------------------
  5703. */
  5704. int atcommand_undisguise(
  5705. const int fd, struct map_session_data* sd,
  5706. const char* command, const char* message)
  5707. {
  5708. nullpo_retr(-1, sd);
  5709. if (sd->disguise) {
  5710. pc_stop_walking(sd,0);
  5711. clif_clearchar(&sd->bl, 0);
  5712. sd->disguise = 0;
  5713. clif_changeoption(&sd->bl);
  5714. clif_spawnpc(sd);
  5715. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5716. } else {
  5717. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5718. return -1;
  5719. }
  5720. return 0;
  5721. }
  5722. /*==========================================
  5723. * UndisguiseAll
  5724. *------------------------------------------
  5725. */
  5726. int atcommand_undisguiseall(
  5727. const int fd, struct map_session_data* sd,
  5728. const char* command, const char* message)
  5729. {
  5730. struct map_session_data *pl_sd, **pl_allsd;
  5731. int i, users;
  5732. nullpo_retr(-1, sd);
  5733. pl_allsd = map_getallusers(&users);
  5734. for(i=0; i < users; i++) {
  5735. if((pl_sd = pl_allsd[i]) && pl_sd->disguise) {
  5736. pc_stop_walking(pl_sd,0);
  5737. clif_clearchar(&pl_sd->bl, 0);
  5738. pl_sd->disguise = 0;
  5739. clif_changeoption(&pl_sd->bl);
  5740. clif_spawnpc(pl_sd);
  5741. }
  5742. }
  5743. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5744. return 0;
  5745. }
  5746. /*==========================================
  5747. * @exp by [Skotlex]
  5748. *------------------------------------------
  5749. */
  5750. int atcommand_exp(
  5751. const int fd, struct map_session_data* sd,
  5752. const char* command, const char* message)
  5753. {
  5754. char output[200];
  5755. double nextb, nextj;
  5756. nullpo_retr(-1, sd);
  5757. memset(output, '\0', sizeof(output));
  5758. nextb = pc_nextbaseexp(sd);
  5759. if (nextb)
  5760. nextb = sd->status.base_exp*100.0/nextb;
  5761. nextj = pc_nextjobexp(sd);
  5762. if (nextj)
  5763. nextj = sd->status.job_exp*100.0/nextj;
  5764. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5765. clif_displaymessage(fd, output);
  5766. return 0;
  5767. }
  5768. /*==========================================
  5769. * @broadcast by [Valaris]
  5770. *------------------------------------------
  5771. */
  5772. int atcommand_broadcast(
  5773. const int fd, struct map_session_data* sd,
  5774. const char* command, const char* message)
  5775. {
  5776. nullpo_retr(-1, sd);
  5777. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5778. if (!message || !*message) {
  5779. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5780. return -1;
  5781. }
  5782. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5783. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5784. return 0;
  5785. }
  5786. /*==========================================
  5787. * @localbroadcast by [Valaris]
  5788. *------------------------------------------
  5789. */
  5790. int atcommand_localbroadcast(
  5791. const int fd, struct map_session_data* sd,
  5792. const char* command, const char* message)
  5793. {
  5794. nullpo_retr(-1, sd);
  5795. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5796. if (!message || !*message) {
  5797. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5798. return -1;
  5799. }
  5800. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5801. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5802. return 0;
  5803. }
  5804. /*==========================================
  5805. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5806. *------------------------------------------
  5807. */
  5808. int atcommand_chardisguise(
  5809. const int fd, struct map_session_data* sd,
  5810. const char* command, const char* message)
  5811. {
  5812. int mob_id;
  5813. char mob_name[NAME_LENGTH];
  5814. struct map_session_data* pl_sd;
  5815. nullpo_retr(-1, sd);
  5816. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5817. memset(mob_name, '\0', sizeof(mob_name));
  5818. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5819. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5820. return -1;
  5821. }
  5822. if ((mob_id = atoi(mob_name)) > 0)
  5823. { //Acquired an ID
  5824. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5825. mob_id = 0; //Invalid id for either mobs or npcs.
  5826. } else { //Acquired a Name
  5827. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5828. {
  5829. struct npc_data* nd = npc_name2id(mob_name);
  5830. if (nd != NULL)
  5831. mob_id = nd->n;
  5832. }
  5833. }
  5834. if (mob_id == 0)
  5835. {
  5836. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5837. return -1;
  5838. }
  5839. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5840. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5841. pc_stop_walking(pl_sd,0);
  5842. clif_clearchar(&pl_sd->bl, 0);
  5843. pl_sd->disguise = mob_id;
  5844. pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5845. clif_changeoption(&pl_sd->bl);
  5846. clif_spawnpc(pl_sd);
  5847. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5848. } else {
  5849. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5850. return -1;
  5851. }
  5852. } else {
  5853. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5854. return -1;
  5855. }
  5856. return 0;
  5857. }
  5858. /*==========================================
  5859. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5860. *------------------------------------------
  5861. */
  5862. int atcommand_charundisguise(
  5863. const int fd, struct map_session_data* sd,
  5864. const char* command, const char* message)
  5865. {
  5866. struct map_session_data* pl_sd;
  5867. nullpo_retr(-1, sd);
  5868. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5869. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5870. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5871. return -1;
  5872. }
  5873. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5874. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5875. if (pl_sd->disguise) {
  5876. pc_stop_walking(pl_sd,0);
  5877. clif_clearchar(&pl_sd->bl, 0);
  5878. pl_sd->disguise = 0;
  5879. clif_changeoption(&pl_sd->bl);
  5880. clif_spawnpc(pl_sd);
  5881. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5882. } else {
  5883. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5884. return -1;
  5885. }
  5886. } else {
  5887. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5888. return -1;
  5889. }
  5890. } else {
  5891. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5892. return -1;
  5893. }
  5894. return 0;
  5895. }
  5896. /*==========================================
  5897. * @email <actual@email> <new@email> by [Yor]
  5898. *------------------------------------------
  5899. */
  5900. int atcommand_email(
  5901. const int fd, struct map_session_data* sd,
  5902. const char* command, const char* message)
  5903. {
  5904. char actual_email[100];
  5905. char new_email[100];
  5906. nullpo_retr(-1, sd);
  5907. memset(actual_email, '\0', sizeof(actual_email));
  5908. memset(new_email, '\0', sizeof(new_email));
  5909. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5910. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5911. return -1;
  5912. }
  5913. if (e_mail_check(actual_email) == 0) {
  5914. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5915. return -1;
  5916. } else if (e_mail_check(new_email) == 0) {
  5917. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5918. return -1;
  5919. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5920. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5921. return -1;
  5922. } else if (strcmpi(actual_email, new_email) == 0) {
  5923. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5924. return -1;
  5925. } else {
  5926. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5927. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5928. }
  5929. return 0;
  5930. }
  5931. /*==========================================
  5932. *@effect
  5933. *------------------------------------------
  5934. */
  5935. int atcommand_effect(
  5936. const int fd, struct map_session_data* sd,
  5937. const char* command, const char* message)
  5938. {
  5939. struct map_session_data *pl_sd, **pl_allsd;
  5940. int type = 0, flag = 0, i, users;
  5941. nullpo_retr(-1, sd);
  5942. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5943. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5944. return -1;
  5945. }
  5946. if(flag <=0){
  5947. clif_specialeffect(&sd->bl, type, flag);
  5948. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5949. }
  5950. else{
  5951. pl_allsd = map_getallusers(&users);
  5952. for (i = 0; i < users; i++) {
  5953. if ((pl_sd = pl_allsd[i])) {
  5954. clif_specialeffect(&pl_sd->bl, type, flag);
  5955. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5956. }
  5957. }
  5958. }
  5959. return 0;
  5960. }
  5961. /*==========================================
  5962. * @charcartlist <character>: Displays the items list of a player's cart.
  5963. *------------------------------------------
  5964. */
  5965. int
  5966. atcommand_character_cart_list(
  5967. const int fd, struct map_session_data* sd,
  5968. const char* command, const char* message)
  5969. {
  5970. char outputtmp[200];
  5971. struct map_session_data *pl_sd;
  5972. struct item_data *item_data, *item_temp;
  5973. int i, j, count, counter, counter2;
  5974. nullpo_retr(-1, sd);
  5975. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5976. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5977. memset(outputtmp, '\0', sizeof(outputtmp));
  5978. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5979. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5980. return -1;
  5981. }
  5982. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5983. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5984. counter = 0;
  5985. count = 0;
  5986. for (i = 0; i < MAX_CART; i++) {
  5987. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5988. counter = counter + pl_sd->status.cart[i].amount;
  5989. count++;
  5990. if (count == 1) {
  5991. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  5992. clif_displaymessage(fd, atcmd_output);
  5993. }
  5994. if (pl_sd->status.cart[i].refine)
  5995. sprintf(atcmd_output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  5996. else
  5997. sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  5998. clif_displaymessage(fd, atcmd_output);
  5999. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6000. counter2 = 0;
  6001. for (j = 0; j < item_data->slot; j++) {
  6002. if (pl_sd->status.cart[i].card[j]) {
  6003. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6004. if (atcmd_output[0] == '\0')
  6005. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6006. else
  6007. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6008. strcat(atcmd_output, outputtmp);
  6009. }
  6010. }
  6011. }
  6012. if (atcmd_output[0] != '\0') {
  6013. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6014. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6015. clif_displaymessage(fd, atcmd_output);
  6016. }
  6017. }
  6018. }
  6019. if (count == 0)
  6020. clif_displaymessage(fd, "No item found in the cart of this player.");
  6021. else {
  6022. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6023. clif_displaymessage(fd, atcmd_output);
  6024. }
  6025. } else {
  6026. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6027. return -1;
  6028. }
  6029. } else {
  6030. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6031. return -1;
  6032. }
  6033. return 0;
  6034. }
  6035. /*==========================================
  6036. * @killer by MouseJstr
  6037. * enable killing players even when not in pvp
  6038. *------------------------------------------
  6039. */
  6040. int
  6041. atcommand_killer(
  6042. const int fd, struct map_session_data* sd,
  6043. const char* command, const char* message)
  6044. {
  6045. nullpo_retr(-1, sd);
  6046. sd->special_state.killer = !sd->special_state.killer;
  6047. if(sd->special_state.killer)
  6048. clif_displaymessage(fd, msg_table[241]);
  6049. else
  6050. clif_displaymessage(fd, msg_table[242]);
  6051. return 0;
  6052. }
  6053. /*==========================================
  6054. * @killable by MouseJstr
  6055. * enable other people killing you
  6056. *------------------------------------------
  6057. */
  6058. int
  6059. atcommand_killable(
  6060. const int fd, struct map_session_data* sd,
  6061. const char* command, const char* message)
  6062. {
  6063. nullpo_retr(-1, sd);
  6064. sd->special_state.killable = !sd->special_state.killable;
  6065. if(sd->special_state.killable)
  6066. clif_displaymessage(fd, msg_table[242]);
  6067. else
  6068. clif_displaymessage(fd, msg_table[241]);
  6069. return 0;
  6070. }
  6071. /*==========================================
  6072. * @charkillable by MouseJstr
  6073. * enable another player to be killed
  6074. *------------------------------------------
  6075. */
  6076. int
  6077. atcommand_charkillable(
  6078. const int fd, struct map_session_data* sd,
  6079. const char* command, const char* message)
  6080. {
  6081. struct map_session_data *pl_sd = NULL;
  6082. nullpo_retr(-1, sd);
  6083. if (!message || !*message)
  6084. return -1;
  6085. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6086. return -1;
  6087. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6088. if(pl_sd->special_state.killable)
  6089. clif_displaymessage(fd, "The player is now killable");
  6090. else
  6091. clif_displaymessage(fd, "The player is no longer killable");
  6092. return 0;
  6093. }
  6094. /*==========================================
  6095. * @skillon by MouseJstr
  6096. * turn skills on for the map
  6097. *------------------------------------------
  6098. */
  6099. int
  6100. atcommand_skillon(
  6101. const int fd, struct map_session_data* sd,
  6102. const char* command, const char* message)
  6103. {
  6104. nullpo_retr(-1, sd);
  6105. map[sd->bl.m].flag.noskill = 0;
  6106. clif_displaymessage(fd, msg_table[244]);
  6107. return 0;
  6108. }
  6109. /*==========================================
  6110. * @skilloff by MouseJstr
  6111. * Turn skills off on the map
  6112. *------------------------------------------
  6113. */
  6114. int
  6115. atcommand_skilloff(
  6116. const int fd, struct map_session_data* sd,
  6117. const char* command, const char* message)
  6118. {
  6119. nullpo_retr(-1, sd);
  6120. map[sd->bl.m].flag.noskill = 1;
  6121. clif_displaymessage(fd, msg_table[243]);
  6122. return 0;
  6123. }
  6124. /*==========================================
  6125. * @npcmove by MouseJstr
  6126. *
  6127. * move a npc
  6128. *------------------------------------------
  6129. */
  6130. int
  6131. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6132. const char* command, const char* message)
  6133. {
  6134. int x = 0, y = 0;
  6135. struct npc_data *nd = 0;
  6136. nullpo_retr(-1, sd);
  6137. if (!message || !*message)
  6138. return -1;
  6139. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6140. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6141. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6142. return -1;
  6143. }
  6144. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6145. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6146. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6147. return -1;
  6148. npc_enable(atcmd_player_name, 0);
  6149. nd->bl.x = x;
  6150. nd->bl.y = y;
  6151. npc_enable(atcmd_player_name, 1);
  6152. return 0;
  6153. }
  6154. /*==========================================
  6155. * @addwarp by MouseJstr
  6156. *
  6157. * Create a new static warp point.
  6158. *------------------------------------------
  6159. */
  6160. int
  6161. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6162. const char* command, const char* message)
  6163. {
  6164. char w1[64], w3[64], w4[64];
  6165. int x,y,ret;
  6166. nullpo_retr(-1, sd);
  6167. if (!message || !*message)
  6168. return -1;
  6169. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6170. return -1;
  6171. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6172. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6173. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6174. ret = npc_parse_warp(w1, "warp", w3, w4);
  6175. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6176. clif_displaymessage(fd, atcmd_output);
  6177. return ret;
  6178. }
  6179. /*==========================================
  6180. * @follow by [MouseJstr]
  6181. *
  6182. * Follow a player .. staying no more then 5 spaces away
  6183. *------------------------------------------
  6184. */
  6185. int
  6186. atcommand_follow(const int fd, struct map_session_data* sd,
  6187. const char* command, const char* message)
  6188. {
  6189. struct map_session_data *pl_sd = NULL;
  6190. nullpo_retr(-1, sd);
  6191. if (!message || !*message) {
  6192. if (sd->followtarget == -1)
  6193. return -1;
  6194. pc_stop_following (sd);
  6195. clif_displaymessage(fd, "Stop following");
  6196. return 0;
  6197. }
  6198. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6199. if (sd->followtarget == pl_sd->bl.id)
  6200. pc_stop_following (sd);
  6201. else
  6202. pc_follow(sd, pl_sd->bl.id);
  6203. return 0;
  6204. }
  6205. return 1;
  6206. }
  6207. /*==========================================
  6208. * @dropall by [MouseJstr]
  6209. *
  6210. * Drop all your possession on the ground
  6211. *------------------------------------------
  6212. */
  6213. int
  6214. atcommand_dropall(const int fd, struct map_session_data* sd,
  6215. const char* command, const char* message)
  6216. {
  6217. int i;
  6218. nullpo_retr(-1, sd);
  6219. for (i = 0; i < MAX_INVENTORY; i++) {
  6220. if (sd->status.inventory[i].amount) {
  6221. if(sd->status.inventory[i].equip != 0)
  6222. pc_unequipitem(sd, i, 3);
  6223. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6224. }
  6225. }
  6226. return 0;
  6227. }
  6228. /*==========================================
  6229. * @chardropall by [MouseJstr]
  6230. *
  6231. * Throw all the characters possessions on the ground. Normally
  6232. * done in response to them being disrespectful of a GM
  6233. *------------------------------------------
  6234. */
  6235. int
  6236. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6237. const char* command, const char* message)
  6238. {
  6239. int i;
  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. return -1;
  6246. for (i = 0; i < MAX_INVENTORY; i++) {
  6247. if (pl_sd->status.inventory[i].amount) {
  6248. if(pl_sd->status.inventory[i].equip != 0)
  6249. pc_unequipitem(pl_sd, i, 3);
  6250. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6251. }
  6252. }
  6253. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6254. clif_displaymessage(fd, "It is done");
  6255. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6256. return 0;
  6257. }
  6258. /*==========================================
  6259. * @storeall by [MouseJstr]
  6260. *
  6261. * Put everything into storage to simplify your inventory to make
  6262. * debugging easie
  6263. *------------------------------------------
  6264. */
  6265. int
  6266. atcommand_storeall(const int fd, struct map_session_data* sd,
  6267. const char* command, const char* message)
  6268. {
  6269. int i;
  6270. nullpo_retr(-1, sd);
  6271. if (storage_storageopen(sd) == 1) {
  6272. clif_displaymessage(fd, "run this command again..");
  6273. return 0;
  6274. }
  6275. for (i = 0; i < MAX_INVENTORY; i++) {
  6276. if (sd->status.inventory[i].amount) {
  6277. if(sd->status.inventory[i].equip != 0)
  6278. pc_unequipitem(sd, i, 3);
  6279. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6280. }
  6281. }
  6282. storage_storageclose(sd);
  6283. clif_displaymessage(fd, "It is done");
  6284. return 0;
  6285. }
  6286. /*==========================================
  6287. * @charstoreall by [MouseJstr]
  6288. *
  6289. * A way to screw with players who piss you off
  6290. *------------------------------------------
  6291. */
  6292. int
  6293. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6294. const char* command, const char* message)
  6295. {
  6296. int i;
  6297. struct map_session_data *pl_sd = NULL;
  6298. nullpo_retr(-1, sd);
  6299. if (!message || !*message)
  6300. return -1;
  6301. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6302. return -1;
  6303. if (storage_storageopen(pl_sd) == 1) {
  6304. clif_displaymessage(fd, "Had to open the characters storage window...");
  6305. clif_displaymessage(fd, "run this command again..");
  6306. return 0;
  6307. }
  6308. for (i = 0; i < MAX_INVENTORY; i++) {
  6309. if (pl_sd->status.inventory[i].amount) {
  6310. if(pl_sd->status.inventory[i].equip != 0)
  6311. pc_unequipitem(pl_sd, i, 3);
  6312. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6313. }
  6314. }
  6315. storage_storageclose(pl_sd);
  6316. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6317. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6318. clif_displaymessage(pl_sd->fd, " -- the management");
  6319. clif_displaymessage(fd, "It is done");
  6320. return 0;
  6321. }
  6322. /*==========================================
  6323. * @skillid by [MouseJstr]
  6324. *
  6325. * lookup a skill by name
  6326. *------------------------------------------
  6327. */
  6328. int
  6329. atcommand_skillid(const int fd, struct map_session_data* sd,
  6330. const char* command, const char* message)
  6331. {
  6332. int skillen, idx;
  6333. nullpo_retr(-1, sd);
  6334. if (!message || !*message)
  6335. return -1;
  6336. skillen = strlen(message);
  6337. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6338. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6339. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6340. {
  6341. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6342. clif_displaymessage(fd, atcmd_output);
  6343. }
  6344. }
  6345. return 0;
  6346. }
  6347. /*==========================================
  6348. * @useskill by [MouseJstr]
  6349. *
  6350. * A way of using skills without having to find them in the skills menu
  6351. *------------------------------------------
  6352. */
  6353. int
  6354. atcommand_useskill(const int fd, struct map_session_data* sd,
  6355. const char* command, const char* message)
  6356. {
  6357. struct map_session_data *pl_sd = NULL;
  6358. int skillnum;
  6359. int skilllv;
  6360. char target[255];
  6361. nullpo_retr(-1, sd);
  6362. if (!message || !*message)
  6363. return -1;
  6364. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6365. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6366. return -1;
  6367. }
  6368. if((pl_sd=map_nick2sd(target)) == NULL) {
  6369. return -1;
  6370. }
  6371. if (skill_get_inf(skillnum) & INF_GROUND_SKILL)
  6372. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6373. else
  6374. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6375. return 0;
  6376. }
  6377. /*==========================================
  6378. * @skilltree by [MouseJstr]
  6379. *
  6380. * prints the skill tree for a player required to get to a skill
  6381. *------------------------------------------
  6382. */
  6383. int
  6384. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6385. const char* command, const char* message)
  6386. {
  6387. struct map_session_data *pl_sd = NULL;
  6388. int skillnum, skillidx = -1;
  6389. int meets = 1, j, c=0;
  6390. char target[NAME_LENGTH], *tbl;
  6391. struct skill_tree_entry *ent;
  6392. nullpo_retr(-1, sd);
  6393. if (!message || !*message)
  6394. return -1;
  6395. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6396. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6397. return -1;
  6398. }
  6399. if((pl_sd=map_nick2sd(target)) == NULL)
  6400. return -1;
  6401. c = pc_calc_skilltree_normalize_job(pl_sd);
  6402. tbl = job_name(c);
  6403. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6404. tbl, pc_checkskill(pl_sd, 1));
  6405. clif_displaymessage(fd, atcmd_output);
  6406. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6407. if (skill_tree[c][j].id == skillnum) {
  6408. skillidx = j;
  6409. break;
  6410. }
  6411. }
  6412. if (skillidx == -1) {
  6413. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6414. clif_displaymessage(fd, atcmd_output);
  6415. return 0;
  6416. }
  6417. ent = &skill_tree[c][skillidx];
  6418. for(j=0;j<5;j++)
  6419. if( ent->need[j].id &&
  6420. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6421. {
  6422. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6423. sprintf(atcmd_output, "player requires level %d of skill %s",
  6424. ent->need[j].lv, desc);
  6425. clif_displaymessage(fd, atcmd_output);
  6426. meets = 0;
  6427. }
  6428. if (meets == 1) {
  6429. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6430. clif_displaymessage(fd, atcmd_output);
  6431. }
  6432. return 0;
  6433. }
  6434. // Hand a ring with partners name on it to this char
  6435. void getring (struct map_session_data *sd)
  6436. {
  6437. int flag,item_id = 0;
  6438. struct item item_tmp;
  6439. if(sd->status.sex==0)
  6440. item_id = 2635;
  6441. else
  6442. item_id = 2634;
  6443. memset(&item_tmp,0,sizeof(item_tmp));
  6444. item_tmp.nameid=item_id;
  6445. item_tmp.identify=1;
  6446. item_tmp.card[0]=255;
  6447. item_tmp.card[2]=sd->status.partner_id;
  6448. item_tmp.card[3]=sd->status.partner_id >> 16;
  6449. //Logs (A)dmins items [Lupus]
  6450. if(log_config.pick > 0 ) {
  6451. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6452. }
  6453. //Logs
  6454. if((flag = pc_additem(sd,&item_tmp,1))) {
  6455. clif_additem(sd,0,0,flag);
  6456. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6457. }
  6458. }
  6459. /*==========================================
  6460. * @marry by [MouseJstr], fixed by Lupus
  6461. *
  6462. * Marry two players
  6463. *------------------------------------------
  6464. */
  6465. int
  6466. atcommand_marry(const int fd, struct map_session_data* sd,
  6467. const char* command, const char* message)
  6468. {
  6469. struct map_session_data *pl_sd1 = NULL;
  6470. struct map_session_data *pl_sd2 = NULL;
  6471. char player1[128], player2[128]; //Length used for return error msgs
  6472. nullpo_retr(-1, sd);
  6473. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6474. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6475. return -1;
  6476. }
  6477. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6478. sprintf(player2, "Cannot find player '%s' online", player1);
  6479. clif_displaymessage(fd, player2);
  6480. return -1;
  6481. }
  6482. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6483. sprintf(player1, "Cannot find player '%s' online", player2);
  6484. clif_displaymessage(fd, player1);
  6485. return -1;
  6486. }
  6487. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6488. clif_displaymessage(fd, "They are married.. wish them well");
  6489. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6490. // Auto-give named rings (Aru)
  6491. getring (pl_sd1);
  6492. getring (pl_sd2);
  6493. return 0;
  6494. }
  6495. return -1;
  6496. }
  6497. /*==========================================
  6498. * @divorce by [MouseJstr], fixed by [Lupus]
  6499. *
  6500. * divorce two players
  6501. *------------------------------------------
  6502. */
  6503. int
  6504. atcommand_divorce(const int fd, struct map_session_data* sd,
  6505. const char* command, const char* message)
  6506. {
  6507. struct map_session_data *pl_sd = NULL;
  6508. nullpo_retr(-1, sd);
  6509. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6510. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6511. return -1;
  6512. }
  6513. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6514. if (pc_divorce(pl_sd) != 0) {
  6515. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6516. clif_displaymessage(fd, atcmd_output);
  6517. return -1;
  6518. } else {
  6519. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6520. clif_displaymessage(fd, atcmd_output);
  6521. return 0;
  6522. }
  6523. }
  6524. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6525. clif_displaymessage(fd, atcmd_output);
  6526. return -1;
  6527. }
  6528. #ifdef DMALLOC
  6529. unsigned long dmark_;
  6530. int
  6531. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6532. const char* command, const char* message)
  6533. {
  6534. dmark_ = dmalloc_mark();
  6535. clif_displaymessage(fd, "debug mark set");
  6536. return 0;
  6537. }
  6538. int
  6539. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6540. const char* command, const char* message)
  6541. {
  6542. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6543. dmark_ = dmalloc_mark();
  6544. clif_displaymessage(fd, "malloc changes logged");
  6545. return 0;
  6546. }
  6547. #endif
  6548. /*==========================================
  6549. * @grind by [MouseJstr]
  6550. *------------------------------------------
  6551. */
  6552. int
  6553. atcommand_grind(const int fd, struct map_session_data* sd,
  6554. const char* command, const char* message)
  6555. {
  6556. struct map_session_data *pl_sd = NULL;
  6557. int skillnum;
  6558. int inf;
  6559. char target[NAME_LENGTH];
  6560. nullpo_retr(-1, sd);
  6561. if (!message || !*message)
  6562. return -1;
  6563. if(sscanf(message, "%23s", target) != 1) {
  6564. clif_displaymessage(fd, "Usage: @grind <target>");
  6565. return -1;
  6566. }
  6567. if((pl_sd=map_nick2sd(target)) == NULL)
  6568. return -1;
  6569. for (skillnum = 1; skillnum < 500; skillnum++) {
  6570. sd->status.sp = sd->status.max_sp;
  6571. atcommand_alive(fd, sd, command, message);
  6572. inf = skill_get_inf(skillnum);
  6573. if (inf & INF_GROUND_SKILL)
  6574. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6575. else if (!(inf & INF_SUPPORT_SKILL))
  6576. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6577. }
  6578. return 0;
  6579. }
  6580. /*==========================================
  6581. * @grind2 by [MouseJstr]
  6582. *------------------------------------------
  6583. */
  6584. int
  6585. atcommand_grind2(const int fd, struct map_session_data* sd,
  6586. const char* command, const char* message)
  6587. {
  6588. int i, x, y, id;
  6589. for (i = 1000; i <2000; i++) {
  6590. x = sd->bl.x + (rand() % 10 - 5);
  6591. y = sd->bl.y + (rand() % 10 - 5);
  6592. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6593. }
  6594. return 0;
  6595. }
  6596. /*==========================================
  6597. * @changelook by [Celest]
  6598. *------------------------------------------
  6599. */
  6600. int
  6601. atcommand_changelook(const int fd, struct map_session_data* sd,
  6602. const char* command, const char* message)
  6603. {
  6604. int i, j = 0, k = 0;
  6605. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6606. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6607. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6608. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6609. return -1;
  6610. } else if (i == 2) {
  6611. if (j < 1) j = 1;
  6612. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6613. j = pos[j - 1];
  6614. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6615. k = j; // swap
  6616. j = LOOK_HEAD_TOP;
  6617. }
  6618. clif_changelook(&sd->bl,j,k);
  6619. return 0;
  6620. }
  6621. /*==========================================
  6622. *Turns on/off Autotrade for a specific player
  6623. *------------------------------------------
  6624. *by durf (changed by Lupus)
  6625. */
  6626. int
  6627. atcommand_autotrade(
  6628. const int fd, struct map_session_data* sd,
  6629. const char* command, const char* message)
  6630. {
  6631. nullpo_retr(-1, sd);
  6632. if (sd->vender_id) //check if player's vending
  6633. {
  6634. sd->state.autotrade = 1;
  6635. clif_authfail_fd(fd, 15);
  6636. }
  6637. else
  6638. {
  6639. //"You should be vending to use @Autotrade."
  6640. clif_displaymessage(fd, msg_txt(549));
  6641. }
  6642. return 0;
  6643. }
  6644. /*==========================================
  6645. * Changes Master of your Guild to a specified guild member
  6646. *------------------------------------------
  6647. *by durf (changed by Lupus)
  6648. */
  6649. int
  6650. atcommand_changegm(
  6651. const int fd, struct map_session_data* sd,
  6652. const char* command, const char* message)
  6653. {
  6654. struct guild *g;
  6655. struct map_session_data *pl_sd;
  6656. nullpo_retr(-1, sd);
  6657. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6658. {
  6659. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6660. return -1;
  6661. }
  6662. if (strlen(message)==0)
  6663. {
  6664. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6665. return -1;
  6666. }
  6667. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6668. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6669. return -1;
  6670. }
  6671. guild_gm_change(sd->status.guild_id, pl_sd);
  6672. return 0;
  6673. }
  6674. /*==========================================
  6675. *Changes the leader of a party.
  6676. *------------------------------------------
  6677. *by Skotlex
  6678. */
  6679. int
  6680. atcommand_changeleader(
  6681. const int fd, struct map_session_data* sd,
  6682. const char* command, const char* message)
  6683. {
  6684. struct party *p;
  6685. struct map_session_data *pl_sd;
  6686. int mi, pl_mi;
  6687. nullpo_retr(-1, sd);
  6688. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6689. {
  6690. clif_displaymessage(fd, "You need to be a party's leader to use this command.");
  6691. return -1;
  6692. }
  6693. for (mi = 0; mi < MAX_PARTY && p->member[mi].sd != sd; mi++);
  6694. if (mi == MAX_PARTY)
  6695. return -1; //Shouldn't happen
  6696. if (!p->member[mi].leader)
  6697. {
  6698. clif_displaymessage(fd, "You need to be the party's leader to use this command.");
  6699. return -1;
  6700. }
  6701. if (strlen(message)==0)
  6702. {
  6703. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6704. return -1;
  6705. }
  6706. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6707. clif_displaymessage(fd, "Target character must be online and be in your party.");
  6708. return -1;
  6709. }
  6710. for (pl_mi = 0; pl_mi < MAX_PARTY && p->member[pl_mi].sd != pl_sd; pl_mi++);
  6711. if (pl_mi == MAX_PARTY)
  6712. return -1; //Shouldn't happen
  6713. //Change leadership.
  6714. p->member[mi].leader = 0;
  6715. if (p->member[mi].sd->fd)
  6716. clif_displaymessage(p->member[mi].sd->fd, "Leadership transferred.");
  6717. p->member[pl_mi].leader = 1;
  6718. if (p->member[pl_mi].sd->fd)
  6719. clif_displaymessage(p->member[pl_mi].sd->fd, "You've become the party leader.");
  6720. intif_party_leaderchange(p->party_id,p->member[pl_mi].account_id,p->member[pl_mi].char_id);
  6721. //Update info.
  6722. clif_party_main_info(p,-1);
  6723. clif_party_info(p,-1);
  6724. return 0;
  6725. }
  6726. /*==========================================
  6727. *Turns on/off AutoLoot for a specific player
  6728. *------------------------------------------
  6729. *by Upa-Kun
  6730. */
  6731. int
  6732. atcommand_autoloot(
  6733. const int fd, struct map_session_data* sd,
  6734. const char* command, const char* message)
  6735. {
  6736. int rate;
  6737. double drate;
  6738. nullpo_retr(-1, sd);
  6739. if (!message || !*message) {
  6740. if (sd->state.autoloot)
  6741. rate = 0;
  6742. else
  6743. rate = 10000;
  6744. } else {
  6745. drate = atof(message);
  6746. rate = (int)(drate*100);
  6747. }
  6748. if (rate > 10000) rate = 10000;
  6749. else if (rate < 0) rate = 0;
  6750. sd->state.autoloot = rate;
  6751. if (sd->state.autoloot) {
  6752. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6753. clif_displaymessage(fd, atcmd_output);
  6754. }else
  6755. clif_displaymessage(fd, "Autoloot is now off.");
  6756. return 0;
  6757. }
  6758. /*==========================================
  6759. * It is made to rain.
  6760. *------------------------------------------
  6761. */
  6762. int
  6763. atcommand_rain(
  6764. const int fd, struct map_session_data* sd,
  6765. const char* command, const char* message)
  6766. {
  6767. nullpo_retr(-1, sd);
  6768. if (map[sd->bl.m].flag.rain) {
  6769. map[sd->bl.m].flag.rain=0;
  6770. clif_weather(sd->bl.m);
  6771. clif_displaymessage(fd, "The rain has stopped.");
  6772. } else {
  6773. map[sd->bl.m].flag.rain=1;
  6774. clif_weather(sd->bl.m);
  6775. clif_displaymessage(fd, "It is made to rain.");
  6776. }
  6777. return 0;
  6778. }
  6779. /*==========================================
  6780. * It is made to snow.
  6781. *------------------------------------------
  6782. */
  6783. int
  6784. atcommand_snow(
  6785. const int fd, struct map_session_data* sd,
  6786. const char* command, const char* message)
  6787. {
  6788. nullpo_retr(-1, sd);
  6789. if (map[sd->bl.m].flag.snow) {
  6790. map[sd->bl.m].flag.snow=0;
  6791. clif_weather(sd->bl.m);
  6792. clif_displaymessage(fd, "Snow has stopped falling.");
  6793. } else {
  6794. map[sd->bl.m].flag.snow=1;
  6795. clif_weather(sd->bl.m);
  6796. clif_displaymessage(fd, "It is made to snow.");
  6797. }
  6798. return 0;
  6799. }
  6800. /*==========================================
  6801. * Cherry tree snowstorm is made to fall. (Sakura)
  6802. *------------------------------------------
  6803. */
  6804. int
  6805. atcommand_sakura(
  6806. const int fd, struct map_session_data* sd,
  6807. const char* command, const char* message)
  6808. {
  6809. nullpo_retr(-1, sd);
  6810. if (map[sd->bl.m].flag.sakura) {
  6811. map[sd->bl.m].flag.sakura=0;
  6812. clif_weather(sd->bl.m);
  6813. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6814. } else {
  6815. map[sd->bl.m].flag.sakura=1;
  6816. clif_weather(sd->bl.m);
  6817. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6818. }
  6819. return 0;
  6820. }
  6821. /*==========================================
  6822. * Clouds appear.
  6823. *------------------------------------------
  6824. */
  6825. int
  6826. atcommand_clouds(
  6827. const int fd, struct map_session_data* sd,
  6828. const char* command, const char* message)
  6829. {
  6830. nullpo_retr(-1, sd);
  6831. if (map[sd->bl.m].flag.clouds) {
  6832. map[sd->bl.m].flag.clouds=0;
  6833. clif_weather(sd->bl.m);
  6834. clif_displaymessage(fd, "The clouds has disappear.");
  6835. } else {
  6836. map[sd->bl.m].flag.clouds=1;
  6837. clif_weather(sd->bl.m);
  6838. clif_displaymessage(fd, "Clouds appear.");
  6839. }
  6840. return 0;
  6841. }
  6842. /*==========================================
  6843. * Different type of clouds using effect 516
  6844. *------------------------------------------
  6845. */
  6846. int
  6847. atcommand_clouds2(
  6848. const int fd, struct map_session_data* sd,
  6849. const char* command, const char* message)
  6850. {
  6851. nullpo_retr(-1, sd);
  6852. if (map[sd->bl.m].flag.clouds2) {
  6853. map[sd->bl.m].flag.clouds2=0;
  6854. clif_weather(sd->bl.m);
  6855. clif_displaymessage(fd, "The alternative clouds disappear.");
  6856. } else {
  6857. map[sd->bl.m].flag.clouds2=1;
  6858. clif_weather(sd->bl.m);
  6859. clif_displaymessage(fd, "Alternative clouds appear.");
  6860. }
  6861. return 0;
  6862. }
  6863. /*==========================================
  6864. * Fog hangs over.
  6865. *------------------------------------------
  6866. */
  6867. int
  6868. atcommand_fog(
  6869. const int fd, struct map_session_data* sd,
  6870. const char* command, const char* message)
  6871. {
  6872. nullpo_retr(-1, sd);
  6873. if (map[sd->bl.m].flag.fog) {
  6874. map[sd->bl.m].flag.fog=0;
  6875. clif_weather(sd->bl.m);
  6876. clif_displaymessage(fd, "The fog has gone.");
  6877. } else {
  6878. map[sd->bl.m].flag.fog=1;
  6879. clif_weather(sd->bl.m);
  6880. clif_displaymessage(fd, "Fog hangs over.");
  6881. }
  6882. return 0;
  6883. }
  6884. /*==========================================
  6885. * Fallen leaves fall.
  6886. *------------------------------------------
  6887. */
  6888. int
  6889. atcommand_leaves(
  6890. const int fd, struct map_session_data* sd,
  6891. const char* command, const char* message)
  6892. {
  6893. nullpo_retr(-1, sd);
  6894. if (map[sd->bl.m].flag.leaves) {
  6895. map[sd->bl.m].flag.leaves=0;
  6896. clif_weather(sd->bl.m);
  6897. clif_displaymessage(fd, "Leaves no longer fall.");
  6898. } else {
  6899. map[sd->bl.m].flag.leaves=1;
  6900. clif_weather(sd->bl.m);
  6901. clif_displaymessage(fd, "Fallen leaves fall.");
  6902. }
  6903. return 0;
  6904. }
  6905. /*==========================================
  6906. * Fireworks appear.
  6907. *------------------------------------------
  6908. */
  6909. int
  6910. atcommand_fireworks(
  6911. const int fd, struct map_session_data* sd,
  6912. const char* command, const char* message)
  6913. {
  6914. nullpo_retr(-1, sd);
  6915. if (map[sd->bl.m].flag.fireworks) {
  6916. map[sd->bl.m].flag.fireworks=0;
  6917. clif_weather(sd->bl.m);
  6918. clif_displaymessage(fd, "Fireworks are ended.");
  6919. } else {
  6920. map[sd->bl.m].flag.fireworks=1;
  6921. clif_weather(sd->bl.m);
  6922. clif_displaymessage(fd, "Fireworks are launched.");
  6923. }
  6924. return 0;
  6925. }
  6926. /*==========================================
  6927. * Clearing Weather Effects by Dexity
  6928. *------------------------------------------
  6929. */
  6930. int
  6931. atcommand_clearweather(
  6932. const int fd, struct map_session_data* sd,
  6933. const char* command, const char* message)
  6934. {
  6935. nullpo_retr(-1, sd);
  6936. map[sd->bl.m].flag.rain=0;
  6937. map[sd->bl.m].flag.snow=0;
  6938. map[sd->bl.m].flag.sakura=0;
  6939. map[sd->bl.m].flag.clouds=0;
  6940. map[sd->bl.m].flag.clouds2=0;
  6941. map[sd->bl.m].flag.fog=0;
  6942. map[sd->bl.m].flag.fireworks=0;
  6943. map[sd->bl.m].flag.leaves=0;
  6944. clif_weather(sd->bl.m);
  6945. return 0;
  6946. }
  6947. /*===============================================================
  6948. * Sound Command - plays a sound for everyone! [Codemaster]
  6949. *---------------------------------------------------------------
  6950. */
  6951. int
  6952. atcommand_sound(
  6953. const int fd, struct map_session_data *sd,
  6954. const char *command, const char *message)
  6955. {
  6956. char sound_file[100];
  6957. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6958. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6959. return -1;
  6960. }
  6961. memset(sound_file, '\0', sizeof(sound_file));
  6962. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6963. return -1;
  6964. if(strstr(sound_file, ".wav") == NULL)
  6965. strcat(sound_file, ".wav");
  6966. clif_soundeffectall(&sd->bl, sound_file,0);
  6967. return 0;
  6968. }
  6969. /*==========================================
  6970. * MOB Search
  6971. *------------------------------------------
  6972. */
  6973. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  6974. {
  6975. int mob_id,fd;
  6976. static int number=0;
  6977. struct mob_data *md;
  6978. nullpo_retr(0, bl);
  6979. if(!ap){
  6980. number=0;
  6981. return 0;
  6982. }
  6983. mob_id = va_arg(ap,int);
  6984. fd = va_arg(ap,int);
  6985. md = (struct mob_data *)bl;
  6986. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  6987. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  6988. ++number,bl->x, bl->y,md->name);
  6989. clif_displaymessage(fd, atcmd_output);
  6990. }
  6991. return 0;
  6992. }
  6993. int atcommand_mobsearch(
  6994. const int fd, struct map_session_data* sd,
  6995. const char* command, const char* message)
  6996. {
  6997. char mob_name[100];
  6998. int mob_id,map_id = 0;
  6999. nullpo_retr(-1, sd);
  7000. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7001. return -1;
  7002. if ((mob_id = atoi(mob_name)) == 0)
  7003. mob_id = mobdb_searchname(mob_name);
  7004. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7005. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7006. clif_displaymessage(fd, atcmd_output);
  7007. return 0;
  7008. }
  7009. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7010. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7011. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7012. map_id = sd->bl.m;
  7013. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7014. mob_name, mapindex_id2name(sd->mapindex));
  7015. clif_displaymessage(fd, atcmd_output);
  7016. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7017. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7018. return 0;
  7019. }
  7020. /*==========================================
  7021. * ドロップアイテムの掃除
  7022. *------------------------------------------
  7023. */
  7024. /*==========================================
  7025. * cleanmap
  7026. *------------------------------------------
  7027. */
  7028. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7029. {
  7030. nullpo_retr(0, bl);
  7031. map_clearflooritem(bl->id);
  7032. return 0;
  7033. }
  7034. int
  7035. atcommand_cleanmap(
  7036. const int fd, struct map_session_data* sd,
  7037. const char* command, const char* message)
  7038. {
  7039. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7040. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7041. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7042. BL_ITEM);
  7043. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7044. return 0;
  7045. }
  7046. /*==========================================
  7047. * NPC/PETに話させる
  7048. *------------------------------------------
  7049. */
  7050. int
  7051. atcommand_npctalk(
  7052. const int fd, struct map_session_data* sd,
  7053. const char* command, const char* message)
  7054. {
  7055. char name[NAME_LENGTH],mes[100],temp[100];
  7056. struct npc_data *nd;
  7057. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7058. return -1;
  7059. if (!(nd = npc_name2id(name)))
  7060. return -1;
  7061. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7062. clif_message(&nd->bl, temp);
  7063. return 0;
  7064. }
  7065. int
  7066. atcommand_pettalk(
  7067. const int fd, struct map_session_data* sd,
  7068. const char* command, const char* message)
  7069. {
  7070. char mes[100],temp[100];
  7071. struct pet_data *pd;
  7072. nullpo_retr(-1, sd);
  7073. if(!sd->status.pet_id || !(pd=sd->pd))
  7074. return -1;
  7075. if (sscanf(message, "%99[^\n]", mes) < 1)
  7076. return -1;
  7077. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  7078. clif_message(&pd->bl, temp);
  7079. return 0;
  7080. }
  7081. /*==========================================
  7082. * @users
  7083. * サーバー内の人数マップを表示させる
  7084. * 手抜きのため汚くなっているのは仕様です。
  7085. *------------------------------------------
  7086. */
  7087. static struct dbt *users_db = NULL;
  7088. static int users_all;
  7089. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7090. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7091. users_all++;
  7092. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7093. return 0;
  7094. }
  7095. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7096. char buf[256];
  7097. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7098. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7099. clif_displaymessage(sd->fd,buf);
  7100. return 0;
  7101. }
  7102. int
  7103. atcommand_users(
  7104. const int fd, struct map_session_data* sd,
  7105. const char* command, const char* message)
  7106. {
  7107. char buf[256];
  7108. users_all = 0;
  7109. users_db->clear(users_db, NULL);
  7110. clif_foreachclient(atcommand_users_sub1);
  7111. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7112. sprintf(buf,"all : %d",users_all);
  7113. clif_displaymessage(fd,buf);
  7114. return 0;
  7115. }
  7116. /*==========================================
  7117. *
  7118. *------------------------------------------
  7119. */
  7120. int
  7121. atcommand_summon(
  7122. const int fd, struct map_session_data* sd,
  7123. const char* command, const char* message)
  7124. {
  7125. char name[NAME_LENGTH];
  7126. int mob_id = 0;
  7127. int x = 0;
  7128. int y = 0;
  7129. int id = 0;
  7130. int duration = 0;
  7131. struct mob_data *md;
  7132. unsigned int tick=gettick();
  7133. nullpo_retr(-1, sd);
  7134. if (!message || !*message)
  7135. return -1;
  7136. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7137. return -1;
  7138. if (duration < 1)
  7139. duration =1;
  7140. else if (duration > 60)
  7141. duration =60;
  7142. if ((mob_id = atoi(name)) == 0)
  7143. mob_id = mobdb_searchname(name);
  7144. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7145. return -1;
  7146. x = sd->bl.x + (rand() % 10 - 5);
  7147. y = sd->bl.y + (rand() % 10 - 5);
  7148. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  7149. if((md=(struct mob_data *)map_id2bl(id))){
  7150. md->master_id=sd->bl.id;
  7151. md->special_state.ai=1;
  7152. md->mode=md->db->mode|MD_AGGRESSIVE;
  7153. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7154. clif_misceffect2(&md->bl,344);
  7155. }
  7156. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  7157. return 0;
  7158. }
  7159. /*==========================================
  7160. * @adjcmdlvl by [MouseJstr]
  7161. *
  7162. * Temp adjust the GM level required to use a GM command
  7163. *
  7164. * Used during beta testing to allow players to use GM commands
  7165. * for short periods of time
  7166. *------------------------------------------
  7167. */
  7168. int
  7169. atcommand_adjcmdlvl(
  7170. const int fd, struct map_session_data* sd,
  7171. const char* command, const char* message)
  7172. {
  7173. int i, newlev;
  7174. char cmd[100];
  7175. nullpo_retr(-1, sd);
  7176. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7177. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7178. return -1;
  7179. }
  7180. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7181. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7182. atcommand_info[i].level = newlev;
  7183. clif_displaymessage(fd, "@command level changed.");
  7184. return 0;
  7185. }
  7186. clif_displaymessage(fd, "@command not found.");
  7187. return -1;
  7188. }
  7189. /*==========================================
  7190. * @adjgmlvl by [MouseJstr]
  7191. *
  7192. * Create a temp GM
  7193. *
  7194. * Used during beta testing to allow players to use GM commands
  7195. * for short periods of time
  7196. *------------------------------------------
  7197. */
  7198. int
  7199. atcommand_adjgmlvl(
  7200. const int fd, struct map_session_data* sd,
  7201. const char* command, const char* message)
  7202. {
  7203. int newlev;
  7204. char user[NAME_LENGTH];
  7205. struct map_session_data *pl_sd;
  7206. nullpo_retr(-1, sd);
  7207. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7208. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7209. return -1;
  7210. }
  7211. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7212. return -1;
  7213. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7214. return 0;
  7215. }
  7216. /*==========================================
  7217. * @trade by [MouseJstr]
  7218. *
  7219. * Open a trade window with a remote player
  7220. *
  7221. * If I have to jump to a remote player one more time, I am
  7222. * gonna scream!
  7223. *------------------------------------------
  7224. */
  7225. int
  7226. atcommand_trade(
  7227. const int fd, struct map_session_data* sd,
  7228. const char* command, const char* message)
  7229. {
  7230. struct map_session_data *pl_sd = NULL;
  7231. nullpo_retr(-1, sd);
  7232. if (!message || !*message)
  7233. return -1;
  7234. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7235. trade_traderequest(sd, pl_sd->bl.id);
  7236. return 0;
  7237. }
  7238. return -1;
  7239. }
  7240. /*==========================================
  7241. * @setbattleflag by [MouseJstr]
  7242. *
  7243. * set a battle_config flag without having to reboot
  7244. */
  7245. int
  7246. atcommand_setbattleflag(
  7247. const int fd, struct map_session_data* sd,
  7248. const char* command, const char* message)
  7249. {
  7250. char flag[128], value[128];
  7251. nullpo_retr(-1, sd);
  7252. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7253. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7254. return -1;
  7255. }
  7256. if (battle_set_value(flag, value) == 0)
  7257. clif_displaymessage(fd, "unknown battle_config flag");
  7258. else
  7259. clif_displaymessage(fd, "battle_config set as requested");
  7260. return 0;
  7261. }
  7262. /*===========================
  7263. * @unmute [Valaris]
  7264. *===========================
  7265. */
  7266. int atcommand_unmute(
  7267. const int fd, struct map_session_data* sd,
  7268. const char* command, const char* message)
  7269. {
  7270. struct map_session_data *pl_sd = NULL;
  7271. nullpo_retr(-1, sd);
  7272. if(!battle_config.muting_players) {
  7273. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7274. return 0;
  7275. }
  7276. if (!message || !*message)
  7277. return -1;
  7278. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7279. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7280. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7281. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7282. clif_displaymessage(sd->fd,"Player unmuted");
  7283. }
  7284. else
  7285. clif_displaymessage(sd->fd,"Player is not muted");
  7286. }
  7287. return 0;
  7288. }
  7289. /*==========================================
  7290. * @uptime by MC Cameri
  7291. *------------------------------------------
  7292. */
  7293. int
  7294. atcommand_uptime(
  7295. const int fd, struct map_session_data* sd,
  7296. const char* command, const char* message)
  7297. {
  7298. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7299. minute = 60, days = 0, hours = 0, minutes = 0;
  7300. nullpo_retr(-1, sd);
  7301. seconds = get_uptime();
  7302. days = seconds/day;
  7303. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7304. hours = seconds/hour;
  7305. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7306. minutes = seconds/minute;
  7307. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7308. snprintf(atcmd_output, sizeof(atcmd_output), msg_table[245], days, hours, minutes, seconds);
  7309. clif_displaymessage(fd, atcmd_output);
  7310. return 0;
  7311. }
  7312. /*==========================================
  7313. * @changesex <sex>
  7314. * => Changes one's sex. Argument sex can be
  7315. * 0 or 1, m or f, male or female.
  7316. *------------------------------------------
  7317. */
  7318. int
  7319. atcommand_changesex(
  7320. const int fd, struct map_session_data* sd,
  7321. const char* command, const char* message)
  7322. {
  7323. nullpo_retr(-1, sd);
  7324. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7325. return 0;
  7326. }
  7327. /*================================================
  7328. * @mute - Mutes a player for a set amount of time
  7329. *------------------------------------------------
  7330. */
  7331. int atcommand_mute(
  7332. const int fd, struct map_session_data* sd,
  7333. const char* command, const char* message)
  7334. {
  7335. struct map_session_data *pl_sd = NULL;
  7336. int manner;
  7337. nullpo_retr(-1, sd);
  7338. if(!battle_config.muting_players) {
  7339. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7340. return 0;
  7341. }
  7342. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7343. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7344. return -1;
  7345. }
  7346. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7347. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7348. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7349. return -1;
  7350. }
  7351. clif_GM_silence(sd, pl_sd, 0);
  7352. pl_sd->status.manner -= manner;
  7353. if(pl_sd->status.manner < 0)
  7354. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7355. }
  7356. else {
  7357. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7358. return -1;
  7359. }
  7360. return 0;
  7361. }
  7362. /*==========================================
  7363. * @refresh (like @jumpto <<yourself>>)
  7364. *------------------------------------------
  7365. */
  7366. int atcommand_refresh(
  7367. const int fd, struct map_session_data* sd,
  7368. const char* command, const char* message)
  7369. {
  7370. nullpo_retr(-1, sd);
  7371. clif_refresh(sd);
  7372. return 0;
  7373. }
  7374. /*==========================================
  7375. * @petid <part of pet name>
  7376. * => Displays a list of matching pets.
  7377. *------------------------------------------
  7378. */
  7379. int
  7380. atcommand_petid(const int fd, struct map_session_data* sd,
  7381. const char* command, const char* message)
  7382. {
  7383. char searchtext[100];
  7384. char temp0[100];
  7385. char temp1[100];
  7386. int cnt = 0, i = 0;
  7387. nullpo_retr(-1, sd);
  7388. if (!message || !*message)
  7389. return -1;
  7390. if (sscanf(message, "%99s", searchtext) < 1)
  7391. return -1;
  7392. estr_lower(searchtext);
  7393. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7394. clif_displaymessage(fd,temp0);
  7395. while (i < MAX_PET_DB) {
  7396. strcpy(temp1,pet_db[i].name);
  7397. strcpy(temp1, estr_lower(temp1));
  7398. strcpy(temp0,pet_db[i].jname);
  7399. strcpy(temp0, estr_lower(temp1));
  7400. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7401. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7402. pet_db[i].jname);
  7403. if (cnt >= 100) { // Only if there are custom pets
  7404. clif_displaymessage(fd, "Be more specific, can't send more than"
  7405. " 100 results.");
  7406. } else {
  7407. clif_displaymessage(fd, temp0);
  7408. }
  7409. cnt++;
  7410. }
  7411. i++;
  7412. }
  7413. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7414. clif_displaymessage(fd, temp0);
  7415. return 0;
  7416. }
  7417. /*==========================================
  7418. * @identify
  7419. * => GM's magnifier.
  7420. *------------------------------------------
  7421. */
  7422. int
  7423. atcommand_identify(
  7424. const int fd, struct map_session_data* sd,
  7425. const char* command, const char* message)
  7426. {
  7427. int i,num;
  7428. nullpo_retr(-1, sd);
  7429. for(i=num=0;i<MAX_INVENTORY;i++){
  7430. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7431. num++;
  7432. }
  7433. }
  7434. if (num > 0) {
  7435. clif_item_identify_list(sd);
  7436. } else {
  7437. clif_displaymessage(fd,"There are no items to appraise.");
  7438. }
  7439. return 0;
  7440. }
  7441. /*==========================================
  7442. * @gmotd (Global MOTD)
  7443. * by davidsiaw :P
  7444. *------------------------------------------
  7445. */
  7446. int
  7447. atcommand_gmotd(
  7448. const int fd, struct map_session_data* sd,
  7449. const char* command, const char* message)
  7450. {
  7451. char buf[256];
  7452. FILE *fp;
  7453. nullpo_retr(-1, sd);
  7454. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7455. while (fgets(buf, 250, fp) != NULL){
  7456. int i;
  7457. for( i=0; buf[i]; i++){
  7458. if( buf[i]=='\r' || buf[i]=='\n'){
  7459. buf[i]=0;
  7460. break;
  7461. }
  7462. }
  7463. intif_GMmessage(buf,strlen(buf)+1,8);
  7464. }
  7465. fclose(fp);
  7466. }
  7467. return 0;
  7468. }
  7469. int atcommand_misceffect(
  7470. const int fd, struct map_session_data* sd,
  7471. const char* command, const char* message)
  7472. {
  7473. int effect = 0;
  7474. nullpo_retr(-1, sd);
  7475. if (!message || !*message)
  7476. return -1;
  7477. if (sscanf(message, "%d", &effect) < 1)
  7478. return -1;
  7479. clif_misceffect(&sd->bl,effect);
  7480. return 0;
  7481. }
  7482. int charid2sessionid(int charid)
  7483. {
  7484. struct map_session_data *pl_sd = NULL;
  7485. pl_sd = map_charid2sd(charid);
  7486. if (pl_sd) return pl_sd->fd;
  7487. return 0;
  7488. }
  7489. int accountid2sessionid(int accountid)
  7490. {
  7491. struct map_session_data *pl_sd = NULL;
  7492. pl_sd = map_id2sd(accountid);
  7493. if (pl_sd) return pl_sd->fd;
  7494. return 0;
  7495. }
  7496. /*==========================================
  7497. * Jump to a player by PID number
  7498. * Original by Dino9021
  7499. * Added in by nsstrunks
  7500. *------------------------------------------
  7501. */
  7502. int atcommand_jumptoid(
  7503. const int fd, struct map_session_data* sd,
  7504. const char* command, const char* message)
  7505. {
  7506. int cid=0;
  7507. int session_id=0;
  7508. struct map_session_data *pl_sd;
  7509. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7510. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7511. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7512. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7513. return -1;
  7514. }
  7515. cid=atoi(message);
  7516. if ((session_id=charid2sessionid(cid))!=0)
  7517. {
  7518. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7519. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7520. clif_displaymessage(fd, msg_table[247]);
  7521. return -1;
  7522. }
  7523. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7524. clif_displaymessage(fd, msg_table[248]);
  7525. return -1;
  7526. }
  7527. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7528. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7529. clif_displaymessage(fd, atcmd_output);
  7530. } else {
  7531. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7532. return -1;
  7533. }
  7534. }
  7535. else
  7536. {
  7537. clif_displaymessage(fd,msg_table[3]);
  7538. }
  7539. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7540. return 0;
  7541. }
  7542. /*==========================================
  7543. * Jump to a player by PID number
  7544. * Original by Dino9021
  7545. * Added in by nsstrunks
  7546. *------------------------------------------
  7547. */
  7548. int atcommand_jumptoid2(
  7549. const int fd, struct map_session_data* sd,
  7550. const char* command, const char* message)
  7551. {
  7552. int aid=0;
  7553. int session_id=0;
  7554. struct map_session_data *pl_sd;
  7555. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7556. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7557. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7558. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7559. return -1;
  7560. }
  7561. aid=atoi(message);
  7562. if ((session_id=accountid2sessionid(aid))!=0)
  7563. {
  7564. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7565. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7566. clif_displaymessage(fd, msg_table[247]);
  7567. return -1;
  7568. }
  7569. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7570. clif_displaymessage(fd, msg_table[248]);
  7571. return -1;
  7572. }
  7573. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7574. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7575. clif_displaymessage(fd, atcmd_output);
  7576. } else {
  7577. clif_displaymessage(fd, msg_table[154]); // 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. * Recall a player by PID number
  7590. * Original by Dino9021
  7591. * Added in by nsstrunks
  7592. *------------------------------------------
  7593. */
  7594. int atcommand_recallid(
  7595. const int fd, struct map_session_data* sd,
  7596. const char* command, const char* message)
  7597. {
  7598. int cid=0;
  7599. int session_id=0;
  7600. struct map_session_data *pl_sd;
  7601. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7602. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7603. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7604. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7605. return -1;
  7606. }
  7607. cid=atoi(message);
  7608. if ((session_id=charid2sessionid(cid))!=0)
  7609. {
  7610. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7611. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7612. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7613. clif_displaymessage(fd, msg_table[247]);
  7614. return -1;
  7615. }
  7616. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7617. clif_displaymessage(fd, msg_table[248]);
  7618. return -1;
  7619. }
  7620. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7621. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7622. clif_displaymessage(fd, atcmd_output);
  7623. } else {
  7624. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7625. return -1;
  7626. }
  7627. } else {
  7628. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7629. return -1;
  7630. }
  7631. }
  7632. else
  7633. {
  7634. clif_displaymessage(fd,msg_table[3]);
  7635. }
  7636. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7637. return 0;
  7638. }
  7639. /*==========================================
  7640. * Recall a player by PID number
  7641. * Original by Dino9021
  7642. * Added in by nsstrunks
  7643. *------------------------------------------
  7644. */
  7645. int atcommand_recallid2(
  7646. const int fd, struct map_session_data* sd,
  7647. const char* command, const char* message)
  7648. {
  7649. int aid=0;
  7650. int session_id=0;
  7651. struct map_session_data *pl_sd;
  7652. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7654. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7655. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7656. return -1;
  7657. }
  7658. aid=atoi(message);
  7659. if ((session_id=accountid2sessionid(aid))!=0)
  7660. {
  7661. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7662. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7663. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7664. clif_displaymessage(fd, msg_table[247]);
  7665. return -1;
  7666. }
  7667. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7668. clif_displaymessage(fd, msg_table[248]);
  7669. return -1;
  7670. }
  7671. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7672. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7673. clif_displaymessage(fd, atcmd_output);
  7674. } else {
  7675. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7676. return -1;
  7677. }
  7678. } else {
  7679. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7680. return -1;
  7681. }
  7682. }
  7683. else
  7684. {
  7685. clif_displaymessage(fd,msg_table[3]);
  7686. }
  7687. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7688. return 0;
  7689. }
  7690. /*==========================================
  7691. * Kick a player by PID number
  7692. * Original by Dino9021
  7693. * Added in by nsstrunks
  7694. *------------------------------------------
  7695. */
  7696. int atcommand_kickid(
  7697. const int fd, struct map_session_data* sd,
  7698. const char* command, const char* message)
  7699. {
  7700. struct map_session_data *pl_sd;
  7701. int cid=0;
  7702. int session_id=0;
  7703. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7704. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7705. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7706. return -1;
  7707. }
  7708. cid=atoi(message);
  7709. if ((session_id=charid2sessionid(cid))!=0)
  7710. {
  7711. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7712. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7713. clif_GM_kick(sd, pl_sd, 1);
  7714. else {
  7715. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7716. return -1;
  7717. }
  7718. } else {
  7719. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7720. return -1;
  7721. }
  7722. }
  7723. else
  7724. {
  7725. clif_displaymessage(fd,msg_table[3]);
  7726. }
  7727. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7728. return 0;
  7729. }
  7730. /*==========================================
  7731. * Kick a player by PID number
  7732. * Original by Dino9021
  7733. * Added in by nsstrunks
  7734. *------------------------------------------
  7735. */
  7736. int atcommand_kickid2(
  7737. const int fd, struct map_session_data* sd,
  7738. const char* command, const char* message)
  7739. {
  7740. struct map_session_data *pl_sd;
  7741. int aid=0;
  7742. int session_id=0;
  7743. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7744. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7745. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7746. return -1;
  7747. }
  7748. aid=atoi(message);
  7749. if ((session_id=accountid2sessionid(aid))!=0)
  7750. {
  7751. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7752. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7753. clif_GM_kick(sd, pl_sd, 1);
  7754. else {
  7755. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7756. return -1;
  7757. }
  7758. } else {
  7759. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7760. return -1;
  7761. }
  7762. }
  7763. else
  7764. {
  7765. clif_displaymessage(fd,msg_table[3]);
  7766. }
  7767. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7768. return 0;
  7769. }
  7770. /*==========================================
  7771. * Revive a player by PID number
  7772. * Original by Dino9021
  7773. * Added in by nsstrunks
  7774. *------------------------------------------
  7775. */
  7776. int atcommand_reviveid(
  7777. const int fd, struct map_session_data* sd,
  7778. const char* command, const char* message)
  7779. {
  7780. int cid=0;
  7781. int session_id=0;
  7782. struct map_session_data *pl_sd;
  7783. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7784. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7785. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7786. return -1;
  7787. }
  7788. cid=atoi(message);
  7789. if ((session_id=charid2sessionid(cid))!=0)
  7790. {
  7791. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7792. pl_sd->status.hp = pl_sd->status.max_hp;
  7793. pc_setstand(pl_sd);
  7794. if (battle_config.pc_invincible_time > 0)
  7795. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7796. clif_updatestatus(pl_sd, SP_HP);
  7797. clif_updatestatus(pl_sd, SP_SP);
  7798. clif_resurrection(&pl_sd->bl, 1);
  7799. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7800. } else {
  7801. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7802. return -1;
  7803. }
  7804. }
  7805. else
  7806. {
  7807. clif_displaymessage(fd,msg_table[3]);
  7808. }
  7809. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7810. return 0;
  7811. }
  7812. /*==========================================
  7813. * Revive a player by PID number
  7814. * Original by Dino9021
  7815. * Added in by nsstrunks
  7816. *------------------------------------------
  7817. */
  7818. int atcommand_reviveid2(
  7819. const int fd, struct map_session_data* sd,
  7820. const char* command, const char* message)
  7821. {
  7822. int aid=0;
  7823. int session_id=0;
  7824. struct map_session_data *pl_sd;
  7825. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7826. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7827. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7828. return -1;
  7829. }
  7830. aid=atoi(message);
  7831. if ((session_id=accountid2sessionid(aid))!=0)
  7832. {
  7833. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7834. pl_sd->status.hp = pl_sd->status.max_hp;
  7835. pc_setstand(pl_sd);
  7836. if (battle_config.pc_invincible_time > 0)
  7837. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7838. clif_updatestatus(pl_sd, SP_HP);
  7839. clif_updatestatus(pl_sd, SP_SP);
  7840. clif_resurrection(&pl_sd->bl, 1);
  7841. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7842. } else {
  7843. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7844. return -1;
  7845. }
  7846. }
  7847. else
  7848. {
  7849. clif_displaymessage(fd,msg_table[3]);
  7850. }
  7851. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7852. return 0;
  7853. }
  7854. /*==========================================
  7855. * Kill a player by PID number
  7856. * Original by Dino9021
  7857. * Added in by nsstrunks
  7858. *------------------------------------------
  7859. */
  7860. int atcommand_killid(
  7861. const int fd, struct map_session_data* sd,
  7862. const char* command, const char* message)
  7863. {
  7864. int cid=0;
  7865. int session_id=0;
  7866. struct map_session_data *pl_sd;
  7867. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7868. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7869. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7870. return -1;
  7871. }
  7872. cid=atoi(message);
  7873. if ((session_id=charid2sessionid(cid))!=0)
  7874. {
  7875. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7876. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7877. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7878. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7879. } else {
  7880. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7881. return -1;
  7882. }
  7883. } else {
  7884. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7885. return -1;
  7886. }
  7887. }
  7888. else
  7889. {
  7890. clif_displaymessage(fd,msg_table[3]);
  7891. }
  7892. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7893. return 0;
  7894. }
  7895. /*==========================================
  7896. * Kill a player by PID number
  7897. * Original by Dino9021
  7898. * Added in by nsstrunks
  7899. *------------------------------------------
  7900. */
  7901. int atcommand_killid2(
  7902. const int fd, struct map_session_data* sd,
  7903. const char* command, const char* message)
  7904. {
  7905. int aid=0;
  7906. int session_id=0;
  7907. struct map_session_data *pl_sd;
  7908. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7909. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7910. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7911. return -1;
  7912. }
  7913. aid=atoi(message);
  7914. if ((session_id=accountid2sessionid(aid))!=0)
  7915. {
  7916. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7917. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7918. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7919. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7920. } else {
  7921. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7922. return -1;
  7923. }
  7924. } else {
  7925. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7926. return -1;
  7927. }
  7928. }
  7929. else
  7930. {
  7931. clif_displaymessage(fd,msg_table[3]);
  7932. }
  7933. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7934. return 0;
  7935. }
  7936. /*==========================================
  7937. * Make a player killable, by PID
  7938. * Original by Dino9021
  7939. * Added in by nsstrunks
  7940. *------------------------------------------
  7941. */
  7942. int
  7943. atcommand_charkillableid(
  7944. const int fd, struct map_session_data* sd,
  7945. const char* command, const char* message)
  7946. {
  7947. struct map_session_data *pl_sd = NULL;
  7948. int cid=0;
  7949. int session_id=0;
  7950. if (!message || (cid = atoi(message)) == 0 || !*message)
  7951. return -1;
  7952. cid=atoi(message);
  7953. if ((session_id=charid2sessionid(cid))!=0)
  7954. {
  7955. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7956. return -1;
  7957. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7958. if(pl_sd->special_state.killable)
  7959. clif_displaymessage(fd, "The player is now killable");
  7960. else
  7961. clif_displaymessage(fd, "The player is no longer killable");
  7962. }
  7963. else
  7964. {
  7965. clif_displaymessage(fd,msg_table[3]);
  7966. }
  7967. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7968. return 0;
  7969. }
  7970. /*==========================================
  7971. * Make a player killable, by PID
  7972. * Original by Dino9021
  7973. * Added in by nsstrunks
  7974. *------------------------------------------
  7975. */
  7976. int
  7977. atcommand_charkillableid2(
  7978. const int fd, struct map_session_data* sd,
  7979. const char* command, const char* message)
  7980. {
  7981. struct map_session_data *pl_sd = NULL;
  7982. int aid=0;
  7983. int session_id=0;
  7984. if (!message || (aid = atoi(message)) == 0 || !*message)
  7985. return -1;
  7986. aid=atoi(message);
  7987. if ((session_id=accountid2sessionid(aid))!=0)
  7988. {
  7989. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7990. return -1;
  7991. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7992. if(pl_sd->special_state.killable)
  7993. clif_displaymessage(fd, "The player is now killable");
  7994. else
  7995. clif_displaymessage(fd, "The player is no longer killable");
  7996. }
  7997. else
  7998. {
  7999. clif_displaymessage(fd,msg_table[3]);
  8000. }
  8001. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8002. return 0;
  8003. }
  8004. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8005. /*==========================================
  8006. * Mail System commands by [Valaris]
  8007. *------------------------------------------
  8008. */
  8009. int atcommand_listmail(
  8010. const int fd, struct map_session_data* sd,
  8011. const char* command, const char* message)
  8012. {
  8013. if(!mail_server_enable)
  8014. return 0;
  8015. nullpo_retr(-1, sd);
  8016. if(strlen(command)==12)
  8017. mail_check(sd,3);
  8018. else if(strlen(command)==9)
  8019. mail_check(sd,2);
  8020. else
  8021. mail_check(sd,1);
  8022. return 0;
  8023. }
  8024. int atcommand_readmail(
  8025. const int fd, struct map_session_data* sd,
  8026. const char* command, const char* message)
  8027. {
  8028. int index;
  8029. if(!mail_server_enable)
  8030. return 0;
  8031. nullpo_retr(-1, sd);
  8032. if (!message || !*message) {
  8033. clif_displaymessage(sd->fd,"You must specify a message number.");
  8034. return 0;
  8035. }
  8036. index = atoi(message);
  8037. if (index < 1) {
  8038. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8039. return 0;
  8040. }
  8041. if(strlen(command)==11)
  8042. mail_delete(sd,index);
  8043. else
  8044. mail_read(sd,index);
  8045. return 0;
  8046. }
  8047. int atcommand_sendmail(
  8048. const int fd, struct map_session_data* sd,
  8049. const char* command, const char* message)
  8050. {
  8051. char name[NAME_LENGTH],text[80];
  8052. if(!mail_server_enable)
  8053. return 0;
  8054. nullpo_retr(-1, sd);
  8055. if (!message || !*message) {
  8056. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8057. return 0;
  8058. }
  8059. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8060. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8061. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8062. return 0;
  8063. }
  8064. if(strlen(command)==17)
  8065. mail_send(sd,name,text,1);
  8066. else
  8067. mail_send(sd,name,text,0);
  8068. return 0;
  8069. }
  8070. /*==========================================
  8071. * Refresh online command for SQL [Valaris]
  8072. * Will refresh and check online column of
  8073. * players and set correctly.
  8074. *------------------------------------------
  8075. */
  8076. int atcommand_refreshonline(
  8077. const int fd, struct map_session_data* sd,
  8078. const char* command, const char* message)
  8079. {
  8080. send_users_tochar(-1, gettick(), 0, 0);
  8081. return 0;
  8082. }
  8083. #endif /* end sql only */
  8084. /*==========================================
  8085. * Show Monster DB Info v 1.0
  8086. * originally by [Lupus] eAthena
  8087. *------------------------------------------
  8088. */
  8089. int atcommand_mobinfo(
  8090. const int fd, struct map_session_data* sd,
  8091. const char* command, const char* message)
  8092. {
  8093. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8094. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8095. unsigned char melement[11][8] = {"None", "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8096. char atcmd_output2[200];
  8097. struct item_data *item_data;
  8098. struct mob_db *mob;
  8099. int mob_id;
  8100. int i, j;
  8101. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8102. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8103. if (!message || !*message) {
  8104. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8105. return -1;
  8106. }
  8107. // If monster identifier/name argument is a name
  8108. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  8109. mob_id = mobdb_checkid(atoi(message));
  8110. if (mob_id == 0) {
  8111. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8112. return -1;
  8113. }
  8114. mob = mob_db(mob_id);
  8115. // stats
  8116. if (mob->mexp)
  8117. sprintf(atcmd_output, "MVP Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8118. else
  8119. sprintf(atcmd_output, "Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8120. clif_displaymessage(fd, atcmd_output);
  8121. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%d Job EXP:%d", mob->lv, mob->max_hp, mob->max_sp, mob->base_exp, mob->job_exp);
  8122. clif_displaymessage(fd, atcmd_output);
  8123. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d", mob->def, mob->mdef, mob->str, mob->agi, mob->vit, mob->int_, mob->dex, mob->luk);
  8124. clif_displaymessage(fd, atcmd_output);
  8125. if (mob->element < 20) {
  8126. //Element - None, Level 0
  8127. i = 0;
  8128. j = 0;
  8129. } else {
  8130. i = mob->element % 20 + 1;
  8131. j = mob->element / 20;
  8132. }
  8133. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)", mob->atk1, mob->atk2, mob->range, mob->range2 , mob->range3, msize[mob->size], mrace[mob->race], melement[i], j);
  8134. clif_displaymessage(fd, atcmd_output);
  8135. // drops
  8136. clif_displaymessage(fd, " Drops:");
  8137. strcpy(atcmd_output, " ");
  8138. j = 0;
  8139. for (i = 0; i < 10; i++) {
  8140. if (mob->dropitem[i].nameid <= 0 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8141. continue;
  8142. if (mob->dropitem[i].p > 0) {
  8143. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->dropitem[i].p / 100);
  8144. strcat(atcmd_output, atcmd_output2);
  8145. if (++j % 3 == 0) {
  8146. clif_displaymessage(fd, atcmd_output);
  8147. strcpy(atcmd_output, " ");
  8148. }
  8149. }
  8150. }
  8151. if (j == 0)
  8152. clif_displaymessage(fd, "This monster has no drops.");
  8153. else if (j % 3 != 0)
  8154. clif_displaymessage(fd, atcmd_output);
  8155. // mvp
  8156. if (mob->mexp) {
  8157. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8158. clif_displaymessage(fd, atcmd_output);
  8159. strcpy(atcmd_output, " MVP Items:");
  8160. j = 0;
  8161. for (i = 0; i < 3; i++) {
  8162. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8163. continue;
  8164. if (mob->mvpitem[i].p > 0) {
  8165. j++;
  8166. if (j == 1)
  8167. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8168. else
  8169. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8170. strcat(atcmd_output, atcmd_output2);
  8171. }
  8172. }
  8173. if (j == 0)
  8174. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8175. else
  8176. clif_displaymessage(fd, atcmd_output);
  8177. }
  8178. return 0;
  8179. }
  8180. /*==========================================
  8181. * Show Items DB Info v 1.0
  8182. * originally by [Lupus] eAthena
  8183. *------------------------------------------
  8184. */
  8185. int atcommand_iteminfo(
  8186. const int fd, struct map_session_data* sd,
  8187. const char* command, const char* message)
  8188. {
  8189. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8190. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8191. struct item_data *item_data;
  8192. int item_id=0;
  8193. if (!message || !*message) {
  8194. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8195. return -1;
  8196. }
  8197. if ((item_data = itemdb_searchname(message)) != NULL ||
  8198. (item_data = itemdb_exists(atoi(message))) != NULL)
  8199. item_id = item_data->nameid;
  8200. if (item_id >= 500) {
  8201. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8202. item_data->name,item_data->jname,item_data->slot,item_id,
  8203. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8204. (item_data->script==NULL)? "None" : "With script"
  8205. );
  8206. clif_displaymessage(fd, atcmd_output);
  8207. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %d ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight );
  8208. clif_displaymessage(fd, atcmd_output);
  8209. if (item_data->maxchance == 10000)
  8210. strcpy(atcmd_output, " - Available in the shops only");
  8211. else if (item_data->maxchance)
  8212. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8213. else
  8214. strcpy(atcmd_output, " - Monsters don't drop this item");
  8215. clif_displaymessage(fd, atcmd_output);
  8216. return 0;
  8217. }
  8218. clif_displaymessage(fd, "Item not found.");
  8219. return -1;
  8220. }
  8221. /*==========================================
  8222. * @adopt by [Veider]
  8223. *
  8224. * adopt a novice
  8225. *------------------------------------------
  8226. */
  8227. int
  8228. atcommand_adopt(const int fd, struct map_session_data* sd,
  8229. const char* command, const char* message)
  8230. {
  8231. struct map_session_data *pl_sd1 = NULL;
  8232. struct map_session_data *pl_sd2 = NULL;
  8233. struct map_session_data *pl_sd3 = NULL;
  8234. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8235. nullpo_retr(-1, sd);
  8236. if (!message || !*message)
  8237. return -1;
  8238. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8239. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8240. return -1;
  8241. }
  8242. if (battle_config.etc_log)
  8243. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8244. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8245. sprintf(player2, "Cannot find player %s online", player1);
  8246. clif_displaymessage(fd, player2);
  8247. return -1;
  8248. }
  8249. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8250. sprintf(player1, "Cannot find player %s online", player2);
  8251. clif_displaymessage(fd, player1);
  8252. return -1;
  8253. }
  8254. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8255. sprintf(player1, "Cannot find player %s online", player3);
  8256. clif_displaymessage(fd, player1);
  8257. return -1;
  8258. }
  8259. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8260. clif_displaymessage(fd, "They are too young to be parents!");
  8261. return -1;
  8262. }
  8263. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8264. clif_displaymessage(fd, "They are family.. wish them luck");
  8265. return 0;
  8266. }
  8267. else
  8268. return -1;
  8269. }
  8270. int atcommand_version(
  8271. const int fd, struct map_session_data* sd,
  8272. const char* command, const char* message)
  8273. {
  8274. const char * revision;
  8275. if ((revision = get_svn_revision()) != 0) {
  8276. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8277. clif_displaymessage(fd,atcmd_output);
  8278. } else
  8279. clif_displaymessage(fd,"Cannot determine SVN revision");
  8280. return 0;
  8281. }
  8282. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8283. {
  8284. int time, id;
  8285. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8286. if (pl_sd == NULL)
  8287. return 0;
  8288. id = va_arg(ap, int);
  8289. time = va_arg(ap, int);
  8290. if (id != bl->id && !pc_isGM(pl_sd)) {
  8291. pl_sd->status.manner -= time;
  8292. if (pl_sd->status.manner < 0)
  8293. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8294. }
  8295. return 0;
  8296. }
  8297. /*==========================================
  8298. * @mutearea by MouseJstr
  8299. *------------------------------------------
  8300. */
  8301. int atcommand_mutearea(
  8302. const int fd, struct map_session_data* sd,
  8303. const char* command, const char* message)
  8304. {
  8305. int time;
  8306. nullpo_retr(0, sd);
  8307. if(!battle_config.muting_players) {
  8308. clif_displaymessage(fd, "Please enable the muting system before using it.");
  8309. return 0;
  8310. }
  8311. time = atoi(message);
  8312. if (time <= 0)
  8313. time = 15; // 15 minutes default
  8314. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8315. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8316. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8317. return 0;
  8318. }
  8319. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8320. {
  8321. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8322. if (bl == NULL)
  8323. return 0;
  8324. if (!pc_isGM(pl_sd))
  8325. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8326. return 0;
  8327. }
  8328. /*==========================================
  8329. * @shuffle by MouseJstr
  8330. *------------------------------------------
  8331. */
  8332. int atcommand_shuffle(
  8333. const int fd, struct map_session_data* sd,
  8334. const char* command, const char* message)
  8335. {
  8336. nullpo_retr(0, sd);
  8337. if (strcmp(message, "area")== 0) {
  8338. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8339. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8340. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8341. } else if (strcmp(message, "map")== 0) {
  8342. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8343. } else if (strcmp(message, "world") == 0) {
  8344. struct map_session_data **pl_allsd;
  8345. int i, users;
  8346. pl_allsd = map_getallusers(&users);
  8347. for (i = 0; i < users; i++)
  8348. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8349. } else
  8350. clif_displaymessage(fd, "options are area, map, or world");
  8351. return 0;
  8352. }
  8353. int atcommand_rates(
  8354. const int fd, struct map_session_data* sd,
  8355. const char* command, const char* message)
  8356. {
  8357. char buf[255];
  8358. nullpo_retr(0, sd);
  8359. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8360. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8361. clif_displaymessage(fd, buf);
  8362. return 0;
  8363. }
  8364. /*==========================================
  8365. * @me by lordalfa
  8366. * => Displays the OUTPUT string on top of
  8367. * the Visible players Heads.
  8368. *------------------------------------------
  8369. */
  8370. int atcommand_me(
  8371. const int fd, struct map_session_data* sd,
  8372. const char* command, const char* message)
  8373. {
  8374. char tempmes[200];
  8375. nullpo_retr(-1, sd);
  8376. memset(tempmes, '\0', sizeof(tempmes));
  8377. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8378. if (!message || !*message) {
  8379. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8380. return -1;
  8381. }
  8382. sscanf(message, "%199[^\n]", tempmes);
  8383. sprintf(atcmd_output, "* %s %s *", sd->status.name, tempmes);
  8384. clif_disp_overhead(sd, atcmd_output);
  8385. return 0;
  8386. }
  8387. /*==========================================
  8388. * @size
  8389. * => Resize your character sprite. [Valaris]
  8390. *------------------------------------------
  8391. */
  8392. int atcommand_size(
  8393. const int fd, struct map_session_data* sd,
  8394. const char* command, const char* message)
  8395. {
  8396. int size=0;
  8397. nullpo_retr(-1, sd);
  8398. if (!message || !*message)
  8399. return -1;
  8400. if (sscanf(message,"%d", &size) < 1)
  8401. return -1;
  8402. if(sd->state.size) {
  8403. sd->state.size=0;
  8404. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8405. }
  8406. if(size==1) {
  8407. sd->state.size=1;
  8408. clif_specialeffect(&sd->bl,420,0);
  8409. } else if(size==2) {
  8410. sd->state.size=2;
  8411. clif_specialeffect(&sd->bl,422,0);
  8412. }
  8413. return 0;
  8414. }
  8415. /*==========================================
  8416. * @monsterignore
  8417. * => Makes monsters ignore you. [Valaris]
  8418. *------------------------------------------
  8419. */
  8420. int atcommand_monsterignore(
  8421. const int fd, struct map_session_data* sd,
  8422. const char* command, const char* message)
  8423. {
  8424. nullpo_retr(-1, sd);
  8425. if (!sd->state.monster_ignore) {
  8426. sd->state.monster_ignore = 1;
  8427. clif_displaymessage(sd->fd, "Monsters will now ignore you.");
  8428. } else {
  8429. sd->state.monster_ignore = 0;
  8430. clif_displaymessage(sd->fd, "Monsters are no longer ignoring you.");
  8431. }
  8432. return 0;
  8433. }
  8434. /*==========================================
  8435. * @fakename
  8436. * => Gives your character a fake name. [Valaris]
  8437. *------------------------------------------
  8438. */
  8439. int atcommand_fakename(
  8440. const int fd, struct map_session_data* sd,
  8441. const char* command, const char* message)
  8442. {
  8443. char name[NAME_LENGTH];
  8444. nullpo_retr(-1, sd);
  8445. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8446. sd->fakename[0]='\0';
  8447. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8448. clif_displaymessage(sd->fd,"Returned to real name.");
  8449. return 0;
  8450. }
  8451. if (!message || !*message) {
  8452. clif_displaymessage(sd->fd,"You must enter a name.");
  8453. return 0;
  8454. }
  8455. if (sscanf(message, "%23[^\n]", name) < 1) {
  8456. return 0;
  8457. }
  8458. if(strlen(name) < 2) {
  8459. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8460. return 0;
  8461. }
  8462. memcpy(sd->fakename,name,NAME_LENGTH-1);
  8463. clif_charnameack(0, &sd->bl);
  8464. clif_displaymessage(sd->fd,"Fake name enabled.");
  8465. return 0;
  8466. }
  8467. /*==========================================
  8468. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  8469. * => Shows information about the map flags [map name]
  8470. * Also set flags
  8471. *------------------------------------------
  8472. */
  8473. int atcommand_mapflag(
  8474. const int fd, struct map_session_data* sd,
  8475. const char* command, const char* message)
  8476. {
  8477. // WIP
  8478. return 0;
  8479. }
  8480. /*===================================
  8481. * Remove some messages
  8482. *-----------------------------------
  8483. */
  8484. int atcommand_showexp(
  8485. const int fd, struct map_session_data* sd,
  8486. const char* command, const char* message)
  8487. {
  8488. if (sd->state.showexp) {
  8489. sd->state.showexp = 0;
  8490. clif_displaymessage(fd, "Gained exp will not be shown.");
  8491. return 0;
  8492. }
  8493. sd->state.showexp = 1;
  8494. clif_displaymessage(fd, "Gained exp is now shown");
  8495. return 0;
  8496. }
  8497. int atcommand_showzeny(
  8498. const int fd, struct map_session_data* sd,
  8499. const char* command, const char* message)
  8500. {
  8501. if (sd->state.showzeny) {
  8502. sd->state.showzeny = 0;
  8503. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8504. return 0;
  8505. }
  8506. sd->state.showzeny = 1;
  8507. clif_displaymessage(fd, "Gained zeny is now shown");
  8508. return 0;
  8509. }
  8510. int atcommand_showdelay(
  8511. const int fd, struct map_session_data* sd,
  8512. const char* command, const char* message)
  8513. {
  8514. if (sd->state.showdelay) {
  8515. sd->state.showdelay = 0;
  8516. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8517. return 0;
  8518. }
  8519. sd->state.showdelay = 1;
  8520. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8521. return 0;
  8522. }
  8523. /*==========================================
  8524. * Duel organizing functions [LuzZza]
  8525. *
  8526. * @duel [limit|nick] - create a duel
  8527. * @invite <nick> - invite player
  8528. * @accept - accept invitation
  8529. * @reject - reject invitation
  8530. * @leave - leave duel
  8531. *------------------------------------------
  8532. */
  8533. int atcommand_invite(
  8534. const int fd, struct map_session_data* sd,
  8535. const char* command, const char* message)
  8536. {
  8537. unsigned int did = sd->duel_group;
  8538. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8539. if(did <= 0) {
  8540. // "Duel: @invite without @duel."
  8541. clif_displaymessage(fd, msg_txt(350));
  8542. return 0;
  8543. }
  8544. if(duel_list[did].max_players_limit > 0 &&
  8545. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8546. // "Duel: Limit of players is reached."
  8547. clif_displaymessage(fd, msg_txt(351));
  8548. return 0;
  8549. }
  8550. if(target_sd == NULL) {
  8551. // "Duel: Player not found."
  8552. clif_displaymessage(fd, msg_txt(352));
  8553. return 0;
  8554. }
  8555. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8556. // "Duel: Player already in duel."
  8557. clif_displaymessage(fd, msg_txt(353));
  8558. return 0;
  8559. }
  8560. duel_invite(did, sd, target_sd);
  8561. // "Duel: Invitation has been sent."
  8562. clif_displaymessage(fd, msg_txt(354));
  8563. return 0;
  8564. }
  8565. int atcommand_duel(
  8566. const int fd, struct map_session_data* sd,
  8567. const char* command, const char* message)
  8568. {
  8569. char output[256];
  8570. unsigned int maxpl=0, newduel;
  8571. struct map_session_data *target_sd;
  8572. /* // Commnted because it can be disabled in at-comms conf.
  8573. if(!battle_config.duel_enable) {
  8574. clif_displaymessage(fd, "Duel: duel is disable.");
  8575. return 0;
  8576. }
  8577. */
  8578. if(sd->duel_group > 0) {
  8579. duel_showinfo(sd->duel_group, sd);
  8580. return 0;
  8581. }
  8582. if(sd->duel_invite > 0) {
  8583. // "Duel: @duel without @reject."
  8584. clif_displaymessage(fd, msg_txt(355));
  8585. return 0;
  8586. }
  8587. if(!duel_checktime(sd)) {
  8588. // "Duel: You can take part in duel only one time per %d minutes."
  8589. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8590. clif_displaymessage(fd, output);
  8591. return 0;
  8592. }
  8593. if(strlen(message) > 0) {
  8594. if(sscanf(message, "%d", &maxpl) >= 1) {
  8595. if(maxpl < 2 || maxpl > 65535) {
  8596. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8597. return 0;
  8598. }
  8599. duel_create(sd, maxpl);
  8600. } else {
  8601. target_sd = map_nick2sd((char *)message);
  8602. if(target_sd != NULL) {
  8603. if((newduel = duel_create(sd, 2)) != -1) {
  8604. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8605. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8606. return 0;
  8607. }
  8608. duel_invite(newduel, sd, target_sd);
  8609. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8610. }
  8611. } else {
  8612. // "Duel: Player not found."
  8613. clif_displaymessage(fd, msg_txt(352));
  8614. return 0;
  8615. }
  8616. }
  8617. } else
  8618. duel_create(sd, 0);
  8619. return 0;
  8620. }
  8621. int atcommand_leave(
  8622. const int fd, struct map_session_data* sd,
  8623. const char* command, const char* message)
  8624. {
  8625. if(sd->duel_group <= 0) {
  8626. // "Duel: @leave without @duel."
  8627. clif_displaymessage(fd, msg_txt(358));
  8628. return 0;
  8629. }
  8630. duel_leave(sd->duel_group, sd);
  8631. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8632. return 0;
  8633. }
  8634. int atcommand_accept(
  8635. const int fd, struct map_session_data* sd,
  8636. const char* command, const char* message)
  8637. {
  8638. char output[256];
  8639. if(!duel_checktime(sd)) {
  8640. // "Duel: You can take part in duel only one time per %d minutes."
  8641. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8642. clif_displaymessage(fd, output);
  8643. return 0;
  8644. }
  8645. if(sd->duel_invite <= 0) {
  8646. // "Duel: @accept without invititation."
  8647. clif_displaymessage(fd, msg_txt(360));
  8648. return 0;
  8649. }
  8650. duel_accept(sd->duel_invite, sd);
  8651. // "Duel: Invitation has been accepted."
  8652. clif_displaymessage(fd, msg_txt(361));
  8653. return 0;
  8654. }
  8655. int atcommand_reject(
  8656. const int fd, struct map_session_data* sd,
  8657. const char* command, const char* message)
  8658. {
  8659. if(sd->duel_invite <= 0) {
  8660. // "Duel: @reject without invititation."
  8661. clif_displaymessage(fd, msg_txt(362));
  8662. return 0;
  8663. }
  8664. duel_reject(sd->duel_invite, sd);
  8665. // "Duel: Invitation has been rejected."
  8666. clif_displaymessage(fd, msg_txt(363));
  8667. return 0;
  8668. }
  8669. /*===================================
  8670. * Away message (@away, @aw) [LuzZza]
  8671. *-----------------------------------
  8672. */
  8673. int atcommand_away(
  8674. const int fd, struct map_session_data* sd,
  8675. const char* command, const char* message)
  8676. {
  8677. if(strlen(message) > 0) {
  8678. if(strlen(message) > 128)
  8679. return -1;
  8680. strcpy(sd->away_message, message);
  8681. //"Away automessage has been activated."
  8682. clif_displaymessage(fd, msg_txt(546));
  8683. } else {
  8684. if(strlen(sd->away_message) > 0) {
  8685. sd->away_message[0] = 0;
  8686. //"Away automessage has been disabled."
  8687. clif_displaymessage(fd, msg_txt(547));
  8688. return 0;
  8689. }
  8690. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8691. clif_displaymessage(fd, msg_txt(548));
  8692. }
  8693. return 0;
  8694. }
  8695. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8696. int atcommand_clone(
  8697. const int fd, struct map_session_data* sd,
  8698. const char* command, const char* message)
  8699. {
  8700. int x=0,y=0,flag=0,master=0,i=0;
  8701. struct map_session_data *pl_sd=NULL;
  8702. if (!message || !*message) {
  8703. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8704. return 0;
  8705. }
  8706. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8707. clif_displaymessage(fd, "Player not found.");
  8708. return 0;
  8709. }
  8710. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8711. clif_displaymessage(fd, "Cannot clone a player of higher GM level than yourself.");
  8712. return 0;
  8713. }
  8714. if (strcmpi(command, "@clone") == 0)
  8715. flag = 1;
  8716. else if (strcmpi(command, "@slaveclone") == 0) {
  8717. flag = 2;
  8718. master = sd->bl.id;
  8719. if (battle_config.atc_slave_clone_limit
  8720. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8721. clif_displaymessage(fd, "You've reached your slave clones limit.");
  8722. return 0;
  8723. }
  8724. }
  8725. do {
  8726. x = sd->bl.x + (rand() % 10 - 5);
  8727. y = sd->bl.y + (rand() % 10 - 5);
  8728. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8729. if (i >= 10) {
  8730. x = sd->bl.x;
  8731. y = sd->bl.y;
  8732. }
  8733. if((x = mob_clone_spawn(pl_sd, (char*)mapindex_id2name(sd->mapindex), x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8734. clif_displaymessage(fd, msg_txt(126+flag*2));
  8735. return 0;
  8736. }
  8737. clif_displaymessage(fd, msg_txt(127+flag*2));
  8738. return 0;
  8739. }
  8740. /*===================================
  8741. * Main chat [LuzZza]
  8742. * Usage: @main <on|off|message>
  8743. *-----------------------------------
  8744. */
  8745. int atcommand_main(
  8746. const int fd, struct map_session_data* sd,
  8747. const char* command, const char* message)
  8748. {
  8749. if(strlen(message) > 0) {
  8750. if(strlen(message) > 128)
  8751. return -1;
  8752. if(strcmpi(message, "on") == 0) {
  8753. if(!sd->state.mainchat) {
  8754. sd->state.mainchat = 1;
  8755. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8756. } else {
  8757. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8758. }
  8759. } else if(strcmpi(message, "off") == 0) {
  8760. if(sd->state.mainchat) {
  8761. sd->state.mainchat = 0;
  8762. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8763. } else {
  8764. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8765. }
  8766. } else {
  8767. if(!sd->state.mainchat) {
  8768. sd->state.mainchat = 1;
  8769. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8770. }
  8771. if (sd->sc.data[SC_NOCHAT].timer != -1) {
  8772. clif_displaymessage(fd, msg_txt(387));
  8773. return -1;
  8774. }
  8775. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8776. // I use 0xFE000000 color for signalizing that this message is
  8777. // main chat message. 0xFE000000 is invalid color, same using
  8778. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8779. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8780. }
  8781. } else {
  8782. if(sd->state.mainchat)
  8783. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8784. clif_displaymessage(fd, msg_txt(384));
  8785. else
  8786. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8787. clif_displaymessage(fd, msg_txt(385));
  8788. }
  8789. return 0;
  8790. }
  8791. void do_init_atcommand() {
  8792. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8793. duel_count = 0;
  8794. memset(&duel_list[0], 0, sizeof(duel_list));
  8795. return;
  8796. }
  8797. void do_final_atcommand() {
  8798. users_db->destroy(users_db,NULL);
  8799. }