atcommand.c 293 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "atcommand.h"
  14. #include "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 "npc.h"
  25. #include "pet.h"
  26. #include "mercenary.h" //[orn]
  27. #include "battle.h"
  28. #include "party.h"
  29. #include "guild.h"
  30. #include "script.h"
  31. #include "npc.h"
  32. #include "trade.h"
  33. #include "unit.h"
  34. #ifndef TXT_ONLY
  35. #include "mail.h"
  36. #endif
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <math.h>
  41. char atcommand_symbol = '@'; // first char of the commands (by [Yor])
  42. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  43. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  44. ACMD_FUNC(broadcast);
  45. ACMD_FUNC(localbroadcast);
  46. ACMD_FUNC(rura);
  47. ACMD_FUNC(where);
  48. ACMD_FUNC(jumpto);
  49. ACMD_FUNC(jump);
  50. ACMD_FUNC(who);
  51. ACMD_FUNC(who2);
  52. ACMD_FUNC(who3);
  53. ACMD_FUNC(whomap);
  54. ACMD_FUNC(whomap2);
  55. ACMD_FUNC(whomap3);
  56. ACMD_FUNC(whogm); // by Yor
  57. ACMD_FUNC(whozeny); // [Valaris]
  58. ACMD_FUNC(save);
  59. ACMD_FUNC(load);
  60. ACMD_FUNC(speed);
  61. ACMD_FUNC(storage);
  62. ACMD_FUNC(guildstorage);
  63. ACMD_FUNC(option);
  64. ACMD_FUNC(hide);
  65. ACMD_FUNC(jobchange);
  66. ACMD_FUNC(die);
  67. ACMD_FUNC(kill);
  68. ACMD_FUNC(alive);
  69. ACMD_FUNC(kami);
  70. ACMD_FUNC(heal);
  71. ACMD_FUNC(item);
  72. ACMD_FUNC(item2);
  73. ACMD_FUNC(itemreset);
  74. ACMD_FUNC(baselevelup);
  75. ACMD_FUNC(joblevelup);
  76. ACMD_FUNC(help);
  77. ACMD_FUNC(help2);
  78. ACMD_FUNC(gm);
  79. ACMD_FUNC(pvpoff);
  80. ACMD_FUNC(pvpon);
  81. ACMD_FUNC(gvgoff);
  82. ACMD_FUNC(gvgon);
  83. ACMD_FUNC(model);
  84. ACMD_FUNC(go);
  85. ACMD_FUNC(monster);
  86. ACMD_FUNC(monstersmall);
  87. ACMD_FUNC(monsterbig);
  88. ACMD_FUNC(spawn);
  89. ACMD_FUNC(killmonster);
  90. ACMD_FUNC(killmonster2);
  91. ACMD_FUNC(refine);
  92. ACMD_FUNC(produce);
  93. ACMD_FUNC(memo);
  94. ACMD_FUNC(gat);
  95. ACMD_FUNC(displaystatus);
  96. ACMD_FUNC(statuspoint);
  97. ACMD_FUNC(skillpoint);
  98. ACMD_FUNC(zeny);
  99. ACMD_FUNC(param);
  100. ACMD_FUNC(guildlevelup);
  101. ACMD_FUNC(makeegg);
  102. ACMD_FUNC(hatch);
  103. ACMD_FUNC(petfriendly);
  104. ACMD_FUNC(pethungry);
  105. ACMD_FUNC(petrename);
  106. ACMD_FUNC(recall);
  107. ACMD_FUNC(recallall);
  108. ACMD_FUNC(night);
  109. ACMD_FUNC(day);
  110. ACMD_FUNC(doom);
  111. ACMD_FUNC(doommap);
  112. ACMD_FUNC(raise);
  113. ACMD_FUNC(raisemap);
  114. ACMD_FUNC(kick);
  115. ACMD_FUNC(kickall);
  116. ACMD_FUNC(allskill);
  117. ACMD_FUNC(questskill);
  118. ACMD_FUNC(lostskill);
  119. ACMD_FUNC(spiritball);
  120. ACMD_FUNC(party);
  121. ACMD_FUNC(guild);
  122. ACMD_FUNC(agitstart);
  123. ACMD_FUNC(agitend);
  124. ACMD_FUNC(reloaditemdb);
  125. ACMD_FUNC(reloadmobdb);
  126. ACMD_FUNC(reloadskilldb);
  127. ACMD_FUNC(reloadscript);
  128. ACMD_FUNC(reloadgmdb); // by Yor
  129. ACMD_FUNC(reloadatcommand);
  130. ACMD_FUNC(reloadbattleconf);
  131. ACMD_FUNC(reloadstatusdb);
  132. ACMD_FUNC(reloadpcdb);
  133. ACMD_FUNC(reloadmotd); // [Valaris]
  134. ACMD_FUNC(mapexit);
  135. ACMD_FUNC(idsearch);
  136. ACMD_FUNC(mapinfo);
  137. ACMD_FUNC(dye); //** by fritz
  138. ACMD_FUNC(hair_style); //** by fritz
  139. ACMD_FUNC(hair_color); //** by fritz
  140. ACMD_FUNC(stat_all); //** by fritz
  141. ACMD_FUNC(char_block); // by Yor
  142. ACMD_FUNC(char_ban); // by Yor
  143. ACMD_FUNC(char_unblock); // by Yor
  144. ACMD_FUNC(char_unban); // by Yor
  145. ACMD_FUNC(mount_peco); // by Valaris
  146. ACMD_FUNC(guildspy); // [Syrus22]
  147. ACMD_FUNC(partyspy); // [Syrus22]
  148. ACMD_FUNC(repairall); // [Valaris]
  149. ACMD_FUNC(guildrecall); // by Yor
  150. ACMD_FUNC(partyrecall); // by Yor
  151. ACMD_FUNC(nuke); // [Valaris]
  152. ACMD_FUNC(shownpc);
  153. ACMD_FUNC(hidenpc);
  154. ACMD_FUNC(loadnpc);
  155. ACMD_FUNC(unloadnpc);
  156. ACMD_FUNC(servertime); // by Yor
  157. ACMD_FUNC(jail); // by Yor
  158. ACMD_FUNC(unjail); // by Yor
  159. ACMD_FUNC(jailfor); // Alias Meruru
  160. ACMD_FUNC(jailtime); // Coltaro
  161. ACMD_FUNC(disguise); // [Valaris]
  162. ACMD_FUNC(undisguise); // by Yor
  163. ACMD_FUNC(email); // by Yor
  164. ACMD_FUNC(effect);//by Apple
  165. ACMD_FUNC(addwarp); // by MouseJstr
  166. ACMD_FUNC(follow); // by MouseJstr
  167. ACMD_FUNC(skillon); // by MouseJstr
  168. ACMD_FUNC(skilloff); // by MouseJstr
  169. ACMD_FUNC(killer); // by MouseJstr
  170. ACMD_FUNC(npcmove); // by MouseJstr
  171. ACMD_FUNC(killable); // by MouseJstr
  172. ACMD_FUNC(dropall); // by MouseJstr
  173. ACMD_FUNC(storeall); // by MouseJstr
  174. ACMD_FUNC(skillid); // by MouseJstr
  175. ACMD_FUNC(useskill); // by MouseJstr
  176. ACMD_FUNC(displayskill); //[Skotlex]
  177. ACMD_FUNC(summon);
  178. ACMD_FUNC(rain);
  179. ACMD_FUNC(snow);
  180. ACMD_FUNC(sakura);
  181. ACMD_FUNC(clouds);
  182. ACMD_FUNC(clouds2); // [Valaris]
  183. ACMD_FUNC(fog);
  184. ACMD_FUNC(fireworks);
  185. ACMD_FUNC(leaves);
  186. ACMD_FUNC(adjgmlvl); // by MouseJstr
  187. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  188. ACMD_FUNC(trade); // by MouseJstr
  189. ACMD_FUNC(send); // by davidsiaw
  190. ACMD_FUNC(setbattleflag); // by MouseJstr
  191. ACMD_FUNC(unmute); // [Valaris]
  192. ACMD_FUNC(clearweather); // Dexity
  193. ACMD_FUNC(uptime); // by MC Cameri
  194. ACMD_FUNC(changesex); // by MC Cameri
  195. ACMD_FUNC(mute); // celest
  196. ACMD_FUNC(refresh); // by MC Cameri
  197. ACMD_FUNC(petid); // by MC Cameri
  198. ACMD_FUNC(identify); // by MC Cameri
  199. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  200. ACMD_FUNC(misceffect); // by MC Cameri
  201. ACMD_FUNC(mobsearch);
  202. ACMD_FUNC(cleanmap);
  203. ACMD_FUNC(npctalk);
  204. ACMD_FUNC(pettalk);
  205. ACMD_FUNC(users);
  206. ACMD_FUNC(reset);
  207. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  208. ACMD_FUNC(skilltree); // by MouseJstr
  209. ACMD_FUNC(marry); // by MouseJstr
  210. ACMD_FUNC(divorce); // by MouseJstr
  211. ACMD_FUNC(jumptoid2); // by Dino9021
  212. ACMD_FUNC(recallid2); // by Dino9021
  213. ACMD_FUNC(kickid2); // by Dino9021
  214. ACMD_FUNC(reviveid2); // by Dino9021
  215. ACMD_FUNC(killid2); // by Dino9021
  216. ACMD_FUNC(sound);
  217. ACMD_FUNC(undisguiseall);
  218. ACMD_FUNC(disguiseall);
  219. ACMD_FUNC(changelook);
  220. ACMD_FUNC(mobinfo); //by Lupus
  221. ACMD_FUNC(exp); // by Skotlex
  222. ACMD_FUNC(adopt); // by Veider
  223. ACMD_FUNC(version); // by Ancyker
  224. ACMD_FUNC(mutearea); // by MouseJstr
  225. ACMD_FUNC(rates); // by MouseJstr
  226. ACMD_FUNC(iteminfo); // Lupus
  227. ACMD_FUNC(whodrops); //Skotlex
  228. ACMD_FUNC(whereis); //Skotlex
  229. ACMD_FUNC(mapflag); // Lupus
  230. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  231. ACMD_FUNC(monsterignore); // [Valaris]
  232. ACMD_FUNC(fakename); //[Valaris]
  233. ACMD_FUNC(size); //[Valaris]
  234. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  235. ACMD_FUNC(showzeny);
  236. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  237. ACMD_FUNC(autotrade);// durf
  238. ACMD_FUNC(changeleader);// [Skotlex]
  239. ACMD_FUNC(partyoption);// [Skotlex]
  240. ACMD_FUNC(changegm);// durf
  241. // Duel [LuzZza]
  242. ACMD_FUNC(invite);
  243. ACMD_FUNC(duel);
  244. ACMD_FUNC(leave);
  245. ACMD_FUNC(accept);
  246. ACMD_FUNC(reject);
  247. ACMD_FUNC(away); // LuzZza
  248. ACMD_FUNC(main); // LuzZza
  249. ACMD_FUNC(clone); // [Valaris]
  250. ACMD_FUNC(tonpc); // LuzZza
  251. ACMD_FUNC(commands); // [Skotlex]
  252. ACMD_FUNC(noask); //LuzZza
  253. ACMD_FUNC(request); //[Skotlex]
  254. ACMD_FUNC(homlevel); //[orn]
  255. ACMD_FUNC(homevolution); //[orn]
  256. ACMD_FUNC(makehomun); //[orn]
  257. ACMD_FUNC(homfriendly); //[orn]
  258. ACMD_FUNC(homhungry); //[orn]
  259. ACMD_FUNC(homtalk); //[orn]
  260. ACMD_FUNC(hominfo); //[Toms]
  261. ACMD_FUNC(homstats); //[Skotlex]
  262. ACMD_FUNC(homshuffle); //[Skotlex]
  263. ACMD_FUNC(showmobs); //KarLaeda
  264. ACMD_FUNC(feelreset); //[HiddenDragon]
  265. #ifndef TXT_ONLY
  266. ACMD_FUNC(checkmail); // [Valaris]
  267. ACMD_FUNC(listmail); // [Valaris]
  268. ACMD_FUNC(listnewmail); // [Valaris]
  269. ACMD_FUNC(readmail); // [Valaris]
  270. ACMD_FUNC(deletemail); // [Valaris]
  271. ACMD_FUNC(sendmail); // [Valaris]
  272. ACMD_FUNC(sendprioritymail); // [Valaris]
  273. ACMD_FUNC(refreshonline); // [Valaris]
  274. #endif
  275. #ifdef DMALLOC
  276. ACMD_FUNC(dmstart); // by MouseJstr
  277. ACMD_FUNC(dmtick); // by MouseJstr
  278. #endif
  279. /*==========================================
  280. *AtCommandInfo atcommand_info[] structure definition
  281. *------------------------------------------*/
  282. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  283. // to set default level, read atcommand_athena.conf first please.
  284. static AtCommandInfo atcommand_info[] = {
  285. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  286. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  287. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  288. { AtCommand_Where, "@where", 1, atcommand_where },
  289. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  290. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  291. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  292. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  293. { AtCommand_Who, "@who", 20, atcommand_who },
  294. { AtCommand_Who, "@whois", 20, atcommand_who },
  295. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  296. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  297. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  298. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  299. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  300. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  301. { AtCommand_Save, "@save", 40, atcommand_save },
  302. { AtCommand_Load, "@return", 40, atcommand_load },
  303. { AtCommand_Load, "@load", 40, atcommand_load },
  304. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  305. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  306. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  307. { AtCommand_Option, "@option", 40, atcommand_option },
  308. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  309. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  310. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  311. { AtCommand_Die, "@die", 1, atcommand_die },
  312. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  313. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  314. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  315. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  316. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  317. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  318. { AtCommand_Item, "@item", 60, atcommand_item },
  319. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  320. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  321. { AtCommand_BaseLevelUp, "@baselvl", 60, atcommand_baselevelup },
  322. { AtCommand_BaseLevelUp, "@baselevel", 60, atcommand_baselevelup },
  323. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  324. { AtCommand_BaseLevelUp, "@blvl", 60, atcommand_baselevelup },
  325. { AtCommand_JobLevelUp, "@jlvl", 60, atcommand_joblevelup },
  326. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  327. { AtCommand_JobLevelUp, "@joblvl", 60, atcommand_joblevelup },
  328. { AtCommand_JobLevelUp, "@joblevel", 60, atcommand_joblevelup },
  329. { AtCommand_H, "@h", 20, atcommand_help },
  330. { AtCommand_Help, "@help", 20, atcommand_help },
  331. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  332. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  333. { AtCommand_GM, "@gm", 100,atcommand_gm },
  334. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  335. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  336. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  337. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  338. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  339. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  340. { AtCommand_Model, "@model", 20, atcommand_model },
  341. { AtCommand_Go, "@go", 10, atcommand_go },
  342. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  343. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  344. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  345. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  346. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  347. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  348. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  349. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  350. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  351. { AtCommand_GAT, "@gat", 99, atcommand_gat },
  352. { AtCommand_DisplayStatus, "@displaystatus", 99, atcommand_displaystatus },
  353. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  354. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  355. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  356. { AtCommand_Strength, "@str", 60, atcommand_param },
  357. { AtCommand_Agility, "@agi", 60, atcommand_param },
  358. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  359. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  360. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  361. { AtCommand_Luck, "@luk", 60, atcommand_param },
  362. { AtCommand_GuildLevelUp, "@glvl", 60, atcommand_guildlevelup },
  363. { AtCommand_GuildLevelUp, "@glevel", 60, atcommand_guildlevelup },
  364. { AtCommand_GuildLevelUp, "@guildlvl", 60, atcommand_guildlevelup },
  365. { AtCommand_GuildLevelUp, "@guildlevel", 60, atcommand_guildlevelup },
  366. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  367. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  368. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  369. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  370. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  371. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  372. { AtCommand_Night, "@night", 80, atcommand_night },
  373. { AtCommand_Day, "@day", 80, atcommand_day },
  374. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  375. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  376. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  377. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  378. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  379. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  380. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  381. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  382. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  383. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  384. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  385. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  386. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  387. { AtCommand_Party, "@party", 1, atcommand_party },
  388. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  389. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  390. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  391. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  392. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  393. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  394. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  395. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  396. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  397. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  398. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  399. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  400. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  401. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  402. { AtCommand_ReloadBattleConf, "@reloadbattleconf",99, atcommand_reloadbattleconf },
  403. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  404. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  405. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  406. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  407. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  408. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  409. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  410. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  411. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  412. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  413. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  414. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  415. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  416. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  417. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  418. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  419. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  420. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  421. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  422. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  423. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  424. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  425. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  426. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  427. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  428. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  429. { AtCommand_MountPeco, "@mount", 20, atcommand_mount_peco }, // by Valaris
  430. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  431. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  432. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  433. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  434. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  435. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  436. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  437. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  438. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  439. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  440. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  441. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  442. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  443. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  444. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  445. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  446. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  447. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  448. { AtCommand_JailFor, "@jailfor", 60, atcommand_jailfor }, //Meruru
  449. { AtCommand_JailTime, "@jailtime", 1, atcommand_jailtime }, //Change this to 0 in atcommand_conf.txt if you want it accessible to players (you most likely will ;))
  450. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  451. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  452. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  453. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  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", 80, atcommand_npcmove }, // by MouseJstr
  460. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  461. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  462. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  463. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  464. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  465. { AtCommand_DisplaySkill, "@displayskill", 99, atcommand_displayskill }, // Skotlex
  466. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  467. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  468. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  469. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  470. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  471. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  472. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  473. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  474. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  475. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  476. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  477. { AtCommand_Send, "@send", 99, atcommand_send },
  478. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  479. { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
  480. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  481. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  482. { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken] <- why not? [Skotlex]
  483. { AtCommand_Mute, "@mute", 80, atcommand_mute }, // [celest]
  484. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  485. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  486. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  487. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  488. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  489. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  490. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  491. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  492. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  493. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  494. { AtCommand_Users, "@users", 40, atcommand_users },
  495. { AtCommand_ResetState, "@reset", 40, atcommand_reset },
  496. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  497. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  498. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  499. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  500. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  501. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  502. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  503. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  504. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  505. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  506. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  507. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  508. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  509. { AtCommand_ChangeLook, "@changelook", 60, atcommand_changelook },
  510. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  511. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  512. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  513. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  514. { AtCommand_Exp, "@exp", 1, atcommand_exp }, // [Skotlex]
  515. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  516. { AtCommand_Version, "@version", 1, atcommand_version },
  517. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  518. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  519. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  520. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  521. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  522. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  523. { AtCommand_WhereIs, "@whereis", 10, atcommand_whereis }, // [Skotlex]
  524. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  525. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  526. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  527. { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
  528. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  529. { AtCommand_Size, "@size", 20, atcommand_size },
  530. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  531. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  532. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  533. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  534. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  535. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  536. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  537. { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
  538. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  539. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  540. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  541. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  542. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  543. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  544. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  545. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  546. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  547. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  548. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  549. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  550. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  551. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  552. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  553. { AtCommand_HomLevel, "@hlvl", 60, atcommand_homlevel },
  554. { AtCommand_HomLevel, "@hlevel", 60, atcommand_homlevel },
  555. { AtCommand_HomLevel, "@homlvl", 60, atcommand_homlevel },
  556. { AtCommand_HomLevel, "@homlevel", 60, atcommand_homlevel },
  557. { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
  558. { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
  559. { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
  560. { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
  561. { AtCommand_HomTalk, "@homtalk", 10, atcommand_homtalk },
  562. { AtCommand_HomInfo, "@hominfo", 1, atcommand_hominfo },
  563. { AtCommand_HomStats, "@homstats", 1, atcommand_homstats },
  564. { AtCommand_HomShuffle, "@homshuffle", 60, atcommand_homshuffle },
  565. { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
  566. { AtCommand_FeelReset, "@feelreset", 10, atcommand_feelreset }, //[HiddenDragon]
  567. #ifndef TXT_ONLY // sql-only commands
  568. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  569. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  570. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  571. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  572. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_deletemail }, // [Valaris]
  573. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  574. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  575. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  576. #endif
  577. #ifdef DMALLOC
  578. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  579. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  580. #endif
  581. // add new commands before this line
  582. { AtCommand_Unknown, NULL, 1, NULL }
  583. };
  584. /*=========================================
  585. * Generic variables
  586. *-----------------------------------------*/
  587. char atcmd_output[200];
  588. char atcmd_player_name[NAME_LENGTH];
  589. char atcmd_temp[100];
  590. // compare function for sorting high to lowest
  591. int hightolow_compare (const void * a, const void * b)
  592. {
  593. return ( *(int*)b - *(int*)a );
  594. }
  595. // compare function for sorting lowest to highest
  596. int lowtohigh_compare (const void * a, const void * b)
  597. {
  598. return ( *(int*)a - *(int*)b );
  599. }
  600. //-----------------------------------------------------------
  601. // Return the message string of the specified number by [Yor]
  602. //-----------------------------------------------------------
  603. char* msg_txt(int msg_number)
  604. {
  605. if (msg_number >= 0 && msg_number < MAX_MSG &&
  606. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  607. return msg_table[msg_number];
  608. return "??";
  609. }
  610. //-----------------------------------------------------------
  611. // Returns Players title (from msg_athena.conf) [Lupus]
  612. //-----------------------------------------------------------
  613. static char* player_title_txt(int level)
  614. {
  615. const char* format;
  616. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  617. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  618. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  619. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  620. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  621. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  622. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  623. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  624. : "";
  625. sprintf(atcmd_temp, format, level);
  626. return atcmd_temp;
  627. }
  628. /*==========================================
  629. * Retrieve the atcommand's required gm level
  630. *------------------------------------------*/
  631. int get_atcommand_level(const AtCommandType type)
  632. {
  633. int i;
  634. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  635. if (atcommand_info[i].type == type)
  636. return atcommand_info[i].level;
  637. return 100; // 100: command can not be used
  638. }
  639. AtCommandType is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  640. {
  641. AtCommandInfo info;
  642. AtCommandType type;
  643. memset(&info, 0, sizeof(info));
  644. type = atcommand(sd, gmlvl, str, &info);
  645. if (type != AtCommand_None) {
  646. char command[100];
  647. const char* p = str;
  648. if (map[sd->bl.m].nocommand &&
  649. gmlvl < map[sd->bl.m].nocommand)
  650. { //Command not allowed on this map.
  651. sprintf(atcmd_output, msg_txt(143));
  652. clif_displaymessage(fd, atcmd_output);
  653. return AtCommand_None;
  654. }
  655. memset(command, '\0', sizeof(command));
  656. memset(atcmd_output, '\0', sizeof(atcmd_output));
  657. while (*p && !ISSPACE(*p))
  658. p++;
  659. if (p - str >= sizeof(command)) // too long
  660. return AtCommand_Unknown;
  661. strncpy(command, str, p - str);
  662. while (ISSPACE(*p))
  663. p++;
  664. if (type == AtCommand_Unknown || info.proc == NULL) {
  665. sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
  666. clif_displaymessage(fd, atcmd_output);
  667. } else {
  668. if (info.proc(fd, sd, command, p) != 0) {
  669. // Command can not be executed
  670. sprintf(atcmd_output, msg_txt(154), command); // %s failed.
  671. clif_displaymessage(fd, atcmd_output);
  672. }
  673. }
  674. return info.type;
  675. }
  676. return AtCommand_None;
  677. }
  678. /*==========================================
  679. *
  680. *------------------------------------------*/
  681. AtCommandType is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  682. {
  683. const char* str = message;
  684. int s_flag = 0;
  685. nullpo_retr(AtCommand_None, sd);
  686. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
  687. return AtCommand_Unknown;
  688. }
  689. if (!message || !*message)
  690. return AtCommand_None;
  691. str += strlen(sd->status.name);
  692. while (*str && (ISSPACE(*str) || (s_flag == 0 && *str == ':'))) {
  693. if (*str == ':')
  694. s_flag = 1;
  695. str++;
  696. }
  697. if (!*str)
  698. return AtCommand_None;
  699. if(str[0] == '|' && strlen(str) >= 4 && str[3] == atcommand_symbol)
  700. str += 3; // skip 10/11-langtype's codepage indicator, if detected
  701. return is_atcommand_sub(fd,sd,str,pc_isGM(sd));
  702. }
  703. /*==========================================
  704. *
  705. *------------------------------------------*/
  706. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info)
  707. {
  708. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  709. if (!info)
  710. return AtCommand_None;
  711. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  712. return AtCommand_None;
  713. if (!p || !*p) {
  714. ShowError("at command message is empty\n");
  715. return AtCommand_None;
  716. }
  717. if (*p == atcommand_symbol) { // check first char
  718. char command[101];
  719. int i = 0;
  720. memset(info, 0, sizeof(AtCommandInfo));
  721. sscanf(p, "%100s", command);
  722. command[100] = '\0';
  723. while (atcommand_info[i].type != AtCommand_Unknown) {
  724. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  725. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  726. break;
  727. }
  728. i++;
  729. }
  730. if (atcommand_info[i].type == AtCommand_Unknown) {
  731. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  732. if (level == 0)
  733. return AtCommand_None;
  734. else
  735. return AtCommand_Unknown;
  736. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  737. log_atcommand(sd, message);
  738. }
  739. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  740. } else {
  741. return AtCommand_None;
  742. }
  743. return info->type;
  744. }
  745. /*==========================================
  746. * Read Message Data
  747. *------------------------------------------*/
  748. int msg_config_read(const char* cfgName)
  749. {
  750. int msg_number;
  751. char line[1024], w1[1024], w2[1024];
  752. FILE *fp;
  753. static int called = 1;
  754. if ((fp = fopen(cfgName, "r")) == NULL) {
  755. ShowError("Messages file not found: %s\n", cfgName);
  756. return 1;
  757. }
  758. if ((--called) == 0)
  759. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  760. while(fgets(line, sizeof(line), fp))
  761. {
  762. if (line[0] == '/' && line[1] == '/')
  763. continue;
  764. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  765. continue;
  766. if (strcmpi(w1, "import") == 0)
  767. msg_config_read(w2);
  768. else
  769. {
  770. msg_number = atoi(w1);
  771. if (msg_number >= 0 && msg_number < MAX_MSG)
  772. {
  773. if (msg_table[msg_number] != NULL)
  774. aFree(msg_table[msg_number]);
  775. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  776. strcpy(msg_table[msg_number],w2);
  777. }
  778. }
  779. }
  780. fclose(fp);
  781. return 0;
  782. }
  783. /*==========================================
  784. * Cleanup Message Data
  785. *------------------------------------------*/
  786. void do_final_msg(void)
  787. {
  788. int i;
  789. for (i = 0; i < MAX_MSG; i++)
  790. aFree(msg_table[i]);
  791. return;
  792. }
  793. /*==========================================
  794. *
  795. *------------------------------------------*/
  796. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  797. {
  798. int i;
  799. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  800. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  801. return &atcommand_info[i];
  802. return NULL;
  803. }
  804. /*==========================================
  805. *
  806. *------------------------------------------*/
  807. int atcommand_config_read(const char *cfgName)
  808. {
  809. char line[1024], w1[1024], w2[1024];
  810. AtCommandInfo* p;
  811. FILE* fp;
  812. if ((fp = fopen(cfgName, "r")) == NULL) {
  813. ShowError("At commands configuration file not found: %s\n", cfgName);
  814. return 1;
  815. }
  816. while(fgets(line, sizeof(line), fp))
  817. {
  818. if (line[0] == '/' && line[1] == '/')
  819. continue;
  820. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  821. continue;
  822. p = get_atcommandinfo_byname(w1);
  823. if (p != NULL) {
  824. p->level = atoi(w2);
  825. if (p->level > 100)
  826. p->level = 100;
  827. else if (p->level < 0)
  828. p->level = 0;
  829. }
  830. if (strcmpi(w1, "import") == 0)
  831. atcommand_config_read(w2);
  832. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  833. w2[0] != '/' && // symbol of standard ragnarok GM commands
  834. w2[0] != '%' && // symbol of party chat speaking
  835. w2[0] != '$' && // symbol of guild chat
  836. w2[0] != '#') // symbol of charcommand
  837. atcommand_symbol = w2[0];
  838. }
  839. fclose(fp);
  840. return 0;
  841. }
  842. /*==========================================
  843. // @ command processing functions
  844. *------------------------------------------*/
  845. /*==========================================
  846. * @commands Lists available @ commands to you (code 98% from Meruru)
  847. *------------------------------------------*/
  848. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  849. {
  850. char cz_line_buff[CHATBOX_SIZE+1];
  851. register char *lpcz_cur = cz_line_buff;
  852. register unsigned int ui_slen;
  853. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  854. memset(cz_line_buff,' ',CHATBOX_SIZE);
  855. cz_line_buff[CHATBOX_SIZE] = 0;
  856. clif_displaymessage(fd, msg_txt(273));
  857. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  858. {
  859. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  860. continue;
  861. count++;
  862. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  863. //remember not <= bc we need null terminator
  864. if(((CHATBOX_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  865. {
  866. clif_displaymessage(fd,(char*)cz_line_buff);
  867. lpcz_cur = cz_line_buff;
  868. memset(cz_line_buff,' ',CHATBOX_SIZE);
  869. cz_line_buff[CHATBOX_SIZE] = 0;
  870. }
  871. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  872. lpcz_cur += ui_slen+(10-ui_slen%10);
  873. }
  874. clif_displaymessage(fd,(char*)cz_line_buff);
  875. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  876. clif_displaymessage(fd, atcmd_output);
  877. return 0;
  878. }
  879. /*==========================================
  880. * @send (used for testing packet sends from the client)
  881. *------------------------------------------*/
  882. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  883. {
  884. int len=0,off,end,type;
  885. long num;
  886. (void)command; // not used
  887. // read message type as hex number (without the 0x)
  888. if(!message || !*message ||
  889. !((sscanf(message, "len %x", &type)==1 && (len=1))
  890. || sscanf(message, "%x", &type)==1) )
  891. {
  892. clif_displaymessage(fd, "Usage:");
  893. clif_displaymessage(fd, " @send len <packet hex number>");
  894. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  895. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  896. return -1;
  897. }
  898. #define PARSE_ERROR(error,p) \
  899. {\
  900. clif_displaymessage(fd, (error));\
  901. sprintf(atcmd_output, ">%s", (p));\
  902. clif_displaymessage(fd, atcmd_output);\
  903. }
  904. //define PARSE_ERROR
  905. #define CHECK_EOS(p) \
  906. if(*(p) == 0){\
  907. clif_displaymessage(fd, "Unexpected end of string");\
  908. return -1;\
  909. }
  910. //define CHECK_EOS
  911. #define SKIP_VALUE(p) \
  912. {\
  913. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  914. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  915. }
  916. //define SKIP_VALUE
  917. #define GET_VALUE(p,num) \
  918. {\
  919. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  920. PARSE_ERROR("Invalid number in:",(p));\
  921. return -1;\
  922. }\
  923. }
  924. //define GET_VALUE
  925. if (type > 0 && type < MAX_PACKET_DB) {
  926. if(len)
  927. {// show packet length
  928. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  929. clif_displaymessage(fd, atcmd_output);
  930. return 0;
  931. }
  932. len=packet_db[sd->packet_ver][type].len;
  933. off=2;
  934. if(len == 0)
  935. {// unknown packet - ERROR
  936. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  937. clif_displaymessage(fd, atcmd_output);
  938. return -1;
  939. } else if(len == -1)
  940. {// dynamic packet
  941. len=SHRT_MAX-4; // maximum length
  942. off=4;
  943. }
  944. WFIFOHEAD(fd, len);
  945. WFIFOW(fd,0)=TOW(type);
  946. // parse packet contents
  947. SKIP_VALUE(message);
  948. while(*message != 0 && off < len){
  949. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  950. {// default (byte)
  951. GET_VALUE(message,num);
  952. WFIFOB(fd,off)=TOB(num);
  953. ++off;
  954. } else if(TOUPPER(*message) == 'B')
  955. {// byte
  956. ++message;
  957. GET_VALUE(message,num);
  958. WFIFOB(fd,off)=TOB(num);
  959. ++off;
  960. } else if(TOUPPER(*message) == 'W')
  961. {// word (2 bytes)
  962. ++message;
  963. GET_VALUE(message,num);
  964. WFIFOW(fd,off)=TOW(num);
  965. off+=2;
  966. } else if(TOUPPER(*message) == 'L')
  967. {// long word (4 bytes)
  968. ++message;
  969. GET_VALUE(message,num);
  970. WFIFOL(fd,off)=TOL(num);
  971. off+=4;
  972. } else if(TOUPPER(*message) == 'S')
  973. {// string - escapes are valid
  974. // get string length - num <= 0 means not fixed length (default)
  975. ++message;
  976. if(*message == '"'){
  977. num=0;
  978. } else {
  979. GET_VALUE(message,num);
  980. while(*message != '"')
  981. {// find start of string
  982. if(*message == 0 || ISSPACE(*message)){
  983. PARSE_ERROR("Not a string:",message);
  984. return -1;
  985. }
  986. ++message;
  987. }
  988. }
  989. // parse string
  990. ++message;
  991. CHECK_EOS(message);
  992. end=(num<=0? 0: min(off+((int)num),len));
  993. for(; *message != '"' && (off < end || end == 0); ++off){
  994. if(*message == '\\'){
  995. ++message;
  996. CHECK_EOS(message);
  997. switch(*message){
  998. case 'a': num=0x07; break; // Bell
  999. case 'b': num=0x08; break; // Backspace
  1000. case 't': num=0x09; break; // Horizontal tab
  1001. case 'n': num=0x0A; break; // Line feed
  1002. case 'v': num=0x0B; break; // Vertical tab
  1003. case 'f': num=0x0C; break; // Form feed
  1004. case 'r': num=0x0D; break; // Carriage return
  1005. case 'e': num=0x1B; break; // Escape
  1006. default: num=*message; break;
  1007. case 'x': // Hexadecimal
  1008. {
  1009. ++message;
  1010. CHECK_EOS(message);
  1011. if(!ISXDIGIT(*message)){
  1012. PARSE_ERROR("Not a hexadecimal digit:",message);
  1013. return -1;
  1014. }
  1015. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  1016. if(ISXDIGIT(*message)){
  1017. ++message;
  1018. CHECK_EOS(message);
  1019. num<<=8;
  1020. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  1021. }
  1022. WFIFOB(fd,off)=TOB(num);
  1023. ++message;
  1024. CHECK_EOS(message);
  1025. continue;
  1026. }
  1027. case '0':
  1028. case '1':
  1029. case '2':
  1030. case '3':
  1031. case '4':
  1032. case '5':
  1033. case '6':
  1034. case '7': // Octal
  1035. {
  1036. num=*message-'0'; // 1st octal digit
  1037. ++message;
  1038. CHECK_EOS(message);
  1039. if(ISDIGIT(*message) && *message < '8'){
  1040. num<<=3;
  1041. num+=*message-'0'; // 2nd octal digit
  1042. ++message;
  1043. CHECK_EOS(message);
  1044. if(ISDIGIT(*message) && *message < '8'){
  1045. num<<=3;
  1046. num+=*message-'0'; // 3rd octal digit
  1047. ++message;
  1048. CHECK_EOS(message);
  1049. }
  1050. }
  1051. WFIFOB(fd,off)=TOB(num);
  1052. continue;
  1053. }
  1054. }
  1055. } else
  1056. num=*message;
  1057. WFIFOB(fd,off)=TOB(num);
  1058. ++message;
  1059. CHECK_EOS(message);
  1060. }//for
  1061. while(*message != '"')
  1062. {// ignore extra characters
  1063. ++message;
  1064. CHECK_EOS(message);
  1065. }
  1066. // terminate the string
  1067. if(off < end)
  1068. {// fill the rest with 0's
  1069. memset(WFIFOP(fd,off),0,end-off);
  1070. off=end;
  1071. }
  1072. } else
  1073. {// unknown
  1074. PARSE_ERROR("Unknown type of value in:",message);
  1075. return -1;
  1076. }
  1077. SKIP_VALUE(message);
  1078. }
  1079. if(packet_db[sd->packet_ver][type].len == -1)
  1080. {// send dynamic packet
  1081. WFIFOW(fd,2)=TOW(off);
  1082. WFIFOSET(fd,off);
  1083. } else
  1084. {// send static packet
  1085. if(off < len)
  1086. memset(WFIFOP(fd,off),0,len-off);
  1087. WFIFOSET(fd,len);
  1088. }
  1089. } else {
  1090. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  1091. return -1;
  1092. }
  1093. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  1094. clif_displaymessage(fd, atcmd_output);
  1095. return 0;
  1096. #undef PARSE_ERROR
  1097. #undef CHECK_EOS
  1098. #undef SKIP_VALUE
  1099. #undef GET_VALUE
  1100. }
  1101. /*==========================================
  1102. * @rura
  1103. *------------------------------------------*/
  1104. int atcommand_rura( const int fd, struct map_session_data* sd, const char* command, const char* message)
  1105. {
  1106. char map_name[MAP_NAME_LENGTH_EXT];
  1107. unsigned short mapindex;
  1108. int x = 0, y = 0;
  1109. int m = -1;
  1110. nullpo_retr(-1, sd);
  1111. memset(map_name, '\0', sizeof(map_name));
  1112. if (!message || !*message ||
  1113. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1114. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1115. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1116. return -1;
  1117. }
  1118. mapindex = mapindex_name2id(map_name);
  1119. if (mapindex)
  1120. m = map_mapindex2mapid(mapindex);
  1121. if (!mapindex || m < 0) {
  1122. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1123. return -1;
  1124. }
  1125. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  1126. { //This is to prevent the pc_setpos call from printing an error.
  1127. clif_displaymessage(fd, msg_txt(2));
  1128. x = y = 0; //Invalid cell, use random spot.
  1129. }
  1130. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1131. clif_displaymessage(fd, msg_txt(247));
  1132. return -1;
  1133. }
  1134. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1135. clif_displaymessage(fd, msg_txt(248));
  1136. return -1;
  1137. }
  1138. if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
  1139. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1140. return -1;
  1141. }
  1142. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1143. return 0;
  1144. }
  1145. /*==========================================
  1146. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1147. *------------------------------------------*/
  1148. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1149. {
  1150. struct map_session_data* pl_sd;
  1151. nullpo_retr(-1, sd);
  1152. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1153. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1154. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1155. return -1;
  1156. }
  1157. pl_sd = map_nick2sd(atcmd_player_name);
  1158. if( pl_sd == NULL
  1159. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  1160. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  1161. ) {
  1162. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1163. return -1;
  1164. }
  1165. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1166. clif_displaymessage(fd, atcmd_output);
  1167. return 0;
  1168. }
  1169. /*==========================================
  1170. *
  1171. *------------------------------------------*/
  1172. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1173. {
  1174. struct map_session_data *pl_sd = NULL;
  1175. nullpo_retr(-1, sd);
  1176. if (!message || !*message) {
  1177. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  1178. return -1;
  1179. }
  1180. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1181. {
  1182. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1183. return -1;
  1184. }
  1185. if (pl_sd == sd)
  1186. {
  1187. clif_displaymessage(fd, "But you are already where you are...");
  1188. return -1;
  1189. }
  1190. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  1191. {
  1192. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  1193. return -1;
  1194. }
  1195. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  1196. {
  1197. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  1198. return -1;
  1199. }
  1200. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1201. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  1202. clif_displaymessage(fd, atcmd_output);
  1203. return 0;
  1204. }
  1205. /*==========================================
  1206. *
  1207. *------------------------------------------*/
  1208. int atcommand_jump(const int fd, struct map_session_data* sd, 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.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1219. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  1220. return -1;
  1221. }
  1222. pc_setpos(sd, sd->mapindex, x, y, 3);
  1223. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  1224. clif_displaymessage(fd, atcmd_output);
  1225. return 0;
  1226. }
  1227. /*==========================================
  1228. * @who3 = Player name, his location
  1229. *------------------------------------------*/
  1230. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1231. {
  1232. char temp0[100];
  1233. struct map_session_data *pl_sd, **pl_allsd;
  1234. int i, j, count, users;
  1235. int pl_GM_level, GM_level;
  1236. char match_text[100];
  1237. char player_name[NAME_LENGTH];
  1238. nullpo_retr(-1, sd);
  1239. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1240. memset(match_text, '\0', sizeof(match_text));
  1241. memset(player_name, '\0', sizeof(player_name));
  1242. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1243. strcpy(match_text, "");
  1244. for (j = 0; match_text[j]; j++)
  1245. match_text[j] = TOLOWER(match_text[j]);
  1246. count = 0;
  1247. GM_level = pc_isGM(sd);
  1248. pl_allsd = map_getallusers(&users);
  1249. for (i = 0; i < users; i++) {
  1250. if ((pl_sd = pl_allsd[i])) {
  1251. pl_GM_level = pc_isGM(pl_sd);
  1252. 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
  1253. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1254. for (j = 0; player_name[j]; j++)
  1255. player_name[j] = TOLOWER(player_name[j]);
  1256. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1257. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1258. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1259. } else {
  1260. atcmd_output[0]=0;
  1261. }
  1262. //Player name
  1263. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1264. strcat(atcmd_output,temp0);
  1265. //Player title, if exists
  1266. if (pl_GM_level > 0) {
  1267. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1268. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1269. strcat(atcmd_output,temp0);
  1270. }
  1271. //Players Location: map x y
  1272. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1273. strcat(atcmd_output,temp0);
  1274. clif_displaymessage(fd, atcmd_output);
  1275. count++;
  1276. }
  1277. }
  1278. }
  1279. }
  1280. if (count == 0)
  1281. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1282. else if (count == 1)
  1283. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1284. else {
  1285. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1286. clif_displaymessage(fd, atcmd_output);
  1287. }
  1288. return 0;
  1289. }
  1290. /*==========================================
  1291. * Player name, BLevel, Job,
  1292. *------------------------------------------*/
  1293. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1294. {
  1295. char temp0[100];
  1296. struct map_session_data *pl_sd, **pl_allsd;
  1297. int i, j, count, users;
  1298. int pl_GM_level, GM_level;
  1299. char match_text[100];
  1300. char player_name[NAME_LENGTH];
  1301. nullpo_retr(-1, sd);
  1302. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1303. memset(match_text, '\0', sizeof(match_text));
  1304. memset(player_name, '\0', sizeof(player_name));
  1305. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1306. strcpy(match_text, "");
  1307. for (j = 0; match_text[j]; j++)
  1308. match_text[j] = TOLOWER(match_text[j]);
  1309. count = 0;
  1310. GM_level = pc_isGM(sd);
  1311. pl_allsd = map_getallusers(&users);
  1312. for (i = 0; i < users; i++) {
  1313. if ((pl_sd = pl_allsd[i])) {
  1314. pl_GM_level = pc_isGM(pl_sd);
  1315. 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
  1316. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1317. for (j = 0; player_name[j]; j++)
  1318. player_name[j] = TOLOWER(player_name[j]);
  1319. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1320. //Players Name
  1321. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1322. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1323. //Player title, if exists
  1324. if (pl_GM_level > 0) {
  1325. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1326. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1327. strcat(atcmd_output,temp0);
  1328. }
  1329. //Players Base Level / Job name
  1330. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1331. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1332. strcat(atcmd_output,temp0);
  1333. clif_displaymessage(fd, atcmd_output);
  1334. count++;
  1335. }
  1336. }
  1337. }
  1338. }
  1339. if (count == 0)
  1340. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1341. else if (count == 1)
  1342. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1343. else {
  1344. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1345. clif_displaymessage(fd, atcmd_output);
  1346. }
  1347. return 0;
  1348. }
  1349. /*==========================================
  1350. * Player name, Playrs Party / Guild name
  1351. *------------------------------------------*/
  1352. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1353. {
  1354. char temp0[100];
  1355. struct map_session_data *pl_sd, **pl_allsd;
  1356. int i, j, count, users;
  1357. int pl_GM_level, GM_level;
  1358. char match_text[100];
  1359. char player_name[NAME_LENGTH];
  1360. struct guild *g;
  1361. struct party_data *p;
  1362. nullpo_retr(-1, sd);
  1363. memset(temp0, '\0', sizeof(temp0));
  1364. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1365. memset(match_text, '\0', sizeof(match_text));
  1366. memset(player_name, '\0', sizeof(player_name));
  1367. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1368. strcpy(match_text, "");
  1369. for (j = 0; match_text[j]; j++)
  1370. match_text[j] = TOLOWER(match_text[j]);
  1371. count = 0;
  1372. GM_level = pc_isGM(sd);
  1373. pl_allsd = map_getallusers(&users);
  1374. for (i = 0; i < users; i++) {
  1375. if ((pl_sd = pl_allsd[i])) {
  1376. pl_GM_level = pc_isGM(pl_sd);
  1377. 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
  1378. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1379. for (j = 0; player_name[j]; j++)
  1380. player_name[j] = TOLOWER(player_name[j]);
  1381. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1382. g = guild_search(pl_sd->status.guild_id);
  1383. p = party_search(pl_sd->status.party_id);
  1384. //Players Name
  1385. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1386. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1387. //Player title, if exists
  1388. if (pl_GM_level > 0) {
  1389. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1390. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1391. strcat(atcmd_output,temp0);
  1392. }
  1393. //Players Party if exists
  1394. if (p != NULL) {
  1395. //sprintf(temp0," | Party: '%s'", p->name);
  1396. sprintf(temp0, msg_txt(335), p->party.name);
  1397. strcat(atcmd_output,temp0);
  1398. }
  1399. //Players Guild if exists
  1400. if (g != NULL) {
  1401. //sprintf(temp0," | Guild: '%s'", g->name);
  1402. sprintf(temp0, msg_txt(336), g->name);
  1403. strcat(atcmd_output,temp0);
  1404. }
  1405. clif_displaymessage(fd, atcmd_output);
  1406. count++;
  1407. }
  1408. }
  1409. }
  1410. }
  1411. if (count == 0)
  1412. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1413. else if (count == 1)
  1414. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1415. else {
  1416. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1417. clif_displaymessage(fd, atcmd_output);
  1418. }
  1419. return 0;
  1420. }
  1421. /*==========================================
  1422. *
  1423. *------------------------------------------*/
  1424. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1425. {
  1426. struct map_session_data *pl_sd, **pl_allsd;
  1427. int i, count, users;
  1428. int pl_GM_level, GM_level;
  1429. int map_id;
  1430. char map_name[MAP_NAME_LENGTH_EXT];
  1431. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1432. memset(map_name, '\0', sizeof(map_name));
  1433. if (!message || !*message)
  1434. map_id = sd->bl.m;
  1435. else {
  1436. sscanf(message, "%15s", map_name);
  1437. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1438. map_id = sd->bl.m;
  1439. }
  1440. count = 0;
  1441. GM_level = pc_isGM(sd);
  1442. pl_allsd = map_getallusers(&users);
  1443. for (i = 0; i < users; i++) {
  1444. if ((pl_sd = pl_allsd[i])) {
  1445. pl_GM_level = pc_isGM(pl_sd);
  1446. 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
  1447. if (pl_sd->bl.m == map_id) {
  1448. if (pl_GM_level > 0)
  1449. 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);
  1450. else
  1451. 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);
  1452. clif_displaymessage(fd, atcmd_output);
  1453. count++;
  1454. }
  1455. }
  1456. }
  1457. }
  1458. if (count == 0)
  1459. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1460. else if (count == 1)
  1461. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1462. else {
  1463. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1464. }
  1465. clif_displaymessage(fd, atcmd_output);
  1466. return 0;
  1467. }
  1468. /*==========================================
  1469. *
  1470. *------------------------------------------*/
  1471. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1472. {
  1473. struct map_session_data *pl_sd, **pl_allsd;
  1474. int i, count, users;
  1475. int pl_GM_level, GM_level;
  1476. int map_id = 0;
  1477. char map_name[MAP_NAME_LENGTH_EXT];
  1478. nullpo_retr(-1, sd);
  1479. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1480. memset(map_name, '\0', sizeof(map_name));
  1481. if (!message || !*message)
  1482. map_id = sd->bl.m;
  1483. else {
  1484. sscanf(message, "%15s", map_name);
  1485. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1486. map_id = sd->bl.m;
  1487. }
  1488. count = 0;
  1489. GM_level = pc_isGM(sd);
  1490. pl_allsd = map_getallusers(&users);
  1491. for (i = 0; i < users; i++) {
  1492. if ((pl_sd = pl_allsd[i])) {
  1493. pl_GM_level = pc_isGM(pl_sd);
  1494. 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
  1495. if (pl_sd->bl.m == map_id) {
  1496. if (pl_GM_level > 0)
  1497. 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);
  1498. else
  1499. 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);
  1500. clif_displaymessage(fd, atcmd_output);
  1501. count++;
  1502. }
  1503. }
  1504. }
  1505. }
  1506. if (count == 0)
  1507. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1508. else if (count == 1)
  1509. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1510. else {
  1511. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1512. }
  1513. clif_displaymessage(fd, atcmd_output);
  1514. return 0;
  1515. }
  1516. /*==========================================
  1517. *
  1518. *------------------------------------------*/
  1519. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1520. {
  1521. char temp0[100];
  1522. char temp1[100];
  1523. struct map_session_data *pl_sd, **pl_allsd;
  1524. int i, count, users;
  1525. int pl_GM_level, GM_level;
  1526. int map_id = 0;
  1527. char map_name[MAP_NAME_LENGTH_EXT];
  1528. struct guild *g;
  1529. struct party_data *p;
  1530. nullpo_retr(-1, sd);
  1531. memset(temp0, '\0', sizeof(temp0));
  1532. memset(temp1, '\0', sizeof(temp1));
  1533. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1534. memset(map_name, '\0', sizeof(map_name));
  1535. if (!message || !*message)
  1536. map_id = sd->bl.m;
  1537. else {
  1538. sscanf(message, "%15s", map_name);
  1539. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1540. map_id = sd->bl.m;
  1541. }
  1542. count = 0;
  1543. GM_level = pc_isGM(sd);
  1544. pl_allsd = map_getallusers(&users);
  1545. for (i = 0; i < users; i++) {
  1546. if ((pl_sd = pl_allsd[i])) {
  1547. pl_GM_level = pc_isGM(pl_sd);
  1548. 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
  1549. if (pl_sd->bl.m == map_id) {
  1550. g = guild_search(pl_sd->status.guild_id);
  1551. if (g == NULL)
  1552. sprintf(temp1, "None");
  1553. else
  1554. sprintf(temp1, "%s", g->name);
  1555. p = party_search(pl_sd->status.party_id);
  1556. if (p == NULL)
  1557. sprintf(temp0, "None");
  1558. else
  1559. sprintf(temp0, "%s", p->party.name);
  1560. if (pl_GM_level > 0)
  1561. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1562. else
  1563. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1564. clif_displaymessage(fd, atcmd_output);
  1565. count++;
  1566. }
  1567. }
  1568. }
  1569. }
  1570. if (count == 0)
  1571. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1572. else if (count == 1)
  1573. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1574. else {
  1575. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1576. }
  1577. clif_displaymessage(fd, atcmd_output);
  1578. return 0;
  1579. }
  1580. /*==========================================
  1581. *
  1582. *------------------------------------------*/
  1583. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1584. {
  1585. struct map_session_data *pl_sd, **pl_allsd;
  1586. int i, j, count, users;
  1587. int pl_GM_level, GM_level;
  1588. char match_text[200];
  1589. char player_name[NAME_LENGTH];
  1590. struct guild *g;
  1591. struct party_data *p;
  1592. nullpo_retr(-1, sd);
  1593. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1594. memset(match_text, '\0', sizeof(match_text));
  1595. memset(player_name, '\0', sizeof(player_name));
  1596. if (sscanf(message, "%199[^\n]", match_text) < 1)
  1597. strcpy(match_text, "");
  1598. for (j = 0; match_text[j]; j++)
  1599. match_text[j] = TOLOWER(match_text[j]);
  1600. count = 0;
  1601. GM_level = pc_isGM(sd);
  1602. pl_allsd = map_getallusers(&users);
  1603. for (i = 0; i < users; i++) {
  1604. pl_sd = pl_allsd[i];
  1605. pl_GM_level = pc_isGM(pl_sd);
  1606. if (!pl_GM_level)
  1607. continue;
  1608. if (match_text[0])
  1609. {
  1610. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1611. for (j = 0; player_name[j]; j++)
  1612. player_name[j] = TOLOWER(player_name[j]);
  1613. // search with no case sensitive
  1614. if (strstr(player_name, match_text) == NULL)
  1615. continue;
  1616. }
  1617. if (pl_GM_level > GM_level) {
  1618. if (pl_sd->sc.option & OPTION_INVISIBLE)
  1619. continue;
  1620. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  1621. clif_displaymessage(fd, atcmd_output);
  1622. count++;
  1623. continue;
  1624. }
  1625. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  1626. pl_sd->status.name, pl_GM_level,
  1627. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1628. clif_displaymessage(fd, atcmd_output);
  1629. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  1630. pl_sd->status.base_level,
  1631. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1632. clif_displaymessage(fd, atcmd_output);
  1633. p = party_search(pl_sd->status.party_id);
  1634. g = guild_search(pl_sd->status.guild_id);
  1635. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  1636. p?p->party.name:"None", g?g->name:"None");
  1637. clif_displaymessage(fd, atcmd_output);
  1638. count++;
  1639. }
  1640. if (count == 0)
  1641. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1642. else if (count == 1)
  1643. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1644. else {
  1645. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1646. clif_displaymessage(fd, atcmd_output);
  1647. }
  1648. return 0;
  1649. }
  1650. int atcommand_whozeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1651. {
  1652. struct map_session_data *pl_sd, **pl_allsd;
  1653. int i, j, count,c, users;
  1654. char match_text[100];
  1655. char player_name[NAME_LENGTH];
  1656. int *zeny;
  1657. int *counted;
  1658. nullpo_retr(-1, sd);
  1659. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1660. memset(match_text, '\0', sizeof(match_text));
  1661. memset(player_name, '\0', sizeof(player_name));
  1662. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1663. strcpy(match_text, "");
  1664. for (j = 0; match_text[j]; j++)
  1665. match_text[j] = TOLOWER(match_text[j]);
  1666. count = 0;
  1667. pl_allsd = map_getallusers(&users);
  1668. if (users < 1)
  1669. {
  1670. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1671. return 0;
  1672. }
  1673. zeny = (int *)aMallocA(users*sizeof(int));
  1674. counted = (int *)aMallocA(users*sizeof(int));
  1675. for (i = 0; i < users; i++) {
  1676. if ((pl_sd = pl_allsd[i])) {
  1677. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1678. for (j = 0; player_name[j]; j++)
  1679. player_name[j] = TOLOWER(player_name[j]);
  1680. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1681. zeny[count]=pl_sd->status.zeny;
  1682. counted[i]=0;
  1683. count++;
  1684. }
  1685. }
  1686. }
  1687. qsort(zeny, count, sizeof(int), hightolow_compare);
  1688. for (c = 0; c < count && c < 50; c++) {
  1689. if(!zeny[c])
  1690. continue;
  1691. for (i = 0; i < users; i++) {
  1692. if(!zeny[c])
  1693. continue;
  1694. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1695. if(pl_sd->status.zeny==zeny[c]) {
  1696. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1697. clif_displaymessage(fd, atcmd_output);
  1698. zeny[c]=0;
  1699. counted[i]=1;
  1700. }
  1701. }
  1702. }
  1703. }
  1704. if (count == 0)
  1705. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1706. else if (count == 1)
  1707. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1708. else {
  1709. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1710. clif_displaymessage(fd, atcmd_output);
  1711. }
  1712. aFree(zeny);
  1713. aFree(counted);
  1714. return 0;
  1715. }
  1716. /*==========================================
  1717. *
  1718. *------------------------------------------*/
  1719. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1720. {
  1721. nullpo_retr(-1, sd);
  1722. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1723. if (sd->status.pet_id > 0 && sd->pd)
  1724. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1725. chrif_save(sd,0);
  1726. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  1727. return 0;
  1728. }
  1729. /*==========================================
  1730. *
  1731. *------------------------------------------*/
  1732. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1733. {
  1734. int m;
  1735. nullpo_retr(-1, sd);
  1736. m = map_mapindex2mapid(sd->status.save_point.map);
  1737. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1738. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  1739. return -1;
  1740. }
  1741. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1742. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  1743. return -1;
  1744. }
  1745. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1746. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1747. return 0;
  1748. }
  1749. /*==========================================
  1750. *
  1751. *------------------------------------------*/
  1752. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1753. {
  1754. int speed;
  1755. nullpo_retr(-1, sd);
  1756. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1757. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  1758. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1759. clif_displaymessage(fd, atcmd_output);
  1760. return -1;
  1761. }
  1762. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  1763. status_calc_bl(&sd->bl, SCB_SPEED);
  1764. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1765. return 0;
  1766. }
  1767. /*==========================================
  1768. *
  1769. *------------------------------------------*/
  1770. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1771. {
  1772. nullpo_retr(-1, sd);
  1773. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1774. return -1;
  1775. if (storage_storageopen(sd) == 1)
  1776. { //Already open.
  1777. clif_displaymessage(fd, msg_txt(250));
  1778. return -1;
  1779. }
  1780. clif_displaymessage(fd, "Storage opened.");
  1781. return 0;
  1782. }
  1783. /*==========================================
  1784. *
  1785. *------------------------------------------*/
  1786. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1787. {
  1788. struct storage *stor; //changes from Freya/Yor
  1789. nullpo_retr(-1, sd);
  1790. if (!sd->status.guild_id) {
  1791. clif_displaymessage(fd, msg_txt(252));
  1792. return -1;
  1793. }
  1794. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1795. return -1;
  1796. if (sd->state.storage_flag) {
  1797. clif_displaymessage(fd, msg_txt(251));
  1798. return -1;
  1799. }
  1800. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1801. clif_displaymessage(fd, msg_txt(251));
  1802. return -1;
  1803. }
  1804. storage_guild_storageopen(sd);
  1805. clif_displaymessage(fd, "Guild storage opened.");
  1806. return 0;
  1807. }
  1808. /*==========================================
  1809. *
  1810. *------------------------------------------*/
  1811. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1812. {
  1813. int param1 = 0, param2 = 0, param3 = 0;
  1814. nullpo_retr(-1, sd);
  1815. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1816. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1817. return -1;
  1818. }
  1819. sd->sc.opt1 = param1;
  1820. sd->sc.opt2 = param2;
  1821. pc_setoption(sd, param3);
  1822. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1823. return 0;
  1824. }
  1825. /*==========================================
  1826. *
  1827. *------------------------------------------*/
  1828. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1829. {
  1830. nullpo_retr(-1, sd);
  1831. if (sd->sc.option & OPTION_INVISIBLE) {
  1832. sd->sc.option &= ~OPTION_INVISIBLE;
  1833. if (sd->disguise)
  1834. status_set_viewdata(&sd->bl, sd->disguise);
  1835. else
  1836. status_set_viewdata(&sd->bl, sd->status.class_);
  1837. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1838. } else {
  1839. sd->sc.option |= OPTION_INVISIBLE;
  1840. sd->vd.class_ = INVISIBLE_CLASS;
  1841. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1842. }
  1843. clif_changeoption(&sd->bl);
  1844. return 0;
  1845. }
  1846. /*==========================================
  1847. * Changes a character's class
  1848. *------------------------------------------*/
  1849. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1850. {
  1851. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1852. int job = 0, upper = 0;
  1853. nullpo_retr(-1, sd);
  1854. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1855. {
  1856. int i, found = 0;
  1857. const struct { char name[16]; int id; } jobs[] = {
  1858. { "novice", 0 },
  1859. { "swordsman", 1 },
  1860. { "mage", 2 },
  1861. { "archer", 3 },
  1862. { "acolyte", 4 },
  1863. { "merchant", 5 },
  1864. { "thief", 6 },
  1865. { "knight", 7 },
  1866. { "priest", 8 },
  1867. { "priestess", 8 },
  1868. { "wizard", 9 },
  1869. { "blacksmith", 10 },
  1870. { "hunter", 11 },
  1871. { "assassin", 12 },
  1872. { "crusader", 14 },
  1873. { "monk", 15 },
  1874. { "sage", 16 },
  1875. { "rogue", 17 },
  1876. { "alchemist", 18 },
  1877. { "bard", 19 },
  1878. { "dancer", 20 },
  1879. { "super novice", 23 },
  1880. { "supernovice", 23 },
  1881. { "gunslinger", 24 },
  1882. { "gunner", 24 },
  1883. { "ninja", 25 },
  1884. { "high novice", 4001 },
  1885. { "swordsman high", 4002 },
  1886. { "mage high", 4003 },
  1887. { "archer high", 4004 },
  1888. { "acolyte high", 4005 },
  1889. { "merchant high", 4006 },
  1890. { "thief high", 4007 },
  1891. { "lord knight", 4008 },
  1892. { "high priest", 4009 },
  1893. { "high priestess", 4009 },
  1894. { "high wizard", 4010 },
  1895. { "whitesmith", 4011 },
  1896. { "sniper", 4012 },
  1897. { "assassin cross", 4013 },
  1898. { "paladin", 4015 },
  1899. { "champion", 4016 },
  1900. { "professor", 4017 },
  1901. { "stalker", 4018 },
  1902. { "creator", 4019 },
  1903. { "clown", 4020 },
  1904. { "gypsy", 4021 },
  1905. { "baby novice", 4023 },
  1906. { "baby swordsman", 4024 },
  1907. { "baby mage", 4025 },
  1908. { "baby archer", 4026 },
  1909. { "baby acolyte", 4027 },
  1910. { "baby merchant", 4028 },
  1911. { "baby thief", 4029 },
  1912. { "baby knight", 4030 },
  1913. { "baby priest", 4031 },
  1914. { "baby priestess", 4031 },
  1915. { "baby wizard", 4032 },
  1916. { "baby blacksmith",4033 },
  1917. { "baby hunter", 4034 },
  1918. { "baby assassin", 4035 },
  1919. { "baby crusader", 4037 },
  1920. { "baby monk", 4038 },
  1921. { "baby sage", 4039 },
  1922. { "baby rogue", 4040 },
  1923. { "baby alchemist", 4041 },
  1924. { "baby bard", 4042 },
  1925. { "baby dancer", 4043 },
  1926. { "super baby", 4045 },
  1927. { "taekwon", 4046 },
  1928. { "taekwon boy", 4046 },
  1929. { "taekwon girl", 4046 },
  1930. { "star gladiator", 4047 },
  1931. { "soul linker", 4049 },
  1932. };
  1933. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  1934. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1935. job = jobs[i].id;
  1936. upper = 0;
  1937. found = 1;
  1938. break;
  1939. }
  1940. }
  1941. if (!found) {
  1942. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1943. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1944. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1945. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1946. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1947. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1948. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1949. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1950. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1951. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1952. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1953. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1954. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1955. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1956. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1957. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1958. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1959. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1960. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1961. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1962. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1963. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1964. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1965. return -1;
  1966. }
  1967. }
  1968. if (job == 37 ||job == 45)
  1969. return 0;
  1970. if ((job >= 0 && job < MAX_PC_CLASS))
  1971. {
  1972. int j;
  1973. for (j=0; j < MAX_INVENTORY; j++) {
  1974. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  1975. pc_unequipitem(sd, j, 3);
  1976. }
  1977. if (pc_jobchange(sd, job, upper) == 0)
  1978. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1979. else {
  1980. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  1981. return -1;
  1982. }
  1983. } else {
  1984. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1985. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1986. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1987. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1988. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1989. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1990. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1991. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1992. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1993. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1994. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1995. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1996. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1997. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1998. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1999. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  2000. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  2001. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  2002. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  2003. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  2004. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  2005. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  2006. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  2007. return -1;
  2008. }
  2009. return 0;
  2010. }
  2011. /*==========================================
  2012. *
  2013. *------------------------------------------*/
  2014. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2015. {
  2016. nullpo_retr(-1, sd);
  2017. clif_specialeffect(&sd->bl,450,SELF);
  2018. status_kill(&sd->bl);
  2019. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  2020. return 0;
  2021. }
  2022. /*==========================================
  2023. *
  2024. *------------------------------------------*/
  2025. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2026. {
  2027. struct map_session_data *pl_sd;
  2028. nullpo_retr(-1, sd);
  2029. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2030. if (!message || !*message) {
  2031. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  2032. return -1;
  2033. }
  2034. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2035. {
  2036. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2037. return -1;
  2038. }
  2039. if (pc_isGM(sd) < pc_isGM(pl_sd))
  2040. { // you can kill only lower or same level
  2041. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2042. return -1;
  2043. }
  2044. status_kill(&pl_sd->bl);
  2045. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  2046. if (fd != pl_sd->fd)
  2047. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  2048. return 0;
  2049. }
  2050. /*==========================================
  2051. *
  2052. *------------------------------------------*/
  2053. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2054. {
  2055. nullpo_retr(-1, sd);
  2056. if (!status_revive(&sd->bl, 100, 100))
  2057. {
  2058. clif_displaymessage(fd, "You're not dead.");
  2059. return -1;
  2060. }
  2061. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2062. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  2063. return 0;
  2064. }
  2065. /*==========================================
  2066. * +kamic [LuzZza]
  2067. *------------------------------------------*/
  2068. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2069. {
  2070. unsigned long color=0;
  2071. nullpo_retr(-1, sd);
  2072. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2073. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2074. if (!message || !*message) {
  2075. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2076. return -1;
  2077. }
  2078. sscanf(message, "%199[^\n]", atcmd_output);
  2079. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2080. } else {
  2081. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2082. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2083. return -1;
  2084. }
  2085. if(color > 0xFFFFFF) {
  2086. clif_displaymessage(fd, "Invalid color.");
  2087. return -1;
  2088. }
  2089. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2090. }
  2091. return 0;
  2092. }
  2093. /*==========================================
  2094. *
  2095. *------------------------------------------*/
  2096. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2097. {
  2098. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2099. nullpo_retr(-1, sd);
  2100. sscanf(message, "%d %d", &hp, &sp);
  2101. if (hp == 0 && sp == 0) {
  2102. if (!status_percent_heal(&sd->bl, 100, 100))
  2103. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2104. else
  2105. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2106. return 0;
  2107. }
  2108. if(hp > 0 && sp >= 0) {
  2109. if(!status_heal(&sd->bl, hp, sp, 0))
  2110. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2111. else
  2112. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2113. return 0;
  2114. }
  2115. if(hp < 0 && sp <= 0) {
  2116. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2117. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2118. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2119. return 0;
  2120. }
  2121. //Opposing signs.
  2122. if (hp) {
  2123. if (hp > 0)
  2124. status_heal(&sd->bl, hp, 0, 0);
  2125. else {
  2126. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2127. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2128. }
  2129. }
  2130. if (sp) {
  2131. if (sp > 0)
  2132. status_heal(&sd->bl, 0, sp, 0);
  2133. else
  2134. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2135. }
  2136. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2137. return 0;
  2138. }
  2139. /*==========================================
  2140. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2141. *------------------------------------------*/
  2142. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2143. {
  2144. char item_name[100];
  2145. int number = 0, item_id, flag;
  2146. struct item item_tmp;
  2147. struct item_data *item_data;
  2148. int get_count, i;
  2149. nullpo_retr(-1, sd);
  2150. memset(item_name, '\0', sizeof(item_name));
  2151. if (!message || !*message || (
  2152. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  2153. sscanf(message, "%99s %d", item_name, &number) < 1
  2154. )) {
  2155. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2156. return -1;
  2157. }
  2158. if (number <= 0)
  2159. number = 1;
  2160. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2161. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2162. {
  2163. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2164. return -1;
  2165. }
  2166. item_id = item_data->nameid;
  2167. get_count = number;
  2168. //Check if it's stackable.
  2169. if (!itemdb_isstackable2(item_data))
  2170. get_count = 1;
  2171. for (i = 0; i < number; i += get_count) {
  2172. // if not pet egg
  2173. if (!pet_create_egg(sd, item_id)) {
  2174. memset(&item_tmp, 0, sizeof(item_tmp));
  2175. item_tmp.nameid = item_id;
  2176. item_tmp.identify = 1;
  2177. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2178. clif_additem(sd, 0, 0, flag);
  2179. }
  2180. }
  2181. //Logs (A)dmins items [Lupus]
  2182. if(log_config.enable_logs&0x400)
  2183. log_pick_pc(sd, "A", item_id, number, NULL);
  2184. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2185. return 0;
  2186. }
  2187. /*==========================================
  2188. *
  2189. *------------------------------------------*/
  2190. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2191. {
  2192. struct item item_tmp;
  2193. struct item_data *item_data;
  2194. char item_name[100];
  2195. int item_id, number = 0;
  2196. int identify = 0, refine = 0, attr = 0;
  2197. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2198. int flag;
  2199. int loop, get_count, i;
  2200. nullpo_retr(-1, sd);
  2201. memset(item_name, '\0', sizeof(item_name));
  2202. if (!message || !*message || (
  2203. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  2204. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  2205. )) {
  2206. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2207. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2208. return -1;
  2209. }
  2210. if (number <= 0)
  2211. number = 1;
  2212. item_id = 0;
  2213. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2214. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2215. item_id = item_data->nameid;
  2216. if (item_id > 500) {
  2217. loop = 1;
  2218. get_count = number;
  2219. if (item_data->type == 4 || item_data->type == 5 ||
  2220. item_data->type == 7 || item_data->type == 8) {
  2221. loop = number;
  2222. get_count = 1;
  2223. if (item_data->type == 7) {
  2224. identify = 1;
  2225. refine = 0;
  2226. }
  2227. if (item_data->type == 8)
  2228. refine = 0;
  2229. if (refine > 10)
  2230. refine = 10;
  2231. } else {
  2232. identify = 1;
  2233. refine = attr = 0;
  2234. }
  2235. for (i = 0; i < loop; i++) {
  2236. memset(&item_tmp, 0, sizeof(item_tmp));
  2237. item_tmp.nameid = item_id;
  2238. item_tmp.identify = identify;
  2239. item_tmp.refine = refine;
  2240. item_tmp.attribute = attr;
  2241. item_tmp.card[0] = c1;
  2242. item_tmp.card[1] = c2;
  2243. item_tmp.card[2] = c3;
  2244. item_tmp.card[3] = c4;
  2245. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2246. clif_additem(sd, 0, 0, flag);
  2247. }
  2248. //Logs (A)dmins items [Lupus]
  2249. if(log_config.enable_logs&0x400)
  2250. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  2251. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2252. } else {
  2253. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2254. return -1;
  2255. }
  2256. return 0;
  2257. }
  2258. /*==========================================
  2259. *
  2260. *------------------------------------------*/
  2261. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2262. {
  2263. int i;
  2264. nullpo_retr(-1, sd);
  2265. for (i = 0; i < MAX_INVENTORY; i++) {
  2266. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2267. //Logs (A)dmins items [Lupus]
  2268. if(log_config.enable_logs&0x400)
  2269. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2270. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2271. }
  2272. }
  2273. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  2274. return 0;
  2275. }
  2276. /*==========================================
  2277. * Atcommand @lvlup
  2278. *------------------------------------------*/
  2279. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2280. {
  2281. int level=0, i=0, status_point=0;
  2282. nullpo_retr(-1, sd);
  2283. level = atoi(message);
  2284. if (!message || !*message || !level) {
  2285. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2286. return -1;
  2287. }
  2288. if (level > 0) {
  2289. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  2290. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  2291. return -1;
  2292. } // End Addition
  2293. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2294. level = pc_maxbaselv(sd) - sd->status.base_level;
  2295. for (i = 1; i <= level; i++)
  2296. status_point += (sd->status.base_level + i + 14) / 5;
  2297. if (sd->status.status_point > USHRT_MAX - status_point)
  2298. sd->status.status_point = USHRT_MAX;
  2299. else
  2300. sd->status.status_point += status_point;
  2301. sd->status.base_level += (unsigned int)level;
  2302. status_percent_heal(&sd->bl, 100, 100);
  2303. clif_misceffect(&sd->bl, 0);
  2304. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  2305. } else {
  2306. if (sd->status.base_level == 1) {
  2307. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  2308. return -1;
  2309. }
  2310. level*=-1;
  2311. if ((unsigned int)level >= sd->status.base_level)
  2312. level = sd->status.base_level-1;
  2313. for (i = 0; i > -level; i--)
  2314. status_point += (sd->status.base_level + i + 14) / 5;
  2315. if (sd->status.status_point < status_point)
  2316. pc_resetstate(sd);
  2317. if (sd->status.status_point < status_point)
  2318. sd->status.status_point = 0;
  2319. else
  2320. sd->status.status_point -= status_point;
  2321. sd->status.base_level -= (unsigned int)level;
  2322. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  2323. }
  2324. clif_updatestatus(sd, SP_STATUSPOINT);
  2325. clif_updatestatus(sd, SP_BASELEVEL);
  2326. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2327. status_calc_pc(sd, 0);
  2328. if(sd->status.party_id)
  2329. party_send_levelup(sd);
  2330. return 0;
  2331. }
  2332. /*==========================================
  2333. *
  2334. *------------------------------------------*/
  2335. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2336. {
  2337. int level=0;
  2338. nullpo_retr(-1, sd);
  2339. level = atoi(message);
  2340. if (!message || !*message || !level) {
  2341. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2342. return -1;
  2343. }
  2344. if (level > 0) {
  2345. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2346. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  2347. return -1;
  2348. }
  2349. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2350. level = pc_maxjoblv(sd) - sd->status.job_level;
  2351. sd->status.job_level += (unsigned int)level;
  2352. clif_updatestatus(sd, SP_JOBLEVEL);
  2353. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2354. if (sd->status.skill_point > USHRT_MAX - level)
  2355. sd->status.skill_point = USHRT_MAX;
  2356. else
  2357. sd->status.skill_point += level;
  2358. clif_updatestatus(sd, SP_SKILLPOINT);
  2359. status_calc_pc(sd, 0);
  2360. clif_misceffect(&sd->bl, 1);
  2361. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  2362. } else {
  2363. if (sd->status.job_level == 1) {
  2364. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  2365. return -1;
  2366. }
  2367. level *=-1;
  2368. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2369. level = sd->status.job_level-1;
  2370. sd->status.job_level -= (unsigned int)level;
  2371. clif_updatestatus(sd, SP_JOBLEVEL);
  2372. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2373. if (sd->status.skill_point < level)
  2374. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2375. if (sd->status.skill_point < level)
  2376. sd->status.skill_point = 0;
  2377. else
  2378. sd->status.skill_point -= level;
  2379. clif_updatestatus(sd, SP_SKILLPOINT);
  2380. status_calc_pc(sd, 0);
  2381. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  2382. }
  2383. return 0;
  2384. }
  2385. /*==========================================
  2386. * @help
  2387. *------------------------------------------*/
  2388. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2389. {
  2390. char buf[2048], w1[2048], w2[2048];
  2391. int i, gm_level;
  2392. FILE* fp;
  2393. nullpo_retr(-1, sd);
  2394. memset(buf, '\0', sizeof(buf));
  2395. if ((fp = fopen(help_txt, "r")) != NULL) {
  2396. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  2397. gm_level = pc_isGM(sd);
  2398. while(fgets(buf, sizeof(buf), fp) != NULL) {
  2399. if (buf[0] == '/' && buf[1] == '/')
  2400. continue;
  2401. for (i = 0; buf[i] != '\0'; i++) {
  2402. if (buf[i] == '\r' || buf[i] == '\n') {
  2403. buf[i] = '\0';
  2404. break;
  2405. }
  2406. }
  2407. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2408. clif_displaymessage(fd, buf);
  2409. else if (gm_level >= atoi(w1))
  2410. clif_displaymessage(fd, w2);
  2411. }
  2412. fclose(fp);
  2413. } else {
  2414. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  2415. return -1;
  2416. }
  2417. return 0;
  2418. }
  2419. /*==========================================
  2420. * @help2 - Char commands [Kayla]
  2421. *------------------------------------------*/
  2422. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2423. {
  2424. char buf[2048], w1[2048], w2[2048];
  2425. int i, gm_level;
  2426. FILE* fp;
  2427. nullpo_retr(-1, sd);
  2428. memset(buf, '\0', sizeof(buf));
  2429. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2430. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  2431. gm_level = pc_isGM(sd);
  2432. while(fgets(buf, sizeof(buf), fp) != NULL) {
  2433. if (buf[0] == '/' && buf[1] == '/')
  2434. continue;
  2435. for (i = 0; buf[i] != '\0'; i++) {
  2436. if (buf[i] == '\r' || buf[i] == '\n') {
  2437. buf[i] = '\0';
  2438. break;
  2439. }
  2440. }
  2441. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2442. clif_displaymessage(fd, buf);
  2443. else if (gm_level >= atoi(w1))
  2444. clif_displaymessage(fd, w2);
  2445. }
  2446. fclose(fp);
  2447. } else {
  2448. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  2449. return -1;
  2450. }
  2451. return 0;
  2452. }
  2453. /*==========================================
  2454. * @gm
  2455. *------------------------------------------*/
  2456. int atcommand_gm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2457. {
  2458. char password[100];
  2459. nullpo_retr(-1, sd);
  2460. memset(password, '\0', sizeof(password));
  2461. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2462. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2463. return -1;
  2464. }
  2465. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  2466. clif_displaymessage(fd, msg_txt(50)); // You already have some GM powers.
  2467. return -1;
  2468. } else
  2469. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2470. return 0;
  2471. }
  2472. // helper function, used in foreach calls to stop auto-attack timers
  2473. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  2474. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  2475. {
  2476. struct unit_data *ud = unit_bl2ud(bl);
  2477. int id = va_arg(ap, int);
  2478. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  2479. {
  2480. unit_stop_attack(bl);
  2481. return 1;
  2482. }
  2483. return 0;
  2484. }
  2485. /*==========================================
  2486. *
  2487. *------------------------------------------*/
  2488. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) {
  2489. TBL_PC* sd = (TBL_PC*)bl;
  2490. clif_pvpset(sd, 0, 0, 2);
  2491. if (sd->pvp_timer != UINT_MAX) {
  2492. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  2493. sd->pvp_timer = UINT_MAX;
  2494. }
  2495. return 0;
  2496. }
  2497. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2498. {
  2499. nullpo_retr(-1, sd);
  2500. //if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2501. // clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2502. // return -1;
  2503. //}
  2504. if (!map[sd->bl.m].flag.pvp) {
  2505. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2506. return -1;
  2507. }
  2508. map[sd->bl.m].flag.pvp = 0;
  2509. if (!battle_config.pk_mode)
  2510. clif_send0199(sd->bl.m, 0);
  2511. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  2512. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  2513. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2514. return 0;
  2515. }
  2516. /*==========================================
  2517. *
  2518. *------------------------------------------*/
  2519. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2520. {
  2521. struct map_session_data *pl_sd, **pl_allsd;
  2522. int i, users;
  2523. nullpo_retr(-1, sd);
  2524. //if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2525. // clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2526. // return -1;
  2527. //}
  2528. if (!map[sd->bl.m].flag.pvp) {
  2529. map[sd->bl.m].flag.pvp = 1;
  2530. if (!battle_config.pk_mode)
  2531. {
  2532. clif_send0199(sd->bl.m, 1);
  2533. pl_allsd = map_getallusers(&users);
  2534. for (i = 0; i < users; i++) {
  2535. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2536. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2537. pl_sd->pvp_rank = 0;
  2538. pl_sd->pvp_lastusers = 0;
  2539. pl_sd->pvp_point = 5;
  2540. pl_sd->pvp_won = 0;
  2541. pl_sd->pvp_lost = 0;
  2542. }
  2543. }
  2544. }
  2545. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2546. } else {
  2547. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2548. return -1;
  2549. }
  2550. return 0;
  2551. }
  2552. /*==========================================
  2553. *
  2554. *------------------------------------------*/
  2555. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2556. {
  2557. nullpo_retr(-1, sd);
  2558. if (map[sd->bl.m].flag.gvg) {
  2559. map[sd->bl.m].flag.gvg = 0;
  2560. clif_send0199(sd->bl.m, 0);
  2561. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  2562. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2563. } else {
  2564. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2565. return -1;
  2566. }
  2567. return 0;
  2568. }
  2569. /*==========================================
  2570. *
  2571. *------------------------------------------*/
  2572. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2573. {
  2574. nullpo_retr(-1, sd);
  2575. if (!map[sd->bl.m].flag.gvg) {
  2576. map[sd->bl.m].flag.gvg = 1;
  2577. clif_send0199(sd->bl.m, 3);
  2578. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2579. } else {
  2580. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2581. return -1;
  2582. }
  2583. return 0;
  2584. }
  2585. /*==========================================
  2586. *
  2587. *------------------------------------------*/
  2588. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2589. {
  2590. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2591. nullpo_retr(-1, sd);
  2592. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2593. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2594. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2595. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2596. clif_displaymessage(fd, atcmd_output);
  2597. return -1;
  2598. }
  2599. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2600. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2601. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2602. pc_changelook(sd, LOOK_HAIR, hair_style);
  2603. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2604. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2605. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2606. } else {
  2607. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2608. return -1;
  2609. }
  2610. return 0;
  2611. }
  2612. /*==========================================
  2613. * @dye && @ccolor
  2614. *------------------------------------------*/
  2615. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2616. {
  2617. int cloth_color = 0;
  2618. nullpo_retr(-1, sd);
  2619. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2620. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2621. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2622. clif_displaymessage(fd, atcmd_output);
  2623. return -1;
  2624. }
  2625. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2626. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2627. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2628. } else {
  2629. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2630. return -1;
  2631. }
  2632. return 0;
  2633. }
  2634. /*==========================================
  2635. * @hairstyle && @hstyle
  2636. *------------------------------------------*/
  2637. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2638. {
  2639. int hair_style = 0;
  2640. nullpo_retr(-1, sd);
  2641. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2642. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2643. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2644. clif_displaymessage(fd, atcmd_output);
  2645. return -1;
  2646. }
  2647. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2648. pc_changelook(sd, LOOK_HAIR, hair_style);
  2649. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2650. } else {
  2651. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2652. return -1;
  2653. }
  2654. return 0;
  2655. }
  2656. /*==========================================
  2657. * @haircolor && @hcolor
  2658. *------------------------------------------*/
  2659. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2660. {
  2661. int hair_color = 0;
  2662. nullpo_retr(-1, sd);
  2663. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2664. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2665. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2666. clif_displaymessage(fd, atcmd_output);
  2667. return -1;
  2668. }
  2669. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2670. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2671. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2672. } else {
  2673. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2674. return -1;
  2675. }
  2676. return 0;
  2677. }
  2678. /*==========================================
  2679. * @go [city_number or city_name] - Updated by Harbin
  2680. *------------------------------------------*/
  2681. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2682. {
  2683. int i;
  2684. int town;
  2685. char map_name[MAP_NAME_LENGTH_EXT];
  2686. int m;
  2687. const struct { char map[MAP_NAME_LENGTH_EXT]; int x, y; } data[] = {
  2688. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2689. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2690. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2691. { MAP_PAYON, 162, 233 }, // 3=Payon
  2692. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2693. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2694. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2695. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2696. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2697. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2698. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2699. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2700. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2701. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2702. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2703. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  2704. { MAP_JAIL, 23, 61 }, // 16=Prison
  2705. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2706. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2707. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2708. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2709. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2710. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2711. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2712. { MAP_VEINS, 216, 123 }, // 24=Veins
  2713. };
  2714. nullpo_retr(-1, sd);
  2715. if(map[sd->bl.m].flag.nogo) {
  2716. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2717. return 0;
  2718. }
  2719. memset(map_name, '\0', sizeof(map_name));
  2720. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2721. // get the number
  2722. town = atoi(message);
  2723. // if no value, display all value
  2724. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2725. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2726. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  2727. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2728. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2729. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2730. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2731. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2732. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2733. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2734. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2735. clif_displaymessage(fd, " 24=Veins");
  2736. return -1;
  2737. } else {
  2738. // get possible name of the city
  2739. map_name[MAP_NAME_LENGTH_EXT-1] = '\0';
  2740. for (i = 0; map_name[i]; i++)
  2741. map_name[i] = TOLOWER(map_name[i]);
  2742. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2743. if (strncmp(map_name, "prontera", 3) == 0) { // 3 first characters
  2744. town = 0;
  2745. } else if (strncmp(map_name, "morocc", 3) == 0) { // 3 first characters
  2746. town = 1;
  2747. } else if (strncmp(map_name, "geffen", 3) == 0) { // 3 first characters
  2748. town = 2;
  2749. } else if (strncmp(map_name, "payon", 3) == 0 || // 3 first characters
  2750. strncmp(map_name, "paion", 3) == 0) { // writing error (3 first characters)
  2751. town = 3;
  2752. } else if (strncmp(map_name, "alberta", 3) == 0) { // 3 first characters
  2753. town = 4;
  2754. } else if (strncmp(map_name, "izlude", 3) == 0 || // 3 first characters
  2755. strncmp(map_name, "islude", 3) == 0) { // writing error (3 first characters)
  2756. town = 5;
  2757. } else if (strncmp(map_name, "aldebaran", 3) == 0 || // 3 first characters
  2758. strcmp(map_name, "al") == 0) { // al (de baran)
  2759. town = 6;
  2760. } else if (strncmp(map_name, "lutie", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2761. strcmp(map_name, "christmas") == 0 || // name of the symbol
  2762. strncmp(map_name, "xmas", 3) == 0 || // 3 first characters
  2763. strncmp(map_name, "x-mas", 3) == 0) { // writing error (3 first characters)
  2764. town = 7;
  2765. } else if (strncmp(map_name, "comodo", 3) == 0) { // 3 first characters
  2766. town = 8;
  2767. } else if (strncmp(map_name, "yuno", 3) == 0) { // 3 first characters
  2768. town = 9;
  2769. } else if (strncmp(map_name, "amatsu", 3) == 0 || // 3 first characters
  2770. strncmp(map_name, "ammatsu", 3) == 0) { // writing error (3 first characters)
  2771. town = 10;
  2772. } else if (strncmp(map_name, "gonryun", 3) == 0) { // 3 first characters
  2773. town = 11;
  2774. } else if (strncmp(map_name, "umbala", 3) == 0) { // 3 first characters
  2775. town = 12;
  2776. } else if (strncmp(map_name, "niflheim", 3) == 0) { // 3 first characters
  2777. town = 13;
  2778. } else if (strncmp(map_name, "louyang", 3) == 0) { // 3 first characters
  2779. town = 14;
  2780. } else if (strncmp(map_name, "new_zone01", 3) == 0 || // 3 first characters (or "newbies")
  2781. strncmp(map_name, "startpoint", 3) == 0 || // name of the position (3 first characters)
  2782. strncmp(map_name, "begining", 3) == 0) { // name of the position (3 first characters)
  2783. town = 15;
  2784. } else if (strncmp(map_name, "sec_pri", 3) == 0 || // 3 first characters
  2785. strncmp(map_name, "prison", 3) == 0 || // name of the position (3 first characters)
  2786. strncmp(map_name, "jails", 3) == 0) { // name of the position
  2787. town = 16;
  2788. } else if (strncmp(map_name, "jawaii", 3) == 0 || // 3 first characters
  2789. strncmp(map_name, "jawai", 3) == 0) { // writing error (3 first characters)
  2790. town = 17;
  2791. } else if (strncmp(map_name, "ayothaya", 2) == 0 || // 2 first characters
  2792. strncmp(map_name, "ayotaya", 2) == 0) { // writing error (2 first characters)
  2793. town = 18;
  2794. } else if (strncmp(map_name, "einbroch", 5) == 0 || // 5 first characters
  2795. strncmp(map_name, "ainbroch", 5) == 0) { // writing error (5 first characters)
  2796. town = 19;
  2797. } else if (strncmp(map_name, "lighthalzen", 3) == 0 || // 3 first characters
  2798. strncmp(map_name, "reichthalzen", 3) == 0) { // 'alternative' name (3 first characters)
  2799. town = 20;
  2800. } else if (strncmp(map_name, "einbech", 3) == 0) { // 3 first characters
  2801. town = 21;
  2802. } else if (strncmp(map_name, "hugel", 3) == 0) { // 3 first characters
  2803. town = 22;
  2804. } else if (strncmp(map_name, "rachel", 3) == 0) { // 3 first characters
  2805. town = 23;
  2806. } else if (strncmp(map_name, "veins", 3) == 0) { // 3 first characters
  2807. town = 24;
  2808. }
  2809. if (town >= -3 && town <= -1) {
  2810. if (sd->status.memo_point[-town-1].map) {
  2811. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2812. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2813. clif_displaymessage(fd, msg_txt(247));
  2814. return -1;
  2815. }
  2816. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2817. clif_displaymessage(fd, msg_txt(248));
  2818. return -1;
  2819. }
  2820. 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) {
  2821. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2822. } else {
  2823. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2824. return -1;
  2825. }
  2826. } else {
  2827. sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
  2828. clif_displaymessage(fd, atcmd_output);
  2829. return -1;
  2830. }
  2831. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2832. m = map_mapname2mapid((char *)data[town].map);
  2833. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2834. clif_displaymessage(fd, msg_txt(247));
  2835. return -1;
  2836. }
  2837. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2838. clif_displaymessage(fd, msg_txt(248));
  2839. return -1;
  2840. }
  2841. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2842. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2843. } else {
  2844. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2845. return -1;
  2846. }
  2847. } else { // if you arrive here, you have an error in town variable when reading of names
  2848. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2849. return -1;
  2850. }
  2851. }
  2852. return 0;
  2853. }
  2854. /*==========================================
  2855. *
  2856. *------------------------------------------*/
  2857. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2858. {
  2859. char name[NAME_LENGTH];
  2860. char monster[NAME_LENGTH];
  2861. int mob_id;
  2862. int number = 0;
  2863. int count;
  2864. int i, k, range;
  2865. short mx, my;
  2866. nullpo_retr(-1, sd);
  2867. memset(name, '\0', sizeof(name));
  2868. memset(monster, '\0', sizeof(monster));
  2869. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2870. if (!message || !*message) {
  2871. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2872. return -1;
  2873. }
  2874. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2875. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2876. //All data can be left as it is.
  2877. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2878. //Here, it is possible name was not given and we are using monster for it.
  2879. if (count < 3) //Blank mob's name.
  2880. name[0] = '\0';
  2881. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2882. //All data can be left as it is.
  2883. } else if (sscanf(message, "%23s", monster) > 0) {
  2884. //As before, name may be already filled.
  2885. name[0] = '\0';
  2886. } else {
  2887. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2888. return -1;
  2889. }
  2890. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2891. mob_id = mobdb_checkid(atoi(monster));
  2892. if (mob_id == 0) {
  2893. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2894. return -1;
  2895. }
  2896. if (mob_id == MOBID_EMPERIUM) {
  2897. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  2898. return -1;
  2899. }
  2900. if (number <= 0)
  2901. number = 1;
  2902. if (strlen(name) < 1)
  2903. strcpy(name, "--ja--");
  2904. // 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
  2905. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2906. number = battle_config.atc_spawn_quantity_limit;
  2907. if (battle_config.etc_log)
  2908. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
  2909. count = 0;
  2910. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  2911. for (i = 0; i < number; i++) {
  2912. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2913. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  2914. count += (k != 0) ? 1 : 0;
  2915. }
  2916. if (count != 0)
  2917. if (number == count)
  2918. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2919. else {
  2920. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2921. clif_displaymessage(fd, atcmd_output);
  2922. }
  2923. else {
  2924. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2925. return -1;
  2926. }
  2927. return 0;
  2928. }
  2929. // small monster spawning [Valaris]
  2930. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2931. {
  2932. char name[NAME_LENGTH] = "";
  2933. char monster[NAME_LENGTH] = "";
  2934. int mob_id = 0;
  2935. int number = 0;
  2936. int x = 0;
  2937. int y = 0;
  2938. int count;
  2939. int i;
  2940. nullpo_retr(-1, sd);
  2941. if (!message || !*message) {
  2942. clif_displaymessage(fd, "Give a monster name/id please.");
  2943. return -1;
  2944. }
  2945. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2946. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2947. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2948. clif_displaymessage(fd, "Give a monster name/id please.");
  2949. return -1;
  2950. }
  2951. // If monster identifier/name argument is a name
  2952. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2953. mob_id = atoi(monster);
  2954. if (mob_id == 0) {
  2955. clif_displaymessage(fd, msg_txt(40));
  2956. return -1;
  2957. }
  2958. if (mob_id == MOBID_EMPERIUM) {
  2959. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2960. return -1;
  2961. }
  2962. if (mobdb_checkid(mob_id) == 0) {
  2963. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2964. return -1;
  2965. }
  2966. if (number <= 0)
  2967. number = 1;
  2968. if (strlen(name) < 1)
  2969. strcpy(name, "--ja--");
  2970. // 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
  2971. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2972. number = battle_config.atc_spawn_quantity_limit;
  2973. count = 0;
  2974. for (i = 0; i < number; i++) {
  2975. int mx, my;
  2976. if (x <= 0)
  2977. mx = sd->bl.x + (rand() % 11 - 5);
  2978. else
  2979. mx = x;
  2980. if (y <= 0)
  2981. my = sd->bl.y + (rand() % 11 - 5);
  2982. else
  2983. my = y;
  2984. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2985. }
  2986. if (count != 0)
  2987. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2988. else
  2989. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2990. return 0;
  2991. }
  2992. // big monster spawning [Valaris]
  2993. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2994. {
  2995. char name[NAME_LENGTH] = "";
  2996. char monster[NAME_LENGTH] = "";
  2997. int mob_id = 0;
  2998. int number = 0;
  2999. int x = 0;
  3000. int y = 0;
  3001. int count;
  3002. int i;
  3003. nullpo_retr(-1, sd);
  3004. if (!message || !*message) {
  3005. clif_displaymessage(fd, "Give a monster name/id please.");
  3006. return -1;
  3007. }
  3008. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3009. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3010. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3011. clif_displaymessage(fd, "Give a monster name/id please.");
  3012. return -1;
  3013. }
  3014. // If monster identifier/name argument is a name
  3015. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3016. mob_id = atoi(monster);
  3017. if (mob_id == 0) {
  3018. clif_displaymessage(fd, msg_txt(40));
  3019. return -1;
  3020. }
  3021. if (mob_id == MOBID_EMPERIUM) {
  3022. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  3023. return -1;
  3024. }
  3025. if (mobdb_checkid(mob_id) == 0) {
  3026. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3027. return -1;
  3028. }
  3029. if (number <= 0)
  3030. number = 1;
  3031. if (strlen(name) < 1)
  3032. strcpy(name, "--ja--");
  3033. // 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
  3034. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3035. number = battle_config.atc_spawn_quantity_limit;
  3036. count = 0;
  3037. for (i = 0; i < number; i++) {
  3038. int mx, my;
  3039. if (x <= 0)
  3040. mx = sd->bl.x + (rand() % 11 - 5);
  3041. else
  3042. mx = x;
  3043. if (y <= 0)
  3044. my = sd->bl.y + (rand() % 11 - 5);
  3045. else
  3046. my = y;
  3047. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3048. }
  3049. if (count != 0)
  3050. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3051. else
  3052. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3053. return 0;
  3054. }
  3055. /*==========================================
  3056. *
  3057. *------------------------------------------*/
  3058. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  3059. {
  3060. struct mob_data *md;
  3061. int flag;
  3062. nullpo_retr(0, ap);
  3063. nullpo_retr(0, md=(struct mob_data *)bl);
  3064. flag = va_arg(ap, int);
  3065. if (md->guardian_data)
  3066. return 0; //Do not touch WoE mobs!
  3067. if (flag)
  3068. status_zap(bl,md->status.hp, 0);
  3069. else
  3070. status_kill(bl);
  3071. return 1;
  3072. }
  3073. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  3074. {
  3075. int map_id;
  3076. char map_name[MAP_NAME_LENGTH_EXT];
  3077. if (!sd) return;
  3078. memset(map_name, '\0', sizeof(map_name));
  3079. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3080. map_id = sd->bl.m;
  3081. else {
  3082. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3083. map_id = sd->bl.m;
  3084. }
  3085. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3086. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  3087. return;
  3088. }
  3089. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3090. {
  3091. atcommand_killmonster_sub(fd, sd, message, 1);
  3092. return 0;
  3093. }
  3094. /*==========================================
  3095. *
  3096. *------------------------------------------*/
  3097. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3098. {
  3099. atcommand_killmonster_sub(fd, sd, message, 0);
  3100. return 0;
  3101. }
  3102. /*==========================================
  3103. *
  3104. *------------------------------------------*/
  3105. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3106. {
  3107. int i,j, position = 0, refine = 0, current_position, final_refine;
  3108. int count;
  3109. nullpo_retr(-1, sd);
  3110. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3111. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3112. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3113. sprintf(atcmd_output, "%d: Left Accessory", EQI_ACC_L);
  3114. clif_displaymessage(fd, atcmd_output);
  3115. sprintf(atcmd_output, "%d: Right Accessory", EQI_ACC_R);
  3116. clif_displaymessage(fd, atcmd_output);
  3117. sprintf(atcmd_output, "%d: Shoes", EQI_SHOES);
  3118. clif_displaymessage(fd, atcmd_output);
  3119. sprintf(atcmd_output, "%d: Garment", EQI_GARMENT);
  3120. clif_displaymessage(fd, atcmd_output);
  3121. sprintf(atcmd_output, "%d: Lower Headgear", EQI_HEAD_LOW);
  3122. clif_displaymessage(fd, atcmd_output);
  3123. sprintf(atcmd_output, "%d: Mid Headgear", EQI_HEAD_MID);
  3124. clif_displaymessage(fd, atcmd_output);
  3125. sprintf(atcmd_output, "%d: Top Headgear", EQI_HEAD_TOP);
  3126. clif_displaymessage(fd, atcmd_output);
  3127. sprintf(atcmd_output, "%d: Body Armor", EQI_ARMOR);
  3128. clif_displaymessage(fd, atcmd_output);
  3129. sprintf(atcmd_output, "%d: Left Hand", EQI_HAND_L);
  3130. clif_displaymessage(fd, atcmd_output);
  3131. sprintf(atcmd_output, "%d: Right Hand", EQI_HAND_R);
  3132. clif_displaymessage(fd, atcmd_output);
  3133. return -1;
  3134. }
  3135. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  3136. count = 0;
  3137. for (j = 0; j < EQI_MAX-1; j++) {
  3138. if ((i = sd->equip_index[j]) < 0)
  3139. continue;
  3140. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  3141. continue;
  3142. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  3143. continue;
  3144. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  3145. continue;
  3146. if(position && !(sd->status.inventory[i].equip & position))
  3147. continue;
  3148. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  3149. if (sd->status.inventory[i].refine != final_refine) {
  3150. sd->status.inventory[i].refine = final_refine;
  3151. current_position = sd->status.inventory[i].equip;
  3152. pc_unequipitem(sd, i, 3);
  3153. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  3154. clif_delitem(sd, i, 1);
  3155. clif_additem(sd, i, 1, 0);
  3156. pc_equipitem(sd, i, current_position);
  3157. clif_misceffect(&sd->bl, 3);
  3158. count++;
  3159. }
  3160. }
  3161. if (count == 0)
  3162. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  3163. else if (count == 1)
  3164. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  3165. else {
  3166. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  3167. clif_displaymessage(fd, atcmd_output);
  3168. }
  3169. return 0;
  3170. }
  3171. /*==========================================
  3172. *
  3173. *------------------------------------------*/
  3174. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3175. {
  3176. char item_name[100];
  3177. int item_id, attribute = 0, star = 0;
  3178. int flag = 0;
  3179. struct item_data *item_data;
  3180. struct item tmp_item;
  3181. nullpo_retr(-1, sd);
  3182. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3183. memset(item_name, '\0', sizeof(item_name));
  3184. if (!message || !*message || (
  3185. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  3186. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  3187. )) {
  3188. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3189. return -1;
  3190. }
  3191. item_id = 0;
  3192. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  3193. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  3194. {
  3195. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  3196. clif_displaymessage(fd, atcmd_output);
  3197. return -1;
  3198. }
  3199. item_id = item_data->nameid;
  3200. if (itemdb_isequip2(item_data)) {
  3201. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3202. attribute = ATTRIBUTE_NORMAL;
  3203. if (star < MIN_STAR || star > MAX_STAR)
  3204. star = 0;
  3205. memset(&tmp_item, 0, sizeof tmp_item);
  3206. tmp_item.nameid = item_id;
  3207. tmp_item.amount = 1;
  3208. tmp_item.identify = 1;
  3209. tmp_item.card[0] = CARD0_FORGE;
  3210. tmp_item.card[1] = item_data->type==IT_WEAPON?
  3211. ((star*5) << 8) + attribute:0;
  3212. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  3213. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  3214. clif_produceeffect(sd, 0, item_id);
  3215. clif_misceffect(&sd->bl, 3);
  3216. //Logs (A)dmins items [Lupus]
  3217. if(log_config.enable_logs&0x400)
  3218. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  3219. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3220. clif_additem(sd, 0, 0, flag);
  3221. } else {
  3222. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3223. clif_displaymessage(fd, atcmd_output);
  3224. return -1;
  3225. }
  3226. return 0;
  3227. }
  3228. /*==========================================
  3229. * Sub-function to display actual memo points
  3230. *------------------------------------------*/
  3231. void atcommand_memo_sub(struct map_session_data* sd)
  3232. {
  3233. int i;
  3234. if (!sd) return;
  3235. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3236. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3237. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3238. if (sd->status.memo_point[i].map)
  3239. 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);
  3240. else
  3241. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  3242. clif_displaymessage(sd->fd, atcmd_output);
  3243. }
  3244. return;
  3245. }
  3246. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3247. {
  3248. int position = 0;
  3249. nullpo_retr(-1, sd);
  3250. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3251. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3252. atcommand_memo_sub(sd);
  3253. else {
  3254. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3255. 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)) {
  3256. clif_displaymessage(fd, msg_txt(253));
  3257. return -1;
  3258. }
  3259. if (sd->status.memo_point[position].map) {
  3260. sprintf(atcmd_output, msg_txt(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).
  3261. clif_displaymessage(fd, atcmd_output);
  3262. }
  3263. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3264. sd->status.memo_point[position].x = sd->bl.x;
  3265. sd->status.memo_point[position].y = sd->bl.y;
  3266. clif_skill_memo(sd, 0);
  3267. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3268. clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
  3269. atcommand_memo_sub(sd);
  3270. } else {
  3271. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3272. clif_displaymessage(fd, atcmd_output);
  3273. atcommand_memo_sub(sd);
  3274. return -1;
  3275. }
  3276. }
  3277. return 0;
  3278. }
  3279. /*==========================================
  3280. *
  3281. *------------------------------------------*/
  3282. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3283. {
  3284. int y;
  3285. nullpo_retr(-1, sd);
  3286. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3287. for (y = 2; y >= -2; y--) {
  3288. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3289. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3290. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3291. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3292. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3293. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3294. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3295. clif_displaymessage(fd, atcmd_output);
  3296. }
  3297. return 0;
  3298. }
  3299. /*==========================================
  3300. *
  3301. *------------------------------------------*/
  3302. int atcommand_displaystatus(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3303. {
  3304. int i, type, flag;
  3305. nullpo_retr(-1, sd);
  3306. if (!message || !*message || (i = sscanf(message, "%d %d", &type, &flag)) < 1) {
  3307. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag>).");
  3308. return -1;
  3309. }
  3310. if (i == 1) flag = 1;
  3311. clif_status_change(&sd->bl, type, flag);
  3312. return 0;
  3313. }
  3314. /*==========================================
  3315. * @stpoint (Rewritten by [Yor])
  3316. *------------------------------------------*/
  3317. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3318. {
  3319. int point, new_status_point;
  3320. if (!message || !*message || (point = atoi(message)) == 0) {
  3321. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3322. return -1;
  3323. }
  3324. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3325. new_status_point = USHRT_MAX;
  3326. else
  3327. if (point < 0 && sd->status.status_point < -point)
  3328. new_status_point = 0;
  3329. else
  3330. new_status_point = sd->status.status_point + point;
  3331. if (new_status_point != (int)sd->status.status_point) {
  3332. sd->status.status_point = (unsigned short)new_status_point;
  3333. clif_updatestatus(sd, SP_STATUSPOINT);
  3334. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  3335. } else {
  3336. if (point < 0)
  3337. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3338. else
  3339. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3340. return -1;
  3341. }
  3342. return 0;
  3343. }
  3344. /*==========================================
  3345. * @skpoint (Rewritten by [Yor])
  3346. *------------------------------------------*/
  3347. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3348. {
  3349. int point, new_skill_point;
  3350. nullpo_retr(-1, sd);
  3351. if (!message || !*message || (point = atoi(message)) == 0) {
  3352. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3353. return -1;
  3354. }
  3355. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3356. new_skill_point = USHRT_MAX;
  3357. else if (point < 0 && sd->status.skill_point < -point)
  3358. new_skill_point = 0;
  3359. else
  3360. new_skill_point = sd->status.skill_point + point;
  3361. if (new_skill_point != (int)sd->status.skill_point) {
  3362. sd->status.skill_point = (unsigned short)new_skill_point;
  3363. clif_updatestatus(sd, SP_SKILLPOINT);
  3364. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  3365. } else {
  3366. if (point < 0)
  3367. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3368. else
  3369. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3370. return -1;
  3371. }
  3372. return 0;
  3373. }
  3374. /*==========================================
  3375. * @zeny (Rewritten by [Yor])
  3376. *------------------------------------------*/
  3377. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3378. {
  3379. int zeny, new_zeny;
  3380. nullpo_retr(-1, sd);
  3381. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3382. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3383. return -1;
  3384. }
  3385. new_zeny = sd->status.zeny + zeny;
  3386. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3387. new_zeny = MAX_ZENY;
  3388. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3389. new_zeny = 0;
  3390. if (new_zeny != sd->status.zeny) {
  3391. sd->status.zeny = new_zeny;
  3392. clif_updatestatus(sd, SP_ZENY);
  3393. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  3394. } else {
  3395. if (zeny < 0)
  3396. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3397. else
  3398. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3399. return -1;
  3400. }
  3401. return 0;
  3402. }
  3403. /*==========================================
  3404. *
  3405. *------------------------------------------*/
  3406. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3407. {
  3408. int i, value = 0, new_value, max;
  3409. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3410. short* status[6];
  3411. //we don't use direct initialization because it isn't part of the c standard.
  3412. nullpo_retr(-1, sd);
  3413. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3414. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3415. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  3416. clif_displaymessage(fd, atcmd_output);
  3417. return -1;
  3418. }
  3419. for (i = 0; param[i] != NULL; i++)
  3420. if (strcmpi(command, param[i]) == 0)
  3421. break;
  3422. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  3423. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  3424. clif_displaymessage(fd, atcmd_output);
  3425. return -1;
  3426. }
  3427. status[0] = &sd->status.str;
  3428. status[1] = &sd->status.agi;
  3429. status[2] = &sd->status.vit;
  3430. status[3] = &sd->status.int_;
  3431. status[4] = &sd->status.dex;
  3432. status[5] = &sd->status.luk;
  3433. max = SHRT_MAX;
  3434. new_value = cap_value(*status[i] + value, 1, max);
  3435. if (new_value != (int)*status[i]) {
  3436. *status[i] = new_value;
  3437. clif_updatestatus(sd, SP_STR + i);
  3438. clif_updatestatus(sd, SP_USTR + i);
  3439. status_calc_pc(sd, 0);
  3440. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3441. } else {
  3442. if (value < 0)
  3443. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3444. else
  3445. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3446. return -1;
  3447. }
  3448. return 0;
  3449. }
  3450. /*==========================================
  3451. * Stat all by fritz (rewritten by [Yor])
  3452. *------------------------------------------*/
  3453. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3454. {
  3455. int index, count, value, max, new_value;
  3456. short* status[6];
  3457. //we don't use direct initialization because it isn't part of the c standard.
  3458. nullpo_retr(-1, sd);
  3459. status[0] = &sd->status.str;
  3460. status[1] = &sd->status.agi;
  3461. status[2] = &sd->status.vit;
  3462. status[3] = &sd->status.int_;
  3463. status[4] = &sd->status.dex;
  3464. status[5] = &sd->status.luk;
  3465. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3466. value = pc_maxparameter(sd);
  3467. max = pc_maxparameter(sd);
  3468. } else {
  3469. max = SHRT_MAX;
  3470. }
  3471. count = 0;
  3472. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3473. if (value > 0 && *status[index] > max - value)
  3474. new_value = max;
  3475. else if (value < 0 && *status[index] <= -value)
  3476. new_value = 1;
  3477. else
  3478. new_value = *status[index] +value;
  3479. if (new_value != (int)*status[index]) {
  3480. *status[index] = new_value;
  3481. clif_updatestatus(sd, SP_STR + index);
  3482. clif_updatestatus(sd, SP_USTR + index);
  3483. count++;
  3484. }
  3485. }
  3486. if (count > 0) { // if at least 1 stat modified
  3487. status_calc_pc(sd, 0);
  3488. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3489. } else {
  3490. if (value < 0)
  3491. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  3492. else
  3493. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  3494. return -1;
  3495. }
  3496. return 0;
  3497. }
  3498. /*==========================================
  3499. *
  3500. *------------------------------------------*/
  3501. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3502. {
  3503. int level = 0;
  3504. short added_level;
  3505. struct guild *guild_info;
  3506. nullpo_retr(-1, sd);
  3507. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3508. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3509. return -1;
  3510. }
  3511. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3512. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3513. return -1;
  3514. }
  3515. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  3516. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3517. // return -1;
  3518. //}
  3519. added_level = (short)level;
  3520. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3521. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3522. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3523. added_level = 1 - guild_info->guild_lv;
  3524. if (added_level != 0) {
  3525. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3526. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3527. } else {
  3528. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3529. return -1;
  3530. }
  3531. return 0;
  3532. }
  3533. /*==========================================
  3534. *
  3535. *------------------------------------------*/
  3536. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3537. {
  3538. struct item_data *item_data;
  3539. int id, pet_id;
  3540. nullpo_retr(-1, sd);
  3541. if (!message || !*message) {
  3542. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet_id>).");
  3543. return -1;
  3544. }
  3545. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3546. id = item_data->nameid;
  3547. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3548. id = atoi(message);
  3549. pet_id = search_petDB_index(id, PET_CLASS);
  3550. if (pet_id < 0)
  3551. pet_id = search_petDB_index(id, PET_EGG);
  3552. if (pet_id >= 0) {
  3553. sd->catch_target_class = pet_db[pet_id].class_;
  3554. intif_create_pet(
  3555. sd->status.account_id, sd->status.char_id,
  3556. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3557. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3558. 100, 0, 1, pet_db[pet_id].jname);
  3559. } else {
  3560. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  3561. return -1;
  3562. }
  3563. return 0;
  3564. }
  3565. /*==========================================
  3566. *
  3567. *------------------------------------------*/
  3568. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3569. {
  3570. nullpo_retr(-1, sd);
  3571. if (sd->status.pet_id <= 0)
  3572. clif_sendegg(sd);
  3573. else {
  3574. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3575. return -1;
  3576. }
  3577. return 0;
  3578. }
  3579. /*==========================================
  3580. *
  3581. *------------------------------------------*/
  3582. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3583. {
  3584. int friendly;
  3585. struct pet_data *pd;
  3586. nullpo_retr(-1, sd);
  3587. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3588. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3589. return -1;
  3590. }
  3591. pd = sd->pd;
  3592. if (!pd) {
  3593. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3594. return -1;
  3595. }
  3596. if (friendly < 0 || friendly > 1000)
  3597. {
  3598. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3599. return -1;
  3600. }
  3601. if (friendly == pd->pet.intimate) {
  3602. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  3603. return -1;
  3604. }
  3605. pd->pet.intimate = friendly;
  3606. clif_send_petstatus(sd);
  3607. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  3608. return 0;
  3609. }
  3610. /*==========================================
  3611. *
  3612. *------------------------------------------*/
  3613. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3614. {
  3615. int hungry;
  3616. struct pet_data *pd;
  3617. nullpo_retr(-1, sd);
  3618. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3619. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3620. return -1;
  3621. }
  3622. pd = sd->pd;
  3623. if (!sd->status.pet_id || !pd) {
  3624. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3625. return -1;
  3626. }
  3627. if (hungry < 0 || hungry > 100) {
  3628. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3629. return -1;
  3630. }
  3631. if (hungry == pd->pet.hungry) {
  3632. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  3633. return -1;
  3634. }
  3635. pd->pet.hungry = hungry;
  3636. clif_send_petstatus(sd);
  3637. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  3638. return 0;
  3639. }
  3640. /*==========================================
  3641. *
  3642. *------------------------------------------*/
  3643. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3644. {
  3645. struct pet_data *pd;
  3646. nullpo_retr(-1, sd);
  3647. if (!sd->status.pet_id || !sd->pd) {
  3648. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3649. return -1;
  3650. }
  3651. pd = sd->pd;
  3652. if (!pd->pet.rename_flag) {
  3653. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  3654. return -1;
  3655. }
  3656. pd->pet.rename_flag = 0;
  3657. intif_save_petdata(sd->status.account_id, &pd->pet);
  3658. clif_send_petstatus(sd);
  3659. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  3660. return 0;
  3661. }
  3662. /*==========================================
  3663. *
  3664. *------------------------------------------*/
  3665. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3666. {
  3667. struct map_session_data *pl_sd = NULL;
  3668. nullpo_retr(-1, sd);
  3669. if (!message || !*message) {
  3670. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  3671. return -1;
  3672. }
  3673. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3674. {
  3675. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3676. return -1;
  3677. }
  3678. if (pl_sd == sd)
  3679. {
  3680. clif_displaymessage(fd, "You are already where you are...");
  3681. return -1;
  3682. }
  3683. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3684. {
  3685. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3686. return -1;
  3687. }
  3688. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3689. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3690. return -1;
  3691. }
  3692. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3693. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3694. return -1;
  3695. }
  3696. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3697. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  3698. clif_displaymessage(fd, atcmd_output);
  3699. return 0;
  3700. }
  3701. /*==========================================
  3702. * charblock command (usage: charblock <player_name>)
  3703. * This command do a definitiv ban on a player
  3704. *------------------------------------------*/
  3705. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3706. {
  3707. nullpo_retr(-1, sd);
  3708. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3709. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3710. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3711. return -1;
  3712. }
  3713. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3714. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3715. return 0;
  3716. }
  3717. /*==========================================
  3718. * charban command (usage: charban <time> <player_name>)
  3719. * This command do a limited ban on a player
  3720. * Time is done as follows:
  3721. * Adjustment value (-1, 1, +1, etc...)
  3722. * Modified element:
  3723. * a or y: year
  3724. * m: month
  3725. * j or d: day
  3726. * h: hour
  3727. * mn: minute
  3728. * s: second
  3729. * <example> @ban +1m-2mn1s-6y test_player
  3730. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3731. *------------------------------------------*/
  3732. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3733. {
  3734. char * modif_p;
  3735. int year, month, day, hour, minute, second, value;
  3736. nullpo_retr(-1, sd);
  3737. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3738. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3739. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3740. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3741. return -1;
  3742. }
  3743. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3744. modif_p = atcmd_output;
  3745. year = month = day = hour = minute = second = 0;
  3746. while (modif_p[0] != '\0') {
  3747. value = atoi(modif_p);
  3748. if (value == 0)
  3749. modif_p++;
  3750. else {
  3751. if (modif_p[0] == '-' || modif_p[0] == '+')
  3752. modif_p++;
  3753. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3754. modif_p++;
  3755. if (modif_p[0] == 's') {
  3756. second = value;
  3757. modif_p++;
  3758. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  3759. minute = value;
  3760. modif_p = modif_p + 2;
  3761. } else if (modif_p[0] == 'h') {
  3762. hour = value;
  3763. modif_p++;
  3764. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3765. day = value;
  3766. modif_p++;
  3767. } else if (modif_p[0] == 'm') {
  3768. month = value;
  3769. modif_p++;
  3770. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3771. year = value;
  3772. modif_p++;
  3773. } else if (modif_p[0] != '\0') {
  3774. modif_p++;
  3775. }
  3776. }
  3777. }
  3778. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3779. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3780. return -1;
  3781. }
  3782. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3783. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3784. return 0;
  3785. }
  3786. /*==========================================
  3787. * charunblock command (usage: charunblock <player_name>)
  3788. *------------------------------------------*/
  3789. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3790. {
  3791. nullpo_retr(-1, sd);
  3792. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3793. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3794. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3795. return -1;
  3796. }
  3797. // send answer to login server via char-server
  3798. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3799. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3800. return 0;
  3801. }
  3802. /*==========================================
  3803. * charunban command (usage: charunban <player_name>)
  3804. *------------------------------------------*/
  3805. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3806. {
  3807. nullpo_retr(-1, sd);
  3808. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3809. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3810. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3811. return -1;
  3812. }
  3813. // send answer to login server via char-server
  3814. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3815. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3816. return 0;
  3817. }
  3818. /*==========================================
  3819. *
  3820. *------------------------------------------*/
  3821. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3822. {
  3823. nullpo_retr(-1, sd);
  3824. if (night_flag != 1) {
  3825. map_night_timer(night_timer_tid, 0, 0, 1);
  3826. } else {
  3827. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  3828. return -1;
  3829. }
  3830. return 0;
  3831. }
  3832. /*==========================================
  3833. *
  3834. *------------------------------------------*/
  3835. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3836. {
  3837. nullpo_retr(-1, sd);
  3838. if (night_flag != 0) {
  3839. map_day_timer(day_timer_tid, 0, 0, 1);
  3840. } else {
  3841. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  3842. return -1;
  3843. }
  3844. return 0;
  3845. }
  3846. /*==========================================
  3847. *
  3848. *------------------------------------------*/
  3849. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3850. {
  3851. struct map_session_data *pl_sd, **pl_allsd;
  3852. int i, users;
  3853. nullpo_retr(-1, sd);
  3854. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  3855. pl_allsd = map_getallusers(&users);
  3856. for(i = 0; i < users; i++) {
  3857. 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
  3858. status_kill(&pl_sd->bl);
  3859. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3860. }
  3861. }
  3862. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3863. return 0;
  3864. }
  3865. /*==========================================
  3866. *
  3867. *------------------------------------------*/
  3868. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3869. {
  3870. struct map_session_data *pl_sd, **pl_allsd;
  3871. int i, users;
  3872. nullpo_retr(-1, sd);
  3873. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  3874. pl_allsd = map_getallusers(&users);
  3875. for (i = 0; i < users; i++) {
  3876. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  3877. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  3878. {
  3879. status_kill(&pl_sd->bl);
  3880. // clif_specialeffect(&pl_sd->bl,450,1);
  3881. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3882. }
  3883. }
  3884. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3885. return 0;
  3886. }
  3887. /*==========================================
  3888. *
  3889. *------------------------------------------*/
  3890. static void atcommand_raise_sub(struct map_session_data* sd)
  3891. {
  3892. if (!sd->state.auth || !status_isdead(&sd->bl))
  3893. return;
  3894. if(!status_revive(&sd->bl, 100, 100))
  3895. return;
  3896. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3897. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3898. }
  3899. /*==========================================
  3900. *
  3901. *------------------------------------------*/
  3902. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3903. {
  3904. int i, users;
  3905. struct map_session_data **all_sd;
  3906. nullpo_retr(-1, sd);
  3907. all_sd = map_getallusers(&users);
  3908. for (i = 0; i < users; i++) {
  3909. atcommand_raise_sub(all_sd[i]);
  3910. }
  3911. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3912. return 0;
  3913. }
  3914. /*==========================================
  3915. *
  3916. *------------------------------------------*/
  3917. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3918. {
  3919. struct map_session_data **pl_allsd;
  3920. int i, users;
  3921. nullpo_retr(-1, sd);
  3922. pl_allsd = map_getallusers(&users);
  3923. for (i = 0; i < users; i++) {
  3924. if (sd->bl.m == pl_allsd[i]->bl.m)
  3925. atcommand_raise_sub(pl_allsd[i]);
  3926. }
  3927. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3928. return 0;
  3929. }
  3930. /*==========================================
  3931. *
  3932. *------------------------------------------*/
  3933. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3934. {
  3935. struct map_session_data *pl_sd;
  3936. nullpo_retr(-1, sd);
  3937. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3938. if (!message || !*message) {
  3939. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3940. return -1;
  3941. }
  3942. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3943. {
  3944. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3945. return -1;
  3946. }
  3947. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3948. {
  3949. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3950. return -1;
  3951. }
  3952. clif_GM_kick(sd, pl_sd, 1);
  3953. return 0;
  3954. }
  3955. /*==========================================
  3956. *
  3957. *------------------------------------------*/
  3958. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3959. {
  3960. struct map_session_data *pl_sd, **pl_allsd;
  3961. int i, users;
  3962. nullpo_retr(-1, sd);
  3963. pl_allsd = map_getallusers(&users);
  3964. for (i = 0; i < users; i++) {
  3965. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3966. if (sd->status.account_id != pl_sd->status.account_id)
  3967. clif_GM_kick(sd, pl_sd, 0);
  3968. }
  3969. }
  3970. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3971. return 0;
  3972. }
  3973. /*==========================================
  3974. *
  3975. *------------------------------------------*/
  3976. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3977. {
  3978. nullpo_retr(-1, sd);
  3979. pc_allskillup(sd); // all skills
  3980. sd->status.skill_point = 0; // 0 skill points
  3981. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3982. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  3983. return 0;
  3984. }
  3985. /*==========================================
  3986. *
  3987. *------------------------------------------*/
  3988. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3989. {
  3990. int skill_id;
  3991. nullpo_retr(-1, sd);
  3992. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3993. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3994. return -1;
  3995. }
  3996. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3997. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3998. return -1;
  3999. }
  4000. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  4001. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4002. return -1;
  4003. }
  4004. if (pc_checkskill(sd, skill_id) > 0) {
  4005. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  4006. return -1;
  4007. }
  4008. pc_skill(sd, skill_id, 1, 0);
  4009. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  4010. return 0;
  4011. }
  4012. /*==========================================
  4013. *
  4014. *------------------------------------------*/
  4015. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4016. {
  4017. int skill_id;
  4018. nullpo_retr(-1, sd);
  4019. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4020. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4021. return -1;
  4022. }
  4023. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  4024. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4025. return -1;
  4026. }
  4027. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  4028. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4029. return -1;
  4030. }
  4031. if (pc_checkskill(sd, skill_id) == 0) {
  4032. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  4033. return -1;
  4034. }
  4035. sd->status.skill[skill_id].lv = 0;
  4036. sd->status.skill[skill_id].flag = 0;
  4037. clif_skillinfoblock(sd);
  4038. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  4039. return 0;
  4040. }
  4041. /*==========================================
  4042. *
  4043. *------------------------------------------*/
  4044. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4045. {
  4046. int number;
  4047. nullpo_retr(-1, sd);
  4048. if (!message || !*message || (number = atoi(message)) < 0) {
  4049. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4050. return -1;
  4051. }
  4052. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4053. if (number > 500)
  4054. number = 500;
  4055. if (number >= 0 && number <= 0x7FFF) {
  4056. if (sd->spiritball != number || number > 499) {
  4057. if (sd->spiritball > 0)
  4058. pc_delspiritball(sd, sd->spiritball, 1);
  4059. sd->spiritball = number;
  4060. clif_spiritball(sd);
  4061. // no message, player can look the difference
  4062. if (number > 1000)
  4063. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4064. } else {
  4065. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  4066. return -1;
  4067. }
  4068. } else {
  4069. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4070. return -1;
  4071. }
  4072. return 0;
  4073. }
  4074. /*==========================================
  4075. *
  4076. *------------------------------------------*/
  4077. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4078. {
  4079. char party[NAME_LENGTH];
  4080. nullpo_retr(-1, sd);
  4081. memset(party, '\0', sizeof(party));
  4082. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4083. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4084. return -1;
  4085. }
  4086. party_create(sd, party, 0, 0);
  4087. return 0;
  4088. }
  4089. /*==========================================
  4090. *
  4091. *------------------------------------------*/
  4092. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4093. {
  4094. char guild[NAME_LENGTH];
  4095. int prev;
  4096. nullpo_retr(-1, sd);
  4097. memset(guild, '\0', sizeof(guild));
  4098. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4099. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4100. return -1;
  4101. }
  4102. prev = battle_config.guild_emperium_check;
  4103. battle_config.guild_emperium_check = 0;
  4104. guild_create(sd, guild);
  4105. battle_config.guild_emperium_check = prev;
  4106. return 0;
  4107. }
  4108. /*==========================================
  4109. *
  4110. *------------------------------------------*/
  4111. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4112. {
  4113. nullpo_retr(-1, sd);
  4114. if (agit_flag == 1) {
  4115. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  4116. return -1;
  4117. }
  4118. agit_flag = 1;
  4119. guild_agit_start();
  4120. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  4121. return 0;
  4122. }
  4123. /*==========================================
  4124. *
  4125. *------------------------------------------*/
  4126. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4127. {
  4128. nullpo_retr(-1, sd);
  4129. if (agit_flag == 0) {
  4130. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  4131. return -1;
  4132. }
  4133. agit_flag = 0;
  4134. guild_agit_end();
  4135. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  4136. return 0;
  4137. }
  4138. /*==========================================
  4139. * @mapexit - shuts down the map server
  4140. *------------------------------------------*/
  4141. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4142. {
  4143. struct map_session_data *pl_sd, **pl_allsd;
  4144. int i, users;
  4145. nullpo_retr(-1, sd);
  4146. pl_allsd = map_getallusers(&users);
  4147. for (i = 0; i < users; i++) {
  4148. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4149. clif_GM_kick(sd, pl_sd, 0);
  4150. }
  4151. clif_GM_kick(sd, sd, 0);
  4152. flush_fifos();
  4153. runflag = 0;
  4154. return 0;
  4155. }
  4156. /*==========================================
  4157. * idsearch <part_of_name>: revrited by [Yor]
  4158. *------------------------------------------*/
  4159. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4160. {
  4161. char item_name[100];
  4162. unsigned int i, match;
  4163. struct item_data *item_array[MAX_SEARCH];
  4164. nullpo_retr(-1, sd);
  4165. memset(item_name, '\0', sizeof(item_name));
  4166. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4167. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4168. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4169. return -1;
  4170. }
  4171. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  4172. clif_displaymessage(fd, atcmd_output);
  4173. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4174. if (match > MAX_SEARCH) {
  4175. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  4176. clif_displaymessage(fd, atcmd_output);
  4177. match = MAX_SEARCH;
  4178. }
  4179. for(i = 0; i < match; i++) {
  4180. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4181. clif_displaymessage(fd, atcmd_output);
  4182. }
  4183. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  4184. clif_displaymessage(fd, atcmd_output);
  4185. return 0;
  4186. }
  4187. /*==========================================
  4188. * Recall All Characters Online To Your Location
  4189. *------------------------------------------*/
  4190. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4191. {
  4192. struct map_session_data *pl_sd, **pl_allsd;
  4193. int i;
  4194. int count, users;
  4195. nullpo_retr(-1, sd);
  4196. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4197. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4198. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4199. return -1;
  4200. }
  4201. count = 0;
  4202. pl_allsd = map_getallusers(&users);
  4203. for (i = 0; i < users; i++) {
  4204. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4205. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4206. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4207. count++;
  4208. else {
  4209. if (pc_isdead(pl_sd)) { //Wake them up
  4210. pc_setstand(pl_sd);
  4211. pc_setrestartvalue(pl_sd,1);
  4212. }
  4213. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4214. }
  4215. }
  4216. }
  4217. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4218. if (count) {
  4219. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4220. clif_displaymessage(fd, atcmd_output);
  4221. }
  4222. return 0;
  4223. }
  4224. /*==========================================
  4225. * Recall online characters of a guild to your location
  4226. *------------------------------------------*/
  4227. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4228. {
  4229. struct map_session_data *pl_sd, **pl_allsd;
  4230. int i, users, count;
  4231. char guild_name[NAME_LENGTH];
  4232. struct guild *g;
  4233. nullpo_retr(-1, sd);
  4234. memset(guild_name, '\0', sizeof(guild_name));
  4235. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4236. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4237. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4238. return -1;
  4239. }
  4240. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4241. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4242. return -1;
  4243. }
  4244. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4245. (g = guild_search(atoi(message))) != NULL) {
  4246. count = 0;
  4247. pl_allsd = map_getallusers(&users);
  4248. for (i = 0; i < users; i++) {
  4249. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4250. pl_sd->status.guild_id == g->guild_id) {
  4251. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4252. continue; //Skip GMs greater than you.
  4253. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4254. count++;
  4255. else
  4256. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4257. }
  4258. }
  4259. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  4260. clif_displaymessage(fd, atcmd_output);
  4261. if (count) {
  4262. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4263. clif_displaymessage(fd, atcmd_output);
  4264. }
  4265. } else {
  4266. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4267. return -1;
  4268. }
  4269. return 0;
  4270. }
  4271. /*==========================================
  4272. * Recall online characters of a party to your location
  4273. *------------------------------------------*/
  4274. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4275. {
  4276. int i;
  4277. struct map_session_data *pl_sd, **pl_allsd;
  4278. char party_name[NAME_LENGTH];
  4279. struct party_data *p;
  4280. int count, users;
  4281. nullpo_retr(-1, sd);
  4282. memset(party_name, '\0', sizeof(party_name));
  4283. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4284. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4285. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4286. return -1;
  4287. }
  4288. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4289. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4290. return -1;
  4291. }
  4292. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4293. (p = party_search(atoi(message))) != NULL) {
  4294. count = 0;
  4295. pl_allsd = map_getallusers(&users);
  4296. for (i = 0; i < users; i++) {
  4297. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4298. pl_sd->status.party_id == p->party.party_id) {
  4299. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4300. continue; //Skip GMs greater than you.
  4301. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4302. count++;
  4303. else
  4304. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4305. }
  4306. }
  4307. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  4308. clif_displaymessage(fd, atcmd_output);
  4309. if (count) {
  4310. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4311. clif_displaymessage(fd, atcmd_output);
  4312. }
  4313. } else {
  4314. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4315. return -1;
  4316. }
  4317. return 0;
  4318. }
  4319. /*==========================================
  4320. *
  4321. *------------------------------------------*/
  4322. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4323. {
  4324. nullpo_retr(-1, sd);
  4325. itemdb_reload();
  4326. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  4327. return 0;
  4328. }
  4329. /*==========================================
  4330. *
  4331. *------------------------------------------*/
  4332. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4333. {
  4334. nullpo_retr(-1, sd);
  4335. mob_reload();
  4336. read_petdb();
  4337. merc_reload();
  4338. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  4339. return 0;
  4340. }
  4341. /*==========================================
  4342. *
  4343. *------------------------------------------*/
  4344. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4345. {
  4346. nullpo_retr(-1, sd);
  4347. skill_reload();
  4348. merc_skill_reload();
  4349. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  4350. return 0;
  4351. }
  4352. /*==========================================
  4353. * @reloadatcommand - reloads atcommand_athena.conf
  4354. *------------------------------------------*/
  4355. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4356. {
  4357. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4358. clif_displaymessage(fd, msg_txt(254));
  4359. return 0;
  4360. }
  4361. /*==========================================
  4362. * @reloadbattleconf - reloads battle_athena.conf
  4363. *------------------------------------------*/
  4364. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4365. {
  4366. struct Battle_Config prev_config;
  4367. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4368. battle_config_read(BATTLE_CONF_FILENAME);
  4369. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  4370. || prev_config.item_rate_common != battle_config.item_rate_common
  4371. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  4372. || prev_config.item_rate_card != battle_config.item_rate_card
  4373. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  4374. || prev_config.item_rate_equip != battle_config.item_rate_equip
  4375. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  4376. || prev_config.item_rate_heal != battle_config.item_rate_heal
  4377. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  4378. || prev_config.item_rate_use != battle_config.item_rate_use
  4379. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  4380. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  4381. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  4382. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  4383. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  4384. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  4385. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  4386. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  4387. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  4388. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  4389. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  4390. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  4391. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  4392. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  4393. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  4394. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  4395. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  4396. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  4397. )
  4398. { //Drop rates changed.
  4399. mob_reload(); //Needed as well so rate changes take effect.
  4400. #ifndef TXT_ONLY
  4401. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4402. #endif
  4403. }
  4404. clif_displaymessage(fd, msg_txt(255));
  4405. return 0;
  4406. }
  4407. /*==========================================
  4408. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  4409. *------------------------------------------*/
  4410. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4411. {
  4412. status_readdb();
  4413. clif_displaymessage(fd, msg_txt(256));
  4414. return 0;
  4415. }
  4416. /*==========================================
  4417. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  4418. *------------------------------------------*/
  4419. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4420. {
  4421. pc_readdb();
  4422. clif_displaymessage(fd, msg_txt(257));
  4423. return 0;
  4424. }
  4425. /*==========================================
  4426. * @reloadmotd - reloads motd.txt
  4427. *------------------------------------------*/
  4428. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4429. {
  4430. pc_read_motd();
  4431. clif_displaymessage(fd, msg_txt(268));
  4432. return 0;
  4433. }
  4434. /*==========================================
  4435. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  4436. *------------------------------------------*/
  4437. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4438. {
  4439. nullpo_retr(-1, sd);
  4440. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4441. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4442. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4443. flush_fifos();
  4444. script_reload();
  4445. npc_reload();
  4446. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  4447. return 0;
  4448. }
  4449. /*==========================================
  4450. * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database)
  4451. *------------------------------------------*/
  4452. int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4453. {
  4454. nullpo_retr(-1, sd);
  4455. chrif_reloadGMdb();
  4456. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  4457. return 0;
  4458. }
  4459. /*==========================================
  4460. * @mapinfo <map name> [0-3] by MC_Cameri
  4461. * => Shows information about the map [map name]
  4462. * 0 = no additional information
  4463. * 1 = Show users in that map and their location
  4464. * 2 = Shows NPCs in that map
  4465. * 3 = Shows the shops/chats in that map (not implemented)
  4466. *------------------------------------------*/
  4467. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4468. {
  4469. struct map_session_data *pl_sd, **pl_allsd;
  4470. struct npc_data *nd = NULL;
  4471. struct chat_data *cd = NULL;
  4472. char direction[12];
  4473. int m_id, i, chat_num, users, list = 0;
  4474. unsigned short m_index;
  4475. nullpo_retr(-1, sd);
  4476. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4477. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4478. memset(direction, '\0', sizeof(direction));
  4479. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4480. if (list < 0 || list > 3) {
  4481. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4482. return -1;
  4483. }
  4484. if (atcmd_player_name[0] == '\0') {
  4485. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH_EXT);
  4486. atcmd_player_name[MAP_NAME_LENGTH_EXT-1] = '\0';
  4487. m_id = map_mapindex2mapid(sd->mapindex);
  4488. } else {
  4489. m_id = map_mapname2mapid(atcmd_player_name);
  4490. }
  4491. if (m_id < 0) {
  4492. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  4493. return -1;
  4494. }
  4495. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4496. clif_displaymessage(fd, "------ Map Info ------");
  4497. chat_num = 0;
  4498. pl_allsd = map_getallusers(&users);
  4499. for (i = 0; i < users; i++) {
  4500. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4501. chat_num++;
  4502. }
  4503. }
  4504. 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);
  4505. clif_displaymessage(fd, atcmd_output);
  4506. clif_displaymessage(fd, "------ Map Flags ------");
  4507. strcpy(atcmd_output,"PvP Flags: ");
  4508. if (map[m_id].flag.pvp)
  4509. strcat(atcmd_output, "Pvp ON | ");
  4510. if (map[m_id].flag.pvp_noguild)
  4511. strcat(atcmd_output, "NoGuild | ");
  4512. if (map[m_id].flag.pvp_noparty)
  4513. strcat(atcmd_output, "NoParty | ");
  4514. if (map[m_id].flag.pvp_nightmaredrop)
  4515. strcat(atcmd_output, "NightmareDrop | ");
  4516. if (map[m_id].flag.pvp_nocalcrank)
  4517. strcat(atcmd_output, "NoCalcRank | ");
  4518. clif_displaymessage(fd, atcmd_output);
  4519. strcpy(atcmd_output,"GvG Flags: ");
  4520. if (map[m_id].flag.gvg)
  4521. strcat(atcmd_output, "GvG ON | ");
  4522. if (map[m_id].flag.gvg_dungeon)
  4523. strcat(atcmd_output, "GvG Dungeon | ");
  4524. if (map[m_id].flag.gvg_castle)
  4525. strcat(atcmd_output, "GvG Castle | ");
  4526. if (map[m_id].flag.gvg_noparty)
  4527. strcat(atcmd_output, "NoParty | ");
  4528. clif_displaymessage(fd, atcmd_output);
  4529. strcpy(atcmd_output,"Teleport Flags: ");
  4530. if (map[m_id].flag.noteleport)
  4531. strcat(atcmd_output, "NoTeleport | ");
  4532. if (map[m_id].flag.monster_noteleport)
  4533. strcat(atcmd_output, "Monster NoTeleport | ");
  4534. if (map[m_id].flag.nowarp)
  4535. strcat(atcmd_output, "NoWarp | ");
  4536. if (map[m_id].flag.nowarpto)
  4537. strcat(atcmd_output, "NoWarpTo | ");
  4538. if (map[m_id].flag.noreturn)
  4539. strcat(atcmd_output, "NoReturn | ");
  4540. if (map[m_id].flag.nogo)
  4541. strcat(atcmd_output, "NoGo | ");
  4542. if (map[m_id].flag.nomemo)
  4543. strcat(atcmd_output, "NoMemo | ");
  4544. clif_displaymessage(fd, atcmd_output);
  4545. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4546. clif_displaymessage(fd, atcmd_output);
  4547. if (map[m_id].flag.nosave) {
  4548. if (!map[m_id].save.map)
  4549. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  4550. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4551. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4552. else
  4553. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4554. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4555. clif_displaymessage(fd, atcmd_output);
  4556. }
  4557. strcpy(atcmd_output,"Weather Flags: ");
  4558. if (map[m_id].flag.snow)
  4559. strcat(atcmd_output, "Snow | ");
  4560. if (map[m_id].flag.fog)
  4561. strcat(atcmd_output, "Fog | ");
  4562. if (map[m_id].flag.sakura)
  4563. strcat(atcmd_output, "Sakura | ");
  4564. if (map[m_id].flag.clouds)
  4565. strcat(atcmd_output, "Clouds | ");
  4566. if (map[m_id].flag.clouds2)
  4567. strcat(atcmd_output, "Clouds2 | ");
  4568. if (map[m_id].flag.fireworks)
  4569. strcat(atcmd_output, "Fireworks | ");
  4570. if (map[m_id].flag.leaves)
  4571. strcat(atcmd_output, "Leaves | ");
  4572. if (map[m_id].flag.rain)
  4573. strcat(atcmd_output, "Rain | ");
  4574. if (map[m_id].flag.indoors)
  4575. strcat(atcmd_output, "Indoors | ");
  4576. if (map[m_id].flag.nightenabled)
  4577. strcat(atcmd_output, "Displays Night | ");
  4578. clif_displaymessage(fd, atcmd_output);
  4579. strcpy(atcmd_output,"Other Flags: ");
  4580. if (map[m_id].flag.nobranch)
  4581. strcat(atcmd_output, "NoBranch | ");
  4582. if (map[m_id].flag.notrade)
  4583. strcat(atcmd_output, "NoTrade | ");
  4584. if (map[m_id].flag.novending)
  4585. strcat(atcmd_output, "NoVending | ");
  4586. if (map[m_id].flag.nodrop)
  4587. strcat(atcmd_output, "NoDrop | ");
  4588. if (map[m_id].flag.noskill)
  4589. strcat(atcmd_output, "NoSkill | ");
  4590. if (map[m_id].flag.noicewall)
  4591. strcat(atcmd_output, "NoIcewall | ");
  4592. clif_displaymessage(fd, atcmd_output);
  4593. strcpy(atcmd_output,"Other Flags: ");
  4594. if (map[m_id].nocommand)
  4595. strcat(atcmd_output, "NoCommand | ");
  4596. if (map[m_id].flag.nobaseexp)
  4597. strcat(atcmd_output, "NoBaseEXP | ");
  4598. if (map[m_id].flag.nojobexp)
  4599. strcat(atcmd_output, "NoJobEXP | ");
  4600. if (map[m_id].flag.nomobloot)
  4601. strcat(atcmd_output, "NoMobLoot | ");
  4602. if (map[m_id].flag.nomvploot)
  4603. strcat(atcmd_output, "NoMVPLoot | ");
  4604. if (map[m_id].flag.partylock)
  4605. strcat(atcmd_output, "PartyLock | ");
  4606. if (map[m_id].flag.guildlock)
  4607. strcat(atcmd_output, "GuildLock | ");
  4608. clif_displaymessage(fd, atcmd_output);
  4609. switch (list) {
  4610. case 0:
  4611. // Do nothing. It's list 0, no additional display.
  4612. break;
  4613. case 1:
  4614. clif_displaymessage(fd, "----- Players in Map -----");
  4615. for (i = 0; i < users; i++) {
  4616. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  4617. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  4618. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4619. clif_displaymessage(fd, atcmd_output);
  4620. }
  4621. }
  4622. break;
  4623. case 2:
  4624. clif_displaymessage(fd, "----- NPCs in Map -----");
  4625. for (i = 0; i < map[m_id].npc_num;) {
  4626. nd = map[m_id].npc[i];
  4627. switch(nd->ud.dir) {
  4628. case 0: strcpy(direction, "North"); break;
  4629. case 1: strcpy(direction, "North West"); break;
  4630. case 2: strcpy(direction, "West"); break;
  4631. case 3: strcpy(direction, "South West"); break;
  4632. case 4: strcpy(direction, "South"); break;
  4633. case 5: strcpy(direction, "South East"); break;
  4634. case 6: strcpy(direction, "East"); break;
  4635. case 7: strcpy(direction, "North East"); break;
  4636. case 9: strcpy(direction, "North"); break;
  4637. default: strcpy(direction, "Unknown"); break;
  4638. }
  4639. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  4640. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4641. clif_displaymessage(fd, atcmd_output);
  4642. }
  4643. break;
  4644. case 3:
  4645. clif_displaymessage(fd, "----- Chats in Map -----");
  4646. for (i = 0; i < users; i++) {
  4647. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  4648. pl_sd->mapindex == m_index &&
  4649. cd->usersd[0] == pl_sd) {
  4650. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  4651. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4652. clif_displaymessage(fd, atcmd_output);
  4653. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4654. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4655. clif_displaymessage(fd, atcmd_output);
  4656. }
  4657. }
  4658. break;
  4659. default: // normally impossible to arrive here
  4660. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4661. return -1;
  4662. break;
  4663. }
  4664. return 0;
  4665. }
  4666. /*==========================================
  4667. *
  4668. *------------------------------------------*/
  4669. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4670. {
  4671. nullpo_retr(-1, sd);
  4672. if (!pc_isriding(sd)) { // if actually no peco
  4673. if (!pc_checkskill(sd, KN_RIDING))
  4674. {
  4675. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  4676. return -1;
  4677. }
  4678. if (sd->disguise)
  4679. {
  4680. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco while in disguise.
  4681. return -1;
  4682. }
  4683. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4684. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  4685. } else { //Dismount
  4686. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4687. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  4688. }
  4689. return 0;
  4690. }
  4691. /*==========================================
  4692. *Spy Commands by Syrus22
  4693. *------------------------------------------*/
  4694. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4695. {
  4696. char guild_name[NAME_LENGTH];
  4697. struct guild *g;
  4698. nullpo_retr(-1, sd);
  4699. memset(guild_name, '\0', sizeof(guild_name));
  4700. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4701. if (!enable_spy)
  4702. {
  4703. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4704. return -1;
  4705. }
  4706. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4707. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4708. return -1;
  4709. }
  4710. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4711. (g = guild_search(atoi(message))) != NULL) {
  4712. if (sd->guildspy == g->guild_id) {
  4713. sd->guildspy = 0;
  4714. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4715. clif_displaymessage(fd, atcmd_output);
  4716. } else {
  4717. sd->guildspy = g->guild_id;
  4718. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4719. clif_displaymessage(fd, atcmd_output);
  4720. }
  4721. } else {
  4722. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4723. return -1;
  4724. }
  4725. return 0;
  4726. }
  4727. /*==========================================
  4728. *
  4729. *------------------------------------------*/
  4730. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4731. {
  4732. char party_name[NAME_LENGTH];
  4733. struct party_data *p;
  4734. nullpo_retr(-1, sd);
  4735. memset(party_name, '\0', sizeof(party_name));
  4736. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4737. if (!enable_spy)
  4738. {
  4739. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4740. return -1;
  4741. }
  4742. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4743. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4744. return -1;
  4745. }
  4746. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4747. (p = party_search(atoi(message))) != NULL) {
  4748. if (sd->partyspy == p->party.party_id) {
  4749. sd->partyspy = 0;
  4750. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4751. clif_displaymessage(fd, atcmd_output);
  4752. } else {
  4753. sd->partyspy = p->party.party_id;
  4754. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4755. clif_displaymessage(fd, atcmd_output);
  4756. }
  4757. } else {
  4758. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4759. return -1;
  4760. }
  4761. return 0;
  4762. }
  4763. /*==========================================
  4764. * @repairall [Valaris]
  4765. *------------------------------------------*/
  4766. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4767. {
  4768. int count, i;
  4769. nullpo_retr(-1, sd);
  4770. count = 0;
  4771. for (i = 0; i < MAX_INVENTORY; i++) {
  4772. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4773. sd->status.inventory[i].attribute = 0;
  4774. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4775. count++;
  4776. }
  4777. }
  4778. if (count > 0) {
  4779. clif_misceffect(&sd->bl, 3);
  4780. clif_equiplist(sd);
  4781. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4782. } else {
  4783. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4784. return -1;
  4785. }
  4786. return 0;
  4787. }
  4788. /*==========================================
  4789. * @nuke [Valaris]
  4790. *------------------------------------------*/
  4791. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4792. {
  4793. struct map_session_data *pl_sd;
  4794. nullpo_retr(-1, sd);
  4795. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4796. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4797. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4798. return -1;
  4799. }
  4800. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4801. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4802. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4803. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4804. } else {
  4805. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4806. return -1;
  4807. }
  4808. } else {
  4809. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4810. return -1;
  4811. }
  4812. return 0;
  4813. }
  4814. /*==========================================
  4815. * @tonpc
  4816. *------------------------------------------*/
  4817. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4818. {
  4819. char npcname[NAME_LENGTH];
  4820. struct npc_data *nd;
  4821. nullpo_retr(-1, sd);
  4822. memset(npcname, 0, sizeof(npcname));
  4823. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4824. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4825. return -1;
  4826. }
  4827. if ((nd = npc_name2id(npcname)) != NULL) {
  4828. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  4829. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4830. else
  4831. return -1;
  4832. } else {
  4833. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4834. return -1;
  4835. }
  4836. return 0;
  4837. }
  4838. /*==========================================
  4839. *
  4840. *------------------------------------------*/
  4841. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4842. {
  4843. char NPCname[NAME_LENGTH];
  4844. nullpo_retr(-1, sd);
  4845. memset(NPCname, '\0', sizeof(NPCname));
  4846. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4847. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4848. return -1;
  4849. }
  4850. if (npc_name2id(NPCname) != NULL) {
  4851. npc_enable(NPCname, 1);
  4852. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4853. } else {
  4854. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4855. return -1;
  4856. }
  4857. return 0;
  4858. }
  4859. /*==========================================
  4860. *
  4861. *------------------------------------------*/
  4862. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4863. {
  4864. char NPCname[NAME_LENGTH];
  4865. nullpo_retr(-1, sd);
  4866. memset(NPCname, '\0', sizeof(NPCname));
  4867. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4868. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4869. return -1;
  4870. }
  4871. if (npc_name2id(NPCname) == NULL) {
  4872. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4873. return -1;
  4874. }
  4875. npc_enable(NPCname, 0);
  4876. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4877. return 0;
  4878. }
  4879. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4880. {
  4881. FILE *fp;
  4882. if (!message || !*message) {
  4883. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4884. return -1;
  4885. }
  4886. // check if script file exists
  4887. if ((fp = fopen(message, "r")) == NULL) {
  4888. clif_displaymessage(fd, msg_txt(261));
  4889. return -1;
  4890. }
  4891. fclose(fp);
  4892. // add to list of script sources and run it
  4893. npc_addsrcfile(message);
  4894. npc_parsesrcfile(message);
  4895. npc_read_event_script();
  4896. clif_displaymessage(fd, msg_txt(262));
  4897. return 0;
  4898. }
  4899. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4900. {
  4901. struct npc_data *nd;
  4902. char NPCname[NAME_LENGTH];
  4903. nullpo_retr(-1, sd);
  4904. memset(NPCname, '\0', sizeof(NPCname));
  4905. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4906. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4907. return -1;
  4908. }
  4909. if ((nd = npc_name2id(NPCname)) == NULL) {
  4910. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4911. return -1;
  4912. }
  4913. npc_unload_duplicates(nd);
  4914. npc_unload(nd);
  4915. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4916. return 0;
  4917. }
  4918. /*==========================================
  4919. * time in txt for time command (by [Yor])
  4920. *------------------------------------------*/
  4921. char* txt_time(unsigned int duration)
  4922. {
  4923. int days, hours, minutes, seconds;
  4924. char temp[256];
  4925. static char temp1[256];
  4926. memset(temp, '\0', sizeof(temp));
  4927. memset(temp1, '\0', sizeof(temp1));
  4928. days = duration / (60 * 60 * 24);
  4929. duration = duration - (60 * 60 * 24 * days);
  4930. hours = duration / (60 * 60);
  4931. duration = duration - (60 * 60 * hours);
  4932. minutes = duration / 60;
  4933. seconds = duration - (60 * minutes);
  4934. if (days < 2)
  4935. sprintf(temp, msg_txt(219), days); // %d day
  4936. else
  4937. sprintf(temp, msg_txt(220), days); // %d days
  4938. if (hours < 2)
  4939. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4940. else
  4941. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4942. if (minutes < 2)
  4943. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4944. else
  4945. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4946. if (seconds < 2)
  4947. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4948. else
  4949. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4950. return temp1;
  4951. }
  4952. /*==========================================
  4953. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4954. * Calculation management of GM modification (@day/@night GM commands) is done
  4955. *------------------------------------------*/
  4956. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4957. {
  4958. struct TimerData * timer_data;
  4959. struct TimerData * timer_data2;
  4960. time_t time_server; // variable for number of seconds (used with time() function)
  4961. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4962. char temp[256];
  4963. nullpo_retr(-1, sd);
  4964. memset(temp, '\0', sizeof(temp));
  4965. time(&time_server); // get time in seconds since 1/1/1970
  4966. datetime = localtime(&time_server); // convert seconds in structure
  4967. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4968. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4969. clif_displaymessage(fd, temp);
  4970. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4971. if (night_flag == 0)
  4972. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4973. else
  4974. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4975. } else if (battle_config.night_duration == 0)
  4976. if (night_flag == 1) { // we start with night
  4977. timer_data = get_timer(day_timer_tid);
  4978. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4979. clif_displaymessage(fd, temp);
  4980. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4981. } else
  4982. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4983. else if (battle_config.day_duration == 0)
  4984. if (night_flag == 0) { // we start with day
  4985. timer_data = get_timer(night_timer_tid);
  4986. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4987. clif_displaymessage(fd, temp);
  4988. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4989. } else
  4990. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4991. else {
  4992. if (night_flag == 0) {
  4993. timer_data = get_timer(night_timer_tid);
  4994. timer_data2 = get_timer(day_timer_tid);
  4995. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4996. clif_displaymessage(fd, temp);
  4997. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4998. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  4999. else
  5000. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5001. clif_displaymessage(fd, temp);
  5002. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5003. clif_displaymessage(fd, temp);
  5004. } else {
  5005. timer_data = get_timer(day_timer_tid);
  5006. timer_data2 = get_timer(night_timer_tid);
  5007. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5008. clif_displaymessage(fd, temp);
  5009. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5010. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5011. else
  5012. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5013. clif_displaymessage(fd, temp);
  5014. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5015. clif_displaymessage(fd, temp);
  5016. }
  5017. }
  5018. return 0;
  5019. }
  5020. //Added by Coltaro
  5021. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  5022. //Well, using time_t could still work but for some reason that looks like more coding x_x
  5023. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  5024. {
  5025. const int factor_year = 518400; //12*30*24*60 = 518400
  5026. const int factor_month = 43200; //30*24*60 = 43200
  5027. const int factor_day = 1440; //24*60 = 1440
  5028. const int factor_hour = 60;
  5029. *year = jailtime/factor_year;
  5030. jailtime -= *year*factor_year;
  5031. *month = jailtime/factor_month;
  5032. jailtime -= *month*factor_month;
  5033. *day = jailtime/factor_day;
  5034. jailtime -= *day*factor_day;
  5035. *hour = jailtime/factor_hour;
  5036. jailtime -= *hour*factor_hour;
  5037. *minute = jailtime;
  5038. *year = *year > 0? *year : 0;
  5039. *month = *month > 0? *month : 0;
  5040. *day = *day > 0? *day : 0;
  5041. *hour = *hour > 0? *hour : 0;
  5042. *minute = *minute > 0? *minute : 0;
  5043. return;
  5044. }
  5045. /*==========================================
  5046. * @jail <char_name> by [Yor]
  5047. * Special warp! No check with nowarp and nowarpto flag
  5048. *------------------------------------------*/
  5049. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5050. {
  5051. struct map_session_data *pl_sd;
  5052. int x, y;
  5053. unsigned short m_index;
  5054. nullpo_retr(-1, sd);
  5055. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5056. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5057. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5058. return -1;
  5059. }
  5060. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5061. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5062. return -1;
  5063. }
  5064. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5065. { // you can jail only lower or same GM
  5066. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5067. return -1;
  5068. }
  5069. if (pl_sd->sc.data[SC_JAILED].timer != -1)
  5070. {
  5071. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5072. return -1;
  5073. }
  5074. switch(rand() % 2) { //Jail Locations
  5075. case 0:
  5076. m_index = mapindex_name2id(MAP_JAIL);
  5077. x = 24;
  5078. y = 75;
  5079. break;
  5080. default:
  5081. m_index = mapindex_name2id(MAP_JAIL);
  5082. x = 49;
  5083. y = 75;
  5084. break;
  5085. }
  5086. //Duration of INT_MAX to specify infinity.
  5087. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  5088. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5089. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5090. return 0;
  5091. }
  5092. /*==========================================
  5093. * @unjail/@discharge <char_name> by [Yor]
  5094. * Special warp! No check with nowarp and nowarpto flag
  5095. *------------------------------------------*/
  5096. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5097. {
  5098. struct map_session_data *pl_sd;
  5099. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5100. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5101. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5102. return -1;
  5103. }
  5104. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5105. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5106. return -1;
  5107. }
  5108. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5109. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5110. return -1;
  5111. }
  5112. if (pl_sd->sc.data[SC_JAILED].timer == -1)
  5113. {
  5114. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5115. return -1;
  5116. }
  5117. //Reset jail time to 1 sec.
  5118. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  5119. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5120. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5121. return 0;
  5122. }
  5123. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5124. {
  5125. struct map_session_data *pl_sd = NULL;
  5126. int year, month, day, hour, minute, value;
  5127. char * modif_p;
  5128. int jailtime = 0,x,y;
  5129. short m_index = 0;
  5130. nullpo_retr(-1, sd);
  5131. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5132. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5133. return -1;
  5134. }
  5135. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5136. modif_p = atcmd_output;
  5137. year = month = day = hour = minute = 0;
  5138. while (modif_p[0] != '\0') {
  5139. value = atoi(modif_p);
  5140. if (value == 0)
  5141. modif_p++;
  5142. else {
  5143. if (modif_p[0] == '-' || modif_p[0] == '+')
  5144. modif_p++;
  5145. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5146. modif_p++;
  5147. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  5148. minute = value;
  5149. modif_p = modif_p + 2;
  5150. } else if (modif_p[0] == 'h') {
  5151. hour = value;
  5152. modif_p++;
  5153. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5154. day = value;
  5155. modif_p++;
  5156. } else if (modif_p[0] == 'm') {
  5157. month = value;
  5158. modif_p++;
  5159. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5160. year = value;
  5161. modif_p++;
  5162. } else if (modif_p[0] != '\0') {
  5163. modif_p++;
  5164. }
  5165. }
  5166. }
  5167. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5168. clif_displaymessage(fd, "Invalid time for jail command.");
  5169. return -1;
  5170. }
  5171. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5172. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5173. return -1;
  5174. }
  5175. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5176. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5177. return -1;
  5178. }
  5179. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5180. if(jailtime==0) {
  5181. clif_displaymessage(fd, "Invalid time for jail command.");
  5182. return -1;
  5183. }
  5184. //Added by Coltaro
  5185. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1 &&
  5186. pl_sd->sc.data[SC_JAILED].val1 != INT_MAX)
  5187. { //Update the player's jail time
  5188. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  5189. if (jailtime <= 0) {
  5190. jailtime = 0;
  5191. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5192. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5193. } else {
  5194. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5195. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  5196. clif_displaymessage(pl_sd->fd, atcmd_output);
  5197. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  5198. clif_displaymessage(fd, atcmd_output);
  5199. }
  5200. } else if (jailtime < 0) {
  5201. clif_displaymessage(fd, "Invalid time for jail command.");
  5202. return -1;
  5203. }
  5204. //Jail locations, add more as you wish.
  5205. switch(rand()%2)
  5206. {
  5207. case 1: //Jail #1
  5208. m_index = mapindex_name2id(MAP_JAIL);
  5209. x = 49; y = 75;
  5210. break;
  5211. default: //Default Jail
  5212. m_index = mapindex_name2id(MAP_JAIL);
  5213. x = 24; y = 75;
  5214. break;
  5215. }
  5216. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  5217. return 0;
  5218. }
  5219. //By Coltaro
  5220. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5221. {
  5222. int year, month, day, hour, minute;
  5223. nullpo_retr(-1, sd);
  5224. if (!sd->sc.count || sd->sc.data[SC_JAILED].timer == -1) {
  5225. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5226. return -1;
  5227. }
  5228. if (sd->sc.data[SC_JAILED].val1 == INT_MAX) {
  5229. clif_displaymessage(fd, "You have been jailed indefinitely.");
  5230. return 0;
  5231. }
  5232. if (sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  5233. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5234. return -1;
  5235. }
  5236. //Get remaining jail time
  5237. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5238. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  5239. clif_displaymessage(fd, atcmd_output);
  5240. return 0;
  5241. }
  5242. /*==========================================
  5243. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5244. *------------------------------------------*/
  5245. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5246. {
  5247. int id = 0;
  5248. nullpo_retr(-1, sd);
  5249. if (!message || !*message) {
  5250. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5251. return -1;
  5252. }
  5253. if ((id = atoi(message)) > 0)
  5254. { //Acquired an ID
  5255. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5256. id = 0; //Invalid id for either mobs or npcs.
  5257. } else { //Acquired a Name
  5258. if ((id = mobdb_searchname(message)) == 0)
  5259. {
  5260. struct npc_data* nd = npc_name2id(message);
  5261. if (nd != NULL)
  5262. id = nd->n;
  5263. }
  5264. }
  5265. if (id == 0)
  5266. {
  5267. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  5268. return -1;
  5269. }
  5270. if(pc_isriding(sd))
  5271. {
  5272. //FIXME: wrong message [ultramage]
  5273. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  5274. return -1;
  5275. }
  5276. pc_disguise(sd, id);
  5277. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5278. return 0;
  5279. }
  5280. /*==========================================
  5281. * DisguiseAll
  5282. *------------------------------------------*/
  5283. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5284. {
  5285. int mob_id=0, i=0, users;
  5286. struct map_session_data *pl_sd, **pl_allsd;
  5287. nullpo_retr(-1, sd);
  5288. if (!message || !*message) {
  5289. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  5290. return -1;
  5291. }
  5292. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5293. mob_id = atoi(message);
  5294. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  5295. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  5296. return -1;
  5297. }
  5298. pl_allsd = map_getallusers(&users);
  5299. for(i=0; i < users; i++)
  5300. {
  5301. if((pl_sd = pl_allsd[i]))
  5302. pc_disguise(pl_sd, mob_id);
  5303. }
  5304. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5305. return 0;
  5306. }
  5307. /*==========================================
  5308. * @undisguise by [Yor]
  5309. *------------------------------------------*/
  5310. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5311. {
  5312. nullpo_retr(-1, sd);
  5313. if (sd->disguise) {
  5314. pc_disguise(sd, 0);
  5315. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5316. } else {
  5317. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  5318. return -1;
  5319. }
  5320. return 0;
  5321. }
  5322. /*==========================================
  5323. * UndisguiseAll
  5324. *------------------------------------------*/
  5325. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5326. {
  5327. struct map_session_data *pl_sd, **pl_allsd;
  5328. int i, users;
  5329. nullpo_retr(-1, sd);
  5330. pl_allsd = map_getallusers(&users);
  5331. for(i=0; i < users; i++) {
  5332. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5333. pc_disguise(pl_sd, 0);
  5334. }
  5335. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5336. return 0;
  5337. }
  5338. /*==========================================
  5339. * @exp by [Skotlex]
  5340. *------------------------------------------*/
  5341. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5342. {
  5343. char output[200];
  5344. double nextb, nextj;
  5345. nullpo_retr(-1, sd);
  5346. memset(output, '\0', sizeof(output));
  5347. nextb = pc_nextbaseexp(sd);
  5348. if (nextb)
  5349. nextb = sd->status.base_exp*100.0/nextb;
  5350. nextj = pc_nextjobexp(sd);
  5351. if (nextj)
  5352. nextj = sd->status.job_exp*100.0/nextj;
  5353. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5354. clif_displaymessage(fd, output);
  5355. return 0;
  5356. }
  5357. /*==========================================
  5358. * @broadcast by [Valaris]
  5359. *------------------------------------------*/
  5360. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5361. {
  5362. nullpo_retr(-1, sd);
  5363. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5364. if (!message || !*message) {
  5365. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5366. return -1;
  5367. }
  5368. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5369. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5370. return 0;
  5371. }
  5372. /*==========================================
  5373. * @localbroadcast by [Valaris]
  5374. *------------------------------------------*/
  5375. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5376. {
  5377. nullpo_retr(-1, sd);
  5378. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5379. if (!message || !*message) {
  5380. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5381. return -1;
  5382. }
  5383. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  5384. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5385. return 0;
  5386. }
  5387. /*==========================================
  5388. * @email <actual@email> <new@email> by [Yor]
  5389. *------------------------------------------*/
  5390. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5391. {
  5392. char actual_email[100];
  5393. char new_email[100];
  5394. nullpo_retr(-1, sd);
  5395. memset(actual_email, '\0', sizeof(actual_email));
  5396. memset(new_email, '\0', sizeof(new_email));
  5397. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5398. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5399. return -1;
  5400. }
  5401. if (e_mail_check(actual_email) == 0) {
  5402. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  5403. return -1;
  5404. } else if (e_mail_check(new_email) == 0) {
  5405. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  5406. return -1;
  5407. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5408. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  5409. return -1;
  5410. } else if (strcmpi(actual_email, new_email) == 0) {
  5411. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  5412. return -1;
  5413. }
  5414. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5415. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  5416. return 0;
  5417. }
  5418. /*==========================================
  5419. *@effect
  5420. *------------------------------------------*/
  5421. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5422. {
  5423. int type = 0, flag = 0;
  5424. nullpo_retr(-1, sd);
  5425. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  5426. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  5427. return -1;
  5428. }
  5429. clif_specialeffect(&sd->bl, type, flag);
  5430. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  5431. return 0;
  5432. }
  5433. /*==========================================
  5434. * @killer by MouseJstr
  5435. * enable killing players even when not in pvp
  5436. *------------------------------------------*/
  5437. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5438. {
  5439. nullpo_retr(-1, sd);
  5440. sd->state.killer = !sd->state.killer;
  5441. if(sd->state.killer)
  5442. clif_displaymessage(fd, msg_txt(241));
  5443. else {
  5444. clif_displaymessage(fd, msg_txt(287));
  5445. pc_stop_attack(sd);
  5446. }
  5447. return 0;
  5448. }
  5449. /*==========================================
  5450. * @killable by MouseJstr
  5451. * enable other people killing you
  5452. *------------------------------------------*/
  5453. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5454. {
  5455. nullpo_retr(-1, sd);
  5456. sd->state.killable = !sd->state.killable;
  5457. if(sd->state.killable)
  5458. clif_displaymessage(fd, msg_txt(242));
  5459. else {
  5460. clif_displaymessage(fd, msg_txt(288));
  5461. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  5462. }
  5463. return 0;
  5464. }
  5465. /*==========================================
  5466. * @skillon by MouseJstr
  5467. * turn skills on for the map
  5468. *------------------------------------------*/
  5469. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5470. {
  5471. nullpo_retr(-1, sd);
  5472. map[sd->bl.m].flag.noskill = 0;
  5473. clif_displaymessage(fd, msg_txt(244));
  5474. return 0;
  5475. }
  5476. /*==========================================
  5477. * @skilloff by MouseJstr
  5478. * Turn skills off on the map
  5479. *------------------------------------------*/
  5480. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5481. {
  5482. nullpo_retr(-1, sd);
  5483. map[sd->bl.m].flag.noskill = 1;
  5484. clif_displaymessage(fd, msg_txt(243));
  5485. return 0;
  5486. }
  5487. /*==========================================
  5488. * @npcmove by MouseJstr
  5489. * move a npc
  5490. *------------------------------------------*/
  5491. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5492. {
  5493. int x = 0, y = 0, m;
  5494. struct npc_data *nd = 0;
  5495. nullpo_retr(-1, sd);
  5496. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  5497. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  5498. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  5499. return -1;
  5500. }
  5501. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  5502. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  5503. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  5504. {
  5505. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5506. return -1;
  5507. }
  5508. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  5509. {
  5510. clif_displaymessage(fd, "NPC is not on this map.");
  5511. return -1; //Not on a map.
  5512. }
  5513. if (x < 0) x = 0;
  5514. else if (x >= map[m].xs) x = map[m].xs-1;
  5515. if (y < 0) y = 0;
  5516. else if (y >= map[m].ys) y = map[m].ys-1;
  5517. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5518. map_moveblock(&nd->bl, x, y, gettick());
  5519. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  5520. clif_displaymessage(fd, "NPC moved.");
  5521. return 0;
  5522. }
  5523. /*==========================================
  5524. * @addwarp by MouseJstr
  5525. * Create a new static warp point.
  5526. *------------------------------------------*/
  5527. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5528. {
  5529. char w1[64], w3[64], w4[64];
  5530. int x,y,ret;
  5531. nullpo_retr(-1, sd);
  5532. if (!message || !*message || sscanf(message, "%23s %d %d[^\n]", atcmd_player_name, &x, &y) < 3) {
  5533. clif_displaymessage(fd, "usage: @addwarp <mapname (without .gat)> <X> <Y>.");
  5534. return -1;
  5535. }
  5536. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  5537. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  5538. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  5539. ret = npc_parse_warp(w1, "warp", w3, w4);
  5540. sprintf(atcmd_output, "New warp NPC => %s",w3);
  5541. clif_displaymessage(fd, atcmd_output);
  5542. return ret;
  5543. }
  5544. /*==========================================
  5545. * @follow by [MouseJstr]
  5546. * Follow a player .. staying no more then 5 spaces away
  5547. *------------------------------------------*/
  5548. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5549. {
  5550. struct map_session_data *pl_sd = NULL;
  5551. nullpo_retr(-1, sd);
  5552. if (!message || !*message) {
  5553. if (sd->followtarget == -1)
  5554. return -1;
  5555. pc_stop_following (sd);
  5556. clif_displaymessage(fd, "Follow mode OFF.");
  5557. return 0;
  5558. }
  5559. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5560. {
  5561. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5562. return -1;
  5563. }
  5564. if (sd->followtarget == pl_sd->bl.id) {
  5565. pc_stop_following (sd);
  5566. clif_displaymessage(fd, "Follow mode OFF.");
  5567. } else {
  5568. pc_follow(sd, pl_sd->bl.id);
  5569. clif_displaymessage(fd, "Follow mode ON.");
  5570. }
  5571. return 0;
  5572. }
  5573. /*==========================================
  5574. * @dropall by [MouseJstr]
  5575. * Drop all your possession on the ground
  5576. *------------------------------------------*/
  5577. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5578. {
  5579. int i;
  5580. nullpo_retr(-1, sd);
  5581. for (i = 0; i < MAX_INVENTORY; i++) {
  5582. if (sd->status.inventory[i].amount) {
  5583. if(sd->status.inventory[i].equip != 0)
  5584. pc_unequipitem(sd, i, 3);
  5585. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  5586. }
  5587. }
  5588. return 0;
  5589. }
  5590. /*==========================================
  5591. * @storeall by [MouseJstr]
  5592. * Put everything into storage
  5593. *------------------------------------------*/
  5594. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5595. {
  5596. int i;
  5597. nullpo_retr(-1, sd);
  5598. if (sd->state.storage_flag != 1)
  5599. { //Open storage.
  5600. switch (storage_storageopen(sd)) {
  5601. case 2: //Try again
  5602. clif_displaymessage(fd, "run this command again..");
  5603. return 0;
  5604. case 1: //Failure
  5605. clif_displaymessage(fd, "You can't open the storage currently.");
  5606. return -1;
  5607. }
  5608. }
  5609. for (i = 0; i < MAX_INVENTORY; i++) {
  5610. if (sd->status.inventory[i].amount) {
  5611. if(sd->status.inventory[i].equip != 0)
  5612. pc_unequipitem(sd, i, 3);
  5613. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  5614. }
  5615. }
  5616. storage_storageclose(sd);
  5617. clif_displaymessage(fd, "It is done");
  5618. return 0;
  5619. }
  5620. /*==========================================
  5621. * @skillid by [MouseJstr]
  5622. * lookup a skill by name
  5623. *------------------------------------------*/
  5624. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5625. {
  5626. int skillen, idx;
  5627. nullpo_retr(-1, sd);
  5628. if (!message || !*message)
  5629. {
  5630. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  5631. return -1;
  5632. }
  5633. skillen = strlen(message);
  5634. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  5635. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  5636. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  5637. {
  5638. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5639. clif_displaymessage(fd, atcmd_output);
  5640. }
  5641. }
  5642. return 0;
  5643. }
  5644. /*==========================================
  5645. * @useskill by [MouseJstr]
  5646. * A way of using skills without having to find them in the skills menu
  5647. *------------------------------------------*/
  5648. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5649. {
  5650. struct map_session_data *pl_sd = NULL;
  5651. struct block_list *bl;
  5652. int skillnum;
  5653. int skilllv;
  5654. char target[100];
  5655. nullpo_retr(-1, sd);
  5656. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5657. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5658. return -1;
  5659. }
  5660. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5661. {
  5662. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5663. return -1;
  5664. }
  5665. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5666. {
  5667. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5668. return -1;
  5669. }
  5670. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  5671. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5672. bl = &sd->hd->bl;
  5673. else
  5674. bl = &sd->bl;
  5675. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5676. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5677. else
  5678. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5679. return 0;
  5680. }
  5681. /*==========================================
  5682. * @displayskill by [Skotlex]
  5683. * Debug command to locate new skill IDs. It sends the
  5684. * three possible skill-effect packets to the area.
  5685. *------------------------------------------*/
  5686. int atcommand_displayskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5687. {
  5688. struct status_data * status;
  5689. unsigned int tick;
  5690. int skillnum;
  5691. int skilllv = 1;
  5692. nullpo_retr(-1, sd);
  5693. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5694. {
  5695. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5696. return -1;
  5697. }
  5698. status = status_get_status_data(&sd->bl);
  5699. tick = gettick();
  5700. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion,
  5701. 1, 1, skillnum, skilllv, 5);
  5702. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5703. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5704. return 0;
  5705. }
  5706. /*==========================================
  5707. * @skilltree by [MouseJstr]
  5708. * prints the skill tree for a player required to get to a skill
  5709. *------------------------------------------*/
  5710. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5711. {
  5712. struct map_session_data *pl_sd = NULL;
  5713. int skillnum, skillidx = -1;
  5714. int meets = 1, j, c=0;
  5715. char target[NAME_LENGTH], *tbl;
  5716. struct skill_tree_entry *ent;
  5717. nullpo_retr(-1, sd);
  5718. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5719. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5720. return -1;
  5721. }
  5722. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5723. {
  5724. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5725. return -1;
  5726. }
  5727. c = pc_calc_skilltree_normalize_job(pl_sd);
  5728. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5729. tbl = job_name(c);
  5730. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  5731. tbl, pc_checkskill(pl_sd, 1));
  5732. clif_displaymessage(fd, atcmd_output);
  5733. for (j = 0; skill_tree[c][j].id != 0; j++) {
  5734. if (skill_tree[c][j].id == skillnum) {
  5735. skillidx = j;
  5736. break;
  5737. }
  5738. }
  5739. if (skillidx == -1) {
  5740. sprintf(atcmd_output, "I do not believe the player can use that skill");
  5741. clif_displaymessage(fd, atcmd_output);
  5742. return 0;
  5743. }
  5744. ent = &skill_tree[c][skillidx];
  5745. for(j=0;j<5;j++)
  5746. if( ent->need[j].id &&
  5747. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5748. {
  5749. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  5750. sprintf(atcmd_output, "player requires level %d of skill %s",
  5751. ent->need[j].lv, desc);
  5752. clif_displaymessage(fd, atcmd_output);
  5753. meets = 0;
  5754. }
  5755. if (meets == 1) {
  5756. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5757. clif_displaymessage(fd, atcmd_output);
  5758. }
  5759. return 0;
  5760. }
  5761. // Hand a ring with partners name on it to this char
  5762. void getring (struct map_session_data* sd)
  5763. {
  5764. int flag, item_id;
  5765. struct item item_tmp;
  5766. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5767. memset(&item_tmp, 0, sizeof(item_tmp));
  5768. item_tmp.nameid = item_id;
  5769. item_tmp.identify = 1;
  5770. item_tmp.card[0] = 255;
  5771. item_tmp.card[2] = sd->status.partner_id;
  5772. item_tmp.card[3] = sd->status.partner_id >> 16;
  5773. //Logs (A)dmins items [Lupus]
  5774. if(log_config.enable_logs&0x400)
  5775. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  5776. if((flag = pc_additem(sd,&item_tmp,1))) {
  5777. clif_additem(sd,0,0,flag);
  5778. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5779. }
  5780. }
  5781. /*==========================================
  5782. * @marry by [MouseJstr], fixed by Lupus
  5783. * Marry two players
  5784. *------------------------------------------*/
  5785. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5786. {
  5787. struct map_session_data *pl_sd1 = NULL;
  5788. struct map_session_data *pl_sd2 = NULL;
  5789. char player1[128], player2[128]; //Length used for return error msgs
  5790. nullpo_retr(-1, sd);
  5791. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5792. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5793. return -1;
  5794. }
  5795. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5796. sprintf(player2, "Cannot find player '%s' online", player1);
  5797. clif_displaymessage(fd, player2);
  5798. return -1;
  5799. }
  5800. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5801. sprintf(player1, "Cannot find player '%s' online", player2);
  5802. clif_displaymessage(fd, player1);
  5803. return -1;
  5804. }
  5805. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5806. clif_displaymessage(fd, "They are married.. wish them well");
  5807. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5808. // Auto-give named rings (Aru)
  5809. getring (pl_sd1);
  5810. getring (pl_sd2);
  5811. return 0;
  5812. }
  5813. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5814. return -1;
  5815. }
  5816. /*==========================================
  5817. * @divorce by [MouseJstr], fixed by [Lupus]
  5818. * divorce two players
  5819. *------------------------------------------*/
  5820. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5821. {
  5822. struct map_session_data *pl_sd = NULL;
  5823. nullpo_retr(-1, sd);
  5824. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5825. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5826. return -1;
  5827. }
  5828. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5829. {
  5830. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5831. return -1;
  5832. }
  5833. if (pc_divorce(pl_sd) != 0) {
  5834. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5835. clif_displaymessage(fd, atcmd_output);
  5836. return -1;
  5837. }
  5838. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5839. clif_displaymessage(fd, atcmd_output);
  5840. return 0;
  5841. }
  5842. #ifdef DMALLOC
  5843. unsigned long dmark_;
  5844. int atcommand_dmstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5845. {
  5846. dmark_ = dmalloc_mark();
  5847. clif_displaymessage(fd, "debug mark set");
  5848. return 0;
  5849. }
  5850. int atcommand_dmtick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5851. {
  5852. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  5853. dmark_ = dmalloc_mark();
  5854. clif_displaymessage(fd, "malloc changes logged");
  5855. return 0;
  5856. }
  5857. #endif
  5858. /*==========================================
  5859. * @changelook by [Celest]
  5860. *------------------------------------------*/
  5861. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5862. {
  5863. int i, j = 0, k = 0;
  5864. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5865. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5866. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5867. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5868. return -1;
  5869. } else if (i == 2) {
  5870. if (j < 1) j = 1;
  5871. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5872. j = pos[j - 1];
  5873. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5874. k = j; // swap
  5875. j = LOOK_HEAD_TOP;
  5876. }
  5877. clif_changelook(&sd->bl,j,k);
  5878. return 0;
  5879. }
  5880. /*==========================================
  5881. * @autotrade by durf (changed by Lupus)
  5882. * Turns on/off Autotrade for a specific player
  5883. *------------------------------------------*/
  5884. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5885. {
  5886. nullpo_retr(-1, sd);
  5887. if (sd->vender_id) //check if player's vending
  5888. {
  5889. sd->state.autotrade = 1;
  5890. clif_authfail_fd(fd, 15);
  5891. }
  5892. else
  5893. {
  5894. //"You should be vending to use @Autotrade."
  5895. clif_displaymessage(fd, msg_txt(549));
  5896. }
  5897. return 0;
  5898. }
  5899. /*==========================================
  5900. * @changegm by durf (changed by Lupus)
  5901. * Changes Master of your Guild to a specified guild member
  5902. *------------------------------------------*/
  5903. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5904. {
  5905. struct guild *g;
  5906. struct map_session_data *pl_sd;
  5907. nullpo_retr(-1, sd);
  5908. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5909. {
  5910. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5911. return -1;
  5912. }
  5913. if (strlen(message)==0)
  5914. {
  5915. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5916. return -1;
  5917. }
  5918. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5919. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5920. return -1;
  5921. }
  5922. guild_gm_change(sd->status.guild_id, pl_sd);
  5923. return 0;
  5924. }
  5925. /*==========================================
  5926. * @changeleader by Skotlex
  5927. * Changes the leader of a party.
  5928. *------------------------------------------*/
  5929. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5930. {
  5931. struct party_data *p;
  5932. struct map_session_data *pl_sd;
  5933. int mi, pl_mi;
  5934. nullpo_retr(-1, sd);
  5935. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5936. { //Need to be a party leader.
  5937. clif_displaymessage(fd, msg_txt(282));
  5938. return -1;
  5939. }
  5940. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  5941. if (mi == MAX_PARTY)
  5942. return -1; //Shouldn't happen
  5943. if (!p->party.member[mi].leader)
  5944. { //Need to be a party leader.
  5945. clif_displaymessage(fd, msg_txt(282));
  5946. return -1;
  5947. }
  5948. if (strlen(message)==0)
  5949. {
  5950. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5951. return -1;
  5952. }
  5953. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  5954. clif_displaymessage(fd, msg_txt(283));
  5955. return -1;
  5956. }
  5957. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  5958. if (pl_mi == MAX_PARTY)
  5959. return -1; //Shouldn't happen
  5960. //Change leadership.
  5961. p->party.member[mi].leader = 0;
  5962. if (p->data[mi].sd->fd)
  5963. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  5964. p->party.member[pl_mi].leader = 1;
  5965. if (p->data[pl_mi].sd->fd)
  5966. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  5967. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  5968. //Update info.
  5969. clif_party_info(p,NULL);
  5970. return 0;
  5971. }
  5972. /*==========================================
  5973. * @partyoption by Skotlex
  5974. * Used to change the item share setting of a party.
  5975. *------------------------------------------*/
  5976. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5977. {
  5978. struct party_data *p;
  5979. int mi, option;
  5980. char w1[15], w2[15];
  5981. nullpo_retr(-1, sd);
  5982. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5983. {
  5984. clif_displaymessage(fd, msg_txt(282));
  5985. return -1;
  5986. }
  5987. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  5988. if (mi == MAX_PARTY)
  5989. return -1; //Shouldn't happen
  5990. if (!p->party.member[mi].leader)
  5991. {
  5992. clif_displaymessage(fd, msg_txt(282));
  5993. return -1;
  5994. }
  5995. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5996. {
  5997. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  5998. return -1;
  5999. }
  6000. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  6001. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  6002. //Change item share type.
  6003. if (option != p->party.item)
  6004. party_changeoption(sd, p->party.exp, option);
  6005. else
  6006. clif_displaymessage(fd, msg_txt(286));
  6007. return 0;
  6008. }
  6009. /*==========================================
  6010. * @autoloot by Upa-Kun
  6011. * Turns on/off AutoLoot for a specific player
  6012. *------------------------------------------*/
  6013. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6014. {
  6015. int rate;
  6016. double drate;
  6017. nullpo_retr(-1, sd);
  6018. // autoloot command without value
  6019. if(!message || !*message)
  6020. {
  6021. if (sd->state.autoloot)
  6022. rate = 0;
  6023. else
  6024. rate = 10000;
  6025. } else {
  6026. drate = atof(message);
  6027. rate = (int)(drate*100);
  6028. }
  6029. if (rate < 0) rate = 0;
  6030. if (rate > 10000) rate = 10000;
  6031. sd->state.autoloot = rate;
  6032. if (sd->state.autoloot) {
  6033. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6034. clif_displaymessage(fd, atcmd_output);
  6035. }else
  6036. clif_displaymessage(fd, "Autoloot is now off.");
  6037. return 0;
  6038. }
  6039. /*==========================================
  6040. * It is made to rain.
  6041. *------------------------------------------*/
  6042. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6043. {
  6044. nullpo_retr(-1, sd);
  6045. if (map[sd->bl.m].flag.rain) {
  6046. map[sd->bl.m].flag.rain=0;
  6047. clif_weather(sd->bl.m);
  6048. clif_displaymessage(fd, "The rain has stopped.");
  6049. } else {
  6050. map[sd->bl.m].flag.rain=1;
  6051. clif_weather(sd->bl.m);
  6052. clif_displaymessage(fd, "It is made to rain.");
  6053. }
  6054. return 0;
  6055. }
  6056. /*==========================================
  6057. * It is made to snow.
  6058. *------------------------------------------*/
  6059. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6060. {
  6061. nullpo_retr(-1, sd);
  6062. if (map[sd->bl.m].flag.snow) {
  6063. map[sd->bl.m].flag.snow=0;
  6064. clif_weather(sd->bl.m);
  6065. clif_displaymessage(fd, "Snow has stopped falling.");
  6066. } else {
  6067. map[sd->bl.m].flag.snow=1;
  6068. clif_weather(sd->bl.m);
  6069. clif_displaymessage(fd, "It is made to snow.");
  6070. }
  6071. return 0;
  6072. }
  6073. /*==========================================
  6074. * Cherry tree snowstorm is made to fall. (Sakura)
  6075. *------------------------------------------*/
  6076. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6077. {
  6078. nullpo_retr(-1, sd);
  6079. if (map[sd->bl.m].flag.sakura) {
  6080. map[sd->bl.m].flag.sakura=0;
  6081. clif_weather(sd->bl.m);
  6082. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6083. } else {
  6084. map[sd->bl.m].flag.sakura=1;
  6085. clif_weather(sd->bl.m);
  6086. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6087. }
  6088. return 0;
  6089. }
  6090. /*==========================================
  6091. * Clouds appear.
  6092. *------------------------------------------*/
  6093. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6094. {
  6095. nullpo_retr(-1, sd);
  6096. if (map[sd->bl.m].flag.clouds) {
  6097. map[sd->bl.m].flag.clouds=0;
  6098. clif_weather(sd->bl.m);
  6099. clif_displaymessage(fd, "The clouds has disappear.");
  6100. } else {
  6101. map[sd->bl.m].flag.clouds=1;
  6102. clif_weather(sd->bl.m);
  6103. clif_displaymessage(fd, "Clouds appear.");
  6104. }
  6105. return 0;
  6106. }
  6107. /*==========================================
  6108. * Different type of clouds using effect 516
  6109. *------------------------------------------*/
  6110. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6111. {
  6112. nullpo_retr(-1, sd);
  6113. if (map[sd->bl.m].flag.clouds2) {
  6114. map[sd->bl.m].flag.clouds2=0;
  6115. clif_weather(sd->bl.m);
  6116. clif_displaymessage(fd, "The alternative clouds disappear.");
  6117. } else {
  6118. map[sd->bl.m].flag.clouds2=1;
  6119. clif_weather(sd->bl.m);
  6120. clif_displaymessage(fd, "Alternative clouds appear.");
  6121. }
  6122. return 0;
  6123. }
  6124. /*==========================================
  6125. * Fog hangs over.
  6126. *------------------------------------------*/
  6127. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6128. {
  6129. nullpo_retr(-1, sd);
  6130. if (map[sd->bl.m].flag.fog) {
  6131. map[sd->bl.m].flag.fog=0;
  6132. clif_weather(sd->bl.m);
  6133. clif_displaymessage(fd, "The fog has gone.");
  6134. } else {
  6135. map[sd->bl.m].flag.fog=1;
  6136. clif_weather(sd->bl.m);
  6137. clif_displaymessage(fd, "Fog hangs over.");
  6138. }
  6139. return 0;
  6140. }
  6141. /*==========================================
  6142. * Fallen leaves fall.
  6143. *------------------------------------------*/
  6144. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6145. {
  6146. nullpo_retr(-1, sd);
  6147. if (map[sd->bl.m].flag.leaves) {
  6148. map[sd->bl.m].flag.leaves=0;
  6149. clif_weather(sd->bl.m);
  6150. clif_displaymessage(fd, "Leaves no longer fall.");
  6151. } else {
  6152. map[sd->bl.m].flag.leaves=1;
  6153. clif_weather(sd->bl.m);
  6154. clif_displaymessage(fd, "Fallen leaves fall.");
  6155. }
  6156. return 0;
  6157. }
  6158. /*==========================================
  6159. * Fireworks appear.
  6160. *------------------------------------------*/
  6161. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6162. {
  6163. nullpo_retr(-1, sd);
  6164. if (map[sd->bl.m].flag.fireworks) {
  6165. map[sd->bl.m].flag.fireworks=0;
  6166. clif_weather(sd->bl.m);
  6167. clif_displaymessage(fd, "Fireworks are ended.");
  6168. } else {
  6169. map[sd->bl.m].flag.fireworks=1;
  6170. clif_weather(sd->bl.m);
  6171. clif_displaymessage(fd, "Fireworks are launched.");
  6172. }
  6173. return 0;
  6174. }
  6175. /*==========================================
  6176. * Clearing Weather Effects by Dexity
  6177. *------------------------------------------*/
  6178. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6179. {
  6180. nullpo_retr(-1, sd);
  6181. map[sd->bl.m].flag.rain=0;
  6182. map[sd->bl.m].flag.snow=0;
  6183. map[sd->bl.m].flag.sakura=0;
  6184. map[sd->bl.m].flag.clouds=0;
  6185. map[sd->bl.m].flag.clouds2=0;
  6186. map[sd->bl.m].flag.fog=0;
  6187. map[sd->bl.m].flag.fireworks=0;
  6188. map[sd->bl.m].flag.leaves=0;
  6189. clif_weather(sd->bl.m);
  6190. clif_displaymessage(fd, msg_txt(291));
  6191. return 0;
  6192. }
  6193. /*===============================================================
  6194. * Sound Command - plays a sound for everyone around! [Codemaster]
  6195. *---------------------------------------------------------------*/
  6196. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6197. {
  6198. char sound_file[100];
  6199. memset(sound_file, '\0', sizeof(sound_file));
  6200. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6201. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6202. return -1;
  6203. }
  6204. if(strstr(sound_file, ".wav") == NULL)
  6205. strcat(sound_file, ".wav");
  6206. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  6207. return 0;
  6208. }
  6209. /*==========================================
  6210. * MOB Search
  6211. *------------------------------------------*/
  6212. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  6213. {
  6214. int mob_id,fd;
  6215. static int number=0;
  6216. struct mob_data *md;
  6217. nullpo_retr(0, bl);
  6218. if(!ap){
  6219. number=0;
  6220. return 0;
  6221. }
  6222. mob_id = va_arg(ap,int);
  6223. fd = va_arg(ap,int);
  6224. md = (struct mob_data *)bl;
  6225. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  6226. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  6227. ++number,bl->x, bl->y,md->name);
  6228. clif_displaymessage(fd, atcmd_output);
  6229. }
  6230. return 0;
  6231. }
  6232. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6233. {
  6234. char mob_name[100];
  6235. int mob_id,map_id = 0;
  6236. nullpo_retr(-1, sd);
  6237. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6238. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  6239. return -1;
  6240. }
  6241. if ((mob_id = atoi(mob_name)) == 0)
  6242. mob_id = mobdb_searchname(mob_name);
  6243. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6244. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6245. clif_displaymessage(fd, atcmd_output);
  6246. return -1;
  6247. }
  6248. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6249. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6250. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6251. map_id = sd->bl.m;
  6252. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  6253. clif_displaymessage(fd, atcmd_output);
  6254. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  6255. atmobsearch_sub(&sd->bl,0); // reset the counter
  6256. return 0;
  6257. }
  6258. /*==========================================
  6259. * @cleanmap - cleans items on the ground
  6260. *------------------------------------------*/
  6261. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  6262. {
  6263. nullpo_retr(0, bl);
  6264. map_clearflooritem(bl->id);
  6265. return 0;
  6266. }
  6267. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6268. {
  6269. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  6270. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  6271. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  6272. BL_ITEM);
  6273. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  6274. return 0;
  6275. }
  6276. /*==========================================
  6277. * make a NPC/PET talk
  6278. *------------------------------------------*/
  6279. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6280. {
  6281. char name[NAME_LENGTH],mes[100],temp[100];
  6282. struct npc_data *nd;
  6283. if (sd->sc.count && //no "chatting" while muted.
  6284. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  6285. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  6286. return -1;
  6287. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  6288. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  6289. return -1;
  6290. }
  6291. if (!(nd = npc_name2id(name))) {
  6292. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  6293. return -1;
  6294. }
  6295. strtok(name, "#"); // discard extra name identifier if present
  6296. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6297. clif_message(&nd->bl, temp);
  6298. return 0;
  6299. }
  6300. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6301. {
  6302. char mes[100],temp[100];
  6303. struct pet_data *pd;
  6304. const char* emo[] = { "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6305. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6306. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6307. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  6308. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  6309. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", NULL };
  6310. nullpo_retr(-1, sd);
  6311. if(!sd->status.pet_id || !(pd=sd->pd))
  6312. {
  6313. clif_displaymessage(fd, msg_txt(184));
  6314. return -1;
  6315. }
  6316. if (sd->sc.count && //no "chatting" while muted.
  6317. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  6318. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  6319. return -1;
  6320. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6321. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  6322. return -1;
  6323. }
  6324. if (message[0] == '/') {
  6325. int i;
  6326. for (i = 0; emo[i] != NULL; i++) {
  6327. if (!stricmp(message, emo[i])) {
  6328. clif_emotion(&pd->bl, i);
  6329. return 0;
  6330. }
  6331. }
  6332. }
  6333. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6334. clif_message(&pd->bl, temp);
  6335. return 0;
  6336. }
  6337. /*==========================================
  6338. * @users - displays the number of players present on each map (percentage)
  6339. *------------------------------------------*/
  6340. static struct dbt *users_db = NULL;
  6341. static int users_all;
  6342. static int atcommand_users_sub1(struct map_session_data* sd,va_list va)
  6343. {
  6344. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  6345. users_all++;
  6346. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  6347. return 0;
  6348. }
  6349. static int atcommand_users_sub2(DBKey key,void* val,va_list va)
  6350. {
  6351. char buf[256];
  6352. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  6353. sprintf(buf,"%s: %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  6354. clif_displaymessage(sd->fd,buf);
  6355. return 0;
  6356. }
  6357. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6358. {
  6359. char buf[256];
  6360. users_all = 0;
  6361. users_db->clear(users_db, NULL);
  6362. clif_foreachclient(atcommand_users_sub1);
  6363. users_db->foreach(users_db,atcommand_users_sub2,sd);
  6364. sprintf(buf,"all: %d",users_all);
  6365. clif_displaymessage(fd,buf);
  6366. return 0;
  6367. }
  6368. /*==========================================
  6369. *
  6370. *------------------------------------------*/
  6371. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6372. {
  6373. pc_resetstate(sd);
  6374. pc_resetskill(sd,1);
  6375. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  6376. clif_displaymessage(fd, atcmd_output);
  6377. return 0;
  6378. }
  6379. /*==========================================
  6380. *
  6381. *------------------------------------------*/
  6382. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6383. {
  6384. char name[NAME_LENGTH];
  6385. int mob_id = 0;
  6386. int duration = 0;
  6387. struct mob_data *md;
  6388. unsigned int tick=gettick();
  6389. nullpo_retr(-1, sd);
  6390. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  6391. {
  6392. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  6393. return -1;
  6394. }
  6395. if (duration < 1)
  6396. duration =1;
  6397. else if (duration > 60)
  6398. duration =60;
  6399. if ((mob_id = atoi(name)) == 0)
  6400. mob_id = mobdb_searchname(name);
  6401. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6402. {
  6403. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6404. return -1;
  6405. }
  6406. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  6407. if(!md)
  6408. return -1;
  6409. md->master_id=sd->bl.id;
  6410. md->special_state.ai=1;
  6411. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6412. clif_misceffect2(&md->bl,344);
  6413. mob_spawn(md);
  6414. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6415. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  6416. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  6417. return 0;
  6418. }
  6419. /*==========================================
  6420. * @adjcmdlvl by [MouseJstr]
  6421. *
  6422. * Temp adjust the GM level required to use a GM command
  6423. * Useful during beta testing to allow players to use GM commands for short periods of time
  6424. *------------------------------------------*/
  6425. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6426. {
  6427. int i, newlev;
  6428. char cmd[100];
  6429. nullpo_retr(-1, sd);
  6430. if (!message || !*message || sscanf(message, "%d %99s", &newlev, cmd) != 2)
  6431. {
  6432. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  6433. return -1;
  6434. }
  6435. if (newlev > pc_isGM(sd))
  6436. {
  6437. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  6438. return -1;
  6439. }
  6440. for (i = 0; atcommand_info[i].command && atcommand_info[i].type != AtCommand_None; i++)
  6441. {
  6442. if (strcmpi(cmd, atcommand_info[i].command+1) != 0)
  6443. continue;
  6444. if (atcommand_info[i].level > pc_isGM(sd))
  6445. {
  6446. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  6447. return -1;
  6448. }
  6449. atcommand_info[i].level = newlev;
  6450. clif_displaymessage(fd, "@command level changed.");
  6451. return 0;
  6452. }
  6453. clif_displaymessage(fd, "@command not found.");
  6454. return -1;
  6455. }
  6456. /*==========================================
  6457. * @adjgmlvl by [MouseJstr]
  6458. * Create a temp GM
  6459. * Useful during beta testing to allow players to use GM commands for short periods of time
  6460. *------------------------------------------*/
  6461. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6462. {
  6463. int newlev;
  6464. char user[NAME_LENGTH];
  6465. struct map_session_data *pl_sd;
  6466. nullpo_retr(-1, sd);
  6467. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  6468. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  6469. return -1;
  6470. }
  6471. if ( (pl_sd = map_nick2sd(user)) == NULL )
  6472. {
  6473. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6474. return -1;
  6475. }
  6476. pc_set_gm_level(pl_sd->status.account_id, newlev);
  6477. return 0;
  6478. }
  6479. /*==========================================
  6480. * @trade by [MouseJstr]
  6481. * Open a trade window with a remote player
  6482. *------------------------------------------*/
  6483. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6484. {
  6485. struct map_session_data *pl_sd = NULL;
  6486. nullpo_retr(-1, sd);
  6487. if (!message || !*message) {
  6488. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  6489. return -1;
  6490. }
  6491. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  6492. {
  6493. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6494. return -1;
  6495. }
  6496. trade_traderequest(sd, pl_sd);
  6497. return 0;
  6498. }
  6499. /*==========================================
  6500. * @setbattleflag by [MouseJstr]
  6501. * set a battle_config flag without having to reboot
  6502. *------------------------------------------*/
  6503. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6504. {
  6505. char flag[128], value[128];
  6506. nullpo_retr(-1, sd);
  6507. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  6508. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  6509. return -1;
  6510. }
  6511. if (battle_set_value(flag, value) == 0)
  6512. {
  6513. clif_displaymessage(fd, "unknown battle_config flag");
  6514. return -1;
  6515. }
  6516. clif_displaymessage(fd, "battle_config set as requested");
  6517. return 0;
  6518. }
  6519. /*==========================================
  6520. * @unmute [Valaris]
  6521. *------------------------------------------*/
  6522. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6523. {
  6524. struct map_session_data *pl_sd = NULL;
  6525. nullpo_retr(-1, sd);
  6526. if (!message || !*message) {
  6527. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  6528. return -1;
  6529. }
  6530. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  6531. {
  6532. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6533. return -1;
  6534. }
  6535. if(pl_sd->sc.data[SC_NOCHAT].timer == -1) {
  6536. clif_displaymessage(sd->fd,"Player is not muted");
  6537. return -1;
  6538. }
  6539. pl_sd->status.manner = 0;
  6540. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  6541. clif_displaymessage(sd->fd,"Player unmuted");
  6542. return 0;
  6543. }
  6544. /*==========================================
  6545. * @uptime by MC Cameri
  6546. *------------------------------------------*/
  6547. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6548. {
  6549. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6550. minute = 60, days = 0, hours = 0, minutes = 0;
  6551. nullpo_retr(-1, sd);
  6552. seconds = get_uptime();
  6553. days = seconds/day;
  6554. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6555. hours = seconds/hour;
  6556. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6557. minutes = seconds/minute;
  6558. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6559. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  6560. clif_displaymessage(fd, atcmd_output);
  6561. return 0;
  6562. }
  6563. /*==========================================
  6564. * @changesex <sex>
  6565. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  6566. *------------------------------------------*/
  6567. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6568. {
  6569. nullpo_retr(-1, sd);
  6570. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  6571. return 0;
  6572. }
  6573. /*================================================
  6574. * @mute - Mutes a player for a set amount of time
  6575. *------------------------------------------------*/
  6576. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6577. {
  6578. struct map_session_data *pl_sd = NULL;
  6579. int manner;
  6580. nullpo_retr(-1, sd);
  6581. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6582. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  6583. return -1;
  6584. }
  6585. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  6586. {
  6587. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6588. return -1;
  6589. }
  6590. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  6591. {
  6592. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6593. return -1;
  6594. }
  6595. clif_GM_silence(sd, pl_sd, 0);
  6596. pl_sd->status.manner -= manner;
  6597. if(pl_sd->status.manner < 0)
  6598. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6599. return 0;
  6600. }
  6601. /*==========================================
  6602. * @refresh (like @jumpto <<yourself>>)
  6603. *------------------------------------------*/
  6604. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6605. {
  6606. nullpo_retr(-1, sd);
  6607. clif_refresh(sd);
  6608. return 0;
  6609. }
  6610. /*==========================================
  6611. * @petid <part of pet name>
  6612. * => Displays a list of matching pets.
  6613. *------------------------------------------*/
  6614. int atcommand_petid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6615. {
  6616. char searchtext[100];
  6617. char temp0[100];
  6618. int cnt = 0, i = 0;
  6619. nullpo_retr(-1, sd);
  6620. if (!message || !*message || sscanf(message, "%99s", searchtext) < 1)
  6621. {
  6622. clif_displaymessage(fd, "Please, enter a pet name (usage: @petid <part of pet name>).");
  6623. return -1;
  6624. }
  6625. snprintf(temp0, sizeof(temp0), "First %i search results for: %s", MAX_SEARCH, searchtext);
  6626. clif_displaymessage(fd,temp0);
  6627. for (i = 0; i < MAX_PET_DB; i++)
  6628. {
  6629. if (stristr(pet_db[i].name, searchtext) || stristr(pet_db[i].jname, searchtext))
  6630. {
  6631. cnt++;
  6632. if (cnt <= MAX_SEARCH) { // limits the number of search results
  6633. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_, pet_db[i].jname);
  6634. clif_displaymessage(fd, temp0);
  6635. }
  6636. }
  6637. }
  6638. snprintf(temp0, sizeof(temp0), "%i pets have '%s' in their name.", cnt, searchtext);
  6639. clif_displaymessage(fd, temp0);
  6640. return 0;
  6641. }
  6642. /*==========================================
  6643. * @identify
  6644. * => GM's magnifier.
  6645. *------------------------------------------*/
  6646. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6647. {
  6648. int i,num;
  6649. nullpo_retr(-1, sd);
  6650. for(i=num=0;i<MAX_INVENTORY;i++){
  6651. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6652. num++;
  6653. }
  6654. }
  6655. if (num > 0) {
  6656. clif_item_identify_list(sd);
  6657. } else {
  6658. clif_displaymessage(fd,"There are no items to appraise.");
  6659. }
  6660. return 0;
  6661. }
  6662. /*==========================================
  6663. * @gmotd (Global MOTD)
  6664. * by davidsiaw :P
  6665. *------------------------------------------*/
  6666. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6667. {
  6668. char buf[256];
  6669. FILE *fp;
  6670. nullpo_retr(-1, sd);
  6671. if((fp = fopen(motd_txt, "r"))!=NULL){
  6672. while(fgets(buf, sizeof(buf), fp) != NULL)
  6673. {
  6674. int i;
  6675. if (buf[0] == '/' && buf[1] == '/')
  6676. continue;
  6677. for(i=0; buf[i]; i++){
  6678. if(buf[i]=='\r' || buf[i]=='\n'){
  6679. buf[i]=0;
  6680. break;
  6681. }
  6682. }
  6683. intif_GMmessage(buf,strlen(buf)+1,8);
  6684. }
  6685. fclose(fp);
  6686. }
  6687. return 0;
  6688. }
  6689. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6690. {
  6691. int effect = 0;
  6692. nullpo_retr(-1, sd);
  6693. if (!message || !*message)
  6694. return -1;
  6695. if (sscanf(message, "%d", &effect) < 1)
  6696. return -1;
  6697. clif_misceffect(&sd->bl,effect);
  6698. return 0;
  6699. }
  6700. /*==========================================
  6701. * Jump to a player by PID number
  6702. * Original by Dino9021
  6703. * Added in by nsstrunks
  6704. *------------------------------------------*/
  6705. int atcommand_jumptoid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6706. {
  6707. int aid=0;
  6708. struct map_session_data *pl_sd;
  6709. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6710. if (!message || (aid = atoi(message)) == 0) {
  6711. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  6712. return -1;
  6713. }
  6714. pl_sd = map_id2sd(aid);
  6715. if (!pl_sd) {
  6716. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  6717. return -1;
  6718. }
  6719. if (map[pl_sd->bl.m].flag.nowarpto &&
  6720. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  6721. {
  6722. clif_displaymessage(fd, msg_txt(247));
  6723. return -1;
  6724. }
  6725. if (map[sd->bl.m].flag.nowarp &&
  6726. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  6727. {
  6728. clif_displaymessage(fd, msg_txt(248));
  6729. return -1;
  6730. }
  6731. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  6732. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  6733. clif_displaymessage(fd, atcmd_output);
  6734. return 0;
  6735. }
  6736. /*==========================================
  6737. * Recall a player by PID number
  6738. * Original by Dino9021
  6739. * Added in by nsstrunks
  6740. *------------------------------------------*/
  6741. int atcommand_recallid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6742. {
  6743. int aid=0;
  6744. struct map_session_data *pl_sd;
  6745. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6746. if (!message || (aid = atoi(message)) == 0) {
  6747. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  6748. return -1;
  6749. }
  6750. pl_sd = map_id2sd(aid);
  6751. if (!pl_sd) {
  6752. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  6753. return -1;
  6754. }
  6755. if (pc_isGM(sd) < pc_isGM(pl_sd))
  6756. { // you can recall only lower or same level
  6757. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6758. return -1;
  6759. }
  6760. if (map[pl_sd->bl.m].flag.nowarpto &&
  6761. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  6762. {
  6763. clif_displaymessage(fd, msg_txt(247));
  6764. return -1;
  6765. }
  6766. if (map[sd->bl.m].flag.nowarp &&
  6767. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  6768. {
  6769. clif_displaymessage(fd, msg_txt(248));
  6770. return -1;
  6771. }
  6772. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  6773. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  6774. clif_displaymessage(fd, atcmd_output);
  6775. return 0;
  6776. }
  6777. /*==========================================
  6778. * Kick a player by PID number
  6779. * Original by Dino9021
  6780. * Added in by nsstrunks
  6781. *------------------------------------------*/
  6782. int atcommand_kickid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6783. {
  6784. struct map_session_data *pl_sd;
  6785. int aid=0;
  6786. if (!message || (aid = atoi(message)) == 0) {
  6787. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  6788. return -1;
  6789. }
  6790. pl_sd = map_id2sd(aid);
  6791. if (!pl_sd) {
  6792. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6793. return -1;
  6794. }
  6795. if (pc_isGM(sd) < pc_isGM(pl_sd))
  6796. { // you can kick only lower or same gm level
  6797. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6798. return -1;
  6799. }
  6800. clif_GM_kick(sd, pl_sd, 1);
  6801. return 0;
  6802. }
  6803. /*==========================================
  6804. * Revive a player by PID number
  6805. * Original by Dino9021
  6806. * Added in by nsstrunks
  6807. *------------------------------------------*/
  6808. int atcommand_reviveid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6809. {
  6810. int aid=0;
  6811. struct map_session_data *pl_sd;
  6812. if (!message || (aid = atoi(message)) == 0) {
  6813. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  6814. return -1;
  6815. }
  6816. pl_sd = map_id2sd(aid);
  6817. if(!pl_sd) {
  6818. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6819. return -1;
  6820. }
  6821. if(!status_revive(&pl_sd->bl, 100, 100))
  6822. return -1;
  6823. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  6824. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  6825. return 0;
  6826. }
  6827. /*==========================================
  6828. * Kill a player by PID number
  6829. * Original by Dino9021
  6830. * Added in by nsstrunks
  6831. *------------------------------------------*/
  6832. int atcommand_killid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6833. {
  6834. int aid=0;
  6835. struct map_session_data *pl_sd;
  6836. if (!message || (aid = atoi(message)) == 0) {
  6837. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  6838. return -1;
  6839. }
  6840. pl_sd = map_id2sd(aid);
  6841. if (!pl_sd) {
  6842. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6843. return -1;
  6844. }
  6845. if (pc_isGM(sd) < pc_isGM(pl_sd))
  6846. { // you can kill only lower or same level
  6847. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6848. return -1;
  6849. }
  6850. status_kill(&pl_sd->bl);
  6851. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  6852. return 0;
  6853. }
  6854. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  6855. /*==========================================
  6856. * Mail System commands by [Valaris]
  6857. *------------------------------------------*/
  6858. int atcommand_listmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6859. {
  6860. if(!mail_server_enable)
  6861. return 0;
  6862. nullpo_retr(-1, sd);
  6863. if(strlen(command)==12) // @listnewmail
  6864. mail_check(sd,3);
  6865. else if(strlen(command)==9) // @listmail
  6866. mail_check(sd,2);
  6867. else // @checkmail
  6868. mail_check(sd,1);
  6869. return 0;
  6870. }
  6871. int atcommand_readmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6872. {
  6873. int index;
  6874. if(!mail_server_enable)
  6875. return 0;
  6876. nullpo_retr(-1, sd);
  6877. if (!message || !*message) {
  6878. clif_displaymessage(sd->fd,"You must specify a message number.");
  6879. return 0;
  6880. }
  6881. index = atoi(message);
  6882. if (index < 1) {
  6883. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  6884. return 0;
  6885. }
  6886. mail_read(sd,index);
  6887. return 0;
  6888. }
  6889. int atcommand_deletemail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6890. {
  6891. int index;
  6892. if(!mail_server_enable)
  6893. return 0;
  6894. nullpo_retr(-1, sd);
  6895. if (!message || !*message) {
  6896. clif_displaymessage(sd->fd,"You must specify a message number.");
  6897. return 0;
  6898. }
  6899. index = atoi(message);
  6900. if (index < 1) {
  6901. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  6902. return 0;
  6903. }
  6904. mail_delete(sd,index);
  6905. return 0;
  6906. }
  6907. int atcommand_sendmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6908. {
  6909. char name[NAME_LENGTH],text[80];
  6910. if(!mail_server_enable)
  6911. return 0;
  6912. nullpo_retr(-1, sd);
  6913. if (!message || !*message) {
  6914. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  6915. return 0;
  6916. }
  6917. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  6918. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  6919. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  6920. return 0;
  6921. }
  6922. if(strlen(command)==17) // @sendprioritymail
  6923. mail_send(sd,name,text,1);
  6924. else
  6925. mail_send(sd,name,text,0);
  6926. return 0;
  6927. }
  6928. /*==========================================
  6929. * Refresh online command for SQL [Valaris]
  6930. * Will refresh and check online column of players and set correctly.
  6931. *------------------------------------------*/
  6932. int atcommand_refreshonline(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6933. {
  6934. send_users_tochar(-1, gettick(), 0, 0);
  6935. return 0;
  6936. }
  6937. #endif /* end sql only */
  6938. /*==========================================
  6939. * Show Monster DB Info v 1.0
  6940. * originally by [Lupus] eAthena
  6941. *------------------------------------------*/
  6942. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6943. {
  6944. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  6945. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  6946. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  6947. char atcmd_output2[200];
  6948. struct item_data *item_data;
  6949. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6950. int count;
  6951. int i, j, k;
  6952. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6953. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6954. if (!message || !*message) {
  6955. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  6956. return -1;
  6957. }
  6958. // If monster identifier/name argument is a name
  6959. if ((i = mobdb_checkid(atoi(message))))
  6960. {
  6961. mob_array[0] = mob_db(i);
  6962. count = 1;
  6963. } else
  6964. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6965. if (!count) {
  6966. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6967. return -1;
  6968. }
  6969. if (count > MAX_SEARCH) {
  6970. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6971. clif_displaymessage(fd, atcmd_output);
  6972. count = MAX_SEARCH;
  6973. }
  6974. for (k = 0; k < count; k++) {
  6975. mob = mob_array[k];
  6976. // stats
  6977. if (mob->mexp)
  6978. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6979. else
  6980. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6981. clif_displaymessage(fd, atcmd_output);
  6982. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  6983. clif_displaymessage(fd, atcmd_output);
  6984. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  6985. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  6986. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6987. clif_displaymessage(fd, atcmd_output);
  6988. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  6989. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6990. mob->range2 , mob->range3, msize[mob->status.size],
  6991. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6992. clif_displaymessage(fd, atcmd_output);
  6993. // drops
  6994. clif_displaymessage(fd, " Drops:");
  6995. strcpy(atcmd_output, " ");
  6996. j = 0;
  6997. for (i = 0; i < MAX_MOB_DROP; i++) {
  6998. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  6999. continue;
  7000. if (item_data->slot)
  7001. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  7002. else
  7003. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  7004. strcat(atcmd_output, atcmd_output2);
  7005. if (++j % 3 == 0) {
  7006. clif_displaymessage(fd, atcmd_output);
  7007. strcpy(atcmd_output, " ");
  7008. }
  7009. }
  7010. if (j == 0)
  7011. clif_displaymessage(fd, "This monster has no drops.");
  7012. else if (j % 3 != 0)
  7013. clif_displaymessage(fd, atcmd_output);
  7014. // mvp
  7015. if (mob->mexp) {
  7016. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  7017. clif_displaymessage(fd, atcmd_output);
  7018. strcpy(atcmd_output, " MVP Items:");
  7019. j = 0;
  7020. for (i = 0; i < 3; i++) {
  7021. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  7022. continue;
  7023. if (mob->mvpitem[i].p > 0) {
  7024. j++;
  7025. if (j == 1)
  7026. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  7027. else
  7028. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  7029. strcat(atcmd_output, atcmd_output2);
  7030. }
  7031. }
  7032. if (j == 0)
  7033. clif_displaymessage(fd, "This monster has no MVP prizes.");
  7034. else
  7035. clif_displaymessage(fd, atcmd_output);
  7036. }
  7037. }
  7038. return 0;
  7039. }
  7040. /*=========================================
  7041. * @showmobs by KarLaeda
  7042. * => For 5 sec displays the mobs on minimap
  7043. *------------------------------------------*/
  7044. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  7045. {
  7046. struct map_session_data *sd;
  7047. if (!session[id] || (sd = session[id]->session_data) == NULL)
  7048. return 0;
  7049. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  7050. return 1;
  7051. }
  7052. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  7053. {
  7054. int mob_id,fd;
  7055. struct map_session_data* sd;
  7056. static int number=0;
  7057. struct mob_data *md;
  7058. if(!ap){
  7059. number=0;
  7060. return 0;
  7061. }
  7062. mob_id = va_arg(ap,int);
  7063. fd = va_arg(ap,int);
  7064. sd = va_arg(ap,struct map_session_data*);
  7065. md = (struct mob_data *)bl;
  7066. if(md->special_state.ai || md->master_id)
  7067. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  7068. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  7069. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  7070. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  7071. }
  7072. return 0;
  7073. }
  7074. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7075. {
  7076. char mob_name[100];
  7077. int mob_id,map_id = 0;
  7078. nullpo_retr(-1, sd);
  7079. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7080. return -1;
  7081. if ((mob_id = atoi(mob_name)) == 0)
  7082. mob_id = mobdb_searchname(mob_name);
  7083. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7084. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7085. clif_displaymessage(fd, atcmd_output);
  7086. return 0;
  7087. }
  7088. // Uncomment the following line to show mini-bosses & MVP.
  7089. //#define SHOW_MVP
  7090. #ifndef SHOW_MVP
  7091. if(mob_db(mob_id)->status.mode&MD_BOSS){
  7092. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  7093. clif_displaymessage(fd, atcmd_output);
  7094. return 0;
  7095. }
  7096. #endif
  7097. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7098. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7099. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7100. map_id = sd->bl.m;
  7101. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7102. mob_name, mapindex_id2name(sd->mapindex));
  7103. clif_displaymessage(fd, atcmd_output);
  7104. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  7105. atshowmobs_sub(&sd->bl,0);
  7106. return 0;
  7107. }
  7108. /*==========================================
  7109. * homunculus level up [orn]
  7110. *------------------------------------------*/
  7111. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7112. {
  7113. TBL_HOM * hd;
  7114. int level = 0, i = 0;
  7115. nullpo_retr(-1, sd);
  7116. if (!message || !*message) {
  7117. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <+/- # of levels>.");
  7118. return -1;
  7119. }
  7120. if ( !merc_is_hom_active(sd->hd) ) {
  7121. clif_displaymessage(fd, "You do not have a homunculus.");
  7122. return -1;
  7123. }
  7124. level = atoi(message);
  7125. hd = sd->hd;
  7126. for (i = 1; i <= level && hd->exp_next; i++){
  7127. hd->homunculus.exp += hd->exp_next;
  7128. merc_hom_levelup(hd);
  7129. }
  7130. status_calc_homunculus(hd,0);
  7131. status_percent_heal(&hd->bl, 100, 100);
  7132. clif_misceffect2(&hd->bl,568);
  7133. return 0;
  7134. }
  7135. /*==========================================
  7136. * homunculus evolution H [orn]
  7137. *------------------------------------------*/
  7138. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7139. {
  7140. nullpo_retr(-1, sd);
  7141. if ( !merc_is_hom_active(sd->hd) ) {
  7142. clif_displaymessage(fd, "You do not have a homunculus.");
  7143. return -1;
  7144. }
  7145. if ( !merc_hom_evolution(sd->hd) ) {
  7146. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  7147. return -1;
  7148. }
  7149. return 0;
  7150. }
  7151. /*==========================================
  7152. * call choosen homunculus [orn]
  7153. *------------------------------------------*/
  7154. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7155. {
  7156. int homunid;
  7157. nullpo_retr(-1, sd);
  7158. if ( merc_is_hom_active(sd->hd) ) {
  7159. clif_displaymessage(fd, msg_txt(450));
  7160. return -1;
  7161. }
  7162. if (!message || !*message) {
  7163. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  7164. return -1;
  7165. }
  7166. homunid = atoi(message);
  7167. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  7168. {
  7169. clif_displaymessage(fd, "Invalid Homunculus id.");
  7170. return -1;
  7171. }
  7172. merc_create_homunculus_request(sd,homunid);
  7173. return 0;
  7174. }
  7175. /*==========================================
  7176. * modify homunculus intimacy [orn]
  7177. *------------------------------------------*/
  7178. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7179. {
  7180. int friendly = 0;
  7181. nullpo_retr(-1, sd);
  7182. if ( !merc_is_hom_active(sd->hd) ) {
  7183. clif_displaymessage(fd, "You do not have a homunculus.");
  7184. return -1;
  7185. }
  7186. if (!message || !*message) {
  7187. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  7188. return -1;
  7189. }
  7190. friendly = atoi(message);
  7191. friendly = cap_value(friendly, 0, 1000);
  7192. sd->hd->homunculus.intimacy = friendly * 100 ;
  7193. clif_send_homdata(sd,SP_INTIMATE,friendly);
  7194. return 0;
  7195. }
  7196. /*==========================================
  7197. * modify homunculus hunger [orn]
  7198. *------------------------------------------*/
  7199. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7200. {
  7201. int hungry = 0;
  7202. nullpo_retr(-1, sd);
  7203. if ( !merc_is_hom_active(sd->hd) ) {
  7204. clif_displaymessage(fd, "You do not have a homunculus.");
  7205. return -1;
  7206. }
  7207. if (!message || !*message) {
  7208. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  7209. return -1;
  7210. }
  7211. hungry = atoi(message);
  7212. hungry = cap_value(hungry, 0, 100);
  7213. sd->hd->homunculus.hunger = hungry;
  7214. clif_send_homdata(sd,SP_HUNGRY,hungry);
  7215. return 0;
  7216. }
  7217. /*==========================================
  7218. * make the homunculus speak [orn]
  7219. *------------------------------------------*/
  7220. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7221. {
  7222. char mes[100],temp[100];
  7223. nullpo_retr(-1, sd);
  7224. if (sd->sc.count && //no "chatting" while muted.
  7225. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7226. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7227. return -1;
  7228. if ( !merc_is_hom_active(sd->hd) ) {
  7229. clif_displaymessage(fd, "You do not have a homunculus.");
  7230. return -1;
  7231. }
  7232. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  7233. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  7234. return -1;
  7235. }
  7236. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  7237. clif_message(&sd->hd->bl, temp);
  7238. return 0;
  7239. }
  7240. /*==========================================
  7241. * Show homunculus stats
  7242. *------------------------------------------*/
  7243. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7244. {
  7245. struct homun_data *hd;
  7246. struct status_data *status;
  7247. nullpo_retr(-1, sd);
  7248. if ( !merc_is_hom_active(sd->hd) ) {
  7249. clif_displaymessage(fd, "You do not have a homunculus.");
  7250. return -1;
  7251. }
  7252. hd = sd->hd;
  7253. status = status_get_status_data(&hd->bl);
  7254. clif_displaymessage(fd, "Homunculus stats :");
  7255. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  7256. status->hp, status->max_hp, status->sp, status->max_sp);
  7257. clif_displaymessage(fd, atcmd_output);
  7258. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  7259. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  7260. clif_displaymessage(fd, atcmd_output);
  7261. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  7262. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  7263. clif_displaymessage(fd, atcmd_output);
  7264. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7265. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  7266. status->str, status->agi, status->vit,
  7267. status->int_, status->dex, status->luk);
  7268. clif_displaymessage(fd, atcmd_output);
  7269. return 0;
  7270. }
  7271. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7272. {
  7273. struct homun_data *hd;
  7274. struct homunculus_db *db;
  7275. struct s_homunculus *hom;
  7276. int lv, min, max, evo;
  7277. nullpo_retr(-1, sd);
  7278. if ( !merc_is_hom_active(sd->hd) ) {
  7279. clif_displaymessage(fd, "You do not have a homunculus.");
  7280. return -1;
  7281. }
  7282. hd = sd->hd;
  7283. hom = &hd->homunculus;
  7284. db = hd->homunculusDB;
  7285. lv = hom->level;
  7286. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7287. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  7288. clif_displaymessage(fd, atcmd_output);
  7289. lv--; //Since the first increase is at level 2.
  7290. evo = (hom->class_ == db->evo_class);
  7291. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  7292. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  7293. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  7294. clif_displaymessage(fd, atcmd_output);
  7295. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  7296. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  7297. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  7298. clif_displaymessage(fd, atcmd_output);
  7299. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  7300. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  7301. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  7302. clif_displaymessage(fd, atcmd_output);
  7303. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  7304. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  7305. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  7306. clif_displaymessage(fd, atcmd_output);
  7307. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  7308. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  7309. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  7310. clif_displaymessage(fd, atcmd_output);
  7311. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  7312. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  7313. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  7314. clif_displaymessage(fd, atcmd_output);
  7315. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  7316. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  7317. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  7318. clif_displaymessage(fd, atcmd_output);
  7319. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  7320. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  7321. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  7322. clif_displaymessage(fd, atcmd_output);
  7323. return 0;
  7324. }
  7325. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7326. {
  7327. struct homun_data *hd;
  7328. int lv, i, skillpts;
  7329. unsigned int exp;
  7330. struct skill b_skill[MAX_HOMUNSKILL];
  7331. TBL_PC* tsd = sd;
  7332. nullpo_retr(-1, sd);
  7333. if ((!message || !*message) && !sd->hd)
  7334. {
  7335. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  7336. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  7337. return -1;
  7338. }
  7339. if (message && *message) {
  7340. tsd = map_nick2sd((char*)message);
  7341. if (!tsd) {
  7342. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7343. return -1;
  7344. }
  7345. if (pc_isGM(tsd) > pc_isGM(sd)) {
  7346. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7347. return -1;
  7348. }
  7349. }
  7350. hd = tsd->hd;
  7351. if(!merc_is_hom_active(hd))
  7352. return -1;
  7353. lv = hd->homunculus.level;
  7354. exp = hd->homunculus.exp;
  7355. memcpy(&b_skill, &hd->homunculus.hskill, sizeof(b_skill));
  7356. skillpts = hd->homunculus.skillpts;
  7357. //Reset values to level 1.
  7358. merc_reset_stats(hd);
  7359. //Level it back up
  7360. for (i = 1; i < lv && hd->exp_next; i++){
  7361. hd->homunculus.exp += hd->exp_next;
  7362. merc_hom_levelup(hd);
  7363. }
  7364. hd->homunculus.exp = exp;
  7365. memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill));
  7366. hd->homunculus.skillpts = skillpts;
  7367. clif_homskillinfoblock(hd->master);
  7368. status_calc_homunculus(hd,0);
  7369. status_percent_heal(&hd->bl, 100, 100);
  7370. clif_misceffect2(&hd->bl,568);
  7371. clif_displaymessage(fd, "Homunculus stats altered");
  7372. //Print out the new stats
  7373. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  7374. atcommand_homstats(fd, tsd, command, message);
  7375. return 0;
  7376. }
  7377. /*==========================================
  7378. * Show Items DB Info v 1.0
  7379. * originally by [Lupus] eAthena
  7380. *------------------------------------------*/
  7381. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7382. {
  7383. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  7384. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  7385. struct item_data *item_data, *item_array[MAX_SEARCH];
  7386. int i, count = 1;
  7387. if (!message || !*message) {
  7388. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  7389. return -1;
  7390. }
  7391. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  7392. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7393. if (!count) {
  7394. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7395. return -1;
  7396. }
  7397. if (count > MAX_SEARCH) {
  7398. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  7399. clif_displaymessage(fd, atcmd_output);
  7400. count = MAX_SEARCH;
  7401. }
  7402. for (i = 0; i < count; i++) {
  7403. item_data = item_array[i];
  7404. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  7405. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  7406. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  7407. (item_data->script==NULL)? "None" : "With script"
  7408. );
  7409. clif_displaymessage(fd, atcmd_output);
  7410. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
  7411. clif_displaymessage(fd, atcmd_output);
  7412. if (item_data->maxchance == 10000)
  7413. strcpy(atcmd_output, " - Available in the shops only");
  7414. else if (item_data->maxchance)
  7415. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  7416. else
  7417. strcpy(atcmd_output, " - Monsters don't drop this item");
  7418. clif_displaymessage(fd, atcmd_output);
  7419. }
  7420. return 0;
  7421. }
  7422. /*==========================================
  7423. * Show who drops the item.
  7424. *------------------------------------------*/
  7425. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7426. {
  7427. struct item_data *item_data, *item_array[MAX_SEARCH];
  7428. int i,j, count = 1;
  7429. if (!message || !*message) {
  7430. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  7431. return -1;
  7432. }
  7433. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  7434. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7435. if (!count) {
  7436. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7437. return -1;
  7438. }
  7439. if (count > MAX_SEARCH) {
  7440. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  7441. clif_displaymessage(fd, atcmd_output);
  7442. count = MAX_SEARCH;
  7443. }
  7444. for (i = 0; i < count; i++) {
  7445. item_data = item_array[i];
  7446. sprintf(atcmd_output, "Item: '%s'[%d]",
  7447. item_data->jname,item_data->slot);
  7448. clif_displaymessage(fd, atcmd_output);
  7449. if (item_data->mob[0].chance == 0) {
  7450. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  7451. clif_displaymessage(fd, atcmd_output);
  7452. } else {
  7453. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  7454. clif_displaymessage(fd, atcmd_output);
  7455. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  7456. {
  7457. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  7458. clif_displaymessage(fd, atcmd_output);
  7459. }
  7460. }
  7461. }
  7462. return 0;
  7463. }
  7464. int atcommand_whereis(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7465. {
  7466. struct mob_db *mob, *mob_array[MAX_SEARCH];
  7467. int count;
  7468. int i, j, k;
  7469. if (!message || !*message) {
  7470. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  7471. return -1;
  7472. }
  7473. // If monster identifier/name argument is a name
  7474. if ((i = mobdb_checkid(atoi(message))))
  7475. {
  7476. mob_array[0] = mob_db(i);
  7477. count = 1;
  7478. } else
  7479. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  7480. if (!count) {
  7481. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  7482. return -1;
  7483. }
  7484. if (count > MAX_SEARCH) {
  7485. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  7486. clif_displaymessage(fd, atcmd_output);
  7487. count = MAX_SEARCH;
  7488. }
  7489. for (k = 0; k < count; k++) {
  7490. mob = mob_array[k];
  7491. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  7492. clif_displaymessage(fd, atcmd_output);
  7493. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  7494. {
  7495. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  7496. if (j < 0) continue;
  7497. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  7498. clif_displaymessage(fd, atcmd_output);
  7499. }
  7500. if (i == 0)
  7501. clif_displaymessage(fd, "This monster does not spawn normally.");
  7502. }
  7503. return 0;
  7504. }
  7505. /*==========================================
  7506. * @adopt by [Veider]
  7507. * adopt a novice
  7508. *------------------------------------------*/
  7509. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7510. {
  7511. struct map_session_data *pl_sd1 = NULL;
  7512. struct map_session_data *pl_sd2 = NULL;
  7513. struct map_session_data *pl_sd3 = NULL;
  7514. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  7515. nullpo_retr(-1, sd);
  7516. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  7517. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  7518. return -1;
  7519. }
  7520. if (battle_config.etc_log)
  7521. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  7522. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  7523. sprintf(player2, "Cannot find player %s online", player1);
  7524. clif_displaymessage(fd, player2);
  7525. return -1;
  7526. }
  7527. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  7528. sprintf(player1, "Cannot find player %s online", player2);
  7529. clif_displaymessage(fd, player1);
  7530. return -1;
  7531. }
  7532. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  7533. sprintf(player1, "Cannot find player %s online", player3);
  7534. clif_displaymessage(fd, player1);
  7535. return -1;
  7536. }
  7537. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  7538. clif_displaymessage(fd, "They are family.. wish them luck");
  7539. return 0;
  7540. }
  7541. else
  7542. return -1;
  7543. }
  7544. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7545. {
  7546. const char * revision;
  7547. if ((revision = get_svn_revision()) != 0) {
  7548. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  7549. clif_displaymessage(fd,atcmd_output);
  7550. } else
  7551. clif_displaymessage(fd,"Cannot determine SVN revision");
  7552. return 0;
  7553. }
  7554. /*==========================================
  7555. * @mutearea by MouseJstr
  7556. *------------------------------------------*/
  7557. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7558. {
  7559. int time, id;
  7560. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  7561. if (pl_sd == NULL)
  7562. return 0;
  7563. id = va_arg(ap, int);
  7564. time = va_arg(ap, int);
  7565. if (id != bl->id && !pc_isGM(pl_sd)) {
  7566. pl_sd->status.manner -= time;
  7567. if (pl_sd->status.manner < 0)
  7568. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7569. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  7570. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  7571. }
  7572. return 0;
  7573. }
  7574. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7575. {
  7576. int time;
  7577. nullpo_retr(0, sd);
  7578. if (!message || !*message) {
  7579. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  7580. return -1;
  7581. }
  7582. time = atoi(message);
  7583. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  7584. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7585. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7586. return 0;
  7587. }
  7588. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7589. {
  7590. char buf[255];
  7591. nullpo_retr(0, sd);
  7592. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  7593. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  7594. clif_displaymessage(fd, buf);
  7595. return 0;
  7596. }
  7597. /*==========================================
  7598. * @me by lordalfa
  7599. * => Displays the OUTPUT string on top of the Visible players Heads.
  7600. *------------------------------------------*/
  7601. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7602. {
  7603. char tempmes[200];
  7604. nullpo_retr(-1, sd);
  7605. memset(tempmes, '\0', sizeof(tempmes));
  7606. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7607. if (sd->sc.count && //no "chatting" while muted.
  7608. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7609. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7610. return -1;
  7611. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  7612. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  7613. return -1;
  7614. }
  7615. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  7616. clif_disp_overhead(sd, atcmd_output);
  7617. return 0;
  7618. }
  7619. /*==========================================
  7620. * @size
  7621. * => Resize your character sprite. [Valaris]
  7622. *------------------------------------------*/
  7623. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7624. {
  7625. int size=0;
  7626. nullpo_retr(-1, sd);
  7627. size = atoi(message);
  7628. if(sd->state.size) {
  7629. sd->state.size=0;
  7630. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  7631. }
  7632. if(size==1) {
  7633. sd->state.size=1;
  7634. clif_specialeffect(&sd->bl,420,AREA);
  7635. } else if(size==2) {
  7636. sd->state.size=2;
  7637. clif_specialeffect(&sd->bl,422,AREA);
  7638. }
  7639. return 0;
  7640. }
  7641. /*==========================================
  7642. * @monsterignore
  7643. * => Makes monsters ignore you. [Valaris]
  7644. *------------------------------------------*/
  7645. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7646. {
  7647. nullpo_retr(-1, sd);
  7648. if (!sd->state.monster_ignore) {
  7649. sd->state.monster_ignore = 1;
  7650. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  7651. } else {
  7652. sd->state.monster_ignore = 0;
  7653. clif_displaymessage(sd->fd, "Returned to normal state.");
  7654. }
  7655. return 0;
  7656. }
  7657. /*==========================================
  7658. * @fakename
  7659. * => Gives your character a fake name. [Valaris]
  7660. *------------------------------------------*/
  7661. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7662. {
  7663. char name[NAME_LENGTH];
  7664. nullpo_retr(-1, sd);
  7665. if((!message || !*message) && strlen(sd->fakename) > 1) {
  7666. sd->fakename[0]='\0';
  7667. clif_charnameack(0, &sd->bl);
  7668. clif_displaymessage(sd->fd,"Returned to real name.");
  7669. return 0;
  7670. }
  7671. if (!message || !*message || sscanf(message, "%23[^\n]", name) < 1) {
  7672. clif_displaymessage(sd->fd,"You must enter a name.");
  7673. return -1;
  7674. }
  7675. if(strlen(name) < 2) {
  7676. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  7677. return -1;
  7678. }
  7679. memcpy(sd->fakename,name,NAME_LENGTH);
  7680. sd->fakename[NAME_LENGTH-1] = '\0';
  7681. clif_charnameack(0, &sd->bl);
  7682. clif_displaymessage(sd->fd,"Fake name enabled.");
  7683. return 0;
  7684. }
  7685. /*==========================================
  7686. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  7687. * => Shows information about the map flags [map name]
  7688. * Also set flags
  7689. *------------------------------------------*/
  7690. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7691. {
  7692. // WIP
  7693. return 0;
  7694. }
  7695. /*===================================
  7696. * Remove some messages
  7697. *-----------------------------------*/
  7698. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7699. {
  7700. if (sd->state.showexp) {
  7701. sd->state.showexp = 0;
  7702. clif_displaymessage(fd, "Gained exp will not be shown.");
  7703. return 0;
  7704. }
  7705. sd->state.showexp = 1;
  7706. clif_displaymessage(fd, "Gained exp is now shown");
  7707. return 0;
  7708. }
  7709. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7710. {
  7711. if (sd->state.showzeny) {
  7712. sd->state.showzeny = 0;
  7713. clif_displaymessage(fd, "Gained zeny will not be shown.");
  7714. return 0;
  7715. }
  7716. sd->state.showzeny = 1;
  7717. clif_displaymessage(fd, "Gained zeny is now shown");
  7718. return 0;
  7719. }
  7720. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7721. {
  7722. if (sd->state.showdelay) {
  7723. sd->state.showdelay = 0;
  7724. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  7725. return 0;
  7726. }
  7727. sd->state.showdelay = 1;
  7728. clif_displaymessage(fd, "Skill delay failures are shown now.");
  7729. return 0;
  7730. }
  7731. /*==========================================
  7732. * Duel organizing functions [LuzZza]
  7733. *
  7734. * @duel [limit|nick] - create a duel
  7735. * @invite <nick> - invite player
  7736. * @accept - accept invitation
  7737. * @reject - reject invitation
  7738. * @leave - leave duel
  7739. *------------------------------------------*/
  7740. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7741. {
  7742. unsigned int did = sd->duel_group;
  7743. struct map_session_data *target_sd = map_nick2sd((char *)message);
  7744. if(did <= 0) {
  7745. // "Duel: @invite without @duel."
  7746. clif_displaymessage(fd, msg_txt(350));
  7747. return 0;
  7748. }
  7749. if(duel_list[did].max_players_limit > 0 &&
  7750. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  7751. // "Duel: Limit of players is reached."
  7752. clif_displaymessage(fd, msg_txt(351));
  7753. return 0;
  7754. }
  7755. if(target_sd == NULL) {
  7756. // "Duel: Player not found."
  7757. clif_displaymessage(fd, msg_txt(352));
  7758. return 0;
  7759. }
  7760. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7761. // "Duel: Player already in duel."
  7762. clif_displaymessage(fd, msg_txt(353));
  7763. return 0;
  7764. }
  7765. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7766. {
  7767. sprintf(atcmd_output, msg_txt(364), message);
  7768. clif_displaymessage(fd, atcmd_output);
  7769. return 0;
  7770. }
  7771. duel_invite(did, sd, target_sd);
  7772. // "Duel: Invitation has been sent."
  7773. clif_displaymessage(fd, msg_txt(354));
  7774. return 0;
  7775. }
  7776. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7777. {
  7778. char output[256];
  7779. unsigned int maxpl=0, newduel;
  7780. struct map_session_data *target_sd;
  7781. if(sd->duel_group > 0) {
  7782. duel_showinfo(sd->duel_group, sd);
  7783. return 0;
  7784. }
  7785. if(sd->duel_invite > 0) {
  7786. // "Duel: @duel without @reject."
  7787. clif_displaymessage(fd, msg_txt(355));
  7788. return 0;
  7789. }
  7790. if(!duel_checktime(sd)) {
  7791. // "Duel: You can take part in duel only one time per %d minutes."
  7792. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  7793. clif_displaymessage(fd, output);
  7794. return 0;
  7795. }
  7796. if(strlen(message) > 0) {
  7797. if(sscanf(message, "%d", &maxpl) >= 1) {
  7798. if(maxpl < 2 || maxpl > 65535) {
  7799. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  7800. return 0;
  7801. }
  7802. duel_create(sd, maxpl);
  7803. } else {
  7804. target_sd = map_nick2sd((char *)message);
  7805. if(target_sd != NULL) {
  7806. if((newduel = duel_create(sd, 2)) != -1) {
  7807. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7808. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  7809. return 0;
  7810. }
  7811. duel_invite(newduel, sd, target_sd);
  7812. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  7813. }
  7814. } else {
  7815. // "Duel: Player not found."
  7816. clif_displaymessage(fd, msg_txt(352));
  7817. return 0;
  7818. }
  7819. }
  7820. } else
  7821. duel_create(sd, 0);
  7822. return 0;
  7823. }
  7824. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7825. {
  7826. if(sd->duel_group <= 0) {
  7827. // "Duel: @leave without @duel."
  7828. clif_displaymessage(fd, msg_txt(358));
  7829. return 0;
  7830. }
  7831. duel_leave(sd->duel_group, sd);
  7832. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  7833. return 0;
  7834. }
  7835. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7836. {
  7837. char output[256];
  7838. if(!duel_checktime(sd)) {
  7839. // "Duel: You can take part in duel only one time per %d minutes."
  7840. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  7841. clif_displaymessage(fd, output);
  7842. return 0;
  7843. }
  7844. if(sd->duel_invite <= 0) {
  7845. // "Duel: @accept without invititation."
  7846. clif_displaymessage(fd, msg_txt(360));
  7847. return 0;
  7848. }
  7849. duel_accept(sd->duel_invite, sd);
  7850. // "Duel: Invitation has been accepted."
  7851. clif_displaymessage(fd, msg_txt(361));
  7852. return 0;
  7853. }
  7854. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7855. {
  7856. if(sd->duel_invite <= 0) {
  7857. // "Duel: @reject without invititation."
  7858. clif_displaymessage(fd, msg_txt(362));
  7859. return 0;
  7860. }
  7861. duel_reject(sd->duel_invite, sd);
  7862. // "Duel: Invitation has been rejected."
  7863. clif_displaymessage(fd, msg_txt(363));
  7864. return 0;
  7865. }
  7866. /*===================================
  7867. * Away message (@away, @aw) [LuzZza]
  7868. *-----------------------------------*/
  7869. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7870. {
  7871. if(strlen(message) > 0) {
  7872. if(strlen(message) > 128)
  7873. return -1;
  7874. strcpy(sd->away_message, message);
  7875. //"Away automessage has been activated."
  7876. clif_displaymessage(fd, msg_txt(546));
  7877. } else {
  7878. if(strlen(sd->away_message) > 0) {
  7879. sd->away_message[0] = 0;
  7880. //"Away automessage has been disabled."
  7881. clif_displaymessage(fd, msg_txt(547));
  7882. return 0;
  7883. }
  7884. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  7885. clif_displaymessage(fd, msg_txt(548));
  7886. }
  7887. return 0;
  7888. }
  7889. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7890. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7891. {
  7892. int x=0,y=0,flag=0,master=0,i=0;
  7893. struct map_session_data *pl_sd=NULL;
  7894. if (!message || !*message) {
  7895. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  7896. return 0;
  7897. }
  7898. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7899. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7900. return 0;
  7901. }
  7902. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  7903. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  7904. return 0;
  7905. }
  7906. if (strcmpi(command, "@clone") == 0)
  7907. flag = 1;
  7908. else if (strcmpi(command, "@slaveclone") == 0) {
  7909. flag = 2;
  7910. master = sd->bl.id;
  7911. if (battle_config.atc_slave_clone_limit
  7912. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7913. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  7914. return 0;
  7915. }
  7916. }
  7917. do {
  7918. x = sd->bl.x + (rand() % 10 - 5);
  7919. y = sd->bl.y + (rand() % 10 - 5);
  7920. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7921. if (i >= 10) {
  7922. x = sd->bl.x;
  7923. y = sd->bl.y;
  7924. }
  7925. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7926. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7927. return 0;
  7928. }
  7929. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7930. return 0;
  7931. }
  7932. /*===================================
  7933. * Main chat [LuzZza]
  7934. * Usage: @main <on|off|message>
  7935. *-----------------------------------*/
  7936. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7937. {
  7938. if(strlen(message) > 0) {
  7939. if(strcmpi(message, "on") == 0) {
  7940. if(!sd->state.mainchat) {
  7941. sd->state.mainchat = 1;
  7942. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7943. } else {
  7944. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  7945. }
  7946. } else if(strcmpi(message, "off") == 0) {
  7947. if(sd->state.mainchat) {
  7948. sd->state.mainchat = 0;
  7949. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  7950. } else {
  7951. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  7952. }
  7953. } else {
  7954. if(!sd->state.mainchat) {
  7955. sd->state.mainchat = 1;
  7956. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7957. }
  7958. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  7959. clif_displaymessage(fd, msg_txt(387));
  7960. return -1;
  7961. }
  7962. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  7963. // I use 0xFE000000 color for signalizing that this message is
  7964. // main chat message. 0xFE000000 is invalid color, same using
  7965. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  7966. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  7967. // Chat logging type 'M' / Main Chat
  7968. if( log_config.chat&1 || (log_config.chat&32 && !(agit_flag && log_config.chat&64)) )
  7969. log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  7970. }
  7971. } else {
  7972. if(sd->state.mainchat)
  7973. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  7974. else
  7975. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  7976. }
  7977. return 0;
  7978. }
  7979. /*=====================================
  7980. * Autorejecting Invites/Deals [LuzZza]
  7981. * Usage: @noask
  7982. *-------------------------------------*/
  7983. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7984. {
  7985. if(sd->state.noask) {
  7986. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  7987. sd->state.noask = 0;
  7988. } else {
  7989. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  7990. sd->state.noask = 1;
  7991. }
  7992. return 0;
  7993. }
  7994. /*=====================================
  7995. * Send a @request message to all GMs of lowest_gm_level.
  7996. * Usage: @request <petition>
  7997. *-------------------------------------*/
  7998. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7999. {
  8000. if (!message || !*message) {
  8001. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  8002. return -1;
  8003. }
  8004. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  8005. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  8006. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  8007. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  8008. return 0;
  8009. }
  8010. /*==========================================
  8011. * Feel (SG save map) Reset [HiddenDragon]
  8012. *------------------------------------------*/
  8013. int atcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8014. {
  8015. pc_resetfeel(sd);
  8016. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  8017. return 0;
  8018. }
  8019. void do_init_atcommand()
  8020. {
  8021. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8022. duel_count = 0;
  8023. memset(&duel_list[0], 0, sizeof(duel_list));
  8024. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  8025. return;
  8026. }
  8027. void do_final_atcommand()
  8028. {
  8029. users_db->destroy(users_db,NULL);
  8030. }