atcommand.c 269 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "atcommand.h"
  14. #include "battle.h"
  15. #include "chat.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "intif.h"
  19. #include "itemdb.h"
  20. #include "log.h"
  21. #include "map.h"
  22. #include "pc.h"
  23. #include "status.h"
  24. #include "skill.h"
  25. #include "mob.h"
  26. #include "npc.h"
  27. #include "pet.h"
  28. #include "homunculus.h"
  29. #include "mercenary.h"
  30. #include "party.h"
  31. #include "guild.h"
  32. #include "script.h"
  33. #include "trade.h"
  34. #include "unit.h"
  35. #ifndef TXT_ONLY
  36. #include "mail.h"
  37. #endif
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. #include <string.h>
  41. #include <math.h>
  42. // extern variables
  43. char atcommand_symbol = '@'; // first char of the commands
  44. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  45. // local declarations
  46. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  47. typedef struct AtCommandInfo
  48. {
  49. const char* command;
  50. int level;
  51. AtCommandFunc func;
  52. } AtCommandInfo;
  53. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  54. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  55. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message);
  56. /*=========================================
  57. * Generic variables
  58. *-----------------------------------------*/
  59. char atcmd_output[200];
  60. char atcmd_player_name[NAME_LENGTH];
  61. char atcmd_temp[100];
  62. // compare function for sorting high to lowest
  63. int hightolow_compare (const void * a, const void * b)
  64. {
  65. return ( *(int*)b - *(int*)a );
  66. }
  67. // compare function for sorting lowest to highest
  68. int lowtohigh_compare (const void * a, const void * b)
  69. {
  70. return ( *(int*)a - *(int*)b );
  71. }
  72. //-----------------------------------------------------------
  73. // Return the message string of the specified number by [Yor]
  74. //-----------------------------------------------------------
  75. char* msg_txt(int msg_number)
  76. {
  77. if (msg_number >= 0 && msg_number < MAX_MSG &&
  78. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  79. return msg_table[msg_number];
  80. return "??";
  81. }
  82. //-----------------------------------------------------------
  83. // Returns Players title (from msg_athena.conf) [Lupus]
  84. //-----------------------------------------------------------
  85. static char* player_title_txt(int level)
  86. {
  87. const char* format;
  88. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  89. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  90. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  91. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  92. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  93. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  94. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  95. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  96. : "";
  97. sprintf(atcmd_temp, format, level);
  98. return atcmd_temp;
  99. }
  100. /*==========================================
  101. * Read Message Data
  102. *------------------------------------------*/
  103. int msg_config_read(const char* cfgName)
  104. {
  105. int msg_number;
  106. char line[1024], w1[1024], w2[1024];
  107. FILE *fp;
  108. static int called = 1;
  109. if ((fp = fopen(cfgName, "r")) == NULL) {
  110. ShowError("Messages file not found: %s\n", cfgName);
  111. return 1;
  112. }
  113. if ((--called) == 0)
  114. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  115. while(fgets(line, sizeof(line), fp))
  116. {
  117. if (line[0] == '/' && line[1] == '/')
  118. continue;
  119. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  120. continue;
  121. if (strcmpi(w1, "import") == 0)
  122. msg_config_read(w2);
  123. else
  124. {
  125. msg_number = atoi(w1);
  126. if (msg_number >= 0 && msg_number < MAX_MSG)
  127. {
  128. if (msg_table[msg_number] != NULL)
  129. aFree(msg_table[msg_number]);
  130. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  131. strcpy(msg_table[msg_number],w2);
  132. }
  133. }
  134. }
  135. fclose(fp);
  136. return 0;
  137. }
  138. /*==========================================
  139. * Cleanup Message Data
  140. *------------------------------------------*/
  141. void do_final_msg(void)
  142. {
  143. int i;
  144. for (i = 0; i < MAX_MSG; i++)
  145. aFree(msg_table[i]);
  146. }
  147. /*==========================================
  148. * @send (used for testing packet sends from the client)
  149. *------------------------------------------*/
  150. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  151. {
  152. int len=0,off,end,type;
  153. long num;
  154. (void)command; // not used
  155. // read message type as hex number (without the 0x)
  156. if(!message || !*message ||
  157. !((sscanf(message, "len %x", &type)==1 && (len=1))
  158. || sscanf(message, "%x", &type)==1) )
  159. {
  160. clif_displaymessage(fd, "Usage:");
  161. clif_displaymessage(fd, " @send len <packet hex number>");
  162. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  163. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  164. return -1;
  165. }
  166. #define PARSE_ERROR(error,p) \
  167. {\
  168. clif_displaymessage(fd, (error));\
  169. sprintf(atcmd_output, ">%s", (p));\
  170. clif_displaymessage(fd, atcmd_output);\
  171. }
  172. //define PARSE_ERROR
  173. #define CHECK_EOS(p) \
  174. if(*(p) == 0){\
  175. clif_displaymessage(fd, "Unexpected end of string");\
  176. return -1;\
  177. }
  178. //define CHECK_EOS
  179. #define SKIP_VALUE(p) \
  180. {\
  181. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  182. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  183. }
  184. //define SKIP_VALUE
  185. #define GET_VALUE(p,num) \
  186. {\
  187. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  188. PARSE_ERROR("Invalid number in:",(p));\
  189. return -1;\
  190. }\
  191. }
  192. //define GET_VALUE
  193. if (type > 0 && type < MAX_PACKET_DB) {
  194. if(len)
  195. {// show packet length
  196. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  197. clif_displaymessage(fd, atcmd_output);
  198. return 0;
  199. }
  200. len=packet_db[sd->packet_ver][type].len;
  201. off=2;
  202. if(len == 0)
  203. {// unknown packet - ERROR
  204. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  205. clif_displaymessage(fd, atcmd_output);
  206. return -1;
  207. } else if(len == -1)
  208. {// dynamic packet
  209. len=SHRT_MAX-4; // maximum length
  210. off=4;
  211. }
  212. WFIFOHEAD(fd, len);
  213. WFIFOW(fd,0)=TOW(type);
  214. // parse packet contents
  215. SKIP_VALUE(message);
  216. while(*message != 0 && off < len){
  217. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  218. {// default (byte)
  219. GET_VALUE(message,num);
  220. WFIFOB(fd,off)=TOB(num);
  221. ++off;
  222. } else if(TOUPPER(*message) == 'B')
  223. {// byte
  224. ++message;
  225. GET_VALUE(message,num);
  226. WFIFOB(fd,off)=TOB(num);
  227. ++off;
  228. } else if(TOUPPER(*message) == 'W')
  229. {// word (2 bytes)
  230. ++message;
  231. GET_VALUE(message,num);
  232. WFIFOW(fd,off)=TOW(num);
  233. off+=2;
  234. } else if(TOUPPER(*message) == 'L')
  235. {// long word (4 bytes)
  236. ++message;
  237. GET_VALUE(message,num);
  238. WFIFOL(fd,off)=TOL(num);
  239. off+=4;
  240. } else if(TOUPPER(*message) == 'S')
  241. {// string - escapes are valid
  242. // get string length - num <= 0 means not fixed length (default)
  243. ++message;
  244. if(*message == '"'){
  245. num=0;
  246. } else {
  247. GET_VALUE(message,num);
  248. while(*message != '"')
  249. {// find start of string
  250. if(*message == 0 || ISSPACE(*message)){
  251. PARSE_ERROR("Not a string:",message);
  252. return -1;
  253. }
  254. ++message;
  255. }
  256. }
  257. // parse string
  258. ++message;
  259. CHECK_EOS(message);
  260. end=(num<=0? 0: min(off+((int)num),len));
  261. for(; *message != '"' && (off < end || end == 0); ++off){
  262. if(*message == '\\'){
  263. ++message;
  264. CHECK_EOS(message);
  265. switch(*message){
  266. case 'a': num=0x07; break; // Bell
  267. case 'b': num=0x08; break; // Backspace
  268. case 't': num=0x09; break; // Horizontal tab
  269. case 'n': num=0x0A; break; // Line feed
  270. case 'v': num=0x0B; break; // Vertical tab
  271. case 'f': num=0x0C; break; // Form feed
  272. case 'r': num=0x0D; break; // Carriage return
  273. case 'e': num=0x1B; break; // Escape
  274. default: num=*message; break;
  275. case 'x': // Hexadecimal
  276. {
  277. ++message;
  278. CHECK_EOS(message);
  279. if(!ISXDIGIT(*message)){
  280. PARSE_ERROR("Not a hexadecimal digit:",message);
  281. return -1;
  282. }
  283. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  284. if(ISXDIGIT(*message)){
  285. ++message;
  286. CHECK_EOS(message);
  287. num<<=8;
  288. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  289. }
  290. WFIFOB(fd,off)=TOB(num);
  291. ++message;
  292. CHECK_EOS(message);
  293. continue;
  294. }
  295. case '0':
  296. case '1':
  297. case '2':
  298. case '3':
  299. case '4':
  300. case '5':
  301. case '6':
  302. case '7': // Octal
  303. {
  304. num=*message-'0'; // 1st octal digit
  305. ++message;
  306. CHECK_EOS(message);
  307. if(ISDIGIT(*message) && *message < '8'){
  308. num<<=3;
  309. num+=*message-'0'; // 2nd octal digit
  310. ++message;
  311. CHECK_EOS(message);
  312. if(ISDIGIT(*message) && *message < '8'){
  313. num<<=3;
  314. num+=*message-'0'; // 3rd octal digit
  315. ++message;
  316. CHECK_EOS(message);
  317. }
  318. }
  319. WFIFOB(fd,off)=TOB(num);
  320. continue;
  321. }
  322. }
  323. } else
  324. num=*message;
  325. WFIFOB(fd,off)=TOB(num);
  326. ++message;
  327. CHECK_EOS(message);
  328. }//for
  329. while(*message != '"')
  330. {// ignore extra characters
  331. ++message;
  332. CHECK_EOS(message);
  333. }
  334. // terminate the string
  335. if(off < end)
  336. {// fill the rest with 0's
  337. memset(WFIFOP(fd,off),0,end-off);
  338. off=end;
  339. }
  340. } else
  341. {// unknown
  342. PARSE_ERROR("Unknown type of value in:",message);
  343. return -1;
  344. }
  345. SKIP_VALUE(message);
  346. }
  347. if(packet_db[sd->packet_ver][type].len == -1)
  348. {// send dynamic packet
  349. WFIFOW(fd,2)=TOW(off);
  350. WFIFOSET(fd,off);
  351. } else
  352. {// send static packet
  353. if(off < len)
  354. memset(WFIFOP(fd,off),0,len-off);
  355. WFIFOSET(fd,len);
  356. }
  357. } else {
  358. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  359. return -1;
  360. }
  361. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  362. clif_displaymessage(fd, atcmd_output);
  363. return 0;
  364. #undef PARSE_ERROR
  365. #undef CHECK_EOS
  366. #undef SKIP_VALUE
  367. #undef GET_VALUE
  368. }
  369. /*==========================================
  370. * @rura, @warp, @mapmove
  371. *------------------------------------------*/
  372. int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  373. {
  374. char map_name[MAP_NAME_LENGTH_EXT];
  375. unsigned short mapindex;
  376. int x = 0, y = 0;
  377. int m = -1;
  378. nullpo_retr(-1, sd);
  379. memset(map_name, '\0', sizeof(map_name));
  380. if (!message || !*message ||
  381. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  382. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  383. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  384. return -1;
  385. }
  386. mapindex = mapindex_name2id(map_name);
  387. if (mapindex)
  388. m = map_mapindex2mapid(mapindex);
  389. if (!mapindex) { // m < 0 means on different server! [Kevin]
  390. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  391. return -1;
  392. }
  393. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  394. { //This is to prevent the pc_setpos call from printing an error.
  395. clif_displaymessage(fd, msg_txt(2));
  396. x = y = 0; //Invalid cell, use random spot.
  397. }
  398. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  399. clif_displaymessage(fd, msg_txt(247));
  400. return -1;
  401. }
  402. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  403. clif_displaymessage(fd, msg_txt(248));
  404. return -1;
  405. }
  406. if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
  407. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  408. return -1;
  409. }
  410. clif_displaymessage(fd, msg_txt(0)); // Warped.
  411. return 0;
  412. }
  413. /*==========================================
  414. * Displays where a character is. Corrected version by Silent. [Skotlex]
  415. *------------------------------------------*/
  416. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  417. {
  418. struct map_session_data* pl_sd;
  419. nullpo_retr(-1, sd);
  420. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  421. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  422. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  423. return -1;
  424. }
  425. pl_sd = map_nick2sd(atcmd_player_name);
  426. if( pl_sd == NULL
  427. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  428. || (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))
  429. ) {
  430. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  431. return -1;
  432. }
  433. 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);
  434. clif_displaymessage(fd, atcmd_output);
  435. return 0;
  436. }
  437. /*==========================================
  438. *
  439. *------------------------------------------*/
  440. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  441. {
  442. struct map_session_data *pl_sd = NULL;
  443. nullpo_retr(-1, sd);
  444. if (!message || !*message) {
  445. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  446. return -1;
  447. }
  448. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  449. {
  450. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  451. return -1;
  452. }
  453. if (pl_sd == sd)
  454. {
  455. clif_displaymessage(fd, "But you are already where you are...");
  456. return -1;
  457. }
  458. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  459. {
  460. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  461. return -1;
  462. }
  463. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  464. {
  465. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  466. return -1;
  467. }
  468. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  469. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  470. clif_displaymessage(fd, atcmd_output);
  471. return 0;
  472. }
  473. /*==========================================
  474. *
  475. *------------------------------------------*/
  476. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  477. {
  478. int x = 0, y = 0;
  479. nullpo_retr(-1, sd);
  480. memset(atcmd_output, '\0', sizeof(atcmd_output));
  481. sscanf(message, "%d %d", &x, &y);
  482. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  483. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  484. return -1;
  485. }
  486. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  487. { //This is to prevent the pc_setpos call from printing an error.
  488. clif_displaymessage(fd, msg_txt(2));
  489. x = y = 0; //Invalid cell, use random spot.
  490. }
  491. pc_setpos(sd, sd->mapindex, x, y, 3);
  492. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  493. clif_displaymessage(fd, atcmd_output);
  494. return 0;
  495. }
  496. /*==========================================
  497. * @who3 = Player name, his location
  498. *------------------------------------------*/
  499. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  500. {
  501. char temp0[100];
  502. struct map_session_data *pl_sd;
  503. struct s_mapiterator* iter;
  504. int j, count;
  505. int pl_GM_level, GM_level;
  506. char match_text[100];
  507. char player_name[NAME_LENGTH];
  508. nullpo_retr(-1, sd);
  509. memset(atcmd_output, '\0', sizeof(atcmd_output));
  510. memset(match_text, '\0', sizeof(match_text));
  511. memset(player_name, '\0', sizeof(player_name));
  512. if (sscanf(message, "%99[^\n]", match_text) < 1)
  513. strcpy(match_text, "");
  514. for (j = 0; match_text[j]; j++)
  515. match_text[j] = TOLOWER(match_text[j]);
  516. count = 0;
  517. GM_level = pc_isGM(sd);
  518. iter = mapit_getallusers();
  519. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  520. {
  521. pl_GM_level = pc_isGM(pl_sd);
  522. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  523. {// you can look only lower or same level
  524. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  525. for (j = 0; player_name[j]; j++)
  526. player_name[j] = TOLOWER(player_name[j]);
  527. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  528. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  529. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  530. } else {
  531. atcmd_output[0]=0;
  532. }
  533. //Player name
  534. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  535. strcat(atcmd_output,temp0);
  536. //Player title, if exists
  537. if (pl_GM_level > 0) {
  538. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  539. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  540. strcat(atcmd_output,temp0);
  541. }
  542. //Players Location: map x y
  543. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  544. strcat(atcmd_output,temp0);
  545. clif_displaymessage(fd, atcmd_output);
  546. count++;
  547. }
  548. }
  549. }
  550. mapit_free(iter);
  551. if (count == 0)
  552. clif_displaymessage(fd, msg_txt(28)); // No player found.
  553. else if (count == 1)
  554. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  555. else {
  556. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  557. clif_displaymessage(fd, atcmd_output);
  558. }
  559. return 0;
  560. }
  561. /*==========================================
  562. * Player name, BLevel, Job,
  563. *------------------------------------------*/
  564. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  565. {
  566. char temp0[100];
  567. struct map_session_data *pl_sd;
  568. struct s_mapiterator* iter;
  569. int j, count;
  570. int pl_GM_level, GM_level;
  571. char match_text[100];
  572. char player_name[NAME_LENGTH];
  573. nullpo_retr(-1, sd);
  574. memset(atcmd_output, '\0', sizeof(atcmd_output));
  575. memset(match_text, '\0', sizeof(match_text));
  576. memset(player_name, '\0', sizeof(player_name));
  577. if (sscanf(message, "%99[^\n]", match_text) < 1)
  578. strcpy(match_text, "");
  579. for (j = 0; match_text[j]; j++)
  580. match_text[j] = TOLOWER(match_text[j]);
  581. count = 0;
  582. GM_level = pc_isGM(sd);
  583. iter = mapit_getallusers();
  584. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  585. {
  586. pl_GM_level = pc_isGM(pl_sd);
  587. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  588. {// you can look only lower or same level
  589. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  590. for (j = 0; player_name[j]; j++)
  591. player_name[j] = TOLOWER(player_name[j]);
  592. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  593. //Players Name
  594. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  595. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  596. //Player title, if exists
  597. if (pl_GM_level > 0) {
  598. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  599. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  600. strcat(atcmd_output,temp0);
  601. }
  602. //Players Base Level / Job name
  603. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  604. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  605. strcat(atcmd_output,temp0);
  606. clif_displaymessage(fd, atcmd_output);
  607. count++;
  608. }
  609. }
  610. }
  611. mapit_free(iter);
  612. if (count == 0)
  613. clif_displaymessage(fd, msg_txt(28)); // No player found.
  614. else if (count == 1)
  615. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  616. else {
  617. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  618. clif_displaymessage(fd, atcmd_output);
  619. }
  620. return 0;
  621. }
  622. /*==========================================
  623. * Player name, Playrs Party / Guild name
  624. *------------------------------------------*/
  625. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  626. {
  627. char temp0[100];
  628. struct map_session_data *pl_sd;
  629. struct s_mapiterator* iter;
  630. int j, count;
  631. int pl_GM_level, GM_level;
  632. char match_text[100];
  633. char player_name[NAME_LENGTH];
  634. struct guild *g;
  635. struct party_data *p;
  636. nullpo_retr(-1, sd);
  637. memset(temp0, '\0', sizeof(temp0));
  638. memset(atcmd_output, '\0', sizeof(atcmd_output));
  639. memset(match_text, '\0', sizeof(match_text));
  640. memset(player_name, '\0', sizeof(player_name));
  641. if (sscanf(message, "%99[^\n]", match_text) < 1)
  642. strcpy(match_text, "");
  643. for (j = 0; match_text[j]; j++)
  644. match_text[j] = TOLOWER(match_text[j]);
  645. count = 0;
  646. GM_level = pc_isGM(sd);
  647. iter = mapit_getallusers();
  648. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  649. {
  650. pl_GM_level = pc_isGM(pl_sd);
  651. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  652. {// you can look only lower or same level
  653. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  654. for (j = 0; player_name[j]; j++)
  655. player_name[j] = TOLOWER(player_name[j]);
  656. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  657. g = guild_search(pl_sd->status.guild_id);
  658. p = party_search(pl_sd->status.party_id);
  659. //Players Name
  660. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  661. //Player title, if exists
  662. if (pl_GM_level > 0) {
  663. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  664. strcat(atcmd_output,temp0);
  665. }
  666. //Players Party if exists
  667. if (p != NULL) {
  668. //sprintf(temp0," | Party: '%s'", p->name);
  669. sprintf(temp0, msg_txt(335), p->party.name);
  670. strcat(atcmd_output,temp0);
  671. }
  672. //Players Guild if exists
  673. if (g != NULL) {
  674. //sprintf(temp0," | Guild: '%s'", g->name);
  675. sprintf(temp0, msg_txt(336), g->name);
  676. strcat(atcmd_output,temp0);
  677. }
  678. clif_displaymessage(fd, atcmd_output);
  679. count++;
  680. }
  681. }
  682. }
  683. mapit_free(iter);
  684. if (count == 0)
  685. clif_displaymessage(fd, msg_txt(28)); // No player found.
  686. else if (count == 1)
  687. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  688. else {
  689. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  690. clif_displaymessage(fd, atcmd_output);
  691. }
  692. return 0;
  693. }
  694. /*==========================================
  695. *
  696. *------------------------------------------*/
  697. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  698. {
  699. struct map_session_data *pl_sd;
  700. struct s_mapiterator* iter;
  701. int count;
  702. int pl_GM_level, GM_level;
  703. int map_id;
  704. char map_name[MAP_NAME_LENGTH_EXT];
  705. memset(atcmd_output, '\0', sizeof(atcmd_output));
  706. memset(map_name, '\0', sizeof(map_name));
  707. if (!message || !*message)
  708. map_id = sd->bl.m;
  709. else {
  710. sscanf(message, "%15s", map_name);
  711. if ((map_id = map_mapname2mapid(map_name)) < 0)
  712. map_id = sd->bl.m;
  713. }
  714. count = 0;
  715. GM_level = pc_isGM(sd);
  716. iter = mapit_getallusers();
  717. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  718. {
  719. pl_GM_level = pc_isGM(pl_sd);
  720. if( pl_sd->bl.m != map_id )
  721. continue;
  722. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  723. continue;
  724. if (pl_GM_level > 0)
  725. 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);
  726. else
  727. 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);
  728. clif_displaymessage(fd, atcmd_output);
  729. count++;
  730. }
  731. mapit_free(iter);
  732. if (count == 0)
  733. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  734. else if (count == 1)
  735. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  736. else {
  737. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  738. }
  739. clif_displaymessage(fd, atcmd_output);
  740. return 0;
  741. }
  742. /*==========================================
  743. *
  744. *------------------------------------------*/
  745. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  746. {
  747. struct map_session_data *pl_sd;
  748. struct s_mapiterator* iter;
  749. int count;
  750. int pl_GM_level, GM_level;
  751. int map_id = 0;
  752. char map_name[MAP_NAME_LENGTH_EXT];
  753. nullpo_retr(-1, sd);
  754. memset(atcmd_output, '\0', sizeof(atcmd_output));
  755. memset(map_name, '\0', sizeof(map_name));
  756. if (!message || !*message)
  757. map_id = sd->bl.m;
  758. else {
  759. sscanf(message, "%15s", map_name);
  760. if ((map_id = map_mapname2mapid(map_name)) < 0)
  761. map_id = sd->bl.m;
  762. }
  763. count = 0;
  764. GM_level = pc_isGM(sd);
  765. iter = mapit_getallusers();
  766. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  767. {
  768. pl_GM_level = pc_isGM(pl_sd);
  769. if( pl_sd->bl.m != map_id )
  770. continue;
  771. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  772. continue;
  773. if (pl_GM_level > 0)
  774. 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);
  775. else
  776. 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);
  777. clif_displaymessage(fd, atcmd_output);
  778. count++;
  779. }
  780. mapit_free(iter);
  781. if (count == 0)
  782. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  783. else if (count == 1)
  784. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  785. else {
  786. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  787. }
  788. clif_displaymessage(fd, atcmd_output);
  789. return 0;
  790. }
  791. /*==========================================
  792. *
  793. *------------------------------------------*/
  794. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  795. {
  796. char temp0[100];
  797. char temp1[100];
  798. struct map_session_data *pl_sd;
  799. struct s_mapiterator* iter;
  800. int count;
  801. int pl_GM_level, GM_level;
  802. int map_id = 0;
  803. char map_name[MAP_NAME_LENGTH_EXT];
  804. struct guild *g;
  805. struct party_data *p;
  806. nullpo_retr(-1, sd);
  807. memset(temp0, '\0', sizeof(temp0));
  808. memset(temp1, '\0', sizeof(temp1));
  809. memset(atcmd_output, '\0', sizeof(atcmd_output));
  810. memset(map_name, '\0', sizeof(map_name));
  811. if (!message || !*message)
  812. map_id = sd->bl.m;
  813. else {
  814. sscanf(message, "%15s", map_name);
  815. if ((map_id = map_mapname2mapid(map_name)) < 0)
  816. map_id = sd->bl.m;
  817. }
  818. count = 0;
  819. GM_level = pc_isGM(sd);
  820. iter = mapit_getallusers();
  821. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  822. {
  823. pl_GM_level = pc_isGM(pl_sd);
  824. if( pl_sd->bl.m != map_id )
  825. continue;
  826. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  827. continue;
  828. g = guild_search(pl_sd->status.guild_id);
  829. if (g == NULL)
  830. sprintf(temp1, "None");
  831. else
  832. sprintf(temp1, "%s", g->name);
  833. p = party_search(pl_sd->status.party_id);
  834. if (p == NULL)
  835. sprintf(temp0, "None");
  836. else
  837. sprintf(temp0, "%s", p->party.name);
  838. if (pl_GM_level > 0)
  839. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  840. else
  841. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  842. clif_displaymessage(fd, atcmd_output);
  843. count++;
  844. }
  845. mapit_free(iter);
  846. if (count == 0)
  847. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  848. else if (count == 1)
  849. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  850. else {
  851. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  852. }
  853. clif_displaymessage(fd, atcmd_output);
  854. return 0;
  855. }
  856. /*==========================================
  857. *
  858. *------------------------------------------*/
  859. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  860. {
  861. struct map_session_data* pl_sd;
  862. struct s_mapiterator* iter;
  863. int j, count;
  864. int pl_GM_level, GM_level;
  865. char match_text[200];
  866. char player_name[NAME_LENGTH];
  867. struct guild *g;
  868. struct party_data *p;
  869. nullpo_retr(-1, sd);
  870. memset(atcmd_output, '\0', sizeof(atcmd_output));
  871. memset(match_text, '\0', sizeof(match_text));
  872. memset(player_name, '\0', sizeof(player_name));
  873. if (sscanf(message, "%199[^\n]", match_text) < 1)
  874. strcpy(match_text, "");
  875. for (j = 0; match_text[j]; j++)
  876. match_text[j] = TOLOWER(match_text[j]);
  877. count = 0;
  878. GM_level = pc_isGM(sd);
  879. iter = mapit_getallusers();
  880. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  881. {
  882. pl_GM_level = pc_isGM(pl_sd);
  883. if (!pl_GM_level)
  884. continue;
  885. if (match_text[0])
  886. {
  887. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  888. for (j = 0; player_name[j]; j++)
  889. player_name[j] = TOLOWER(player_name[j]);
  890. // search with no case sensitive
  891. if (strstr(player_name, match_text) == NULL)
  892. continue;
  893. }
  894. if (pl_GM_level > GM_level) {
  895. if (pl_sd->sc.option & OPTION_INVISIBLE)
  896. continue;
  897. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  898. clif_displaymessage(fd, atcmd_output);
  899. count++;
  900. continue;
  901. }
  902. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  903. pl_sd->status.name, pl_GM_level,
  904. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  905. clif_displaymessage(fd, atcmd_output);
  906. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  907. pl_sd->status.base_level,
  908. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  909. clif_displaymessage(fd, atcmd_output);
  910. p = party_search(pl_sd->status.party_id);
  911. g = guild_search(pl_sd->status.guild_id);
  912. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  913. p?p->party.name:"None", g?g->name:"None");
  914. clif_displaymessage(fd, atcmd_output);
  915. count++;
  916. }
  917. mapit_free(iter);
  918. if (count == 0)
  919. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  920. else if (count == 1)
  921. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  922. else {
  923. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  924. clif_displaymessage(fd, atcmd_output);
  925. }
  926. return 0;
  927. }
  928. /*==========================================
  929. *
  930. *------------------------------------------*/
  931. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  932. {
  933. nullpo_retr(-1, sd);
  934. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  935. if (sd->status.pet_id > 0 && sd->pd)
  936. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  937. chrif_save(sd,0);
  938. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  939. return 0;
  940. }
  941. /*==========================================
  942. *
  943. *------------------------------------------*/
  944. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  945. {
  946. int m;
  947. nullpo_retr(-1, sd);
  948. m = map_mapindex2mapid(sd->status.save_point.map);
  949. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  950. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  951. return -1;
  952. }
  953. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  954. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  955. return -1;
  956. }
  957. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  958. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  959. return 0;
  960. }
  961. /*==========================================
  962. *
  963. *------------------------------------------*/
  964. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  965. {
  966. int speed;
  967. nullpo_retr(-1, sd);
  968. memset(atcmd_output, '\0', sizeof(atcmd_output));
  969. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  970. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  971. clif_displaymessage(fd, atcmd_output);
  972. return -1;
  973. }
  974. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  975. status_calc_bl(&sd->bl, SCB_SPEED);
  976. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  977. return 0;
  978. }
  979. /*==========================================
  980. *
  981. *------------------------------------------*/
  982. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  983. {
  984. nullpo_retr(-1, sd);
  985. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  986. return -1;
  987. if (storage_storageopen(sd) == 1)
  988. { //Already open.
  989. clif_displaymessage(fd, msg_txt(250));
  990. return -1;
  991. }
  992. clif_displaymessage(fd, "Storage opened.");
  993. return 0;
  994. }
  995. /*==========================================
  996. *
  997. *------------------------------------------*/
  998. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  999. {
  1000. nullpo_retr(-1, sd);
  1001. if (!sd->status.guild_id) {
  1002. clif_displaymessage(fd, msg_txt(252));
  1003. return -1;
  1004. }
  1005. if (sd->npc_id || sd->vender_id || sd->state.trading)
  1006. return -1;
  1007. if (sd->state.storage_flag == 1) {
  1008. clif_displaymessage(fd, msg_txt(250));
  1009. return -1;
  1010. }
  1011. if (sd->state.storage_flag == 2) {
  1012. clif_displaymessage(fd, msg_txt(251));
  1013. return -1;
  1014. }
  1015. storage_guild_storageopen(sd);
  1016. clif_displaymessage(fd, "Guild storage opened.");
  1017. return 0;
  1018. }
  1019. /*==========================================
  1020. *
  1021. *------------------------------------------*/
  1022. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1023. {
  1024. int param1 = 0, param2 = 0, param3 = 0;
  1025. nullpo_retr(-1, sd);
  1026. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1027. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1028. return -1;
  1029. }
  1030. sd->sc.opt1 = param1;
  1031. sd->sc.opt2 = param2;
  1032. pc_setoption(sd, param3);
  1033. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1034. return 0;
  1035. }
  1036. /*==========================================
  1037. *
  1038. *------------------------------------------*/
  1039. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1040. {
  1041. nullpo_retr(-1, sd);
  1042. if (sd->sc.option & OPTION_INVISIBLE) {
  1043. sd->sc.option &= ~OPTION_INVISIBLE;
  1044. if (sd->disguise)
  1045. status_set_viewdata(&sd->bl, sd->disguise);
  1046. else
  1047. status_set_viewdata(&sd->bl, sd->status.class_);
  1048. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1049. } else {
  1050. sd->sc.option |= OPTION_INVISIBLE;
  1051. sd->vd.class_ = INVISIBLE_CLASS;
  1052. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1053. }
  1054. clif_changeoption(&sd->bl);
  1055. return 0;
  1056. }
  1057. /*==========================================
  1058. * Changes a character's class
  1059. *------------------------------------------*/
  1060. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1061. {
  1062. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1063. int job = 0, upper = 0;
  1064. nullpo_retr(-1, sd);
  1065. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1066. {
  1067. int i, found = 0;
  1068. const struct { char name[16]; int id; } jobs[] = {
  1069. { "novice", 0 },
  1070. { "swordsman", 1 },
  1071. { "mage", 2 },
  1072. { "archer", 3 },
  1073. { "acolyte", 4 },
  1074. { "merchant", 5 },
  1075. { "thief", 6 },
  1076. { "knight", 7 },
  1077. { "priest", 8 },
  1078. { "priestess", 8 },
  1079. { "wizard", 9 },
  1080. { "blacksmith", 10 },
  1081. { "hunter", 11 },
  1082. { "assassin", 12 },
  1083. { "crusader", 14 },
  1084. { "monk", 15 },
  1085. { "sage", 16 },
  1086. { "rogue", 17 },
  1087. { "alchemist", 18 },
  1088. { "bard", 19 },
  1089. { "dancer", 20 },
  1090. { "super novice", 23 },
  1091. { "supernovice", 23 },
  1092. { "gunslinger", 24 },
  1093. { "gunner", 24 },
  1094. { "ninja", 25 },
  1095. { "high novice", 4001 },
  1096. { "swordsman high", 4002 },
  1097. { "mage high", 4003 },
  1098. { "archer high", 4004 },
  1099. { "acolyte high", 4005 },
  1100. { "merchant high", 4006 },
  1101. { "thief high", 4007 },
  1102. { "lord knight", 4008 },
  1103. { "high priest", 4009 },
  1104. { "high priestess", 4009 },
  1105. { "high wizard", 4010 },
  1106. { "whitesmith", 4011 },
  1107. { "sniper", 4012 },
  1108. { "assassin cross", 4013 },
  1109. { "paladin", 4015 },
  1110. { "champion", 4016 },
  1111. { "professor", 4017 },
  1112. { "stalker", 4018 },
  1113. { "creator", 4019 },
  1114. { "clown", 4020 },
  1115. { "gypsy", 4021 },
  1116. { "baby novice", 4023 },
  1117. { "baby swordsman", 4024 },
  1118. { "baby mage", 4025 },
  1119. { "baby archer", 4026 },
  1120. { "baby acolyte", 4027 },
  1121. { "baby merchant", 4028 },
  1122. { "baby thief", 4029 },
  1123. { "baby knight", 4030 },
  1124. { "baby priest", 4031 },
  1125. { "baby priestess", 4031 },
  1126. { "baby wizard", 4032 },
  1127. { "baby blacksmith",4033 },
  1128. { "baby hunter", 4034 },
  1129. { "baby assassin", 4035 },
  1130. { "baby crusader", 4037 },
  1131. { "baby monk", 4038 },
  1132. { "baby sage", 4039 },
  1133. { "baby rogue", 4040 },
  1134. { "baby alchemist", 4041 },
  1135. { "baby bard", 4042 },
  1136. { "baby dancer", 4043 },
  1137. { "super baby", 4045 },
  1138. { "taekwon", 4046 },
  1139. { "taekwon boy", 4046 },
  1140. { "taekwon girl", 4046 },
  1141. { "star gladiator", 4047 },
  1142. { "soul linker", 4049 },
  1143. };
  1144. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1145. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1146. job = jobs[i].id;
  1147. upper = 0;
  1148. found = 1;
  1149. break;
  1150. }
  1151. }
  1152. if (!found) {
  1153. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1154. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1155. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1156. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1157. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1158. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1159. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1160. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1161. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1162. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1163. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1164. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1165. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1166. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1167. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1168. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1169. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1170. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1171. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1172. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1173. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1174. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1175. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1176. return -1;
  1177. }
  1178. }
  1179. if (job == 37 ||job == 45)
  1180. return 0;
  1181. if (pcdb_checkid(job))
  1182. {
  1183. if (pc_jobchange(sd, job, upper) == 0)
  1184. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1185. else {
  1186. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  1187. return -1;
  1188. }
  1189. } else {
  1190. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1191. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1192. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1193. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1194. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1195. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1196. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1197. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1198. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1199. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1200. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1201. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1202. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1203. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1204. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1205. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1206. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1207. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1208. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1209. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1210. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1211. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1212. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1213. return -1;
  1214. }
  1215. return 0;
  1216. }
  1217. /*==========================================
  1218. *
  1219. *------------------------------------------*/
  1220. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1221. {
  1222. nullpo_retr(-1, sd);
  1223. clif_specialeffect(&sd->bl,450,SELF);
  1224. status_kill(&sd->bl);
  1225. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1226. return 0;
  1227. }
  1228. /*==========================================
  1229. *
  1230. *------------------------------------------*/
  1231. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1232. {
  1233. struct map_session_data *pl_sd;
  1234. nullpo_retr(-1, sd);
  1235. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1236. if (!message || !*message) {
  1237. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1238. return -1;
  1239. }
  1240. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1241. {
  1242. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1243. return -1;
  1244. }
  1245. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1246. { // you can kill only lower or same level
  1247. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1248. return -1;
  1249. }
  1250. status_kill(&pl_sd->bl);
  1251. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1252. if (fd != pl_sd->fd)
  1253. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1254. return 0;
  1255. }
  1256. /*==========================================
  1257. *
  1258. *------------------------------------------*/
  1259. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1260. {
  1261. nullpo_retr(-1, sd);
  1262. if (!status_revive(&sd->bl, 100, 100))
  1263. {
  1264. clif_displaymessage(fd, "You're not dead.");
  1265. return -1;
  1266. }
  1267. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1268. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1269. return 0;
  1270. }
  1271. /*==========================================
  1272. * +kamic [LuzZza]
  1273. *------------------------------------------*/
  1274. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1275. {
  1276. unsigned long color=0;
  1277. nullpo_retr(-1, sd);
  1278. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1279. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1280. if (!message || !*message) {
  1281. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1282. return -1;
  1283. }
  1284. sscanf(message, "%199[^\n]", atcmd_output);
  1285. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1286. } else {
  1287. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1288. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1289. return -1;
  1290. }
  1291. if(color > 0xFFFFFF) {
  1292. clif_displaymessage(fd, "Invalid color.");
  1293. return -1;
  1294. }
  1295. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  1296. }
  1297. return 0;
  1298. }
  1299. /*==========================================
  1300. *
  1301. *------------------------------------------*/
  1302. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1303. {
  1304. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1305. nullpo_retr(-1, sd);
  1306. sscanf(message, "%d %d", &hp, &sp);
  1307. if (hp == 0 && sp == 0) {
  1308. if (!status_percent_heal(&sd->bl, 100, 100))
  1309. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1310. else
  1311. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1312. return 0;
  1313. }
  1314. if(hp > 0 && sp >= 0) {
  1315. if(!status_heal(&sd->bl, hp, sp, 0))
  1316. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1317. else
  1318. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1319. return 0;
  1320. }
  1321. if(hp < 0 && sp <= 0) {
  1322. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1323. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1324. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1325. return 0;
  1326. }
  1327. //Opposing signs.
  1328. if (hp) {
  1329. if (hp > 0)
  1330. status_heal(&sd->bl, hp, 0, 0);
  1331. else {
  1332. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1333. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1334. }
  1335. }
  1336. if (sp) {
  1337. if (sp > 0)
  1338. status_heal(&sd->bl, 0, sp, 0);
  1339. else
  1340. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1341. }
  1342. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1343. return 0;
  1344. }
  1345. /*==========================================
  1346. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1347. *------------------------------------------*/
  1348. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1349. {
  1350. char item_name[100];
  1351. int number = 0, item_id, flag;
  1352. struct item item_tmp;
  1353. struct item_data *item_data;
  1354. int get_count, i;
  1355. nullpo_retr(-1, sd);
  1356. memset(item_name, '\0', sizeof(item_name));
  1357. if (!message || !*message || (
  1358. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1359. sscanf(message, "%99s %d", item_name, &number) < 1
  1360. )) {
  1361. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1362. return -1;
  1363. }
  1364. if (number <= 0)
  1365. number = 1;
  1366. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1367. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1368. {
  1369. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1370. return -1;
  1371. }
  1372. item_id = item_data->nameid;
  1373. get_count = number;
  1374. //Check if it's stackable.
  1375. if (!itemdb_isstackable2(item_data))
  1376. get_count = 1;
  1377. for (i = 0; i < number; i += get_count) {
  1378. // if not pet egg
  1379. if (!pet_create_egg(sd, item_id)) {
  1380. memset(&item_tmp, 0, sizeof(item_tmp));
  1381. item_tmp.nameid = item_id;
  1382. item_tmp.identify = 1;
  1383. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1384. clif_additem(sd, 0, 0, flag);
  1385. }
  1386. }
  1387. //Logs (A)dmins items [Lupus]
  1388. if(log_config.enable_logs&0x400)
  1389. log_pick_pc(sd, "A", item_id, number, NULL);
  1390. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1391. return 0;
  1392. }
  1393. /*==========================================
  1394. *
  1395. *------------------------------------------*/
  1396. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1397. {
  1398. struct item item_tmp;
  1399. struct item_data *item_data;
  1400. char item_name[100];
  1401. int item_id, number = 0;
  1402. int identify = 0, refine = 0, attr = 0;
  1403. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1404. int flag;
  1405. int loop, get_count, i;
  1406. nullpo_retr(-1, sd);
  1407. memset(item_name, '\0', sizeof(item_name));
  1408. if (!message || !*message || (
  1409. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1410. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1411. )) {
  1412. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1413. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1414. return -1;
  1415. }
  1416. if (number <= 0)
  1417. number = 1;
  1418. item_id = 0;
  1419. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1420. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1421. item_id = item_data->nameid;
  1422. if (item_id > 500) {
  1423. loop = 1;
  1424. get_count = number;
  1425. if (item_data->type == 4 || item_data->type == 5 ||
  1426. item_data->type == 7 || item_data->type == 8) {
  1427. loop = number;
  1428. get_count = 1;
  1429. if (item_data->type == 7) {
  1430. identify = 1;
  1431. refine = 0;
  1432. }
  1433. if (item_data->type == 8)
  1434. refine = 0;
  1435. if (refine > 10)
  1436. refine = 10;
  1437. } else {
  1438. identify = 1;
  1439. refine = attr = 0;
  1440. }
  1441. for (i = 0; i < loop; i++) {
  1442. memset(&item_tmp, 0, sizeof(item_tmp));
  1443. item_tmp.nameid = item_id;
  1444. item_tmp.identify = identify;
  1445. item_tmp.refine = refine;
  1446. item_tmp.attribute = attr;
  1447. item_tmp.card[0] = c1;
  1448. item_tmp.card[1] = c2;
  1449. item_tmp.card[2] = c3;
  1450. item_tmp.card[3] = c4;
  1451. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1452. clif_additem(sd, 0, 0, flag);
  1453. }
  1454. //Logs (A)dmins items [Lupus]
  1455. if(log_config.enable_logs&0x400)
  1456. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  1457. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1458. } else {
  1459. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1460. return -1;
  1461. }
  1462. return 0;
  1463. }
  1464. /*==========================================
  1465. *
  1466. *------------------------------------------*/
  1467. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1468. {
  1469. int i;
  1470. nullpo_retr(-1, sd);
  1471. for (i = 0; i < MAX_INVENTORY; i++) {
  1472. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1473. //Logs (A)dmins items [Lupus]
  1474. if(log_config.enable_logs&0x400)
  1475. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1476. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  1477. }
  1478. }
  1479. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1480. return 0;
  1481. }
  1482. /*==========================================
  1483. * Atcommand @lvlup
  1484. *------------------------------------------*/
  1485. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1486. {
  1487. int level=0, i=0, status_point=0;
  1488. nullpo_retr(-1, sd);
  1489. level = atoi(message);
  1490. if (!message || !*message || !level) {
  1491. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1492. return -1;
  1493. }
  1494. if (level > 0) {
  1495. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1496. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1497. return -1;
  1498. } // End Addition
  1499. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1500. level = pc_maxbaselv(sd) - sd->status.base_level;
  1501. for (i = 1; i <= level; i++)
  1502. status_point += (sd->status.base_level + i + 14) / 5;
  1503. if (sd->status.status_point > USHRT_MAX - status_point)
  1504. sd->status.status_point = USHRT_MAX;
  1505. else
  1506. sd->status.status_point += status_point;
  1507. sd->status.base_level += (unsigned int)level;
  1508. status_percent_heal(&sd->bl, 100, 100);
  1509. clif_misceffect(&sd->bl, 0);
  1510. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1511. } else {
  1512. if (sd->status.base_level == 1) {
  1513. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1514. return -1;
  1515. }
  1516. level*=-1;
  1517. if ((unsigned int)level >= sd->status.base_level)
  1518. level = sd->status.base_level-1;
  1519. for (i = 0; i > -level; i--)
  1520. status_point += (sd->status.base_level + i + 14) / 5;
  1521. if (sd->status.status_point < status_point)
  1522. pc_resetstate(sd);
  1523. if (sd->status.status_point < status_point)
  1524. sd->status.status_point = 0;
  1525. else
  1526. sd->status.status_point -= status_point;
  1527. sd->status.base_level -= (unsigned int)level;
  1528. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1529. }
  1530. clif_updatestatus(sd, SP_STATUSPOINT);
  1531. clif_updatestatus(sd, SP_BASELEVEL);
  1532. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1533. status_calc_pc(sd, 0);
  1534. if(sd->status.party_id)
  1535. party_send_levelup(sd);
  1536. return 0;
  1537. }
  1538. /*==========================================
  1539. *
  1540. *------------------------------------------*/
  1541. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1542. {
  1543. int level=0;
  1544. nullpo_retr(-1, sd);
  1545. level = atoi(message);
  1546. if (!message || !*message || !level) {
  1547. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1548. return -1;
  1549. }
  1550. if (level > 0) {
  1551. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1552. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1553. return -1;
  1554. }
  1555. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1556. level = pc_maxjoblv(sd) - sd->status.job_level;
  1557. sd->status.job_level += (unsigned int)level;
  1558. clif_updatestatus(sd, SP_JOBLEVEL);
  1559. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1560. if (sd->status.skill_point > USHRT_MAX - level)
  1561. sd->status.skill_point = USHRT_MAX;
  1562. else
  1563. sd->status.skill_point += level;
  1564. clif_updatestatus(sd, SP_SKILLPOINT);
  1565. status_calc_pc(sd, 0);
  1566. clif_misceffect(&sd->bl, 1);
  1567. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1568. } else {
  1569. if (sd->status.job_level == 1) {
  1570. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1571. return -1;
  1572. }
  1573. level *=-1;
  1574. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1575. level = sd->status.job_level-1;
  1576. sd->status.job_level -= (unsigned int)level;
  1577. clif_updatestatus(sd, SP_JOBLEVEL);
  1578. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1579. if (sd->status.skill_point < level)
  1580. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1581. if (sd->status.skill_point < level)
  1582. sd->status.skill_point = 0;
  1583. else
  1584. sd->status.skill_point -= level;
  1585. clif_updatestatus(sd, SP_SKILLPOINT);
  1586. status_calc_pc(sd, 0);
  1587. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1588. }
  1589. return 0;
  1590. }
  1591. /*==========================================
  1592. * @help
  1593. *------------------------------------------*/
  1594. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1595. {
  1596. char buf[2048], w1[2048], w2[2048];
  1597. int i, gm_level;
  1598. FILE* fp;
  1599. nullpo_retr(-1, sd);
  1600. memset(buf, '\0', sizeof(buf));
  1601. if ((fp = fopen(help_txt, "r")) != NULL) {
  1602. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1603. gm_level = pc_isGM(sd);
  1604. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1605. if (buf[0] == '/' && buf[1] == '/')
  1606. continue;
  1607. for (i = 0; buf[i] != '\0'; i++) {
  1608. if (buf[i] == '\r' || buf[i] == '\n') {
  1609. buf[i] = '\0';
  1610. break;
  1611. }
  1612. }
  1613. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1614. clif_displaymessage(fd, buf);
  1615. else if (gm_level >= atoi(w1))
  1616. clif_displaymessage(fd, w2);
  1617. }
  1618. fclose(fp);
  1619. } else {
  1620. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1621. return -1;
  1622. }
  1623. return 0;
  1624. }
  1625. /*==========================================
  1626. * @help2 - Char commands [Kayla]
  1627. *------------------------------------------*/
  1628. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1629. {
  1630. char buf[2048], w1[2048], w2[2048];
  1631. int i, gm_level;
  1632. FILE* fp;
  1633. nullpo_retr(-1, sd);
  1634. memset(buf, '\0', sizeof(buf));
  1635. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1636. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1637. gm_level = pc_isGM(sd);
  1638. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1639. if (buf[0] == '/' && buf[1] == '/')
  1640. continue;
  1641. for (i = 0; buf[i] != '\0'; i++) {
  1642. if (buf[i] == '\r' || buf[i] == '\n') {
  1643. buf[i] = '\0';
  1644. break;
  1645. }
  1646. }
  1647. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1648. clif_displaymessage(fd, buf);
  1649. else if (gm_level >= atoi(w1))
  1650. clif_displaymessage(fd, w2);
  1651. }
  1652. fclose(fp);
  1653. } else {
  1654. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1655. return -1;
  1656. }
  1657. return 0;
  1658. }
  1659. // helper function, used in foreach calls to stop auto-attack timers
  1660. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1661. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1662. {
  1663. struct unit_data *ud = unit_bl2ud(bl);
  1664. int id = va_arg(ap, int);
  1665. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1666. {
  1667. unit_stop_attack(bl);
  1668. return 1;
  1669. }
  1670. return 0;
  1671. }
  1672. /*==========================================
  1673. *
  1674. *------------------------------------------*/
  1675. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1676. {
  1677. TBL_PC* sd = (TBL_PC*)bl;
  1678. clif_pvpset(sd, 0, 0, 2);
  1679. if (sd->pvp_timer != -1) {
  1680. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1681. sd->pvp_timer = INVALID_TIMER;
  1682. }
  1683. return 0;
  1684. }
  1685. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1686. {
  1687. nullpo_retr(-1, sd);
  1688. if (!map[sd->bl.m].flag.pvp) {
  1689. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1690. return -1;
  1691. }
  1692. map[sd->bl.m].flag.pvp = 0;
  1693. if (!battle_config.pk_mode)
  1694. clif_send0199(sd->bl.m, 0);
  1695. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1696. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1697. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1698. return 0;
  1699. }
  1700. /*==========================================
  1701. *
  1702. *------------------------------------------*/
  1703. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1704. {
  1705. TBL_PC* sd = (TBL_PC*)bl;
  1706. if (sd->pvp_timer == -1) {
  1707. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1708. sd->pvp_rank = 0;
  1709. sd->pvp_lastusers = 0;
  1710. sd->pvp_point = 5;
  1711. sd->pvp_won = 0;
  1712. sd->pvp_lost = 0;
  1713. }
  1714. return 0;
  1715. }
  1716. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1717. {
  1718. nullpo_retr(-1, sd);
  1719. if (map[sd->bl.m].flag.pvp) {
  1720. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1721. return -1;
  1722. }
  1723. map[sd->bl.m].flag.pvp = 1;
  1724. if (!battle_config.pk_mode)
  1725. {// display pvp circle and rank
  1726. clif_send0199(sd->bl.m, 1);
  1727. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1728. }
  1729. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1730. return 0;
  1731. }
  1732. /*==========================================
  1733. *
  1734. *------------------------------------------*/
  1735. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1736. {
  1737. nullpo_retr(-1, sd);
  1738. if (!map[sd->bl.m].flag.gvg) {
  1739. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1740. return -1;
  1741. }
  1742. map[sd->bl.m].flag.gvg = 0;
  1743. clif_send0199(sd->bl.m, 0);
  1744. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1745. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1746. return 0;
  1747. }
  1748. /*==========================================
  1749. *
  1750. *------------------------------------------*/
  1751. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1752. {
  1753. nullpo_retr(-1, sd);
  1754. if (map[sd->bl.m].flag.gvg) {
  1755. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1756. return -1;
  1757. }
  1758. map[sd->bl.m].flag.gvg = 1;
  1759. clif_send0199(sd->bl.m, 3);
  1760. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1761. return 0;
  1762. }
  1763. /*==========================================
  1764. *
  1765. *------------------------------------------*/
  1766. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1767. {
  1768. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1769. nullpo_retr(-1, sd);
  1770. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1771. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1772. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1773. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1774. clif_displaymessage(fd, atcmd_output);
  1775. return -1;
  1776. }
  1777. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1778. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1779. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1780. pc_changelook(sd, LOOK_HAIR, hair_style);
  1781. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1782. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1783. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1784. } else {
  1785. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1786. return -1;
  1787. }
  1788. return 0;
  1789. }
  1790. /*==========================================
  1791. * @dye && @ccolor
  1792. *------------------------------------------*/
  1793. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1794. {
  1795. int cloth_color = 0;
  1796. nullpo_retr(-1, sd);
  1797. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1798. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1799. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1800. clif_displaymessage(fd, atcmd_output);
  1801. return -1;
  1802. }
  1803. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1804. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1805. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1806. } else {
  1807. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1808. return -1;
  1809. }
  1810. return 0;
  1811. }
  1812. /*==========================================
  1813. * @hairstyle && @hstyle
  1814. *------------------------------------------*/
  1815. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1816. {
  1817. int hair_style = 0;
  1818. nullpo_retr(-1, sd);
  1819. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1820. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1821. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1822. clif_displaymessage(fd, atcmd_output);
  1823. return -1;
  1824. }
  1825. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1826. pc_changelook(sd, LOOK_HAIR, hair_style);
  1827. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1828. } else {
  1829. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1830. return -1;
  1831. }
  1832. return 0;
  1833. }
  1834. /*==========================================
  1835. * @haircolor && @hcolor
  1836. *------------------------------------------*/
  1837. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1838. {
  1839. int hair_color = 0;
  1840. nullpo_retr(-1, sd);
  1841. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1842. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1843. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1844. clif_displaymessage(fd, atcmd_output);
  1845. return -1;
  1846. }
  1847. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1848. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1849. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1850. } else {
  1851. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1852. return -1;
  1853. }
  1854. return 0;
  1855. }
  1856. /*==========================================
  1857. * @go [city_number or city_name] - Updated by Harbin
  1858. *------------------------------------------*/
  1859. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1860. {
  1861. int i;
  1862. int town;
  1863. char map_name[MAP_NAME_LENGTH];
  1864. int m;
  1865. const struct {
  1866. char map[MAP_NAME_LENGTH];
  1867. int x, y;
  1868. } data[] = {
  1869. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1870. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1871. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1872. { MAP_PAYON, 162, 233 }, // 3=Payon
  1873. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1874. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1875. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1876. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1877. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1878. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1879. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1880. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1881. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1882. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1883. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1884. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1885. { MAP_JAIL, 23, 61 }, // 16=Prison
  1886. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1887. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1888. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1889. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1890. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1891. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1892. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1893. { MAP_VEINS, 216, 123 }, // 24=Veins
  1894. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1895. };
  1896. nullpo_retr(-1, sd);
  1897. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  1898. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1899. return 0;
  1900. }
  1901. memset(map_name, '\0', sizeof(map_name));
  1902. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1903. // get the number
  1904. town = atoi(message);
  1905. // if no value, display all value
  1906. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1907. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1908. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  1909. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1910. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1911. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1912. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1913. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1914. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1915. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1916. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  1917. clif_displaymessage(fd, " 24=Veins 25=Moscovia");
  1918. return -1;
  1919. }
  1920. // get possible name of the city
  1921. map_name[MAP_NAME_LENGTH-1] = '\0';
  1922. for (i = 0; map_name[i]; i++)
  1923. map_name[i] = TOLOWER(map_name[i]);
  1924. // try to identify the map name
  1925. if (strncmp(map_name, "prontera", 3) == 0) {
  1926. town = 0;
  1927. } else if (strncmp(map_name, "morocc", 3) == 0) {
  1928. town = 1;
  1929. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1930. town = 2;
  1931. } else if (strncmp(map_name, "payon", 3) == 0 ||
  1932. strncmp(map_name, "paion", 3) == 0) {
  1933. town = 3;
  1934. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1935. town = 4;
  1936. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  1937. strncmp(map_name, "islude", 3) == 0) {
  1938. town = 5;
  1939. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  1940. strcmp(map_name, "al") == 0) {
  1941. town = 6;
  1942. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1943. strcmp(map_name, "christmas") == 0 ||
  1944. strncmp(map_name, "xmas", 3) == 0 ||
  1945. strncmp(map_name, "x-mas", 3) == 0) {
  1946. town = 7;
  1947. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1948. town = 8;
  1949. } else if (strncmp(map_name, "yuno", 3) == 0) {
  1950. town = 9;
  1951. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1952. town = 10;
  1953. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  1954. town = 11;
  1955. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1956. town = 12;
  1957. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1958. town = 13;
  1959. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1960. town = 14;
  1961. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1962. strncmp(map_name, "startpoint", 3) == 0 ||
  1963. strncmp(map_name, "begining", 3) == 0) {
  1964. town = 15;
  1965. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1966. strncmp(map_name, "prison", 3) == 0 ||
  1967. strncmp(map_name, "jails", 3) == 0) {
  1968. town = 16;
  1969. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  1970. strncmp(map_name, "jawai", 3) == 0) {
  1971. town = 17;
  1972. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  1973. strncmp(map_name, "ayotaya", 3) == 0) {
  1974. town = 18;
  1975. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  1976. strncmp(map_name, "ainbroch", 5) == 0) {
  1977. town = 19;
  1978. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1979. town = 20;
  1980. } else if (strncmp(map_name, "einbech", 3) == 0) {
  1981. town = 21;
  1982. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1983. town = 22;
  1984. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1985. town = 23;
  1986. } else if (strncmp(map_name, "veins", 3) == 0) {
  1987. town = 24;
  1988. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1989. town = 25;
  1990. }
  1991. if (town >= 0 && town < ARRAYLENGTH(data))
  1992. {
  1993. m = map_mapname2mapid(data[town].map);
  1994. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1995. clif_displaymessage(fd, msg_txt(247));
  1996. return -1;
  1997. }
  1998. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1999. clif_displaymessage(fd, msg_txt(248));
  2000. return -1;
  2001. }
  2002. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
  2003. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2004. } else {
  2005. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2006. return -1;
  2007. }
  2008. } else { // if you arrive here, you have an error in town variable when reading of names
  2009. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2010. return -1;
  2011. }
  2012. return 0;
  2013. }
  2014. /*==========================================
  2015. *
  2016. *------------------------------------------*/
  2017. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2018. {
  2019. char name[NAME_LENGTH];
  2020. char monster[NAME_LENGTH];
  2021. int mob_id;
  2022. int number = 0;
  2023. int count;
  2024. int i, k, range;
  2025. short mx, my;
  2026. nullpo_retr(-1, sd);
  2027. memset(name, '\0', sizeof(name));
  2028. memset(monster, '\0', sizeof(monster));
  2029. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2030. if (!message || !*message) {
  2031. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2032. return -1;
  2033. }
  2034. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2035. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2036. //All data can be left as it is.
  2037. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2038. //Here, it is possible name was not given and we are using monster for it.
  2039. if (count < 3) //Blank mob's name.
  2040. name[0] = '\0';
  2041. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2042. //All data can be left as it is.
  2043. } else if (sscanf(message, "%23s", monster) > 0) {
  2044. //As before, name may be already filled.
  2045. name[0] = '\0';
  2046. } else {
  2047. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2048. return -1;
  2049. }
  2050. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2051. mob_id = mobdb_checkid(atoi(monster));
  2052. if (mob_id == 0) {
  2053. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2054. return -1;
  2055. }
  2056. if (mob_id == MOBID_EMPERIUM) {
  2057. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  2058. return -1;
  2059. }
  2060. if (number <= 0)
  2061. number = 1;
  2062. if (strlen(name) < 1)
  2063. strcpy(name, "--ja--");
  2064. // 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
  2065. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2066. number = battle_config.atc_spawn_quantity_limit;
  2067. if (battle_config.etc_log)
  2068. 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);
  2069. count = 0;
  2070. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2071. for (i = 0; i < number; i++) {
  2072. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2073. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2074. count += (k != 0) ? 1 : 0;
  2075. }
  2076. if (count != 0)
  2077. if (number == count)
  2078. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2079. else {
  2080. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2081. clif_displaymessage(fd, atcmd_output);
  2082. }
  2083. else {
  2084. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2085. return -1;
  2086. }
  2087. return 0;
  2088. }
  2089. // small monster spawning [Valaris]
  2090. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2091. {
  2092. char name[NAME_LENGTH] = "";
  2093. char monster[NAME_LENGTH] = "";
  2094. int mob_id = 0;
  2095. int number = 0;
  2096. int x = 0;
  2097. int y = 0;
  2098. int count;
  2099. int i;
  2100. nullpo_retr(-1, sd);
  2101. if (!message || !*message) {
  2102. clif_displaymessage(fd, "Give a monster name/id please.");
  2103. return -1;
  2104. }
  2105. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2106. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2107. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2108. clif_displaymessage(fd, "Give a monster name/id please.");
  2109. return -1;
  2110. }
  2111. // If monster identifier/name argument is a name
  2112. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2113. mob_id = atoi(monster);
  2114. if (mob_id == 0) {
  2115. clif_displaymessage(fd, msg_txt(40));
  2116. return -1;
  2117. }
  2118. if (mob_id == MOBID_EMPERIUM) {
  2119. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2120. return -1;
  2121. }
  2122. if (mobdb_checkid(mob_id) == 0) {
  2123. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2124. return -1;
  2125. }
  2126. if (number <= 0)
  2127. number = 1;
  2128. if (strlen(name) < 1)
  2129. strcpy(name, "--ja--");
  2130. // 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
  2131. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2132. number = battle_config.atc_spawn_quantity_limit;
  2133. count = 0;
  2134. for (i = 0; i < number; i++) {
  2135. int mx, my;
  2136. if (x <= 0)
  2137. mx = sd->bl.x + (rand() % 11 - 5);
  2138. else
  2139. mx = x;
  2140. if (y <= 0)
  2141. my = sd->bl.y + (rand() % 11 - 5);
  2142. else
  2143. my = y;
  2144. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2145. }
  2146. if (count != 0)
  2147. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2148. else
  2149. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2150. return 0;
  2151. }
  2152. // big monster spawning [Valaris]
  2153. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2154. {
  2155. char name[NAME_LENGTH] = "";
  2156. char monster[NAME_LENGTH] = "";
  2157. int mob_id = 0;
  2158. int number = 0;
  2159. int x = 0;
  2160. int y = 0;
  2161. int count;
  2162. int i;
  2163. nullpo_retr(-1, sd);
  2164. if (!message || !*message) {
  2165. clif_displaymessage(fd, "Give a monster name/id please.");
  2166. return -1;
  2167. }
  2168. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2169. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2170. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2171. clif_displaymessage(fd, "Give a monster name/id please.");
  2172. return -1;
  2173. }
  2174. // If monster identifier/name argument is a name
  2175. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2176. mob_id = atoi(monster);
  2177. if (mob_id == 0) {
  2178. clif_displaymessage(fd, msg_txt(40));
  2179. return -1;
  2180. }
  2181. if (mob_id == MOBID_EMPERIUM) {
  2182. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2183. return -1;
  2184. }
  2185. if (mobdb_checkid(mob_id) == 0) {
  2186. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2187. return -1;
  2188. }
  2189. if (number <= 0)
  2190. number = 1;
  2191. if (strlen(name) < 1)
  2192. strcpy(name, "--ja--");
  2193. // 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
  2194. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2195. number = battle_config.atc_spawn_quantity_limit;
  2196. count = 0;
  2197. for (i = 0; i < number; i++) {
  2198. int mx, my;
  2199. if (x <= 0)
  2200. mx = sd->bl.x + (rand() % 11 - 5);
  2201. else
  2202. mx = x;
  2203. if (y <= 0)
  2204. my = sd->bl.y + (rand() % 11 - 5);
  2205. else
  2206. my = y;
  2207. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2208. }
  2209. if (count != 0)
  2210. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2211. else
  2212. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2213. return 0;
  2214. }
  2215. /*==========================================
  2216. *
  2217. *------------------------------------------*/
  2218. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2219. {
  2220. struct mob_data *md;
  2221. int flag;
  2222. nullpo_retr(0, ap);
  2223. nullpo_retr(0, md=(struct mob_data *)bl);
  2224. flag = va_arg(ap, int);
  2225. if (md->guardian_data)
  2226. return 0; //Do not touch WoE mobs!
  2227. if (flag)
  2228. status_zap(bl,md->status.hp, 0);
  2229. else
  2230. status_kill(bl);
  2231. return 1;
  2232. }
  2233. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2234. {
  2235. int map_id;
  2236. char map_name[MAP_NAME_LENGTH_EXT];
  2237. if (!sd) return;
  2238. memset(map_name, '\0', sizeof(map_name));
  2239. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2240. map_id = sd->bl.m;
  2241. else {
  2242. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2243. map_id = sd->bl.m;
  2244. }
  2245. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2246. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2247. return;
  2248. }
  2249. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2250. {
  2251. atcommand_killmonster_sub(fd, sd, message, 1);
  2252. return 0;
  2253. }
  2254. /*==========================================
  2255. *
  2256. *------------------------------------------*/
  2257. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2258. {
  2259. atcommand_killmonster_sub(fd, sd, message, 0);
  2260. return 0;
  2261. }
  2262. /*==========================================
  2263. *
  2264. *------------------------------------------*/
  2265. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2266. {
  2267. int i,j, position = 0, refine = 0, current_position, final_refine;
  2268. int count;
  2269. nullpo_retr(-1, sd);
  2270. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2271. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2272. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  2273. sprintf(atcmd_output, "%d: Left Accessory", EQI_ACC_L);
  2274. clif_displaymessage(fd, atcmd_output);
  2275. sprintf(atcmd_output, "%d: Right Accessory", EQI_ACC_R);
  2276. clif_displaymessage(fd, atcmd_output);
  2277. sprintf(atcmd_output, "%d: Shoes", EQI_SHOES);
  2278. clif_displaymessage(fd, atcmd_output);
  2279. sprintf(atcmd_output, "%d: Garment", EQI_GARMENT);
  2280. clif_displaymessage(fd, atcmd_output);
  2281. sprintf(atcmd_output, "%d: Lower Headgear", EQI_HEAD_LOW);
  2282. clif_displaymessage(fd, atcmd_output);
  2283. sprintf(atcmd_output, "%d: Mid Headgear", EQI_HEAD_MID);
  2284. clif_displaymessage(fd, atcmd_output);
  2285. sprintf(atcmd_output, "%d: Top Headgear", EQI_HEAD_TOP);
  2286. clif_displaymessage(fd, atcmd_output);
  2287. sprintf(atcmd_output, "%d: Body Armor", EQI_ARMOR);
  2288. clif_displaymessage(fd, atcmd_output);
  2289. sprintf(atcmd_output, "%d: Left Hand", EQI_HAND_L);
  2290. clif_displaymessage(fd, atcmd_output);
  2291. sprintf(atcmd_output, "%d: Right Hand", EQI_HAND_R);
  2292. clif_displaymessage(fd, atcmd_output);
  2293. return -1;
  2294. }
  2295. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2296. count = 0;
  2297. for (j = 0; j < EQI_MAX-1; j++) {
  2298. if ((i = sd->equip_index[j]) < 0)
  2299. continue;
  2300. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2301. continue;
  2302. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2303. continue;
  2304. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2305. continue;
  2306. if(position && !(sd->status.inventory[i].equip & position))
  2307. continue;
  2308. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2309. if (sd->status.inventory[i].refine != final_refine) {
  2310. sd->status.inventory[i].refine = final_refine;
  2311. current_position = sd->status.inventory[i].equip;
  2312. pc_unequipitem(sd, i, 3);
  2313. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2314. clif_delitem(sd, i, 1);
  2315. clif_additem(sd, i, 1, 0);
  2316. pc_equipitem(sd, i, current_position);
  2317. clif_misceffect(&sd->bl, 3);
  2318. count++;
  2319. }
  2320. }
  2321. if (count == 0)
  2322. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  2323. else if (count == 1)
  2324. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  2325. else {
  2326. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  2327. clif_displaymessage(fd, atcmd_output);
  2328. }
  2329. return 0;
  2330. }
  2331. /*==========================================
  2332. *
  2333. *------------------------------------------*/
  2334. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2335. {
  2336. char item_name[100];
  2337. int item_id, attribute = 0, star = 0;
  2338. int flag = 0;
  2339. struct item_data *item_data;
  2340. struct item tmp_item;
  2341. nullpo_retr(-1, sd);
  2342. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2343. memset(item_name, '\0', sizeof(item_name));
  2344. if (!message || !*message || (
  2345. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2346. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2347. )) {
  2348. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2349. return -1;
  2350. }
  2351. item_id = 0;
  2352. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2353. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2354. {
  2355. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  2356. clif_displaymessage(fd, atcmd_output);
  2357. return -1;
  2358. }
  2359. item_id = item_data->nameid;
  2360. if (itemdb_isequip2(item_data)) {
  2361. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2362. attribute = ATTRIBUTE_NORMAL;
  2363. if (star < MIN_STAR || star > MAX_STAR)
  2364. star = 0;
  2365. memset(&tmp_item, 0, sizeof tmp_item);
  2366. tmp_item.nameid = item_id;
  2367. tmp_item.amount = 1;
  2368. tmp_item.identify = 1;
  2369. tmp_item.card[0] = CARD0_FORGE;
  2370. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2371. ((star*5) << 8) + attribute:0;
  2372. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2373. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2374. clif_produceeffect(sd, 0, item_id);
  2375. clif_misceffect(&sd->bl, 3);
  2376. //Logs (A)dmins items [Lupus]
  2377. if(log_config.enable_logs&0x400)
  2378. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  2379. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2380. clif_additem(sd, 0, 0, flag);
  2381. } else {
  2382. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  2383. clif_displaymessage(fd, atcmd_output);
  2384. return -1;
  2385. }
  2386. return 0;
  2387. }
  2388. /*==========================================
  2389. *
  2390. *------------------------------------------*/
  2391. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2392. {
  2393. int position = 0;
  2394. nullpo_retr(-1, sd);
  2395. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2396. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2397. {
  2398. int i;
  2399. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2400. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2401. {
  2402. if( sd->status.memo_point[i].map )
  2403. 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);
  2404. else
  2405. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2406. clif_displaymessage(sd->fd, atcmd_output);
  2407. }
  2408. return 0;
  2409. }
  2410. if( position < 0 && position >= MAX_MEMOPOINTS )
  2411. {
  2412. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2413. clif_displaymessage(fd, atcmd_output);
  2414. return -1;
  2415. }
  2416. pc_memo(sd, position);
  2417. return 0;
  2418. }
  2419. /*==========================================
  2420. *
  2421. *------------------------------------------*/
  2422. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2423. {
  2424. int y;
  2425. nullpo_retr(-1, sd);
  2426. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2427. for (y = 2; y >= -2; y--) {
  2428. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2429. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2430. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2431. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2432. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2433. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2434. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2435. clif_displaymessage(fd, atcmd_output);
  2436. }
  2437. return 0;
  2438. }
  2439. /*==========================================
  2440. *
  2441. *------------------------------------------*/
  2442. int atcommand_displaystatus(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2443. {
  2444. int i, type, flag;
  2445. nullpo_retr(-1, sd);
  2446. if (!message || !*message || (i = sscanf(message, "%d %d", &type, &flag)) < 1) {
  2447. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag>).");
  2448. return -1;
  2449. }
  2450. if (i == 1) flag = 1;
  2451. clif_status_change(&sd->bl, type, flag);
  2452. return 0;
  2453. }
  2454. /*==========================================
  2455. * @stpoint (Rewritten by [Yor])
  2456. *------------------------------------------*/
  2457. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2458. {
  2459. int point, new_status_point;
  2460. if (!message || !*message || (point = atoi(message)) == 0) {
  2461. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2462. return -1;
  2463. }
  2464. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  2465. new_status_point = USHRT_MAX;
  2466. else
  2467. if (point < 0 && sd->status.status_point < -point)
  2468. new_status_point = 0;
  2469. else
  2470. new_status_point = sd->status.status_point + point;
  2471. if (new_status_point != (int)sd->status.status_point) {
  2472. sd->status.status_point = (unsigned short)new_status_point;
  2473. clif_updatestatus(sd, SP_STATUSPOINT);
  2474. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  2475. } else {
  2476. if (point < 0)
  2477. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2478. else
  2479. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2480. return -1;
  2481. }
  2482. return 0;
  2483. }
  2484. /*==========================================
  2485. * @skpoint (Rewritten by [Yor])
  2486. *------------------------------------------*/
  2487. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2488. {
  2489. int point, new_skill_point;
  2490. nullpo_retr(-1, sd);
  2491. if (!message || !*message || (point = atoi(message)) == 0) {
  2492. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2493. return -1;
  2494. }
  2495. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  2496. new_skill_point = USHRT_MAX;
  2497. else if (point < 0 && sd->status.skill_point < -point)
  2498. new_skill_point = 0;
  2499. else
  2500. new_skill_point = sd->status.skill_point + point;
  2501. if (new_skill_point != (int)sd->status.skill_point) {
  2502. sd->status.skill_point = (unsigned short)new_skill_point;
  2503. clif_updatestatus(sd, SP_SKILLPOINT);
  2504. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  2505. } else {
  2506. if (point < 0)
  2507. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2508. else
  2509. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2510. return -1;
  2511. }
  2512. return 0;
  2513. }
  2514. /*==========================================
  2515. * @zeny (Rewritten by [Yor])
  2516. *------------------------------------------*/
  2517. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2518. {
  2519. int zeny, new_zeny;
  2520. nullpo_retr(-1, sd);
  2521. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2522. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2523. return -1;
  2524. }
  2525. new_zeny = sd->status.zeny + zeny;
  2526. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2527. new_zeny = MAX_ZENY;
  2528. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2529. new_zeny = 0;
  2530. if (new_zeny != sd->status.zeny) {
  2531. sd->status.zeny = new_zeny;
  2532. clif_updatestatus(sd, SP_ZENY);
  2533. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  2534. } else {
  2535. if (zeny < 0)
  2536. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2537. else
  2538. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2539. return -1;
  2540. }
  2541. return 0;
  2542. }
  2543. /*==========================================
  2544. *
  2545. *------------------------------------------*/
  2546. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2547. {
  2548. int i, value = 0, new_value, max;
  2549. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  2550. short* status[6];
  2551. //we don't use direct initialization because it isn't part of the c standard.
  2552. nullpo_retr(-1, sd);
  2553. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2554. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2555. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2556. clif_displaymessage(fd, atcmd_output);
  2557. return -1;
  2558. }
  2559. for (i = 0; param[i] != NULL; i++)
  2560. if (strcmpi(command, param[i]) == 0)
  2561. break;
  2562. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  2563. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2564. clif_displaymessage(fd, atcmd_output);
  2565. return -1;
  2566. }
  2567. status[0] = &sd->status.str;
  2568. status[1] = &sd->status.agi;
  2569. status[2] = &sd->status.vit;
  2570. status[3] = &sd->status.int_;
  2571. status[4] = &sd->status.dex;
  2572. status[5] = &sd->status.luk;
  2573. max = SHRT_MAX;
  2574. new_value = cap_value(*status[i] + value, 1, max);
  2575. if (new_value != (int)*status[i]) {
  2576. *status[i] = new_value;
  2577. clif_updatestatus(sd, SP_STR + i);
  2578. clif_updatestatus(sd, SP_USTR + i);
  2579. status_calc_pc(sd, 0);
  2580. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2581. } else {
  2582. if (value < 0)
  2583. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2584. else
  2585. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2586. return -1;
  2587. }
  2588. return 0;
  2589. }
  2590. /*==========================================
  2591. * Stat all by fritz (rewritten by [Yor])
  2592. *------------------------------------------*/
  2593. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2594. {
  2595. int index, count, value, max, new_value;
  2596. short* status[6];
  2597. //we don't use direct initialization because it isn't part of the c standard.
  2598. nullpo_retr(-1, sd);
  2599. status[0] = &sd->status.str;
  2600. status[1] = &sd->status.agi;
  2601. status[2] = &sd->status.vit;
  2602. status[3] = &sd->status.int_;
  2603. status[4] = &sd->status.dex;
  2604. status[5] = &sd->status.luk;
  2605. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2606. value = pc_maxparameter(sd);
  2607. max = pc_maxparameter(sd);
  2608. } else {
  2609. max = SHRT_MAX;
  2610. }
  2611. count = 0;
  2612. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2613. if (value > 0 && *status[index] > max - value)
  2614. new_value = max;
  2615. else if (value < 0 && *status[index] <= -value)
  2616. new_value = 1;
  2617. else
  2618. new_value = *status[index] +value;
  2619. if (new_value != (int)*status[index]) {
  2620. *status[index] = new_value;
  2621. clif_updatestatus(sd, SP_STR + index);
  2622. clif_updatestatus(sd, SP_USTR + index);
  2623. count++;
  2624. }
  2625. }
  2626. if (count > 0) { // if at least 1 stat modified
  2627. status_calc_pc(sd, 0);
  2628. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2629. } else {
  2630. if (value < 0)
  2631. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  2632. else
  2633. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  2634. return -1;
  2635. }
  2636. return 0;
  2637. }
  2638. /*==========================================
  2639. *
  2640. *------------------------------------------*/
  2641. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2642. {
  2643. int level = 0;
  2644. short added_level;
  2645. struct guild *guild_info;
  2646. nullpo_retr(-1, sd);
  2647. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2648. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2649. return -1;
  2650. }
  2651. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2652. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2653. return -1;
  2654. }
  2655. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2656. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2657. // return -1;
  2658. //}
  2659. added_level = (short)level;
  2660. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2661. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2662. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2663. added_level = 1 - guild_info->guild_lv;
  2664. if (added_level != 0) {
  2665. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  2666. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2667. } else {
  2668. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2669. return -1;
  2670. }
  2671. return 0;
  2672. }
  2673. /*==========================================
  2674. *
  2675. *------------------------------------------*/
  2676. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2677. {
  2678. struct item_data *item_data;
  2679. int id, pet_id;
  2680. nullpo_retr(-1, sd);
  2681. if (!message || !*message) {
  2682. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2683. return -1;
  2684. }
  2685. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2686. id = item_data->nameid;
  2687. else
  2688. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2689. ;
  2690. else
  2691. id = atoi(message);
  2692. pet_id = search_petDB_index(id, PET_CLASS);
  2693. if (pet_id < 0)
  2694. pet_id = search_petDB_index(id, PET_EGG);
  2695. if (pet_id >= 0) {
  2696. sd->catch_target_class = pet_db[pet_id].class_;
  2697. intif_create_pet(
  2698. sd->status.account_id, sd->status.char_id,
  2699. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2700. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2701. 100, 0, 1, pet_db[pet_id].jname);
  2702. } else {
  2703. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2704. return -1;
  2705. }
  2706. return 0;
  2707. }
  2708. /*==========================================
  2709. *
  2710. *------------------------------------------*/
  2711. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2712. {
  2713. nullpo_retr(-1, sd);
  2714. if (sd->status.pet_id <= 0)
  2715. clif_sendegg(sd);
  2716. else {
  2717. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2718. return -1;
  2719. }
  2720. return 0;
  2721. }
  2722. /*==========================================
  2723. *
  2724. *------------------------------------------*/
  2725. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2726. {
  2727. int friendly;
  2728. struct pet_data *pd;
  2729. nullpo_retr(-1, sd);
  2730. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2731. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2732. return -1;
  2733. }
  2734. pd = sd->pd;
  2735. if (!pd) {
  2736. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2737. return -1;
  2738. }
  2739. if (friendly < 0 || friendly > 1000)
  2740. {
  2741. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2742. return -1;
  2743. }
  2744. if (friendly == pd->pet.intimate) {
  2745. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  2746. return -1;
  2747. }
  2748. pd->pet.intimate = friendly;
  2749. clif_send_petstatus(sd);
  2750. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  2751. return 0;
  2752. }
  2753. /*==========================================
  2754. *
  2755. *------------------------------------------*/
  2756. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2757. {
  2758. int hungry;
  2759. struct pet_data *pd;
  2760. nullpo_retr(-1, sd);
  2761. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2762. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2763. return -1;
  2764. }
  2765. pd = sd->pd;
  2766. if (!sd->status.pet_id || !pd) {
  2767. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2768. return -1;
  2769. }
  2770. if (hungry < 0 || hungry > 100) {
  2771. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2772. return -1;
  2773. }
  2774. if (hungry == pd->pet.hungry) {
  2775. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  2776. return -1;
  2777. }
  2778. pd->pet.hungry = hungry;
  2779. clif_send_petstatus(sd);
  2780. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  2781. return 0;
  2782. }
  2783. /*==========================================
  2784. *
  2785. *------------------------------------------*/
  2786. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2787. {
  2788. struct pet_data *pd;
  2789. nullpo_retr(-1, sd);
  2790. if (!sd->status.pet_id || !sd->pd) {
  2791. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2792. return -1;
  2793. }
  2794. pd = sd->pd;
  2795. if (!pd->pet.rename_flag) {
  2796. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2797. return -1;
  2798. }
  2799. pd->pet.rename_flag = 0;
  2800. intif_save_petdata(sd->status.account_id, &pd->pet);
  2801. clif_send_petstatus(sd);
  2802. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2803. return 0;
  2804. }
  2805. /*==========================================
  2806. *
  2807. *------------------------------------------*/
  2808. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2809. {
  2810. struct map_session_data *pl_sd = NULL;
  2811. nullpo_retr(-1, sd);
  2812. if (!message || !*message) {
  2813. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2814. return -1;
  2815. }
  2816. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2817. {
  2818. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2819. return -1;
  2820. }
  2821. if (pl_sd == sd)
  2822. {
  2823. clif_displaymessage(fd, "You are already where you are...");
  2824. return -1;
  2825. }
  2826. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2827. {
  2828. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2829. return -1;
  2830. }
  2831. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2832. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  2833. return -1;
  2834. }
  2835. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2836. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2837. return -1;
  2838. }
  2839. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  2840. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2841. clif_displaymessage(fd, atcmd_output);
  2842. return 0;
  2843. }
  2844. /*==========================================
  2845. * charblock command (usage: charblock <player_name>)
  2846. * This command do a definitiv ban on a player
  2847. *------------------------------------------*/
  2848. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2849. {
  2850. nullpo_retr(-1, sd);
  2851. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2852. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2853. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2854. return -1;
  2855. }
  2856. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2857. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2858. return 0;
  2859. }
  2860. /*==========================================
  2861. * charban command (usage: charban <time> <player_name>)
  2862. * This command do a limited ban on a player
  2863. * Time is done as follows:
  2864. * Adjustment value (-1, 1, +1, etc...)
  2865. * Modified element:
  2866. * a or y: year
  2867. * m: month
  2868. * j or d: day
  2869. * h: hour
  2870. * mn: minute
  2871. * s: second
  2872. * <example> @ban +1m-2mn1s-6y test_player
  2873. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2874. *------------------------------------------*/
  2875. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2876. {
  2877. char * modif_p;
  2878. int year, month, day, hour, minute, second, value;
  2879. nullpo_retr(-1, sd);
  2880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2881. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2882. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2883. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2884. return -1;
  2885. }
  2886. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2887. modif_p = atcmd_output;
  2888. year = month = day = hour = minute = second = 0;
  2889. while (modif_p[0] != '\0') {
  2890. value = atoi(modif_p);
  2891. if (value == 0)
  2892. modif_p++;
  2893. else {
  2894. if (modif_p[0] == '-' || modif_p[0] == '+')
  2895. modif_p++;
  2896. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2897. modif_p++;
  2898. if (modif_p[0] == 's') {
  2899. second = value;
  2900. modif_p++;
  2901. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  2902. minute = value;
  2903. modif_p = modif_p + 2;
  2904. } else if (modif_p[0] == 'h') {
  2905. hour = value;
  2906. modif_p++;
  2907. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2908. day = value;
  2909. modif_p++;
  2910. } else if (modif_p[0] == 'm') {
  2911. month = value;
  2912. modif_p++;
  2913. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2914. year = value;
  2915. modif_p++;
  2916. } else if (modif_p[0] != '\0') {
  2917. modif_p++;
  2918. }
  2919. }
  2920. }
  2921. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2922. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2923. return -1;
  2924. }
  2925. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2926. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2927. return 0;
  2928. }
  2929. /*==========================================
  2930. * charunblock command (usage: charunblock <player_name>)
  2931. *------------------------------------------*/
  2932. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2933. {
  2934. nullpo_retr(-1, sd);
  2935. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2936. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2937. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  2938. return -1;
  2939. }
  2940. // send answer to login server via char-server
  2941. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2942. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2943. return 0;
  2944. }
  2945. /*==========================================
  2946. * charunban command (usage: charunban <player_name>)
  2947. *------------------------------------------*/
  2948. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2949. {
  2950. nullpo_retr(-1, sd);
  2951. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2952. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2953. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  2954. return -1;
  2955. }
  2956. // send answer to login server via char-server
  2957. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2958. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2959. return 0;
  2960. }
  2961. /*==========================================
  2962. *
  2963. *------------------------------------------*/
  2964. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2965. {
  2966. nullpo_retr(-1, sd);
  2967. if (night_flag != 1) {
  2968. map_night_timer(night_timer_tid, 0, 0, 1);
  2969. } else {
  2970. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  2971. return -1;
  2972. }
  2973. return 0;
  2974. }
  2975. /*==========================================
  2976. *
  2977. *------------------------------------------*/
  2978. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2979. {
  2980. nullpo_retr(-1, sd);
  2981. if (night_flag != 0) {
  2982. map_day_timer(day_timer_tid, 0, 0, 1);
  2983. } else {
  2984. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  2985. return -1;
  2986. }
  2987. return 0;
  2988. }
  2989. /*==========================================
  2990. *
  2991. *------------------------------------------*/
  2992. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2993. {
  2994. struct map_session_data* pl_sd;
  2995. struct s_mapiterator* iter;
  2996. nullpo_retr(-1, sd);
  2997. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  2998. iter = mapit_getallusers();
  2999. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3000. {
  3001. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3002. {
  3003. status_kill(&pl_sd->bl);
  3004. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3005. }
  3006. }
  3007. mapit_free(iter);
  3008. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3009. return 0;
  3010. }
  3011. /*==========================================
  3012. *
  3013. *------------------------------------------*/
  3014. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3015. {
  3016. struct map_session_data* pl_sd;
  3017. struct s_mapiterator* iter;
  3018. nullpo_retr(-1, sd);
  3019. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  3020. iter = mapit_getallusers();
  3021. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3022. {
  3023. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3024. {
  3025. status_kill(&pl_sd->bl);
  3026. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3027. }
  3028. }
  3029. mapit_free(iter);
  3030. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3031. return 0;
  3032. }
  3033. /*==========================================
  3034. *
  3035. *------------------------------------------*/
  3036. static void atcommand_raise_sub(struct map_session_data* sd)
  3037. {
  3038. if (!status_isdead(&sd->bl))
  3039. return;
  3040. if(!status_revive(&sd->bl, 100, 100))
  3041. return;
  3042. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3043. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3044. }
  3045. /*==========================================
  3046. *
  3047. *------------------------------------------*/
  3048. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3049. {
  3050. struct map_session_data* pl_sd;
  3051. struct s_mapiterator* iter;
  3052. nullpo_retr(-1, sd);
  3053. iter = mapit_getallusers();
  3054. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3055. atcommand_raise_sub(pl_sd);
  3056. mapit_free(iter);
  3057. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3058. return 0;
  3059. }
  3060. /*==========================================
  3061. *
  3062. *------------------------------------------*/
  3063. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3064. {
  3065. struct map_session_data* pl_sd;
  3066. struct s_mapiterator* iter;
  3067. nullpo_retr(-1, sd);
  3068. iter = mapit_getallusers();
  3069. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3070. if (sd->bl.m == pl_sd->bl.m)
  3071. atcommand_raise_sub(pl_sd);
  3072. mapit_free(iter);
  3073. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3074. return 0;
  3075. }
  3076. /*==========================================
  3077. *
  3078. *------------------------------------------*/
  3079. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3080. {
  3081. struct map_session_data *pl_sd;
  3082. nullpo_retr(-1, sd);
  3083. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3084. if (!message || !*message) {
  3085. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3086. return -1;
  3087. }
  3088. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3089. {
  3090. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3091. return -1;
  3092. }
  3093. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3094. {
  3095. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3096. return -1;
  3097. }
  3098. clif_GM_kick(sd, pl_sd);
  3099. return 0;
  3100. }
  3101. /*==========================================
  3102. *
  3103. *------------------------------------------*/
  3104. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3105. {
  3106. struct map_session_data* pl_sd;
  3107. struct s_mapiterator* iter;
  3108. nullpo_retr(-1, sd);
  3109. iter = mapit_getallusers();
  3110. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3111. {
  3112. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3113. if (sd->status.account_id != pl_sd->status.account_id)
  3114. clif_GM_kick(NULL, pl_sd);
  3115. }
  3116. }
  3117. mapit_free(iter);
  3118. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3119. return 0;
  3120. }
  3121. /*==========================================
  3122. *
  3123. *------------------------------------------*/
  3124. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3125. {
  3126. nullpo_retr(-1, sd);
  3127. pc_allskillup(sd); // all skills
  3128. sd->status.skill_point = 0; // 0 skill points
  3129. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3130. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  3131. return 0;
  3132. }
  3133. /*==========================================
  3134. *
  3135. *------------------------------------------*/
  3136. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3137. {
  3138. int skill_id;
  3139. nullpo_retr(-1, sd);
  3140. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3141. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3142. return -1;
  3143. }
  3144. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3145. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3146. return -1;
  3147. }
  3148. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3149. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3150. return -1;
  3151. }
  3152. if (pc_checkskill(sd, skill_id) > 0) {
  3153. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3154. return -1;
  3155. }
  3156. pc_skill(sd, skill_id, 1, 0);
  3157. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3158. return 0;
  3159. }
  3160. /*==========================================
  3161. *
  3162. *------------------------------------------*/
  3163. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3164. {
  3165. int skill_id;
  3166. nullpo_retr(-1, sd);
  3167. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3168. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3169. return -1;
  3170. }
  3171. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3172. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3173. return -1;
  3174. }
  3175. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3176. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3177. return -1;
  3178. }
  3179. if (pc_checkskill(sd, skill_id) == 0) {
  3180. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3181. return -1;
  3182. }
  3183. sd->status.skill[skill_id].lv = 0;
  3184. sd->status.skill[skill_id].flag = 0;
  3185. clif_skillinfoblock(sd);
  3186. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3187. return 0;
  3188. }
  3189. /*==========================================
  3190. *
  3191. *------------------------------------------*/
  3192. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3193. {
  3194. int number;
  3195. nullpo_retr(-1, sd);
  3196. if (!message || !*message || (number = atoi(message)) < 0) {
  3197. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  3198. return -1;
  3199. }
  3200. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  3201. if (number > 500)
  3202. number = 500;
  3203. if (number >= 0 && number <= 0x7FFF) {
  3204. if (sd->spiritball != number || number > 499) {
  3205. if (sd->spiritball > 0)
  3206. pc_delspiritball(sd, sd->spiritball, 1);
  3207. sd->spiritball = number;
  3208. clif_spiritball(sd);
  3209. // no message, player can look the difference
  3210. if (number > 1000)
  3211. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  3212. } else {
  3213. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  3214. return -1;
  3215. }
  3216. } else {
  3217. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3218. return -1;
  3219. }
  3220. return 0;
  3221. }
  3222. /*==========================================
  3223. *
  3224. *------------------------------------------*/
  3225. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3226. {
  3227. char party[NAME_LENGTH];
  3228. nullpo_retr(-1, sd);
  3229. memset(party, '\0', sizeof(party));
  3230. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3231. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3232. return -1;
  3233. }
  3234. party_create(sd, party, 0, 0);
  3235. return 0;
  3236. }
  3237. /*==========================================
  3238. *
  3239. *------------------------------------------*/
  3240. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3241. {
  3242. char guild[NAME_LENGTH];
  3243. int prev;
  3244. nullpo_retr(-1, sd);
  3245. memset(guild, '\0', sizeof(guild));
  3246. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3247. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3248. return -1;
  3249. }
  3250. prev = battle_config.guild_emperium_check;
  3251. battle_config.guild_emperium_check = 0;
  3252. guild_create(sd, guild);
  3253. battle_config.guild_emperium_check = prev;
  3254. return 0;
  3255. }
  3256. /*==========================================
  3257. *
  3258. *------------------------------------------*/
  3259. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3260. {
  3261. nullpo_retr(-1, sd);
  3262. if (agit_flag == 1) {
  3263. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  3264. return -1;
  3265. }
  3266. agit_flag = 1;
  3267. guild_agit_start();
  3268. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  3269. return 0;
  3270. }
  3271. /*==========================================
  3272. *
  3273. *------------------------------------------*/
  3274. int atcommand_agitstart2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3275. {
  3276. nullpo_retr(-1, sd);
  3277. if (agit2_flag == 1) {
  3278. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3279. return -1;
  3280. }
  3281. agit2_flag = 1;
  3282. guild_agit2_start();
  3283. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3284. return 0;
  3285. }
  3286. /*==========================================
  3287. *
  3288. *------------------------------------------*/
  3289. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3290. {
  3291. nullpo_retr(-1, sd);
  3292. if (agit_flag == 0) {
  3293. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  3294. return -1;
  3295. }
  3296. agit_flag = 0;
  3297. guild_agit_end();
  3298. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  3299. return 0;
  3300. }
  3301. /*==========================================
  3302. *
  3303. *------------------------------------------*/
  3304. int atcommand_agitend2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3305. {
  3306. nullpo_retr(-1, sd);
  3307. if (agit2_flag == 0) {
  3308. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3309. return -1;
  3310. }
  3311. agit2_flag = 0;
  3312. guild_agit2_end();
  3313. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3314. return 0;
  3315. }
  3316. /*==========================================
  3317. * @mapexit - shuts down the map server
  3318. *------------------------------------------*/
  3319. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3320. {
  3321. struct map_session_data* pl_sd;
  3322. struct s_mapiterator* iter;
  3323. nullpo_retr(-1, sd);
  3324. iter = mapit_getallusers();
  3325. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3326. if (sd->status.account_id != pl_sd->status.account_id)
  3327. clif_GM_kick(NULL, pl_sd);
  3328. mapit_free(iter);
  3329. clif_GM_kick(NULL, sd);
  3330. flush_fifos();
  3331. runflag = 0;
  3332. return 0;
  3333. }
  3334. /*==========================================
  3335. * idsearch <part_of_name>: revrited by [Yor]
  3336. *------------------------------------------*/
  3337. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3338. {
  3339. char item_name[100];
  3340. unsigned int i, match;
  3341. struct item_data *item_array[MAX_SEARCH];
  3342. nullpo_retr(-1, sd);
  3343. memset(item_name, '\0', sizeof(item_name));
  3344. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3345. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3346. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3347. return -1;
  3348. }
  3349. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3350. clif_displaymessage(fd, atcmd_output);
  3351. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3352. if (match > MAX_SEARCH) {
  3353. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3354. clif_displaymessage(fd, atcmd_output);
  3355. match = MAX_SEARCH;
  3356. }
  3357. for(i = 0; i < match; i++) {
  3358. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3359. clif_displaymessage(fd, atcmd_output);
  3360. }
  3361. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3362. clif_displaymessage(fd, atcmd_output);
  3363. return 0;
  3364. }
  3365. /*==========================================
  3366. * Recall All Characters Online To Your Location
  3367. *------------------------------------------*/
  3368. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3369. {
  3370. struct map_session_data* pl_sd;
  3371. struct s_mapiterator* iter;
  3372. int count;
  3373. nullpo_retr(-1, sd);
  3374. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3375. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3376. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3377. return -1;
  3378. }
  3379. count = 0;
  3380. iter = mapit_getallusers();
  3381. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3382. {
  3383. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3384. {
  3385. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3386. count++;
  3387. else {
  3388. if (pc_isdead(pl_sd)) { //Wake them up
  3389. pc_setstand(pl_sd);
  3390. pc_setrestartvalue(pl_sd,1);
  3391. }
  3392. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3393. }
  3394. }
  3395. }
  3396. mapit_free(iter);
  3397. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3398. if (count) {
  3399. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3400. clif_displaymessage(fd, atcmd_output);
  3401. }
  3402. return 0;
  3403. }
  3404. /*==========================================
  3405. * Recall online characters of a guild to your location
  3406. *------------------------------------------*/
  3407. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3408. {
  3409. struct map_session_data* pl_sd;
  3410. struct s_mapiterator* iter;
  3411. int count;
  3412. char guild_name[NAME_LENGTH];
  3413. struct guild *g;
  3414. nullpo_retr(-1, sd);
  3415. memset(guild_name, '\0', sizeof(guild_name));
  3416. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3417. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3418. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3419. return -1;
  3420. }
  3421. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3422. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3423. return -1;
  3424. }
  3425. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3426. (g = guild_search(atoi(message))) == NULL)
  3427. {
  3428. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3429. return -1;
  3430. }
  3431. count = 0;
  3432. iter = mapit_getallusers();
  3433. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3434. {
  3435. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3436. {
  3437. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3438. continue; //Skip GMs greater than you.
  3439. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3440. count++;
  3441. else
  3442. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3443. }
  3444. }
  3445. mapit_free(iter);
  3446. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  3447. clif_displaymessage(fd, atcmd_output);
  3448. if (count) {
  3449. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3450. clif_displaymessage(fd, atcmd_output);
  3451. }
  3452. return 0;
  3453. }
  3454. /*==========================================
  3455. * Recall online characters of a party to your location
  3456. *------------------------------------------*/
  3457. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3458. {
  3459. struct map_session_data* pl_sd;
  3460. struct s_mapiterator* iter;
  3461. char party_name[NAME_LENGTH];
  3462. struct party_data *p;
  3463. int count;
  3464. nullpo_retr(-1, sd);
  3465. memset(party_name, '\0', sizeof(party_name));
  3466. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3467. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3468. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3469. return -1;
  3470. }
  3471. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3472. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3473. return -1;
  3474. }
  3475. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3476. (p = party_search(atoi(message))) == NULL)
  3477. {
  3478. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3479. return -1;
  3480. }
  3481. count = 0;
  3482. iter = mapit_getallusers();
  3483. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3484. {
  3485. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3486. {
  3487. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3488. continue; //Skip GMs greater than you.
  3489. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3490. count++;
  3491. else
  3492. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3493. }
  3494. }
  3495. mapit_free(iter);
  3496. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  3497. clif_displaymessage(fd, atcmd_output);
  3498. if (count) {
  3499. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3500. clif_displaymessage(fd, atcmd_output);
  3501. }
  3502. return 0;
  3503. }
  3504. /*==========================================
  3505. *
  3506. *------------------------------------------*/
  3507. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3508. {
  3509. nullpo_retr(-1, sd);
  3510. itemdb_reload();
  3511. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  3512. return 0;
  3513. }
  3514. /*==========================================
  3515. *
  3516. *------------------------------------------*/
  3517. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3518. {
  3519. nullpo_retr(-1, sd);
  3520. mob_reload();
  3521. read_petdb();
  3522. merc_reload();
  3523. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  3524. return 0;
  3525. }
  3526. /*==========================================
  3527. *
  3528. *------------------------------------------*/
  3529. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3530. {
  3531. nullpo_retr(-1, sd);
  3532. skill_reload();
  3533. merc_skill_reload();
  3534. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  3535. return 0;
  3536. }
  3537. /*==========================================
  3538. * @reloadatcommand - reloads atcommand_athena.conf
  3539. *------------------------------------------*/
  3540. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3541. {
  3542. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  3543. clif_displaymessage(fd, msg_txt(254));
  3544. return 0;
  3545. }
  3546. /*==========================================
  3547. * @reloadbattleconf - reloads battle_athena.conf
  3548. *------------------------------------------*/
  3549. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3550. {
  3551. struct Battle_Config prev_config;
  3552. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3553. battle_config_read(BATTLE_CONF_FILENAME);
  3554. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3555. || prev_config.item_rate_common != battle_config.item_rate_common
  3556. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3557. || prev_config.item_rate_card != battle_config.item_rate_card
  3558. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3559. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3560. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3561. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3562. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3563. || prev_config.item_rate_use != battle_config.item_rate_use
  3564. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3565. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3566. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3567. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3568. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3569. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3570. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3571. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3572. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3573. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3574. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3575. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3576. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3577. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3578. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3579. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3580. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3581. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3582. )
  3583. { //Drop rates changed.
  3584. mob_reload(); //Needed as well so rate changes take effect.
  3585. #ifndef TXT_ONLY
  3586. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3587. #endif
  3588. }
  3589. clif_displaymessage(fd, msg_txt(255));
  3590. return 0;
  3591. }
  3592. /*==========================================
  3593. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3594. *------------------------------------------*/
  3595. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3596. {
  3597. status_readdb();
  3598. clif_displaymessage(fd, msg_txt(256));
  3599. return 0;
  3600. }
  3601. /*==========================================
  3602. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3603. *------------------------------------------*/
  3604. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3605. {
  3606. pc_readdb();
  3607. clif_displaymessage(fd, msg_txt(257));
  3608. return 0;
  3609. }
  3610. /*==========================================
  3611. * @reloadmotd - reloads motd.txt
  3612. *------------------------------------------*/
  3613. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3614. {
  3615. pc_read_motd();
  3616. clif_displaymessage(fd, msg_txt(268));
  3617. return 0;
  3618. }
  3619. /*==========================================
  3620. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3621. *------------------------------------------*/
  3622. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3623. {
  3624. nullpo_retr(-1, sd);
  3625. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3626. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3627. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3628. flush_fifos();
  3629. script_reload();
  3630. npc_reload();
  3631. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  3632. return 0;
  3633. }
  3634. /*==========================================
  3635. * @mapinfo <map name> [0-3] by MC_Cameri
  3636. * => Shows information about the map [map name]
  3637. * 0 = no additional information
  3638. * 1 = Show users in that map and their location
  3639. * 2 = Shows NPCs in that map
  3640. * 3 = Shows the shops/chats in that map (not implemented)
  3641. *------------------------------------------*/
  3642. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3643. {
  3644. struct map_session_data* pl_sd;
  3645. struct s_mapiterator* iter;
  3646. struct npc_data *nd = NULL;
  3647. struct chat_data *cd = NULL;
  3648. char direction[12];
  3649. int i, m_id, chat_num, list = 0;
  3650. unsigned short m_index;
  3651. char mapname[24];
  3652. nullpo_retr(-1, sd);
  3653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3654. memset(mapname, '\0', sizeof(mapname));
  3655. memset(direction, '\0', sizeof(direction));
  3656. sscanf(message, "%d %23[^\n]", &list, mapname);
  3657. if (list < 0 || list > 3) {
  3658. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3659. return -1;
  3660. }
  3661. if (mapname[0] == '\0') {
  3662. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3663. m_id = map_mapindex2mapid(sd->mapindex);
  3664. } else {
  3665. m_id = map_mapname2mapid(mapname);
  3666. }
  3667. if (m_id < 0) {
  3668. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3669. return -1;
  3670. }
  3671. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3672. clif_displaymessage(fd, "------ Map Info ------");
  3673. // count chats (for initial message)
  3674. chat_num = 0;
  3675. iter = mapit_getallusers();
  3676. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3677. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3678. chat_num++;
  3679. mapit_free(iter);
  3680. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
  3681. clif_displaymessage(fd, atcmd_output);
  3682. clif_displaymessage(fd, "------ Map Flags ------");
  3683. strcpy(atcmd_output,"PvP Flags: ");
  3684. if (map[m_id].flag.pvp)
  3685. strcat(atcmd_output, "Pvp ON | ");
  3686. if (map[m_id].flag.pvp_noguild)
  3687. strcat(atcmd_output, "NoGuild | ");
  3688. if (map[m_id].flag.pvp_noparty)
  3689. strcat(atcmd_output, "NoParty | ");
  3690. if (map[m_id].flag.pvp_nightmaredrop)
  3691. strcat(atcmd_output, "NightmareDrop | ");
  3692. if (map[m_id].flag.pvp_nocalcrank)
  3693. strcat(atcmd_output, "NoCalcRank | ");
  3694. clif_displaymessage(fd, atcmd_output);
  3695. strcpy(atcmd_output,"GvG Flags: ");
  3696. if (map[m_id].flag.gvg)
  3697. strcat(atcmd_output, "GvG ON | ");
  3698. if (map[m_id].flag.gvg_dungeon)
  3699. strcat(atcmd_output, "GvG Dungeon | ");
  3700. if (map[m_id].flag.gvg_castle)
  3701. strcat(atcmd_output, "GvG Castle | ");
  3702. if (map[m_id].flag.gvg_noparty)
  3703. strcat(atcmd_output, "NoParty | ");
  3704. clif_displaymessage(fd, atcmd_output);
  3705. strcpy(atcmd_output,"Teleport Flags: ");
  3706. if (map[m_id].flag.noteleport)
  3707. strcat(atcmd_output, "NoTeleport | ");
  3708. if (map[m_id].flag.monster_noteleport)
  3709. strcat(atcmd_output, "Monster NoTeleport | ");
  3710. if (map[m_id].flag.nowarp)
  3711. strcat(atcmd_output, "NoWarp | ");
  3712. if (map[m_id].flag.nowarpto)
  3713. strcat(atcmd_output, "NoWarpTo | ");
  3714. if (map[m_id].flag.noreturn)
  3715. strcat(atcmd_output, "NoReturn | ");
  3716. if (map[m_id].flag.nogo)
  3717. strcat(atcmd_output, "NoGo | ");
  3718. if (map[m_id].flag.nomemo)
  3719. strcat(atcmd_output, "NoMemo | ");
  3720. clif_displaymessage(fd, atcmd_output);
  3721. 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");
  3722. clif_displaymessage(fd, atcmd_output);
  3723. if (map[m_id].flag.nosave) {
  3724. if (!map[m_id].save.map)
  3725. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3726. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3727. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3728. else
  3729. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3730. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3731. clif_displaymessage(fd, atcmd_output);
  3732. }
  3733. strcpy(atcmd_output,"Weather Flags: ");
  3734. if (map[m_id].flag.snow)
  3735. strcat(atcmd_output, "Snow | ");
  3736. if (map[m_id].flag.fog)
  3737. strcat(atcmd_output, "Fog | ");
  3738. if (map[m_id].flag.sakura)
  3739. strcat(atcmd_output, "Sakura | ");
  3740. if (map[m_id].flag.clouds)
  3741. strcat(atcmd_output, "Clouds | ");
  3742. if (map[m_id].flag.clouds2)
  3743. strcat(atcmd_output, "Clouds2 | ");
  3744. if (map[m_id].flag.fireworks)
  3745. strcat(atcmd_output, "Fireworks | ");
  3746. if (map[m_id].flag.leaves)
  3747. strcat(atcmd_output, "Leaves | ");
  3748. if (map[m_id].flag.rain)
  3749. strcat(atcmd_output, "Rain | ");
  3750. if (map[m_id].flag.indoors)
  3751. strcat(atcmd_output, "Indoors | ");
  3752. if (map[m_id].flag.nightenabled)
  3753. strcat(atcmd_output, "Displays Night | ");
  3754. clif_displaymessage(fd, atcmd_output);
  3755. strcpy(atcmd_output,"Other Flags: ");
  3756. if (map[m_id].flag.nobranch)
  3757. strcat(atcmd_output, "NoBranch | ");
  3758. if (map[m_id].flag.notrade)
  3759. strcat(atcmd_output, "NoTrade | ");
  3760. if (map[m_id].flag.novending)
  3761. strcat(atcmd_output, "NoVending | ");
  3762. if (map[m_id].flag.nodrop)
  3763. strcat(atcmd_output, "NoDrop | ");
  3764. if (map[m_id].flag.noskill)
  3765. strcat(atcmd_output, "NoSkill | ");
  3766. if (map[m_id].flag.noicewall)
  3767. strcat(atcmd_output, "NoIcewall | ");
  3768. clif_displaymessage(fd, atcmd_output);
  3769. strcpy(atcmd_output,"Other Flags: ");
  3770. if (map[m_id].nocommand)
  3771. strcat(atcmd_output, "NoCommand | ");
  3772. if (map[m_id].flag.nobaseexp)
  3773. strcat(atcmd_output, "NoBaseEXP | ");
  3774. if (map[m_id].flag.nojobexp)
  3775. strcat(atcmd_output, "NoJobEXP | ");
  3776. if (map[m_id].flag.nomobloot)
  3777. strcat(atcmd_output, "NoMobLoot | ");
  3778. if (map[m_id].flag.nomvploot)
  3779. strcat(atcmd_output, "NoMVPLoot | ");
  3780. if (map[m_id].flag.partylock)
  3781. strcat(atcmd_output, "PartyLock | ");
  3782. if (map[m_id].flag.guildlock)
  3783. strcat(atcmd_output, "GuildLock | ");
  3784. clif_displaymessage(fd, atcmd_output);
  3785. switch (list) {
  3786. case 0:
  3787. // Do nothing. It's list 0, no additional display.
  3788. break;
  3789. case 1:
  3790. clif_displaymessage(fd, "----- Players in Map -----");
  3791. iter = mapit_getallusers();
  3792. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3793. {
  3794. if (pl_sd->mapindex == m_index) {
  3795. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3796. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3797. clif_displaymessage(fd, atcmd_output);
  3798. }
  3799. }
  3800. mapit_free(iter);
  3801. break;
  3802. case 2:
  3803. clif_displaymessage(fd, "----- NPCs in Map -----");
  3804. for (i = 0; i < map[m_id].npc_num;)
  3805. {
  3806. nd = map[m_id].npc[i];
  3807. switch(nd->ud.dir) {
  3808. case 0: strcpy(direction, "North"); break;
  3809. case 1: strcpy(direction, "North West"); break;
  3810. case 2: strcpy(direction, "West"); break;
  3811. case 3: strcpy(direction, "South West"); break;
  3812. case 4: strcpy(direction, "South"); break;
  3813. case 5: strcpy(direction, "South East"); break;
  3814. case 6: strcpy(direction, "East"); break;
  3815. case 7: strcpy(direction, "North East"); break;
  3816. case 9: strcpy(direction, "North"); break;
  3817. default: strcpy(direction, "Unknown"); break;
  3818. }
  3819. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3820. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3821. clif_displaymessage(fd, atcmd_output);
  3822. }
  3823. break;
  3824. case 3:
  3825. clif_displaymessage(fd, "----- Chats in Map -----");
  3826. iter = mapit_getallusers();
  3827. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3828. {
  3829. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3830. pl_sd->mapindex == m_index &&
  3831. cd->usersd[0] == pl_sd)
  3832. {
  3833. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  3834. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3835. clif_displaymessage(fd, atcmd_output);
  3836. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3837. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3838. clif_displaymessage(fd, atcmd_output);
  3839. }
  3840. }
  3841. mapit_free(iter);
  3842. break;
  3843. default: // normally impossible to arrive here
  3844. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3845. return -1;
  3846. break;
  3847. }
  3848. return 0;
  3849. }
  3850. /*==========================================
  3851. *
  3852. *------------------------------------------*/
  3853. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3854. {
  3855. nullpo_retr(-1, sd);
  3856. if (!pc_isriding(sd)) { // if actually no peco
  3857. if (!pc_checkskill(sd, KN_RIDING))
  3858. {
  3859. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  3860. return -1;
  3861. }
  3862. if (sd->disguise)
  3863. {
  3864. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco while in disguise.
  3865. return -1;
  3866. }
  3867. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3868. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  3869. } else { //Dismount
  3870. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3871. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  3872. }
  3873. return 0;
  3874. }
  3875. /*==========================================
  3876. *Spy Commands by Syrus22
  3877. *------------------------------------------*/
  3878. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3879. {
  3880. char guild_name[NAME_LENGTH];
  3881. struct guild *g;
  3882. nullpo_retr(-1, sd);
  3883. memset(guild_name, '\0', sizeof(guild_name));
  3884. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3885. if (!enable_spy)
  3886. {
  3887. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3888. return -1;
  3889. }
  3890. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3891. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3892. return -1;
  3893. }
  3894. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3895. (g = guild_search(atoi(message))) != NULL) {
  3896. if (sd->guildspy == g->guild_id) {
  3897. sd->guildspy = 0;
  3898. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3899. clif_displaymessage(fd, atcmd_output);
  3900. } else {
  3901. sd->guildspy = g->guild_id;
  3902. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3903. clif_displaymessage(fd, atcmd_output);
  3904. }
  3905. } else {
  3906. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3907. return -1;
  3908. }
  3909. return 0;
  3910. }
  3911. /*==========================================
  3912. *
  3913. *------------------------------------------*/
  3914. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3915. {
  3916. char party_name[NAME_LENGTH];
  3917. struct party_data *p;
  3918. nullpo_retr(-1, sd);
  3919. memset(party_name, '\0', sizeof(party_name));
  3920. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3921. if (!enable_spy)
  3922. {
  3923. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3924. return -1;
  3925. }
  3926. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3927. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3928. return -1;
  3929. }
  3930. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3931. (p = party_search(atoi(message))) != NULL) {
  3932. if (sd->partyspy == p->party.party_id) {
  3933. sd->partyspy = 0;
  3934. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3935. clif_displaymessage(fd, atcmd_output);
  3936. } else {
  3937. sd->partyspy = p->party.party_id;
  3938. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3939. clif_displaymessage(fd, atcmd_output);
  3940. }
  3941. } else {
  3942. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3943. return -1;
  3944. }
  3945. return 0;
  3946. }
  3947. /*==========================================
  3948. * @repairall [Valaris]
  3949. *------------------------------------------*/
  3950. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3951. {
  3952. int count, i;
  3953. nullpo_retr(-1, sd);
  3954. count = 0;
  3955. for (i = 0; i < MAX_INVENTORY; i++) {
  3956. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3957. sd->status.inventory[i].attribute = 0;
  3958. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3959. count++;
  3960. }
  3961. }
  3962. if (count > 0) {
  3963. clif_misceffect(&sd->bl, 3);
  3964. clif_equiplist(sd);
  3965. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3966. } else {
  3967. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3968. return -1;
  3969. }
  3970. return 0;
  3971. }
  3972. /*==========================================
  3973. * @nuke [Valaris]
  3974. *------------------------------------------*/
  3975. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3976. {
  3977. struct map_session_data *pl_sd;
  3978. nullpo_retr(-1, sd);
  3979. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3980. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3981. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  3982. return -1;
  3983. }
  3984. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3985. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  3986. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3987. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3988. } else {
  3989. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3990. return -1;
  3991. }
  3992. } else {
  3993. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3994. return -1;
  3995. }
  3996. return 0;
  3997. }
  3998. /*==========================================
  3999. * @tonpc
  4000. *------------------------------------------*/
  4001. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4002. {
  4003. char npcname[NAME_LENGTH];
  4004. struct npc_data *nd;
  4005. nullpo_retr(-1, sd);
  4006. memset(npcname, 0, sizeof(npcname));
  4007. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4008. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4009. return -1;
  4010. }
  4011. if ((nd = npc_name2id(npcname)) != NULL) {
  4012. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
  4013. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4014. else
  4015. return -1;
  4016. } else {
  4017. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4018. return -1;
  4019. }
  4020. return 0;
  4021. }
  4022. /*==========================================
  4023. *
  4024. *------------------------------------------*/
  4025. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4026. {
  4027. char NPCname[NAME_LENGTH];
  4028. nullpo_retr(-1, sd);
  4029. memset(NPCname, '\0', sizeof(NPCname));
  4030. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4031. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4032. return -1;
  4033. }
  4034. if (npc_name2id(NPCname) != NULL) {
  4035. npc_enable(NPCname, 1);
  4036. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4037. } else {
  4038. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4039. return -1;
  4040. }
  4041. return 0;
  4042. }
  4043. /*==========================================
  4044. *
  4045. *------------------------------------------*/
  4046. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4047. {
  4048. char NPCname[NAME_LENGTH];
  4049. nullpo_retr(-1, sd);
  4050. memset(NPCname, '\0', sizeof(NPCname));
  4051. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4052. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4053. return -1;
  4054. }
  4055. if (npc_name2id(NPCname) == NULL) {
  4056. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4057. return -1;
  4058. }
  4059. npc_enable(NPCname, 0);
  4060. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4061. return 0;
  4062. }
  4063. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4064. {
  4065. FILE *fp;
  4066. if (!message || !*message) {
  4067. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4068. return -1;
  4069. }
  4070. // check if script file exists
  4071. if ((fp = fopen(message, "r")) == NULL) {
  4072. clif_displaymessage(fd, msg_txt(261));
  4073. return -1;
  4074. }
  4075. fclose(fp);
  4076. // add to list of script sources and run it
  4077. npc_addsrcfile(message);
  4078. npc_parsesrcfile(message);
  4079. npc_read_event_script();
  4080. clif_displaymessage(fd, msg_txt(262));
  4081. return 0;
  4082. }
  4083. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4084. {
  4085. struct npc_data *nd;
  4086. char NPCname[NAME_LENGTH];
  4087. nullpo_retr(-1, sd);
  4088. memset(NPCname, '\0', sizeof(NPCname));
  4089. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4090. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4091. return -1;
  4092. }
  4093. if ((nd = npc_name2id(NPCname)) == NULL) {
  4094. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4095. return -1;
  4096. }
  4097. npc_unload_duplicates(nd);
  4098. npc_unload(nd);
  4099. npc_read_event_script();
  4100. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4101. return 0;
  4102. }
  4103. /*==========================================
  4104. * time in txt for time command (by [Yor])
  4105. *------------------------------------------*/
  4106. char* txt_time(unsigned int duration)
  4107. {
  4108. int days, hours, minutes, seconds;
  4109. char temp[256];
  4110. static char temp1[256];
  4111. memset(temp, '\0', sizeof(temp));
  4112. memset(temp1, '\0', sizeof(temp1));
  4113. days = duration / (60 * 60 * 24);
  4114. duration = duration - (60 * 60 * 24 * days);
  4115. hours = duration / (60 * 60);
  4116. duration = duration - (60 * 60 * hours);
  4117. minutes = duration / 60;
  4118. seconds = duration - (60 * minutes);
  4119. if (days < 2)
  4120. sprintf(temp, msg_txt(219), days); // %d day
  4121. else
  4122. sprintf(temp, msg_txt(220), days); // %d days
  4123. if (hours < 2)
  4124. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4125. else
  4126. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4127. if (minutes < 2)
  4128. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4129. else
  4130. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4131. if (seconds < 2)
  4132. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4133. else
  4134. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4135. return temp1;
  4136. }
  4137. /*==========================================
  4138. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4139. * Calculation management of GM modification (@day/@night GM commands) is done
  4140. *------------------------------------------*/
  4141. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4142. {
  4143. const struct TimerData * timer_data;
  4144. const struct TimerData * timer_data2;
  4145. time_t time_server; // variable for number of seconds (used with time() function)
  4146. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4147. char temp[256];
  4148. nullpo_retr(-1, sd);
  4149. memset(temp, '\0', sizeof(temp));
  4150. time(&time_server); // get time in seconds since 1/1/1970
  4151. datetime = localtime(&time_server); // convert seconds in structure
  4152. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4153. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4154. clif_displaymessage(fd, temp);
  4155. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4156. if (night_flag == 0)
  4157. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4158. else
  4159. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4160. } else if (battle_config.night_duration == 0)
  4161. if (night_flag == 1) { // we start with night
  4162. timer_data = get_timer(day_timer_tid);
  4163. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4164. clif_displaymessage(fd, temp);
  4165. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4166. } else
  4167. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4168. else if (battle_config.day_duration == 0)
  4169. if (night_flag == 0) { // we start with day
  4170. timer_data = get_timer(night_timer_tid);
  4171. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4172. clif_displaymessage(fd, temp);
  4173. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4174. } else
  4175. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4176. else {
  4177. if (night_flag == 0) {
  4178. timer_data = get_timer(night_timer_tid);
  4179. timer_data2 = get_timer(day_timer_tid);
  4180. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4181. clif_displaymessage(fd, temp);
  4182. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4183. 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.
  4184. else
  4185. 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.
  4186. clif_displaymessage(fd, temp);
  4187. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4188. clif_displaymessage(fd, temp);
  4189. } else {
  4190. timer_data = get_timer(day_timer_tid);
  4191. timer_data2 = get_timer(night_timer_tid);
  4192. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4193. clif_displaymessage(fd, temp);
  4194. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4195. 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.
  4196. else
  4197. 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.
  4198. clif_displaymessage(fd, temp);
  4199. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4200. clif_displaymessage(fd, temp);
  4201. }
  4202. }
  4203. return 0;
  4204. }
  4205. //Added by Coltaro
  4206. //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...).
  4207. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4208. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4209. {
  4210. const int factor_year = 518400; //12*30*24*60 = 518400
  4211. const int factor_month = 43200; //30*24*60 = 43200
  4212. const int factor_day = 1440; //24*60 = 1440
  4213. const int factor_hour = 60;
  4214. *year = jailtime/factor_year;
  4215. jailtime -= *year*factor_year;
  4216. *month = jailtime/factor_month;
  4217. jailtime -= *month*factor_month;
  4218. *day = jailtime/factor_day;
  4219. jailtime -= *day*factor_day;
  4220. *hour = jailtime/factor_hour;
  4221. jailtime -= *hour*factor_hour;
  4222. *minute = jailtime;
  4223. *year = *year > 0? *year : 0;
  4224. *month = *month > 0? *month : 0;
  4225. *day = *day > 0? *day : 0;
  4226. *hour = *hour > 0? *hour : 0;
  4227. *minute = *minute > 0? *minute : 0;
  4228. return;
  4229. }
  4230. /*==========================================
  4231. * @jail <char_name> by [Yor]
  4232. * Special warp! No check with nowarp and nowarpto flag
  4233. *------------------------------------------*/
  4234. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4235. {
  4236. struct map_session_data *pl_sd;
  4237. int x, y;
  4238. unsigned short m_index;
  4239. nullpo_retr(-1, sd);
  4240. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4241. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4242. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4243. return -1;
  4244. }
  4245. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4246. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4247. return -1;
  4248. }
  4249. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4250. { // you can jail only lower or same GM
  4251. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4252. return -1;
  4253. }
  4254. if (pl_sd->sc.data[SC_JAILED])
  4255. {
  4256. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4257. return -1;
  4258. }
  4259. switch(rand() % 2) { //Jail Locations
  4260. case 0:
  4261. m_index = mapindex_name2id(MAP_JAIL);
  4262. x = 24;
  4263. y = 75;
  4264. break;
  4265. default:
  4266. m_index = mapindex_name2id(MAP_JAIL);
  4267. x = 49;
  4268. y = 75;
  4269. break;
  4270. }
  4271. //Duration of INT_MAX to specify infinity.
  4272. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4273. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4274. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4275. return 0;
  4276. }
  4277. /*==========================================
  4278. * @unjail/@discharge <char_name> by [Yor]
  4279. * Special warp! No check with nowarp and nowarpto flag
  4280. *------------------------------------------*/
  4281. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4282. {
  4283. struct map_session_data *pl_sd;
  4284. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4285. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4286. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4287. return -1;
  4288. }
  4289. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4290. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4291. return -1;
  4292. }
  4293. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4294. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4295. return -1;
  4296. }
  4297. if (!pl_sd->sc.data[SC_JAILED])
  4298. {
  4299. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4300. return -1;
  4301. }
  4302. //Reset jail time to 1 sec.
  4303. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4304. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4305. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4306. return 0;
  4307. }
  4308. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4309. {
  4310. struct map_session_data *pl_sd = NULL;
  4311. int year, month, day, hour, minute, value;
  4312. char * modif_p;
  4313. int jailtime = 0,x,y;
  4314. short m_index = 0;
  4315. nullpo_retr(-1, sd);
  4316. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4317. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4318. return -1;
  4319. }
  4320. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4321. modif_p = atcmd_output;
  4322. year = month = day = hour = minute = 0;
  4323. while (modif_p[0] != '\0') {
  4324. value = atoi(modif_p);
  4325. if (value == 0)
  4326. modif_p++;
  4327. else {
  4328. if (modif_p[0] == '-' || modif_p[0] == '+')
  4329. modif_p++;
  4330. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4331. modif_p++;
  4332. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4333. minute = value;
  4334. modif_p = modif_p + 2;
  4335. } else if (modif_p[0] == 'h') {
  4336. hour = value;
  4337. modif_p++;
  4338. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4339. day = value;
  4340. modif_p++;
  4341. } else if (modif_p[0] == 'm') {
  4342. month = value;
  4343. modif_p++;
  4344. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4345. year = value;
  4346. modif_p++;
  4347. } else if (modif_p[0] != '\0') {
  4348. modif_p++;
  4349. }
  4350. }
  4351. }
  4352. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4353. clif_displaymessage(fd, "Invalid time for jail command.");
  4354. return -1;
  4355. }
  4356. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4357. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4358. return -1;
  4359. }
  4360. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4361. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4362. return -1;
  4363. }
  4364. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4365. if(jailtime==0) {
  4366. clif_displaymessage(fd, "Invalid time for jail command.");
  4367. return -1;
  4368. }
  4369. //Added by Coltaro
  4370. if(pl_sd->sc.data[SC_JAILED] &&
  4371. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4372. { //Update the player's jail time
  4373. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4374. if (jailtime <= 0) {
  4375. jailtime = 0;
  4376. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4377. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4378. } else {
  4379. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4380. 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
  4381. clif_displaymessage(pl_sd->fd, atcmd_output);
  4382. 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
  4383. clif_displaymessage(fd, atcmd_output);
  4384. }
  4385. } else if (jailtime < 0) {
  4386. clif_displaymessage(fd, "Invalid time for jail command.");
  4387. return -1;
  4388. }
  4389. //Jail locations, add more as you wish.
  4390. switch(rand()%2)
  4391. {
  4392. case 1: //Jail #1
  4393. m_index = mapindex_name2id(MAP_JAIL);
  4394. x = 49; y = 75;
  4395. break;
  4396. default: //Default Jail
  4397. m_index = mapindex_name2id(MAP_JAIL);
  4398. x = 24; y = 75;
  4399. break;
  4400. }
  4401. 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).
  4402. return 0;
  4403. }
  4404. //By Coltaro
  4405. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4406. {
  4407. int year, month, day, hour, minute;
  4408. nullpo_retr(-1, sd);
  4409. if (!sd->sc.data[SC_JAILED]) {
  4410. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4411. return -1;
  4412. }
  4413. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4414. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4415. return 0;
  4416. }
  4417. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4418. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4419. return -1;
  4420. }
  4421. //Get remaining jail time
  4422. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4423. 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
  4424. clif_displaymessage(fd, atcmd_output);
  4425. return 0;
  4426. }
  4427. /*==========================================
  4428. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4429. *------------------------------------------*/
  4430. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4431. {
  4432. int id = 0;
  4433. nullpo_retr(-1, sd);
  4434. if (!message || !*message) {
  4435. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4436. return -1;
  4437. }
  4438. if ((id = atoi(message)) > 0)
  4439. { //Acquired an ID
  4440. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4441. id = 0; //Invalid id for either mobs or npcs.
  4442. } else { //Acquired a Name
  4443. if ((id = mobdb_searchname(message)) == 0)
  4444. {
  4445. struct npc_data* nd = npc_name2id(message);
  4446. if (nd != NULL)
  4447. id = nd->class_;
  4448. }
  4449. }
  4450. if (id == 0)
  4451. {
  4452. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4453. return -1;
  4454. }
  4455. if(pc_isriding(sd))
  4456. {
  4457. //FIXME: wrong message [ultramage]
  4458. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4459. return -1;
  4460. }
  4461. pc_disguise(sd, id);
  4462. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4463. return 0;
  4464. }
  4465. /*==========================================
  4466. * DisguiseAll
  4467. *------------------------------------------*/
  4468. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4469. {
  4470. int mob_id=0;
  4471. struct map_session_data *pl_sd;
  4472. struct s_mapiterator* iter;
  4473. nullpo_retr(-1, sd);
  4474. if (!message || !*message) {
  4475. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4476. return -1;
  4477. }
  4478. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4479. mob_id = atoi(message);
  4480. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4481. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4482. return -1;
  4483. }
  4484. iter = mapit_getallusers();
  4485. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4486. pc_disguise(pl_sd, mob_id);
  4487. mapit_free(iter);
  4488. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4489. return 0;
  4490. }
  4491. /*==========================================
  4492. * @undisguise by [Yor]
  4493. *------------------------------------------*/
  4494. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4495. {
  4496. nullpo_retr(-1, sd);
  4497. if (sd->disguise) {
  4498. pc_disguise(sd, 0);
  4499. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4500. } else {
  4501. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4502. return -1;
  4503. }
  4504. return 0;
  4505. }
  4506. /*==========================================
  4507. * UndisguiseAll
  4508. *------------------------------------------*/
  4509. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4510. {
  4511. struct map_session_data *pl_sd;
  4512. struct s_mapiterator* iter;
  4513. nullpo_retr(-1, sd);
  4514. iter = mapit_getallusers();
  4515. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4516. if( pl_sd->disguise )
  4517. pc_disguise(pl_sd, 0);
  4518. mapit_free(iter);
  4519. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4520. return 0;
  4521. }
  4522. /*==========================================
  4523. * @exp by [Skotlex]
  4524. *------------------------------------------*/
  4525. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4526. {
  4527. char output[200];
  4528. double nextb, nextj;
  4529. nullpo_retr(-1, sd);
  4530. memset(output, '\0', sizeof(output));
  4531. nextb = pc_nextbaseexp(sd);
  4532. if (nextb)
  4533. nextb = sd->status.base_exp*100.0/nextb;
  4534. nextj = pc_nextjobexp(sd);
  4535. if (nextj)
  4536. nextj = sd->status.job_exp*100.0/nextj;
  4537. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4538. clif_displaymessage(fd, output);
  4539. return 0;
  4540. }
  4541. /*==========================================
  4542. * @broadcast by [Valaris]
  4543. *------------------------------------------*/
  4544. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4545. {
  4546. nullpo_retr(-1, sd);
  4547. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4548. if (!message || !*message) {
  4549. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4550. return -1;
  4551. }
  4552. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4553. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  4554. return 0;
  4555. }
  4556. /*==========================================
  4557. * @localbroadcast by [Valaris]
  4558. *------------------------------------------*/
  4559. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4560. {
  4561. nullpo_retr(-1, sd);
  4562. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4563. if (!message || !*message) {
  4564. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4565. return -1;
  4566. }
  4567. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4568. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  4569. return 0;
  4570. }
  4571. /*==========================================
  4572. * @email <actual@email> <new@email> by [Yor]
  4573. *------------------------------------------*/
  4574. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4575. {
  4576. char actual_email[100];
  4577. char new_email[100];
  4578. nullpo_retr(-1, sd);
  4579. memset(actual_email, '\0', sizeof(actual_email));
  4580. memset(new_email, '\0', sizeof(new_email));
  4581. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4582. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4583. return -1;
  4584. }
  4585. if (e_mail_check(actual_email) == 0) {
  4586. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4587. return -1;
  4588. } else if (e_mail_check(new_email) == 0) {
  4589. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4590. return -1;
  4591. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4592. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4593. return -1;
  4594. } else if (strcmpi(actual_email, new_email) == 0) {
  4595. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4596. return -1;
  4597. }
  4598. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4599. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4600. return 0;
  4601. }
  4602. /*==========================================
  4603. *@effect
  4604. *------------------------------------------*/
  4605. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4606. {
  4607. int type = 0, flag = 0;
  4608. nullpo_retr(-1, sd);
  4609. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4610. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4611. return -1;
  4612. }
  4613. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4614. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4615. return 0;
  4616. }
  4617. /*==========================================
  4618. * @killer by MouseJstr
  4619. * enable killing players even when not in pvp
  4620. *------------------------------------------*/
  4621. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4622. {
  4623. nullpo_retr(-1, sd);
  4624. sd->state.killer = !sd->state.killer;
  4625. if(sd->state.killer)
  4626. clif_displaymessage(fd, msg_txt(241));
  4627. else {
  4628. clif_displaymessage(fd, msg_txt(287));
  4629. pc_stop_attack(sd);
  4630. }
  4631. return 0;
  4632. }
  4633. /*==========================================
  4634. * @killable by MouseJstr
  4635. * enable other people killing you
  4636. *------------------------------------------*/
  4637. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4638. {
  4639. nullpo_retr(-1, sd);
  4640. sd->state.killable = !sd->state.killable;
  4641. if(sd->state.killable)
  4642. clif_displaymessage(fd, msg_txt(242));
  4643. else {
  4644. clif_displaymessage(fd, msg_txt(288));
  4645. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4646. }
  4647. return 0;
  4648. }
  4649. /*==========================================
  4650. * @skillon by MouseJstr
  4651. * turn skills on for the map
  4652. *------------------------------------------*/
  4653. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4654. {
  4655. nullpo_retr(-1, sd);
  4656. map[sd->bl.m].flag.noskill = 0;
  4657. clif_displaymessage(fd, msg_txt(244));
  4658. return 0;
  4659. }
  4660. /*==========================================
  4661. * @skilloff by MouseJstr
  4662. * Turn skills off on the map
  4663. *------------------------------------------*/
  4664. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4665. {
  4666. nullpo_retr(-1, sd);
  4667. map[sd->bl.m].flag.noskill = 1;
  4668. clif_displaymessage(fd, msg_txt(243));
  4669. return 0;
  4670. }
  4671. /*==========================================
  4672. * @npcmove by MouseJstr
  4673. * move a npc
  4674. *------------------------------------------*/
  4675. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4676. {
  4677. int x = 0, y = 0, m;
  4678. struct npc_data *nd = 0;
  4679. nullpo_retr(-1, sd);
  4680. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4681. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4682. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4683. return -1;
  4684. }
  4685. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4686. {
  4687. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4688. return -1;
  4689. }
  4690. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4691. {
  4692. clif_displaymessage(fd, "NPC is not on this map.");
  4693. return -1; //Not on a map.
  4694. }
  4695. x = cap_value(x, 0, map[m].xs-1);
  4696. y = cap_value(y, 0, map[m].ys-1);
  4697. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4698. map_moveblock(&nd->bl, x, y, gettick());
  4699. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4700. clif_displaymessage(fd, "NPC moved.");
  4701. return 0;
  4702. }
  4703. /*==========================================
  4704. * @addwarp by MouseJstr
  4705. * Create a new static warp point.
  4706. *------------------------------------------*/
  4707. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4708. {
  4709. char mapname[32];
  4710. int x,y;
  4711. unsigned short m;
  4712. struct npc_data* nd;
  4713. nullpo_retr(-1, sd);
  4714. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4715. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4716. return -1;
  4717. }
  4718. m = mapindex_name2id(mapname);
  4719. if( m == 0 )
  4720. {
  4721. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4722. clif_displaymessage(fd, atcmd_output);
  4723. return -1;
  4724. }
  4725. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4726. if( nd == NULL )
  4727. return -1;
  4728. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4729. clif_displaymessage(fd, atcmd_output);
  4730. return 0;
  4731. }
  4732. /*==========================================
  4733. * @follow by [MouseJstr]
  4734. * Follow a player .. staying no more then 5 spaces away
  4735. *------------------------------------------*/
  4736. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4737. {
  4738. struct map_session_data *pl_sd = NULL;
  4739. nullpo_retr(-1, sd);
  4740. if (!message || !*message) {
  4741. if (sd->followtarget == -1)
  4742. return -1;
  4743. pc_stop_following (sd);
  4744. clif_displaymessage(fd, "Follow mode OFF.");
  4745. return 0;
  4746. }
  4747. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4748. {
  4749. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4750. return -1;
  4751. }
  4752. if (sd->followtarget == pl_sd->bl.id) {
  4753. pc_stop_following (sd);
  4754. clif_displaymessage(fd, "Follow mode OFF.");
  4755. } else {
  4756. pc_follow(sd, pl_sd->bl.id);
  4757. clif_displaymessage(fd, "Follow mode ON.");
  4758. }
  4759. return 0;
  4760. }
  4761. /*==========================================
  4762. * @dropall by [MouseJstr]
  4763. * Drop all your possession on the ground
  4764. *------------------------------------------*/
  4765. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4766. {
  4767. int i;
  4768. nullpo_retr(-1, sd);
  4769. for (i = 0; i < MAX_INVENTORY; i++) {
  4770. if (sd->status.inventory[i].amount) {
  4771. if(sd->status.inventory[i].equip != 0)
  4772. pc_unequipitem(sd, i, 3);
  4773. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4774. }
  4775. }
  4776. return 0;
  4777. }
  4778. /*==========================================
  4779. * @storeall by [MouseJstr]
  4780. * Put everything into storage
  4781. *------------------------------------------*/
  4782. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4783. {
  4784. int i;
  4785. nullpo_retr(-1, sd);
  4786. if (sd->state.storage_flag != 1)
  4787. { //Open storage.
  4788. if( storage_storageopen(sd) == 1 ) {
  4789. clif_displaymessage(fd, "You can't open the storage currently.");
  4790. return -1;
  4791. }
  4792. }
  4793. for (i = 0; i < MAX_INVENTORY; i++) {
  4794. if (sd->status.inventory[i].amount) {
  4795. if(sd->status.inventory[i].equip != 0)
  4796. pc_unequipitem(sd, i, 3);
  4797. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4798. }
  4799. }
  4800. storage_storageclose(sd);
  4801. clif_displaymessage(fd, "It is done");
  4802. return 0;
  4803. }
  4804. /*==========================================
  4805. * @skillid by [MouseJstr]
  4806. * lookup a skill by name
  4807. *------------------------------------------*/
  4808. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4809. {
  4810. int skillen, idx;
  4811. nullpo_retr(-1, sd);
  4812. if (!message || !*message)
  4813. {
  4814. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4815. return -1;
  4816. }
  4817. skillen = strlen(message);
  4818. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4819. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4820. {
  4821. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4822. clif_displaymessage(fd, atcmd_output);
  4823. }
  4824. }
  4825. return 0;
  4826. }
  4827. /*==========================================
  4828. * @useskill by [MouseJstr]
  4829. * A way of using skills without having to find them in the skills menu
  4830. *------------------------------------------*/
  4831. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4832. {
  4833. struct map_session_data *pl_sd = NULL;
  4834. struct block_list *bl;
  4835. int skillnum;
  4836. int skilllv;
  4837. char target[100];
  4838. nullpo_retr(-1, sd);
  4839. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4840. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4841. return -1;
  4842. }
  4843. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4844. {
  4845. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4846. return -1;
  4847. }
  4848. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  4849. {
  4850. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4851. return -1;
  4852. }
  4853. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4854. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4855. bl = &sd->hd->bl;
  4856. else
  4857. bl = &sd->bl;
  4858. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4859. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4860. else
  4861. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4862. return 0;
  4863. }
  4864. /*==========================================
  4865. * @displayskill by [Skotlex]
  4866. * Debug command to locate new skill IDs. It sends the
  4867. * three possible skill-effect packets to the area.
  4868. *------------------------------------------*/
  4869. int atcommand_displayskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4870. {
  4871. struct status_data * status;
  4872. unsigned int tick;
  4873. int skillnum;
  4874. int skilllv = 1;
  4875. nullpo_retr(-1, sd);
  4876. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4877. {
  4878. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4879. return -1;
  4880. }
  4881. status = status_get_status_data(&sd->bl);
  4882. tick = gettick();
  4883. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4884. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4885. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4886. return 0;
  4887. }
  4888. /*==========================================
  4889. * @skilltree by [MouseJstr]
  4890. * prints the skill tree for a player required to get to a skill
  4891. *------------------------------------------*/
  4892. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4893. {
  4894. struct map_session_data *pl_sd = NULL;
  4895. int skillnum;
  4896. int meets, j, c=0;
  4897. char target[NAME_LENGTH], *tbl;
  4898. struct skill_tree_entry *ent;
  4899. nullpo_retr(-1, sd);
  4900. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4901. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4902. return -1;
  4903. }
  4904. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4905. {
  4906. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4907. return -1;
  4908. }
  4909. c = pc_calc_skilltree_normalize_job(pl_sd);
  4910. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4911. tbl = job_name(c);
  4912. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", tbl, pc_checkskill(pl_sd, 1));
  4913. clif_displaymessage(fd, atcmd_output);
  4914. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  4915. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4916. {
  4917. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4918. clif_displaymessage(fd, atcmd_output);
  4919. return 0;
  4920. }
  4921. ent = &skill_tree[c][j];
  4922. meets = 1;
  4923. for(j=0;j<5;j++)
  4924. {
  4925. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4926. {
  4927. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  4928. clif_displaymessage(fd, atcmd_output);
  4929. meets = 0;
  4930. }
  4931. }
  4932. if (meets == 1) {
  4933. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4934. clif_displaymessage(fd, atcmd_output);
  4935. }
  4936. return 0;
  4937. }
  4938. // Hand a ring with partners name on it to this char
  4939. void getring (struct map_session_data* sd)
  4940. {
  4941. int flag, item_id;
  4942. struct item item_tmp;
  4943. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4944. memset(&item_tmp, 0, sizeof(item_tmp));
  4945. item_tmp.nameid = item_id;
  4946. item_tmp.identify = 1;
  4947. item_tmp.card[0] = 255;
  4948. item_tmp.card[2] = sd->status.partner_id;
  4949. item_tmp.card[3] = sd->status.partner_id >> 16;
  4950. //Logs (A)dmins items [Lupus]
  4951. if(log_config.enable_logs&0x400)
  4952. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  4953. if((flag = pc_additem(sd,&item_tmp,1))) {
  4954. clif_additem(sd,0,0,flag);
  4955. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4956. }
  4957. }
  4958. /*==========================================
  4959. * @marry by [MouseJstr], fixed by Lupus
  4960. * Marry two players
  4961. *------------------------------------------*/
  4962. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4963. {
  4964. struct map_session_data *pl_sd1 = NULL;
  4965. struct map_session_data *pl_sd2 = NULL;
  4966. char player1[128], player2[128]; //Length used for return error msgs
  4967. nullpo_retr(-1, sd);
  4968. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  4969. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  4970. return -1;
  4971. }
  4972. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  4973. sprintf(player2, "Cannot find player '%s' online", player1);
  4974. clif_displaymessage(fd, player2);
  4975. return -1;
  4976. }
  4977. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  4978. sprintf(player1, "Cannot find player '%s' online", player2);
  4979. clif_displaymessage(fd, player1);
  4980. return -1;
  4981. }
  4982. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  4983. clif_displaymessage(fd, "They are married.. wish them well");
  4984. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  4985. // Auto-give named rings (Aru)
  4986. getring (pl_sd1);
  4987. getring (pl_sd2);
  4988. return 0;
  4989. }
  4990. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  4991. return -1;
  4992. }
  4993. /*==========================================
  4994. * @divorce by [MouseJstr], fixed by [Lupus]
  4995. * divorce two players
  4996. *------------------------------------------*/
  4997. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4998. {
  4999. struct map_session_data *pl_sd = NULL;
  5000. nullpo_retr(-1, sd);
  5001. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5002. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5003. return -1;
  5004. }
  5005. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5006. {
  5007. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5008. return -1;
  5009. }
  5010. if (pc_divorce(pl_sd) != 0) {
  5011. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5012. clif_displaymessage(fd, atcmd_output);
  5013. return -1;
  5014. }
  5015. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5016. clif_displaymessage(fd, atcmd_output);
  5017. return 0;
  5018. }
  5019. /*==========================================
  5020. * @changelook by [Celest]
  5021. *------------------------------------------*/
  5022. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5023. {
  5024. int i, j = 0, k = 0;
  5025. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5026. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5027. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5028. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5029. return -1;
  5030. } else if (i == 2) {
  5031. if (j < 1) j = 1;
  5032. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5033. j = pos[j - 1];
  5034. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5035. k = j; // swap
  5036. j = LOOK_HEAD_TOP;
  5037. }
  5038. clif_changelook(&sd->bl,j,k);
  5039. return 0;
  5040. }
  5041. /*==========================================
  5042. * @autotrade by durf (changed by Lupus)
  5043. * Turns on/off Autotrade for a specific player
  5044. *------------------------------------------*/
  5045. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5046. {
  5047. nullpo_retr(-1, sd);
  5048. if( sd->vender_id ) //check if player's vending
  5049. {
  5050. if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
  5051. {
  5052. sd->state.autotrade = 1;
  5053. if( battle_config.at_timeout )
  5054. {
  5055. int timeout = atoi(message);
  5056. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  5057. }
  5058. clif_authfail_fd(fd, 15);
  5059. } else
  5060. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5061. }
  5062. else
  5063. clif_displaymessage(fd, msg_txt(549)); // You should be vending to use @Autotrade.
  5064. return 0;
  5065. }
  5066. /*==========================================
  5067. * @changegm by durf (changed by Lupus)
  5068. * Changes Master of your Guild to a specified guild member
  5069. *------------------------------------------*/
  5070. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5071. {
  5072. struct guild *g;
  5073. struct map_session_data *pl_sd;
  5074. nullpo_retr(-1, sd);
  5075. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5076. {
  5077. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5078. return -1;
  5079. }
  5080. if( map[sd->bl.m].flag.guildlock )
  5081. {
  5082. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5083. return -1;
  5084. }
  5085. if (strlen(message)==0)
  5086. {
  5087. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5088. return -1;
  5089. }
  5090. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5091. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5092. return -1;
  5093. }
  5094. guild_gm_change(sd->status.guild_id, pl_sd);
  5095. return 0;
  5096. }
  5097. /*==========================================
  5098. * @changeleader by Skotlex
  5099. * Changes the leader of a party.
  5100. *------------------------------------------*/
  5101. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5102. {
  5103. struct party_data *p;
  5104. struct map_session_data *pl_sd;
  5105. int mi, pl_mi;
  5106. nullpo_retr(-1, sd);
  5107. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5108. { //Need to be a party leader.
  5109. clif_displaymessage(fd, msg_txt(282));
  5110. return -1;
  5111. }
  5112. if( map[sd->bl.m].flag.partylock )
  5113. {
  5114. clif_displaymessage(fd, "You cannot change party leaders on this map.");
  5115. return -1;
  5116. }
  5117. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5118. if (mi == MAX_PARTY)
  5119. return -1; //Shouldn't happen
  5120. if (!p->party.member[mi].leader)
  5121. { //Need to be a party leader.
  5122. clif_displaymessage(fd, msg_txt(282));
  5123. return -1;
  5124. }
  5125. if (strlen(message)==0)
  5126. {
  5127. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5128. return -1;
  5129. }
  5130. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  5131. clif_displaymessage(fd, msg_txt(283));
  5132. return -1;
  5133. }
  5134. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  5135. if (pl_mi == MAX_PARTY)
  5136. return -1; //Shouldn't happen
  5137. //Change leadership.
  5138. p->party.member[mi].leader = 0;
  5139. if (p->data[mi].sd->fd)
  5140. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  5141. p->party.member[pl_mi].leader = 1;
  5142. if (p->data[pl_mi].sd->fd)
  5143. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  5144. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  5145. //Update info.
  5146. clif_party_info(p,NULL);
  5147. return 0;
  5148. }
  5149. /*==========================================
  5150. * @partyoption by Skotlex
  5151. * Used to change the item share setting of a party.
  5152. *------------------------------------------*/
  5153. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5154. {
  5155. struct party_data *p;
  5156. int mi, option;
  5157. char w1[16], w2[16];
  5158. nullpo_retr(-1, sd);
  5159. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5160. {
  5161. clif_displaymessage(fd, msg_txt(282));
  5162. return -1;
  5163. }
  5164. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5165. if (mi == MAX_PARTY)
  5166. return -1; //Shouldn't happen
  5167. if (!p->party.member[mi].leader)
  5168. {
  5169. clif_displaymessage(fd, msg_txt(282));
  5170. return -1;
  5171. }
  5172. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5173. {
  5174. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5175. return -1;
  5176. }
  5177. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5178. //Change item share type.
  5179. if (option != p->party.item)
  5180. party_changeoption(sd, p->party.exp, option);
  5181. else
  5182. clif_displaymessage(fd, msg_txt(286));
  5183. return 0;
  5184. }
  5185. /*==========================================
  5186. * @autoloot by Upa-Kun
  5187. * Turns on/off AutoLoot for a specific player
  5188. *------------------------------------------*/
  5189. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5190. {
  5191. int rate;
  5192. double drate;
  5193. nullpo_retr(-1, sd);
  5194. // autoloot command without value
  5195. if(!message || !*message)
  5196. {
  5197. if (sd->state.autoloot)
  5198. rate = 0;
  5199. else
  5200. rate = 10000;
  5201. } else {
  5202. drate = atof(message);
  5203. rate = (int)(drate*100);
  5204. }
  5205. if (rate < 0) rate = 0;
  5206. if (rate > 10000) rate = 10000;
  5207. sd->state.autoloot = rate;
  5208. if (sd->state.autoloot) {
  5209. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5210. clif_displaymessage(fd, atcmd_output);
  5211. }else
  5212. clif_displaymessage(fd, "Autoloot is now off.");
  5213. return 0;
  5214. }
  5215. /*==========================================
  5216. * @autolootitem
  5217. *------------------------------------------*/
  5218. int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5219. {
  5220. struct item_data *item_data = NULL;
  5221. if (!message || !*message) {
  5222. if (sd->state.autolootid) {
  5223. sd->state.autolootid = 0;
  5224. clif_displaymessage(fd, "Autolootitem have been turned OFF.");
  5225. } else
  5226. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>).");
  5227. return -1;
  5228. }
  5229. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5230. item_data = itemdb_searchname(message);
  5231. if (!item_data) {
  5232. // No items founds in the DB with Id or Name
  5233. clif_displaymessage(fd, "Item not found.");
  5234. return -1;
  5235. }
  5236. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  5237. sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
  5238. item_data->name, item_data->jname, item_data->nameid);
  5239. clif_displaymessage(fd, atcmd_output);
  5240. return 0;
  5241. }
  5242. /*==========================================
  5243. * It is made to rain.
  5244. *------------------------------------------*/
  5245. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5246. {
  5247. nullpo_retr(-1, sd);
  5248. if (map[sd->bl.m].flag.rain) {
  5249. map[sd->bl.m].flag.rain=0;
  5250. clif_weather(sd->bl.m);
  5251. clif_displaymessage(fd, "The rain has stopped.");
  5252. } else {
  5253. map[sd->bl.m].flag.rain=1;
  5254. clif_weather(sd->bl.m);
  5255. clif_displaymessage(fd, "It is made to rain.");
  5256. }
  5257. return 0;
  5258. }
  5259. /*==========================================
  5260. * It is made to snow.
  5261. *------------------------------------------*/
  5262. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5263. {
  5264. nullpo_retr(-1, sd);
  5265. if (map[sd->bl.m].flag.snow) {
  5266. map[sd->bl.m].flag.snow=0;
  5267. clif_weather(sd->bl.m);
  5268. clif_displaymessage(fd, "Snow has stopped falling.");
  5269. } else {
  5270. map[sd->bl.m].flag.snow=1;
  5271. clif_weather(sd->bl.m);
  5272. clif_displaymessage(fd, "It is made to snow.");
  5273. }
  5274. return 0;
  5275. }
  5276. /*==========================================
  5277. * Cherry tree snowstorm is made to fall. (Sakura)
  5278. *------------------------------------------*/
  5279. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5280. {
  5281. nullpo_retr(-1, sd);
  5282. if (map[sd->bl.m].flag.sakura) {
  5283. map[sd->bl.m].flag.sakura=0;
  5284. clif_weather(sd->bl.m);
  5285. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5286. } else {
  5287. map[sd->bl.m].flag.sakura=1;
  5288. clif_weather(sd->bl.m);
  5289. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5290. }
  5291. return 0;
  5292. }
  5293. /*==========================================
  5294. * Clouds appear.
  5295. *------------------------------------------*/
  5296. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5297. {
  5298. nullpo_retr(-1, sd);
  5299. if (map[sd->bl.m].flag.clouds) {
  5300. map[sd->bl.m].flag.clouds=0;
  5301. clif_weather(sd->bl.m);
  5302. clif_displaymessage(fd, "The clouds has disappear.");
  5303. } else {
  5304. map[sd->bl.m].flag.clouds=1;
  5305. clif_weather(sd->bl.m);
  5306. clif_displaymessage(fd, "Clouds appear.");
  5307. }
  5308. return 0;
  5309. }
  5310. /*==========================================
  5311. * Different type of clouds using effect 516
  5312. *------------------------------------------*/
  5313. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5314. {
  5315. nullpo_retr(-1, sd);
  5316. if (map[sd->bl.m].flag.clouds2) {
  5317. map[sd->bl.m].flag.clouds2=0;
  5318. clif_weather(sd->bl.m);
  5319. clif_displaymessage(fd, "The alternative clouds disappear.");
  5320. } else {
  5321. map[sd->bl.m].flag.clouds2=1;
  5322. clif_weather(sd->bl.m);
  5323. clif_displaymessage(fd, "Alternative clouds appear.");
  5324. }
  5325. return 0;
  5326. }
  5327. /*==========================================
  5328. * Fog hangs over.
  5329. *------------------------------------------*/
  5330. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5331. {
  5332. nullpo_retr(-1, sd);
  5333. if (map[sd->bl.m].flag.fog) {
  5334. map[sd->bl.m].flag.fog=0;
  5335. clif_weather(sd->bl.m);
  5336. clif_displaymessage(fd, "The fog has gone.");
  5337. } else {
  5338. map[sd->bl.m].flag.fog=1;
  5339. clif_weather(sd->bl.m);
  5340. clif_displaymessage(fd, "Fog hangs over.");
  5341. }
  5342. return 0;
  5343. }
  5344. /*==========================================
  5345. * Fallen leaves fall.
  5346. *------------------------------------------*/
  5347. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5348. {
  5349. nullpo_retr(-1, sd);
  5350. if (map[sd->bl.m].flag.leaves) {
  5351. map[sd->bl.m].flag.leaves=0;
  5352. clif_weather(sd->bl.m);
  5353. clif_displaymessage(fd, "Leaves no longer fall.");
  5354. } else {
  5355. map[sd->bl.m].flag.leaves=1;
  5356. clif_weather(sd->bl.m);
  5357. clif_displaymessage(fd, "Fallen leaves fall.");
  5358. }
  5359. return 0;
  5360. }
  5361. /*==========================================
  5362. * Fireworks appear.
  5363. *------------------------------------------*/
  5364. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5365. {
  5366. nullpo_retr(-1, sd);
  5367. if (map[sd->bl.m].flag.fireworks) {
  5368. map[sd->bl.m].flag.fireworks=0;
  5369. clif_weather(sd->bl.m);
  5370. clif_displaymessage(fd, "Fireworks are ended.");
  5371. } else {
  5372. map[sd->bl.m].flag.fireworks=1;
  5373. clif_weather(sd->bl.m);
  5374. clif_displaymessage(fd, "Fireworks are launched.");
  5375. }
  5376. return 0;
  5377. }
  5378. /*==========================================
  5379. * Clearing Weather Effects by Dexity
  5380. *------------------------------------------*/
  5381. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5382. {
  5383. nullpo_retr(-1, sd);
  5384. map[sd->bl.m].flag.rain=0;
  5385. map[sd->bl.m].flag.snow=0;
  5386. map[sd->bl.m].flag.sakura=0;
  5387. map[sd->bl.m].flag.clouds=0;
  5388. map[sd->bl.m].flag.clouds2=0;
  5389. map[sd->bl.m].flag.fog=0;
  5390. map[sd->bl.m].flag.fireworks=0;
  5391. map[sd->bl.m].flag.leaves=0;
  5392. clif_weather(sd->bl.m);
  5393. clif_displaymessage(fd, msg_txt(291));
  5394. return 0;
  5395. }
  5396. /*===============================================================
  5397. * Sound Command - plays a sound for everyone around! [Codemaster]
  5398. *---------------------------------------------------------------*/
  5399. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  5400. {
  5401. char sound_file[100];
  5402. memset(sound_file, '\0', sizeof(sound_file));
  5403. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5404. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5405. return -1;
  5406. }
  5407. if(strstr(sound_file, ".wav") == NULL)
  5408. strcat(sound_file, ".wav");
  5409. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5410. return 0;
  5411. }
  5412. /*==========================================
  5413. * MOB Search
  5414. *------------------------------------------*/
  5415. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  5416. {
  5417. int mob_id,fd;
  5418. static int number=0;
  5419. struct mob_data *md;
  5420. nullpo_retr(0, bl);
  5421. if(!ap){
  5422. number=0;
  5423. return 0;
  5424. }
  5425. mob_id = va_arg(ap,int);
  5426. fd = va_arg(ap,int);
  5427. md = (struct mob_data *)bl;
  5428. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  5429. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  5430. ++number,bl->x, bl->y,md->name);
  5431. clif_displaymessage(fd, atcmd_output);
  5432. }
  5433. return 0;
  5434. }
  5435. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5436. {
  5437. char mob_name[100];
  5438. int mob_id,map_id = 0;
  5439. nullpo_retr(-1, sd);
  5440. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5441. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5442. return -1;
  5443. }
  5444. if ((mob_id = atoi(mob_name)) == 0)
  5445. mob_id = mobdb_searchname(mob_name);
  5446. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5447. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5448. clif_displaymessage(fd, atcmd_output);
  5449. return -1;
  5450. }
  5451. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5452. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5453. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5454. map_id = sd->bl.m;
  5455. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5456. clif_displaymessage(fd, atcmd_output);
  5457. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  5458. atmobsearch_sub(&sd->bl,0); // reset the counter
  5459. return 0;
  5460. }
  5461. /*==========================================
  5462. * @cleanmap - cleans items on the ground
  5463. *------------------------------------------*/
  5464. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5465. {
  5466. nullpo_retr(0, bl);
  5467. map_clearflooritem(bl->id);
  5468. return 0;
  5469. }
  5470. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5471. {
  5472. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5473. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5474. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5475. BL_ITEM);
  5476. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5477. return 0;
  5478. }
  5479. /*==========================================
  5480. * make a NPC/PET talk
  5481. *------------------------------------------*/
  5482. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5483. {
  5484. char name[NAME_LENGTH],mes[100],temp[100];
  5485. struct npc_data *nd;
  5486. if (sd->sc.count && //no "chatting" while muted.
  5487. (sd->sc.data[SC_BERSERK] ||
  5488. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5489. return -1;
  5490. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5491. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5492. return -1;
  5493. }
  5494. if (!(nd = npc_name2id(name))) {
  5495. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5496. return -1;
  5497. }
  5498. strtok(name, "#"); // discard extra name identifier if present
  5499. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5500. clif_message(&nd->bl, temp);
  5501. return 0;
  5502. }
  5503. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5504. {
  5505. char mes[100],temp[100];
  5506. struct pet_data *pd;
  5507. nullpo_retr(-1, sd);
  5508. if(!sd->status.pet_id || !(pd=sd->pd))
  5509. {
  5510. clif_displaymessage(fd, msg_txt(184));
  5511. return -1;
  5512. }
  5513. if (sd->sc.count && //no "chatting" while muted.
  5514. (sd->sc.data[SC_BERSERK] ||
  5515. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5516. return -1;
  5517. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5518. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5519. return -1;
  5520. }
  5521. if (message[0] == '/')
  5522. {// pet emotion processing
  5523. const char* emo[] = {
  5524. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5525. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5526. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5527. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5528. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5529. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5530. };
  5531. int i;
  5532. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5533. if( i < ARRAYLENGTH(emo) )
  5534. {
  5535. clif_emotion(&pd->bl, i);
  5536. return 0;
  5537. }
  5538. }
  5539. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5540. clif_message(&pd->bl, temp);
  5541. return 0;
  5542. }
  5543. /*==========================================
  5544. * @users - displays the number of players present on each map (percentage)
  5545. *------------------------------------------*/
  5546. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5547. {
  5548. char buf[256];
  5549. DBMap* users_db; // unsigned int mapindex -> int users
  5550. int users_all;
  5551. users_db = uidb_alloc(DB_OPT_BASE);
  5552. users_all = 0;
  5553. // count users on each map
  5554. {
  5555. struct s_mapiterator* iter;
  5556. struct map_session_data* sd;
  5557. iter = mapit_getallusers();
  5558. for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) )
  5559. {
  5560. int users = (int)uidb_get(users_db,sd->mapindex) + 1;
  5561. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  5562. users_all++;
  5563. }
  5564. mapit_free(iter);
  5565. }
  5566. // display results for each map
  5567. {
  5568. DBIterator* iter;
  5569. DBKey index;
  5570. int users;
  5571. iter = users_db->iterator(users_db);
  5572. for( users = (int)iter->first(iter,&index); iter->exists(iter); users = (int)iter->next(iter,&index) )
  5573. {
  5574. sprintf(buf,"%s: %d (%d%%)",mapindex_id2name(index.i),users,users * 100 / users_all);
  5575. clif_displaymessage(sd->fd,buf);
  5576. }
  5577. iter->destroy(iter);
  5578. }
  5579. // display overall count
  5580. sprintf(buf,"all: %d",users_all);
  5581. clif_displaymessage(fd,buf);
  5582. users_db->destroy(users_db,NULL);
  5583. return 0;
  5584. }
  5585. /*==========================================
  5586. *
  5587. *------------------------------------------*/
  5588. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5589. {
  5590. pc_resetstate(sd);
  5591. pc_resetskill(sd,1);
  5592. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5593. clif_displaymessage(fd, atcmd_output);
  5594. return 0;
  5595. }
  5596. /*==========================================
  5597. *
  5598. *------------------------------------------*/
  5599. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5600. {
  5601. char name[NAME_LENGTH];
  5602. int mob_id = 0;
  5603. int duration = 0;
  5604. struct mob_data *md;
  5605. unsigned int tick=gettick();
  5606. nullpo_retr(-1, sd);
  5607. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5608. {
  5609. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5610. return -1;
  5611. }
  5612. if (duration < 1)
  5613. duration =1;
  5614. else if (duration > 60)
  5615. duration =60;
  5616. if ((mob_id = atoi(name)) == 0)
  5617. mob_id = mobdb_searchname(name);
  5618. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5619. {
  5620. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5621. return -1;
  5622. }
  5623. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5624. if(!md)
  5625. return -1;
  5626. md->master_id=sd->bl.id;
  5627. md->special_state.ai=1;
  5628. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5629. clif_misceffect2(&md->bl,344);
  5630. mob_spawn(md);
  5631. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5632. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5633. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5634. return 0;
  5635. }
  5636. /*==========================================
  5637. * @adjcmdlvl by [MouseJstr]
  5638. *
  5639. * Temp adjust the GM level required to use a GM command
  5640. * Useful during beta testing to allow players to use GM commands for short periods of time
  5641. *------------------------------------------*/
  5642. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5643. {
  5644. int newlev;
  5645. char name[100];
  5646. AtCommandInfo* cmd;
  5647. nullpo_retr(-1, sd);
  5648. if (!message || !*message || sscanf(message, "%d %99s", &newlev, name) != 2)
  5649. {
  5650. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  5651. return -1;
  5652. }
  5653. cmd = get_atcommandinfo_byname(name);
  5654. if (cmd == NULL)
  5655. {
  5656. clif_displaymessage(fd, "@command not found.");
  5657. return -1;
  5658. }
  5659. else if (newlev > pc_isGM(sd))
  5660. {
  5661. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5662. return -1;
  5663. }
  5664. else if (cmd->level > pc_isGM(sd))
  5665. {
  5666. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5667. return -1;
  5668. }
  5669. else
  5670. {
  5671. cmd->level = newlev;
  5672. clif_displaymessage(fd, "@command level changed.");
  5673. return 0;
  5674. }
  5675. }
  5676. /*==========================================
  5677. * @adjgmlvl by [MouseJstr]
  5678. * Create a temp GM
  5679. * Useful during beta testing to allow players to use GM commands for short periods of time
  5680. *------------------------------------------*/
  5681. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5682. {
  5683. int newlev;
  5684. char user[NAME_LENGTH];
  5685. struct map_session_data *pl_sd;
  5686. nullpo_retr(-1, sd);
  5687. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5688. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5689. return -1;
  5690. }
  5691. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5692. {
  5693. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5694. return -1;
  5695. }
  5696. pl_sd->gmlevel = newlev;
  5697. return 0;
  5698. }
  5699. /*==========================================
  5700. * @trade by [MouseJstr]
  5701. * Open a trade window with a remote player
  5702. *------------------------------------------*/
  5703. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5704. {
  5705. struct map_session_data *pl_sd = NULL;
  5706. nullpo_retr(-1, sd);
  5707. if (!message || !*message) {
  5708. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5709. return -1;
  5710. }
  5711. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5712. {
  5713. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5714. return -1;
  5715. }
  5716. trade_traderequest(sd, pl_sd);
  5717. return 0;
  5718. }
  5719. /*==========================================
  5720. * @setbattleflag by [MouseJstr]
  5721. * set a battle_config flag without having to reboot
  5722. *------------------------------------------*/
  5723. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5724. {
  5725. char flag[128], value[128];
  5726. nullpo_retr(-1, sd);
  5727. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5728. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5729. return -1;
  5730. }
  5731. if (battle_set_value(flag, value) == 0)
  5732. {
  5733. clif_displaymessage(fd, "unknown battle_config flag");
  5734. return -1;
  5735. }
  5736. clif_displaymessage(fd, "battle_config set as requested");
  5737. return 0;
  5738. }
  5739. /*==========================================
  5740. * @unmute [Valaris]
  5741. *------------------------------------------*/
  5742. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5743. {
  5744. struct map_session_data *pl_sd = NULL;
  5745. nullpo_retr(-1, sd);
  5746. if (!message || !*message) {
  5747. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5748. return -1;
  5749. }
  5750. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5751. {
  5752. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5753. return -1;
  5754. }
  5755. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5756. clif_displaymessage(sd->fd,"Player is not muted");
  5757. return -1;
  5758. }
  5759. pl_sd->status.manner = 0;
  5760. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5761. clif_displaymessage(sd->fd,"Player unmuted");
  5762. return 0;
  5763. }
  5764. /*==========================================
  5765. * @uptime by MC Cameri
  5766. *------------------------------------------*/
  5767. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5768. {
  5769. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5770. minute = 60, days = 0, hours = 0, minutes = 0;
  5771. nullpo_retr(-1, sd);
  5772. seconds = get_uptime();
  5773. days = seconds/day;
  5774. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5775. hours = seconds/hour;
  5776. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5777. minutes = seconds/minute;
  5778. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5779. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5780. clif_displaymessage(fd, atcmd_output);
  5781. return 0;
  5782. }
  5783. /*==========================================
  5784. * @changesex <sex>
  5785. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5786. *------------------------------------------*/
  5787. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5788. {
  5789. nullpo_retr(-1, sd);
  5790. chrif_changesex(sd);
  5791. return 0;
  5792. }
  5793. /*================================================
  5794. * @mute - Mutes a player for a set amount of time
  5795. *------------------------------------------------*/
  5796. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5797. {
  5798. struct map_session_data *pl_sd = NULL;
  5799. int manner;
  5800. nullpo_retr(-1, sd);
  5801. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5802. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5803. return -1;
  5804. }
  5805. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5806. {
  5807. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5808. return -1;
  5809. }
  5810. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5811. {
  5812. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5813. return -1;
  5814. }
  5815. clif_manner_message(sd, 0);
  5816. clif_manner_message(pl_sd, 5);
  5817. if( pl_sd->status.manner < manner ) {
  5818. pl_sd->status.manner -= manner;
  5819. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5820. } else {
  5821. pl_sd->status.manner = 0;
  5822. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5823. }
  5824. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5825. return 0;
  5826. }
  5827. /*==========================================
  5828. * @refresh (like @jumpto <<yourself>>)
  5829. *------------------------------------------*/
  5830. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5831. {
  5832. nullpo_retr(-1, sd);
  5833. clif_refresh(sd);
  5834. return 0;
  5835. }
  5836. /*==========================================
  5837. * @identify
  5838. * => GM's magnifier.
  5839. *------------------------------------------*/
  5840. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5841. {
  5842. int i,num;
  5843. nullpo_retr(-1, sd);
  5844. for(i=num=0;i<MAX_INVENTORY;i++){
  5845. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5846. num++;
  5847. }
  5848. }
  5849. if (num > 0) {
  5850. clif_item_identify_list(sd);
  5851. } else {
  5852. clif_displaymessage(fd,"There are no items to appraise.");
  5853. }
  5854. return 0;
  5855. }
  5856. /*==========================================
  5857. * @gmotd (Global MOTD)
  5858. * by davidsiaw :P
  5859. *------------------------------------------*/
  5860. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5861. {
  5862. char buf[256];
  5863. FILE *fp;
  5864. nullpo_retr(-1, sd);
  5865. if((fp = fopen(motd_txt, "r"))!=NULL){
  5866. while(fgets(buf, sizeof(buf), fp) != NULL)
  5867. {
  5868. int i;
  5869. if (buf[0] == '/' && buf[1] == '/')
  5870. continue;
  5871. for(i=0; buf[i]; i++){
  5872. if(buf[i]=='\r' || buf[i]=='\n'){
  5873. buf[i]=0;
  5874. break;
  5875. }
  5876. }
  5877. intif_GMmessage(buf,strlen(buf)+1,8);
  5878. }
  5879. fclose(fp);
  5880. }
  5881. return 0;
  5882. }
  5883. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5884. {
  5885. int effect = 0;
  5886. nullpo_retr(-1, sd);
  5887. if (!message || !*message)
  5888. return -1;
  5889. if (sscanf(message, "%d", &effect) < 1)
  5890. return -1;
  5891. clif_misceffect(&sd->bl,effect);
  5892. return 0;
  5893. }
  5894. /*==========================================
  5895. * MAIL SYSTEM
  5896. *------------------------------------------*/
  5897. int atcommand_mail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5898. {
  5899. nullpo_retr(0,sd);
  5900. #ifndef TXT_ONLY
  5901. mail_openmail(sd);
  5902. #endif
  5903. return 0;
  5904. }
  5905. /*==========================================
  5906. * Show Monster DB Info v 1.0
  5907. * originally by [Lupus] eAthena
  5908. *------------------------------------------*/
  5909. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5910. {
  5911. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5912. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5913. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5914. char atcmd_output2[200];
  5915. struct item_data *item_data;
  5916. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5917. int count;
  5918. int i, j, k;
  5919. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5920. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5921. if (!message || !*message) {
  5922. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5923. return -1;
  5924. }
  5925. // If monster identifier/name argument is a name
  5926. if ((i = mobdb_checkid(atoi(message))))
  5927. {
  5928. mob_array[0] = mob_db(i);
  5929. count = 1;
  5930. } else
  5931. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5932. if (!count) {
  5933. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5934. return -1;
  5935. }
  5936. if (count > MAX_SEARCH) {
  5937. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5938. clif_displaymessage(fd, atcmd_output);
  5939. count = MAX_SEARCH;
  5940. }
  5941. for (k = 0; k < count; k++) {
  5942. mob = mob_array[k];
  5943. // stats
  5944. if (mob->mexp)
  5945. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5946. else
  5947. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5948. clif_displaymessage(fd, atcmd_output);
  5949. 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);
  5950. clif_displaymessage(fd, atcmd_output);
  5951. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5952. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5953. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5954. clif_displaymessage(fd, atcmd_output);
  5955. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5956. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5957. mob->range2 , mob->range3, msize[mob->status.size],
  5958. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5959. clif_displaymessage(fd, atcmd_output);
  5960. // drops
  5961. clif_displaymessage(fd, " Drops:");
  5962. strcpy(atcmd_output, " ");
  5963. j = 0;
  5964. for (i = 0; i < MAX_MOB_DROP; i++) {
  5965. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  5966. continue;
  5967. if (item_data->slot)
  5968. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5969. else
  5970. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5971. strcat(atcmd_output, atcmd_output2);
  5972. if (++j % 3 == 0) {
  5973. clif_displaymessage(fd, atcmd_output);
  5974. strcpy(atcmd_output, " ");
  5975. }
  5976. }
  5977. if (j == 0)
  5978. clif_displaymessage(fd, "This monster has no drops.");
  5979. else if (j % 3 != 0)
  5980. clif_displaymessage(fd, atcmd_output);
  5981. // mvp
  5982. if (mob->mexp) {
  5983. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  5984. clif_displaymessage(fd, atcmd_output);
  5985. strcpy(atcmd_output, " MVP Items:");
  5986. j = 0;
  5987. for (i = 0; i < 3; i++) {
  5988. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  5989. continue;
  5990. if (mob->mvpitem[i].p > 0) {
  5991. j++;
  5992. if (j == 1)
  5993. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5994. else
  5995. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5996. strcat(atcmd_output, atcmd_output2);
  5997. }
  5998. }
  5999. if (j == 0)
  6000. clif_displaymessage(fd, "This monster has no MVP prizes.");
  6001. else
  6002. clif_displaymessage(fd, atcmd_output);
  6003. }
  6004. }
  6005. return 0;
  6006. }
  6007. /*=========================================
  6008. * @showmobs by KarLaeda
  6009. * => For 5 sec displays the mobs on minimap
  6010. *------------------------------------------*/
  6011. int atshowmobs_timer(int tid, unsigned int tick, int id, intptr data)
  6012. {
  6013. struct map_session_data* sd = map_id2sd(id);
  6014. if( sd == NULL )
  6015. return 0;
  6016. // remove indicator
  6017. clif_viewpoint(sd, 1, 2, 0, 0, (int)data, 0xFFFFFF);
  6018. return 1;
  6019. }
  6020. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  6021. {
  6022. int mob_id;
  6023. struct map_session_data* sd;
  6024. static int number=0;
  6025. struct mob_data *md;
  6026. if(!ap){
  6027. number=0;
  6028. return 0;
  6029. }
  6030. mob_id = va_arg(ap,int);
  6031. sd = va_arg(ap,struct map_session_data*);
  6032. md = (struct mob_data *)bl;
  6033. if(md->special_state.ai || md->master_id)
  6034. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  6035. if(mob_id==-1 || md->class_==mob_id){
  6036. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  6037. add_timer(gettick()+5000, atshowmobs_timer, sd->bl.id, number);
  6038. }
  6039. return 0;
  6040. }
  6041. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6042. {
  6043. char mob_name[100];
  6044. int mob_id,map_id = 0;
  6045. nullpo_retr(-1, sd);
  6046. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6047. return -1;
  6048. if((mob_id = atoi(mob_name)) == 0)
  6049. mob_id = mobdb_searchname(mob_name);
  6050. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6051. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6052. clif_displaymessage(fd, atcmd_output);
  6053. return 0;
  6054. }
  6055. // Uncomment the following line to show mini-bosses & MVP.
  6056. //#define SHOW_MVP
  6057. #ifndef SHOW_MVP
  6058. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6059. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6060. clif_displaymessage(fd, atcmd_output);
  6061. return 0;
  6062. }
  6063. #endif
  6064. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6065. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6066. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6067. map_id = sd->bl.m;
  6068. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6069. mob_name, mapindex_id2name(sd->mapindex));
  6070. clif_displaymessage(fd, atcmd_output);
  6071. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, sd);
  6072. atshowmobs_sub(&sd->bl,0);
  6073. return 0;
  6074. }
  6075. /*==========================================
  6076. * homunculus level up [orn]
  6077. *------------------------------------------*/
  6078. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6079. {
  6080. TBL_HOM * hd;
  6081. int level = 0, i = 0;
  6082. nullpo_retr(-1, sd);
  6083. if (!message || !*message) {
  6084. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <+/- # of levels>.");
  6085. return -1;
  6086. }
  6087. if ( !merc_is_hom_active(sd->hd) ) {
  6088. clif_displaymessage(fd, "You do not have a homunculus.");
  6089. return -1;
  6090. }
  6091. level = atoi(message);
  6092. hd = sd->hd;
  6093. for (i = 1; i <= level && hd->exp_next; i++){
  6094. hd->homunculus.exp += hd->exp_next;
  6095. merc_hom_levelup(hd);
  6096. }
  6097. status_calc_homunculus(hd,0);
  6098. status_percent_heal(&hd->bl, 100, 100);
  6099. clif_misceffect2(&hd->bl,568);
  6100. return 0;
  6101. }
  6102. /*==========================================
  6103. * homunculus evolution H [orn]
  6104. *------------------------------------------*/
  6105. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6106. {
  6107. nullpo_retr(-1, sd);
  6108. if ( !merc_is_hom_active(sd->hd) ) {
  6109. clif_displaymessage(fd, "You do not have a homunculus.");
  6110. return -1;
  6111. }
  6112. if ( !merc_hom_evolution(sd->hd) ) {
  6113. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6114. return -1;
  6115. }
  6116. return 0;
  6117. }
  6118. /*==========================================
  6119. * call choosen homunculus [orn]
  6120. *------------------------------------------*/
  6121. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6122. {
  6123. int homunid;
  6124. nullpo_retr(-1, sd);
  6125. if ( merc_is_hom_active(sd->hd) ) {
  6126. clif_displaymessage(fd, msg_txt(450));
  6127. return -1;
  6128. }
  6129. if (!message || !*message) {
  6130. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6131. return -1;
  6132. }
  6133. homunid = atoi(message);
  6134. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6135. {
  6136. clif_displaymessage(fd, "Invalid Homunculus id.");
  6137. return -1;
  6138. }
  6139. merc_create_homunculus_request(sd,homunid);
  6140. return 0;
  6141. }
  6142. /*==========================================
  6143. * modify homunculus intimacy [orn]
  6144. *------------------------------------------*/
  6145. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6146. {
  6147. int friendly = 0;
  6148. nullpo_retr(-1, sd);
  6149. if ( !merc_is_hom_active(sd->hd) ) {
  6150. clif_displaymessage(fd, "You do not have a homunculus.");
  6151. return -1;
  6152. }
  6153. if (!message || !*message) {
  6154. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6155. return -1;
  6156. }
  6157. friendly = atoi(message);
  6158. friendly = cap_value(friendly, 0, 1000);
  6159. sd->hd->homunculus.intimacy = friendly * 100 ;
  6160. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6161. return 0;
  6162. }
  6163. /*==========================================
  6164. * modify homunculus hunger [orn]
  6165. *------------------------------------------*/
  6166. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6167. {
  6168. int hungry = 0;
  6169. nullpo_retr(-1, sd);
  6170. if ( !merc_is_hom_active(sd->hd) ) {
  6171. clif_displaymessage(fd, "You do not have a homunculus.");
  6172. return -1;
  6173. }
  6174. if (!message || !*message) {
  6175. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6176. return -1;
  6177. }
  6178. hungry = atoi(message);
  6179. hungry = cap_value(hungry, 0, 100);
  6180. sd->hd->homunculus.hunger = hungry;
  6181. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6182. return 0;
  6183. }
  6184. /*==========================================
  6185. * make the homunculus speak [orn]
  6186. *------------------------------------------*/
  6187. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6188. {
  6189. char mes[100],temp[100];
  6190. nullpo_retr(-1, sd);
  6191. if (sd->sc.count && //no "chatting" while muted.
  6192. (sd->sc.data[SC_BERSERK] ||
  6193. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6194. return -1;
  6195. if ( !merc_is_hom_active(sd->hd) ) {
  6196. clif_displaymessage(fd, "You do not have a homunculus.");
  6197. return -1;
  6198. }
  6199. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6200. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6201. return -1;
  6202. }
  6203. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6204. clif_message(&sd->hd->bl, temp);
  6205. return 0;
  6206. }
  6207. /*==========================================
  6208. * Show homunculus stats
  6209. *------------------------------------------*/
  6210. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6211. {
  6212. struct homun_data *hd;
  6213. struct status_data *status;
  6214. nullpo_retr(-1, sd);
  6215. if ( !merc_is_hom_active(sd->hd) ) {
  6216. clif_displaymessage(fd, "You do not have a homunculus.");
  6217. return -1;
  6218. }
  6219. hd = sd->hd;
  6220. status = status_get_status_data(&hd->bl);
  6221. clif_displaymessage(fd, "Homunculus stats :");
  6222. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6223. status->hp, status->max_hp, status->sp, status->max_sp);
  6224. clif_displaymessage(fd, atcmd_output);
  6225. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6226. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6227. clif_displaymessage(fd, atcmd_output);
  6228. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6229. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6230. clif_displaymessage(fd, atcmd_output);
  6231. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6232. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6233. status->str, status->agi, status->vit,
  6234. status->int_, status->dex, status->luk);
  6235. clif_displaymessage(fd, atcmd_output);
  6236. return 0;
  6237. }
  6238. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6239. {
  6240. struct homun_data *hd;
  6241. struct s_homunculus_db *db;
  6242. struct s_homunculus *hom;
  6243. int lv, min, max, evo;
  6244. nullpo_retr(-1, sd);
  6245. if ( !merc_is_hom_active(sd->hd) ) {
  6246. clif_displaymessage(fd, "You do not have a homunculus.");
  6247. return -1;
  6248. }
  6249. hd = sd->hd;
  6250. hom = &hd->homunculus;
  6251. db = hd->homunculusDB;
  6252. lv = hom->level;
  6253. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6254. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6255. clif_displaymessage(fd, atcmd_output);
  6256. lv--; //Since the first increase is at level 2.
  6257. evo = (hom->class_ == db->evo_class);
  6258. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6259. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6260. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6261. clif_displaymessage(fd, atcmd_output);
  6262. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6263. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6264. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6265. clif_displaymessage(fd, atcmd_output);
  6266. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6267. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6268. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6269. clif_displaymessage(fd, atcmd_output);
  6270. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6271. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6272. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6273. clif_displaymessage(fd, atcmd_output);
  6274. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6275. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6276. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6277. clif_displaymessage(fd, atcmd_output);
  6278. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6279. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6280. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6281. clif_displaymessage(fd, atcmd_output);
  6282. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6283. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6284. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6285. clif_displaymessage(fd, atcmd_output);
  6286. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6287. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6288. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6289. clif_displaymessage(fd, atcmd_output);
  6290. return 0;
  6291. }
  6292. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6293. {
  6294. TBL_PC* tsd = sd;
  6295. nullpo_retr(-1, sd);
  6296. if ((!message || !*message) && !sd->hd)
  6297. {
  6298. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  6299. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  6300. return -1;
  6301. }
  6302. if (message && *message) {
  6303. tsd = map_nick2sd((char*)message);
  6304. if (!tsd) {
  6305. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6306. return -1;
  6307. }
  6308. if (pc_isGM(tsd) > pc_isGM(sd)) {
  6309. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6310. return -1;
  6311. }
  6312. }
  6313. if(!merc_hom_shuffle(tsd->hd))
  6314. return -1;
  6315. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6316. //Print out the new stats
  6317. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  6318. atcommand_homstats(fd, tsd, command, message);
  6319. return 0;
  6320. }
  6321. /*==========================================
  6322. * Show Items DB Info v 1.0
  6323. * originally by [Lupus] eAthena
  6324. *------------------------------------------*/
  6325. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6326. {
  6327. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  6328. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  6329. struct item_data *item_data, *item_array[MAX_SEARCH];
  6330. int i, count = 1;
  6331. if (!message || !*message) {
  6332. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6333. return -1;
  6334. }
  6335. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6336. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6337. if (!count) {
  6338. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6339. return -1;
  6340. }
  6341. if (count > MAX_SEARCH) {
  6342. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6343. clif_displaymessage(fd, atcmd_output);
  6344. count = MAX_SEARCH;
  6345. }
  6346. for (i = 0; i < count; i++) {
  6347. item_data = item_array[i];
  6348. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6349. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6350. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  6351. (item_data->script==NULL)? "None" : "With script"
  6352. );
  6353. clif_displaymessage(fd, atcmd_output);
  6354. 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. );
  6355. clif_displaymessage(fd, atcmd_output);
  6356. if (item_data->maxchance == 10000)
  6357. strcpy(atcmd_output, " - Available in the shops only");
  6358. else if (item_data->maxchance)
  6359. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6360. else
  6361. strcpy(atcmd_output, " - Monsters don't drop this item");
  6362. clif_displaymessage(fd, atcmd_output);
  6363. }
  6364. return 0;
  6365. }
  6366. /*==========================================
  6367. * Show who drops the item.
  6368. *------------------------------------------*/
  6369. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6370. {
  6371. struct item_data *item_data, *item_array[MAX_SEARCH];
  6372. int i,j, count = 1;
  6373. if (!message || !*message) {
  6374. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6375. return -1;
  6376. }
  6377. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6378. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6379. if (!count) {
  6380. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6381. return -1;
  6382. }
  6383. if (count > MAX_SEARCH) {
  6384. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6385. clif_displaymessage(fd, atcmd_output);
  6386. count = MAX_SEARCH;
  6387. }
  6388. for (i = 0; i < count; i++) {
  6389. item_data = item_array[i];
  6390. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6391. clif_displaymessage(fd, atcmd_output);
  6392. if (item_data->mob[0].chance == 0) {
  6393. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6394. clif_displaymessage(fd, atcmd_output);
  6395. } else {
  6396. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6397. clif_displaymessage(fd, atcmd_output);
  6398. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6399. {
  6400. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6401. clif_displaymessage(fd, atcmd_output);
  6402. }
  6403. }
  6404. }
  6405. return 0;
  6406. }
  6407. int atcommand_whereis(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6408. {
  6409. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6410. int count;
  6411. int i, j, k;
  6412. if (!message || !*message) {
  6413. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6414. return -1;
  6415. }
  6416. // If monster identifier/name argument is a name
  6417. if ((i = mobdb_checkid(atoi(message))))
  6418. {
  6419. mob_array[0] = mob_db(i);
  6420. count = 1;
  6421. } else
  6422. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6423. if (!count) {
  6424. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6425. return -1;
  6426. }
  6427. if (count > MAX_SEARCH) {
  6428. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6429. clif_displaymessage(fd, atcmd_output);
  6430. count = MAX_SEARCH;
  6431. }
  6432. for (k = 0; k < count; k++) {
  6433. mob = mob_array[k];
  6434. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6435. clif_displaymessage(fd, atcmd_output);
  6436. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6437. {
  6438. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6439. if (j < 0) continue;
  6440. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6441. clif_displaymessage(fd, atcmd_output);
  6442. }
  6443. if (i == 0)
  6444. clif_displaymessage(fd, "This monster does not spawn normally.");
  6445. }
  6446. return 0;
  6447. }
  6448. /*==========================================
  6449. * @adopt by [Veider]
  6450. * adopt a novice
  6451. *------------------------------------------*/
  6452. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6453. {
  6454. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6455. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6456. char output[256];
  6457. nullpo_retr(-1, sd);
  6458. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6459. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6460. return -1;
  6461. }
  6462. if (battle_config.etc_log)
  6463. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6464. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6465. sprintf(output, "Cannot find player %s online", player1);
  6466. clif_displaymessage(fd, output);
  6467. return -1;
  6468. }
  6469. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6470. sprintf(output, "Cannot find player %s online", player2);
  6471. clif_displaymessage(fd, output);
  6472. return -1;
  6473. }
  6474. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6475. sprintf(output, "Cannot find player %s online", player3);
  6476. clif_displaymessage(fd, output);
  6477. return -1;
  6478. }
  6479. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6480. return -1;
  6481. }
  6482. clif_displaymessage(fd, "They are family... wish them luck");
  6483. return 0;
  6484. }
  6485. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6486. {
  6487. const char * revision;
  6488. if ((revision = get_svn_revision()) != 0) {
  6489. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6490. clif_displaymessage(fd,atcmd_output);
  6491. } else
  6492. clif_displaymessage(fd,"Cannot determine SVN revision");
  6493. return 0;
  6494. }
  6495. /*==========================================
  6496. * @mutearea by MouseJstr
  6497. *------------------------------------------*/
  6498. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6499. {
  6500. int time, id;
  6501. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6502. if (pl_sd == NULL)
  6503. return 0;
  6504. id = va_arg(ap, int);
  6505. time = va_arg(ap, int);
  6506. if (id != bl->id && !pc_isGM(pl_sd)) {
  6507. pl_sd->status.manner -= time;
  6508. if (pl_sd->status.manner < 0)
  6509. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6510. else if (pl_sd->sc.data[SC_NOCHAT])
  6511. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  6512. }
  6513. return 0;
  6514. }
  6515. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6516. {
  6517. int time;
  6518. nullpo_retr(0, sd);
  6519. if (!message || !*message) {
  6520. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6521. return -1;
  6522. }
  6523. time = atoi(message);
  6524. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6525. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6526. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6527. return 0;
  6528. }
  6529. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6530. {
  6531. char buf[255];
  6532. nullpo_retr(0, sd);
  6533. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  6534. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6535. clif_displaymessage(fd, buf);
  6536. return 0;
  6537. }
  6538. /*==========================================
  6539. * @me by lordalfa
  6540. * => Displays the OUTPUT string on top of the Visible players Heads.
  6541. *------------------------------------------*/
  6542. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6543. {
  6544. char tempmes[200];
  6545. nullpo_retr(-1, sd);
  6546. memset(tempmes, '\0', sizeof(tempmes));
  6547. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6548. if (sd->sc.count && //no "chatting" while muted.
  6549. (sd->sc.data[SC_BERSERK] ||
  6550. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6551. return -1;
  6552. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6553. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6554. return -1;
  6555. }
  6556. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6557. clif_disp_overhead(sd, atcmd_output);
  6558. return 0;
  6559. }
  6560. /*==========================================
  6561. * @size
  6562. * => Resize your character sprite. [Valaris]
  6563. *------------------------------------------*/
  6564. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6565. {
  6566. int size=0;
  6567. nullpo_retr(-1, sd);
  6568. size = atoi(message);
  6569. if(sd->state.size) {
  6570. sd->state.size=0;
  6571. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  6572. }
  6573. if(size==1) {
  6574. sd->state.size=1;
  6575. clif_specialeffect(&sd->bl,420,AREA);
  6576. } else if(size==2) {
  6577. sd->state.size=2;
  6578. clif_specialeffect(&sd->bl,422,AREA);
  6579. }
  6580. return 0;
  6581. }
  6582. /*==========================================
  6583. * @monsterignore
  6584. * => Makes monsters ignore you. [Valaris]
  6585. *------------------------------------------*/
  6586. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6587. {
  6588. nullpo_retr(-1, sd);
  6589. if (!sd->state.monster_ignore) {
  6590. sd->state.monster_ignore = 1;
  6591. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6592. } else {
  6593. sd->state.monster_ignore = 0;
  6594. clif_displaymessage(sd->fd, "Returned to normal state.");
  6595. }
  6596. return 0;
  6597. }
  6598. /*==========================================
  6599. * @fakename
  6600. * => Gives your character a fake name. [Valaris]
  6601. *------------------------------------------*/
  6602. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6603. {
  6604. char name[NAME_LENGTH];
  6605. nullpo_retr(-1, sd);
  6606. if((!message || !*message) && strlen(sd->fakename) > 1) {
  6607. sd->fakename[0]='\0';
  6608. clif_charnameack(0, &sd->bl);
  6609. clif_displaymessage(sd->fd,"Returned to real name.");
  6610. return 0;
  6611. }
  6612. if (!message || !*message || sscanf(message, "%23[^\n]", name) < 1) {
  6613. clif_displaymessage(sd->fd,"You must enter a name.");
  6614. return -1;
  6615. }
  6616. if(strlen(name) < 2) {
  6617. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  6618. return -1;
  6619. }
  6620. memcpy(sd->fakename,name,NAME_LENGTH);
  6621. sd->fakename[NAME_LENGTH-1] = '\0';
  6622. clif_charnameack(0, &sd->bl);
  6623. clif_displaymessage(sd->fd,"Fake name enabled.");
  6624. return 0;
  6625. }
  6626. /*==========================================
  6627. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  6628. * => Shows information about the map flags [map name]
  6629. * Also set flags
  6630. *------------------------------------------*/
  6631. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6632. {
  6633. // WIP
  6634. return 0;
  6635. }
  6636. /*===================================
  6637. * Remove some messages
  6638. *-----------------------------------*/
  6639. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6640. {
  6641. if (sd->state.showexp) {
  6642. sd->state.showexp = 0;
  6643. clif_displaymessage(fd, "Gained exp will not be shown.");
  6644. return 0;
  6645. }
  6646. sd->state.showexp = 1;
  6647. clif_displaymessage(fd, "Gained exp is now shown");
  6648. return 0;
  6649. }
  6650. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6651. {
  6652. if (sd->state.showzeny) {
  6653. sd->state.showzeny = 0;
  6654. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6655. return 0;
  6656. }
  6657. sd->state.showzeny = 1;
  6658. clif_displaymessage(fd, "Gained zeny is now shown");
  6659. return 0;
  6660. }
  6661. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6662. {
  6663. if (sd->state.showdelay) {
  6664. sd->state.showdelay = 0;
  6665. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6666. return 0;
  6667. }
  6668. sd->state.showdelay = 1;
  6669. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6670. return 0;
  6671. }
  6672. /*==========================================
  6673. * Duel organizing functions [LuzZza]
  6674. *
  6675. * @duel [limit|nick] - create a duel
  6676. * @invite <nick> - invite player
  6677. * @accept - accept invitation
  6678. * @reject - reject invitation
  6679. * @leave - leave duel
  6680. *------------------------------------------*/
  6681. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6682. {
  6683. unsigned int did = sd->duel_group;
  6684. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6685. if(did <= 0) {
  6686. // "Duel: @invite without @duel."
  6687. clif_displaymessage(fd, msg_txt(350));
  6688. return 0;
  6689. }
  6690. if(duel_list[did].max_players_limit > 0 &&
  6691. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6692. // "Duel: Limit of players is reached."
  6693. clif_displaymessage(fd, msg_txt(351));
  6694. return 0;
  6695. }
  6696. if(target_sd == NULL) {
  6697. // "Duel: Player not found."
  6698. clif_displaymessage(fd, msg_txt(352));
  6699. return 0;
  6700. }
  6701. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6702. // "Duel: Player already in duel."
  6703. clif_displaymessage(fd, msg_txt(353));
  6704. return 0;
  6705. }
  6706. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6707. {
  6708. sprintf(atcmd_output, msg_txt(364), message);
  6709. clif_displaymessage(fd, atcmd_output);
  6710. return 0;
  6711. }
  6712. duel_invite(did, sd, target_sd);
  6713. // "Duel: Invitation has been sent."
  6714. clif_displaymessage(fd, msg_txt(354));
  6715. return 0;
  6716. }
  6717. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6718. {
  6719. char output[256];
  6720. unsigned int maxpl=0, newduel;
  6721. struct map_session_data *target_sd;
  6722. if(sd->duel_group > 0) {
  6723. duel_showinfo(sd->duel_group, sd);
  6724. return 0;
  6725. }
  6726. if(sd->duel_invite > 0) {
  6727. // "Duel: @duel without @reject."
  6728. clif_displaymessage(fd, msg_txt(355));
  6729. return 0;
  6730. }
  6731. if(!duel_checktime(sd)) {
  6732. // "Duel: You can take part in duel only one time per %d minutes."
  6733. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6734. clif_displaymessage(fd, output);
  6735. return 0;
  6736. }
  6737. if(strlen(message) > 0) {
  6738. if(sscanf(message, "%d", &maxpl) >= 1) {
  6739. if(maxpl < 2 || maxpl > 65535) {
  6740. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6741. return 0;
  6742. }
  6743. duel_create(sd, maxpl);
  6744. } else {
  6745. target_sd = map_nick2sd((char *)message);
  6746. if(target_sd != NULL) {
  6747. if((newduel = duel_create(sd, 2)) != -1) {
  6748. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6749. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6750. return 0;
  6751. }
  6752. duel_invite(newduel, sd, target_sd);
  6753. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6754. }
  6755. } else {
  6756. // "Duel: Player not found."
  6757. clif_displaymessage(fd, msg_txt(352));
  6758. return 0;
  6759. }
  6760. }
  6761. } else
  6762. duel_create(sd, 0);
  6763. return 0;
  6764. }
  6765. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6766. {
  6767. if(sd->duel_group <= 0) {
  6768. // "Duel: @leave without @duel."
  6769. clif_displaymessage(fd, msg_txt(358));
  6770. return 0;
  6771. }
  6772. duel_leave(sd->duel_group, sd);
  6773. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6774. return 0;
  6775. }
  6776. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6777. {
  6778. char output[256];
  6779. if(!duel_checktime(sd)) {
  6780. // "Duel: You can take part in duel only one time per %d minutes."
  6781. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6782. clif_displaymessage(fd, output);
  6783. return 0;
  6784. }
  6785. if(sd->duel_invite <= 0) {
  6786. // "Duel: @accept without invititation."
  6787. clif_displaymessage(fd, msg_txt(360));
  6788. return 0;
  6789. }
  6790. duel_accept(sd->duel_invite, sd);
  6791. // "Duel: Invitation has been accepted."
  6792. clif_displaymessage(fd, msg_txt(361));
  6793. return 0;
  6794. }
  6795. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6796. {
  6797. if(sd->duel_invite <= 0) {
  6798. // "Duel: @reject without invititation."
  6799. clif_displaymessage(fd, msg_txt(362));
  6800. return 0;
  6801. }
  6802. duel_reject(sd->duel_invite, sd);
  6803. // "Duel: Invitation has been rejected."
  6804. clif_displaymessage(fd, msg_txt(363));
  6805. return 0;
  6806. }
  6807. /*===================================
  6808. * Cash Points
  6809. *-----------------------------------*/
  6810. int atcommand_cash(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6811. {
  6812. int value;
  6813. nullpo_retr(-1, sd);
  6814. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6815. clif_displaymessage(fd, "Please, enter an amount.");
  6816. return -1;
  6817. }
  6818. if( !strcmpi(command+1,"cash") )
  6819. {
  6820. if( value > 0 )
  6821. pc_getcash(sd, value, 0);
  6822. else
  6823. pc_paycash(sd, -value, 0);
  6824. }
  6825. else
  6826. { // @points
  6827. if( value > 0 )
  6828. pc_getcash(sd, 0, value);
  6829. else
  6830. pc_paycash(sd, -value, -value);
  6831. }
  6832. return 0;
  6833. }
  6834. /*===================================
  6835. * Away message (@away, @aw) [LuzZza]
  6836. *-----------------------------------*/
  6837. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6838. {
  6839. if(strlen(message) > 0) {
  6840. if(strlen(message) > 128)
  6841. return -1;
  6842. strcpy(sd->away_message, message);
  6843. //"Away automessage has been activated."
  6844. clif_displaymessage(fd, msg_txt(546));
  6845. } else {
  6846. if(strlen(sd->away_message) > 0) {
  6847. sd->away_message[0] = 0;
  6848. //"Away automessage has been disabled."
  6849. clif_displaymessage(fd, msg_txt(547));
  6850. return 0;
  6851. }
  6852. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  6853. clif_displaymessage(fd, msg_txt(548));
  6854. }
  6855. return 0;
  6856. }
  6857. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6858. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6859. {
  6860. int x=0,y=0,flag=0,master=0,i=0;
  6861. struct map_session_data *pl_sd=NULL;
  6862. if (!message || !*message) {
  6863. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6864. return 0;
  6865. }
  6866. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6867. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6868. return 0;
  6869. }
  6870. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  6871. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6872. return 0;
  6873. }
  6874. if (strcmpi(command+1, "clone") == 0)
  6875. flag = 1;
  6876. else if (strcmpi(command+1, "slaveclone") == 0) {
  6877. flag = 2;
  6878. master = sd->bl.id;
  6879. if (battle_config.atc_slave_clone_limit
  6880. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6881. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6882. return 0;
  6883. }
  6884. }
  6885. do {
  6886. x = sd->bl.x + (rand() % 10 - 5);
  6887. y = sd->bl.y + (rand() % 10 - 5);
  6888. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6889. if (i >= 10) {
  6890. x = sd->bl.x;
  6891. y = sd->bl.y;
  6892. }
  6893. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6894. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6895. return 0;
  6896. }
  6897. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6898. return 0;
  6899. }
  6900. /*===================================
  6901. * Main chat [LuzZza]
  6902. * Usage: @main <on|off|message>
  6903. *-----------------------------------*/
  6904. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6905. {
  6906. if(strlen(message) > 0) {
  6907. if(strcmpi(message, "on") == 0) {
  6908. if(!sd->state.mainchat) {
  6909. sd->state.mainchat = 1;
  6910. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6911. } else {
  6912. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6913. }
  6914. } else if(strcmpi(message, "off") == 0) {
  6915. if(sd->state.mainchat) {
  6916. sd->state.mainchat = 0;
  6917. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6918. } else {
  6919. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6920. }
  6921. } else {
  6922. if(!sd->state.mainchat) {
  6923. sd->state.mainchat = 1;
  6924. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6925. }
  6926. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6927. clif_displaymessage(fd, msg_txt(387));
  6928. return -1;
  6929. }
  6930. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  6931. // I use 0xFE000000 color for signalizing that this message is
  6932. // main chat message. 0xFE000000 is invalid color, same using
  6933. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  6934. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  6935. // Chat logging type 'M' / Main Chat
  6936. if( log_config.chat&1 || (log_config.chat&32 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
  6937. log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  6938. }
  6939. } else {
  6940. if(sd->state.mainchat)
  6941. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6942. else
  6943. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6944. }
  6945. return 0;
  6946. }
  6947. /*=====================================
  6948. * Autorejecting Invites/Deals [LuzZza]
  6949. * Usage: @noask
  6950. *-------------------------------------*/
  6951. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6952. {
  6953. if(sd->state.noask) {
  6954. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6955. sd->state.noask = 0;
  6956. } else {
  6957. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6958. sd->state.noask = 1;
  6959. }
  6960. return 0;
  6961. }
  6962. /*=====================================
  6963. * Send a @request message to all GMs of lowest_gm_level.
  6964. * Usage: @request <petition>
  6965. *-------------------------------------*/
  6966. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6967. {
  6968. if (!message || !*message) {
  6969. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6970. return -1;
  6971. }
  6972. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6973. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  6974. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6975. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6976. return 0;
  6977. }
  6978. /*==========================================
  6979. * Feel (SG save map) Reset [HiddenDragon]
  6980. *------------------------------------------*/
  6981. int atcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6982. {
  6983. pc_resetfeel(sd);
  6984. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  6985. return 0;
  6986. }
  6987. /*==========================================
  6988. * AUCTION SYSTEM
  6989. *------------------------------------------*/
  6990. int atcommand_auction(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6991. {
  6992. nullpo_retr(0,sd);
  6993. #ifndef TXT_ONLY
  6994. clif_Auction_openwindow(sd);
  6995. #endif
  6996. return 0;
  6997. }
  6998. /*==========================================
  6999. * Kill Steal Protection
  7000. *------------------------------------------*/
  7001. int atcommand_ksprotection(const int fd, struct map_session_data *sd, const char *command, const char *message)
  7002. {
  7003. nullpo_retr(-1,sd);
  7004. if( sd->state.noks ) {
  7005. sd->state.noks = 0;
  7006. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  7007. }
  7008. else
  7009. {
  7010. if( !message || !*message || !strcmpi(message, "party") )
  7011. { // Default is Party
  7012. sd->state.noks = 2;
  7013. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7014. }
  7015. else if( !strcmpi(message, "self") )
  7016. {
  7017. sd->state.noks = 1;
  7018. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7019. }
  7020. else if( !strcmpi(message, "guild") )
  7021. {
  7022. sd->state.noks = 3;
  7023. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7024. }
  7025. else
  7026. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  7027. }
  7028. clif_displaymessage(fd, atcmd_output);
  7029. return 0;
  7030. }
  7031. /*==========================================
  7032. * Map Kill Steal Protection Setting
  7033. *------------------------------------------*/
  7034. int atcommand_allowks(const int fd, struct map_session_data *sd, const char *command, const char *message)
  7035. {
  7036. nullpo_retr(-1,sd);
  7037. if( map[sd->bl.m].flag.allowks ) {
  7038. map[sd->bl.m].flag.allowks = 0;
  7039. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7040. } else {
  7041. map[sd->bl.m].flag.allowks = 1;
  7042. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7043. }
  7044. clif_displaymessage(fd, atcmd_output);
  7045. return 0;
  7046. }
  7047. /*==========================================
  7048. * atcommand_info[] structure definition
  7049. *------------------------------------------*/
  7050. AtCommandInfo atcommand_info[] = {
  7051. { "rura", 40, atcommand_mapmove },
  7052. { "warp", 40, atcommand_mapmove },
  7053. { "mapmove", 40, atcommand_mapmove }, // + /mm
  7054. { "where", 1, atcommand_where },
  7055. { "jumpto", 20, atcommand_jumpto }, // + /shift
  7056. { "warpto", 20, atcommand_jumpto },
  7057. { "goto", 20, atcommand_jumpto },
  7058. { "jump", 40, atcommand_jump },
  7059. { "who", 20, atcommand_who },
  7060. { "whois", 20, atcommand_who },
  7061. { "who2", 20, atcommand_who2 },
  7062. { "who3", 20, atcommand_who3 },
  7063. { "whomap", 20, atcommand_whomap },
  7064. { "whomap2", 20, atcommand_whomap2 },
  7065. { "whomap3", 20, atcommand_whomap3 },
  7066. { "whogm", 20, atcommand_whogm },
  7067. { "save", 40, atcommand_save },
  7068. { "return", 40, atcommand_load },
  7069. { "load", 40, atcommand_load },
  7070. { "speed", 40, atcommand_speed },
  7071. { "storage", 1, atcommand_storage },
  7072. { "gstorage", 50, atcommand_guildstorage },
  7073. { "option", 40, atcommand_option },
  7074. { "hide", 40, atcommand_hide }, // + /hide
  7075. { "jobchange", 40, atcommand_jobchange },
  7076. { "job", 40, atcommand_jobchange },
  7077. { "die", 1, atcommand_die },
  7078. { "kill", 60, atcommand_kill },
  7079. { "alive", 60, atcommand_alive },
  7080. { "kami", 40, atcommand_kami },
  7081. { "kamib", 40, atcommand_kami },
  7082. { "kamic", 40, atcommand_kami },
  7083. { "heal", 40, atcommand_heal },
  7084. { "item", 60, atcommand_item },
  7085. { "item2", 60, atcommand_item2 },
  7086. { "itemreset", 40, atcommand_itemreset },
  7087. { "blvl", 60, atcommand_baselevelup },
  7088. { "lvup", 60, atcommand_baselevelup },
  7089. { "blevel", 60, atcommand_baselevelup },
  7090. { "baselvl", 60, atcommand_baselevelup },
  7091. { "baselvup", 60, atcommand_baselevelup },
  7092. { "baselevel", 60, atcommand_baselevelup },
  7093. { "baselvlup", 60, atcommand_baselevelup },
  7094. { "jlvl", 60, atcommand_joblevelup },
  7095. { "jlevel", 60, atcommand_joblevelup },
  7096. { "joblvl", 60, atcommand_joblevelup },
  7097. { "joblevel", 60, atcommand_joblevelup },
  7098. { "joblvup", 60, atcommand_joblevelup },
  7099. { "joblvlup", 60, atcommand_joblevelup },
  7100. { "h", 20, atcommand_help },
  7101. { "help", 20, atcommand_help },
  7102. { "h2", 20, atcommand_help2 },
  7103. { "help2", 20, atcommand_help2 },
  7104. { "pvpoff", 40, atcommand_pvpoff },
  7105. { "pvpon", 40, atcommand_pvpon },
  7106. { "gvgoff", 40, atcommand_gvgoff },
  7107. { "gpvpoff", 40, atcommand_gvgoff },
  7108. { "gvgon", 40, atcommand_gvgon },
  7109. { "gpvpon", 40, atcommand_gvgon },
  7110. { "model", 20, atcommand_model },
  7111. { "go", 10, atcommand_go },
  7112. { "monster", 50, atcommand_monster },
  7113. { "spawn", 50, atcommand_monster },
  7114. { "monstersmall", 50, atcommand_monstersmall },
  7115. { "monsterbig", 50, atcommand_monsterbig },
  7116. { "killmonster", 60, atcommand_killmonster },
  7117. { "killmonster2", 40, atcommand_killmonster2 },
  7118. { "refine", 60, atcommand_refine },
  7119. { "produce", 60, atcommand_produce },
  7120. { "memo", 40, atcommand_memo },
  7121. { "gat", 99, atcommand_gat },
  7122. { "displaystatus", 99, atcommand_displaystatus },
  7123. { "stpoint", 60, atcommand_statuspoint },
  7124. { "skpoint", 60, atcommand_skillpoint },
  7125. { "zeny", 60, atcommand_zeny },
  7126. { "str", 60, atcommand_param },
  7127. { "agi", 60, atcommand_param },
  7128. { "vit", 60, atcommand_param },
  7129. { "int", 60, atcommand_param },
  7130. { "dex", 60, atcommand_param },
  7131. { "luk", 60, atcommand_param },
  7132. { "glvl", 60, atcommand_guildlevelup },
  7133. { "glevel", 60, atcommand_guildlevelup },
  7134. { "guildlvl", 60, atcommand_guildlevelup },
  7135. { "guildlvup", 60, atcommand_guildlevelup },
  7136. { "guildlevel", 60, atcommand_guildlevelup },
  7137. { "guildlvlup", 60, atcommand_guildlevelup },
  7138. { "makeegg", 60, atcommand_makeegg },
  7139. { "hatch", 60, atcommand_hatch },
  7140. { "petfriendly", 40, atcommand_petfriendly },
  7141. { "pethungry", 40, atcommand_pethungry },
  7142. { "petrename", 1, atcommand_petrename },
  7143. { "recall", 60, atcommand_recall }, // + /recall
  7144. { "night", 80, atcommand_night },
  7145. { "day", 80, atcommand_day },
  7146. { "doom", 80, atcommand_doom },
  7147. { "doommap", 80, atcommand_doommap },
  7148. { "raise", 80, atcommand_raise },
  7149. { "raisemap", 80, atcommand_raisemap },
  7150. { "kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7151. { "kickall", 99, atcommand_kickall },
  7152. { "allskill", 60, atcommand_allskill },
  7153. { "allskills", 60, atcommand_allskill },
  7154. { "skillall", 60, atcommand_allskill },
  7155. { "skillsall", 60, atcommand_allskill },
  7156. { "questskill", 40, atcommand_questskill },
  7157. { "lostskill", 40, atcommand_lostskill },
  7158. { "spiritball", 40, atcommand_spiritball },
  7159. { "party", 1, atcommand_party },
  7160. { "guild", 50, atcommand_guild },
  7161. { "agitstart", 60, atcommand_agitstart },
  7162. { "agitend", 60, atcommand_agitend },
  7163. { "mapexit", 99, atcommand_mapexit },
  7164. { "idsearch", 60, atcommand_idsearch },
  7165. { "broadcast", 40, atcommand_broadcast }, // + /b and /nb
  7166. { "localbroadcast", 40, atcommand_localbroadcast }, // + /lb and /nlb
  7167. { "recallall", 80, atcommand_recallall },
  7168. { "reloaditemdb", 99, atcommand_reloaditemdb },
  7169. { "reloadmobdb", 99, atcommand_reloadmobdb },
  7170. { "reloadskilldb", 99, atcommand_reloadskilldb },
  7171. { "reloadscript", 99, atcommand_reloadscript },
  7172. { "reloadatcommand", 99, atcommand_reloadatcommand },
  7173. { "reloadbattleconf", 99, atcommand_reloadbattleconf },
  7174. { "reloadstatusdb", 99, atcommand_reloadstatusdb },
  7175. { "reloadpcdb", 99, atcommand_reloadpcdb },
  7176. { "reloadmotd", 99, atcommand_reloadmotd },
  7177. { "mapinfo", 99, atcommand_mapinfo },
  7178. { "dye", 40, atcommand_dye },
  7179. { "ccolor", 40, atcommand_dye },
  7180. { "hairstyle", 40, atcommand_hair_style },
  7181. { "hstyle", 40, atcommand_hair_style },
  7182. { "haircolor", 40, atcommand_hair_color },
  7183. { "hcolor", 40, atcommand_hair_color },
  7184. { "statall", 60, atcommand_stat_all },
  7185. { "statsall", 60, atcommand_stat_all },
  7186. { "allstats", 60, atcommand_stat_all },
  7187. { "allstat", 60, atcommand_stat_all },
  7188. { "block", 60, atcommand_char_block },
  7189. { "charblock", 60, atcommand_char_block },
  7190. { "ban", 60, atcommand_char_ban },
  7191. { "banish", 60, atcommand_char_ban },
  7192. { "charban", 60, atcommand_char_ban },
  7193. { "charbanish", 60, atcommand_char_ban },
  7194. { "unblock", 60, atcommand_char_unblock },
  7195. { "charunblock", 60, atcommand_char_unblock },
  7196. { "unban", 60, atcommand_char_unban },
  7197. { "unbanish", 60, atcommand_char_unban },
  7198. { "charunban", 60, atcommand_char_unban },
  7199. { "charunbanish", 60, atcommand_char_unban },
  7200. { "mount", 20, atcommand_mount_peco },
  7201. { "mountpeco", 20, atcommand_mount_peco },
  7202. { "guildspy", 60, atcommand_guildspy },
  7203. { "partyspy", 60, atcommand_partyspy },
  7204. { "repairall", 60, atcommand_repairall },
  7205. { "guildrecall", 60, atcommand_guildrecall },
  7206. { "partyrecall", 60, atcommand_partyrecall },
  7207. { "nuke", 60, atcommand_nuke },
  7208. { "shownpc", 80, atcommand_shownpc },
  7209. { "hidenpc", 80, atcommand_hidenpc },
  7210. { "loadnpc", 80, atcommand_loadnpc },
  7211. { "unloadnpc", 80, atcommand_unloadnpc },
  7212. { "time", 1, atcommand_servertime },
  7213. { "date", 1, atcommand_servertime },
  7214. { "serverdate", 1, atcommand_servertime },
  7215. { "servertime", 1, atcommand_servertime },
  7216. { "jail", 60, atcommand_jail },
  7217. { "unjail", 60, atcommand_unjail },
  7218. { "discharge", 60, atcommand_unjail },
  7219. { "jailfor", 60, atcommand_jailfor },
  7220. { "jailtime", 1, atcommand_jailtime },
  7221. { "disguise", 20, atcommand_disguise },
  7222. { "undisguise", 20, atcommand_undisguise },
  7223. { "email", 1, atcommand_email },
  7224. { "effect", 40, atcommand_effect },
  7225. { "follow", 20, atcommand_follow },
  7226. { "addwarp", 60, atcommand_addwarp },
  7227. { "skillon", 80, atcommand_skillon },
  7228. { "skilloff", 80, atcommand_skilloff },
  7229. { "killer", 60, atcommand_killer },
  7230. { "npcmove", 80, atcommand_npcmove },
  7231. { "killable", 40, atcommand_killable },
  7232. { "dropall", 40, atcommand_dropall },
  7233. { "storeall", 40, atcommand_storeall },
  7234. { "skillid", 40, atcommand_skillid },
  7235. { "useskill", 40, atcommand_useskill },
  7236. { "displayskill", 99, atcommand_displayskill },
  7237. { "snow", 99, atcommand_snow },
  7238. { "sakura", 99, atcommand_sakura },
  7239. { "clouds", 99, atcommand_clouds },
  7240. { "clouds2", 99, atcommand_clouds2 },
  7241. { "fog", 99, atcommand_fog },
  7242. { "fireworks", 99, atcommand_fireworks },
  7243. { "leaves", 99, atcommand_leaves },
  7244. { "summon", 60, atcommand_summon },
  7245. { "adjgmlvl", 99, atcommand_adjgmlvl },
  7246. { "adjcmdlvl", 99, atcommand_adjcmdlvl },
  7247. { "trade", 60, atcommand_trade },
  7248. { "send", 99, atcommand_send },
  7249. { "setbattleflag", 99, atcommand_setbattleflag },
  7250. { "unmute", 80, atcommand_unmute },
  7251. { "clearweather", 99, atcommand_clearweather },
  7252. { "uptime", 1, atcommand_uptime },
  7253. { "changesex", 60, atcommand_changesex },
  7254. { "mute", 80, atcommand_mute },
  7255. { "refresh", 1, atcommand_refresh },
  7256. { "identify", 40, atcommand_identify },
  7257. { "gmotd", 20, atcommand_gmotd },
  7258. { "misceffect", 50, atcommand_misceffect },
  7259. { "mobsearch", 10, atcommand_mobsearch },
  7260. { "cleanmap", 40, atcommand_cleanmap },
  7261. { "npctalk", 20, atcommand_npctalk },
  7262. { "pettalk", 10, atcommand_pettalk },
  7263. { "users", 40, atcommand_users },
  7264. { "reset", 40, atcommand_reset },
  7265. { "skilltree", 40, atcommand_skilltree },
  7266. { "marry", 40, atcommand_marry },
  7267. { "divorce", 40, atcommand_divorce },
  7268. { "sound", 40, atcommand_sound },
  7269. { "undisguiseall", 99, atcommand_undisguiseall },
  7270. { "disguiseall", 99, atcommand_disguiseall },
  7271. { "changelook", 60, atcommand_changelook },
  7272. { "autoloot", 10, atcommand_autoloot },
  7273. { "alootid", 10, atcommand_autolootitem },
  7274. { "mobinfo", 1, atcommand_mobinfo },
  7275. { "monsterinfo", 1, atcommand_mobinfo },
  7276. { "mi", 1, atcommand_mobinfo },
  7277. { "exp", 1, atcommand_exp },
  7278. { "adopt", 40, atcommand_adopt },
  7279. { "version", 1, atcommand_version },
  7280. { "mutearea", 99, atcommand_mutearea },
  7281. { "stfu", 99, atcommand_mutearea },
  7282. { "rates", 1, atcommand_rates },
  7283. { "iteminfo", 1, atcommand_iteminfo },
  7284. { "ii", 1, atcommand_iteminfo },
  7285. { "whodrops", 1, atcommand_whodrops },
  7286. { "whereis", 10, atcommand_whereis },
  7287. { "mapflag", 99, atcommand_mapflag },
  7288. { "me", 20, atcommand_me },
  7289. { "monsterignore", 99, atcommand_monsterignore },
  7290. { "battleignore", 99, atcommand_monsterignore },
  7291. { "fakename", 20, atcommand_fakename },
  7292. { "size", 20, atcommand_size },
  7293. { "showexp", 10, atcommand_showexp},
  7294. { "showzeny", 10, atcommand_showzeny},
  7295. { "showdelay", 1, atcommand_showdelay},
  7296. { "autotrade", 10, atcommand_autotrade },
  7297. { "at", 10, atcommand_autotrade },
  7298. { "changegm", 10, atcommand_changegm },
  7299. { "changeleader", 10, atcommand_changeleader },
  7300. { "partyoption", 10, atcommand_partyoption},
  7301. { "invite", 1, atcommand_invite },
  7302. { "duel", 1, atcommand_duel },
  7303. { "leave", 1, atcommand_leave },
  7304. { "accept", 1, atcommand_accept },
  7305. { "reject", 1, atcommand_reject },
  7306. { "away", 1, atcommand_away },
  7307. { "aw", 1, atcommand_away },
  7308. { "main", 1, atcommand_main },
  7309. { "clone", 50, atcommand_clone },
  7310. { "slaveclone", 50, atcommand_clone },
  7311. { "evilclone", 50, atcommand_clone },
  7312. { "tonpc", 40, atcommand_tonpc },
  7313. { "commands", 1, atcommand_commands },
  7314. { "noask", 1, atcommand_noask },
  7315. { "request", 20, atcommand_request },
  7316. { "hlvl", 60, atcommand_homlevel },
  7317. { "hlevel", 60, atcommand_homlevel },
  7318. { "homlvl", 60, atcommand_homlevel },
  7319. { "homlvup", 60, atcommand_homlevel },
  7320. { "homlevel", 60, atcommand_homlevel },
  7321. { "homevolve", 60, atcommand_homevolution },
  7322. { "homevolution", 60, atcommand_homevolution },
  7323. { "makehomun", 60, atcommand_makehomun },
  7324. { "homfriendly", 60, atcommand_homfriendly },
  7325. { "homhungry", 60, atcommand_homhungry },
  7326. { "homtalk", 10, atcommand_homtalk },
  7327. { "hominfo", 1, atcommand_hominfo },
  7328. { "homstats", 1, atcommand_homstats },
  7329. { "homshuffle", 60, atcommand_homshuffle },
  7330. { "showmobs", 10, atcommand_showmobs },
  7331. { "feelreset", 10, atcommand_feelreset },
  7332. { "auction", 60, atcommand_auction },
  7333. { "mail", 1, atcommand_mail },
  7334. { "noks", 0, atcommand_ksprotection },
  7335. { "allowks", 6, atcommand_allowks },
  7336. { "cash", 60, atcommand_cash },
  7337. { "points", 60, atcommand_cash },
  7338. { "agitstart2", 60, atcommand_agitstart2 },
  7339. { "agitend2", 60, atcommand_agitend2 },
  7340. };
  7341. /*==========================================
  7342. * Command lookup functions
  7343. *------------------------------------------*/
  7344. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  7345. {
  7346. int i;
  7347. if( *name == atcommand_symbol ) name++; // for backwards compatibility
  7348. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  7349. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7350. }
  7351. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  7352. {
  7353. int i;
  7354. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  7355. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7356. }
  7357. /*==========================================
  7358. * Retrieve the command's required gm level
  7359. *------------------------------------------*/
  7360. int get_atcommand_level(const AtCommandFunc func)
  7361. {
  7362. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  7363. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7364. }
  7365. /// Executes an at-command.
  7366. /// To be called by internal server code (bypasses various restrictions).
  7367. bool is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  7368. {
  7369. AtCommandInfo* info;
  7370. char command[100];
  7371. char args[100];
  7372. char output[200];
  7373. if( !str || !*str )
  7374. return false;
  7375. if( *str != atcommand_symbol ) // check first char
  7376. return false;
  7377. if( sscanf(str, "%99s %99[^\n]", command, args) < 2 )
  7378. args[0] = '\0';
  7379. info = get_atcommandinfo_byname(command);
  7380. if( info == NULL || info->func == NULL || gmlvl < info->level )
  7381. {
  7382. if( gmlvl == 0 )
  7383. return false; // will just display as normal text
  7384. else
  7385. {
  7386. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7387. clif_displaymessage(fd, output);
  7388. return true;
  7389. }
  7390. }
  7391. if( log_config.gm && info->level >= log_config.gm )
  7392. log_atcommand(sd, str);
  7393. if( info->func(fd, sd, command, args) != 0 )
  7394. {
  7395. sprintf(output, msg_txt(154), command); // "%s failed."
  7396. clif_displaymessage(fd, output);
  7397. }
  7398. return true;
  7399. }
  7400. /// Executes an at-command.
  7401. /// To be used by player-invoked code (restrictions will be applied).
  7402. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  7403. {
  7404. int gmlvl = pc_isGM(sd);
  7405. nullpo_retr(false, sd);
  7406. if( !message || !*message )
  7407. return false; // shouldn't happen
  7408. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7409. return true; // so that it won't display as normal message
  7410. if( battle_config.atc_gmonly != 0 && gmlvl == 0 )
  7411. return false;
  7412. if( map[sd->bl.m].nocommand && gmlvl < map[sd->bl.m].nocommand )
  7413. {
  7414. clif_displaymessage(fd, msg_txt(143)); // "Commands are disabled on this map."
  7415. return false;
  7416. }
  7417. // skip 10/11-langtype's codepage indicator, if detected
  7418. if( message[0] == '|' && strlen(message) >= 4 && message[3] == atcommand_symbol )
  7419. message += 3;
  7420. return is_atcommand_sub(fd,sd,message,gmlvl);
  7421. }
  7422. /*==========================================
  7423. *
  7424. *------------------------------------------*/
  7425. int atcommand_config_read(const char* cfgName)
  7426. {
  7427. char line[1024], w1[1024], w2[1024];
  7428. AtCommandInfo* p;
  7429. FILE* fp;
  7430. if( (fp = fopen(cfgName, "r")) == NULL )
  7431. {
  7432. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  7433. return 1;
  7434. }
  7435. while( fgets(line, sizeof(line), fp) )
  7436. {
  7437. if( line[0] == '/' && line[1] == '/' )
  7438. continue;
  7439. if( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2 )
  7440. continue;
  7441. p = get_atcommandinfo_byname(w1);
  7442. if( p != NULL )
  7443. {
  7444. p->level = atoi(w2);
  7445. p->level = cap_value(p->level, 0, 100);
  7446. }
  7447. else
  7448. if( strcmpi(w1, "import") == 0 )
  7449. atcommand_config_read(w2);
  7450. else
  7451. if( strcmpi(w1, "command_symbol") == 0 &&
  7452. w2[0] > 31 && // control characters
  7453. w2[0] != '/' && // symbol of standard ragnarok GM commands
  7454. w2[0] != '%' && // symbol of party chat speaking
  7455. w2[0] != '$' && // symbol of guild chat speaking
  7456. w2[0] != '#' ) // symbol of charcommand
  7457. atcommand_symbol = w2[0];
  7458. else
  7459. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  7460. }
  7461. fclose(fp);
  7462. return 0;
  7463. }
  7464. void do_init_atcommand()
  7465. {
  7466. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  7467. return;
  7468. }
  7469. void do_final_atcommand()
  7470. {
  7471. }
  7472. // commands that need to go _after_ the commands table
  7473. /*==========================================
  7474. * @commands Lists available @ commands to you
  7475. *------------------------------------------*/
  7476. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7477. {
  7478. char line_buff[CHATBOX_SIZE];
  7479. int i, gm_lvl = pc_isGM(sd), count = 0;
  7480. char* cur = line_buff;
  7481. memset(line_buff,' ',CHATBOX_SIZE);
  7482. line_buff[CHATBOX_SIZE-1] = 0;
  7483. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7484. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  7485. {
  7486. unsigned int slen;
  7487. if( gm_lvl < atcommand_info[i].level )
  7488. continue;
  7489. slen = (unsigned int)strlen(atcommand_info[i].command);
  7490. // flush the text buffer if this command won't fit into it
  7491. if( ((CHATBOX_SIZE-1+(int)line_buff)-(int)cur) < (int)slen )
  7492. {
  7493. clif_displaymessage(fd,line_buff);
  7494. cur = line_buff;
  7495. memset(line_buff,' ',CHATBOX_SIZE);
  7496. line_buff[CHATBOX_SIZE-1] = 0;
  7497. }
  7498. memcpy(cur,atcommand_info[i].command,slen);
  7499. cur += slen+(10-slen%10);
  7500. count++;
  7501. }
  7502. clif_displaymessage(fd,line_buff);
  7503. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7504. clif_displaymessage(fd, atcmd_output);
  7505. return 0;
  7506. }