atcommand.c 268 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619
  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 "clif.h"
  16. #include "chrif.h"
  17. #include "intif.h"
  18. #include "itemdb.h"
  19. #include "log.h"
  20. #include "map.h"
  21. #include "pc.h"
  22. #include "status.h"
  23. #include "skill.h"
  24. #include "mob.h"
  25. #include "npc.h"
  26. #include "pet.h"
  27. #include "mercenary.h"
  28. #include "party.h"
  29. #include "guild.h"
  30. #include "script.h"
  31. #include "trade.h"
  32. #include "unit.h"
  33. #ifndef TXT_ONLY
  34. #include "mail.h"
  35. #endif
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include <string.h>
  39. #include <math.h>
  40. // extern variables
  41. char atcommand_symbol = '@'; // first char of the commands
  42. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  43. // local declarations
  44. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  45. typedef struct AtCommandInfo
  46. {
  47. const char* command;
  48. int level;
  49. AtCommandFunc func;
  50. } AtCommandInfo;
  51. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  52. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  53. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message);
  54. /*=========================================
  55. * Generic variables
  56. *-----------------------------------------*/
  57. char atcmd_output[200];
  58. char atcmd_player_name[NAME_LENGTH];
  59. char atcmd_temp[100];
  60. // compare function for sorting high to lowest
  61. int hightolow_compare (const void * a, const void * b)
  62. {
  63. return ( *(int*)b - *(int*)a );
  64. }
  65. // compare function for sorting lowest to highest
  66. int lowtohigh_compare (const void * a, const void * b)
  67. {
  68. return ( *(int*)a - *(int*)b );
  69. }
  70. //-----------------------------------------------------------
  71. // Return the message string of the specified number by [Yor]
  72. //-----------------------------------------------------------
  73. char* msg_txt(int msg_number)
  74. {
  75. if (msg_number >= 0 && msg_number < MAX_MSG &&
  76. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  77. return msg_table[msg_number];
  78. return "??";
  79. }
  80. //-----------------------------------------------------------
  81. // Returns Players title (from msg_athena.conf) [Lupus]
  82. //-----------------------------------------------------------
  83. static char* player_title_txt(int level)
  84. {
  85. const char* format;
  86. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  87. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  88. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  89. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  90. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  91. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  92. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  93. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  94. : "";
  95. sprintf(atcmd_temp, format, level);
  96. return atcmd_temp;
  97. }
  98. /*==========================================
  99. * Read Message Data
  100. *------------------------------------------*/
  101. int msg_config_read(const char* cfgName)
  102. {
  103. int msg_number;
  104. char line[1024], w1[1024], w2[1024];
  105. FILE *fp;
  106. static int called = 1;
  107. if ((fp = fopen(cfgName, "r")) == NULL) {
  108. ShowError("Messages file not found: %s\n", cfgName);
  109. return 1;
  110. }
  111. if ((--called) == 0)
  112. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  113. while(fgets(line, sizeof(line), fp))
  114. {
  115. if (line[0] == '/' && line[1] == '/')
  116. continue;
  117. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  118. continue;
  119. if (strcmpi(w1, "import") == 0)
  120. msg_config_read(w2);
  121. else
  122. {
  123. msg_number = atoi(w1);
  124. if (msg_number >= 0 && msg_number < MAX_MSG)
  125. {
  126. if (msg_table[msg_number] != NULL)
  127. aFree(msg_table[msg_number]);
  128. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  129. strcpy(msg_table[msg_number],w2);
  130. }
  131. }
  132. }
  133. fclose(fp);
  134. return 0;
  135. }
  136. /*==========================================
  137. * Cleanup Message Data
  138. *------------------------------------------*/
  139. void do_final_msg(void)
  140. {
  141. int i;
  142. for (i = 0; i < MAX_MSG; i++)
  143. aFree(msg_table[i]);
  144. }
  145. /*==========================================
  146. * @send (used for testing packet sends from the client)
  147. *------------------------------------------*/
  148. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  149. {
  150. int len=0,off,end,type;
  151. long num;
  152. (void)command; // not used
  153. // read message type as hex number (without the 0x)
  154. if(!message || !*message ||
  155. !((sscanf(message, "len %x", &type)==1 && (len=1))
  156. || sscanf(message, "%x", &type)==1) )
  157. {
  158. clif_displaymessage(fd, "Usage:");
  159. clif_displaymessage(fd, " @send len <packet hex number>");
  160. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  161. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  162. return -1;
  163. }
  164. #define PARSE_ERROR(error,p) \
  165. {\
  166. clif_displaymessage(fd, (error));\
  167. sprintf(atcmd_output, ">%s", (p));\
  168. clif_displaymessage(fd, atcmd_output);\
  169. }
  170. //define PARSE_ERROR
  171. #define CHECK_EOS(p) \
  172. if(*(p) == 0){\
  173. clif_displaymessage(fd, "Unexpected end of string");\
  174. return -1;\
  175. }
  176. //define CHECK_EOS
  177. #define SKIP_VALUE(p) \
  178. {\
  179. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  180. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  181. }
  182. //define SKIP_VALUE
  183. #define GET_VALUE(p,num) \
  184. {\
  185. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  186. PARSE_ERROR("Invalid number in:",(p));\
  187. return -1;\
  188. }\
  189. }
  190. //define GET_VALUE
  191. if (type > 0 && type < MAX_PACKET_DB) {
  192. if(len)
  193. {// show packet length
  194. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  195. clif_displaymessage(fd, atcmd_output);
  196. return 0;
  197. }
  198. len=packet_db[sd->packet_ver][type].len;
  199. off=2;
  200. if(len == 0)
  201. {// unknown packet - ERROR
  202. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  203. clif_displaymessage(fd, atcmd_output);
  204. return -1;
  205. } else if(len == -1)
  206. {// dynamic packet
  207. len=SHRT_MAX-4; // maximum length
  208. off=4;
  209. }
  210. WFIFOHEAD(fd, len);
  211. WFIFOW(fd,0)=TOW(type);
  212. // parse packet contents
  213. SKIP_VALUE(message);
  214. while(*message != 0 && off < len){
  215. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  216. {// default (byte)
  217. GET_VALUE(message,num);
  218. WFIFOB(fd,off)=TOB(num);
  219. ++off;
  220. } else if(TOUPPER(*message) == 'B')
  221. {// byte
  222. ++message;
  223. GET_VALUE(message,num);
  224. WFIFOB(fd,off)=TOB(num);
  225. ++off;
  226. } else if(TOUPPER(*message) == 'W')
  227. {// word (2 bytes)
  228. ++message;
  229. GET_VALUE(message,num);
  230. WFIFOW(fd,off)=TOW(num);
  231. off+=2;
  232. } else if(TOUPPER(*message) == 'L')
  233. {// long word (4 bytes)
  234. ++message;
  235. GET_VALUE(message,num);
  236. WFIFOL(fd,off)=TOL(num);
  237. off+=4;
  238. } else if(TOUPPER(*message) == 'S')
  239. {// string - escapes are valid
  240. // get string length - num <= 0 means not fixed length (default)
  241. ++message;
  242. if(*message == '"'){
  243. num=0;
  244. } else {
  245. GET_VALUE(message,num);
  246. while(*message != '"')
  247. {// find start of string
  248. if(*message == 0 || ISSPACE(*message)){
  249. PARSE_ERROR("Not a string:",message);
  250. return -1;
  251. }
  252. ++message;
  253. }
  254. }
  255. // parse string
  256. ++message;
  257. CHECK_EOS(message);
  258. end=(num<=0? 0: min(off+((int)num),len));
  259. for(; *message != '"' && (off < end || end == 0); ++off){
  260. if(*message == '\\'){
  261. ++message;
  262. CHECK_EOS(message);
  263. switch(*message){
  264. case 'a': num=0x07; break; // Bell
  265. case 'b': num=0x08; break; // Backspace
  266. case 't': num=0x09; break; // Horizontal tab
  267. case 'n': num=0x0A; break; // Line feed
  268. case 'v': num=0x0B; break; // Vertical tab
  269. case 'f': num=0x0C; break; // Form feed
  270. case 'r': num=0x0D; break; // Carriage return
  271. case 'e': num=0x1B; break; // Escape
  272. default: num=*message; break;
  273. case 'x': // Hexadecimal
  274. {
  275. ++message;
  276. CHECK_EOS(message);
  277. if(!ISXDIGIT(*message)){
  278. PARSE_ERROR("Not a hexadecimal digit:",message);
  279. return -1;
  280. }
  281. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  282. if(ISXDIGIT(*message)){
  283. ++message;
  284. CHECK_EOS(message);
  285. num<<=8;
  286. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  287. }
  288. WFIFOB(fd,off)=TOB(num);
  289. ++message;
  290. CHECK_EOS(message);
  291. continue;
  292. }
  293. case '0':
  294. case '1':
  295. case '2':
  296. case '3':
  297. case '4':
  298. case '5':
  299. case '6':
  300. case '7': // Octal
  301. {
  302. num=*message-'0'; // 1st octal digit
  303. ++message;
  304. CHECK_EOS(message);
  305. if(ISDIGIT(*message) && *message < '8'){
  306. num<<=3;
  307. num+=*message-'0'; // 2nd octal digit
  308. ++message;
  309. CHECK_EOS(message);
  310. if(ISDIGIT(*message) && *message < '8'){
  311. num<<=3;
  312. num+=*message-'0'; // 3rd octal digit
  313. ++message;
  314. CHECK_EOS(message);
  315. }
  316. }
  317. WFIFOB(fd,off)=TOB(num);
  318. continue;
  319. }
  320. }
  321. } else
  322. num=*message;
  323. WFIFOB(fd,off)=TOB(num);
  324. ++message;
  325. CHECK_EOS(message);
  326. }//for
  327. while(*message != '"')
  328. {// ignore extra characters
  329. ++message;
  330. CHECK_EOS(message);
  331. }
  332. // terminate the string
  333. if(off < end)
  334. {// fill the rest with 0's
  335. memset(WFIFOP(fd,off),0,end-off);
  336. off=end;
  337. }
  338. } else
  339. {// unknown
  340. PARSE_ERROR("Unknown type of value in:",message);
  341. return -1;
  342. }
  343. SKIP_VALUE(message);
  344. }
  345. if(packet_db[sd->packet_ver][type].len == -1)
  346. {// send dynamic packet
  347. WFIFOW(fd,2)=TOW(off);
  348. WFIFOSET(fd,off);
  349. } else
  350. {// send static packet
  351. if(off < len)
  352. memset(WFIFOP(fd,off),0,len-off);
  353. WFIFOSET(fd,len);
  354. }
  355. } else {
  356. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  357. return -1;
  358. }
  359. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  360. clif_displaymessage(fd, atcmd_output);
  361. return 0;
  362. #undef PARSE_ERROR
  363. #undef CHECK_EOS
  364. #undef SKIP_VALUE
  365. #undef GET_VALUE
  366. }
  367. /*==========================================
  368. * @rura, @warp, @mapmove
  369. *------------------------------------------*/
  370. int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  371. {
  372. char map_name[MAP_NAME_LENGTH];
  373. unsigned short mapindex;
  374. int x = 0, y = 0;
  375. int m = -1;
  376. nullpo_retr(-1, sd);
  377. memset(map_name, '\0', sizeof(map_name));
  378. if (!message || !*message ||
  379. (sscanf(message, "%11s %d %d", map_name, &x, &y) < 3 &&
  380. sscanf(message, "%11[^,],%d,%d", map_name, &x, &y) < 1)) {
  381. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  382. return -1;
  383. }
  384. mapindex = mapindex_name2id(map_name);
  385. if (mapindex)
  386. m = map_mapindex2mapid(mapindex);
  387. if (!mapindex || m < 0) {
  388. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  389. return -1;
  390. }
  391. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  392. { //This is to prevent the pc_setpos call from printing an error.
  393. clif_displaymessage(fd, msg_txt(2));
  394. x = y = 0; //Invalid cell, use random spot.
  395. }
  396. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  397. clif_displaymessage(fd, msg_txt(247));
  398. return -1;
  399. }
  400. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  401. clif_displaymessage(fd, msg_txt(248));
  402. return -1;
  403. }
  404. if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
  405. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  406. return -1;
  407. }
  408. clif_displaymessage(fd, msg_txt(0)); // Warped.
  409. return 0;
  410. }
  411. /*==========================================
  412. * Displays where a character is. Corrected version by Silent. [Skotlex]
  413. *------------------------------------------*/
  414. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  415. {
  416. struct map_session_data* pl_sd;
  417. nullpo_retr(-1, sd);
  418. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  419. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  420. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  421. return -1;
  422. }
  423. pl_sd = map_nick2sd(atcmd_player_name);
  424. if( pl_sd == NULL
  425. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  426. || (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))
  427. ) {
  428. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  429. return -1;
  430. }
  431. 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);
  432. clif_displaymessage(fd, atcmd_output);
  433. return 0;
  434. }
  435. /*==========================================
  436. *
  437. *------------------------------------------*/
  438. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  439. {
  440. struct map_session_data *pl_sd = NULL;
  441. nullpo_retr(-1, sd);
  442. if (!message || !*message) {
  443. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  444. return -1;
  445. }
  446. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  447. {
  448. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  449. return -1;
  450. }
  451. if (pl_sd == sd)
  452. {
  453. clif_displaymessage(fd, "But you are already where you are...");
  454. return -1;
  455. }
  456. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  457. {
  458. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  459. return -1;
  460. }
  461. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  462. {
  463. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  464. return -1;
  465. }
  466. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  467. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  468. clif_displaymessage(fd, atcmd_output);
  469. return 0;
  470. }
  471. /*==========================================
  472. *
  473. *------------------------------------------*/
  474. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  475. {
  476. int x = 0, y = 0;
  477. nullpo_retr(-1, sd);
  478. memset(atcmd_output, '\0', sizeof(atcmd_output));
  479. sscanf(message, "%d %d", &x, &y);
  480. if (x <= 0) //If coordinates are 'wrong', random jump.
  481. x = -1;
  482. if (y <= 0)
  483. y = -1;
  484. if (sd->bl.m >= 0 && map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  485. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  486. return -1;
  487. }
  488. pc_setpos(sd, sd->mapindex, x, y, 3);
  489. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  490. clif_displaymessage(fd, atcmd_output);
  491. return 0;
  492. }
  493. /*==========================================
  494. * @who3 = Player name, his location
  495. *------------------------------------------*/
  496. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  497. {
  498. char temp0[100];
  499. struct map_session_data *pl_sd, **pl_allsd;
  500. int i, j, count, users;
  501. int pl_GM_level, GM_level;
  502. char match_text[100];
  503. char player_name[NAME_LENGTH];
  504. nullpo_retr(-1, sd);
  505. memset(atcmd_output, '\0', sizeof(atcmd_output));
  506. memset(match_text, '\0', sizeof(match_text));
  507. memset(player_name, '\0', sizeof(player_name));
  508. if (sscanf(message, "%99[^\n]", match_text) < 1)
  509. strcpy(match_text, "");
  510. for (j = 0; match_text[j]; j++)
  511. match_text[j] = TOLOWER(match_text[j]);
  512. count = 0;
  513. GM_level = pc_isGM(sd);
  514. pl_allsd = map_getallusers(&users);
  515. for (i = 0; i < users; i++) {
  516. if ((pl_sd = pl_allsd[i])) {
  517. pl_GM_level = pc_isGM(pl_sd);
  518. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  519. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  520. for (j = 0; player_name[j]; j++)
  521. player_name[j] = TOLOWER(player_name[j]);
  522. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  523. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  524. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  525. } else {
  526. atcmd_output[0]=0;
  527. }
  528. //Player name
  529. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  530. strcat(atcmd_output,temp0);
  531. //Player title, if exists
  532. if (pl_GM_level > 0) {
  533. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  534. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  535. strcat(atcmd_output,temp0);
  536. }
  537. //Players Location: map x y
  538. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  539. strcat(atcmd_output,temp0);
  540. clif_displaymessage(fd, atcmd_output);
  541. count++;
  542. }
  543. }
  544. }
  545. }
  546. if (count == 0)
  547. clif_displaymessage(fd, msg_txt(28)); // No player found.
  548. else if (count == 1)
  549. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  550. else {
  551. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  552. clif_displaymessage(fd, atcmd_output);
  553. }
  554. return 0;
  555. }
  556. /*==========================================
  557. * Player name, BLevel, Job,
  558. *------------------------------------------*/
  559. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  560. {
  561. char temp0[100];
  562. struct map_session_data *pl_sd, **pl_allsd;
  563. int i, j, count, users;
  564. int pl_GM_level, GM_level;
  565. char match_text[100];
  566. char player_name[NAME_LENGTH];
  567. nullpo_retr(-1, sd);
  568. memset(atcmd_output, '\0', sizeof(atcmd_output));
  569. memset(match_text, '\0', sizeof(match_text));
  570. memset(player_name, '\0', sizeof(player_name));
  571. if (sscanf(message, "%99[^\n]", match_text) < 1)
  572. strcpy(match_text, "");
  573. for (j = 0; match_text[j]; j++)
  574. match_text[j] = TOLOWER(match_text[j]);
  575. count = 0;
  576. GM_level = pc_isGM(sd);
  577. pl_allsd = map_getallusers(&users);
  578. for (i = 0; i < users; i++) {
  579. if ((pl_sd = pl_allsd[i])) {
  580. pl_GM_level = pc_isGM(pl_sd);
  581. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  582. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  583. for (j = 0; player_name[j]; j++)
  584. player_name[j] = TOLOWER(player_name[j]);
  585. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  586. //Players Name
  587. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  588. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  589. //Player title, if exists
  590. if (pl_GM_level > 0) {
  591. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  592. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  593. strcat(atcmd_output,temp0);
  594. }
  595. //Players Base Level / Job name
  596. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  597. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  598. strcat(atcmd_output,temp0);
  599. clif_displaymessage(fd, atcmd_output);
  600. count++;
  601. }
  602. }
  603. }
  604. }
  605. if (count == 0)
  606. clif_displaymessage(fd, msg_txt(28)); // No player found.
  607. else if (count == 1)
  608. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  609. else {
  610. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  611. clif_displaymessage(fd, atcmd_output);
  612. }
  613. return 0;
  614. }
  615. /*==========================================
  616. * Player name, Playrs Party / Guild name
  617. *------------------------------------------*/
  618. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  619. {
  620. char temp0[100];
  621. struct map_session_data *pl_sd, **pl_allsd;
  622. int i, j, count, users;
  623. int pl_GM_level, GM_level;
  624. char match_text[100];
  625. char player_name[NAME_LENGTH];
  626. struct guild *g;
  627. struct party_data *p;
  628. nullpo_retr(-1, sd);
  629. memset(temp0, '\0', sizeof(temp0));
  630. memset(atcmd_output, '\0', sizeof(atcmd_output));
  631. memset(match_text, '\0', sizeof(match_text));
  632. memset(player_name, '\0', sizeof(player_name));
  633. if (sscanf(message, "%99[^\n]", match_text) < 1)
  634. strcpy(match_text, "");
  635. for (j = 0; match_text[j]; j++)
  636. match_text[j] = TOLOWER(match_text[j]);
  637. count = 0;
  638. GM_level = pc_isGM(sd);
  639. pl_allsd = map_getallusers(&users);
  640. for (i = 0; i < users; i++) {
  641. if ((pl_sd = pl_allsd[i])) {
  642. pl_GM_level = pc_isGM(pl_sd);
  643. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  644. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  645. for (j = 0; player_name[j]; j++)
  646. player_name[j] = TOLOWER(player_name[j]);
  647. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  648. g = guild_search(pl_sd->status.guild_id);
  649. p = party_search(pl_sd->status.party_id);
  650. //Players Name
  651. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  652. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  653. //Player title, if exists
  654. if (pl_GM_level > 0) {
  655. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  656. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  657. strcat(atcmd_output,temp0);
  658. }
  659. //Players Party if exists
  660. if (p != NULL) {
  661. //sprintf(temp0," | Party: '%s'", p->name);
  662. sprintf(temp0, msg_txt(335), p->party.name);
  663. strcat(atcmd_output,temp0);
  664. }
  665. //Players Guild if exists
  666. if (g != NULL) {
  667. //sprintf(temp0," | Guild: '%s'", g->name);
  668. sprintf(temp0, msg_txt(336), g->name);
  669. strcat(atcmd_output,temp0);
  670. }
  671. clif_displaymessage(fd, atcmd_output);
  672. count++;
  673. }
  674. }
  675. }
  676. }
  677. if (count == 0)
  678. clif_displaymessage(fd, msg_txt(28)); // No player found.
  679. else if (count == 1)
  680. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  681. else {
  682. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  683. clif_displaymessage(fd, atcmd_output);
  684. }
  685. return 0;
  686. }
  687. /*==========================================
  688. *
  689. *------------------------------------------*/
  690. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  691. {
  692. struct map_session_data *pl_sd, **pl_allsd;
  693. int i, count, users;
  694. int pl_GM_level, GM_level;
  695. int map_id;
  696. char map_name[MAP_NAME_LENGTH];
  697. memset(atcmd_output, '\0', sizeof(atcmd_output));
  698. memset(map_name, '\0', sizeof(map_name));
  699. if (!message || !*message)
  700. map_id = sd->bl.m;
  701. else {
  702. sscanf(message, "%11s", map_name);
  703. if ((map_id = map_mapname2mapid(map_name)) < 0)
  704. map_id = sd->bl.m;
  705. }
  706. count = 0;
  707. GM_level = pc_isGM(sd);
  708. pl_allsd = map_getallusers(&users);
  709. for (i = 0; i < users; i++) {
  710. if ((pl_sd = pl_allsd[i])) {
  711. pl_GM_level = pc_isGM(pl_sd);
  712. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  713. if (pl_sd->bl.m == map_id) {
  714. if (pl_GM_level > 0)
  715. 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);
  716. else
  717. 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);
  718. clif_displaymessage(fd, atcmd_output);
  719. count++;
  720. }
  721. }
  722. }
  723. }
  724. if (count == 0)
  725. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  726. else if (count == 1)
  727. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  728. else {
  729. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  730. }
  731. clif_displaymessage(fd, atcmd_output);
  732. return 0;
  733. }
  734. /*==========================================
  735. *
  736. *------------------------------------------*/
  737. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  738. {
  739. struct map_session_data *pl_sd, **pl_allsd;
  740. int i, count, users;
  741. int pl_GM_level, GM_level;
  742. int map_id = 0;
  743. char map_name[MAP_NAME_LENGTH];
  744. nullpo_retr(-1, sd);
  745. memset(atcmd_output, '\0', sizeof(atcmd_output));
  746. memset(map_name, '\0', sizeof(map_name));
  747. if (!message || !*message)
  748. map_id = sd->bl.m;
  749. else {
  750. sscanf(message, "%11s", map_name);
  751. if ((map_id = map_mapname2mapid(map_name)) < 0)
  752. map_id = sd->bl.m;
  753. }
  754. count = 0;
  755. GM_level = pc_isGM(sd);
  756. pl_allsd = map_getallusers(&users);
  757. for (i = 0; i < users; i++) {
  758. if ((pl_sd = pl_allsd[i])) {
  759. pl_GM_level = pc_isGM(pl_sd);
  760. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  761. if (pl_sd->bl.m == map_id) {
  762. if (pl_GM_level > 0)
  763. 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);
  764. else
  765. 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);
  766. clif_displaymessage(fd, atcmd_output);
  767. count++;
  768. }
  769. }
  770. }
  771. }
  772. if (count == 0)
  773. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  774. else if (count == 1)
  775. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  776. else {
  777. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  778. }
  779. clif_displaymessage(fd, atcmd_output);
  780. return 0;
  781. }
  782. /*==========================================
  783. *
  784. *------------------------------------------*/
  785. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  786. {
  787. char temp0[100];
  788. char temp1[100];
  789. struct map_session_data *pl_sd, **pl_allsd;
  790. int i, count, users;
  791. int pl_GM_level, GM_level;
  792. int map_id = 0;
  793. char map_name[MAP_NAME_LENGTH];
  794. struct guild *g;
  795. struct party_data *p;
  796. nullpo_retr(-1, sd);
  797. memset(temp0, '\0', sizeof(temp0));
  798. memset(temp1, '\0', sizeof(temp1));
  799. memset(atcmd_output, '\0', sizeof(atcmd_output));
  800. memset(map_name, '\0', sizeof(map_name));
  801. if (!message || !*message)
  802. map_id = sd->bl.m;
  803. else {
  804. sscanf(message, "%11s", map_name);
  805. if ((map_id = map_mapname2mapid(map_name)) < 0)
  806. map_id = sd->bl.m;
  807. }
  808. count = 0;
  809. GM_level = pc_isGM(sd);
  810. pl_allsd = map_getallusers(&users);
  811. for (i = 0; i < users; i++) {
  812. if ((pl_sd = pl_allsd[i])) {
  813. pl_GM_level = pc_isGM(pl_sd);
  814. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  815. if (pl_sd->bl.m == map_id) {
  816. g = guild_search(pl_sd->status.guild_id);
  817. if (g == NULL)
  818. sprintf(temp1, "None");
  819. else
  820. sprintf(temp1, "%s", g->name);
  821. p = party_search(pl_sd->status.party_id);
  822. if (p == NULL)
  823. sprintf(temp0, "None");
  824. else
  825. sprintf(temp0, "%s", p->party.name);
  826. if (pl_GM_level > 0)
  827. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  828. else
  829. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  830. clif_displaymessage(fd, atcmd_output);
  831. count++;
  832. }
  833. }
  834. }
  835. }
  836. if (count == 0)
  837. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  838. else if (count == 1)
  839. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  840. else {
  841. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  842. }
  843. clif_displaymessage(fd, atcmd_output);
  844. return 0;
  845. }
  846. /*==========================================
  847. *
  848. *------------------------------------------*/
  849. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  850. {
  851. struct map_session_data *pl_sd, **pl_allsd;
  852. int i, j, count, users;
  853. int pl_GM_level, GM_level;
  854. char match_text[200];
  855. char player_name[NAME_LENGTH];
  856. struct guild *g;
  857. struct party_data *p;
  858. nullpo_retr(-1, sd);
  859. memset(atcmd_output, '\0', sizeof(atcmd_output));
  860. memset(match_text, '\0', sizeof(match_text));
  861. memset(player_name, '\0', sizeof(player_name));
  862. if (sscanf(message, "%199[^\n]", match_text) < 1)
  863. strcpy(match_text, "");
  864. for (j = 0; match_text[j]; j++)
  865. match_text[j] = TOLOWER(match_text[j]);
  866. count = 0;
  867. GM_level = pc_isGM(sd);
  868. pl_allsd = map_getallusers(&users);
  869. for (i = 0; i < users; i++) {
  870. pl_sd = pl_allsd[i];
  871. pl_GM_level = pc_isGM(pl_sd);
  872. if (!pl_GM_level)
  873. continue;
  874. if (match_text[0])
  875. {
  876. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  877. for (j = 0; player_name[j]; j++)
  878. player_name[j] = TOLOWER(player_name[j]);
  879. // search with no case sensitive
  880. if (strstr(player_name, match_text) == NULL)
  881. continue;
  882. }
  883. if (pl_GM_level > GM_level) {
  884. if (pl_sd->sc.option & OPTION_INVISIBLE)
  885. continue;
  886. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  887. clif_displaymessage(fd, atcmd_output);
  888. count++;
  889. continue;
  890. }
  891. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  892. pl_sd->status.name, pl_GM_level,
  893. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  894. clif_displaymessage(fd, atcmd_output);
  895. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  896. pl_sd->status.base_level,
  897. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  898. clif_displaymessage(fd, atcmd_output);
  899. p = party_search(pl_sd->status.party_id);
  900. g = guild_search(pl_sd->status.guild_id);
  901. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  902. p?p->party.name:"None", g?g->name:"None");
  903. clif_displaymessage(fd, atcmd_output);
  904. count++;
  905. }
  906. if (count == 0)
  907. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  908. else if (count == 1)
  909. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  910. else {
  911. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  912. clif_displaymessage(fd, atcmd_output);
  913. }
  914. return 0;
  915. }
  916. int atcommand_whozeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  917. {
  918. struct map_session_data *pl_sd, **pl_allsd;
  919. int i, j, count,c, users;
  920. char match_text[100];
  921. char player_name[NAME_LENGTH];
  922. int *zeny;
  923. int *counted;
  924. nullpo_retr(-1, sd);
  925. memset(atcmd_output, '\0', sizeof(atcmd_output));
  926. memset(match_text, '\0', sizeof(match_text));
  927. memset(player_name, '\0', sizeof(player_name));
  928. if (sscanf(message, "%99[^\n]", match_text) < 1)
  929. strcpy(match_text, "");
  930. for (j = 0; match_text[j]; j++)
  931. match_text[j] = TOLOWER(match_text[j]);
  932. count = 0;
  933. pl_allsd = map_getallusers(&users);
  934. if (users < 1)
  935. {
  936. clif_displaymessage(fd, msg_txt(28)); // No player found.
  937. return 0;
  938. }
  939. zeny = (int *)aMallocA(users*sizeof(int));
  940. counted = (int *)aMallocA(users*sizeof(int));
  941. for (i = 0; i < users; i++) {
  942. if ((pl_sd = pl_allsd[i])) {
  943. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  944. for (j = 0; player_name[j]; j++)
  945. player_name[j] = TOLOWER(player_name[j]);
  946. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  947. zeny[count]=pl_sd->status.zeny;
  948. counted[i]=0;
  949. count++;
  950. }
  951. }
  952. }
  953. qsort(zeny, count, sizeof(int), hightolow_compare);
  954. for (c = 0; c < count && c < 50; c++) {
  955. if(!zeny[c])
  956. continue;
  957. for (i = 0; i < users; i++) {
  958. if(!zeny[c])
  959. continue;
  960. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  961. if(pl_sd->status.zeny==zeny[c]) {
  962. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  963. clif_displaymessage(fd, atcmd_output);
  964. zeny[c]=0;
  965. counted[i]=1;
  966. }
  967. }
  968. }
  969. }
  970. if (count == 0)
  971. clif_displaymessage(fd, msg_txt(28)); // No player found.
  972. else if (count == 1)
  973. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  974. else {
  975. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  976. clif_displaymessage(fd, atcmd_output);
  977. }
  978. aFree(zeny);
  979. aFree(counted);
  980. return 0;
  981. }
  982. /*==========================================
  983. *
  984. *------------------------------------------*/
  985. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  986. {
  987. nullpo_retr(-1, sd);
  988. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  989. if (sd->status.pet_id > 0 && sd->pd)
  990. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  991. chrif_save(sd,0);
  992. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  993. return 0;
  994. }
  995. /*==========================================
  996. *
  997. *------------------------------------------*/
  998. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  999. {
  1000. int m;
  1001. nullpo_retr(-1, sd);
  1002. m = map_mapindex2mapid(sd->status.save_point.map);
  1003. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1004. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  1005. return -1;
  1006. }
  1007. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1008. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  1009. return -1;
  1010. }
  1011. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1012. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1013. return 0;
  1014. }
  1015. /*==========================================
  1016. *
  1017. *------------------------------------------*/
  1018. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1019. {
  1020. int speed;
  1021. nullpo_retr(-1, sd);
  1022. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1023. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  1024. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1025. clif_displaymessage(fd, atcmd_output);
  1026. return -1;
  1027. }
  1028. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  1029. status_calc_bl(&sd->bl, SCB_SPEED);
  1030. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1031. return 0;
  1032. }
  1033. /*==========================================
  1034. *
  1035. *------------------------------------------*/
  1036. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1037. {
  1038. nullpo_retr(-1, sd);
  1039. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1040. return -1;
  1041. if (storage_storageopen(sd) == 1)
  1042. { //Already open.
  1043. clif_displaymessage(fd, msg_txt(250));
  1044. return -1;
  1045. }
  1046. clif_displaymessage(fd, "Storage opened.");
  1047. return 0;
  1048. }
  1049. /*==========================================
  1050. *
  1051. *------------------------------------------*/
  1052. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1053. {
  1054. struct storage *stor; //changes from Freya/Yor
  1055. nullpo_retr(-1, sd);
  1056. if (!sd->status.guild_id) {
  1057. clif_displaymessage(fd, msg_txt(252));
  1058. return -1;
  1059. }
  1060. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1061. return -1;
  1062. if (sd->state.storage_flag) {
  1063. clif_displaymessage(fd, msg_txt(251));
  1064. return -1;
  1065. }
  1066. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1067. clif_displaymessage(fd, msg_txt(251));
  1068. return -1;
  1069. }
  1070. storage_guild_storageopen(sd);
  1071. clif_displaymessage(fd, "Guild storage opened.");
  1072. return 0;
  1073. }
  1074. /*==========================================
  1075. *
  1076. *------------------------------------------*/
  1077. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1078. {
  1079. int param1 = 0, param2 = 0, param3 = 0;
  1080. nullpo_retr(-1, sd);
  1081. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1082. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1083. return -1;
  1084. }
  1085. sd->sc.opt1 = param1;
  1086. sd->sc.opt2 = param2;
  1087. pc_setoption(sd, param3);
  1088. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1089. return 0;
  1090. }
  1091. /*==========================================
  1092. *
  1093. *------------------------------------------*/
  1094. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1095. {
  1096. nullpo_retr(-1, sd);
  1097. if (sd->sc.option & OPTION_INVISIBLE) {
  1098. sd->sc.option &= ~OPTION_INVISIBLE;
  1099. if (sd->disguise)
  1100. status_set_viewdata(&sd->bl, sd->disguise);
  1101. else
  1102. status_set_viewdata(&sd->bl, sd->status.class_);
  1103. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1104. } else {
  1105. sd->sc.option |= OPTION_INVISIBLE;
  1106. sd->vd.class_ = INVISIBLE_CLASS;
  1107. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1108. }
  1109. clif_changeoption(&sd->bl);
  1110. return 0;
  1111. }
  1112. /*==========================================
  1113. * Changes a character's class
  1114. *------------------------------------------*/
  1115. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1116. {
  1117. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1118. int job = 0, upper = 0;
  1119. nullpo_retr(-1, sd);
  1120. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1121. {
  1122. int i, found = 0;
  1123. const struct { char name[16]; int id; } jobs[] = {
  1124. { "novice", 0 },
  1125. { "swordsman", 1 },
  1126. { "mage", 2 },
  1127. { "archer", 3 },
  1128. { "acolyte", 4 },
  1129. { "merchant", 5 },
  1130. { "thief", 6 },
  1131. { "knight", 7 },
  1132. { "priest", 8 },
  1133. { "priestess", 8 },
  1134. { "wizard", 9 },
  1135. { "blacksmith", 10 },
  1136. { "hunter", 11 },
  1137. { "assassin", 12 },
  1138. { "crusader", 14 },
  1139. { "monk", 15 },
  1140. { "sage", 16 },
  1141. { "rogue", 17 },
  1142. { "alchemist", 18 },
  1143. { "bard", 19 },
  1144. { "dancer", 20 },
  1145. { "super novice", 23 },
  1146. { "supernovice", 23 },
  1147. { "gunslinger", 24 },
  1148. { "gunner", 24 },
  1149. { "ninja", 25 },
  1150. { "high novice", 4001 },
  1151. { "swordsman high", 4002 },
  1152. { "mage high", 4003 },
  1153. { "archer high", 4004 },
  1154. { "acolyte high", 4005 },
  1155. { "merchant high", 4006 },
  1156. { "thief high", 4007 },
  1157. { "lord knight", 4008 },
  1158. { "high priest", 4009 },
  1159. { "high priestess", 4009 },
  1160. { "high wizard", 4010 },
  1161. { "whitesmith", 4011 },
  1162. { "sniper", 4012 },
  1163. { "assassin cross", 4013 },
  1164. { "paladin", 4015 },
  1165. { "champion", 4016 },
  1166. { "professor", 4017 },
  1167. { "stalker", 4018 },
  1168. { "creator", 4019 },
  1169. { "clown", 4020 },
  1170. { "gypsy", 4021 },
  1171. { "baby novice", 4023 },
  1172. { "baby swordsman", 4024 },
  1173. { "baby mage", 4025 },
  1174. { "baby archer", 4026 },
  1175. { "baby acolyte", 4027 },
  1176. { "baby merchant", 4028 },
  1177. { "baby thief", 4029 },
  1178. { "baby knight", 4030 },
  1179. { "baby priest", 4031 },
  1180. { "baby priestess", 4031 },
  1181. { "baby wizard", 4032 },
  1182. { "baby blacksmith",4033 },
  1183. { "baby hunter", 4034 },
  1184. { "baby assassin", 4035 },
  1185. { "baby crusader", 4037 },
  1186. { "baby monk", 4038 },
  1187. { "baby sage", 4039 },
  1188. { "baby rogue", 4040 },
  1189. { "baby alchemist", 4041 },
  1190. { "baby bard", 4042 },
  1191. { "baby dancer", 4043 },
  1192. { "super baby", 4045 },
  1193. { "taekwon", 4046 },
  1194. { "taekwon boy", 4046 },
  1195. { "taekwon girl", 4046 },
  1196. { "star gladiator", 4047 },
  1197. { "soul linker", 4049 },
  1198. };
  1199. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1200. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1201. job = jobs[i].id;
  1202. upper = 0;
  1203. found = 1;
  1204. break;
  1205. }
  1206. }
  1207. if (!found) {
  1208. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1209. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1210. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1211. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1212. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1213. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1214. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1215. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1216. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1217. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1218. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1219. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1220. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1221. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1222. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1223. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1224. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1225. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1226. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1227. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1228. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1229. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1230. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1231. return -1;
  1232. }
  1233. }
  1234. if (job == 37 ||job == 45)
  1235. return 0;
  1236. if (pcdb_checkid(job))
  1237. {
  1238. if (pc_jobchange(sd, job, upper) == 0)
  1239. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1240. else {
  1241. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  1242. return -1;
  1243. }
  1244. } else {
  1245. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1246. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1247. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1248. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1249. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1250. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1251. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1252. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1253. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1254. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1255. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1256. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1257. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1258. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1259. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1260. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1261. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1262. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1263. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1264. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1265. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1266. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1267. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1268. return -1;
  1269. }
  1270. return 0;
  1271. }
  1272. /*==========================================
  1273. *
  1274. *------------------------------------------*/
  1275. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1276. {
  1277. nullpo_retr(-1, sd);
  1278. clif_specialeffect(&sd->bl,450,SELF);
  1279. status_kill(&sd->bl);
  1280. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1281. return 0;
  1282. }
  1283. /*==========================================
  1284. *
  1285. *------------------------------------------*/
  1286. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1287. {
  1288. struct map_session_data *pl_sd;
  1289. nullpo_retr(-1, sd);
  1290. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1291. if (!message || !*message) {
  1292. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1293. return -1;
  1294. }
  1295. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1296. {
  1297. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1298. return -1;
  1299. }
  1300. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1301. { // you can kill only lower or same level
  1302. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1303. return -1;
  1304. }
  1305. status_kill(&pl_sd->bl);
  1306. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1307. if (fd != pl_sd->fd)
  1308. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1309. return 0;
  1310. }
  1311. /*==========================================
  1312. *
  1313. *------------------------------------------*/
  1314. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1315. {
  1316. nullpo_retr(-1, sd);
  1317. if (!status_revive(&sd->bl, 100, 100))
  1318. {
  1319. clif_displaymessage(fd, "You're not dead.");
  1320. return -1;
  1321. }
  1322. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1323. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1324. return 0;
  1325. }
  1326. /*==========================================
  1327. * +kamic [LuzZza]
  1328. *------------------------------------------*/
  1329. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1330. {
  1331. unsigned long color=0;
  1332. nullpo_retr(-1, sd);
  1333. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1334. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1335. if (!message || !*message) {
  1336. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1337. return -1;
  1338. }
  1339. sscanf(message, "%199[^\n]", atcmd_output);
  1340. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1341. } else {
  1342. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1343. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1344. return -1;
  1345. }
  1346. if(color > 0xFFFFFF) {
  1347. clif_displaymessage(fd, "Invalid color.");
  1348. return -1;
  1349. }
  1350. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  1351. }
  1352. return 0;
  1353. }
  1354. /*==========================================
  1355. *
  1356. *------------------------------------------*/
  1357. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1358. {
  1359. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1360. nullpo_retr(-1, sd);
  1361. sscanf(message, "%d %d", &hp, &sp);
  1362. if (hp == 0 && sp == 0) {
  1363. if (!status_percent_heal(&sd->bl, 100, 100))
  1364. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1365. else
  1366. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1367. return 0;
  1368. }
  1369. if(hp > 0 && sp >= 0) {
  1370. if(!status_heal(&sd->bl, hp, sp, 0))
  1371. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1372. else
  1373. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1374. return 0;
  1375. }
  1376. if(hp < 0 && sp <= 0) {
  1377. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1378. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1379. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1380. return 0;
  1381. }
  1382. //Opposing signs.
  1383. if (hp) {
  1384. if (hp > 0)
  1385. status_heal(&sd->bl, hp, 0, 0);
  1386. else {
  1387. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1388. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1389. }
  1390. }
  1391. if (sp) {
  1392. if (sp > 0)
  1393. status_heal(&sd->bl, 0, sp, 0);
  1394. else
  1395. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1396. }
  1397. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1398. return 0;
  1399. }
  1400. /*==========================================
  1401. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1402. *------------------------------------------*/
  1403. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1404. {
  1405. char item_name[100];
  1406. int number = 0, item_id, flag;
  1407. struct item item_tmp;
  1408. struct item_data *item_data;
  1409. int get_count, i;
  1410. nullpo_retr(-1, sd);
  1411. memset(item_name, '\0', sizeof(item_name));
  1412. if (!message || !*message || (
  1413. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1414. sscanf(message, "%99s %d", item_name, &number) < 1
  1415. )) {
  1416. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1417. return -1;
  1418. }
  1419. if (number <= 0)
  1420. number = 1;
  1421. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1422. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1423. {
  1424. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1425. return -1;
  1426. }
  1427. item_id = item_data->nameid;
  1428. get_count = number;
  1429. //Check if it's stackable.
  1430. if (!itemdb_isstackable2(item_data))
  1431. get_count = 1;
  1432. for (i = 0; i < number; i += get_count) {
  1433. // if not pet egg
  1434. if (!pet_create_egg(sd, item_id)) {
  1435. memset(&item_tmp, 0, sizeof(item_tmp));
  1436. item_tmp.nameid = item_id;
  1437. item_tmp.identify = 1;
  1438. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1439. clif_additem(sd, 0, 0, flag);
  1440. }
  1441. }
  1442. //Logs (A)dmins items [Lupus]
  1443. if(log_config.enable_logs&0x400)
  1444. log_pick_pc(sd, "A", item_id, number, NULL);
  1445. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1446. return 0;
  1447. }
  1448. /*==========================================
  1449. *
  1450. *------------------------------------------*/
  1451. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1452. {
  1453. struct item item_tmp;
  1454. struct item_data *item_data;
  1455. char item_name[100];
  1456. int item_id, number = 0;
  1457. int identify = 0, refine = 0, attr = 0;
  1458. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1459. int flag;
  1460. int loop, get_count, i;
  1461. nullpo_retr(-1, sd);
  1462. memset(item_name, '\0', sizeof(item_name));
  1463. if (!message || !*message || (
  1464. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1465. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1466. )) {
  1467. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1468. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1469. return -1;
  1470. }
  1471. if (number <= 0)
  1472. number = 1;
  1473. item_id = 0;
  1474. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1475. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1476. item_id = item_data->nameid;
  1477. if (item_id > 500) {
  1478. loop = 1;
  1479. get_count = number;
  1480. if (item_data->type == 4 || item_data->type == 5 ||
  1481. item_data->type == 7 || item_data->type == 8) {
  1482. loop = number;
  1483. get_count = 1;
  1484. if (item_data->type == 7) {
  1485. identify = 1;
  1486. refine = 0;
  1487. }
  1488. if (item_data->type == 8)
  1489. refine = 0;
  1490. if (refine > 10)
  1491. refine = 10;
  1492. } else {
  1493. identify = 1;
  1494. refine = attr = 0;
  1495. }
  1496. for (i = 0; i < loop; i++) {
  1497. memset(&item_tmp, 0, sizeof(item_tmp));
  1498. item_tmp.nameid = item_id;
  1499. item_tmp.identify = identify;
  1500. item_tmp.refine = refine;
  1501. item_tmp.attribute = attr;
  1502. item_tmp.card[0] = c1;
  1503. item_tmp.card[1] = c2;
  1504. item_tmp.card[2] = c3;
  1505. item_tmp.card[3] = c4;
  1506. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1507. clif_additem(sd, 0, 0, flag);
  1508. }
  1509. //Logs (A)dmins items [Lupus]
  1510. if(log_config.enable_logs&0x400)
  1511. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  1512. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1513. } else {
  1514. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1515. return -1;
  1516. }
  1517. return 0;
  1518. }
  1519. /*==========================================
  1520. *
  1521. *------------------------------------------*/
  1522. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1523. {
  1524. int i;
  1525. nullpo_retr(-1, sd);
  1526. for (i = 0; i < MAX_INVENTORY; i++) {
  1527. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1528. //Logs (A)dmins items [Lupus]
  1529. if(log_config.enable_logs&0x400)
  1530. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1531. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  1532. }
  1533. }
  1534. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1535. return 0;
  1536. }
  1537. /*==========================================
  1538. * Atcommand @lvlup
  1539. *------------------------------------------*/
  1540. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1541. {
  1542. int level=0, i=0, status_point=0;
  1543. nullpo_retr(-1, sd);
  1544. level = atoi(message);
  1545. if (!message || !*message || !level) {
  1546. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1547. return -1;
  1548. }
  1549. if (level > 0) {
  1550. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1551. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1552. return -1;
  1553. } // End Addition
  1554. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1555. level = pc_maxbaselv(sd) - sd->status.base_level;
  1556. for (i = 1; i <= level; i++)
  1557. status_point += (sd->status.base_level + i + 14) / 5;
  1558. if (sd->status.status_point > USHRT_MAX - status_point)
  1559. sd->status.status_point = USHRT_MAX;
  1560. else
  1561. sd->status.status_point += status_point;
  1562. sd->status.base_level += (unsigned int)level;
  1563. status_percent_heal(&sd->bl, 100, 100);
  1564. clif_misceffect(&sd->bl, 0);
  1565. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1566. } else {
  1567. if (sd->status.base_level == 1) {
  1568. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1569. return -1;
  1570. }
  1571. level*=-1;
  1572. if ((unsigned int)level >= sd->status.base_level)
  1573. level = sd->status.base_level-1;
  1574. for (i = 0; i > -level; i--)
  1575. status_point += (sd->status.base_level + i + 14) / 5;
  1576. if (sd->status.status_point < status_point)
  1577. pc_resetstate(sd);
  1578. if (sd->status.status_point < status_point)
  1579. sd->status.status_point = 0;
  1580. else
  1581. sd->status.status_point -= status_point;
  1582. sd->status.base_level -= (unsigned int)level;
  1583. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1584. }
  1585. clif_updatestatus(sd, SP_STATUSPOINT);
  1586. clif_updatestatus(sd, SP_BASELEVEL);
  1587. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1588. status_calc_pc(sd, 0);
  1589. if(sd->status.party_id)
  1590. party_send_levelup(sd);
  1591. return 0;
  1592. }
  1593. /*==========================================
  1594. *
  1595. *------------------------------------------*/
  1596. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1597. {
  1598. int level=0;
  1599. nullpo_retr(-1, sd);
  1600. level = atoi(message);
  1601. if (!message || !*message || !level) {
  1602. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1603. return -1;
  1604. }
  1605. if (level > 0) {
  1606. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1607. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1608. return -1;
  1609. }
  1610. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1611. level = pc_maxjoblv(sd) - sd->status.job_level;
  1612. sd->status.job_level += (unsigned int)level;
  1613. clif_updatestatus(sd, SP_JOBLEVEL);
  1614. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1615. if (sd->status.skill_point > USHRT_MAX - level)
  1616. sd->status.skill_point = USHRT_MAX;
  1617. else
  1618. sd->status.skill_point += level;
  1619. clif_updatestatus(sd, SP_SKILLPOINT);
  1620. status_calc_pc(sd, 0);
  1621. clif_misceffect(&sd->bl, 1);
  1622. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1623. } else {
  1624. if (sd->status.job_level == 1) {
  1625. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1626. return -1;
  1627. }
  1628. level *=-1;
  1629. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1630. level = sd->status.job_level-1;
  1631. sd->status.job_level -= (unsigned int)level;
  1632. clif_updatestatus(sd, SP_JOBLEVEL);
  1633. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1634. if (sd->status.skill_point < level)
  1635. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1636. if (sd->status.skill_point < level)
  1637. sd->status.skill_point = 0;
  1638. else
  1639. sd->status.skill_point -= level;
  1640. clif_updatestatus(sd, SP_SKILLPOINT);
  1641. status_calc_pc(sd, 0);
  1642. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1643. }
  1644. return 0;
  1645. }
  1646. /*==========================================
  1647. * @help
  1648. *------------------------------------------*/
  1649. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1650. {
  1651. char buf[2048], w1[2048], w2[2048];
  1652. int i, gm_level;
  1653. FILE* fp;
  1654. nullpo_retr(-1, sd);
  1655. memset(buf, '\0', sizeof(buf));
  1656. if ((fp = fopen(help_txt, "r")) != NULL) {
  1657. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1658. gm_level = pc_isGM(sd);
  1659. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1660. if (buf[0] == '/' && buf[1] == '/')
  1661. continue;
  1662. for (i = 0; buf[i] != '\0'; i++) {
  1663. if (buf[i] == '\r' || buf[i] == '\n') {
  1664. buf[i] = '\0';
  1665. break;
  1666. }
  1667. }
  1668. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1669. clif_displaymessage(fd, buf);
  1670. else if (gm_level >= atoi(w1))
  1671. clif_displaymessage(fd, w2);
  1672. }
  1673. fclose(fp);
  1674. } else {
  1675. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1676. return -1;
  1677. }
  1678. return 0;
  1679. }
  1680. /*==========================================
  1681. * @help2 - Char commands [Kayla]
  1682. *------------------------------------------*/
  1683. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1684. {
  1685. char buf[2048], w1[2048], w2[2048];
  1686. int i, gm_level;
  1687. FILE* fp;
  1688. nullpo_retr(-1, sd);
  1689. memset(buf, '\0', sizeof(buf));
  1690. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1691. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1692. gm_level = pc_isGM(sd);
  1693. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1694. if (buf[0] == '/' && buf[1] == '/')
  1695. continue;
  1696. for (i = 0; buf[i] != '\0'; i++) {
  1697. if (buf[i] == '\r' || buf[i] == '\n') {
  1698. buf[i] = '\0';
  1699. break;
  1700. }
  1701. }
  1702. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1703. clif_displaymessage(fd, buf);
  1704. else if (gm_level >= atoi(w1))
  1705. clif_displaymessage(fd, w2);
  1706. }
  1707. fclose(fp);
  1708. } else {
  1709. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1710. return -1;
  1711. }
  1712. return 0;
  1713. }
  1714. /*==========================================
  1715. * @gm
  1716. *------------------------------------------*/
  1717. int atcommand_gm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1718. {
  1719. char password[100];
  1720. nullpo_retr(-1, sd);
  1721. memset(password, '\0', sizeof(password));
  1722. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  1723. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  1724. return -1;
  1725. }
  1726. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  1727. clif_displaymessage(fd, msg_txt(50)); // You already have some GM powers.
  1728. return -1;
  1729. } else
  1730. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  1731. return 0;
  1732. }
  1733. // helper function, used in foreach calls to stop auto-attack timers
  1734. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1735. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1736. {
  1737. struct unit_data *ud = unit_bl2ud(bl);
  1738. int id = va_arg(ap, int);
  1739. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1740. {
  1741. unit_stop_attack(bl);
  1742. return 1;
  1743. }
  1744. return 0;
  1745. }
  1746. /*==========================================
  1747. *
  1748. *------------------------------------------*/
  1749. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1750. {
  1751. TBL_PC* sd = (TBL_PC*)bl;
  1752. clif_pvpset(sd, 0, 0, 2);
  1753. if (sd->pvp_timer != -1) {
  1754. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1755. sd->pvp_timer = -1;
  1756. }
  1757. return 0;
  1758. }
  1759. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1760. {
  1761. nullpo_retr(-1, sd);
  1762. //if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  1763. // clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  1764. // return -1;
  1765. //}
  1766. if (!map[sd->bl.m].flag.pvp) {
  1767. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1768. return -1;
  1769. }
  1770. map[sd->bl.m].flag.pvp = 0;
  1771. if (!battle_config.pk_mode)
  1772. clif_send0199(sd->bl.m, 0);
  1773. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1774. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1775. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1776. return 0;
  1777. }
  1778. /*==========================================
  1779. *
  1780. *------------------------------------------*/
  1781. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1782. {
  1783. struct map_session_data *pl_sd, **pl_allsd;
  1784. int i, users;
  1785. nullpo_retr(-1, sd);
  1786. //if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  1787. // clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  1788. // return -1;
  1789. //}
  1790. if (!map[sd->bl.m].flag.pvp) {
  1791. map[sd->bl.m].flag.pvp = 1;
  1792. if (!battle_config.pk_mode)
  1793. {
  1794. clif_send0199(sd->bl.m, 1);
  1795. pl_allsd = map_getallusers(&users);
  1796. for (i = 0; i < users; i++) {
  1797. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  1798. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  1799. pl_sd->pvp_rank = 0;
  1800. pl_sd->pvp_lastusers = 0;
  1801. pl_sd->pvp_point = 5;
  1802. pl_sd->pvp_won = 0;
  1803. pl_sd->pvp_lost = 0;
  1804. }
  1805. }
  1806. }
  1807. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1808. } else {
  1809. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1810. return -1;
  1811. }
  1812. return 0;
  1813. }
  1814. /*==========================================
  1815. *
  1816. *------------------------------------------*/
  1817. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1818. {
  1819. nullpo_retr(-1, sd);
  1820. if (map[sd->bl.m].flag.gvg) {
  1821. map[sd->bl.m].flag.gvg = 0;
  1822. clif_send0199(sd->bl.m, 0);
  1823. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1824. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1825. } else {
  1826. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1827. return -1;
  1828. }
  1829. return 0;
  1830. }
  1831. /*==========================================
  1832. *
  1833. *------------------------------------------*/
  1834. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1835. {
  1836. nullpo_retr(-1, sd);
  1837. if (!map[sd->bl.m].flag.gvg) {
  1838. map[sd->bl.m].flag.gvg = 1;
  1839. clif_send0199(sd->bl.m, 3);
  1840. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1841. } else {
  1842. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1843. return -1;
  1844. }
  1845. return 0;
  1846. }
  1847. /*==========================================
  1848. *
  1849. *------------------------------------------*/
  1850. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1851. {
  1852. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1853. nullpo_retr(-1, sd);
  1854. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1855. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1856. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1857. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1858. clif_displaymessage(fd, atcmd_output);
  1859. return -1;
  1860. }
  1861. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1862. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1863. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1864. pc_changelook(sd, LOOK_HAIR, hair_style);
  1865. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1866. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1867. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1868. } else {
  1869. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1870. return -1;
  1871. }
  1872. return 0;
  1873. }
  1874. /*==========================================
  1875. * @dye && @ccolor
  1876. *------------------------------------------*/
  1877. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1878. {
  1879. int cloth_color = 0;
  1880. nullpo_retr(-1, sd);
  1881. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1882. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1883. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1884. clif_displaymessage(fd, atcmd_output);
  1885. return -1;
  1886. }
  1887. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1888. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1889. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1890. } else {
  1891. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1892. return -1;
  1893. }
  1894. return 0;
  1895. }
  1896. /*==========================================
  1897. * @hairstyle && @hstyle
  1898. *------------------------------------------*/
  1899. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1900. {
  1901. int hair_style = 0;
  1902. nullpo_retr(-1, sd);
  1903. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1904. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1905. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1906. clif_displaymessage(fd, atcmd_output);
  1907. return -1;
  1908. }
  1909. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1910. pc_changelook(sd, LOOK_HAIR, hair_style);
  1911. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1912. } else {
  1913. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1914. return -1;
  1915. }
  1916. return 0;
  1917. }
  1918. /*==========================================
  1919. * @haircolor && @hcolor
  1920. *------------------------------------------*/
  1921. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1922. {
  1923. int hair_color = 0;
  1924. nullpo_retr(-1, sd);
  1925. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1926. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1927. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1928. clif_displaymessage(fd, atcmd_output);
  1929. return -1;
  1930. }
  1931. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1932. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1933. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1934. } else {
  1935. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1936. return -1;
  1937. }
  1938. return 0;
  1939. }
  1940. /*==========================================
  1941. * @go [city_number or city_name] - Updated by Harbin
  1942. *------------------------------------------*/
  1943. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1944. {
  1945. int i;
  1946. int town;
  1947. char map_name[MAP_NAME_LENGTH];
  1948. int m;
  1949. const struct {
  1950. char map[MAP_NAME_LENGTH];
  1951. int x, y;
  1952. } data[] = {
  1953. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1954. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1955. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1956. { MAP_PAYON, 162, 233 }, // 3=Payon
  1957. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1958. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1959. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1960. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1961. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1962. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1963. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1964. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1965. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1966. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1967. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1968. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1969. { MAP_JAIL, 23, 61 }, // 16=Prison
  1970. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1971. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1972. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1973. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1974. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1975. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1976. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1977. { MAP_VEINS, 216, 123 }, // 24=Veins
  1978. };
  1979. nullpo_retr(-1, sd);
  1980. if(map[sd->bl.m].flag.nogo) {
  1981. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1982. return 0;
  1983. }
  1984. memset(map_name, '\0', sizeof(map_name));
  1985. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1986. // get the number
  1987. town = atoi(message);
  1988. // if no value, display all value
  1989. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1990. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1991. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  1992. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1993. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1994. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1995. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1996. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1997. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1998. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1999. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2000. clif_displaymessage(fd, " 24=Veins");
  2001. return -1;
  2002. }
  2003. // get possible name of the city
  2004. map_name[MAP_NAME_LENGTH-1] = '\0';
  2005. for (i = 0; map_name[i]; i++)
  2006. map_name[i] = TOLOWER(map_name[i]);
  2007. // try to identify the map name
  2008. if (strncmp(map_name, "prontera", 3) == 0) {
  2009. town = 0;
  2010. } else if (strncmp(map_name, "morocc", 3) == 0) {
  2011. town = 1;
  2012. } else if (strncmp(map_name, "geffen", 3) == 0) {
  2013. town = 2;
  2014. } else if (strncmp(map_name, "payon", 3) == 0 ||
  2015. strncmp(map_name, "paion", 3) == 0) {
  2016. town = 3;
  2017. } else if (strncmp(map_name, "alberta", 3) == 0) {
  2018. town = 4;
  2019. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  2020. strncmp(map_name, "islude", 3) == 0) {
  2021. town = 5;
  2022. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2023. strcmp(map_name, "al") == 0) {
  2024. town = 6;
  2025. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  2026. strcmp(map_name, "christmas") == 0 ||
  2027. strncmp(map_name, "xmas", 3) == 0 ||
  2028. strncmp(map_name, "x-mas", 3) == 0) {
  2029. town = 7;
  2030. } else if (strncmp(map_name, "comodo", 3) == 0) {
  2031. town = 8;
  2032. } else if (strncmp(map_name, "yuno", 3) == 0) {
  2033. town = 9;
  2034. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  2035. town = 10;
  2036. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  2037. town = 11;
  2038. } else if (strncmp(map_name, "umbala", 3) == 0) {
  2039. town = 12;
  2040. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  2041. town = 13;
  2042. } else if (strncmp(map_name, "louyang", 3) == 0) {
  2043. town = 14;
  2044. } else if (strncmp(map_name, "new_zone01", 3) == 0 ||
  2045. strncmp(map_name, "startpoint", 3) == 0 ||
  2046. strncmp(map_name, "begining", 3) == 0) {
  2047. town = 15;
  2048. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2049. strncmp(map_name, "prison", 3) == 0 ||
  2050. strncmp(map_name, "jails", 3) == 0) {
  2051. town = 16;
  2052. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2053. strncmp(map_name, "jawai", 3) == 0) {
  2054. town = 17;
  2055. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2056. strncmp(map_name, "ayotaya", 3) == 0) {
  2057. town = 18;
  2058. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2059. strncmp(map_name, "ainbroch", 5) == 0) {
  2060. town = 19;
  2061. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2062. town = 20;
  2063. } else if (strncmp(map_name, "einbech", 3) == 0) {
  2064. town = 21;
  2065. } else if (strncmp(map_name, "hugel", 3) == 0) {
  2066. town = 22;
  2067. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2068. town = 23;
  2069. } else if (strncmp(map_name, "veins", 3) == 0) {
  2070. town = 24;
  2071. }
  2072. if (town >= 0 && town < ARRAYLENGTH(data))
  2073. {
  2074. m = map_mapname2mapid(data[town].map);
  2075. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2076. clif_displaymessage(fd, msg_txt(247));
  2077. return -1;
  2078. }
  2079. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2080. clif_displaymessage(fd, msg_txt(248));
  2081. return -1;
  2082. }
  2083. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
  2084. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2085. } else {
  2086. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2087. return -1;
  2088. }
  2089. } else { // if you arrive here, you have an error in town variable when reading of names
  2090. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2091. return -1;
  2092. }
  2093. return 0;
  2094. }
  2095. /*==========================================
  2096. *
  2097. *------------------------------------------*/
  2098. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2099. {
  2100. char name[NAME_LENGTH];
  2101. char monster[NAME_LENGTH];
  2102. int mob_id;
  2103. int number = 0;
  2104. int count;
  2105. int i, k, range;
  2106. short mx, my;
  2107. nullpo_retr(-1, sd);
  2108. memset(name, '\0', sizeof(name));
  2109. memset(monster, '\0', sizeof(monster));
  2110. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2111. if (!message || !*message) {
  2112. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2113. return -1;
  2114. }
  2115. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2116. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2117. //All data can be left as it is.
  2118. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2119. //Here, it is possible name was not given and we are using monster for it.
  2120. if (count < 3) //Blank mob's name.
  2121. name[0] = '\0';
  2122. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2123. //All data can be left as it is.
  2124. } else if (sscanf(message, "%23s", monster) > 0) {
  2125. //As before, name may be already filled.
  2126. name[0] = '\0';
  2127. } else {
  2128. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2129. return -1;
  2130. }
  2131. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2132. mob_id = mobdb_checkid(atoi(monster));
  2133. if (mob_id == 0) {
  2134. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2135. return -1;
  2136. }
  2137. if (mob_id == MOBID_EMPERIUM) {
  2138. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  2139. return -1;
  2140. }
  2141. if (number <= 0)
  2142. number = 1;
  2143. if (strlen(name) < 1)
  2144. strcpy(name, "--ja--");
  2145. // 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
  2146. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2147. number = battle_config.atc_spawn_quantity_limit;
  2148. if (battle_config.etc_log)
  2149. 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);
  2150. count = 0;
  2151. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  2152. for (i = 0; i < number; i++) {
  2153. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2154. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  2155. count += (k != 0) ? 1 : 0;
  2156. }
  2157. if (count != 0)
  2158. if (number == count)
  2159. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2160. else {
  2161. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2162. clif_displaymessage(fd, atcmd_output);
  2163. }
  2164. else {
  2165. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2166. return -1;
  2167. }
  2168. return 0;
  2169. }
  2170. // small monster spawning [Valaris]
  2171. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2172. {
  2173. char name[NAME_LENGTH] = "";
  2174. char monster[NAME_LENGTH] = "";
  2175. int mob_id = 0;
  2176. int number = 0;
  2177. int x = 0;
  2178. int y = 0;
  2179. int count;
  2180. int i;
  2181. nullpo_retr(-1, sd);
  2182. if (!message || !*message) {
  2183. clif_displaymessage(fd, "Give a monster name/id please.");
  2184. return -1;
  2185. }
  2186. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2187. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2188. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2189. clif_displaymessage(fd, "Give a monster name/id please.");
  2190. return -1;
  2191. }
  2192. // If monster identifier/name argument is a name
  2193. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2194. mob_id = atoi(monster);
  2195. if (mob_id == 0) {
  2196. clif_displaymessage(fd, msg_txt(40));
  2197. return -1;
  2198. }
  2199. if (mob_id == MOBID_EMPERIUM) {
  2200. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2201. return -1;
  2202. }
  2203. if (mobdb_checkid(mob_id) == 0) {
  2204. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2205. return -1;
  2206. }
  2207. if (number <= 0)
  2208. number = 1;
  2209. if (strlen(name) < 1)
  2210. strcpy(name, "--ja--");
  2211. // 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
  2212. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2213. number = battle_config.atc_spawn_quantity_limit;
  2214. count = 0;
  2215. for (i = 0; i < number; i++) {
  2216. int mx, my;
  2217. if (x <= 0)
  2218. mx = sd->bl.x + (rand() % 11 - 5);
  2219. else
  2220. mx = x;
  2221. if (y <= 0)
  2222. my = sd->bl.y + (rand() % 11 - 5);
  2223. else
  2224. my = y;
  2225. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2226. }
  2227. if (count != 0)
  2228. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2229. else
  2230. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2231. return 0;
  2232. }
  2233. // big monster spawning [Valaris]
  2234. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2235. {
  2236. char name[NAME_LENGTH] = "";
  2237. char monster[NAME_LENGTH] = "";
  2238. int mob_id = 0;
  2239. int number = 0;
  2240. int x = 0;
  2241. int y = 0;
  2242. int count;
  2243. int i;
  2244. nullpo_retr(-1, sd);
  2245. if (!message || !*message) {
  2246. clif_displaymessage(fd, "Give a monster name/id please.");
  2247. return -1;
  2248. }
  2249. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2250. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2251. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2252. clif_displaymessage(fd, "Give a monster name/id please.");
  2253. return -1;
  2254. }
  2255. // If monster identifier/name argument is a name
  2256. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2257. mob_id = atoi(monster);
  2258. if (mob_id == 0) {
  2259. clif_displaymessage(fd, msg_txt(40));
  2260. return -1;
  2261. }
  2262. if (mob_id == MOBID_EMPERIUM) {
  2263. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2264. return -1;
  2265. }
  2266. if (mobdb_checkid(mob_id) == 0) {
  2267. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2268. return -1;
  2269. }
  2270. if (number <= 0)
  2271. number = 1;
  2272. if (strlen(name) < 1)
  2273. strcpy(name, "--ja--");
  2274. // 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
  2275. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2276. number = battle_config.atc_spawn_quantity_limit;
  2277. count = 0;
  2278. for (i = 0; i < number; i++) {
  2279. int mx, my;
  2280. if (x <= 0)
  2281. mx = sd->bl.x + (rand() % 11 - 5);
  2282. else
  2283. mx = x;
  2284. if (y <= 0)
  2285. my = sd->bl.y + (rand() % 11 - 5);
  2286. else
  2287. my = y;
  2288. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2289. }
  2290. if (count != 0)
  2291. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2292. else
  2293. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2294. return 0;
  2295. }
  2296. /*==========================================
  2297. *
  2298. *------------------------------------------*/
  2299. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2300. {
  2301. struct mob_data *md;
  2302. int flag;
  2303. nullpo_retr(0, ap);
  2304. nullpo_retr(0, md=(struct mob_data *)bl);
  2305. flag = va_arg(ap, int);
  2306. if (md->guardian_data)
  2307. return 0; //Do not touch WoE mobs!
  2308. if (flag)
  2309. status_zap(bl,md->status.hp, 0);
  2310. else
  2311. status_kill(bl);
  2312. return 1;
  2313. }
  2314. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2315. {
  2316. int map_id;
  2317. char map_name[MAP_NAME_LENGTH];
  2318. if (!sd) return;
  2319. memset(map_name, '\0', sizeof(map_name));
  2320. if (!message || !*message || sscanf(message, "%11s", map_name) < 1)
  2321. map_id = sd->bl.m;
  2322. else {
  2323. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2324. map_id = sd->bl.m;
  2325. }
  2326. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2327. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2328. return;
  2329. }
  2330. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2331. {
  2332. atcommand_killmonster_sub(fd, sd, message, 1);
  2333. return 0;
  2334. }
  2335. /*==========================================
  2336. *
  2337. *------------------------------------------*/
  2338. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2339. {
  2340. atcommand_killmonster_sub(fd, sd, message, 0);
  2341. return 0;
  2342. }
  2343. /*==========================================
  2344. *
  2345. *------------------------------------------*/
  2346. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2347. {
  2348. int i,j, position = 0, refine = 0, current_position, final_refine;
  2349. int count;
  2350. nullpo_retr(-1, sd);
  2351. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2352. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2353. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  2354. sprintf(atcmd_output, "%d: Left Accessory", EQI_ACC_L);
  2355. clif_displaymessage(fd, atcmd_output);
  2356. sprintf(atcmd_output, "%d: Right Accessory", EQI_ACC_R);
  2357. clif_displaymessage(fd, atcmd_output);
  2358. sprintf(atcmd_output, "%d: Shoes", EQI_SHOES);
  2359. clif_displaymessage(fd, atcmd_output);
  2360. sprintf(atcmd_output, "%d: Garment", EQI_GARMENT);
  2361. clif_displaymessage(fd, atcmd_output);
  2362. sprintf(atcmd_output, "%d: Lower Headgear", EQI_HEAD_LOW);
  2363. clif_displaymessage(fd, atcmd_output);
  2364. sprintf(atcmd_output, "%d: Mid Headgear", EQI_HEAD_MID);
  2365. clif_displaymessage(fd, atcmd_output);
  2366. sprintf(atcmd_output, "%d: Top Headgear", EQI_HEAD_TOP);
  2367. clif_displaymessage(fd, atcmd_output);
  2368. sprintf(atcmd_output, "%d: Body Armor", EQI_ARMOR);
  2369. clif_displaymessage(fd, atcmd_output);
  2370. sprintf(atcmd_output, "%d: Left Hand", EQI_HAND_L);
  2371. clif_displaymessage(fd, atcmd_output);
  2372. sprintf(atcmd_output, "%d: Right Hand", EQI_HAND_R);
  2373. clif_displaymessage(fd, atcmd_output);
  2374. return -1;
  2375. }
  2376. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2377. count = 0;
  2378. for (j = 0; j < EQI_MAX-1; j++) {
  2379. if ((i = sd->equip_index[j]) < 0)
  2380. continue;
  2381. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2382. continue;
  2383. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2384. continue;
  2385. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2386. continue;
  2387. if(position && !(sd->status.inventory[i].equip & position))
  2388. continue;
  2389. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2390. if (sd->status.inventory[i].refine != final_refine) {
  2391. sd->status.inventory[i].refine = final_refine;
  2392. current_position = sd->status.inventory[i].equip;
  2393. pc_unequipitem(sd, i, 3);
  2394. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2395. clif_delitem(sd, i, 1);
  2396. clif_additem(sd, i, 1, 0);
  2397. pc_equipitem(sd, i, current_position);
  2398. clif_misceffect(&sd->bl, 3);
  2399. count++;
  2400. }
  2401. }
  2402. if (count == 0)
  2403. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  2404. else if (count == 1)
  2405. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  2406. else {
  2407. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  2408. clif_displaymessage(fd, atcmd_output);
  2409. }
  2410. return 0;
  2411. }
  2412. /*==========================================
  2413. *
  2414. *------------------------------------------*/
  2415. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2416. {
  2417. char item_name[100];
  2418. int item_id, attribute = 0, star = 0;
  2419. int flag = 0;
  2420. struct item_data *item_data;
  2421. struct item tmp_item;
  2422. nullpo_retr(-1, sd);
  2423. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2424. memset(item_name, '\0', sizeof(item_name));
  2425. if (!message || !*message || (
  2426. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2427. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2428. )) {
  2429. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2430. return -1;
  2431. }
  2432. item_id = 0;
  2433. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2434. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2435. {
  2436. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  2437. clif_displaymessage(fd, atcmd_output);
  2438. return -1;
  2439. }
  2440. item_id = item_data->nameid;
  2441. if (itemdb_isequip2(item_data)) {
  2442. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2443. attribute = ATTRIBUTE_NORMAL;
  2444. if (star < MIN_STAR || star > MAX_STAR)
  2445. star = 0;
  2446. memset(&tmp_item, 0, sizeof tmp_item);
  2447. tmp_item.nameid = item_id;
  2448. tmp_item.amount = 1;
  2449. tmp_item.identify = 1;
  2450. tmp_item.card[0] = CARD0_FORGE;
  2451. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2452. ((star*5) << 8) + attribute:0;
  2453. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2454. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2455. clif_produceeffect(sd, 0, item_id);
  2456. clif_misceffect(&sd->bl, 3);
  2457. //Logs (A)dmins items [Lupus]
  2458. if(log_config.enable_logs&0x400)
  2459. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  2460. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2461. clif_additem(sd, 0, 0, flag);
  2462. } else {
  2463. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  2464. clif_displaymessage(fd, atcmd_output);
  2465. return -1;
  2466. }
  2467. return 0;
  2468. }
  2469. /*==========================================
  2470. *
  2471. *------------------------------------------*/
  2472. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2473. {
  2474. int position = 0;
  2475. nullpo_retr(-1, sd);
  2476. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2477. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2478. {
  2479. int i;
  2480. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2481. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2482. {
  2483. if( sd->status.memo_point[i].map )
  2484. 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);
  2485. else
  2486. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2487. clif_displaymessage(sd->fd, atcmd_output);
  2488. }
  2489. return 0;
  2490. }
  2491. if( position < 0 && position >= MAX_MEMOPOINTS )
  2492. {
  2493. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2494. clif_displaymessage(fd, atcmd_output);
  2495. return -1;
  2496. }
  2497. pc_memo(sd, position);
  2498. return 0;
  2499. }
  2500. /*==========================================
  2501. *
  2502. *------------------------------------------*/
  2503. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2504. {
  2505. int y;
  2506. nullpo_retr(-1, sd);
  2507. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2508. for (y = 2; y >= -2; y--) {
  2509. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2510. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2511. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2512. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2513. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2514. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2515. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2516. clif_displaymessage(fd, atcmd_output);
  2517. }
  2518. return 0;
  2519. }
  2520. /*==========================================
  2521. *
  2522. *------------------------------------------*/
  2523. int atcommand_displaystatus(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2524. {
  2525. int i, type, flag;
  2526. nullpo_retr(-1, sd);
  2527. if (!message || !*message || (i = sscanf(message, "%d %d", &type, &flag)) < 1) {
  2528. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag>).");
  2529. return -1;
  2530. }
  2531. if (i == 1) flag = 1;
  2532. clif_status_change(&sd->bl, type, flag);
  2533. return 0;
  2534. }
  2535. /*==========================================
  2536. * @stpoint (Rewritten by [Yor])
  2537. *------------------------------------------*/
  2538. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2539. {
  2540. int point, new_status_point;
  2541. if (!message || !*message || (point = atoi(message)) == 0) {
  2542. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2543. return -1;
  2544. }
  2545. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  2546. new_status_point = USHRT_MAX;
  2547. else
  2548. if (point < 0 && sd->status.status_point < -point)
  2549. new_status_point = 0;
  2550. else
  2551. new_status_point = sd->status.status_point + point;
  2552. if (new_status_point != (int)sd->status.status_point) {
  2553. sd->status.status_point = (unsigned short)new_status_point;
  2554. clif_updatestatus(sd, SP_STATUSPOINT);
  2555. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  2556. } else {
  2557. if (point < 0)
  2558. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2559. else
  2560. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2561. return -1;
  2562. }
  2563. return 0;
  2564. }
  2565. /*==========================================
  2566. * @skpoint (Rewritten by [Yor])
  2567. *------------------------------------------*/
  2568. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2569. {
  2570. int point, new_skill_point;
  2571. nullpo_retr(-1, sd);
  2572. if (!message || !*message || (point = atoi(message)) == 0) {
  2573. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2574. return -1;
  2575. }
  2576. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  2577. new_skill_point = USHRT_MAX;
  2578. else if (point < 0 && sd->status.skill_point < -point)
  2579. new_skill_point = 0;
  2580. else
  2581. new_skill_point = sd->status.skill_point + point;
  2582. if (new_skill_point != (int)sd->status.skill_point) {
  2583. sd->status.skill_point = (unsigned short)new_skill_point;
  2584. clif_updatestatus(sd, SP_SKILLPOINT);
  2585. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  2586. } else {
  2587. if (point < 0)
  2588. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2589. else
  2590. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2591. return -1;
  2592. }
  2593. return 0;
  2594. }
  2595. /*==========================================
  2596. * @zeny (Rewritten by [Yor])
  2597. *------------------------------------------*/
  2598. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2599. {
  2600. int zeny, new_zeny;
  2601. nullpo_retr(-1, sd);
  2602. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2603. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2604. return -1;
  2605. }
  2606. new_zeny = sd->status.zeny + zeny;
  2607. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2608. new_zeny = MAX_ZENY;
  2609. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2610. new_zeny = 0;
  2611. if (new_zeny != sd->status.zeny) {
  2612. sd->status.zeny = new_zeny;
  2613. clif_updatestatus(sd, SP_ZENY);
  2614. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  2615. } else {
  2616. if (zeny < 0)
  2617. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2618. else
  2619. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2620. return -1;
  2621. }
  2622. return 0;
  2623. }
  2624. /*==========================================
  2625. *
  2626. *------------------------------------------*/
  2627. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2628. {
  2629. int i, value = 0, new_value, max;
  2630. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  2631. short* status[6];
  2632. //we don't use direct initialization because it isn't part of the c standard.
  2633. nullpo_retr(-1, sd);
  2634. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2635. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2636. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2637. clif_displaymessage(fd, atcmd_output);
  2638. return -1;
  2639. }
  2640. for (i = 0; param[i] != NULL; i++)
  2641. if (strcmpi(command, param[i]) == 0)
  2642. break;
  2643. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  2644. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2645. clif_displaymessage(fd, atcmd_output);
  2646. return -1;
  2647. }
  2648. status[0] = &sd->status.str;
  2649. status[1] = &sd->status.agi;
  2650. status[2] = &sd->status.vit;
  2651. status[3] = &sd->status.int_;
  2652. status[4] = &sd->status.dex;
  2653. status[5] = &sd->status.luk;
  2654. max = SHRT_MAX;
  2655. new_value = cap_value(*status[i] + value, 1, max);
  2656. if (new_value != (int)*status[i]) {
  2657. *status[i] = new_value;
  2658. clif_updatestatus(sd, SP_STR + i);
  2659. clif_updatestatus(sd, SP_USTR + i);
  2660. status_calc_pc(sd, 0);
  2661. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2662. } else {
  2663. if (value < 0)
  2664. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2665. else
  2666. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2667. return -1;
  2668. }
  2669. return 0;
  2670. }
  2671. /*==========================================
  2672. * Stat all by fritz (rewritten by [Yor])
  2673. *------------------------------------------*/
  2674. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2675. {
  2676. int index, count, value, max, new_value;
  2677. short* status[6];
  2678. //we don't use direct initialization because it isn't part of the c standard.
  2679. nullpo_retr(-1, sd);
  2680. status[0] = &sd->status.str;
  2681. status[1] = &sd->status.agi;
  2682. status[2] = &sd->status.vit;
  2683. status[3] = &sd->status.int_;
  2684. status[4] = &sd->status.dex;
  2685. status[5] = &sd->status.luk;
  2686. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2687. value = pc_maxparameter(sd);
  2688. max = pc_maxparameter(sd);
  2689. } else {
  2690. max = SHRT_MAX;
  2691. }
  2692. count = 0;
  2693. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2694. if (value > 0 && *status[index] > max - value)
  2695. new_value = max;
  2696. else if (value < 0 && *status[index] <= -value)
  2697. new_value = 1;
  2698. else
  2699. new_value = *status[index] +value;
  2700. if (new_value != (int)*status[index]) {
  2701. *status[index] = new_value;
  2702. clif_updatestatus(sd, SP_STR + index);
  2703. clif_updatestatus(sd, SP_USTR + index);
  2704. count++;
  2705. }
  2706. }
  2707. if (count > 0) { // if at least 1 stat modified
  2708. status_calc_pc(sd, 0);
  2709. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2710. } else {
  2711. if (value < 0)
  2712. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  2713. else
  2714. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  2715. return -1;
  2716. }
  2717. return 0;
  2718. }
  2719. /*==========================================
  2720. *
  2721. *------------------------------------------*/
  2722. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2723. {
  2724. int level = 0;
  2725. short added_level;
  2726. struct guild *guild_info;
  2727. nullpo_retr(-1, sd);
  2728. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2729. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2730. return -1;
  2731. }
  2732. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2733. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2734. return -1;
  2735. }
  2736. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2737. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2738. // return -1;
  2739. //}
  2740. added_level = (short)level;
  2741. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2742. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2743. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2744. added_level = 1 - guild_info->guild_lv;
  2745. if (added_level != 0) {
  2746. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  2747. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2748. } else {
  2749. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2750. return -1;
  2751. }
  2752. return 0;
  2753. }
  2754. /*==========================================
  2755. *
  2756. *------------------------------------------*/
  2757. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2758. {
  2759. struct item_data *item_data;
  2760. int id, pet_id;
  2761. nullpo_retr(-1, sd);
  2762. if (!message || !*message) {
  2763. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2764. return -1;
  2765. }
  2766. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2767. id = item_data->nameid;
  2768. else
  2769. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2770. ;
  2771. else
  2772. id = atoi(message);
  2773. pet_id = search_petDB_index(id, PET_CLASS);
  2774. if (pet_id < 0)
  2775. pet_id = search_petDB_index(id, PET_EGG);
  2776. if (pet_id >= 0) {
  2777. sd->catch_target_class = pet_db[pet_id].class_;
  2778. intif_create_pet(
  2779. sd->status.account_id, sd->status.char_id,
  2780. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2781. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2782. 100, 0, 1, pet_db[pet_id].jname);
  2783. } else {
  2784. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2785. return -1;
  2786. }
  2787. return 0;
  2788. }
  2789. /*==========================================
  2790. *
  2791. *------------------------------------------*/
  2792. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2793. {
  2794. nullpo_retr(-1, sd);
  2795. if (sd->status.pet_id <= 0)
  2796. clif_sendegg(sd);
  2797. else {
  2798. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2799. return -1;
  2800. }
  2801. return 0;
  2802. }
  2803. /*==========================================
  2804. *
  2805. *------------------------------------------*/
  2806. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2807. {
  2808. int friendly;
  2809. struct pet_data *pd;
  2810. nullpo_retr(-1, sd);
  2811. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2812. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2813. return -1;
  2814. }
  2815. pd = sd->pd;
  2816. if (!pd) {
  2817. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2818. return -1;
  2819. }
  2820. if (friendly < 0 || friendly > 1000)
  2821. {
  2822. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2823. return -1;
  2824. }
  2825. if (friendly == pd->pet.intimate) {
  2826. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  2827. return -1;
  2828. }
  2829. pd->pet.intimate = friendly;
  2830. clif_send_petstatus(sd);
  2831. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  2832. return 0;
  2833. }
  2834. /*==========================================
  2835. *
  2836. *------------------------------------------*/
  2837. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2838. {
  2839. int hungry;
  2840. struct pet_data *pd;
  2841. nullpo_retr(-1, sd);
  2842. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2843. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2844. return -1;
  2845. }
  2846. pd = sd->pd;
  2847. if (!sd->status.pet_id || !pd) {
  2848. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2849. return -1;
  2850. }
  2851. if (hungry < 0 || hungry > 100) {
  2852. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2853. return -1;
  2854. }
  2855. if (hungry == pd->pet.hungry) {
  2856. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  2857. return -1;
  2858. }
  2859. pd->pet.hungry = hungry;
  2860. clif_send_petstatus(sd);
  2861. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  2862. return 0;
  2863. }
  2864. /*==========================================
  2865. *
  2866. *------------------------------------------*/
  2867. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2868. {
  2869. struct pet_data *pd;
  2870. nullpo_retr(-1, sd);
  2871. if (!sd->status.pet_id || !sd->pd) {
  2872. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2873. return -1;
  2874. }
  2875. pd = sd->pd;
  2876. if (!pd->pet.rename_flag) {
  2877. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2878. return -1;
  2879. }
  2880. pd->pet.rename_flag = 0;
  2881. intif_save_petdata(sd->status.account_id, &pd->pet);
  2882. clif_send_petstatus(sd);
  2883. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2884. return 0;
  2885. }
  2886. /*==========================================
  2887. *
  2888. *------------------------------------------*/
  2889. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2890. {
  2891. struct map_session_data *pl_sd = NULL;
  2892. nullpo_retr(-1, sd);
  2893. if (!message || !*message) {
  2894. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2895. return -1;
  2896. }
  2897. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2898. {
  2899. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2900. return -1;
  2901. }
  2902. if (pl_sd == sd)
  2903. {
  2904. clif_displaymessage(fd, "You are already where you are...");
  2905. return -1;
  2906. }
  2907. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2908. {
  2909. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2910. return -1;
  2911. }
  2912. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2913. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  2914. return -1;
  2915. }
  2916. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2917. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2918. return -1;
  2919. }
  2920. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  2921. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2922. clif_displaymessage(fd, atcmd_output);
  2923. return 0;
  2924. }
  2925. /*==========================================
  2926. * charblock command (usage: charblock <player_name>)
  2927. * This command do a definitiv ban on a player
  2928. *------------------------------------------*/
  2929. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2930. {
  2931. nullpo_retr(-1, sd);
  2932. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2933. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2934. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2935. return -1;
  2936. }
  2937. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2938. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2939. return 0;
  2940. }
  2941. /*==========================================
  2942. * charban command (usage: charban <time> <player_name>)
  2943. * This command do a limited ban on a player
  2944. * Time is done as follows:
  2945. * Adjustment value (-1, 1, +1, etc...)
  2946. * Modified element:
  2947. * a or y: year
  2948. * m: month
  2949. * j or d: day
  2950. * h: hour
  2951. * mn: minute
  2952. * s: second
  2953. * <example> @ban +1m-2mn1s-6y test_player
  2954. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2955. *------------------------------------------*/
  2956. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2957. {
  2958. char * modif_p;
  2959. int year, month, day, hour, minute, second, value;
  2960. nullpo_retr(-1, sd);
  2961. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2962. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2963. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2964. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2965. return -1;
  2966. }
  2967. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2968. modif_p = atcmd_output;
  2969. year = month = day = hour = minute = second = 0;
  2970. while (modif_p[0] != '\0') {
  2971. value = atoi(modif_p);
  2972. if (value == 0)
  2973. modif_p++;
  2974. else {
  2975. if (modif_p[0] == '-' || modif_p[0] == '+')
  2976. modif_p++;
  2977. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2978. modif_p++;
  2979. if (modif_p[0] == 's') {
  2980. second = value;
  2981. modif_p++;
  2982. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  2983. minute = value;
  2984. modif_p = modif_p + 2;
  2985. } else if (modif_p[0] == 'h') {
  2986. hour = value;
  2987. modif_p++;
  2988. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2989. day = value;
  2990. modif_p++;
  2991. } else if (modif_p[0] == 'm') {
  2992. month = value;
  2993. modif_p++;
  2994. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2995. year = value;
  2996. modif_p++;
  2997. } else if (modif_p[0] != '\0') {
  2998. modif_p++;
  2999. }
  3000. }
  3001. }
  3002. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3003. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3004. return -1;
  3005. }
  3006. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3007. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3008. return 0;
  3009. }
  3010. /*==========================================
  3011. * charunblock command (usage: charunblock <player_name>)
  3012. *------------------------------------------*/
  3013. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3014. {
  3015. nullpo_retr(-1, sd);
  3016. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3017. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3018. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3019. return -1;
  3020. }
  3021. // send answer to login server via char-server
  3022. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3023. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3024. return 0;
  3025. }
  3026. /*==========================================
  3027. * charunban command (usage: charunban <player_name>)
  3028. *------------------------------------------*/
  3029. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3030. {
  3031. nullpo_retr(-1, sd);
  3032. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3033. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3034. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3035. return -1;
  3036. }
  3037. // send answer to login server via char-server
  3038. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3039. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3040. return 0;
  3041. }
  3042. /*==========================================
  3043. *
  3044. *------------------------------------------*/
  3045. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3046. {
  3047. nullpo_retr(-1, sd);
  3048. if (night_flag != 1) {
  3049. map_night_timer(night_timer_tid, 0, 0, 1);
  3050. } else {
  3051. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  3052. return -1;
  3053. }
  3054. return 0;
  3055. }
  3056. /*==========================================
  3057. *
  3058. *------------------------------------------*/
  3059. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3060. {
  3061. nullpo_retr(-1, sd);
  3062. if (night_flag != 0) {
  3063. map_day_timer(day_timer_tid, 0, 0, 1);
  3064. } else {
  3065. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  3066. return -1;
  3067. }
  3068. return 0;
  3069. }
  3070. /*==========================================
  3071. *
  3072. *------------------------------------------*/
  3073. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3074. {
  3075. struct map_session_data *pl_sd, **pl_allsd;
  3076. int i, users;
  3077. nullpo_retr(-1, sd);
  3078. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  3079. pl_allsd = map_getallusers(&users);
  3080. for(i = 0; i < users; i++) {
  3081. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  3082. status_kill(&pl_sd->bl);
  3083. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3084. }
  3085. }
  3086. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3087. return 0;
  3088. }
  3089. /*==========================================
  3090. *
  3091. *------------------------------------------*/
  3092. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3093. {
  3094. struct map_session_data *pl_sd, **pl_allsd;
  3095. int i, users;
  3096. nullpo_retr(-1, sd);
  3097. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  3098. pl_allsd = map_getallusers(&users);
  3099. for (i = 0; i < users; i++) {
  3100. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  3101. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  3102. {
  3103. status_kill(&pl_sd->bl);
  3104. // clif_specialeffect(&pl_sd->bl,450,1);
  3105. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3106. }
  3107. }
  3108. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3109. return 0;
  3110. }
  3111. /*==========================================
  3112. *
  3113. *------------------------------------------*/
  3114. static void atcommand_raise_sub(struct map_session_data* sd)
  3115. {
  3116. if (!sd->state.auth || !status_isdead(&sd->bl))
  3117. return;
  3118. if(!status_revive(&sd->bl, 100, 100))
  3119. return;
  3120. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3121. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3122. }
  3123. /*==========================================
  3124. *
  3125. *------------------------------------------*/
  3126. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3127. {
  3128. int i, users;
  3129. struct map_session_data **all_sd;
  3130. nullpo_retr(-1, sd);
  3131. all_sd = map_getallusers(&users);
  3132. for (i = 0; i < users; i++) {
  3133. atcommand_raise_sub(all_sd[i]);
  3134. }
  3135. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3136. return 0;
  3137. }
  3138. /*==========================================
  3139. *
  3140. *------------------------------------------*/
  3141. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3142. {
  3143. struct map_session_data **pl_allsd;
  3144. int i, users;
  3145. nullpo_retr(-1, sd);
  3146. pl_allsd = map_getallusers(&users);
  3147. for (i = 0; i < users; i++) {
  3148. if (sd->bl.m == pl_allsd[i]->bl.m)
  3149. atcommand_raise_sub(pl_allsd[i]);
  3150. }
  3151. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3152. return 0;
  3153. }
  3154. /*==========================================
  3155. *
  3156. *------------------------------------------*/
  3157. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3158. {
  3159. struct map_session_data *pl_sd;
  3160. nullpo_retr(-1, sd);
  3161. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3162. if (!message || !*message) {
  3163. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3164. return -1;
  3165. }
  3166. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3167. {
  3168. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3169. return -1;
  3170. }
  3171. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3172. {
  3173. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3174. return -1;
  3175. }
  3176. clif_GM_kick(sd, pl_sd, 1);
  3177. return 0;
  3178. }
  3179. /*==========================================
  3180. *
  3181. *------------------------------------------*/
  3182. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3183. {
  3184. struct map_session_data *pl_sd, **pl_allsd;
  3185. int i, users;
  3186. nullpo_retr(-1, sd);
  3187. pl_allsd = map_getallusers(&users);
  3188. for (i = 0; i < users; i++) {
  3189. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3190. if (sd->status.account_id != pl_sd->status.account_id)
  3191. clif_GM_kick(sd, pl_sd, 0);
  3192. }
  3193. }
  3194. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3195. return 0;
  3196. }
  3197. /*==========================================
  3198. *
  3199. *------------------------------------------*/
  3200. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3201. {
  3202. nullpo_retr(-1, sd);
  3203. pc_allskillup(sd); // all skills
  3204. sd->status.skill_point = 0; // 0 skill points
  3205. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3206. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  3207. return 0;
  3208. }
  3209. /*==========================================
  3210. *
  3211. *------------------------------------------*/
  3212. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3213. {
  3214. int skill_id;
  3215. nullpo_retr(-1, sd);
  3216. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3217. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3218. return -1;
  3219. }
  3220. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3221. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3222. return -1;
  3223. }
  3224. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3225. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3226. return -1;
  3227. }
  3228. if (pc_checkskill(sd, skill_id) > 0) {
  3229. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3230. return -1;
  3231. }
  3232. pc_skill(sd, skill_id, 1, 0);
  3233. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3234. return 0;
  3235. }
  3236. /*==========================================
  3237. *
  3238. *------------------------------------------*/
  3239. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3240. {
  3241. int skill_id;
  3242. nullpo_retr(-1, sd);
  3243. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3244. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3245. return -1;
  3246. }
  3247. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3248. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3249. return -1;
  3250. }
  3251. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3252. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3253. return -1;
  3254. }
  3255. if (pc_checkskill(sd, skill_id) == 0) {
  3256. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3257. return -1;
  3258. }
  3259. sd->status.skill[skill_id].lv = 0;
  3260. sd->status.skill[skill_id].flag = 0;
  3261. clif_skillinfoblock(sd);
  3262. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3263. return 0;
  3264. }
  3265. /*==========================================
  3266. *
  3267. *------------------------------------------*/
  3268. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3269. {
  3270. int number;
  3271. nullpo_retr(-1, sd);
  3272. if (!message || !*message || (number = atoi(message)) < 0) {
  3273. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  3274. return -1;
  3275. }
  3276. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  3277. if (number > 500)
  3278. number = 500;
  3279. if (number >= 0 && number <= 0x7FFF) {
  3280. if (sd->spiritball != number || number > 499) {
  3281. if (sd->spiritball > 0)
  3282. pc_delspiritball(sd, sd->spiritball, 1);
  3283. sd->spiritball = number;
  3284. clif_spiritball(sd);
  3285. // no message, player can look the difference
  3286. if (number > 1000)
  3287. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  3288. } else {
  3289. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  3290. return -1;
  3291. }
  3292. } else {
  3293. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3294. return -1;
  3295. }
  3296. return 0;
  3297. }
  3298. /*==========================================
  3299. *
  3300. *------------------------------------------*/
  3301. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3302. {
  3303. char party[NAME_LENGTH];
  3304. nullpo_retr(-1, sd);
  3305. memset(party, '\0', sizeof(party));
  3306. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3307. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3308. return -1;
  3309. }
  3310. party_create(sd, party, 0, 0);
  3311. return 0;
  3312. }
  3313. /*==========================================
  3314. *
  3315. *------------------------------------------*/
  3316. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3317. {
  3318. char guild[NAME_LENGTH];
  3319. int prev;
  3320. nullpo_retr(-1, sd);
  3321. memset(guild, '\0', sizeof(guild));
  3322. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3323. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3324. return -1;
  3325. }
  3326. prev = battle_config.guild_emperium_check;
  3327. battle_config.guild_emperium_check = 0;
  3328. guild_create(sd, guild);
  3329. battle_config.guild_emperium_check = prev;
  3330. return 0;
  3331. }
  3332. /*==========================================
  3333. *
  3334. *------------------------------------------*/
  3335. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3336. {
  3337. nullpo_retr(-1, sd);
  3338. if (agit_flag == 1) {
  3339. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  3340. return -1;
  3341. }
  3342. agit_flag = 1;
  3343. guild_agit_start();
  3344. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  3345. return 0;
  3346. }
  3347. /*==========================================
  3348. *
  3349. *------------------------------------------*/
  3350. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3351. {
  3352. nullpo_retr(-1, sd);
  3353. if (agit_flag == 0) {
  3354. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  3355. return -1;
  3356. }
  3357. agit_flag = 0;
  3358. guild_agit_end();
  3359. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  3360. return 0;
  3361. }
  3362. /*==========================================
  3363. * @mapexit - shuts down the map server
  3364. *------------------------------------------*/
  3365. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3366. {
  3367. struct map_session_data *pl_sd, **pl_allsd;
  3368. int i, users;
  3369. nullpo_retr(-1, sd);
  3370. pl_allsd = map_getallusers(&users);
  3371. for (i = 0; i < users; i++) {
  3372. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  3373. clif_GM_kick(sd, pl_sd, 0);
  3374. }
  3375. clif_GM_kick(sd, sd, 0);
  3376. flush_fifos();
  3377. runflag = 0;
  3378. return 0;
  3379. }
  3380. /*==========================================
  3381. * idsearch <part_of_name>: revrited by [Yor]
  3382. *------------------------------------------*/
  3383. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3384. {
  3385. char item_name[100];
  3386. unsigned int i, match;
  3387. struct item_data *item_array[MAX_SEARCH];
  3388. nullpo_retr(-1, sd);
  3389. memset(item_name, '\0', sizeof(item_name));
  3390. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3391. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3392. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3393. return -1;
  3394. }
  3395. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3396. clif_displaymessage(fd, atcmd_output);
  3397. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3398. if (match > MAX_SEARCH) {
  3399. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3400. clif_displaymessage(fd, atcmd_output);
  3401. match = MAX_SEARCH;
  3402. }
  3403. for(i = 0; i < match; i++) {
  3404. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3405. clif_displaymessage(fd, atcmd_output);
  3406. }
  3407. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3408. clif_displaymessage(fd, atcmd_output);
  3409. return 0;
  3410. }
  3411. /*==========================================
  3412. * Recall All Characters Online To Your Location
  3413. *------------------------------------------*/
  3414. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3415. {
  3416. struct map_session_data *pl_sd, **pl_allsd;
  3417. int i;
  3418. int count, users;
  3419. nullpo_retr(-1, sd);
  3420. memset(atcmd_output, '\0', sizeof(atcmd_output));
  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. count = 0;
  3426. pl_allsd = map_getallusers(&users);
  3427. for (i = 0; i < users; i++) {
  3428. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  3429. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3430. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3431. count++;
  3432. else {
  3433. if (pc_isdead(pl_sd)) { //Wake them up
  3434. pc_setstand(pl_sd);
  3435. pc_setrestartvalue(pl_sd,1);
  3436. }
  3437. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3438. }
  3439. }
  3440. }
  3441. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3442. if (count) {
  3443. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3444. clif_displaymessage(fd, atcmd_output);
  3445. }
  3446. return 0;
  3447. }
  3448. /*==========================================
  3449. * Recall online characters of a guild to your location
  3450. *------------------------------------------*/
  3451. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3452. {
  3453. struct map_session_data *pl_sd, **pl_allsd;
  3454. int i, users, count;
  3455. char guild_name[NAME_LENGTH];
  3456. struct guild *g;
  3457. nullpo_retr(-1, sd);
  3458. memset(guild_name, '\0', sizeof(guild_name));
  3459. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3460. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3461. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3462. return -1;
  3463. }
  3464. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3465. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3466. return -1;
  3467. }
  3468. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3469. (g = guild_search(atoi(message))) != NULL) {
  3470. count = 0;
  3471. pl_allsd = map_getallusers(&users);
  3472. for (i = 0; i < users; i++) {
  3473. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  3474. pl_sd->status.guild_id == g->guild_id) {
  3475. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3476. continue; //Skip GMs greater than you.
  3477. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3478. count++;
  3479. else
  3480. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3481. }
  3482. }
  3483. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  3484. clif_displaymessage(fd, atcmd_output);
  3485. if (count) {
  3486. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3487. clif_displaymessage(fd, atcmd_output);
  3488. }
  3489. } else {
  3490. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3491. return -1;
  3492. }
  3493. return 0;
  3494. }
  3495. /*==========================================
  3496. * Recall online characters of a party to your location
  3497. *------------------------------------------*/
  3498. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3499. {
  3500. int i;
  3501. struct map_session_data *pl_sd, **pl_allsd;
  3502. char party_name[NAME_LENGTH];
  3503. struct party_data *p;
  3504. int count, users;
  3505. nullpo_retr(-1, sd);
  3506. memset(party_name, '\0', sizeof(party_name));
  3507. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3508. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3509. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3510. return -1;
  3511. }
  3512. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3513. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3514. return -1;
  3515. }
  3516. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3517. (p = party_search(atoi(message))) != NULL) {
  3518. count = 0;
  3519. pl_allsd = map_getallusers(&users);
  3520. for (i = 0; i < users; i++) {
  3521. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  3522. pl_sd->status.party_id == p->party.party_id) {
  3523. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3524. continue; //Skip GMs greater than you.
  3525. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3526. count++;
  3527. else
  3528. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3529. }
  3530. }
  3531. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  3532. clif_displaymessage(fd, atcmd_output);
  3533. if (count) {
  3534. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3535. clif_displaymessage(fd, atcmd_output);
  3536. }
  3537. } else {
  3538. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3539. return -1;
  3540. }
  3541. return 0;
  3542. }
  3543. /*==========================================
  3544. *
  3545. *------------------------------------------*/
  3546. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3547. {
  3548. nullpo_retr(-1, sd);
  3549. itemdb_reload();
  3550. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  3551. return 0;
  3552. }
  3553. /*==========================================
  3554. *
  3555. *------------------------------------------*/
  3556. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3557. {
  3558. nullpo_retr(-1, sd);
  3559. mob_reload();
  3560. read_petdb();
  3561. merc_reload();
  3562. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  3563. return 0;
  3564. }
  3565. /*==========================================
  3566. *
  3567. *------------------------------------------*/
  3568. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3569. {
  3570. nullpo_retr(-1, sd);
  3571. skill_reload();
  3572. merc_skill_reload();
  3573. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  3574. return 0;
  3575. }
  3576. /*==========================================
  3577. * @reloadatcommand - reloads atcommand_athena.conf
  3578. *------------------------------------------*/
  3579. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3580. {
  3581. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  3582. clif_displaymessage(fd, msg_txt(254));
  3583. return 0;
  3584. }
  3585. /*==========================================
  3586. * @reloadbattleconf - reloads battle_athena.conf
  3587. *------------------------------------------*/
  3588. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3589. {
  3590. struct Battle_Config prev_config;
  3591. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3592. battle_config_read(BATTLE_CONF_FILENAME);
  3593. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3594. || prev_config.item_rate_common != battle_config.item_rate_common
  3595. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3596. || prev_config.item_rate_card != battle_config.item_rate_card
  3597. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3598. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3599. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3600. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3601. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3602. || prev_config.item_rate_use != battle_config.item_rate_use
  3603. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3604. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3605. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3606. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3607. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3608. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3609. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3610. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3611. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3612. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3613. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3614. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3615. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3616. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3617. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3618. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3619. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3620. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3621. )
  3622. { //Drop rates changed.
  3623. mob_reload(); //Needed as well so rate changes take effect.
  3624. #ifndef TXT_ONLY
  3625. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3626. #endif
  3627. }
  3628. clif_displaymessage(fd, msg_txt(255));
  3629. return 0;
  3630. }
  3631. /*==========================================
  3632. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3633. *------------------------------------------*/
  3634. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3635. {
  3636. status_readdb();
  3637. clif_displaymessage(fd, msg_txt(256));
  3638. return 0;
  3639. }
  3640. /*==========================================
  3641. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3642. *------------------------------------------*/
  3643. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3644. {
  3645. pc_readdb();
  3646. clif_displaymessage(fd, msg_txt(257));
  3647. return 0;
  3648. }
  3649. /*==========================================
  3650. * @reloadmotd - reloads motd.txt
  3651. *------------------------------------------*/
  3652. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3653. {
  3654. pc_read_motd();
  3655. clif_displaymessage(fd, msg_txt(268));
  3656. return 0;
  3657. }
  3658. /*==========================================
  3659. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3660. *------------------------------------------*/
  3661. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3662. {
  3663. nullpo_retr(-1, sd);
  3664. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3665. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3666. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3667. flush_fifos();
  3668. script_reload();
  3669. npc_reload();
  3670. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  3671. return 0;
  3672. }
  3673. /*==========================================
  3674. * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database)
  3675. *------------------------------------------*/
  3676. int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3677. {
  3678. nullpo_retr(-1, sd);
  3679. chrif_reloadGMdb();
  3680. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  3681. return 0;
  3682. }
  3683. /*==========================================
  3684. * @mapinfo <map name> [0-3] by MC_Cameri
  3685. * => Shows information about the map [map name]
  3686. * 0 = no additional information
  3687. * 1 = Show users in that map and their location
  3688. * 2 = Shows NPCs in that map
  3689. * 3 = Shows the shops/chats in that map (not implemented)
  3690. *------------------------------------------*/
  3691. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3692. {
  3693. struct map_session_data *pl_sd, **pl_allsd;
  3694. struct npc_data *nd = NULL;
  3695. struct chat_data *cd = NULL;
  3696. char direction[12];
  3697. int m_id, i, chat_num, users, list = 0;
  3698. unsigned short m_index;
  3699. nullpo_retr(-1, sd);
  3700. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3701. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3702. memset(direction, '\0', sizeof(direction));
  3703. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  3704. if (list < 0 || list > 3) {
  3705. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3706. return -1;
  3707. }
  3708. if (atcmd_player_name[0] == '\0') {
  3709. safestrncpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3710. m_id = map_mapindex2mapid(sd->mapindex);
  3711. } else {
  3712. m_id = map_mapname2mapid(atcmd_player_name);
  3713. }
  3714. if (m_id < 0) {
  3715. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3716. return -1;
  3717. }
  3718. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  3719. clif_displaymessage(fd, "------ Map Info ------");
  3720. chat_num = 0;
  3721. pl_allsd = map_getallusers(&users);
  3722. for (i = 0; i < users; i++) {
  3723. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  3724. chat_num++;
  3725. }
  3726. }
  3727. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
  3728. clif_displaymessage(fd, atcmd_output);
  3729. clif_displaymessage(fd, "------ Map Flags ------");
  3730. strcpy(atcmd_output,"PvP Flags: ");
  3731. if (map[m_id].flag.pvp)
  3732. strcat(atcmd_output, "Pvp ON | ");
  3733. if (map[m_id].flag.pvp_noguild)
  3734. strcat(atcmd_output, "NoGuild | ");
  3735. if (map[m_id].flag.pvp_noparty)
  3736. strcat(atcmd_output, "NoParty | ");
  3737. if (map[m_id].flag.pvp_nightmaredrop)
  3738. strcat(atcmd_output, "NightmareDrop | ");
  3739. if (map[m_id].flag.pvp_nocalcrank)
  3740. strcat(atcmd_output, "NoCalcRank | ");
  3741. clif_displaymessage(fd, atcmd_output);
  3742. strcpy(atcmd_output,"GvG Flags: ");
  3743. if (map[m_id].flag.gvg)
  3744. strcat(atcmd_output, "GvG ON | ");
  3745. if (map[m_id].flag.gvg_dungeon)
  3746. strcat(atcmd_output, "GvG Dungeon | ");
  3747. if (map[m_id].flag.gvg_castle)
  3748. strcat(atcmd_output, "GvG Castle | ");
  3749. if (map[m_id].flag.gvg_noparty)
  3750. strcat(atcmd_output, "NoParty | ");
  3751. clif_displaymessage(fd, atcmd_output);
  3752. strcpy(atcmd_output,"Teleport Flags: ");
  3753. if (map[m_id].flag.noteleport)
  3754. strcat(atcmd_output, "NoTeleport | ");
  3755. if (map[m_id].flag.monster_noteleport)
  3756. strcat(atcmd_output, "Monster NoTeleport | ");
  3757. if (map[m_id].flag.nowarp)
  3758. strcat(atcmd_output, "NoWarp | ");
  3759. if (map[m_id].flag.nowarpto)
  3760. strcat(atcmd_output, "NoWarpTo | ");
  3761. if (map[m_id].flag.noreturn)
  3762. strcat(atcmd_output, "NoReturn | ");
  3763. if (map[m_id].flag.nogo)
  3764. strcat(atcmd_output, "NoGo | ");
  3765. if (map[m_id].flag.nomemo)
  3766. strcat(atcmd_output, "NoMemo | ");
  3767. clif_displaymessage(fd, atcmd_output);
  3768. 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");
  3769. clif_displaymessage(fd, atcmd_output);
  3770. if (map[m_id].flag.nosave) {
  3771. if (!map[m_id].save.map)
  3772. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3773. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3774. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3775. else
  3776. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3777. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3778. clif_displaymessage(fd, atcmd_output);
  3779. }
  3780. strcpy(atcmd_output,"Weather Flags: ");
  3781. if (map[m_id].flag.snow)
  3782. strcat(atcmd_output, "Snow | ");
  3783. if (map[m_id].flag.fog)
  3784. strcat(atcmd_output, "Fog | ");
  3785. if (map[m_id].flag.sakura)
  3786. strcat(atcmd_output, "Sakura | ");
  3787. if (map[m_id].flag.clouds)
  3788. strcat(atcmd_output, "Clouds | ");
  3789. if (map[m_id].flag.clouds2)
  3790. strcat(atcmd_output, "Clouds2 | ");
  3791. if (map[m_id].flag.fireworks)
  3792. strcat(atcmd_output, "Fireworks | ");
  3793. if (map[m_id].flag.leaves)
  3794. strcat(atcmd_output, "Leaves | ");
  3795. if (map[m_id].flag.rain)
  3796. strcat(atcmd_output, "Rain | ");
  3797. if (map[m_id].flag.indoors)
  3798. strcat(atcmd_output, "Indoors | ");
  3799. if (map[m_id].flag.nightenabled)
  3800. strcat(atcmd_output, "Displays Night | ");
  3801. clif_displaymessage(fd, atcmd_output);
  3802. strcpy(atcmd_output,"Other Flags: ");
  3803. if (map[m_id].flag.nobranch)
  3804. strcat(atcmd_output, "NoBranch | ");
  3805. if (map[m_id].flag.notrade)
  3806. strcat(atcmd_output, "NoTrade | ");
  3807. if (map[m_id].flag.novending)
  3808. strcat(atcmd_output, "NoVending | ");
  3809. if (map[m_id].flag.nodrop)
  3810. strcat(atcmd_output, "NoDrop | ");
  3811. if (map[m_id].flag.noskill)
  3812. strcat(atcmd_output, "NoSkill | ");
  3813. if (map[m_id].flag.noicewall)
  3814. strcat(atcmd_output, "NoIcewall | ");
  3815. clif_displaymessage(fd, atcmd_output);
  3816. strcpy(atcmd_output,"Other Flags: ");
  3817. if (map[m_id].nocommand)
  3818. strcat(atcmd_output, "NoCommand | ");
  3819. if (map[m_id].flag.nobaseexp)
  3820. strcat(atcmd_output, "NoBaseEXP | ");
  3821. if (map[m_id].flag.nojobexp)
  3822. strcat(atcmd_output, "NoJobEXP | ");
  3823. if (map[m_id].flag.nomobloot)
  3824. strcat(atcmd_output, "NoMobLoot | ");
  3825. if (map[m_id].flag.nomvploot)
  3826. strcat(atcmd_output, "NoMVPLoot | ");
  3827. if (map[m_id].flag.partylock)
  3828. strcat(atcmd_output, "PartyLock | ");
  3829. if (map[m_id].flag.guildlock)
  3830. strcat(atcmd_output, "GuildLock | ");
  3831. clif_displaymessage(fd, atcmd_output);
  3832. switch (list) {
  3833. case 0:
  3834. // Do nothing. It's list 0, no additional display.
  3835. break;
  3836. case 1:
  3837. clif_displaymessage(fd, "----- Players in Map -----");
  3838. for (i = 0; i < users; i++) {
  3839. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  3840. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3841. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3842. clif_displaymessage(fd, atcmd_output);
  3843. }
  3844. }
  3845. break;
  3846. case 2:
  3847. clif_displaymessage(fd, "----- NPCs in Map -----");
  3848. for (i = 0; i < map[m_id].npc_num;) {
  3849. nd = map[m_id].npc[i];
  3850. switch(nd->ud.dir) {
  3851. case 0: strcpy(direction, "North"); break;
  3852. case 1: strcpy(direction, "North West"); break;
  3853. case 2: strcpy(direction, "West"); break;
  3854. case 3: strcpy(direction, "South West"); break;
  3855. case 4: strcpy(direction, "South"); break;
  3856. case 5: strcpy(direction, "South East"); break;
  3857. case 6: strcpy(direction, "East"); break;
  3858. case 7: strcpy(direction, "North East"); break;
  3859. case 9: strcpy(direction, "North"); break;
  3860. default: strcpy(direction, "Unknown"); break;
  3861. }
  3862. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3863. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3864. clif_displaymessage(fd, atcmd_output);
  3865. }
  3866. break;
  3867. case 3:
  3868. clif_displaymessage(fd, "----- Chats in Map -----");
  3869. for (i = 0; i < users; i++) {
  3870. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  3871. pl_sd->mapindex == m_index &&
  3872. cd->usersd[0] == pl_sd) {
  3873. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  3874. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3875. clif_displaymessage(fd, atcmd_output);
  3876. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3877. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3878. clif_displaymessage(fd, atcmd_output);
  3879. }
  3880. }
  3881. break;
  3882. default: // normally impossible to arrive here
  3883. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3884. return -1;
  3885. break;
  3886. }
  3887. return 0;
  3888. }
  3889. /*==========================================
  3890. *
  3891. *------------------------------------------*/
  3892. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3893. {
  3894. nullpo_retr(-1, sd);
  3895. if (!pc_isriding(sd)) { // if actually no peco
  3896. if (!pc_checkskill(sd, KN_RIDING))
  3897. {
  3898. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  3899. return -1;
  3900. }
  3901. if (sd->disguise)
  3902. {
  3903. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco while in disguise.
  3904. return -1;
  3905. }
  3906. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3907. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  3908. } else { //Dismount
  3909. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3910. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  3911. }
  3912. return 0;
  3913. }
  3914. /*==========================================
  3915. *Spy Commands by Syrus22
  3916. *------------------------------------------*/
  3917. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3918. {
  3919. char guild_name[NAME_LENGTH];
  3920. struct guild *g;
  3921. nullpo_retr(-1, sd);
  3922. memset(guild_name, '\0', sizeof(guild_name));
  3923. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3924. if (!enable_spy)
  3925. {
  3926. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3927. return -1;
  3928. }
  3929. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3930. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3931. return -1;
  3932. }
  3933. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3934. (g = guild_search(atoi(message))) != NULL) {
  3935. if (sd->guildspy == g->guild_id) {
  3936. sd->guildspy = 0;
  3937. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3938. clif_displaymessage(fd, atcmd_output);
  3939. } else {
  3940. sd->guildspy = g->guild_id;
  3941. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3942. clif_displaymessage(fd, atcmd_output);
  3943. }
  3944. } else {
  3945. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3946. return -1;
  3947. }
  3948. return 0;
  3949. }
  3950. /*==========================================
  3951. *
  3952. *------------------------------------------*/
  3953. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3954. {
  3955. char party_name[NAME_LENGTH];
  3956. struct party_data *p;
  3957. nullpo_retr(-1, sd);
  3958. memset(party_name, '\0', sizeof(party_name));
  3959. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3960. if (!enable_spy)
  3961. {
  3962. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3963. return -1;
  3964. }
  3965. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3966. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3967. return -1;
  3968. }
  3969. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3970. (p = party_search(atoi(message))) != NULL) {
  3971. if (sd->partyspy == p->party.party_id) {
  3972. sd->partyspy = 0;
  3973. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3974. clif_displaymessage(fd, atcmd_output);
  3975. } else {
  3976. sd->partyspy = p->party.party_id;
  3977. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3978. clif_displaymessage(fd, atcmd_output);
  3979. }
  3980. } else {
  3981. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3982. return -1;
  3983. }
  3984. return 0;
  3985. }
  3986. /*==========================================
  3987. * @repairall [Valaris]
  3988. *------------------------------------------*/
  3989. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3990. {
  3991. int count, i;
  3992. nullpo_retr(-1, sd);
  3993. count = 0;
  3994. for (i = 0; i < MAX_INVENTORY; i++) {
  3995. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3996. sd->status.inventory[i].attribute = 0;
  3997. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3998. count++;
  3999. }
  4000. }
  4001. if (count > 0) {
  4002. clif_misceffect(&sd->bl, 3);
  4003. clif_equiplist(sd);
  4004. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4005. } else {
  4006. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4007. return -1;
  4008. }
  4009. return 0;
  4010. }
  4011. /*==========================================
  4012. * @nuke [Valaris]
  4013. *------------------------------------------*/
  4014. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4015. {
  4016. struct map_session_data *pl_sd;
  4017. nullpo_retr(-1, sd);
  4018. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4019. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4020. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4021. return -1;
  4022. }
  4023. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4024. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4025. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4026. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4027. } else {
  4028. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4029. return -1;
  4030. }
  4031. } else {
  4032. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4033. return -1;
  4034. }
  4035. return 0;
  4036. }
  4037. /*==========================================
  4038. * @tonpc
  4039. *------------------------------------------*/
  4040. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4041. {
  4042. char npcname[NAME_LENGTH];
  4043. struct npc_data *nd;
  4044. nullpo_retr(-1, sd);
  4045. memset(npcname, 0, sizeof(npcname));
  4046. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4047. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4048. return -1;
  4049. }
  4050. if ((nd = npc_name2id(npcname)) != NULL) {
  4051. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
  4052. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4053. else
  4054. return -1;
  4055. } else {
  4056. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4057. return -1;
  4058. }
  4059. return 0;
  4060. }
  4061. /*==========================================
  4062. *
  4063. *------------------------------------------*/
  4064. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4065. {
  4066. char NPCname[NAME_LENGTH];
  4067. nullpo_retr(-1, sd);
  4068. memset(NPCname, '\0', sizeof(NPCname));
  4069. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4070. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4071. return -1;
  4072. }
  4073. if (npc_name2id(NPCname) != NULL) {
  4074. npc_enable(NPCname, 1);
  4075. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4076. } else {
  4077. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4078. return -1;
  4079. }
  4080. return 0;
  4081. }
  4082. /*==========================================
  4083. *
  4084. *------------------------------------------*/
  4085. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4086. {
  4087. char NPCname[NAME_LENGTH];
  4088. nullpo_retr(-1, sd);
  4089. memset(NPCname, '\0', sizeof(NPCname));
  4090. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4091. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4092. return -1;
  4093. }
  4094. if (npc_name2id(NPCname) == NULL) {
  4095. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4096. return -1;
  4097. }
  4098. npc_enable(NPCname, 0);
  4099. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4100. return 0;
  4101. }
  4102. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4103. {
  4104. FILE *fp;
  4105. if (!message || !*message) {
  4106. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4107. return -1;
  4108. }
  4109. // check if script file exists
  4110. if ((fp = fopen(message, "r")) == NULL) {
  4111. clif_displaymessage(fd, msg_txt(261));
  4112. return -1;
  4113. }
  4114. fclose(fp);
  4115. // add to list of script sources and run it
  4116. npc_addsrcfile(message);
  4117. npc_parsesrcfile(message);
  4118. npc_read_event_script();
  4119. clif_displaymessage(fd, msg_txt(262));
  4120. return 0;
  4121. }
  4122. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4123. {
  4124. struct npc_data *nd;
  4125. char NPCname[NAME_LENGTH];
  4126. nullpo_retr(-1, sd);
  4127. memset(NPCname, '\0', sizeof(NPCname));
  4128. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4129. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4130. return -1;
  4131. }
  4132. if ((nd = npc_name2id(NPCname)) == NULL) {
  4133. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4134. return -1;
  4135. }
  4136. npc_unload_duplicates(nd);
  4137. npc_unload(nd);
  4138. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4139. return 0;
  4140. }
  4141. /*==========================================
  4142. * time in txt for time command (by [Yor])
  4143. *------------------------------------------*/
  4144. char* txt_time(unsigned int duration)
  4145. {
  4146. int days, hours, minutes, seconds;
  4147. char temp[256];
  4148. static char temp1[256];
  4149. memset(temp, '\0', sizeof(temp));
  4150. memset(temp1, '\0', sizeof(temp1));
  4151. days = duration / (60 * 60 * 24);
  4152. duration = duration - (60 * 60 * 24 * days);
  4153. hours = duration / (60 * 60);
  4154. duration = duration - (60 * 60 * hours);
  4155. minutes = duration / 60;
  4156. seconds = duration - (60 * minutes);
  4157. if (days < 2)
  4158. sprintf(temp, msg_txt(219), days); // %d day
  4159. else
  4160. sprintf(temp, msg_txt(220), days); // %d days
  4161. if (hours < 2)
  4162. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4163. else
  4164. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4165. if (minutes < 2)
  4166. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4167. else
  4168. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4169. if (seconds < 2)
  4170. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4171. else
  4172. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4173. return temp1;
  4174. }
  4175. /*==========================================
  4176. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4177. * Calculation management of GM modification (@day/@night GM commands) is done
  4178. *------------------------------------------*/
  4179. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4180. {
  4181. struct TimerData * timer_data;
  4182. struct TimerData * timer_data2;
  4183. time_t time_server; // variable for number of seconds (used with time() function)
  4184. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4185. char temp[256];
  4186. nullpo_retr(-1, sd);
  4187. memset(temp, '\0', sizeof(temp));
  4188. time(&time_server); // get time in seconds since 1/1/1970
  4189. datetime = localtime(&time_server); // convert seconds in structure
  4190. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4191. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4192. clif_displaymessage(fd, temp);
  4193. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4194. if (night_flag == 0)
  4195. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4196. else
  4197. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4198. } else if (battle_config.night_duration == 0)
  4199. if (night_flag == 1) { // we start with night
  4200. timer_data = get_timer(day_timer_tid);
  4201. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4202. clif_displaymessage(fd, temp);
  4203. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4204. } else
  4205. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4206. else if (battle_config.day_duration == 0)
  4207. if (night_flag == 0) { // we start with day
  4208. timer_data = get_timer(night_timer_tid);
  4209. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4210. clif_displaymessage(fd, temp);
  4211. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4212. } else
  4213. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4214. else {
  4215. if (night_flag == 0) {
  4216. timer_data = get_timer(night_timer_tid);
  4217. timer_data2 = get_timer(day_timer_tid);
  4218. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4219. clif_displaymessage(fd, temp);
  4220. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4221. 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.
  4222. else
  4223. 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.
  4224. clif_displaymessage(fd, temp);
  4225. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4226. clif_displaymessage(fd, temp);
  4227. } else {
  4228. timer_data = get_timer(day_timer_tid);
  4229. timer_data2 = get_timer(night_timer_tid);
  4230. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4231. clif_displaymessage(fd, temp);
  4232. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4233. 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.
  4234. else
  4235. 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.
  4236. clif_displaymessage(fd, temp);
  4237. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4238. clif_displaymessage(fd, temp);
  4239. }
  4240. }
  4241. return 0;
  4242. }
  4243. //Added by Coltaro
  4244. //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...).
  4245. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4246. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4247. {
  4248. const int factor_year = 518400; //12*30*24*60 = 518400
  4249. const int factor_month = 43200; //30*24*60 = 43200
  4250. const int factor_day = 1440; //24*60 = 1440
  4251. const int factor_hour = 60;
  4252. *year = jailtime/factor_year;
  4253. jailtime -= *year*factor_year;
  4254. *month = jailtime/factor_month;
  4255. jailtime -= *month*factor_month;
  4256. *day = jailtime/factor_day;
  4257. jailtime -= *day*factor_day;
  4258. *hour = jailtime/factor_hour;
  4259. jailtime -= *hour*factor_hour;
  4260. *minute = jailtime;
  4261. *year = *year > 0? *year : 0;
  4262. *month = *month > 0? *month : 0;
  4263. *day = *day > 0? *day : 0;
  4264. *hour = *hour > 0? *hour : 0;
  4265. *minute = *minute > 0? *minute : 0;
  4266. return;
  4267. }
  4268. /*==========================================
  4269. * @jail <char_name> by [Yor]
  4270. * Special warp! No check with nowarp and nowarpto flag
  4271. *------------------------------------------*/
  4272. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4273. {
  4274. struct map_session_data *pl_sd;
  4275. int x, y;
  4276. unsigned short m_index;
  4277. nullpo_retr(-1, sd);
  4278. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4279. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4280. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4281. return -1;
  4282. }
  4283. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4284. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4285. return -1;
  4286. }
  4287. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4288. { // you can jail only lower or same GM
  4289. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4290. return -1;
  4291. }
  4292. if (pl_sd->sc.data[SC_JAILED].timer != -1)
  4293. {
  4294. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4295. return -1;
  4296. }
  4297. switch(rand() % 2) { //Jail Locations
  4298. case 0:
  4299. m_index = mapindex_name2id(MAP_JAIL);
  4300. x = 24;
  4301. y = 75;
  4302. break;
  4303. default:
  4304. m_index = mapindex_name2id(MAP_JAIL);
  4305. x = 49;
  4306. y = 75;
  4307. break;
  4308. }
  4309. //Duration of INT_MAX to specify infinity.
  4310. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4311. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4312. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4313. return 0;
  4314. }
  4315. /*==========================================
  4316. * @unjail/@discharge <char_name> by [Yor]
  4317. * Special warp! No check with nowarp and nowarpto flag
  4318. *------------------------------------------*/
  4319. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4320. {
  4321. struct map_session_data *pl_sd;
  4322. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4323. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4324. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4325. return -1;
  4326. }
  4327. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4328. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4329. return -1;
  4330. }
  4331. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4332. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4333. return -1;
  4334. }
  4335. if (pl_sd->sc.data[SC_JAILED].timer == -1)
  4336. {
  4337. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4338. return -1;
  4339. }
  4340. //Reset jail time to 1 sec.
  4341. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4342. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4343. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4344. return 0;
  4345. }
  4346. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4347. {
  4348. struct map_session_data *pl_sd = NULL;
  4349. int year, month, day, hour, minute, value;
  4350. char * modif_p;
  4351. int jailtime = 0,x,y;
  4352. short m_index = 0;
  4353. nullpo_retr(-1, sd);
  4354. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4355. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4356. return -1;
  4357. }
  4358. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4359. modif_p = atcmd_output;
  4360. year = month = day = hour = minute = 0;
  4361. while (modif_p[0] != '\0') {
  4362. value = atoi(modif_p);
  4363. if (value == 0)
  4364. modif_p++;
  4365. else {
  4366. if (modif_p[0] == '-' || modif_p[0] == '+')
  4367. modif_p++;
  4368. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4369. modif_p++;
  4370. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4371. minute = value;
  4372. modif_p = modif_p + 2;
  4373. } else if (modif_p[0] == 'h') {
  4374. hour = value;
  4375. modif_p++;
  4376. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4377. day = value;
  4378. modif_p++;
  4379. } else if (modif_p[0] == 'm') {
  4380. month = value;
  4381. modif_p++;
  4382. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4383. year = value;
  4384. modif_p++;
  4385. } else if (modif_p[0] != '\0') {
  4386. modif_p++;
  4387. }
  4388. }
  4389. }
  4390. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4391. clif_displaymessage(fd, "Invalid time for jail command.");
  4392. return -1;
  4393. }
  4394. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4395. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4396. return -1;
  4397. }
  4398. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4399. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4400. return -1;
  4401. }
  4402. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4403. if(jailtime==0) {
  4404. clif_displaymessage(fd, "Invalid time for jail command.");
  4405. return -1;
  4406. }
  4407. //Added by Coltaro
  4408. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1 &&
  4409. pl_sd->sc.data[SC_JAILED].val1 != INT_MAX)
  4410. { //Update the player's jail time
  4411. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  4412. if (jailtime <= 0) {
  4413. jailtime = 0;
  4414. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4415. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4416. } else {
  4417. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4418. 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
  4419. clif_displaymessage(pl_sd->fd, atcmd_output);
  4420. 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
  4421. clif_displaymessage(fd, atcmd_output);
  4422. }
  4423. } else if (jailtime < 0) {
  4424. clif_displaymessage(fd, "Invalid time for jail command.");
  4425. return -1;
  4426. }
  4427. //Jail locations, add more as you wish.
  4428. switch(rand()%2)
  4429. {
  4430. case 1: //Jail #1
  4431. m_index = mapindex_name2id(MAP_JAIL);
  4432. x = 49; y = 75;
  4433. break;
  4434. default: //Default Jail
  4435. m_index = mapindex_name2id(MAP_JAIL);
  4436. x = 24; y = 75;
  4437. break;
  4438. }
  4439. 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).
  4440. return 0;
  4441. }
  4442. //By Coltaro
  4443. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4444. {
  4445. int year, month, day, hour, minute;
  4446. nullpo_retr(-1, sd);
  4447. if (!sd->sc.count || sd->sc.data[SC_JAILED].timer == -1) {
  4448. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4449. return -1;
  4450. }
  4451. if (sd->sc.data[SC_JAILED].val1 == INT_MAX) {
  4452. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4453. return 0;
  4454. }
  4455. if (sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4456. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4457. return -1;
  4458. }
  4459. //Get remaining jail time
  4460. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  4461. 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
  4462. clif_displaymessage(fd, atcmd_output);
  4463. return 0;
  4464. }
  4465. /*==========================================
  4466. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4467. *------------------------------------------*/
  4468. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4469. {
  4470. int id = 0;
  4471. nullpo_retr(-1, sd);
  4472. if (!message || !*message) {
  4473. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4474. return -1;
  4475. }
  4476. if ((id = atoi(message)) > 0)
  4477. { //Acquired an ID
  4478. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4479. id = 0; //Invalid id for either mobs or npcs.
  4480. } else { //Acquired a Name
  4481. if ((id = mobdb_searchname(message)) == 0)
  4482. {
  4483. struct npc_data* nd = npc_name2id(message);
  4484. if (nd != NULL)
  4485. id = nd->n;
  4486. }
  4487. }
  4488. if (id == 0)
  4489. {
  4490. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4491. return -1;
  4492. }
  4493. if(pc_isriding(sd))
  4494. {
  4495. //FIXME: wrong message [ultramage]
  4496. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4497. return -1;
  4498. }
  4499. pc_disguise(sd, id);
  4500. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4501. return 0;
  4502. }
  4503. /*==========================================
  4504. * DisguiseAll
  4505. *------------------------------------------*/
  4506. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4507. {
  4508. int mob_id=0, i=0, users;
  4509. struct map_session_data *pl_sd, **pl_allsd;
  4510. nullpo_retr(-1, sd);
  4511. if (!message || !*message) {
  4512. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4513. return -1;
  4514. }
  4515. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4516. mob_id = atoi(message);
  4517. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4518. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4519. return -1;
  4520. }
  4521. pl_allsd = map_getallusers(&users);
  4522. for(i=0; i < users; i++)
  4523. {
  4524. if((pl_sd = pl_allsd[i]))
  4525. pc_disguise(pl_sd, mob_id);
  4526. }
  4527. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4528. return 0;
  4529. }
  4530. /*==========================================
  4531. * @undisguise by [Yor]
  4532. *------------------------------------------*/
  4533. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4534. {
  4535. nullpo_retr(-1, sd);
  4536. if (sd->disguise) {
  4537. pc_disguise(sd, 0);
  4538. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4539. } else {
  4540. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4541. return -1;
  4542. }
  4543. return 0;
  4544. }
  4545. /*==========================================
  4546. * UndisguiseAll
  4547. *------------------------------------------*/
  4548. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4549. {
  4550. struct map_session_data *pl_sd, **pl_allsd;
  4551. int i, users;
  4552. nullpo_retr(-1, sd);
  4553. pl_allsd = map_getallusers(&users);
  4554. for(i=0; i < users; i++) {
  4555. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  4556. pc_disguise(pl_sd, 0);
  4557. }
  4558. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4559. return 0;
  4560. }
  4561. /*==========================================
  4562. * @exp by [Skotlex]
  4563. *------------------------------------------*/
  4564. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4565. {
  4566. char output[200];
  4567. double nextb, nextj;
  4568. nullpo_retr(-1, sd);
  4569. memset(output, '\0', sizeof(output));
  4570. nextb = pc_nextbaseexp(sd);
  4571. if (nextb)
  4572. nextb = sd->status.base_exp*100.0/nextb;
  4573. nextj = pc_nextjobexp(sd);
  4574. if (nextj)
  4575. nextj = sd->status.job_exp*100.0/nextj;
  4576. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4577. clif_displaymessage(fd, output);
  4578. return 0;
  4579. }
  4580. /*==========================================
  4581. * @broadcast by [Valaris]
  4582. *------------------------------------------*/
  4583. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4584. {
  4585. nullpo_retr(-1, sd);
  4586. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4587. if (!message || !*message) {
  4588. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4589. return -1;
  4590. }
  4591. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4592. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  4593. return 0;
  4594. }
  4595. /*==========================================
  4596. * @localbroadcast by [Valaris]
  4597. *------------------------------------------*/
  4598. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4599. {
  4600. nullpo_retr(-1, sd);
  4601. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4602. if (!message || !*message) {
  4603. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4604. return -1;
  4605. }
  4606. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4607. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  4608. return 0;
  4609. }
  4610. /*==========================================
  4611. * @email <actual@email> <new@email> by [Yor]
  4612. *------------------------------------------*/
  4613. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4614. {
  4615. char actual_email[100];
  4616. char new_email[100];
  4617. nullpo_retr(-1, sd);
  4618. memset(actual_email, '\0', sizeof(actual_email));
  4619. memset(new_email, '\0', sizeof(new_email));
  4620. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4621. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4622. return -1;
  4623. }
  4624. if (e_mail_check(actual_email) == 0) {
  4625. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4626. return -1;
  4627. } else if (e_mail_check(new_email) == 0) {
  4628. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4629. return -1;
  4630. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4631. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4632. return -1;
  4633. } else if (strcmpi(actual_email, new_email) == 0) {
  4634. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4635. return -1;
  4636. }
  4637. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4638. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4639. return 0;
  4640. }
  4641. /*==========================================
  4642. *@effect
  4643. *------------------------------------------*/
  4644. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4645. {
  4646. int type = 0, flag = 0;
  4647. nullpo_retr(-1, sd);
  4648. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4649. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4650. return -1;
  4651. }
  4652. clif_specialeffect(&sd->bl, type, flag);
  4653. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4654. return 0;
  4655. }
  4656. /*==========================================
  4657. * @killer by MouseJstr
  4658. * enable killing players even when not in pvp
  4659. *------------------------------------------*/
  4660. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4661. {
  4662. nullpo_retr(-1, sd);
  4663. sd->state.killer = !sd->state.killer;
  4664. if(sd->state.killer)
  4665. clif_displaymessage(fd, msg_txt(241));
  4666. else {
  4667. clif_displaymessage(fd, msg_txt(287));
  4668. pc_stop_attack(sd);
  4669. }
  4670. return 0;
  4671. }
  4672. /*==========================================
  4673. * @killable by MouseJstr
  4674. * enable other people killing you
  4675. *------------------------------------------*/
  4676. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4677. {
  4678. nullpo_retr(-1, sd);
  4679. sd->state.killable = !sd->state.killable;
  4680. if(sd->state.killable)
  4681. clif_displaymessage(fd, msg_txt(242));
  4682. else {
  4683. clif_displaymessage(fd, msg_txt(288));
  4684. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4685. }
  4686. return 0;
  4687. }
  4688. /*==========================================
  4689. * @skillon by MouseJstr
  4690. * turn skills on for the map
  4691. *------------------------------------------*/
  4692. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4693. {
  4694. nullpo_retr(-1, sd);
  4695. map[sd->bl.m].flag.noskill = 0;
  4696. clif_displaymessage(fd, msg_txt(244));
  4697. return 0;
  4698. }
  4699. /*==========================================
  4700. * @skilloff by MouseJstr
  4701. * Turn skills off on the map
  4702. *------------------------------------------*/
  4703. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4704. {
  4705. nullpo_retr(-1, sd);
  4706. map[sd->bl.m].flag.noskill = 1;
  4707. clif_displaymessage(fd, msg_txt(243));
  4708. return 0;
  4709. }
  4710. /*==========================================
  4711. * @npcmove by MouseJstr
  4712. * move a npc
  4713. *------------------------------------------*/
  4714. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4715. {
  4716. int x = 0, y = 0, m;
  4717. struct npc_data *nd = 0;
  4718. nullpo_retr(-1, sd);
  4719. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4720. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4721. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4722. return -1;
  4723. }
  4724. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4725. {
  4726. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4727. return -1;
  4728. }
  4729. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4730. {
  4731. clif_displaymessage(fd, "NPC is not on this map.");
  4732. return -1; //Not on a map.
  4733. }
  4734. x = cap_value(x, 0, map[m].xs-1);
  4735. y = cap_value(y, 0, map[m].ys-1);
  4736. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4737. map_moveblock(&nd->bl, x, y, gettick());
  4738. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4739. clif_displaymessage(fd, "NPC moved.");
  4740. return 0;
  4741. }
  4742. /*==========================================
  4743. * @addwarp by MouseJstr
  4744. * Create a new static warp point.
  4745. *------------------------------------------*/
  4746. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4747. {
  4748. char w1[64], w3[64], w4[64];
  4749. int x,y,ret=0;
  4750. nullpo_retr(-1, sd);
  4751. if (!message || !*message || sscanf(message, "%23s %d %d[^\n]", atcmd_player_name, &x, &y) < 3) {
  4752. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4753. return -1;
  4754. }
  4755. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  4756. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  4757. sprintf(w4,"1,1,%s,%d,%d", atcmd_player_name, x, y);
  4758. // FIXME check if it failed [FlavioJS]
  4759. npc_parse_warp(w1, "warp", w3, w4, NULL, NULL, "console");
  4760. sprintf(atcmd_output, "New warp NPC => %s",w3);
  4761. clif_displaymessage(fd, atcmd_output);
  4762. return ret;
  4763. }
  4764. /*==========================================
  4765. * @follow by [MouseJstr]
  4766. * Follow a player .. staying no more then 5 spaces away
  4767. *------------------------------------------*/
  4768. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4769. {
  4770. struct map_session_data *pl_sd = NULL;
  4771. nullpo_retr(-1, sd);
  4772. if (!message || !*message) {
  4773. if (sd->followtarget == -1)
  4774. return -1;
  4775. pc_stop_following (sd);
  4776. clif_displaymessage(fd, "Follow mode OFF.");
  4777. return 0;
  4778. }
  4779. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4780. {
  4781. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4782. return -1;
  4783. }
  4784. if (sd->followtarget == pl_sd->bl.id) {
  4785. pc_stop_following (sd);
  4786. clif_displaymessage(fd, "Follow mode OFF.");
  4787. } else {
  4788. pc_follow(sd, pl_sd->bl.id);
  4789. clif_displaymessage(fd, "Follow mode ON.");
  4790. }
  4791. return 0;
  4792. }
  4793. /*==========================================
  4794. * @dropall by [MouseJstr]
  4795. * Drop all your possession on the ground
  4796. *------------------------------------------*/
  4797. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4798. {
  4799. int i;
  4800. nullpo_retr(-1, sd);
  4801. for (i = 0; i < MAX_INVENTORY; i++) {
  4802. if (sd->status.inventory[i].amount) {
  4803. if(sd->status.inventory[i].equip != 0)
  4804. pc_unequipitem(sd, i, 3);
  4805. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4806. }
  4807. }
  4808. return 0;
  4809. }
  4810. /*==========================================
  4811. * @storeall by [MouseJstr]
  4812. * Put everything into storage
  4813. *------------------------------------------*/
  4814. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4815. {
  4816. int i;
  4817. nullpo_retr(-1, sd);
  4818. if (sd->state.storage_flag != 1)
  4819. { //Open storage.
  4820. switch (storage_storageopen(sd)) {
  4821. case 2: //Try again
  4822. clif_displaymessage(fd, "run this command again..");
  4823. return 0;
  4824. case 1: //Failure
  4825. clif_displaymessage(fd, "You can't open the storage currently.");
  4826. return -1;
  4827. }
  4828. }
  4829. for (i = 0; i < MAX_INVENTORY; i++) {
  4830. if (sd->status.inventory[i].amount) {
  4831. if(sd->status.inventory[i].equip != 0)
  4832. pc_unequipitem(sd, i, 3);
  4833. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4834. }
  4835. }
  4836. storage_storageclose(sd);
  4837. clif_displaymessage(fd, "It is done");
  4838. return 0;
  4839. }
  4840. /*==========================================
  4841. * @skillid by [MouseJstr]
  4842. * lookup a skill by name
  4843. *------------------------------------------*/
  4844. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4845. {
  4846. int skillen, idx;
  4847. nullpo_retr(-1, sd);
  4848. if (!message || !*message)
  4849. {
  4850. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4851. return -1;
  4852. }
  4853. skillen = strlen(message);
  4854. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4855. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  4856. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  4857. {
  4858. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4859. clif_displaymessage(fd, atcmd_output);
  4860. }
  4861. }
  4862. return 0;
  4863. }
  4864. /*==========================================
  4865. * @useskill by [MouseJstr]
  4866. * A way of using skills without having to find them in the skills menu
  4867. *------------------------------------------*/
  4868. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4869. {
  4870. struct map_session_data *pl_sd = NULL;
  4871. struct block_list *bl;
  4872. int skillnum;
  4873. int skilllv;
  4874. char target[100];
  4875. nullpo_retr(-1, sd);
  4876. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4877. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4878. return -1;
  4879. }
  4880. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4881. {
  4882. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4883. return -1;
  4884. }
  4885. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  4886. {
  4887. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4888. return -1;
  4889. }
  4890. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  4891. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4892. bl = &sd->hd->bl;
  4893. else
  4894. bl = &sd->bl;
  4895. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4896. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4897. else
  4898. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4899. return 0;
  4900. }
  4901. /*==========================================
  4902. * @displayskill by [Skotlex]
  4903. * Debug command to locate new skill IDs. It sends the
  4904. * three possible skill-effect packets to the area.
  4905. *------------------------------------------*/
  4906. int atcommand_displayskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4907. {
  4908. struct status_data * status;
  4909. unsigned int tick;
  4910. int skillnum;
  4911. int skilllv = 1;
  4912. nullpo_retr(-1, sd);
  4913. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4914. {
  4915. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4916. return -1;
  4917. }
  4918. status = status_get_status_data(&sd->bl);
  4919. tick = gettick();
  4920. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4921. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4922. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4923. return 0;
  4924. }
  4925. /*==========================================
  4926. * @skilltree by [MouseJstr]
  4927. * prints the skill tree for a player required to get to a skill
  4928. *------------------------------------------*/
  4929. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4930. {
  4931. struct map_session_data *pl_sd = NULL;
  4932. int skillnum, skillidx = -1;
  4933. int meets = 1, j, c=0;
  4934. char target[NAME_LENGTH], *tbl;
  4935. struct skill_tree_entry *ent;
  4936. nullpo_retr(-1, sd);
  4937. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4938. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4939. return -1;
  4940. }
  4941. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4942. {
  4943. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4944. return -1;
  4945. }
  4946. c = pc_calc_skilltree_normalize_job(pl_sd);
  4947. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4948. tbl = job_name(c);
  4949. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  4950. tbl, pc_checkskill(pl_sd, 1));
  4951. clif_displaymessage(fd, atcmd_output);
  4952. for (j = 0; skill_tree[c][j].id != 0; j++) {
  4953. if (skill_tree[c][j].id == skillnum) {
  4954. skillidx = j;
  4955. break;
  4956. }
  4957. }
  4958. if (skillidx == -1) {
  4959. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4960. clif_displaymessage(fd, atcmd_output);
  4961. return 0;
  4962. }
  4963. ent = &skill_tree[c][skillidx];
  4964. for(j=0;j<5;j++)
  4965. if( ent->need[j].id &&
  4966. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4967. {
  4968. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  4969. sprintf(atcmd_output, "player requires level %d of skill %s",
  4970. ent->need[j].lv, desc);
  4971. clif_displaymessage(fd, atcmd_output);
  4972. meets = 0;
  4973. }
  4974. if (meets == 1) {
  4975. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4976. clif_displaymessage(fd, atcmd_output);
  4977. }
  4978. return 0;
  4979. }
  4980. // Hand a ring with partners name on it to this char
  4981. void getring (struct map_session_data* sd)
  4982. {
  4983. int flag, item_id;
  4984. struct item item_tmp;
  4985. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4986. memset(&item_tmp, 0, sizeof(item_tmp));
  4987. item_tmp.nameid = item_id;
  4988. item_tmp.identify = 1;
  4989. item_tmp.card[0] = 255;
  4990. item_tmp.card[2] = sd->status.partner_id;
  4991. item_tmp.card[3] = sd->status.partner_id >> 16;
  4992. //Logs (A)dmins items [Lupus]
  4993. if(log_config.enable_logs&0x400)
  4994. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  4995. if((flag = pc_additem(sd,&item_tmp,1))) {
  4996. clif_additem(sd,0,0,flag);
  4997. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4998. }
  4999. }
  5000. /*==========================================
  5001. * @marry by [MouseJstr], fixed by Lupus
  5002. * Marry two players
  5003. *------------------------------------------*/
  5004. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5005. {
  5006. struct map_session_data *pl_sd1 = NULL;
  5007. struct map_session_data *pl_sd2 = NULL;
  5008. char player1[128], player2[128]; //Length used for return error msgs
  5009. nullpo_retr(-1, sd);
  5010. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5011. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5012. return -1;
  5013. }
  5014. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5015. sprintf(player2, "Cannot find player '%s' online", player1);
  5016. clif_displaymessage(fd, player2);
  5017. return -1;
  5018. }
  5019. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5020. sprintf(player1, "Cannot find player '%s' online", player2);
  5021. clif_displaymessage(fd, player1);
  5022. return -1;
  5023. }
  5024. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5025. clif_displaymessage(fd, "They are married.. wish them well");
  5026. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5027. // Auto-give named rings (Aru)
  5028. getring (pl_sd1);
  5029. getring (pl_sd2);
  5030. return 0;
  5031. }
  5032. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5033. return -1;
  5034. }
  5035. /*==========================================
  5036. * @divorce by [MouseJstr], fixed by [Lupus]
  5037. * divorce two players
  5038. *------------------------------------------*/
  5039. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5040. {
  5041. struct map_session_data *pl_sd = NULL;
  5042. nullpo_retr(-1, sd);
  5043. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5044. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5045. return -1;
  5046. }
  5047. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5048. {
  5049. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5050. return -1;
  5051. }
  5052. if (pc_divorce(pl_sd) != 0) {
  5053. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5054. clif_displaymessage(fd, atcmd_output);
  5055. return -1;
  5056. }
  5057. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5058. clif_displaymessage(fd, atcmd_output);
  5059. return 0;
  5060. }
  5061. /*==========================================
  5062. * @changelook by [Celest]
  5063. *------------------------------------------*/
  5064. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5065. {
  5066. int i, j = 0, k = 0;
  5067. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5068. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5069. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5070. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5071. return -1;
  5072. } else if (i == 2) {
  5073. if (j < 1) j = 1;
  5074. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5075. j = pos[j - 1];
  5076. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5077. k = j; // swap
  5078. j = LOOK_HEAD_TOP;
  5079. }
  5080. clif_changelook(&sd->bl,j,k);
  5081. return 0;
  5082. }
  5083. /*==========================================
  5084. * @autotrade by durf (changed by Lupus)
  5085. * Turns on/off Autotrade for a specific player
  5086. *------------------------------------------*/
  5087. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5088. {
  5089. nullpo_retr(-1, sd);
  5090. if (sd->vender_id) //check if player's vending
  5091. {
  5092. sd->state.autotrade = 1;
  5093. clif_authfail_fd(fd, 15);
  5094. }
  5095. else
  5096. {
  5097. //"You should be vending to use @Autotrade."
  5098. clif_displaymessage(fd, msg_txt(549));
  5099. }
  5100. return 0;
  5101. }
  5102. /*==========================================
  5103. * @changegm by durf (changed by Lupus)
  5104. * Changes Master of your Guild to a specified guild member
  5105. *------------------------------------------*/
  5106. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5107. {
  5108. struct guild *g;
  5109. struct map_session_data *pl_sd;
  5110. nullpo_retr(-1, sd);
  5111. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5112. {
  5113. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5114. return -1;
  5115. }
  5116. if (strlen(message)==0)
  5117. {
  5118. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5119. return -1;
  5120. }
  5121. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5122. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5123. return -1;
  5124. }
  5125. guild_gm_change(sd->status.guild_id, pl_sd);
  5126. return 0;
  5127. }
  5128. /*==========================================
  5129. * @changeleader by Skotlex
  5130. * Changes the leader of a party.
  5131. *------------------------------------------*/
  5132. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5133. {
  5134. struct party_data *p;
  5135. struct map_session_data *pl_sd;
  5136. int mi, pl_mi;
  5137. nullpo_retr(-1, sd);
  5138. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5139. { //Need to be a party leader.
  5140. clif_displaymessage(fd, msg_txt(282));
  5141. return -1;
  5142. }
  5143. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  5144. if (mi == MAX_PARTY)
  5145. return -1; //Shouldn't happen
  5146. if (!p->party.member[mi].leader)
  5147. { //Need to be a party leader.
  5148. clif_displaymessage(fd, msg_txt(282));
  5149. return -1;
  5150. }
  5151. if (strlen(message)==0)
  5152. {
  5153. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5154. return -1;
  5155. }
  5156. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  5157. clif_displaymessage(fd, msg_txt(283));
  5158. return -1;
  5159. }
  5160. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  5161. if (pl_mi == MAX_PARTY)
  5162. return -1; //Shouldn't happen
  5163. //Change leadership.
  5164. p->party.member[mi].leader = 0;
  5165. if (p->data[mi].sd->fd)
  5166. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  5167. p->party.member[pl_mi].leader = 1;
  5168. if (p->data[pl_mi].sd->fd)
  5169. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  5170. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  5171. //Update info.
  5172. clif_party_info(p,NULL);
  5173. return 0;
  5174. }
  5175. /*==========================================
  5176. * @partyoption by Skotlex
  5177. * Used to change the item share setting of a party.
  5178. *------------------------------------------*/
  5179. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5180. {
  5181. struct party_data *p;
  5182. int mi, option;
  5183. char w1[15], w2[15];
  5184. nullpo_retr(-1, sd);
  5185. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5186. {
  5187. clif_displaymessage(fd, msg_txt(282));
  5188. return -1;
  5189. }
  5190. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  5191. if (mi == MAX_PARTY)
  5192. return -1; //Shouldn't happen
  5193. if (!p->party.member[mi].leader)
  5194. {
  5195. clif_displaymessage(fd, msg_txt(282));
  5196. return -1;
  5197. }
  5198. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5199. {
  5200. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  5201. return -1;
  5202. }
  5203. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  5204. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5205. //Change item share type.
  5206. if (option != p->party.item)
  5207. party_changeoption(sd, p->party.exp, option);
  5208. else
  5209. clif_displaymessage(fd, msg_txt(286));
  5210. return 0;
  5211. }
  5212. /*==========================================
  5213. * @autoloot by Upa-Kun
  5214. * Turns on/off AutoLoot for a specific player
  5215. *------------------------------------------*/
  5216. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5217. {
  5218. int rate;
  5219. double drate;
  5220. nullpo_retr(-1, sd);
  5221. // autoloot command without value
  5222. if(!message || !*message)
  5223. {
  5224. if (sd->state.autoloot)
  5225. rate = 0;
  5226. else
  5227. rate = 10000;
  5228. } else {
  5229. drate = atof(message);
  5230. rate = (int)(drate*100);
  5231. }
  5232. if (rate < 0) rate = 0;
  5233. if (rate > 10000) rate = 10000;
  5234. sd->state.autoloot = rate;
  5235. if (sd->state.autoloot) {
  5236. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5237. clif_displaymessage(fd, atcmd_output);
  5238. }else
  5239. clif_displaymessage(fd, "Autoloot is now off.");
  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].timer!=-1 ||
  5488. (sd->sc.data[SC_NOCHAT].timer != -1 && 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. const char* emo[] = { "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5508. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5509. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5510. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5511. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5512. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", NULL };
  5513. nullpo_retr(-1, sd);
  5514. if(!sd->status.pet_id || !(pd=sd->pd))
  5515. {
  5516. clif_displaymessage(fd, msg_txt(184));
  5517. return -1;
  5518. }
  5519. if (sd->sc.count && //no "chatting" while muted.
  5520. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  5521. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  5522. return -1;
  5523. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5524. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5525. return -1;
  5526. }
  5527. if (message[0] == '/') {
  5528. int i;
  5529. for (i = 0; emo[i] != NULL; i++) {
  5530. if (!stricmp(message, emo[i])) {
  5531. clif_emotion(&pd->bl, i);
  5532. return 0;
  5533. }
  5534. }
  5535. }
  5536. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5537. clif_message(&pd->bl, temp);
  5538. return 0;
  5539. }
  5540. /*==========================================
  5541. * @users - displays the number of players present on each map (percentage)
  5542. *------------------------------------------*/
  5543. static struct dbt *users_db = NULL;
  5544. static int users_all;
  5545. static int atcommand_users_sub1(struct map_session_data* sd,va_list va)
  5546. {
  5547. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  5548. users_all++;
  5549. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  5550. return 0;
  5551. }
  5552. static int atcommand_users_sub2(DBKey key,void* val,va_list va)
  5553. {
  5554. char buf[256];
  5555. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  5556. sprintf(buf,"%s: %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  5557. clif_displaymessage(sd->fd,buf);
  5558. return 0;
  5559. }
  5560. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5561. {
  5562. char buf[256];
  5563. users_all = 0;
  5564. users_db->clear(users_db, NULL);
  5565. clif_foreachclient(atcommand_users_sub1);
  5566. users_db->foreach(users_db,atcommand_users_sub2,sd);
  5567. sprintf(buf,"all: %d",users_all);
  5568. clif_displaymessage(fd,buf);
  5569. return 0;
  5570. }
  5571. /*==========================================
  5572. *
  5573. *------------------------------------------*/
  5574. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5575. {
  5576. pc_resetstate(sd);
  5577. pc_resetskill(sd,1);
  5578. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5579. clif_displaymessage(fd, atcmd_output);
  5580. return 0;
  5581. }
  5582. /*==========================================
  5583. *
  5584. *------------------------------------------*/
  5585. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5586. {
  5587. char name[NAME_LENGTH];
  5588. int mob_id = 0;
  5589. int duration = 0;
  5590. struct mob_data *md;
  5591. unsigned int tick=gettick();
  5592. nullpo_retr(-1, sd);
  5593. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5594. {
  5595. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5596. return -1;
  5597. }
  5598. if (duration < 1)
  5599. duration =1;
  5600. else if (duration > 60)
  5601. duration =60;
  5602. if ((mob_id = atoi(name)) == 0)
  5603. mob_id = mobdb_searchname(name);
  5604. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5605. {
  5606. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5607. return -1;
  5608. }
  5609. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5610. if(!md)
  5611. return -1;
  5612. md->master_id=sd->bl.id;
  5613. md->special_state.ai=1;
  5614. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5615. clif_misceffect2(&md->bl,344);
  5616. mob_spawn(md);
  5617. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5618. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5619. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5620. return 0;
  5621. }
  5622. /*==========================================
  5623. * @adjcmdlvl by [MouseJstr]
  5624. *
  5625. * Temp adjust the GM level required to use a GM command
  5626. * Useful during beta testing to allow players to use GM commands for short periods of time
  5627. *------------------------------------------*/
  5628. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5629. {
  5630. int newlev;
  5631. char name[100];
  5632. AtCommandInfo* cmd;
  5633. nullpo_retr(-1, sd);
  5634. if (!message || !*message || sscanf(message, "%d %99s", &newlev, name) != 2)
  5635. {
  5636. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  5637. return -1;
  5638. }
  5639. cmd = get_atcommandinfo_byname(name);
  5640. if (cmd == NULL)
  5641. {
  5642. clif_displaymessage(fd, "@command not found.");
  5643. return -1;
  5644. }
  5645. else if (newlev > pc_isGM(sd))
  5646. {
  5647. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5648. return -1;
  5649. }
  5650. else if (cmd->level > pc_isGM(sd))
  5651. {
  5652. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5653. return -1;
  5654. }
  5655. else
  5656. {
  5657. cmd->level = newlev;
  5658. clif_displaymessage(fd, "@command level changed.");
  5659. return 0;
  5660. }
  5661. }
  5662. /*==========================================
  5663. * @adjgmlvl by [MouseJstr]
  5664. * Create a temp GM
  5665. * Useful during beta testing to allow players to use GM commands for short periods of time
  5666. *------------------------------------------*/
  5667. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5668. {
  5669. int newlev;
  5670. char user[NAME_LENGTH];
  5671. struct map_session_data *pl_sd;
  5672. nullpo_retr(-1, sd);
  5673. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5674. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5675. return -1;
  5676. }
  5677. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5678. {
  5679. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5680. return -1;
  5681. }
  5682. pc_set_gm_level(pl_sd->status.account_id, newlev);
  5683. return 0;
  5684. }
  5685. /*==========================================
  5686. * @trade by [MouseJstr]
  5687. * Open a trade window with a remote player
  5688. *------------------------------------------*/
  5689. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5690. {
  5691. struct map_session_data *pl_sd = NULL;
  5692. nullpo_retr(-1, sd);
  5693. if (!message || !*message) {
  5694. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5695. return -1;
  5696. }
  5697. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5698. {
  5699. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5700. return -1;
  5701. }
  5702. trade_traderequest(sd, pl_sd);
  5703. return 0;
  5704. }
  5705. /*==========================================
  5706. * @setbattleflag by [MouseJstr]
  5707. * set a battle_config flag without having to reboot
  5708. *------------------------------------------*/
  5709. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5710. {
  5711. char flag[128], value[128];
  5712. nullpo_retr(-1, sd);
  5713. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5714. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5715. return -1;
  5716. }
  5717. if (battle_set_value(flag, value) == 0)
  5718. {
  5719. clif_displaymessage(fd, "unknown battle_config flag");
  5720. return -1;
  5721. }
  5722. clif_displaymessage(fd, "battle_config set as requested");
  5723. return 0;
  5724. }
  5725. /*==========================================
  5726. * @unmute [Valaris]
  5727. *------------------------------------------*/
  5728. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5729. {
  5730. struct map_session_data *pl_sd = NULL;
  5731. nullpo_retr(-1, sd);
  5732. if (!message || !*message) {
  5733. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5734. return -1;
  5735. }
  5736. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5737. {
  5738. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5739. return -1;
  5740. }
  5741. if(pl_sd->sc.data[SC_NOCHAT].timer == -1) {
  5742. clif_displaymessage(sd->fd,"Player is not muted");
  5743. return -1;
  5744. }
  5745. pl_sd->status.manner = 0;
  5746. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5747. clif_displaymessage(sd->fd,"Player unmuted");
  5748. return 0;
  5749. }
  5750. /*==========================================
  5751. * @uptime by MC Cameri
  5752. *------------------------------------------*/
  5753. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5754. {
  5755. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5756. minute = 60, days = 0, hours = 0, minutes = 0;
  5757. nullpo_retr(-1, sd);
  5758. seconds = get_uptime();
  5759. days = seconds/day;
  5760. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5761. hours = seconds/hour;
  5762. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5763. minutes = seconds/minute;
  5764. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5765. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5766. clif_displaymessage(fd, atcmd_output);
  5767. return 0;
  5768. }
  5769. /*==========================================
  5770. * @changesex <sex>
  5771. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5772. *------------------------------------------*/
  5773. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5774. {
  5775. nullpo_retr(-1, sd);
  5776. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  5777. return 0;
  5778. }
  5779. /*================================================
  5780. * @mute - Mutes a player for a set amount of time
  5781. *------------------------------------------------*/
  5782. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5783. {
  5784. struct map_session_data *pl_sd = NULL;
  5785. int manner;
  5786. nullpo_retr(-1, sd);
  5787. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5788. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5789. return -1;
  5790. }
  5791. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5792. {
  5793. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5794. return -1;
  5795. }
  5796. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5797. {
  5798. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5799. return -1;
  5800. }
  5801. clif_GM_silence(sd, pl_sd, 0);
  5802. pl_sd->status.manner -= manner;
  5803. if(pl_sd->status.manner < 0)
  5804. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5805. return 0;
  5806. }
  5807. /*==========================================
  5808. * @refresh (like @jumpto <<yourself>>)
  5809. *------------------------------------------*/
  5810. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5811. {
  5812. nullpo_retr(-1, sd);
  5813. clif_refresh(sd);
  5814. return 0;
  5815. }
  5816. /*==========================================
  5817. * @identify
  5818. * => GM's magnifier.
  5819. *------------------------------------------*/
  5820. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5821. {
  5822. int i,num;
  5823. nullpo_retr(-1, sd);
  5824. for(i=num=0;i<MAX_INVENTORY;i++){
  5825. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5826. num++;
  5827. }
  5828. }
  5829. if (num > 0) {
  5830. clif_item_identify_list(sd);
  5831. } else {
  5832. clif_displaymessage(fd,"There are no items to appraise.");
  5833. }
  5834. return 0;
  5835. }
  5836. /*==========================================
  5837. * @gmotd (Global MOTD)
  5838. * by davidsiaw :P
  5839. *------------------------------------------*/
  5840. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5841. {
  5842. char buf[256];
  5843. FILE *fp;
  5844. nullpo_retr(-1, sd);
  5845. if((fp = fopen(motd_txt, "r"))!=NULL){
  5846. while(fgets(buf, sizeof(buf), fp) != NULL)
  5847. {
  5848. int i;
  5849. if (buf[0] == '/' && buf[1] == '/')
  5850. continue;
  5851. for(i=0; buf[i]; i++){
  5852. if(buf[i]=='\r' || buf[i]=='\n'){
  5853. buf[i]=0;
  5854. break;
  5855. }
  5856. }
  5857. intif_GMmessage(buf,strlen(buf)+1,8);
  5858. }
  5859. fclose(fp);
  5860. }
  5861. return 0;
  5862. }
  5863. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5864. {
  5865. int effect = 0;
  5866. nullpo_retr(-1, sd);
  5867. if (!message || !*message)
  5868. return -1;
  5869. if (sscanf(message, "%d", &effect) < 1)
  5870. return -1;
  5871. clif_misceffect(&sd->bl,effect);
  5872. return 0;
  5873. }
  5874. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  5875. /*==========================================
  5876. * MAIL SYSTEM
  5877. *------------------------------------------*/
  5878. int atcommand_mail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5879. {
  5880. nullpo_retr(0,sd);
  5881. mail_openmail(sd);
  5882. return 0;
  5883. }
  5884. /*==========================================
  5885. * Refresh online command for SQL [Valaris]
  5886. * Will refresh and check online column of players and set correctly.
  5887. *------------------------------------------*/
  5888. int atcommand_refreshonline(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5889. {
  5890. send_users_tochar(-1, gettick(), 0, 0);
  5891. return 0;
  5892. }
  5893. #endif /* end sql only */
  5894. /*==========================================
  5895. * Show Monster DB Info v 1.0
  5896. * originally by [Lupus] eAthena
  5897. *------------------------------------------*/
  5898. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5899. {
  5900. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5901. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5902. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5903. char atcmd_output2[200];
  5904. struct item_data *item_data;
  5905. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5906. int count;
  5907. int i, j, k;
  5908. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5909. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5910. if (!message || !*message) {
  5911. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5912. return -1;
  5913. }
  5914. // If monster identifier/name argument is a name
  5915. if ((i = mobdb_checkid(atoi(message))))
  5916. {
  5917. mob_array[0] = mob_db(i);
  5918. count = 1;
  5919. } else
  5920. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5921. if (!count) {
  5922. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5923. return -1;
  5924. }
  5925. if (count > MAX_SEARCH) {
  5926. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5927. clif_displaymessage(fd, atcmd_output);
  5928. count = MAX_SEARCH;
  5929. }
  5930. for (k = 0; k < count; k++) {
  5931. mob = mob_array[k];
  5932. // stats
  5933. if (mob->mexp)
  5934. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5935. else
  5936. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5937. clif_displaymessage(fd, atcmd_output);
  5938. 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);
  5939. clif_displaymessage(fd, atcmd_output);
  5940. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5941. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5942. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5943. clif_displaymessage(fd, atcmd_output);
  5944. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5945. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5946. mob->range2 , mob->range3, msize[mob->status.size],
  5947. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5948. clif_displaymessage(fd, atcmd_output);
  5949. // drops
  5950. clif_displaymessage(fd, " Drops:");
  5951. strcpy(atcmd_output, " ");
  5952. j = 0;
  5953. for (i = 0; i < MAX_MOB_DROP; i++) {
  5954. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  5955. continue;
  5956. if (item_data->slot)
  5957. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5958. else
  5959. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5960. strcat(atcmd_output, atcmd_output2);
  5961. if (++j % 3 == 0) {
  5962. clif_displaymessage(fd, atcmd_output);
  5963. strcpy(atcmd_output, " ");
  5964. }
  5965. }
  5966. if (j == 0)
  5967. clif_displaymessage(fd, "This monster has no drops.");
  5968. else if (j % 3 != 0)
  5969. clif_displaymessage(fd, atcmd_output);
  5970. // mvp
  5971. if (mob->mexp) {
  5972. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  5973. clif_displaymessage(fd, atcmd_output);
  5974. strcpy(atcmd_output, " MVP Items:");
  5975. j = 0;
  5976. for (i = 0; i < 3; i++) {
  5977. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  5978. continue;
  5979. if (mob->mvpitem[i].p > 0) {
  5980. j++;
  5981. if (j == 1)
  5982. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5983. else
  5984. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5985. strcat(atcmd_output, atcmd_output2);
  5986. }
  5987. }
  5988. if (j == 0)
  5989. clif_displaymessage(fd, "This monster has no MVP prizes.");
  5990. else
  5991. clif_displaymessage(fd, atcmd_output);
  5992. }
  5993. }
  5994. return 0;
  5995. }
  5996. /*=========================================
  5997. * @showmobs by KarLaeda
  5998. * => For 5 sec displays the mobs on minimap
  5999. *------------------------------------------*/
  6000. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  6001. {
  6002. struct map_session_data *sd;
  6003. if (!session[id] || (sd = session[id]->session_data) == NULL)
  6004. return 0;
  6005. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  6006. return 1;
  6007. }
  6008. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  6009. {
  6010. int mob_id,fd;
  6011. struct map_session_data* sd;
  6012. static int number=0;
  6013. struct mob_data *md;
  6014. if(!ap){
  6015. number=0;
  6016. return 0;
  6017. }
  6018. mob_id = va_arg(ap,int);
  6019. fd = va_arg(ap,int);
  6020. sd = va_arg(ap,struct map_session_data*);
  6021. md = (struct mob_data *)bl;
  6022. if(md->special_state.ai || md->master_id)
  6023. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  6024. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  6025. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  6026. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  6027. }
  6028. return 0;
  6029. }
  6030. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6031. {
  6032. char mob_name[100];
  6033. int mob_id,map_id = 0;
  6034. nullpo_retr(-1, sd);
  6035. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6036. return -1;
  6037. if ((mob_id = atoi(mob_name)) == 0)
  6038. mob_id = mobdb_searchname(mob_name);
  6039. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6040. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6041. clif_displaymessage(fd, atcmd_output);
  6042. return 0;
  6043. }
  6044. // Uncomment the following line to show mini-bosses & MVP.
  6045. //#define SHOW_MVP
  6046. #ifndef SHOW_MVP
  6047. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6048. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6049. clif_displaymessage(fd, atcmd_output);
  6050. return 0;
  6051. }
  6052. #endif
  6053. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6054. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6055. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6056. map_id = sd->bl.m;
  6057. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6058. mob_name, mapindex_id2name(sd->mapindex));
  6059. clif_displaymessage(fd, atcmd_output);
  6060. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  6061. atshowmobs_sub(&sd->bl,0);
  6062. return 0;
  6063. }
  6064. /*==========================================
  6065. * homunculus level up [orn]
  6066. *------------------------------------------*/
  6067. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6068. {
  6069. TBL_HOM * hd;
  6070. int level = 0, i = 0;
  6071. nullpo_retr(-1, sd);
  6072. if (!message || !*message) {
  6073. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <+/- # of levels>.");
  6074. return -1;
  6075. }
  6076. if ( !merc_is_hom_active(sd->hd) ) {
  6077. clif_displaymessage(fd, "You do not have a homunculus.");
  6078. return -1;
  6079. }
  6080. level = atoi(message);
  6081. hd = sd->hd;
  6082. for (i = 1; i <= level && hd->exp_next; i++){
  6083. hd->homunculus.exp += hd->exp_next;
  6084. merc_hom_levelup(hd);
  6085. }
  6086. status_calc_homunculus(hd,0);
  6087. status_percent_heal(&hd->bl, 100, 100);
  6088. clif_misceffect2(&hd->bl,568);
  6089. return 0;
  6090. }
  6091. /*==========================================
  6092. * homunculus evolution H [orn]
  6093. *------------------------------------------*/
  6094. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6095. {
  6096. nullpo_retr(-1, sd);
  6097. if ( !merc_is_hom_active(sd->hd) ) {
  6098. clif_displaymessage(fd, "You do not have a homunculus.");
  6099. return -1;
  6100. }
  6101. if ( !merc_hom_evolution(sd->hd) ) {
  6102. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6103. return -1;
  6104. }
  6105. return 0;
  6106. }
  6107. /*==========================================
  6108. * call choosen homunculus [orn]
  6109. *------------------------------------------*/
  6110. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6111. {
  6112. int homunid;
  6113. nullpo_retr(-1, sd);
  6114. if ( merc_is_hom_active(sd->hd) ) {
  6115. clif_displaymessage(fd, msg_txt(450));
  6116. return -1;
  6117. }
  6118. if (!message || !*message) {
  6119. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6120. return -1;
  6121. }
  6122. homunid = atoi(message);
  6123. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6124. {
  6125. clif_displaymessage(fd, "Invalid Homunculus id.");
  6126. return -1;
  6127. }
  6128. merc_create_homunculus_request(sd,homunid);
  6129. return 0;
  6130. }
  6131. /*==========================================
  6132. * modify homunculus intimacy [orn]
  6133. *------------------------------------------*/
  6134. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6135. {
  6136. int friendly = 0;
  6137. nullpo_retr(-1, sd);
  6138. if ( !merc_is_hom_active(sd->hd) ) {
  6139. clif_displaymessage(fd, "You do not have a homunculus.");
  6140. return -1;
  6141. }
  6142. if (!message || !*message) {
  6143. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6144. return -1;
  6145. }
  6146. friendly = atoi(message);
  6147. friendly = cap_value(friendly, 0, 1000);
  6148. sd->hd->homunculus.intimacy = friendly * 100 ;
  6149. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6150. return 0;
  6151. }
  6152. /*==========================================
  6153. * modify homunculus hunger [orn]
  6154. *------------------------------------------*/
  6155. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6156. {
  6157. int hungry = 0;
  6158. nullpo_retr(-1, sd);
  6159. if ( !merc_is_hom_active(sd->hd) ) {
  6160. clif_displaymessage(fd, "You do not have a homunculus.");
  6161. return -1;
  6162. }
  6163. if (!message || !*message) {
  6164. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6165. return -1;
  6166. }
  6167. hungry = atoi(message);
  6168. hungry = cap_value(hungry, 0, 100);
  6169. sd->hd->homunculus.hunger = hungry;
  6170. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6171. return 0;
  6172. }
  6173. /*==========================================
  6174. * make the homunculus speak [orn]
  6175. *------------------------------------------*/
  6176. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6177. {
  6178. char mes[100],temp[100];
  6179. nullpo_retr(-1, sd);
  6180. if (sd->sc.count && //no "chatting" while muted.
  6181. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  6182. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  6183. return -1;
  6184. if ( !merc_is_hom_active(sd->hd) ) {
  6185. clif_displaymessage(fd, "You do not have a homunculus.");
  6186. return -1;
  6187. }
  6188. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6189. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6190. return -1;
  6191. }
  6192. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6193. clif_message(&sd->hd->bl, temp);
  6194. return 0;
  6195. }
  6196. /*==========================================
  6197. * Show homunculus stats
  6198. *------------------------------------------*/
  6199. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6200. {
  6201. struct homun_data *hd;
  6202. struct status_data *status;
  6203. nullpo_retr(-1, sd);
  6204. if ( !merc_is_hom_active(sd->hd) ) {
  6205. clif_displaymessage(fd, "You do not have a homunculus.");
  6206. return -1;
  6207. }
  6208. hd = sd->hd;
  6209. status = status_get_status_data(&hd->bl);
  6210. clif_displaymessage(fd, "Homunculus stats :");
  6211. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6212. status->hp, status->max_hp, status->sp, status->max_sp);
  6213. clif_displaymessage(fd, atcmd_output);
  6214. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6215. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6216. clif_displaymessage(fd, atcmd_output);
  6217. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6218. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6219. clif_displaymessage(fd, atcmd_output);
  6220. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6221. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6222. status->str, status->agi, status->vit,
  6223. status->int_, status->dex, status->luk);
  6224. clif_displaymessage(fd, atcmd_output);
  6225. return 0;
  6226. }
  6227. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6228. {
  6229. struct homun_data *hd;
  6230. struct s_homunculus_db *db;
  6231. struct s_homunculus *hom;
  6232. int lv, min, max, evo;
  6233. nullpo_retr(-1, sd);
  6234. if ( !merc_is_hom_active(sd->hd) ) {
  6235. clif_displaymessage(fd, "You do not have a homunculus.");
  6236. return -1;
  6237. }
  6238. hd = sd->hd;
  6239. hom = &hd->homunculus;
  6240. db = hd->homunculusDB;
  6241. lv = hom->level;
  6242. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6243. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6244. clif_displaymessage(fd, atcmd_output);
  6245. lv--; //Since the first increase is at level 2.
  6246. evo = (hom->class_ == db->evo_class);
  6247. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6248. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6249. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6250. clif_displaymessage(fd, atcmd_output);
  6251. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6252. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6253. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6254. clif_displaymessage(fd, atcmd_output);
  6255. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6256. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6257. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6258. clif_displaymessage(fd, atcmd_output);
  6259. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6260. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6261. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6262. clif_displaymessage(fd, atcmd_output);
  6263. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6264. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6265. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6266. clif_displaymessage(fd, atcmd_output);
  6267. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6268. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6269. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6270. clif_displaymessage(fd, atcmd_output);
  6271. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6272. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6273. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6274. clif_displaymessage(fd, atcmd_output);
  6275. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6276. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6277. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6278. clif_displaymessage(fd, atcmd_output);
  6279. return 0;
  6280. }
  6281. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6282. {
  6283. TBL_PC* tsd = sd;
  6284. nullpo_retr(-1, sd);
  6285. if ((!message || !*message) && !sd->hd)
  6286. {
  6287. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  6288. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  6289. return -1;
  6290. }
  6291. if (message && *message) {
  6292. tsd = map_nick2sd((char*)message);
  6293. if (!tsd) {
  6294. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6295. return -1;
  6296. }
  6297. if (pc_isGM(tsd) > pc_isGM(sd)) {
  6298. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6299. return -1;
  6300. }
  6301. }
  6302. if(!merc_hom_shuffle(tsd->hd))
  6303. return -1;
  6304. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6305. //Print out the new stats
  6306. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  6307. atcommand_homstats(fd, tsd, command, message);
  6308. return 0;
  6309. }
  6310. /*==========================================
  6311. * Show Items DB Info v 1.0
  6312. * originally by [Lupus] eAthena
  6313. *------------------------------------------*/
  6314. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6315. {
  6316. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  6317. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  6318. struct item_data *item_data, *item_array[MAX_SEARCH];
  6319. int i, count = 1;
  6320. if (!message || !*message) {
  6321. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6322. return -1;
  6323. }
  6324. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6325. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6326. if (!count) {
  6327. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6328. return -1;
  6329. }
  6330. if (count > MAX_SEARCH) {
  6331. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6332. clif_displaymessage(fd, atcmd_output);
  6333. count = MAX_SEARCH;
  6334. }
  6335. for (i = 0; i < count; i++) {
  6336. item_data = item_array[i];
  6337. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6338. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6339. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  6340. (item_data->script==NULL)? "None" : "With script"
  6341. );
  6342. clif_displaymessage(fd, atcmd_output);
  6343. 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. );
  6344. clif_displaymessage(fd, atcmd_output);
  6345. if (item_data->maxchance == 10000)
  6346. strcpy(atcmd_output, " - Available in the shops only");
  6347. else if (item_data->maxchance)
  6348. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6349. else
  6350. strcpy(atcmd_output, " - Monsters don't drop this item");
  6351. clif_displaymessage(fd, atcmd_output);
  6352. }
  6353. return 0;
  6354. }
  6355. /*==========================================
  6356. * Show who drops the item.
  6357. *------------------------------------------*/
  6358. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6359. {
  6360. struct item_data *item_data, *item_array[MAX_SEARCH];
  6361. int i,j, count = 1;
  6362. if (!message || !*message) {
  6363. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6364. return -1;
  6365. }
  6366. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6367. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6368. if (!count) {
  6369. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6370. return -1;
  6371. }
  6372. if (count > MAX_SEARCH) {
  6373. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6374. clif_displaymessage(fd, atcmd_output);
  6375. count = MAX_SEARCH;
  6376. }
  6377. for (i = 0; i < count; i++) {
  6378. item_data = item_array[i];
  6379. sprintf(atcmd_output, "Item: '%s'[%d]",
  6380. item_data->jname,item_data->slot);
  6381. clif_displaymessage(fd, atcmd_output);
  6382. if (item_data->mob[0].chance == 0) {
  6383. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6384. clif_displaymessage(fd, atcmd_output);
  6385. } else {
  6386. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6387. clif_displaymessage(fd, atcmd_output);
  6388. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6389. {
  6390. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6391. clif_displaymessage(fd, atcmd_output);
  6392. }
  6393. }
  6394. }
  6395. return 0;
  6396. }
  6397. int atcommand_whereis(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6398. {
  6399. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6400. int count;
  6401. int i, j, k;
  6402. if (!message || !*message) {
  6403. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6404. return -1;
  6405. }
  6406. // If monster identifier/name argument is a name
  6407. if ((i = mobdb_checkid(atoi(message))))
  6408. {
  6409. mob_array[0] = mob_db(i);
  6410. count = 1;
  6411. } else
  6412. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6413. if (!count) {
  6414. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6415. return -1;
  6416. }
  6417. if (count > MAX_SEARCH) {
  6418. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6419. clif_displaymessage(fd, atcmd_output);
  6420. count = MAX_SEARCH;
  6421. }
  6422. for (k = 0; k < count; k++) {
  6423. mob = mob_array[k];
  6424. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6425. clif_displaymessage(fd, atcmd_output);
  6426. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6427. {
  6428. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6429. if (j < 0) continue;
  6430. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6431. clif_displaymessage(fd, atcmd_output);
  6432. }
  6433. if (i == 0)
  6434. clif_displaymessage(fd, "This monster does not spawn normally.");
  6435. }
  6436. return 0;
  6437. }
  6438. /*==========================================
  6439. * @adopt by [Veider]
  6440. * adopt a novice
  6441. *------------------------------------------*/
  6442. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6443. {
  6444. struct map_session_data *pl_sd1 = NULL;
  6445. struct map_session_data *pl_sd2 = NULL;
  6446. struct map_session_data *pl_sd3 = NULL;
  6447. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6448. nullpo_retr(-1, sd);
  6449. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6450. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  6451. return -1;
  6452. }
  6453. if (battle_config.etc_log)
  6454. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6455. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6456. sprintf(player2, "Cannot find player %s online", player1);
  6457. clif_displaymessage(fd, player2);
  6458. return -1;
  6459. }
  6460. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6461. sprintf(player1, "Cannot find player %s online", player2);
  6462. clif_displaymessage(fd, player1);
  6463. return -1;
  6464. }
  6465. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6466. sprintf(player1, "Cannot find player %s online", player3);
  6467. clif_displaymessage(fd, player1);
  6468. return -1;
  6469. }
  6470. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  6471. clif_displaymessage(fd, "They are family.. wish them luck");
  6472. return 0;
  6473. }
  6474. else
  6475. return -1;
  6476. }
  6477. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6478. {
  6479. const char * revision;
  6480. if ((revision = get_svn_revision()) != 0) {
  6481. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6482. clif_displaymessage(fd,atcmd_output);
  6483. } else
  6484. clif_displaymessage(fd,"Cannot determine SVN revision");
  6485. return 0;
  6486. }
  6487. /*==========================================
  6488. * @mutearea by MouseJstr
  6489. *------------------------------------------*/
  6490. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6491. {
  6492. int time, id;
  6493. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6494. if (pl_sd == NULL)
  6495. return 0;
  6496. id = va_arg(ap, int);
  6497. time = va_arg(ap, int);
  6498. if (id != bl->id && !pc_isGM(pl_sd)) {
  6499. pl_sd->status.manner -= time;
  6500. if (pl_sd->status.manner < 0)
  6501. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6502. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  6503. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  6504. }
  6505. return 0;
  6506. }
  6507. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6508. {
  6509. int time;
  6510. nullpo_retr(0, sd);
  6511. if (!message || !*message) {
  6512. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6513. return -1;
  6514. }
  6515. time = atoi(message);
  6516. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6517. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6518. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6519. return 0;
  6520. }
  6521. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6522. {
  6523. char buf[255];
  6524. nullpo_retr(0, sd);
  6525. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  6526. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6527. clif_displaymessage(fd, buf);
  6528. return 0;
  6529. }
  6530. /*==========================================
  6531. * @me by lordalfa
  6532. * => Displays the OUTPUT string on top of the Visible players Heads.
  6533. *------------------------------------------*/
  6534. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6535. {
  6536. char tempmes[200];
  6537. nullpo_retr(-1, sd);
  6538. memset(tempmes, '\0', sizeof(tempmes));
  6539. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6540. if (sd->sc.count && //no "chatting" while muted.
  6541. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  6542. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  6543. return -1;
  6544. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6545. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6546. return -1;
  6547. }
  6548. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6549. clif_disp_overhead(sd, atcmd_output);
  6550. return 0;
  6551. }
  6552. /*==========================================
  6553. * @size
  6554. * => Resize your character sprite. [Valaris]
  6555. *------------------------------------------*/
  6556. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6557. {
  6558. int size=0;
  6559. nullpo_retr(-1, sd);
  6560. size = atoi(message);
  6561. if(sd->state.size) {
  6562. sd->state.size=0;
  6563. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  6564. }
  6565. if(size==1) {
  6566. sd->state.size=1;
  6567. clif_specialeffect(&sd->bl,420,AREA);
  6568. } else if(size==2) {
  6569. sd->state.size=2;
  6570. clif_specialeffect(&sd->bl,422,AREA);
  6571. }
  6572. return 0;
  6573. }
  6574. /*==========================================
  6575. * @monsterignore
  6576. * => Makes monsters ignore you. [Valaris]
  6577. *------------------------------------------*/
  6578. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6579. {
  6580. nullpo_retr(-1, sd);
  6581. if (!sd->state.monster_ignore) {
  6582. sd->state.monster_ignore = 1;
  6583. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6584. } else {
  6585. sd->state.monster_ignore = 0;
  6586. clif_displaymessage(sd->fd, "Returned to normal state.");
  6587. }
  6588. return 0;
  6589. }
  6590. /*==========================================
  6591. * @fakename
  6592. * => Gives your character a fake name. [Valaris]
  6593. *------------------------------------------*/
  6594. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6595. {
  6596. char name[NAME_LENGTH];
  6597. nullpo_retr(-1, sd);
  6598. if((!message || !*message) && strlen(sd->fakename) > 1) {
  6599. sd->fakename[0]='\0';
  6600. clif_charnameack(0, &sd->bl);
  6601. clif_displaymessage(sd->fd,"Returned to real name.");
  6602. return 0;
  6603. }
  6604. if (!message || !*message || sscanf(message, "%23[^\n]", name) < 1) {
  6605. clif_displaymessage(sd->fd,"You must enter a name.");
  6606. return -1;
  6607. }
  6608. if(strlen(name) < 2) {
  6609. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  6610. return -1;
  6611. }
  6612. memcpy(sd->fakename,name,NAME_LENGTH);
  6613. sd->fakename[NAME_LENGTH-1] = '\0';
  6614. clif_charnameack(0, &sd->bl);
  6615. clif_displaymessage(sd->fd,"Fake name enabled.");
  6616. return 0;
  6617. }
  6618. /*==========================================
  6619. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  6620. * => Shows information about the map flags [map name]
  6621. * Also set flags
  6622. *------------------------------------------*/
  6623. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6624. {
  6625. // WIP
  6626. return 0;
  6627. }
  6628. /*===================================
  6629. * Remove some messages
  6630. *-----------------------------------*/
  6631. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6632. {
  6633. if (sd->state.showexp) {
  6634. sd->state.showexp = 0;
  6635. clif_displaymessage(fd, "Gained exp will not be shown.");
  6636. return 0;
  6637. }
  6638. sd->state.showexp = 1;
  6639. clif_displaymessage(fd, "Gained exp is now shown");
  6640. return 0;
  6641. }
  6642. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6643. {
  6644. if (sd->state.showzeny) {
  6645. sd->state.showzeny = 0;
  6646. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6647. return 0;
  6648. }
  6649. sd->state.showzeny = 1;
  6650. clif_displaymessage(fd, "Gained zeny is now shown");
  6651. return 0;
  6652. }
  6653. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6654. {
  6655. if (sd->state.showdelay) {
  6656. sd->state.showdelay = 0;
  6657. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6658. return 0;
  6659. }
  6660. sd->state.showdelay = 1;
  6661. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6662. return 0;
  6663. }
  6664. /*==========================================
  6665. * Duel organizing functions [LuzZza]
  6666. *
  6667. * @duel [limit|nick] - create a duel
  6668. * @invite <nick> - invite player
  6669. * @accept - accept invitation
  6670. * @reject - reject invitation
  6671. * @leave - leave duel
  6672. *------------------------------------------*/
  6673. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6674. {
  6675. unsigned int did = sd->duel_group;
  6676. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6677. if(did <= 0) {
  6678. // "Duel: @invite without @duel."
  6679. clif_displaymessage(fd, msg_txt(350));
  6680. return 0;
  6681. }
  6682. if(duel_list[did].max_players_limit > 0 &&
  6683. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6684. // "Duel: Limit of players is reached."
  6685. clif_displaymessage(fd, msg_txt(351));
  6686. return 0;
  6687. }
  6688. if(target_sd == NULL) {
  6689. // "Duel: Player not found."
  6690. clif_displaymessage(fd, msg_txt(352));
  6691. return 0;
  6692. }
  6693. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6694. // "Duel: Player already in duel."
  6695. clif_displaymessage(fd, msg_txt(353));
  6696. return 0;
  6697. }
  6698. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6699. {
  6700. sprintf(atcmd_output, msg_txt(364), message);
  6701. clif_displaymessage(fd, atcmd_output);
  6702. return 0;
  6703. }
  6704. duel_invite(did, sd, target_sd);
  6705. // "Duel: Invitation has been sent."
  6706. clif_displaymessage(fd, msg_txt(354));
  6707. return 0;
  6708. }
  6709. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6710. {
  6711. char output[256];
  6712. unsigned int maxpl=0, newduel;
  6713. struct map_session_data *target_sd;
  6714. if(sd->duel_group > 0) {
  6715. duel_showinfo(sd->duel_group, sd);
  6716. return 0;
  6717. }
  6718. if(sd->duel_invite > 0) {
  6719. // "Duel: @duel without @reject."
  6720. clif_displaymessage(fd, msg_txt(355));
  6721. return 0;
  6722. }
  6723. if(!duel_checktime(sd)) {
  6724. // "Duel: You can take part in duel only one time per %d minutes."
  6725. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6726. clif_displaymessage(fd, output);
  6727. return 0;
  6728. }
  6729. if(strlen(message) > 0) {
  6730. if(sscanf(message, "%d", &maxpl) >= 1) {
  6731. if(maxpl < 2 || maxpl > 65535) {
  6732. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6733. return 0;
  6734. }
  6735. duel_create(sd, maxpl);
  6736. } else {
  6737. target_sd = map_nick2sd((char *)message);
  6738. if(target_sd != NULL) {
  6739. if((newduel = duel_create(sd, 2)) != -1) {
  6740. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6741. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6742. return 0;
  6743. }
  6744. duel_invite(newduel, sd, target_sd);
  6745. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6746. }
  6747. } else {
  6748. // "Duel: Player not found."
  6749. clif_displaymessage(fd, msg_txt(352));
  6750. return 0;
  6751. }
  6752. }
  6753. } else
  6754. duel_create(sd, 0);
  6755. return 0;
  6756. }
  6757. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6758. {
  6759. if(sd->duel_group <= 0) {
  6760. // "Duel: @leave without @duel."
  6761. clif_displaymessage(fd, msg_txt(358));
  6762. return 0;
  6763. }
  6764. duel_leave(sd->duel_group, sd);
  6765. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6766. return 0;
  6767. }
  6768. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6769. {
  6770. char output[256];
  6771. if(!duel_checktime(sd)) {
  6772. // "Duel: You can take part in duel only one time per %d minutes."
  6773. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6774. clif_displaymessage(fd, output);
  6775. return 0;
  6776. }
  6777. if(sd->duel_invite <= 0) {
  6778. // "Duel: @accept without invititation."
  6779. clif_displaymessage(fd, msg_txt(360));
  6780. return 0;
  6781. }
  6782. duel_accept(sd->duel_invite, sd);
  6783. // "Duel: Invitation has been accepted."
  6784. clif_displaymessage(fd, msg_txt(361));
  6785. return 0;
  6786. }
  6787. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6788. {
  6789. if(sd->duel_invite <= 0) {
  6790. // "Duel: @reject without invititation."
  6791. clif_displaymessage(fd, msg_txt(362));
  6792. return 0;
  6793. }
  6794. duel_reject(sd->duel_invite, sd);
  6795. // "Duel: Invitation has been rejected."
  6796. clif_displaymessage(fd, msg_txt(363));
  6797. return 0;
  6798. }
  6799. /*===================================
  6800. * Away message (@away, @aw) [LuzZza]
  6801. *-----------------------------------*/
  6802. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6803. {
  6804. if(strlen(message) > 0) {
  6805. if(strlen(message) > 128)
  6806. return -1;
  6807. strcpy(sd->away_message, message);
  6808. //"Away automessage has been activated."
  6809. clif_displaymessage(fd, msg_txt(546));
  6810. } else {
  6811. if(strlen(sd->away_message) > 0) {
  6812. sd->away_message[0] = 0;
  6813. //"Away automessage has been disabled."
  6814. clif_displaymessage(fd, msg_txt(547));
  6815. return 0;
  6816. }
  6817. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  6818. clif_displaymessage(fd, msg_txt(548));
  6819. }
  6820. return 0;
  6821. }
  6822. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6823. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6824. {
  6825. int x=0,y=0,flag=0,master=0,i=0;
  6826. struct map_session_data *pl_sd=NULL;
  6827. if (!message || !*message) {
  6828. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6829. return 0;
  6830. }
  6831. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6832. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6833. return 0;
  6834. }
  6835. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  6836. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6837. return 0;
  6838. }
  6839. if (strcmpi(command, "@clone") == 0)
  6840. flag = 1;
  6841. else if (strcmpi(command, "@slaveclone") == 0) {
  6842. flag = 2;
  6843. master = sd->bl.id;
  6844. if (battle_config.atc_slave_clone_limit
  6845. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6846. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6847. return 0;
  6848. }
  6849. }
  6850. do {
  6851. x = sd->bl.x + (rand() % 10 - 5);
  6852. y = sd->bl.y + (rand() % 10 - 5);
  6853. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6854. if (i >= 10) {
  6855. x = sd->bl.x;
  6856. y = sd->bl.y;
  6857. }
  6858. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6859. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6860. return 0;
  6861. }
  6862. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6863. return 0;
  6864. }
  6865. /*===================================
  6866. * Main chat [LuzZza]
  6867. * Usage: @main <on|off|message>
  6868. *-----------------------------------*/
  6869. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6870. {
  6871. if(strlen(message) > 0) {
  6872. if(strcmpi(message, "on") == 0) {
  6873. if(!sd->state.mainchat) {
  6874. sd->state.mainchat = 1;
  6875. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6876. } else {
  6877. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6878. }
  6879. } else if(strcmpi(message, "off") == 0) {
  6880. if(sd->state.mainchat) {
  6881. sd->state.mainchat = 0;
  6882. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6883. } else {
  6884. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6885. }
  6886. } else {
  6887. if(!sd->state.mainchat) {
  6888. sd->state.mainchat = 1;
  6889. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6890. }
  6891. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  6892. clif_displaymessage(fd, msg_txt(387));
  6893. return -1;
  6894. }
  6895. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  6896. // I use 0xFE000000 color for signalizing that this message is
  6897. // main chat message. 0xFE000000 is invalid color, same using
  6898. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  6899. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  6900. // Chat logging type 'M' / Main Chat
  6901. if( log_config.chat&1 || (log_config.chat&32 && !(agit_flag && log_config.chat&64)) )
  6902. log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  6903. }
  6904. } else {
  6905. if(sd->state.mainchat)
  6906. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6907. else
  6908. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6909. }
  6910. return 0;
  6911. }
  6912. /*=====================================
  6913. * Autorejecting Invites/Deals [LuzZza]
  6914. * Usage: @noask
  6915. *-------------------------------------*/
  6916. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6917. {
  6918. if(sd->state.noask) {
  6919. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6920. sd->state.noask = 0;
  6921. } else {
  6922. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6923. sd->state.noask = 1;
  6924. }
  6925. return 0;
  6926. }
  6927. /*=====================================
  6928. * Send a @request message to all GMs of lowest_gm_level.
  6929. * Usage: @request <petition>
  6930. *-------------------------------------*/
  6931. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6932. {
  6933. if (!message || !*message) {
  6934. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6935. return -1;
  6936. }
  6937. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6938. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  6939. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6940. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6941. return 0;
  6942. }
  6943. /*==========================================
  6944. * Feel (SG save map) Reset [HiddenDragon]
  6945. *------------------------------------------*/
  6946. int atcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6947. {
  6948. pc_resetfeel(sd);
  6949. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  6950. return 0;
  6951. }
  6952. /*==========================================
  6953. * atcommand_info[] structure definition
  6954. *------------------------------------------*/
  6955. AtCommandInfo atcommand_info[] = {
  6956. { "rura", 40, atcommand_mapmove },
  6957. { "warp", 40, atcommand_mapmove },
  6958. { "mapmove", 40, atcommand_mapmove }, // + /mm
  6959. { "where", 1, atcommand_where },
  6960. { "jumpto", 20, atcommand_jumpto }, // + /shift
  6961. { "warpto", 20, atcommand_jumpto },
  6962. { "goto", 20, atcommand_jumpto },
  6963. { "jump", 40, atcommand_jump },
  6964. { "who", 20, atcommand_who },
  6965. { "whois", 20, atcommand_who },
  6966. { "who2", 20, atcommand_who2 },
  6967. { "who3", 20, atcommand_who3 },
  6968. { "whomap", 20, atcommand_whomap },
  6969. { "whomap2", 20, atcommand_whomap2 },
  6970. { "whomap3", 20, atcommand_whomap3 },
  6971. { "whogm", 20, atcommand_whogm },
  6972. { "save", 40, atcommand_save },
  6973. { "return", 40, atcommand_load },
  6974. { "load", 40, atcommand_load },
  6975. { "speed", 40, atcommand_speed },
  6976. { "storage", 1, atcommand_storage },
  6977. { "gstorage", 50, atcommand_guildstorage },
  6978. { "option", 40, atcommand_option },
  6979. { "hide", 40, atcommand_hide }, // + /hide
  6980. { "jobchange", 40, atcommand_jobchange },
  6981. { "job", 40, atcommand_jobchange },
  6982. { "die", 1, atcommand_die },
  6983. { "kill", 60, atcommand_kill },
  6984. { "alive", 60, atcommand_alive },
  6985. { "kami", 40, atcommand_kami },
  6986. { "kamib", 40, atcommand_kami },
  6987. { "kamic", 40, atcommand_kami },
  6988. { "heal", 40, atcommand_heal },
  6989. { "item", 60, atcommand_item },
  6990. { "item2", 60, atcommand_item2 },
  6991. { "itemreset", 40, atcommand_itemreset },
  6992. { "blvl", 60, atcommand_baselevelup },
  6993. { "lvup", 60, atcommand_baselevelup },
  6994. { "blevel", 60, atcommand_baselevelup },
  6995. { "baselvl", 60, atcommand_baselevelup },
  6996. { "baselvup", 60, atcommand_baselevelup },
  6997. { "baselevel", 60, atcommand_baselevelup },
  6998. { "baselvlup", 60, atcommand_baselevelup },
  6999. { "jlvl", 60, atcommand_joblevelup },
  7000. { "jlevel", 60, atcommand_joblevelup },
  7001. { "joblvl", 60, atcommand_joblevelup },
  7002. { "joblevel", 60, atcommand_joblevelup },
  7003. { "joblvup", 60, atcommand_joblevelup },
  7004. { "joblvlup", 60, atcommand_joblevelup },
  7005. { "h", 20, atcommand_help },
  7006. { "help", 20, atcommand_help },
  7007. { "h2", 20, atcommand_help2 },
  7008. { "help2", 20, atcommand_help2 },
  7009. { "gm", 100, atcommand_gm },
  7010. { "pvpoff", 40, atcommand_pvpoff },
  7011. { "pvpon", 40, atcommand_pvpon },
  7012. { "gvgoff", 40, atcommand_gvgoff },
  7013. { "gpvpoff", 40, atcommand_gvgoff },
  7014. { "gvgon", 40, atcommand_gvgon },
  7015. { "gpvpon", 40, atcommand_gvgon },
  7016. { "model", 20, atcommand_model },
  7017. { "go", 10, atcommand_go },
  7018. { "monster", 50, atcommand_monster },
  7019. { "spawn", 50, atcommand_monster },
  7020. { "monstersmall", 50, atcommand_monstersmall },
  7021. { "monsterbig", 50, atcommand_monsterbig },
  7022. { "killmonster", 60, atcommand_killmonster },
  7023. { "killmonster2", 40, atcommand_killmonster2 },
  7024. { "refine", 60, atcommand_refine },
  7025. { "produce", 60, atcommand_produce },
  7026. { "memo", 40, atcommand_memo },
  7027. { "gat", 99, atcommand_gat },
  7028. { "displaystatus", 99, atcommand_displaystatus },
  7029. { "stpoint", 60, atcommand_statuspoint },
  7030. { "skpoint", 60, atcommand_skillpoint },
  7031. { "zeny", 60, atcommand_zeny },
  7032. { "str", 60, atcommand_param },
  7033. { "agi", 60, atcommand_param },
  7034. { "vit", 60, atcommand_param },
  7035. { "int", 60, atcommand_param },
  7036. { "dex", 60, atcommand_param },
  7037. { "luk", 60, atcommand_param },
  7038. { "glvl", 60, atcommand_guildlevelup },
  7039. { "glevel", 60, atcommand_guildlevelup },
  7040. { "guildlvl", 60, atcommand_guildlevelup },
  7041. { "guildlvup", 60, atcommand_guildlevelup },
  7042. { "guildlevel", 60, atcommand_guildlevelup },
  7043. { "guildlvlup", 60, atcommand_guildlevelup },
  7044. { "makeegg", 60, atcommand_makeegg },
  7045. { "hatch", 60, atcommand_hatch },
  7046. { "petfriendly", 40, atcommand_petfriendly },
  7047. { "pethungry", 40, atcommand_pethungry },
  7048. { "petrename", 1, atcommand_petrename },
  7049. { "recall", 60, atcommand_recall }, // + /recall
  7050. { "night", 80, atcommand_night },
  7051. { "day", 80, atcommand_day },
  7052. { "doom", 80, atcommand_doom },
  7053. { "doommap", 80, atcommand_doommap },
  7054. { "raise", 80, atcommand_raise },
  7055. { "raisemap", 80, atcommand_raisemap },
  7056. { "kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7057. { "kickall", 99, atcommand_kickall },
  7058. { "allskill", 60, atcommand_allskill },
  7059. { "allskills", 60, atcommand_allskill },
  7060. { "skillall", 60, atcommand_allskill },
  7061. { "skillsall", 60, atcommand_allskill },
  7062. { "questskill", 40, atcommand_questskill },
  7063. { "lostskill", 40, atcommand_lostskill },
  7064. { "spiritball", 40, atcommand_spiritball },
  7065. { "party", 1, atcommand_party },
  7066. { "guild", 50, atcommand_guild },
  7067. { "agitstart", 60, atcommand_agitstart },
  7068. { "agitend", 60, atcommand_agitend },
  7069. { "mapexit", 99, atcommand_mapexit },
  7070. { "idsearch", 60, atcommand_idsearch },
  7071. { "broadcast", 40, atcommand_broadcast }, // + /b and /nb
  7072. { "localbroadcast", 40, atcommand_localbroadcast }, // + /lb and /nlb
  7073. { "recallall", 80, atcommand_recallall },
  7074. { "reloaditemdb", 99, atcommand_reloaditemdb },
  7075. { "reloadmobdb", 99, atcommand_reloadmobdb },
  7076. { "reloadskilldb", 99, atcommand_reloadskilldb },
  7077. { "reloadscript", 99, atcommand_reloadscript },
  7078. { "reloadgmdb", 99, atcommand_reloadgmdb },
  7079. { "reloadatcommand", 99, atcommand_reloadatcommand },
  7080. { "reloadbattleconf", 99, atcommand_reloadbattleconf },
  7081. { "reloadstatusdb", 99, atcommand_reloadstatusdb },
  7082. { "reloadpcdb", 99, atcommand_reloadpcdb },
  7083. { "reloadmotd", 99, atcommand_reloadmotd },
  7084. { "mapinfo", 99, atcommand_mapinfo },
  7085. { "dye", 40, atcommand_dye },
  7086. { "ccolor", 40, atcommand_dye },
  7087. { "hairstyle", 40, atcommand_hair_style },
  7088. { "hstyle", 40, atcommand_hair_style },
  7089. { "haircolor", 40, atcommand_hair_color },
  7090. { "hcolor", 40, atcommand_hair_color },
  7091. { "statall", 60, atcommand_stat_all },
  7092. { "statsall", 60, atcommand_stat_all },
  7093. { "allstats", 60, atcommand_stat_all },
  7094. { "allstat", 60, atcommand_stat_all },
  7095. { "block", 60, atcommand_char_block },
  7096. { "charblock", 60, atcommand_char_block },
  7097. { "ban", 60, atcommand_char_ban },
  7098. { "banish", 60, atcommand_char_ban },
  7099. { "charban", 60, atcommand_char_ban },
  7100. { "charbanish", 60, atcommand_char_ban },
  7101. { "unblock", 60, atcommand_char_unblock },
  7102. { "charunblock", 60, atcommand_char_unblock },
  7103. { "unban", 60, atcommand_char_unban },
  7104. { "unbanish", 60, atcommand_char_unban },
  7105. { "charunban", 60, atcommand_char_unban },
  7106. { "charunbanish", 60, atcommand_char_unban },
  7107. { "mount", 20, atcommand_mount_peco },
  7108. { "mountpeco", 20, atcommand_mount_peco },
  7109. { "guildspy", 60, atcommand_guildspy },
  7110. { "partyspy", 60, atcommand_partyspy },
  7111. { "repairall", 60, atcommand_repairall },
  7112. { "guildrecall", 60, atcommand_guildrecall },
  7113. { "partyrecall", 60, atcommand_partyrecall },
  7114. { "nuke", 60, atcommand_nuke },
  7115. { "shownpc", 80, atcommand_shownpc },
  7116. { "hidenpc", 80, atcommand_hidenpc },
  7117. { "loadnpc", 80, atcommand_loadnpc },
  7118. { "unloadnpc", 80, atcommand_unloadnpc },
  7119. { "time", 1, atcommand_servertime },
  7120. { "date", 1, atcommand_servertime },
  7121. { "serverdate", 1, atcommand_servertime },
  7122. { "servertime", 1, atcommand_servertime },
  7123. { "jail", 60, atcommand_jail },
  7124. { "unjail", 60, atcommand_unjail },
  7125. { "discharge", 60, atcommand_unjail },
  7126. { "jailfor", 60, atcommand_jailfor },
  7127. { "jailtime", 1, atcommand_jailtime },
  7128. { "disguise", 20, atcommand_disguise },
  7129. { "undisguise", 20, atcommand_undisguise },
  7130. { "email", 1, atcommand_email },
  7131. { "effect", 40, atcommand_effect },
  7132. { "follow", 20, atcommand_follow },
  7133. { "addwarp", 60, atcommand_addwarp },
  7134. { "skillon", 80, atcommand_skillon },
  7135. { "skilloff", 80, atcommand_skilloff },
  7136. { "killer", 60, atcommand_killer },
  7137. { "npcmove", 80, atcommand_npcmove },
  7138. { "killable", 40, atcommand_killable },
  7139. { "dropall", 40, atcommand_dropall },
  7140. { "storeall", 40, atcommand_storeall },
  7141. { "skillid", 40, atcommand_skillid },
  7142. { "useskill", 40, atcommand_useskill },
  7143. { "displayskill", 99, atcommand_displayskill },
  7144. { "snow", 99, atcommand_snow },
  7145. { "sakura", 99, atcommand_sakura },
  7146. { "clouds", 99, atcommand_clouds },
  7147. { "clouds2", 99, atcommand_clouds2 },
  7148. { "fog", 99, atcommand_fog },
  7149. { "fireworks", 99, atcommand_fireworks },
  7150. { "leaves", 99, atcommand_leaves },
  7151. { "summon", 60, atcommand_summon },
  7152. { "adjgmlvl", 99, atcommand_adjgmlvl },
  7153. { "adjcmdlvl", 99, atcommand_adjcmdlvl },
  7154. { "trade", 60, atcommand_trade },
  7155. { "send", 99, atcommand_send },
  7156. { "setbattleflag", 99, atcommand_setbattleflag },
  7157. { "unmute", 80, atcommand_unmute },
  7158. { "clearweather", 99, atcommand_clearweather },
  7159. { "uptime", 1, atcommand_uptime },
  7160. { "changesex", 60, atcommand_changesex },
  7161. { "mute", 80, atcommand_mute },
  7162. { "whozeny", 20, atcommand_whozeny },
  7163. { "refresh", 1, atcommand_refresh },
  7164. { "identify", 40, atcommand_identify },
  7165. { "gmotd", 20, atcommand_gmotd },
  7166. { "misceffect", 50, atcommand_misceffect },
  7167. { "mobsearch", 10, atcommand_mobsearch },
  7168. { "cleanmap", 40, atcommand_cleanmap },
  7169. { "npctalk", 20, atcommand_npctalk },
  7170. { "pettalk", 10, atcommand_pettalk },
  7171. { "users", 40, atcommand_users },
  7172. { "reset", 40, atcommand_reset },
  7173. { "skilltree", 40, atcommand_skilltree },
  7174. { "marry", 40, atcommand_marry },
  7175. { "divorce", 40, atcommand_divorce },
  7176. { "sound", 40, atcommand_sound },
  7177. { "undisguiseall", 99, atcommand_undisguiseall },
  7178. { "disguiseall", 99, atcommand_disguiseall },
  7179. { "changelook", 60, atcommand_changelook },
  7180. { "autoloot", 10, atcommand_autoloot },
  7181. { "mobinfo", 1, atcommand_mobinfo },
  7182. { "monsterinfo", 1, atcommand_mobinfo },
  7183. { "mi", 1, atcommand_mobinfo },
  7184. { "exp", 1, atcommand_exp },
  7185. { "adopt", 40, atcommand_adopt },
  7186. { "version", 1, atcommand_version },
  7187. { "mutearea", 99, atcommand_mutearea },
  7188. { "stfu", 99, atcommand_mutearea },
  7189. { "rates", 1, atcommand_rates },
  7190. { "iteminfo", 1, atcommand_iteminfo },
  7191. { "ii", 1, atcommand_iteminfo },
  7192. { "whodrops", 1, atcommand_whodrops },
  7193. { "whereis", 10, atcommand_whereis },
  7194. { "mapflag", 99, atcommand_mapflag },
  7195. { "me", 20, atcommand_me },
  7196. { "monsterignore", 99, atcommand_monsterignore },
  7197. { "battleignore", 99, atcommand_monsterignore },
  7198. { "fakename", 20, atcommand_fakename },
  7199. { "size", 20, atcommand_size },
  7200. { "showexp", 10, atcommand_showexp},
  7201. { "showzeny", 10, atcommand_showzeny},
  7202. { "showdelay", 1, atcommand_showdelay},
  7203. { "autotrade", 10, atcommand_autotrade },
  7204. { "at", 10, atcommand_autotrade },
  7205. { "changegm", 10, atcommand_changegm },
  7206. { "changeleader", 10, atcommand_changeleader },
  7207. { "partyoption", 10, atcommand_partyoption},
  7208. { "invite", 1, atcommand_invite },
  7209. { "duel", 1, atcommand_duel },
  7210. { "leave", 1, atcommand_leave },
  7211. { "accept", 1, atcommand_accept },
  7212. { "reject", 1, atcommand_reject },
  7213. { "away", 1, atcommand_away },
  7214. { "aw", 1, atcommand_away },
  7215. { "main", 1, atcommand_main },
  7216. { "clone", 50, atcommand_clone },
  7217. { "slaveclone", 50, atcommand_clone },
  7218. { "evilclone", 50, atcommand_clone },
  7219. { "tonpc", 40, atcommand_tonpc },
  7220. { "commands", 1, atcommand_commands },
  7221. { "noask", 1, atcommand_noask },
  7222. { "request", 20, atcommand_request },
  7223. { "hlvl", 60, atcommand_homlevel },
  7224. { "hlevel", 60, atcommand_homlevel },
  7225. { "homlvl", 60, atcommand_homlevel },
  7226. { "homlvup", 60, atcommand_homlevel },
  7227. { "homlevel", 60, atcommand_homlevel },
  7228. { "homevolve", 60, atcommand_homevolution },
  7229. { "homevolution", 60, atcommand_homevolution },
  7230. { "makehomun", 60, atcommand_makehomun },
  7231. { "homfriendly", 60, atcommand_homfriendly },
  7232. { "homhungry", 60, atcommand_homhungry },
  7233. { "homtalk", 10, atcommand_homtalk },
  7234. { "hominfo", 1, atcommand_hominfo },
  7235. { "homstats", 1, atcommand_homstats },
  7236. { "homshuffle", 60, atcommand_homshuffle },
  7237. { "showmobs", 10, atcommand_showmobs },
  7238. { "feelreset", 10, atcommand_feelreset },
  7239. #ifndef TXT_ONLY
  7240. { "mail", 1, atcommand_mail },
  7241. { "refreshonline", 99, atcommand_refreshonline },
  7242. #endif
  7243. };
  7244. /*==========================================
  7245. * Command lookup functions
  7246. *------------------------------------------*/
  7247. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  7248. {
  7249. int i;
  7250. if( *name == atcommand_symbol ) name++; // for backwards compatibility
  7251. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  7252. return ( i != ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7253. }
  7254. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  7255. {
  7256. int i;
  7257. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  7258. return ( i != ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7259. }
  7260. /*==========================================
  7261. * Retrieve the command's required gm level
  7262. *------------------------------------------*/
  7263. int get_atcommand_level(const AtCommandFunc func)
  7264. {
  7265. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  7266. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7267. }
  7268. /// Executes an at-command.
  7269. /// To be called by internal server code (bypasses various restrictions).
  7270. bool is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  7271. {
  7272. AtCommandInfo* info;
  7273. char command[100];
  7274. char args[100];
  7275. char output[200];
  7276. if( !str || !*str )
  7277. return false;
  7278. if( *str != atcommand_symbol ) // check first char
  7279. return false;
  7280. if( sscanf(str, "%99s %99[^\n]", command, args) < 2 )
  7281. args[0] = '\0';
  7282. info = get_atcommandinfo_byname(command);
  7283. if( info == NULL || info->func == NULL || gmlvl < info->level )
  7284. {
  7285. if( gmlvl == 0 )
  7286. return false; // will just display as normal text
  7287. else
  7288. {
  7289. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7290. clif_displaymessage(fd, output);
  7291. return true;
  7292. }
  7293. }
  7294. if( log_config.gm && info->level >= log_config.gm )
  7295. log_atcommand(sd, str);
  7296. if( info->func(fd, sd, command, args) != 0 )
  7297. {
  7298. sprintf(output, msg_txt(154), command); // "%s failed."
  7299. clif_displaymessage(fd, output);
  7300. }
  7301. return true;
  7302. }
  7303. /// Executes an at-command.
  7304. /// To be used by player-invoked code (restrictions will be applied).
  7305. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  7306. {
  7307. int gmlvl = pc_isGM(sd);
  7308. nullpo_retr(false, sd);
  7309. if( !message || !*message )
  7310. return false; // shouldn't happen
  7311. if( sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND )
  7312. return true; // so that it won't display as normal message
  7313. if( battle_config.atc_gmonly != 0 && gmlvl == 0 )
  7314. return false;
  7315. if( map[sd->bl.m].nocommand && gmlvl < map[sd->bl.m].nocommand )
  7316. {
  7317. clif_displaymessage(fd, msg_txt(143)); // "Commands are disabled on this map."
  7318. return false;
  7319. }
  7320. // skip 10/11-langtype's codepage indicator, if detected
  7321. if( message[0] == '|' && strlen(message) >= 4 && message[3] == atcommand_symbol )
  7322. message += 3;
  7323. return is_atcommand_sub(fd,sd,message,gmlvl);
  7324. }
  7325. /*==========================================
  7326. *
  7327. *------------------------------------------*/
  7328. int atcommand_config_read(const char* cfgName)
  7329. {
  7330. char line[1024], w1[1024], w2[1024];
  7331. AtCommandInfo* p;
  7332. FILE* fp;
  7333. if( (fp = fopen(cfgName, "r")) == NULL )
  7334. {
  7335. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  7336. return 1;
  7337. }
  7338. while( fgets(line, sizeof(line), fp) )
  7339. {
  7340. if( line[0] == '/' && line[1] == '/' )
  7341. continue;
  7342. if( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2 )
  7343. continue;
  7344. p = get_atcommandinfo_byname(w1);
  7345. if( p != NULL )
  7346. {
  7347. p->level = atoi(w2);
  7348. p->level = cap_value(p->level, 0, 100);
  7349. }
  7350. else
  7351. if( strcmpi(w1, "import") == 0 )
  7352. atcommand_config_read(w2);
  7353. else
  7354. if( strcmpi(w1, "command_symbol") == 0 &&
  7355. w2[0] > 31 && // control characters
  7356. w2[0] != '/' && // symbol of standard ragnarok GM commands
  7357. w2[0] != '%' && // symbol of party chat speaking
  7358. w2[0] != '$' && // symbol of guild chat speaking
  7359. w2[0] != '#' ) // symbol of charcommand
  7360. atcommand_symbol = w2[0];
  7361. else
  7362. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  7363. }
  7364. fclose(fp);
  7365. return 0;
  7366. }
  7367. void do_init_atcommand()
  7368. {
  7369. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  7370. duel_count = 0;
  7371. memset(&duel_list[0], 0, sizeof(duel_list));
  7372. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  7373. return;
  7374. }
  7375. void do_final_atcommand()
  7376. {
  7377. users_db->destroy(users_db,NULL);
  7378. }
  7379. // commands that need to go _after_ the commands table
  7380. /*==========================================
  7381. * @commands Lists available @ commands to you
  7382. *------------------------------------------*/
  7383. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7384. {
  7385. char line_buff[CHATBOX_SIZE];
  7386. int i, gm_lvl = pc_isGM(sd), count = 0;
  7387. char* cur = line_buff;
  7388. memset(line_buff,' ',CHATBOX_SIZE);
  7389. line_buff[CHATBOX_SIZE-1] = 0;
  7390. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7391. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  7392. {
  7393. unsigned int slen;
  7394. if( gm_lvl < atcommand_info[i].level )
  7395. continue;
  7396. slen = (unsigned int)strlen(atcommand_info[i].command);
  7397. // flush the text buffer if this command won't fit into it
  7398. if( ((CHATBOX_SIZE-1+(int)line_buff)-(int)cur) < (int)slen )
  7399. {
  7400. clif_displaymessage(fd,line_buff);
  7401. cur = line_buff;
  7402. memset(line_buff,' ',CHATBOX_SIZE);
  7403. line_buff[CHATBOX_SIZE-1] = 0;
  7404. }
  7405. memcpy(cur,atcommand_info[i].command,slen);
  7406. cur += slen+(10-slen%10);
  7407. count++;
  7408. }
  7409. clif_displaymessage(fd,line_buff);
  7410. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7411. clif_displaymessage(fd, atcmd_output);
  7412. return 0;
  7413. }