atcommand.c 278 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501
  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/random.h"
  11. #include "../common/socket.h"
  12. #include "../common/strlib.h"
  13. #include "../common/utils.h"
  14. #include "atcommand.h"
  15. #include "battle.h"
  16. #include "chat.h"
  17. #include "clif.h"
  18. #include "chrif.h"
  19. #include "duel.h"
  20. #include "intif.h"
  21. #include "itemdb.h"
  22. #include "log.h"
  23. #include "map.h"
  24. #include "pc.h"
  25. #include "status.h"
  26. #include "skill.h"
  27. #include "mob.h"
  28. #include "npc.h"
  29. #include "pet.h"
  30. #include "homunculus.h"
  31. #include "mail.h"
  32. #include "mercenary.h"
  33. #include "party.h"
  34. #include "guild.h"
  35. #include "script.h"
  36. #include "storage.h"
  37. #include "trade.h"
  38. #include "unit.h"
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include <math.h>
  43. // extern variables
  44. char atcommand_symbol = '@'; // first char of the commands
  45. char charcommand_symbol = '#';
  46. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  47. // local declarations
  48. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  49. DBMap* atcommand_db = NULL;//name -> AtCommandInfo
  50. #define ATCOMMAND_LENGTH 50
  51. typedef struct AtCommandInfo {
  52. char command[ATCOMMAND_LENGTH];
  53. int level;
  54. int level2;
  55. AtCommandFunc func;
  56. } AtCommandInfo;
  57. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  58. ACMD_FUNC(commands);
  59. ACMD_FUNC(charcommands);
  60. /*=========================================
  61. * Generic variables
  62. *-----------------------------------------*/
  63. char atcmd_output[CHAT_SIZE_MAX];
  64. char atcmd_player_name[NAME_LENGTH];
  65. char atcmd_temp[100];
  66. // compare function for sorting high to lowest
  67. int hightolow_compare (const void * a, const void * b)
  68. {
  69. return ( *(int*)b - *(int*)a );
  70. }
  71. // compare function for sorting lowest to highest
  72. int lowtohigh_compare (const void * a, const void * b)
  73. {
  74. return ( *(int*)a - *(int*)b );
  75. }
  76. //-----------------------------------------------------------
  77. // Return the message string of the specified number by [Yor]
  78. //-----------------------------------------------------------
  79. const char* msg_txt(int msg_number)
  80. {
  81. if (msg_number >= 0 && msg_number < MAX_MSG &&
  82. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  83. return msg_table[msg_number];
  84. return "??";
  85. }
  86. //-----------------------------------------------------------
  87. // Returns Players title (from msg_athena.conf) [Lupus]
  88. //-----------------------------------------------------------
  89. static char* player_title_txt(int level)
  90. {
  91. const char* format;
  92. format = (level >= battle_config.title_lvl8) ? msg_txt(342)
  93. : (level >= battle_config.title_lvl7) ? msg_txt(341)
  94. : (level >= battle_config.title_lvl6) ? msg_txt(340)
  95. : (level >= battle_config.title_lvl5) ? msg_txt(339)
  96. : (level >= battle_config.title_lvl4) ? msg_txt(338)
  97. : (level >= battle_config.title_lvl3) ? msg_txt(337)
  98. : (level >= battle_config.title_lvl2) ? msg_txt(336)
  99. : (level >= battle_config.title_lvl1) ? msg_txt(335)
  100. : "";
  101. sprintf(atcmd_temp, format, level);
  102. return atcmd_temp;
  103. }
  104. /*==========================================
  105. * Read Message Data
  106. *------------------------------------------*/
  107. int msg_config_read(const char* cfgName)
  108. {
  109. int msg_number;
  110. char line[1024], w1[1024], w2[1024];
  111. FILE *fp;
  112. static int called = 1;
  113. if ((fp = fopen(cfgName, "r")) == NULL) {
  114. ShowError("Messages file not found: %s\n", cfgName);
  115. return 1;
  116. }
  117. if ((--called) == 0)
  118. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  119. while(fgets(line, sizeof(line), fp))
  120. {
  121. if (line[0] == '/' && line[1] == '/')
  122. continue;
  123. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  124. continue;
  125. if (strcmpi(w1, "import") == 0)
  126. msg_config_read(w2);
  127. else
  128. {
  129. msg_number = atoi(w1);
  130. if (msg_number >= 0 && msg_number < MAX_MSG)
  131. {
  132. if (msg_table[msg_number] != NULL)
  133. aFree(msg_table[msg_number]);
  134. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  135. strcpy(msg_table[msg_number],w2);
  136. }
  137. }
  138. }
  139. fclose(fp);
  140. return 0;
  141. }
  142. /*==========================================
  143. * Cleanup Message Data
  144. *------------------------------------------*/
  145. void do_final_msg(void)
  146. {
  147. int i;
  148. for (i = 0; i < MAX_MSG; i++)
  149. aFree(msg_table[i]);
  150. }
  151. /*==========================================
  152. * @send (used for testing packet sends from the client)
  153. *------------------------------------------*/
  154. ACMD_FUNC(send)
  155. {
  156. int len=0,off,end,type;
  157. long num;
  158. // read message type as hex number (without the 0x)
  159. if(!message || !*message ||
  160. !((sscanf(message, "len %x", &type)==1 && (len=1))
  161. || sscanf(message, "%x", &type)==1) )
  162. {
  163. clif_displaymessage(fd, "Usage:");
  164. clif_displaymessage(fd, " @send len <packet hex number>");
  165. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  166. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  167. return -1;
  168. }
  169. #define PARSE_ERROR(error,p) \
  170. {\
  171. clif_displaymessage(fd, (error));\
  172. sprintf(atcmd_output, ">%s", (p));\
  173. clif_displaymessage(fd, atcmd_output);\
  174. }
  175. //define PARSE_ERROR
  176. #define CHECK_EOS(p) \
  177. if(*(p) == 0){\
  178. clif_displaymessage(fd, "Unexpected end of string");\
  179. return -1;\
  180. }
  181. //define CHECK_EOS
  182. #define SKIP_VALUE(p) \
  183. {\
  184. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  185. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  186. }
  187. //define SKIP_VALUE
  188. #define GET_VALUE(p,num) \
  189. {\
  190. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  191. PARSE_ERROR("Invalid number in:",(p));\
  192. return -1;\
  193. }\
  194. }
  195. //define GET_VALUE
  196. if (type > 0 && type < MAX_PACKET_DB) {
  197. if(len)
  198. {// show packet length
  199. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  200. clif_displaymessage(fd, atcmd_output);
  201. return 0;
  202. }
  203. len=packet_db[sd->packet_ver][type].len;
  204. off=2;
  205. if(len == 0)
  206. {// unknown packet - ERROR
  207. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  208. clif_displaymessage(fd, atcmd_output);
  209. return -1;
  210. } else if(len == -1)
  211. {// dynamic packet
  212. len=SHRT_MAX-4; // maximum length
  213. off=4;
  214. }
  215. WFIFOHEAD(fd, len);
  216. WFIFOW(fd,0)=TOW(type);
  217. // parse packet contents
  218. SKIP_VALUE(message);
  219. while(*message != 0 && off < len){
  220. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  221. {// default (byte)
  222. GET_VALUE(message,num);
  223. WFIFOB(fd,off)=TOB(num);
  224. ++off;
  225. } else if(TOUPPER(*message) == 'B')
  226. {// byte
  227. ++message;
  228. GET_VALUE(message,num);
  229. WFIFOB(fd,off)=TOB(num);
  230. ++off;
  231. } else if(TOUPPER(*message) == 'W')
  232. {// word (2 bytes)
  233. ++message;
  234. GET_VALUE(message,num);
  235. WFIFOW(fd,off)=TOW(num);
  236. off+=2;
  237. } else if(TOUPPER(*message) == 'L')
  238. {// long word (4 bytes)
  239. ++message;
  240. GET_VALUE(message,num);
  241. WFIFOL(fd,off)=TOL(num);
  242. off+=4;
  243. } else if(TOUPPER(*message) == 'S')
  244. {// string - escapes are valid
  245. // get string length - num <= 0 means not fixed length (default)
  246. ++message;
  247. if(*message == '"'){
  248. num=0;
  249. } else {
  250. GET_VALUE(message,num);
  251. while(*message != '"')
  252. {// find start of string
  253. if(*message == 0 || ISSPACE(*message)){
  254. PARSE_ERROR("Not a string:",message);
  255. return -1;
  256. }
  257. ++message;
  258. }
  259. }
  260. // parse string
  261. ++message;
  262. CHECK_EOS(message);
  263. end=(num<=0? 0: min(off+((int)num),len));
  264. for(; *message != '"' && (off < end || end == 0); ++off){
  265. if(*message == '\\'){
  266. ++message;
  267. CHECK_EOS(message);
  268. switch(*message){
  269. case 'a': num=0x07; break; // Bell
  270. case 'b': num=0x08; break; // Backspace
  271. case 't': num=0x09; break; // Horizontal tab
  272. case 'n': num=0x0A; break; // Line feed
  273. case 'v': num=0x0B; break; // Vertical tab
  274. case 'f': num=0x0C; break; // Form feed
  275. case 'r': num=0x0D; break; // Carriage return
  276. case 'e': num=0x1B; break; // Escape
  277. default: num=*message; break;
  278. case 'x': // Hexadecimal
  279. {
  280. ++message;
  281. CHECK_EOS(message);
  282. if(!ISXDIGIT(*message)){
  283. PARSE_ERROR("Not a hexadecimal digit:",message);
  284. return -1;
  285. }
  286. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  287. if(ISXDIGIT(*message)){
  288. ++message;
  289. CHECK_EOS(message);
  290. num<<=8;
  291. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  292. }
  293. WFIFOB(fd,off)=TOB(num);
  294. ++message;
  295. CHECK_EOS(message);
  296. continue;
  297. }
  298. case '0':
  299. case '1':
  300. case '2':
  301. case '3':
  302. case '4':
  303. case '5':
  304. case '6':
  305. case '7': // Octal
  306. {
  307. num=*message-'0'; // 1st octal digit
  308. ++message;
  309. CHECK_EOS(message);
  310. if(ISDIGIT(*message) && *message < '8'){
  311. num<<=3;
  312. num+=*message-'0'; // 2nd octal digit
  313. ++message;
  314. CHECK_EOS(message);
  315. if(ISDIGIT(*message) && *message < '8'){
  316. num<<=3;
  317. num+=*message-'0'; // 3rd octal digit
  318. ++message;
  319. CHECK_EOS(message);
  320. }
  321. }
  322. WFIFOB(fd,off)=TOB(num);
  323. continue;
  324. }
  325. }
  326. } else
  327. num=*message;
  328. WFIFOB(fd,off)=TOB(num);
  329. ++message;
  330. CHECK_EOS(message);
  331. }//for
  332. while(*message != '"')
  333. {// ignore extra characters
  334. ++message;
  335. CHECK_EOS(message);
  336. }
  337. // terminate the string
  338. if(off < end)
  339. {// fill the rest with 0's
  340. memset(WFIFOP(fd,off),0,end-off);
  341. off=end;
  342. }
  343. } else
  344. {// unknown
  345. PARSE_ERROR("Unknown type of value in:",message);
  346. return -1;
  347. }
  348. SKIP_VALUE(message);
  349. }
  350. if(packet_db[sd->packet_ver][type].len == -1)
  351. {// send dynamic packet
  352. WFIFOW(fd,2)=TOW(off);
  353. WFIFOSET(fd,off);
  354. } else
  355. {// send static packet
  356. if(off < len)
  357. memset(WFIFOP(fd,off),0,len-off);
  358. WFIFOSET(fd,len);
  359. }
  360. } else {
  361. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  362. return -1;
  363. }
  364. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  365. clif_displaymessage(fd, atcmd_output);
  366. return 0;
  367. #undef PARSE_ERROR
  368. #undef CHECK_EOS
  369. #undef SKIP_VALUE
  370. #undef GET_VALUE
  371. }
  372. /*==========================================
  373. * @rura, @warp, @mapmove
  374. *------------------------------------------*/
  375. ACMD_FUNC(mapmove)
  376. {
  377. char map_name[MAP_NAME_LENGTH_EXT];
  378. unsigned short mapindex;
  379. short x = 0, y = 0;
  380. int m = -1;
  381. nullpo_retr(-1, sd);
  382. memset(map_name, '\0', sizeof(map_name));
  383. if (!message || !*message ||
  384. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  385. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  386. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  387. return -1;
  388. }
  389. mapindex = mapindex_name2id(map_name);
  390. if (mapindex)
  391. m = map_mapindex2mapid(mapindex);
  392. if (!mapindex) { // m < 0 means on different server! [Kevin]
  393. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  394. return -1;
  395. }
  396. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  397. { //This is to prevent the pc_setpos call from printing an error.
  398. clif_displaymessage(fd, msg_txt(2));
  399. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  400. x = y = 0; //Invalid cell, use random spot.
  401. }
  402. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  403. clif_displaymessage(fd, msg_txt(247));
  404. return -1;
  405. }
  406. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  407. clif_displaymessage(fd, msg_txt(248));
  408. return -1;
  409. }
  410. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  411. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  412. return -1;
  413. }
  414. clif_displaymessage(fd, msg_txt(0)); // Warped.
  415. return 0;
  416. }
  417. /*==========================================
  418. * Displays where a character is. Corrected version by Silent. [Skotlex]
  419. *------------------------------------------*/
  420. ACMD_FUNC(where)
  421. {
  422. struct map_session_data* pl_sd;
  423. nullpo_retr(-1, sd);
  424. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  425. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  426. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  427. return -1;
  428. }
  429. pl_sd = map_nick2sd(atcmd_player_name);
  430. if( pl_sd == NULL
  431. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  432. || (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))
  433. ) {
  434. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  435. return -1;
  436. }
  437. 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);
  438. clif_displaymessage(fd, atcmd_output);
  439. return 0;
  440. }
  441. /*==========================================
  442. *
  443. *------------------------------------------*/
  444. ACMD_FUNC(jumpto)
  445. {
  446. struct map_session_data *pl_sd = NULL;
  447. nullpo_retr(-1, sd);
  448. if (!message || !*message) {
  449. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  450. return -1;
  451. }
  452. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  453. {
  454. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  455. return -1;
  456. }
  457. if (pl_sd == sd)
  458. {
  459. clif_displaymessage(fd, "But you are already where you are...");
  460. return -1;
  461. }
  462. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  463. {
  464. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  465. return -1;
  466. }
  467. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  468. {
  469. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  470. return -1;
  471. }
  472. if( pc_isdead(sd) )
  473. {
  474. clif_displaymessage(fd, "You cannot use this command when dead.");
  475. return -1;
  476. }
  477. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  478. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  479. clif_displaymessage(fd, atcmd_output);
  480. return 0;
  481. }
  482. /*==========================================
  483. *
  484. *------------------------------------------*/
  485. ACMD_FUNC(jump)
  486. {
  487. short x = 0, y = 0;
  488. nullpo_retr(-1, sd);
  489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  490. sscanf(message, "%hd %hd", &x, &y);
  491. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  492. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  493. return -1;
  494. }
  495. if( pc_isdead(sd) )
  496. {
  497. clif_displaymessage(fd, "You cannot use this command when dead.");
  498. return -1;
  499. }
  500. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  501. { //This is to prevent the pc_setpos call from printing an error.
  502. clif_displaymessage(fd, msg_txt(2));
  503. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  504. x = y = 0; //Invalid cell, use random spot.
  505. }
  506. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  507. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  508. clif_displaymessage(fd, atcmd_output);
  509. return 0;
  510. }
  511. /*==========================================
  512. * @who3 = Player name, his location
  513. *------------------------------------------*/
  514. ACMD_FUNC(who3)
  515. {
  516. char temp0[100];
  517. struct map_session_data *pl_sd;
  518. struct s_mapiterator* iter;
  519. int j, count;
  520. int pl_GM_level, GM_level;
  521. char match_text[100];
  522. char player_name[NAME_LENGTH];
  523. nullpo_retr(-1, sd);
  524. memset(atcmd_output, '\0', sizeof(atcmd_output));
  525. memset(match_text, '\0', sizeof(match_text));
  526. memset(player_name, '\0', sizeof(player_name));
  527. if (sscanf(message, "%99[^\n]", match_text) < 1)
  528. strcpy(match_text, "");
  529. for (j = 0; match_text[j]; j++)
  530. match_text[j] = TOLOWER(match_text[j]);
  531. count = 0;
  532. GM_level = pc_isGM(sd);
  533. iter = mapit_getallusers();
  534. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  535. {
  536. pl_GM_level = pc_isGM(pl_sd);
  537. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  538. {// you can look only lower or same level
  539. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  540. for (j = 0; player_name[j]; j++)
  541. player_name[j] = TOLOWER(player_name[j]);
  542. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  543. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  544. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  545. } else {
  546. atcmd_output[0]=0;
  547. }
  548. //Player name
  549. sprintf(temp0, msg_txt(343), pl_sd->status.name);
  550. strcat(atcmd_output,temp0);
  551. //Player title, if exists
  552. if (pl_GM_level > 0) {
  553. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  554. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  555. strcat(atcmd_output,temp0);
  556. }
  557. //Players Location: map x y
  558. sprintf(temp0, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  559. strcat(atcmd_output,temp0);
  560. clif_displaymessage(fd, atcmd_output);
  561. count++;
  562. }
  563. }
  564. }
  565. mapit_free(iter);
  566. if (count == 0)
  567. clif_displaymessage(fd, msg_txt(28)); // No player found.
  568. else if (count == 1)
  569. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  570. else {
  571. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  572. clif_displaymessage(fd, atcmd_output);
  573. }
  574. return 0;
  575. }
  576. /*==========================================
  577. * Player name, BLevel, Job,
  578. *------------------------------------------*/
  579. ACMD_FUNC(who2)
  580. {
  581. char temp0[100];
  582. struct map_session_data *pl_sd;
  583. struct s_mapiterator* iter;
  584. int j, count;
  585. int pl_GM_level, GM_level;
  586. char match_text[100];
  587. char player_name[NAME_LENGTH];
  588. nullpo_retr(-1, sd);
  589. memset(atcmd_output, '\0', sizeof(atcmd_output));
  590. memset(match_text, '\0', sizeof(match_text));
  591. memset(player_name, '\0', sizeof(player_name));
  592. if (sscanf(message, "%99[^\n]", match_text) < 1)
  593. strcpy(match_text, "");
  594. for (j = 0; match_text[j]; j++)
  595. match_text[j] = TOLOWER(match_text[j]);
  596. count = 0;
  597. GM_level = pc_isGM(sd);
  598. iter = mapit_getallusers();
  599. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  600. {
  601. pl_GM_level = pc_isGM(pl_sd);
  602. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  603. {// you can look only lower or same level
  604. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  605. for (j = 0; player_name[j]; j++)
  606. player_name[j] = TOLOWER(player_name[j]);
  607. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  608. //Players Name
  609. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  610. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  611. //Player title, if exists
  612. if (pl_GM_level > 0) {
  613. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  614. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  615. strcat(atcmd_output,temp0);
  616. }
  617. //Players Base Level / Job name
  618. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  619. sprintf(temp0, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  620. strcat(atcmd_output,temp0);
  621. clif_displaymessage(fd, atcmd_output);
  622. count++;
  623. }
  624. }
  625. }
  626. mapit_free(iter);
  627. if (count == 0)
  628. clif_displaymessage(fd, msg_txt(28)); // No player found.
  629. else if (count == 1)
  630. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  631. else {
  632. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  633. clif_displaymessage(fd, atcmd_output);
  634. }
  635. return 0;
  636. }
  637. /*==========================================
  638. * Player name, Playrs Party / Guild name
  639. *------------------------------------------*/
  640. ACMD_FUNC(who)
  641. {
  642. char temp0[100];
  643. struct map_session_data *pl_sd;
  644. struct s_mapiterator* iter;
  645. int j, count;
  646. int pl_GM_level, GM_level;
  647. char match_text[100];
  648. char player_name[NAME_LENGTH];
  649. struct guild *g;
  650. struct party_data *p;
  651. nullpo_retr(-1, sd);
  652. memset(temp0, '\0', sizeof(temp0));
  653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  654. memset(match_text, '\0', sizeof(match_text));
  655. memset(player_name, '\0', sizeof(player_name));
  656. if (sscanf(message, "%99[^\n]", match_text) < 1)
  657. strcpy(match_text, "");
  658. for (j = 0; match_text[j]; j++)
  659. match_text[j] = TOLOWER(match_text[j]);
  660. count = 0;
  661. GM_level = pc_isGM(sd);
  662. iter = mapit_getallusers();
  663. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  664. {
  665. pl_GM_level = pc_isGM(pl_sd);
  666. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  667. {// you can look only lower or same level
  668. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  669. for (j = 0; player_name[j]; j++)
  670. player_name[j] = TOLOWER(player_name[j]);
  671. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  672. g = guild_search(pl_sd->status.guild_id);
  673. p = party_search(pl_sd->status.party_id);
  674. //Players Name
  675. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  676. //Player title, if exists
  677. if (pl_GM_level > 0) {
  678. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  679. strcat(atcmd_output,temp0);
  680. }
  681. //Players Party if exists
  682. if (p != NULL) {
  683. //sprintf(temp0," | Party: '%s'", p->name);
  684. sprintf(temp0, msg_txt(345), p->party.name);
  685. strcat(atcmd_output,temp0);
  686. }
  687. //Players Guild if exists
  688. if (g != NULL) {
  689. //sprintf(temp0," | Guild: '%s'", g->name);
  690. sprintf(temp0, msg_txt(346), g->name);
  691. strcat(atcmd_output,temp0);
  692. }
  693. clif_displaymessage(fd, atcmd_output);
  694. count++;
  695. }
  696. }
  697. }
  698. mapit_free(iter);
  699. if (count == 0)
  700. clif_displaymessage(fd, msg_txt(28)); // No player found.
  701. else if (count == 1)
  702. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  703. else {
  704. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  705. clif_displaymessage(fd, atcmd_output);
  706. }
  707. return 0;
  708. }
  709. /*==========================================
  710. *
  711. *------------------------------------------*/
  712. ACMD_FUNC(whomap3)
  713. {
  714. struct map_session_data *pl_sd;
  715. struct s_mapiterator* iter;
  716. int count;
  717. int pl_GM_level, GM_level;
  718. int map_id;
  719. char map_name[MAP_NAME_LENGTH_EXT];
  720. memset(atcmd_output, '\0', sizeof(atcmd_output));
  721. memset(map_name, '\0', sizeof(map_name));
  722. if (!message || !*message)
  723. map_id = sd->bl.m;
  724. else {
  725. sscanf(message, "%15s", map_name);
  726. if ((map_id = map_mapname2mapid(map_name)) < 0)
  727. map_id = sd->bl.m;
  728. }
  729. count = 0;
  730. GM_level = pc_isGM(sd);
  731. iter = mapit_getallusers();
  732. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  733. {
  734. pl_GM_level = pc_isGM(pl_sd);
  735. if( pl_sd->bl.m != map_id )
  736. continue;
  737. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  738. continue;
  739. if (pl_GM_level > 0)
  740. 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);
  741. else
  742. 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);
  743. clif_displaymessage(fd, atcmd_output);
  744. count++;
  745. }
  746. mapit_free(iter);
  747. if (count == 0)
  748. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  749. else if (count == 1)
  750. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  751. else {
  752. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  753. }
  754. clif_displaymessage(fd, atcmd_output);
  755. return 0;
  756. }
  757. /*==========================================
  758. *
  759. *------------------------------------------*/
  760. ACMD_FUNC(whomap2)
  761. {
  762. struct map_session_data *pl_sd;
  763. struct s_mapiterator* iter;
  764. int count;
  765. int pl_GM_level, GM_level;
  766. int map_id = 0;
  767. char map_name[MAP_NAME_LENGTH_EXT];
  768. nullpo_retr(-1, sd);
  769. memset(atcmd_output, '\0', sizeof(atcmd_output));
  770. memset(map_name, '\0', sizeof(map_name));
  771. if (!message || !*message)
  772. map_id = sd->bl.m;
  773. else {
  774. sscanf(message, "%15s", map_name);
  775. if ((map_id = map_mapname2mapid(map_name)) < 0)
  776. map_id = sd->bl.m;
  777. }
  778. count = 0;
  779. GM_level = pc_isGM(sd);
  780. iter = mapit_getallusers();
  781. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  782. {
  783. pl_GM_level = pc_isGM(pl_sd);
  784. if( pl_sd->bl.m != map_id )
  785. continue;
  786. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  787. continue;
  788. if (pl_GM_level > 0)
  789. 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);
  790. else
  791. 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);
  792. clif_displaymessage(fd, atcmd_output);
  793. count++;
  794. }
  795. mapit_free(iter);
  796. if (count == 0)
  797. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  798. else if (count == 1)
  799. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  800. else {
  801. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  802. }
  803. clif_displaymessage(fd, atcmd_output);
  804. return 0;
  805. }
  806. /*==========================================
  807. *
  808. *------------------------------------------*/
  809. ACMD_FUNC(whomap)
  810. {
  811. char temp0[100];
  812. char temp1[100];
  813. struct map_session_data *pl_sd;
  814. struct s_mapiterator* iter;
  815. int count;
  816. int pl_GM_level, GM_level;
  817. int map_id = 0;
  818. char map_name[MAP_NAME_LENGTH_EXT];
  819. struct guild *g;
  820. struct party_data *p;
  821. nullpo_retr(-1, sd);
  822. memset(temp0, '\0', sizeof(temp0));
  823. memset(temp1, '\0', sizeof(temp1));
  824. memset(atcmd_output, '\0', sizeof(atcmd_output));
  825. memset(map_name, '\0', sizeof(map_name));
  826. if (!message || !*message)
  827. map_id = sd->bl.m;
  828. else {
  829. sscanf(message, "%15s", map_name);
  830. if ((map_id = map_mapname2mapid(map_name)) < 0)
  831. map_id = sd->bl.m;
  832. }
  833. count = 0;
  834. GM_level = pc_isGM(sd);
  835. iter = mapit_getallusers();
  836. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  837. {
  838. pl_GM_level = pc_isGM(pl_sd);
  839. if( pl_sd->bl.m != map_id )
  840. continue;
  841. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  842. continue;
  843. g = guild_search(pl_sd->status.guild_id);
  844. if (g == NULL)
  845. sprintf(temp1, "None");
  846. else
  847. sprintf(temp1, "%s", g->name);
  848. p = party_search(pl_sd->status.party_id);
  849. if (p == NULL)
  850. sprintf(temp0, "None");
  851. else
  852. sprintf(temp0, "%s", p->party.name);
  853. if (pl_GM_level > 0)
  854. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  855. else
  856. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  857. clif_displaymessage(fd, atcmd_output);
  858. count++;
  859. }
  860. mapit_free(iter);
  861. if (count == 0)
  862. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  863. else if (count == 1)
  864. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  865. else {
  866. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  867. }
  868. clif_displaymessage(fd, atcmd_output);
  869. return 0;
  870. }
  871. /*==========================================
  872. *
  873. *------------------------------------------*/
  874. ACMD_FUNC(whogm)
  875. {
  876. struct map_session_data* pl_sd;
  877. struct s_mapiterator* iter;
  878. int j, count;
  879. int pl_GM_level, GM_level;
  880. char match_text[CHAT_SIZE_MAX];
  881. char player_name[NAME_LENGTH];
  882. struct guild *g;
  883. struct party_data *p;
  884. nullpo_retr(-1, sd);
  885. memset(atcmd_output, '\0', sizeof(atcmd_output));
  886. memset(match_text, '\0', sizeof(match_text));
  887. memset(player_name, '\0', sizeof(player_name));
  888. if (sscanf(message, "%199[^\n]", match_text) < 1)
  889. strcpy(match_text, "");
  890. for (j = 0; match_text[j]; j++)
  891. match_text[j] = TOLOWER(match_text[j]);
  892. count = 0;
  893. GM_level = pc_isGM(sd);
  894. iter = mapit_getallusers();
  895. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  896. {
  897. pl_GM_level = pc_isGM(pl_sd);
  898. if (!pl_GM_level)
  899. continue;
  900. if (match_text[0])
  901. {
  902. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  903. for (j = 0; player_name[j]; j++)
  904. player_name[j] = TOLOWER(player_name[j]);
  905. // search with no case sensitive
  906. if (strstr(player_name, match_text) == NULL)
  907. continue;
  908. }
  909. if (pl_GM_level > GM_level) {
  910. if (pl_sd->sc.option & OPTION_INVISIBLE)
  911. continue;
  912. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  913. clif_displaymessage(fd, atcmd_output);
  914. count++;
  915. continue;
  916. }
  917. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  918. pl_sd->status.name, pl_GM_level,
  919. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  920. clif_displaymessage(fd, atcmd_output);
  921. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  922. pl_sd->status.base_level,
  923. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  924. clif_displaymessage(fd, atcmd_output);
  925. p = party_search(pl_sd->status.party_id);
  926. g = guild_search(pl_sd->status.guild_id);
  927. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  928. p?p->party.name:"None", g?g->name:"None");
  929. clif_displaymessage(fd, atcmd_output);
  930. count++;
  931. }
  932. mapit_free(iter);
  933. if (count == 0)
  934. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  935. else if (count == 1)
  936. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  937. else {
  938. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  939. clif_displaymessage(fd, atcmd_output);
  940. }
  941. return 0;
  942. }
  943. /*==========================================
  944. *
  945. *------------------------------------------*/
  946. ACMD_FUNC(save)
  947. {
  948. nullpo_retr(-1, sd);
  949. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  950. if (sd->status.pet_id > 0 && sd->pd)
  951. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  952. chrif_save(sd,0);
  953. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  954. return 0;
  955. }
  956. /*==========================================
  957. *
  958. *------------------------------------------*/
  959. ACMD_FUNC(load)
  960. {
  961. int m;
  962. nullpo_retr(-1, sd);
  963. m = map_mapindex2mapid(sd->status.save_point.map);
  964. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  965. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  966. return -1;
  967. }
  968. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  969. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  970. return -1;
  971. }
  972. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  973. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  974. return 0;
  975. }
  976. /*==========================================
  977. *
  978. *------------------------------------------*/
  979. ACMD_FUNC(speed)
  980. {
  981. int speed;
  982. nullpo_retr(-1, sd);
  983. memset(atcmd_output, '\0', sizeof(atcmd_output));
  984. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  985. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  986. clif_displaymessage(fd, atcmd_output);
  987. return -1;
  988. }
  989. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  990. status_calc_bl(&sd->bl, SCB_SPEED);
  991. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  992. return 0;
  993. }
  994. /*==========================================
  995. *
  996. *------------------------------------------*/
  997. ACMD_FUNC(storage)
  998. {
  999. nullpo_retr(-1, sd);
  1000. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  1001. return -1;
  1002. if (storage_storageopen(sd) == 1)
  1003. { //Already open.
  1004. clif_displaymessage(fd, msg_txt(250));
  1005. return -1;
  1006. }
  1007. clif_displaymessage(fd, "Storage opened.");
  1008. return 0;
  1009. }
  1010. /*==========================================
  1011. *
  1012. *------------------------------------------*/
  1013. ACMD_FUNC(guildstorage)
  1014. {
  1015. nullpo_retr(-1, sd);
  1016. if (!sd->status.guild_id) {
  1017. clif_displaymessage(fd, msg_txt(252));
  1018. return -1;
  1019. }
  1020. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  1021. return -1;
  1022. if (sd->state.storage_flag == 1) {
  1023. clif_displaymessage(fd, msg_txt(250));
  1024. return -1;
  1025. }
  1026. if (sd->state.storage_flag == 2) {
  1027. clif_displaymessage(fd, msg_txt(251));
  1028. return -1;
  1029. }
  1030. storage_guild_storageopen(sd);
  1031. clif_displaymessage(fd, "Guild storage opened.");
  1032. return 0;
  1033. }
  1034. /*==========================================
  1035. *
  1036. *------------------------------------------*/
  1037. ACMD_FUNC(option)
  1038. {
  1039. int param1 = 0, param2 = 0, param3 = 0;
  1040. nullpo_retr(-1, sd);
  1041. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1042. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1043. return -1;
  1044. }
  1045. sd->sc.opt1 = param1;
  1046. sd->sc.opt2 = param2;
  1047. pc_setoption(sd, param3);
  1048. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1049. return 0;
  1050. }
  1051. /*==========================================
  1052. *
  1053. *------------------------------------------*/
  1054. ACMD_FUNC(hide)
  1055. {
  1056. nullpo_retr(-1, sd);
  1057. if (sd->sc.option & OPTION_INVISIBLE) {
  1058. sd->sc.option &= ~OPTION_INVISIBLE;
  1059. if (sd->disguise)
  1060. status_set_viewdata(&sd->bl, sd->disguise);
  1061. else
  1062. status_set_viewdata(&sd->bl, sd->status.class_);
  1063. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1064. if( map[sd->bl.m].flag.pvp )
  1065. {// increment the number of pvp players on the map
  1066. map[sd->bl.m].users_pvp++;
  1067. if( !map[sd->bl.m].flag.pvp_nocalcrank )
  1068. {// register the player for ranking calculations
  1069. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  1070. }
  1071. }
  1072. //bugreport:2266
  1073. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  1074. } else {
  1075. sd->sc.option |= OPTION_INVISIBLE;
  1076. sd->vd.class_ = INVISIBLE_CLASS;
  1077. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1078. if( map[sd->bl.m].flag.pvp )
  1079. {// decrement the number of pvp players on the map
  1080. map[sd->bl.m].users_pvp--;
  1081. if( !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  1082. {// unregister the player for ranking
  1083. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  1084. sd->pvp_timer = INVALID_TIMER;
  1085. }
  1086. }
  1087. }
  1088. clif_changeoption(&sd->bl);
  1089. return 0;
  1090. }
  1091. /*==========================================
  1092. * Changes a character's class
  1093. *------------------------------------------*/
  1094. ACMD_FUNC(jobchange)
  1095. {
  1096. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1097. int job = 0, upper = 0;
  1098. nullpo_retr(-1, sd);
  1099. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1100. {
  1101. int i, found = 0;
  1102. const struct { char name[24]; int id; } jobs[] = {
  1103. { "novice", 0 },
  1104. { "swordsman", 1 },
  1105. { "mage", 2 },
  1106. { "archer", 3 },
  1107. { "acolyte", 4 },
  1108. { "merchant", 5 },
  1109. { "thief", 6 },
  1110. { "knight", 7 },
  1111. { "priest", 8 },
  1112. { "priestess", 8 },
  1113. { "wizard", 9 },
  1114. { "blacksmith", 10 },
  1115. { "hunter", 11 },
  1116. { "assassin", 12 },
  1117. { "crusader", 14 },
  1118. { "monk", 15 },
  1119. { "sage", 16 },
  1120. { "rogue", 17 },
  1121. { "alchemist", 18 },
  1122. { "bard", 19 },
  1123. { "dancer", 20 },
  1124. { "super novice", 23 },
  1125. { "supernovice", 23 },
  1126. { "gunslinger", 24 },
  1127. { "gunner", 24 },
  1128. { "ninja", 25 },
  1129. { "high novice", 4001 },
  1130. { "swordsman high", 4002 },
  1131. { "mage high", 4003 },
  1132. { "archer high", 4004 },
  1133. { "acolyte high", 4005 },
  1134. { "merchant high", 4006 },
  1135. { "thief high", 4007 },
  1136. { "lord knight", 4008 },
  1137. { "high priest", 4009 },
  1138. { "high priestess", 4009 },
  1139. { "high wizard", 4010 },
  1140. { "whitesmith", 4011 },
  1141. { "sniper", 4012 },
  1142. { "assassin cross", 4013 },
  1143. { "paladin", 4015 },
  1144. { "champion", 4016 },
  1145. { "professor", 4017 },
  1146. { "stalker", 4018 },
  1147. { "creator", 4019 },
  1148. { "clown", 4020 },
  1149. { "gypsy", 4021 },
  1150. { "baby novice", 4023 },
  1151. { "baby swordsman", 4024 },
  1152. { "baby mage", 4025 },
  1153. { "baby archer", 4026 },
  1154. { "baby acolyte", 4027 },
  1155. { "baby merchant", 4028 },
  1156. { "baby thief", 4029 },
  1157. { "baby knight", 4030 },
  1158. { "baby priest", 4031 },
  1159. { "baby priestess", 4031 },
  1160. { "baby wizard", 4032 },
  1161. { "baby blacksmith",4033 },
  1162. { "baby hunter", 4034 },
  1163. { "baby assassin", 4035 },
  1164. { "baby crusader", 4037 },
  1165. { "baby monk", 4038 },
  1166. { "baby sage", 4039 },
  1167. { "baby rogue", 4040 },
  1168. { "baby alchemist", 4041 },
  1169. { "baby bard", 4042 },
  1170. { "baby dancer", 4043 },
  1171. { "super baby", 4045 },
  1172. { "taekwon", 4046 },
  1173. { "taekwon boy", 4046 },
  1174. { "taekwon girl", 4046 },
  1175. { "star gladiator", 4047 },
  1176. { "soul linker", 4049 },
  1177. { "rune knight", 4054 },
  1178. { "warlock", 4055 },
  1179. { "ranger", 4056 },
  1180. { "arch bishop", 4057 },
  1181. { "mechanic", 4058 },
  1182. { "guillotine", 4059 },
  1183. { "rune knight (Trans)", 4060 },
  1184. { "warlock (Trans)", 4061 },
  1185. { "ranger (Trans)", 4062 },
  1186. { "arch bishop (Trans)", 4063 },
  1187. { "mechanic (Trans)", 4064 },
  1188. { "guillotine (Trans)", 4065 },
  1189. { "royal guard", 4066 },
  1190. { "sorcerer", 4067 },
  1191. { "minstrel", 4068 },
  1192. { "wanderer", 4069 },
  1193. { "sura", 4070 },
  1194. { "genetic", 4071 },
  1195. { "shadow chaser", 4072 },
  1196. { "royal guard (Trans)", 4073 },
  1197. { "sorcerer (Trans)", 4074 },
  1198. { "minstrel (Trans)", 4075 },
  1199. { "wanderer (Trans)", 4076 },
  1200. { "sura (Trans)", 4077 },
  1201. { "genetic (Trans)", 4078 },
  1202. { "shadow chaser (Trans)", 4079 },
  1203. };
  1204. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1205. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1206. job = jobs[i].id;
  1207. upper = 0;
  1208. found = 1;
  1209. break;
  1210. }
  1211. }
  1212. if (!found) {
  1213. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1214. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1215. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1216. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1217. clif_displaymessage(fd, "----- 2nd Class -----");
  1218. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1219. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1220. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1221. clif_displaymessage(fd, " 20 Dancer");
  1222. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1223. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1224. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1225. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1226. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1227. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1228. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1229. clif_displaymessage(fd, "4021 Gypsy");
  1230. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1231. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1232. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1233. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1234. clif_displaymessage(fd, "4072 Shadow Chaser");
  1235. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1236. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1237. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1238. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1239. clif_displaymessage(fd, "4079 Shadow Chaser");
  1240. clif_displaymessage(fd, "----- Expanded Class -----");
  1241. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1242. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1243. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1244. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1245. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1246. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1247. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1248. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1249. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1250. clif_displaymessage(fd, "4045 Super Baby");
  1251. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1252. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1253. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1254. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1255. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1256. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1257. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1258. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1259. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1260. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1261. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1262. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1263. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1264. return -1;
  1265. }
  1266. }
  1267. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27
  1268. || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1269. ) // Deny direct transformation into dummy jobs
  1270. return 0;
  1271. if (pcdb_checkid(job))
  1272. {
  1273. if (pc_jobchange(sd, job, upper) == 0)
  1274. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1275. else {
  1276. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1277. return -1;
  1278. }
  1279. } else {
  1280. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1281. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1282. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1283. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1284. clif_displaymessage(fd, "----- 2nd Class -----");
  1285. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1286. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1287. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1288. clif_displaymessage(fd, " 20 Dancer");
  1289. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1290. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1291. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1292. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1293. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1294. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1295. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1296. clif_displaymessage(fd, "4021 Gypsy");
  1297. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1298. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1299. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1300. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1301. clif_displaymessage(fd, "4072 Shadow Chaser");
  1302. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1303. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1304. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1305. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1306. clif_displaymessage(fd, "4079 Shadow Chaser");
  1307. clif_displaymessage(fd, "----- Expanded Class -----");
  1308. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1309. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1310. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1311. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1312. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1313. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1314. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1315. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1316. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1317. clif_displaymessage(fd, "4045 Super Baby");
  1318. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1319. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1320. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1321. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1322. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1323. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1324. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1325. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1326. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1327. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1328. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1329. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1330. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1331. return -1;
  1332. }
  1333. return 0;
  1334. }
  1335. /*==========================================
  1336. *
  1337. *------------------------------------------*/
  1338. ACMD_FUNC(die)
  1339. {
  1340. nullpo_retr(-1, sd);
  1341. clif_specialeffect(&sd->bl,450,SELF);
  1342. status_kill(&sd->bl);
  1343. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1344. return 0;
  1345. }
  1346. /*==========================================
  1347. *
  1348. *------------------------------------------*/
  1349. ACMD_FUNC(kill)
  1350. {
  1351. struct map_session_data *pl_sd;
  1352. nullpo_retr(-1, sd);
  1353. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1354. if (!message || !*message) {
  1355. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1356. return -1;
  1357. }
  1358. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1359. {
  1360. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1361. return -1;
  1362. }
  1363. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1364. { // you can kill only lower or same level
  1365. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1366. return -1;
  1367. }
  1368. status_kill(&pl_sd->bl);
  1369. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1370. if (fd != pl_sd->fd)
  1371. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1372. return 0;
  1373. }
  1374. /*==========================================
  1375. *
  1376. *------------------------------------------*/
  1377. ACMD_FUNC(alive)
  1378. {
  1379. nullpo_retr(-1, sd);
  1380. if (!status_revive(&sd->bl, 100, 100))
  1381. {
  1382. clif_displaymessage(fd, "You're not dead.");
  1383. return -1;
  1384. }
  1385. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1386. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1387. return 0;
  1388. }
  1389. /*==========================================
  1390. * +kamic [LuzZza]
  1391. *------------------------------------------*/
  1392. ACMD_FUNC(kami)
  1393. {
  1394. unsigned long color=0;
  1395. nullpo_retr(-1, sd);
  1396. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1397. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1398. if (!message || !*message) {
  1399. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1400. return -1;
  1401. }
  1402. sscanf(message, "%199[^\n]", atcmd_output);
  1403. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1404. } else {
  1405. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1406. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1407. return -1;
  1408. }
  1409. if(color > 0xFFFFFF) {
  1410. clif_displaymessage(fd, "Invalid color.");
  1411. return -1;
  1412. }
  1413. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1414. }
  1415. return 0;
  1416. }
  1417. /*==========================================
  1418. *
  1419. *------------------------------------------*/
  1420. ACMD_FUNC(heal)
  1421. {
  1422. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1423. nullpo_retr(-1, sd);
  1424. sscanf(message, "%d %d", &hp, &sp);
  1425. // some overflow checks
  1426. if( hp == INT_MIN ) hp++;
  1427. if( sp == INT_MIN ) sp++;
  1428. if ( hp == 0 && sp == 0 ) {
  1429. if (!status_percent_heal(&sd->bl, 100, 100))
  1430. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1431. else
  1432. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1433. return 0;
  1434. }
  1435. if ( hp > 0 && sp >= 0 ) {
  1436. if(!status_heal(&sd->bl, hp, sp, 0))
  1437. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1438. else
  1439. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1440. return 0;
  1441. }
  1442. if ( hp < 0 && sp <= 0 ) {
  1443. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1444. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1445. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1446. return 0;
  1447. }
  1448. //Opposing signs.
  1449. if ( hp ) {
  1450. if (hp > 0)
  1451. status_heal(&sd->bl, hp, 0, 0);
  1452. else {
  1453. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1454. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1455. }
  1456. }
  1457. if ( sp ) {
  1458. if (sp > 0)
  1459. status_heal(&sd->bl, 0, sp, 0);
  1460. else
  1461. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1462. }
  1463. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1464. return 0;
  1465. }
  1466. /*==========================================
  1467. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1468. *------------------------------------------*/
  1469. ACMD_FUNC(item)
  1470. {
  1471. char item_name[100];
  1472. int number = 0, item_id, flag;
  1473. struct item item_tmp;
  1474. struct item_data *item_data;
  1475. int get_count, i;
  1476. nullpo_retr(-1, sd);
  1477. memset(item_name, '\0', sizeof(item_name));
  1478. if (!message || !*message || (
  1479. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1480. sscanf(message, "%99s %d", item_name, &number) < 1
  1481. )) {
  1482. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1483. return -1;
  1484. }
  1485. if (number <= 0)
  1486. number = 1;
  1487. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1488. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1489. {
  1490. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1491. return -1;
  1492. }
  1493. item_id = item_data->nameid;
  1494. get_count = number;
  1495. //Check if it's stackable.
  1496. if (!itemdb_isstackable2(item_data))
  1497. get_count = 1;
  1498. for (i = 0; i < number; i += get_count) {
  1499. // if not pet egg
  1500. if (!pet_create_egg(sd, item_id)) {
  1501. memset(&item_tmp, 0, sizeof(item_tmp));
  1502. item_tmp.nameid = item_id;
  1503. item_tmp.identify = 1;
  1504. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1505. clif_additem(sd, 0, 0, flag);
  1506. }
  1507. }
  1508. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1509. return 0;
  1510. }
  1511. /*==========================================
  1512. *
  1513. *------------------------------------------*/
  1514. ACMD_FUNC(item2)
  1515. {
  1516. struct item item_tmp;
  1517. struct item_data *item_data;
  1518. char item_name[100];
  1519. int item_id, number = 0;
  1520. int identify = 0, refine = 0, attr = 0;
  1521. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1522. int flag;
  1523. int loop, get_count, i;
  1524. nullpo_retr(-1, sd);
  1525. memset(item_name, '\0', sizeof(item_name));
  1526. if (!message || !*message || (
  1527. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1528. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1529. )) {
  1530. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1531. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1532. return -1;
  1533. }
  1534. if (number <= 0)
  1535. number = 1;
  1536. item_id = 0;
  1537. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1538. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1539. item_id = item_data->nameid;
  1540. if (item_id > 500) {
  1541. loop = 1;
  1542. get_count = number;
  1543. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1544. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1545. loop = number;
  1546. get_count = 1;
  1547. if (item_data->type == IT_PETEGG) {
  1548. identify = 1;
  1549. refine = 0;
  1550. }
  1551. if (item_data->type == IT_PETARMOR)
  1552. refine = 0;
  1553. if (refine > MAX_REFINE)
  1554. refine = MAX_REFINE;
  1555. } else {
  1556. identify = 1;
  1557. refine = attr = 0;
  1558. }
  1559. for (i = 0; i < loop; i++) {
  1560. memset(&item_tmp, 0, sizeof(item_tmp));
  1561. item_tmp.nameid = item_id;
  1562. item_tmp.identify = identify;
  1563. item_tmp.refine = refine;
  1564. item_tmp.attribute = attr;
  1565. item_tmp.card[0] = c1;
  1566. item_tmp.card[1] = c2;
  1567. item_tmp.card[2] = c3;
  1568. item_tmp.card[3] = c4;
  1569. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1570. clif_additem(sd, 0, 0, flag);
  1571. }
  1572. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1573. } else {
  1574. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1575. return -1;
  1576. }
  1577. return 0;
  1578. }
  1579. /*==========================================
  1580. *
  1581. *------------------------------------------*/
  1582. ACMD_FUNC(itemreset)
  1583. {
  1584. int i;
  1585. nullpo_retr(-1, sd);
  1586. for (i = 0; i < MAX_INVENTORY; i++) {
  1587. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1588. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1589. }
  1590. }
  1591. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1592. return 0;
  1593. }
  1594. /*==========================================
  1595. * Atcommand @lvlup
  1596. *------------------------------------------*/
  1597. ACMD_FUNC(baselevelup)
  1598. {
  1599. int level=0, i=0, status_point=0;
  1600. nullpo_retr(-1, sd);
  1601. level = atoi(message);
  1602. if (!message || !*message || !level) {
  1603. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1604. return -1;
  1605. }
  1606. if (level > 0) {
  1607. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1608. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1609. return -1;
  1610. } // End Addition
  1611. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1612. level = pc_maxbaselv(sd) - sd->status.base_level;
  1613. for (i = 0; i < level; i++)
  1614. status_point += pc_gets_status_point(sd->status.base_level + i);
  1615. sd->status.status_point += status_point;
  1616. sd->status.base_level += (unsigned int)level;
  1617. status_percent_heal(&sd->bl, 100, 100);
  1618. clif_misceffect(&sd->bl, 0);
  1619. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1620. } else {
  1621. if (sd->status.base_level == 1) {
  1622. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1623. return -1;
  1624. }
  1625. level*=-1;
  1626. if ((unsigned int)level >= sd->status.base_level)
  1627. level = sd->status.base_level-1;
  1628. for (i = 0; i > -level; i--)
  1629. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1630. if (sd->status.status_point < status_point)
  1631. pc_resetstate(sd);
  1632. if (sd->status.status_point < status_point)
  1633. sd->status.status_point = 0;
  1634. else
  1635. sd->status.status_point -= status_point;
  1636. sd->status.base_level -= (unsigned int)level;
  1637. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1638. }
  1639. sd->status.base_exp = 0;
  1640. clif_updatestatus(sd, SP_STATUSPOINT);
  1641. clif_updatestatus(sd, SP_BASELEVEL);
  1642. clif_updatestatus(sd, SP_BASEEXP);
  1643. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1644. status_calc_pc(sd, 0);
  1645. if(sd->status.party_id)
  1646. party_send_levelup(sd);
  1647. return 0;
  1648. }
  1649. /*==========================================
  1650. *
  1651. *------------------------------------------*/
  1652. ACMD_FUNC(joblevelup)
  1653. {
  1654. int level=0;
  1655. nullpo_retr(-1, sd);
  1656. level = atoi(message);
  1657. if (!message || !*message || !level) {
  1658. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1659. return -1;
  1660. }
  1661. if (level > 0) {
  1662. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1663. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1664. return -1;
  1665. }
  1666. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1667. level = pc_maxjoblv(sd) - sd->status.job_level;
  1668. sd->status.job_level += (unsigned int)level;
  1669. sd->status.skill_point += level;
  1670. clif_misceffect(&sd->bl, 1);
  1671. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1672. } else {
  1673. if (sd->status.job_level == 1) {
  1674. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1675. return -1;
  1676. }
  1677. level *=-1;
  1678. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1679. level = sd->status.job_level-1;
  1680. sd->status.job_level -= (unsigned int)level;
  1681. if (sd->status.skill_point < level)
  1682. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1683. if (sd->status.skill_point < level)
  1684. sd->status.skill_point = 0;
  1685. else
  1686. sd->status.skill_point -= level;
  1687. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1688. }
  1689. sd->status.job_exp = 0;
  1690. clif_updatestatus(sd, SP_JOBLEVEL);
  1691. clif_updatestatus(sd, SP_JOBEXP);
  1692. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1693. clif_updatestatus(sd, SP_SKILLPOINT);
  1694. status_calc_pc(sd, 0);
  1695. return 0;
  1696. }
  1697. /*==========================================
  1698. * @help
  1699. *------------------------------------------*/
  1700. ACMD_FUNC(help)
  1701. {
  1702. char buf[2048], w1[2048], w2[2048];
  1703. int i, gm_level;
  1704. FILE* fp;
  1705. nullpo_retr(-1, sd);
  1706. memset(buf, '\0', sizeof(buf));
  1707. if ((fp = fopen(help_txt, "r")) != NULL) {
  1708. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1709. gm_level = pc_isGM(sd);
  1710. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1711. if (buf[0] == '/' && buf[1] == '/')
  1712. continue;
  1713. for (i = 0; buf[i] != '\0'; i++) {
  1714. if (buf[i] == '\r' || buf[i] == '\n') {
  1715. buf[i] = '\0';
  1716. break;
  1717. }
  1718. }
  1719. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1720. clif_displaymessage(fd, buf);
  1721. else if (gm_level >= atoi(w1))
  1722. clif_displaymessage(fd, w2);
  1723. }
  1724. fclose(fp);
  1725. } else {
  1726. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1727. return -1;
  1728. }
  1729. return 0;
  1730. }
  1731. /*==========================================
  1732. * @help2 - Char commands [Kayla]
  1733. *------------------------------------------*/
  1734. ACMD_FUNC(help2)
  1735. {
  1736. char buf[2048], w1[2048], w2[2048];
  1737. int i, gm_level;
  1738. FILE* fp;
  1739. nullpo_retr(-1, sd);
  1740. memset(buf, '\0', sizeof(buf));
  1741. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1742. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1743. gm_level = pc_isGM(sd);
  1744. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1745. if (buf[0] == '/' && buf[1] == '/')
  1746. continue;
  1747. for (i = 0; buf[i] != '\0'; i++) {
  1748. if (buf[i] == '\r' || buf[i] == '\n') {
  1749. buf[i] = '\0';
  1750. break;
  1751. }
  1752. }
  1753. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1754. clif_displaymessage(fd, buf);
  1755. else if (gm_level >= atoi(w1))
  1756. clif_displaymessage(fd, w2);
  1757. }
  1758. fclose(fp);
  1759. } else {
  1760. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1761. return -1;
  1762. }
  1763. return 0;
  1764. }
  1765. // helper function, used in foreach calls to stop auto-attack timers
  1766. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1767. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1768. {
  1769. struct unit_data *ud = unit_bl2ud(bl);
  1770. int id = va_arg(ap, int);
  1771. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1772. {
  1773. unit_stop_attack(bl);
  1774. return 1;
  1775. }
  1776. return 0;
  1777. }
  1778. /*==========================================
  1779. *
  1780. *------------------------------------------*/
  1781. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1782. {
  1783. TBL_PC* sd = (TBL_PC*)bl;
  1784. clif_pvpset(sd, 0, 0, 2);
  1785. if (sd->pvp_timer != INVALID_TIMER) {
  1786. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1787. sd->pvp_timer = INVALID_TIMER;
  1788. }
  1789. return 0;
  1790. }
  1791. ACMD_FUNC(pvpoff)
  1792. {
  1793. nullpo_retr(-1, sd);
  1794. if (!map[sd->bl.m].flag.pvp) {
  1795. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1796. return -1;
  1797. }
  1798. map[sd->bl.m].flag.pvp = 0;
  1799. if (!battle_config.pk_mode)
  1800. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1801. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1802. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1803. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1804. return 0;
  1805. }
  1806. /*==========================================
  1807. *
  1808. *------------------------------------------*/
  1809. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1810. {
  1811. TBL_PC* sd = (TBL_PC*)bl;
  1812. if (sd->pvp_timer == INVALID_TIMER) {
  1813. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1814. sd->pvp_rank = 0;
  1815. sd->pvp_lastusers = 0;
  1816. sd->pvp_point = 5;
  1817. sd->pvp_won = 0;
  1818. sd->pvp_lost = 0;
  1819. }
  1820. return 0;
  1821. }
  1822. ACMD_FUNC(pvpon)
  1823. {
  1824. nullpo_retr(-1, sd);
  1825. if (map[sd->bl.m].flag.pvp) {
  1826. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1827. return -1;
  1828. }
  1829. map[sd->bl.m].flag.pvp = 1;
  1830. if (!battle_config.pk_mode)
  1831. {// display pvp circle and rank
  1832. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1833. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1834. }
  1835. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1836. return 0;
  1837. }
  1838. /*==========================================
  1839. *
  1840. *------------------------------------------*/
  1841. ACMD_FUNC(gvgoff)
  1842. {
  1843. nullpo_retr(-1, sd);
  1844. if (!map[sd->bl.m].flag.gvg) {
  1845. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1846. return -1;
  1847. }
  1848. map[sd->bl.m].flag.gvg = 0;
  1849. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1850. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1851. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1852. return 0;
  1853. }
  1854. /*==========================================
  1855. *
  1856. *------------------------------------------*/
  1857. ACMD_FUNC(gvgon)
  1858. {
  1859. nullpo_retr(-1, sd);
  1860. if (map[sd->bl.m].flag.gvg) {
  1861. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1862. return -1;
  1863. }
  1864. map[sd->bl.m].flag.gvg = 1;
  1865. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1866. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1867. return 0;
  1868. }
  1869. /*==========================================
  1870. *
  1871. *------------------------------------------*/
  1872. ACMD_FUNC(model)
  1873. {
  1874. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1875. nullpo_retr(-1, sd);
  1876. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1877. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1878. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1879. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1880. clif_displaymessage(fd, atcmd_output);
  1881. return -1;
  1882. }
  1883. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1884. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1885. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1886. pc_changelook(sd, LOOK_HAIR, hair_style);
  1887. pc_changelook(sd, LOOK_HAIR_COLOR, hair_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. * @dye && @ccolor
  1898. *------------------------------------------*/
  1899. ACMD_FUNC(dye)
  1900. {
  1901. int cloth_color = 0;
  1902. nullpo_retr(-1, sd);
  1903. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1904. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1905. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1906. clif_displaymessage(fd, atcmd_output);
  1907. return -1;
  1908. }
  1909. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1910. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  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. * @hairstyle && @hstyle
  1920. *------------------------------------------*/
  1921. ACMD_FUNC(hair_style)
  1922. {
  1923. int hair_style = 0;
  1924. nullpo_retr(-1, sd);
  1925. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1926. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1927. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1928. clif_displaymessage(fd, atcmd_output);
  1929. return -1;
  1930. }
  1931. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1932. pc_changelook(sd, LOOK_HAIR, hair_style);
  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. * @haircolor && @hcolor
  1942. *------------------------------------------*/
  1943. ACMD_FUNC(hair_color)
  1944. {
  1945. int hair_color = 0;
  1946. nullpo_retr(-1, sd);
  1947. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1948. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1949. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1950. clif_displaymessage(fd, atcmd_output);
  1951. return -1;
  1952. }
  1953. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1954. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1955. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1956. } else {
  1957. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1958. return -1;
  1959. }
  1960. return 0;
  1961. }
  1962. /*==========================================
  1963. * @go [city_number or city_name] - Updated by Harbin
  1964. *------------------------------------------*/
  1965. ACMD_FUNC(go)
  1966. {
  1967. int i;
  1968. int town;
  1969. char map_name[MAP_NAME_LENGTH];
  1970. int m;
  1971. const struct {
  1972. char map[MAP_NAME_LENGTH];
  1973. int x, y;
  1974. } data[] = {
  1975. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1976. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1977. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1978. { MAP_PAYON, 162, 233 }, // 3=Payon
  1979. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1980. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1981. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1982. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1983. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1984. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1985. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1986. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1987. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1988. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1989. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1990. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1991. { MAP_JAIL, 23, 61 }, // 16=Prison
  1992. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1993. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1994. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1995. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1996. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1997. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1998. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1999. { MAP_VEINS, 216, 123 }, // 24=Veins
  2000. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  2001. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  2002. { MAP_MANUK, 282, 138 }, // 27=Manuk
  2003. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  2004. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  2005. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  2006. { MAP_MORA, 44, 151 }, // 31=Mora
  2007. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  2008. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  2009. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  2010. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  2011. };
  2012. nullpo_retr(-1, sd);
  2013. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  2014. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2015. return 0;
  2016. }
  2017. memset(map_name, '\0', sizeof(map_name));
  2018. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2019. // get the number
  2020. town = atoi(message);
  2021. // if no value, display all value
  2022. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  2023. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  2024. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  2025. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2026. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2027. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2028. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  2029. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  2030. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2031. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2032. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2033. clif_displaymessage(fd, " 24=Veins 25=Moscovia 26=Midgard Camp");
  2034. clif_displaymessage(fd, " 27=Manuk 28=Splendide 29=Brasilis");
  2035. clif_displaymessage(fd, " 30=El Dicastes 31=Mora 32=Dewata");
  2036. clif_displaymessage(fd, " 33=Malangdo Island 34=Malaya Port 35=Eclage");
  2037. return -1;
  2038. }
  2039. // get possible name of the city
  2040. map_name[MAP_NAME_LENGTH-1] = '\0';
  2041. for (i = 0; map_name[i]; i++)
  2042. map_name[i] = TOLOWER(map_name[i]);
  2043. // try to identify the map name
  2044. if (strncmp(map_name, "prontera", 3) == 0) {
  2045. town = 0;
  2046. } else if (strncmp(map_name, "morocc", 3) == 0) {
  2047. town = 1;
  2048. } else if (strncmp(map_name, "geffen", 3) == 0) {
  2049. town = 2;
  2050. } else if (strncmp(map_name, "payon", 3) == 0 ||
  2051. strncmp(map_name, "paion", 3) == 0) {
  2052. town = 3;
  2053. } else if (strncmp(map_name, "alberta", 3) == 0) {
  2054. town = 4;
  2055. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  2056. strncmp(map_name, "islude", 3) == 0) {
  2057. town = 5;
  2058. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2059. strcmp(map_name, "al") == 0) {
  2060. town = 6;
  2061. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  2062. strcmp(map_name, "christmas") == 0 ||
  2063. strncmp(map_name, "xmas", 3) == 0 ||
  2064. strncmp(map_name, "x-mas", 3) == 0) {
  2065. town = 7;
  2066. } else if (strncmp(map_name, "comodo", 3) == 0) {
  2067. town = 8;
  2068. } else if (strncmp(map_name, "yuno", 3) == 0) {
  2069. town = 9;
  2070. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  2071. town = 10;
  2072. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  2073. town = 11;
  2074. } else if (strncmp(map_name, "umbala", 3) == 0) {
  2075. town = 12;
  2076. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  2077. town = 13;
  2078. } else if (strncmp(map_name, "louyang", 3) == 0) {
  2079. town = 14;
  2080. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  2081. strncmp(map_name, "startpoint", 3) == 0 ||
  2082. strncmp(map_name, "begining", 3) == 0) {
  2083. town = 15;
  2084. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2085. strncmp(map_name, "prison", 3) == 0 ||
  2086. strncmp(map_name, "jails", 3) == 0) {
  2087. town = 16;
  2088. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2089. strncmp(map_name, "jawai", 3) == 0) {
  2090. town = 17;
  2091. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2092. strncmp(map_name, "ayotaya", 3) == 0) {
  2093. town = 18;
  2094. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2095. strncmp(map_name, "ainbroch", 5) == 0) {
  2096. town = 19;
  2097. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2098. town = 20;
  2099. } else if (strncmp(map_name, "einbech", 3) == 0) {
  2100. town = 21;
  2101. } else if (strncmp(map_name, "hugel", 3) == 0) {
  2102. town = 22;
  2103. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2104. town = 23;
  2105. } else if (strncmp(map_name, "veins", 3) == 0) {
  2106. town = 24;
  2107. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  2108. town = 25;
  2109. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  2110. town = 26;
  2111. } else if (strncmp(map_name, "manuk", 3) == 0) {
  2112. town = 27;
  2113. } else if (strncmp(map_name, "splendide", 3) == 0) {
  2114. town = 28;
  2115. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  2116. town = 29;
  2117. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  2118. town = 30;
  2119. } else if (strncmp(map_name, "mora", 3) == 0) {
  2120. town = 31;
  2121. } else if (strncmp(map_name, "dewata", 3) == 0) {
  2122. town = 32;
  2123. } else if (strncmp(map_name, "malangdo", 3) == 0) {
  2124. town = 33;
  2125. } else if (strncmp(map_name, "malaya", 3) == 0) {
  2126. town = 34;
  2127. } else if (strncmp(map_name, "eclage", 3) == 0) {
  2128. town = 35;
  2129. }
  2130. if (town >= 0 && town < ARRAYLENGTH(data))
  2131. {
  2132. m = map_mapname2mapid(data[town].map);
  2133. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2134. clif_displaymessage(fd, msg_txt(247));
  2135. return -1;
  2136. }
  2137. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2138. clif_displaymessage(fd, msg_txt(248));
  2139. return -1;
  2140. }
  2141. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  2142. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2143. } else {
  2144. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2145. return -1;
  2146. }
  2147. } else { // if you arrive here, you have an error in town variable when reading of names
  2148. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2149. return -1;
  2150. }
  2151. return 0;
  2152. }
  2153. /*==========================================
  2154. *
  2155. *------------------------------------------*/
  2156. ACMD_FUNC(monster)
  2157. {
  2158. char name[NAME_LENGTH];
  2159. char monster[NAME_LENGTH];
  2160. int mob_id;
  2161. int number = 0;
  2162. int count;
  2163. int i, k, range;
  2164. short mx, my;
  2165. nullpo_retr(-1, sd);
  2166. memset(name, '\0', sizeof(name));
  2167. memset(monster, '\0', sizeof(monster));
  2168. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2169. if (!message || !*message) {
  2170. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2171. return -1;
  2172. }
  2173. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2174. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2175. //All data can be left as it is.
  2176. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2177. //Here, it is possible name was not given and we are using monster for it.
  2178. if (count < 3) //Blank mob's name.
  2179. name[0] = '\0';
  2180. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2181. //All data can be left as it is.
  2182. } else if (sscanf(message, "%23s", monster) > 0) {
  2183. //As before, name may be already filled.
  2184. name[0] = '\0';
  2185. } else {
  2186. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2187. return -1;
  2188. }
  2189. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2190. mob_id = mobdb_checkid(atoi(monster));
  2191. if (mob_id == 0) {
  2192. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2193. return -1;
  2194. }
  2195. if (mob_id == MOBID_EMPERIUM) {
  2196. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2197. return -1;
  2198. }
  2199. if (number <= 0)
  2200. number = 1;
  2201. if( !name[0] )
  2202. strcpy(name, "--ja--");
  2203. // 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
  2204. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2205. number = battle_config.atc_spawn_quantity_limit;
  2206. if (battle_config.etc_log)
  2207. 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);
  2208. count = 0;
  2209. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2210. for (i = 0; i < number; i++) {
  2211. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2212. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2213. count += (k != 0) ? 1 : 0;
  2214. }
  2215. if (count != 0)
  2216. if (number == count)
  2217. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2218. else {
  2219. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2220. clif_displaymessage(fd, atcmd_output);
  2221. }
  2222. else {
  2223. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2224. return -1;
  2225. }
  2226. return 0;
  2227. }
  2228. // small monster spawning [Valaris]
  2229. ACMD_FUNC(monstersmall)
  2230. {
  2231. char name[NAME_LENGTH] = "";
  2232. char monster[NAME_LENGTH] = "";
  2233. int mob_id = 0;
  2234. int number = 0;
  2235. int x = 0;
  2236. int y = 0;
  2237. int count;
  2238. int i;
  2239. nullpo_retr(-1, sd);
  2240. if (!message || !*message) {
  2241. clif_displaymessage(fd, "Give a monster name/id please.");
  2242. return -1;
  2243. }
  2244. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2245. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2246. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2247. clif_displaymessage(fd, "Give a monster name/id please.");
  2248. return -1;
  2249. }
  2250. // If monster identifier/name argument is a name
  2251. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2252. mob_id = atoi(monster);
  2253. if (mob_id == 0) {
  2254. clif_displaymessage(fd, msg_txt(40));
  2255. return -1;
  2256. }
  2257. if (mob_id == MOBID_EMPERIUM) {
  2258. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2259. return -1;
  2260. }
  2261. if (mobdb_checkid(mob_id) == 0) {
  2262. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2263. return -1;
  2264. }
  2265. if (number <= 0)
  2266. number = 1;
  2267. if( !name[0] )
  2268. strcpy(name, "--ja--");
  2269. // 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
  2270. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2271. number = battle_config.atc_spawn_quantity_limit;
  2272. count = 0;
  2273. for (i = 0; i < number; i++) {
  2274. int mx, my;
  2275. if (x <= 0)
  2276. mx = sd->bl.x + (rnd() % 11 - 5);
  2277. else
  2278. mx = x;
  2279. if (y <= 0)
  2280. my = sd->bl.y + (rnd() % 11 - 5);
  2281. else
  2282. my = y;
  2283. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2284. }
  2285. if (count != 0)
  2286. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2287. else
  2288. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2289. return 0;
  2290. }
  2291. // big monster spawning [Valaris]
  2292. ACMD_FUNC(monsterbig)
  2293. {
  2294. char name[NAME_LENGTH] = "";
  2295. char monster[NAME_LENGTH] = "";
  2296. int mob_id = 0;
  2297. int number = 0;
  2298. int x = 0;
  2299. int y = 0;
  2300. int count;
  2301. int i;
  2302. nullpo_retr(-1, sd);
  2303. if (!message || !*message) {
  2304. clif_displaymessage(fd, "Give a monster name/id please.");
  2305. return -1;
  2306. }
  2307. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2308. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2309. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2310. clif_displaymessage(fd, "Give a monster name/id please.");
  2311. return -1;
  2312. }
  2313. // If monster identifier/name argument is a name
  2314. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2315. mob_id = atoi(monster);
  2316. if (mob_id == 0) {
  2317. clif_displaymessage(fd, msg_txt(40));
  2318. return -1;
  2319. }
  2320. if (mob_id == MOBID_EMPERIUM) {
  2321. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2322. return -1;
  2323. }
  2324. if (mobdb_checkid(mob_id) == 0) {
  2325. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2326. return -1;
  2327. }
  2328. if (number <= 0)
  2329. number = 1;
  2330. if( !name[0] )
  2331. strcpy(name, "--ja--");
  2332. // 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
  2333. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2334. number = battle_config.atc_spawn_quantity_limit;
  2335. count = 0;
  2336. for (i = 0; i < number; i++) {
  2337. int mx, my;
  2338. if (x <= 0)
  2339. mx = sd->bl.x + (rnd() % 11 - 5);
  2340. else
  2341. mx = x;
  2342. if (y <= 0)
  2343. my = sd->bl.y + (rnd() % 11 - 5);
  2344. else
  2345. my = y;
  2346. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2347. }
  2348. if (count != 0)
  2349. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2350. else
  2351. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2352. return 0;
  2353. }
  2354. /*==========================================
  2355. *
  2356. *------------------------------------------*/
  2357. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2358. {
  2359. struct mob_data *md;
  2360. int flag;
  2361. nullpo_ret(md=(struct mob_data *)bl);
  2362. flag = va_arg(ap, int);
  2363. if (md->guardian_data)
  2364. return 0; //Do not touch WoE mobs!
  2365. if (flag)
  2366. status_zap(bl,md->status.hp, 0);
  2367. else
  2368. status_kill(bl);
  2369. return 1;
  2370. }
  2371. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2372. {
  2373. int map_id;
  2374. char map_name[MAP_NAME_LENGTH_EXT];
  2375. if (!sd) return;
  2376. memset(map_name, '\0', sizeof(map_name));
  2377. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2378. map_id = sd->bl.m;
  2379. else {
  2380. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2381. map_id = sd->bl.m;
  2382. }
  2383. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2384. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2385. return;
  2386. }
  2387. ACMD_FUNC(killmonster)
  2388. {
  2389. atcommand_killmonster_sub(fd, sd, message, 1);
  2390. return 0;
  2391. }
  2392. /*==========================================
  2393. *
  2394. *------------------------------------------*/
  2395. ACMD_FUNC(killmonster2)
  2396. {
  2397. atcommand_killmonster_sub(fd, sd, message, 0);
  2398. return 0;
  2399. }
  2400. /*==========================================
  2401. *
  2402. *------------------------------------------*/
  2403. ACMD_FUNC(refine)
  2404. {
  2405. int i,j, position = 0, refine = 0, current_position, final_refine;
  2406. int count;
  2407. nullpo_retr(-1, sd);
  2408. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2409. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2410. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2411. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2412. clif_displaymessage(fd, atcmd_output);
  2413. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2414. clif_displaymessage(fd, atcmd_output);
  2415. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2416. clif_displaymessage(fd, atcmd_output);
  2417. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2418. clif_displaymessage(fd, atcmd_output);
  2419. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2420. clif_displaymessage(fd, atcmd_output);
  2421. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2422. clif_displaymessage(fd, atcmd_output);
  2423. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2424. clif_displaymessage(fd, atcmd_output);
  2425. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2426. clif_displaymessage(fd, atcmd_output);
  2427. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2428. clif_displaymessage(fd, atcmd_output);
  2429. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2430. clif_displaymessage(fd, atcmd_output);
  2431. return -1;
  2432. }
  2433. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2434. count = 0;
  2435. for (j = 0; j < EQI_MAX-1; j++) {
  2436. if ((i = sd->equip_index[j]) < 0)
  2437. continue;
  2438. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2439. continue;
  2440. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2441. continue;
  2442. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2443. continue;
  2444. if(position && !(sd->status.inventory[i].equip & position))
  2445. continue;
  2446. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2447. if (sd->status.inventory[i].refine != final_refine) {
  2448. sd->status.inventory[i].refine = final_refine;
  2449. current_position = sd->status.inventory[i].equip;
  2450. pc_unequipitem(sd, i, 3);
  2451. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2452. clif_delitem(sd, i, 1, 3);
  2453. clif_additem(sd, i, 1, 0);
  2454. pc_equipitem(sd, i, current_position);
  2455. clif_misceffect(&sd->bl, 3);
  2456. count++;
  2457. }
  2458. }
  2459. if (count == 0)
  2460. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2461. else if (count == 1)
  2462. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2463. else {
  2464. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2465. clif_displaymessage(fd, atcmd_output);
  2466. }
  2467. return 0;
  2468. }
  2469. /*==========================================
  2470. *
  2471. *------------------------------------------*/
  2472. ACMD_FUNC(produce)
  2473. {
  2474. char item_name[100];
  2475. int item_id, attribute = 0, star = 0;
  2476. int flag = 0;
  2477. struct item_data *item_data;
  2478. struct item tmp_item;
  2479. nullpo_retr(-1, sd);
  2480. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2481. memset(item_name, '\0', sizeof(item_name));
  2482. if (!message || !*message || (
  2483. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2484. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2485. )) {
  2486. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2487. return -1;
  2488. }
  2489. item_id = 0;
  2490. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2491. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2492. {
  2493. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2494. return -1;
  2495. }
  2496. item_id = item_data->nameid;
  2497. if (itemdb_isequip2(item_data)) {
  2498. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2499. attribute = ATTRIBUTE_NORMAL;
  2500. if (star < MIN_STAR || star > MAX_STAR)
  2501. star = 0;
  2502. memset(&tmp_item, 0, sizeof tmp_item);
  2503. tmp_item.nameid = item_id;
  2504. tmp_item.amount = 1;
  2505. tmp_item.identify = 1;
  2506. tmp_item.card[0] = CARD0_FORGE;
  2507. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2508. ((star*5) << 8) + attribute:0;
  2509. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2510. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2511. clif_produceeffect(sd, 0, item_id);
  2512. clif_misceffect(&sd->bl, 3);
  2513. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2514. clif_additem(sd, 0, 0, flag);
  2515. } else {
  2516. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2517. clif_displaymessage(fd, atcmd_output);
  2518. return -1;
  2519. }
  2520. return 0;
  2521. }
  2522. /*==========================================
  2523. *
  2524. *------------------------------------------*/
  2525. ACMD_FUNC(memo)
  2526. {
  2527. int position = 0;
  2528. nullpo_retr(-1, sd);
  2529. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2530. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2531. {
  2532. int i;
  2533. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2534. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2535. {
  2536. if( sd->status.memo_point[i].map )
  2537. 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);
  2538. else
  2539. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2540. clif_displaymessage(sd->fd, atcmd_output);
  2541. }
  2542. return 0;
  2543. }
  2544. if( position < 0 || position >= MAX_MEMOPOINTS )
  2545. {
  2546. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2547. clif_displaymessage(fd, atcmd_output);
  2548. return -1;
  2549. }
  2550. pc_memo(sd, position);
  2551. return 0;
  2552. }
  2553. /*==========================================
  2554. *
  2555. *------------------------------------------*/
  2556. ACMD_FUNC(gat)
  2557. {
  2558. int y;
  2559. nullpo_retr(-1, sd);
  2560. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2561. for (y = 2; y >= -2; y--) {
  2562. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2563. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2564. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2565. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2566. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2567. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2568. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2569. clif_displaymessage(fd, atcmd_output);
  2570. }
  2571. return 0;
  2572. }
  2573. /*==========================================
  2574. *
  2575. *------------------------------------------*/
  2576. ACMD_FUNC(displaystatus)
  2577. {
  2578. int i, type, flag, tick;
  2579. nullpo_retr(-1, sd);
  2580. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2581. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2582. return -1;
  2583. }
  2584. if (i < 2) flag = 1;
  2585. if (i < 3) tick = 0;
  2586. clif_status_change(&sd->bl, type, flag, tick, 0, 0, 0);
  2587. return 0;
  2588. }
  2589. /*==========================================
  2590. * @stpoint (Rewritten by [Yor])
  2591. *------------------------------------------*/
  2592. ACMD_FUNC(statuspoint)
  2593. {
  2594. int point;
  2595. unsigned int new_status_point;
  2596. if (!message || !*message || (point = atoi(message)) == 0) {
  2597. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2598. return -1;
  2599. }
  2600. if(point < 0)
  2601. {
  2602. if(sd->status.status_point < (unsigned int)(-point))
  2603. {
  2604. new_status_point = 0;
  2605. }
  2606. else
  2607. {
  2608. new_status_point = sd->status.status_point + point;
  2609. }
  2610. }
  2611. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2612. {
  2613. new_status_point = UINT_MAX;
  2614. }
  2615. else
  2616. {
  2617. new_status_point = sd->status.status_point + point;
  2618. }
  2619. if (new_status_point != sd->status.status_point) {
  2620. sd->status.status_point = new_status_point;
  2621. clif_updatestatus(sd, SP_STATUSPOINT);
  2622. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2623. } else {
  2624. if (point < 0)
  2625. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2626. else
  2627. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2628. return -1;
  2629. }
  2630. return 0;
  2631. }
  2632. /*==========================================
  2633. * @skpoint (Rewritten by [Yor])
  2634. *------------------------------------------*/
  2635. ACMD_FUNC(skillpoint)
  2636. {
  2637. int point;
  2638. unsigned int new_skill_point;
  2639. nullpo_retr(-1, sd);
  2640. if (!message || !*message || (point = atoi(message)) == 0) {
  2641. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2642. return -1;
  2643. }
  2644. if(point < 0)
  2645. {
  2646. if(sd->status.skill_point < (unsigned int)(-point))
  2647. {
  2648. new_skill_point = 0;
  2649. }
  2650. else
  2651. {
  2652. new_skill_point = sd->status.skill_point + point;
  2653. }
  2654. }
  2655. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2656. {
  2657. new_skill_point = UINT_MAX;
  2658. }
  2659. else
  2660. {
  2661. new_skill_point = sd->status.skill_point + point;
  2662. }
  2663. if (new_skill_point != sd->status.skill_point) {
  2664. sd->status.skill_point = new_skill_point;
  2665. clif_updatestatus(sd, SP_SKILLPOINT);
  2666. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2667. } else {
  2668. if (point < 0)
  2669. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2670. else
  2671. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2672. return -1;
  2673. }
  2674. return 0;
  2675. }
  2676. /*==========================================
  2677. * @zeny (Rewritten by [Yor])
  2678. *------------------------------------------*/
  2679. ACMD_FUNC(zeny)
  2680. {
  2681. int zeny, new_zeny;
  2682. nullpo_retr(-1, sd);
  2683. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2684. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2685. return -1;
  2686. }
  2687. new_zeny = sd->status.zeny + zeny;
  2688. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2689. new_zeny = MAX_ZENY;
  2690. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2691. new_zeny = 0;
  2692. if (new_zeny != sd->status.zeny) {
  2693. sd->status.zeny = new_zeny;
  2694. clif_updatestatus(sd, SP_ZENY);
  2695. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2696. } else {
  2697. if (zeny < 0)
  2698. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2699. else
  2700. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2701. return -1;
  2702. }
  2703. return 0;
  2704. }
  2705. /*==========================================
  2706. *
  2707. *------------------------------------------*/
  2708. ACMD_FUNC(param)
  2709. {
  2710. int i, value = 0, new_value, max;
  2711. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2712. short* status[6];
  2713. //we don't use direct initialization because it isn't part of the c standard.
  2714. nullpo_retr(-1, sd);
  2715. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2716. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2717. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2718. clif_displaymessage(fd, atcmd_output);
  2719. return -1;
  2720. }
  2721. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2722. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2723. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2724. clif_displaymessage(fd, atcmd_output);
  2725. return -1;
  2726. }
  2727. status[0] = &sd->status.str;
  2728. status[1] = &sd->status.agi;
  2729. status[2] = &sd->status.vit;
  2730. status[3] = &sd->status.int_;
  2731. status[4] = &sd->status.dex;
  2732. status[5] = &sd->status.luk;
  2733. if( battle_config.atcommand_max_stat_bypass )
  2734. max = SHRT_MAX;
  2735. else
  2736. max = pc_maxparameter(sd);
  2737. if(value < 0 && *status[i] <= -value) {
  2738. new_value = 1;
  2739. } else if(max - *status[i] < value) {
  2740. new_value = max;
  2741. } else {
  2742. new_value = *status[i] + value;
  2743. }
  2744. if (new_value != *status[i]) {
  2745. *status[i] = new_value;
  2746. clif_updatestatus(sd, SP_STR + i);
  2747. clif_updatestatus(sd, SP_USTR + i);
  2748. status_calc_pc(sd, 0);
  2749. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2750. } else {
  2751. if (value < 0)
  2752. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2753. else
  2754. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2755. return -1;
  2756. }
  2757. return 0;
  2758. }
  2759. /*==========================================
  2760. * Stat all by fritz (rewritten by [Yor])
  2761. *------------------------------------------*/
  2762. ACMD_FUNC(stat_all)
  2763. {
  2764. int index, count, value, max, new_value;
  2765. short* status[6];
  2766. //we don't use direct initialization because it isn't part of the c standard.
  2767. nullpo_retr(-1, sd);
  2768. status[0] = &sd->status.str;
  2769. status[1] = &sd->status.agi;
  2770. status[2] = &sd->status.vit;
  2771. status[3] = &sd->status.int_;
  2772. status[4] = &sd->status.dex;
  2773. status[5] = &sd->status.luk;
  2774. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2775. value = pc_maxparameter(sd);
  2776. max = pc_maxparameter(sd);
  2777. } else {
  2778. if( battle_config.atcommand_max_stat_bypass )
  2779. max = SHRT_MAX;
  2780. else
  2781. max = pc_maxparameter(sd);
  2782. }
  2783. count = 0;
  2784. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2785. if (value > 0 && *status[index] > max - value)
  2786. new_value = max;
  2787. else if (value < 0 && *status[index] <= -value)
  2788. new_value = 1;
  2789. else
  2790. new_value = *status[index] +value;
  2791. if (new_value != (int)*status[index]) {
  2792. *status[index] = new_value;
  2793. clif_updatestatus(sd, SP_STR + index);
  2794. clif_updatestatus(sd, SP_USTR + index);
  2795. count++;
  2796. }
  2797. }
  2798. if (count > 0) { // if at least 1 stat modified
  2799. status_calc_pc(sd, 0);
  2800. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2801. } else {
  2802. if (value < 0)
  2803. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2804. else
  2805. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2806. return -1;
  2807. }
  2808. return 0;
  2809. }
  2810. /*==========================================
  2811. *
  2812. *------------------------------------------*/
  2813. ACMD_FUNC(guildlevelup)
  2814. {
  2815. int level = 0;
  2816. short added_level;
  2817. struct guild *guild_info;
  2818. nullpo_retr(-1, sd);
  2819. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2820. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2821. return -1;
  2822. }
  2823. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2824. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2825. return -1;
  2826. }
  2827. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2828. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2829. // return -1;
  2830. //}
  2831. added_level = (short)level;
  2832. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2833. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2834. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2835. added_level = 1 - guild_info->guild_lv;
  2836. if (added_level != 0) {
  2837. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2838. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2839. } else {
  2840. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2841. return -1;
  2842. }
  2843. return 0;
  2844. }
  2845. /*==========================================
  2846. *
  2847. *------------------------------------------*/
  2848. ACMD_FUNC(makeegg)
  2849. {
  2850. struct item_data *item_data;
  2851. int id, pet_id;
  2852. nullpo_retr(-1, sd);
  2853. if (!message || !*message) {
  2854. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2855. return -1;
  2856. }
  2857. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2858. id = item_data->nameid;
  2859. else
  2860. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2861. ;
  2862. else
  2863. id = atoi(message);
  2864. pet_id = search_petDB_index(id, PET_CLASS);
  2865. if (pet_id < 0)
  2866. pet_id = search_petDB_index(id, PET_EGG);
  2867. if (pet_id >= 0) {
  2868. sd->catch_target_class = pet_db[pet_id].class_;
  2869. intif_create_pet(
  2870. sd->status.account_id, sd->status.char_id,
  2871. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2872. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2873. 100, 0, 1, pet_db[pet_id].jname);
  2874. } else {
  2875. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2876. return -1;
  2877. }
  2878. return 0;
  2879. }
  2880. /*==========================================
  2881. *
  2882. *------------------------------------------*/
  2883. ACMD_FUNC(hatch)
  2884. {
  2885. nullpo_retr(-1, sd);
  2886. if (sd->status.pet_id <= 0)
  2887. clif_sendegg(sd);
  2888. else {
  2889. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2890. return -1;
  2891. }
  2892. return 0;
  2893. }
  2894. /*==========================================
  2895. *
  2896. *------------------------------------------*/
  2897. ACMD_FUNC(petfriendly)
  2898. {
  2899. int friendly;
  2900. struct pet_data *pd;
  2901. nullpo_retr(-1, sd);
  2902. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2903. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2904. return -1;
  2905. }
  2906. pd = sd->pd;
  2907. if (!pd) {
  2908. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2909. return -1;
  2910. }
  2911. if (friendly < 0 || friendly > 1000)
  2912. {
  2913. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2914. return -1;
  2915. }
  2916. if (friendly == pd->pet.intimate) {
  2917. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2918. return -1;
  2919. }
  2920. pet_set_intimate(pd, friendly);
  2921. clif_send_petstatus(sd);
  2922. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2923. return 0;
  2924. }
  2925. /*==========================================
  2926. *
  2927. *------------------------------------------*/
  2928. ACMD_FUNC(pethungry)
  2929. {
  2930. int hungry;
  2931. struct pet_data *pd;
  2932. nullpo_retr(-1, sd);
  2933. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2934. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2935. return -1;
  2936. }
  2937. pd = sd->pd;
  2938. if (!sd->status.pet_id || !pd) {
  2939. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2940. return -1;
  2941. }
  2942. if (hungry < 0 || hungry > 100) {
  2943. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2944. return -1;
  2945. }
  2946. if (hungry == pd->pet.hungry) {
  2947. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2948. return -1;
  2949. }
  2950. pd->pet.hungry = hungry;
  2951. clif_send_petstatus(sd);
  2952. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2953. return 0;
  2954. }
  2955. /*==========================================
  2956. *
  2957. *------------------------------------------*/
  2958. ACMD_FUNC(petrename)
  2959. {
  2960. struct pet_data *pd;
  2961. nullpo_retr(-1, sd);
  2962. if (!sd->status.pet_id || !sd->pd) {
  2963. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2964. return -1;
  2965. }
  2966. pd = sd->pd;
  2967. if (!pd->pet.rename_flag) {
  2968. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2969. return -1;
  2970. }
  2971. pd->pet.rename_flag = 0;
  2972. intif_save_petdata(sd->status.account_id, &pd->pet);
  2973. clif_send_petstatus(sd);
  2974. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2975. return 0;
  2976. }
  2977. /*==========================================
  2978. *
  2979. *------------------------------------------*/
  2980. ACMD_FUNC(recall)
  2981. {
  2982. struct map_session_data *pl_sd = NULL;
  2983. nullpo_retr(-1, sd);
  2984. if (!message || !*message) {
  2985. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2986. return -1;
  2987. }
  2988. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2989. {
  2990. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2991. return -1;
  2992. }
  2993. if (pl_sd == sd)
  2994. {
  2995. clif_displaymessage(fd, "You are already where you are...");
  2996. return -1;
  2997. }
  2998. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2999. {
  3000. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  3001. return -1;
  3002. }
  3003. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3004. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3005. return -1;
  3006. }
  3007. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3008. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3009. return -1;
  3010. }
  3011. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3012. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  3013. clif_displaymessage(fd, atcmd_output);
  3014. return 0;
  3015. }
  3016. /*==========================================
  3017. * charblock command (usage: charblock <player_name>)
  3018. * This command do a definitiv ban on a player
  3019. *------------------------------------------*/
  3020. ACMD_FUNC(char_block)
  3021. {
  3022. nullpo_retr(-1, sd);
  3023. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3024. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3025. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3026. return -1;
  3027. }
  3028. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3029. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3030. return 0;
  3031. }
  3032. /*==========================================
  3033. * charban command (usage: charban <time> <player_name>)
  3034. * This command do a limited ban on a player
  3035. * Time is done as follows:
  3036. * Adjustment value (-1, 1, +1, etc...)
  3037. * Modified element:
  3038. * a or y: year
  3039. * m: month
  3040. * j or d: day
  3041. * h: hour
  3042. * mn: minute
  3043. * s: second
  3044. * <example> @ban +1m-2mn1s-6y test_player
  3045. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3046. *------------------------------------------*/
  3047. ACMD_FUNC(char_ban)
  3048. {
  3049. char * modif_p;
  3050. int year, month, day, hour, minute, second, value;
  3051. nullpo_retr(-1, sd);
  3052. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3053. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3054. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3055. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3056. return -1;
  3057. }
  3058. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3059. modif_p = atcmd_output;
  3060. year = month = day = hour = minute = second = 0;
  3061. while (modif_p[0] != '\0') {
  3062. value = atoi(modif_p);
  3063. if (value == 0)
  3064. modif_p++;
  3065. else {
  3066. if (modif_p[0] == '-' || modif_p[0] == '+') {
  3067. if( modif_p[0] == '-' && get_atcommand_level("unban") > pc_isGM(sd) ) {
  3068. clif_displaymessage(fd,"You are not allowed to reduce the length of a ban");
  3069. return -1;
  3070. }
  3071. modif_p++;
  3072. }
  3073. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3074. modif_p++;
  3075. if (modif_p[0] == 's') {
  3076. second = value;
  3077. modif_p++;
  3078. } else if (modif_p[0] == 'n') {
  3079. minute = value;
  3080. modif_p++;
  3081. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3082. minute = value;
  3083. modif_p = modif_p + 2;
  3084. } else if (modif_p[0] == 'h') {
  3085. hour = value;
  3086. modif_p++;
  3087. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3088. day = value;
  3089. modif_p++;
  3090. } else if (modif_p[0] == 'm') {
  3091. month = value;
  3092. modif_p++;
  3093. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3094. year = value;
  3095. modif_p++;
  3096. } else if (modif_p[0] != '\0') {
  3097. modif_p++;
  3098. }
  3099. }
  3100. }
  3101. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3102. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3103. return -1;
  3104. }
  3105. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3106. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3107. return 0;
  3108. }
  3109. /*==========================================
  3110. * charunblock command (usage: charunblock <player_name>)
  3111. *------------------------------------------*/
  3112. ACMD_FUNC(char_unblock)
  3113. {
  3114. nullpo_retr(-1, sd);
  3115. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3116. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3117. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3118. return -1;
  3119. }
  3120. // send answer to login server via char-server
  3121. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3122. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3123. return 0;
  3124. }
  3125. /*==========================================
  3126. * charunban command (usage: charunban <player_name>)
  3127. *------------------------------------------*/
  3128. ACMD_FUNC(char_unban)
  3129. {
  3130. nullpo_retr(-1, sd);
  3131. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3132. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3133. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3134. return -1;
  3135. }
  3136. // send answer to login server via char-server
  3137. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3138. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3139. return 0;
  3140. }
  3141. /*==========================================
  3142. *
  3143. *------------------------------------------*/
  3144. ACMD_FUNC(night)
  3145. {
  3146. nullpo_retr(-1, sd);
  3147. if (night_flag != 1) {
  3148. map_night_timer(night_timer_tid, 0, 0, 1);
  3149. } else {
  3150. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  3151. return -1;
  3152. }
  3153. return 0;
  3154. }
  3155. /*==========================================
  3156. *
  3157. *------------------------------------------*/
  3158. ACMD_FUNC(day)
  3159. {
  3160. nullpo_retr(-1, sd);
  3161. if (night_flag != 0) {
  3162. map_day_timer(day_timer_tid, 0, 0, 1);
  3163. } else {
  3164. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  3165. return -1;
  3166. }
  3167. return 0;
  3168. }
  3169. /*==========================================
  3170. *
  3171. *------------------------------------------*/
  3172. ACMD_FUNC(doom)
  3173. {
  3174. struct map_session_data* pl_sd;
  3175. struct s_mapiterator* iter;
  3176. nullpo_retr(-1, sd);
  3177. iter = mapit_getallusers();
  3178. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3179. {
  3180. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3181. {
  3182. status_kill(&pl_sd->bl);
  3183. clif_specialeffect(&pl_sd->bl,450,AREA);
  3184. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3185. }
  3186. }
  3187. mapit_free(iter);
  3188. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3189. return 0;
  3190. }
  3191. /*==========================================
  3192. *
  3193. *------------------------------------------*/
  3194. ACMD_FUNC(doommap)
  3195. {
  3196. struct map_session_data* pl_sd;
  3197. struct s_mapiterator* iter;
  3198. nullpo_retr(-1, sd);
  3199. iter = mapit_getallusers();
  3200. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3201. {
  3202. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3203. {
  3204. status_kill(&pl_sd->bl);
  3205. clif_specialeffect(&pl_sd->bl,450,AREA);
  3206. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3207. }
  3208. }
  3209. mapit_free(iter);
  3210. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3211. return 0;
  3212. }
  3213. /*==========================================
  3214. *
  3215. *------------------------------------------*/
  3216. static void atcommand_raise_sub(struct map_session_data* sd)
  3217. {
  3218. if (!status_isdead(&sd->bl))
  3219. return;
  3220. if(!status_revive(&sd->bl, 100, 100))
  3221. return;
  3222. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3223. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3224. }
  3225. /*==========================================
  3226. *
  3227. *------------------------------------------*/
  3228. ACMD_FUNC(raise)
  3229. {
  3230. struct map_session_data* pl_sd;
  3231. struct s_mapiterator* iter;
  3232. nullpo_retr(-1, sd);
  3233. iter = mapit_getallusers();
  3234. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3235. atcommand_raise_sub(pl_sd);
  3236. mapit_free(iter);
  3237. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3238. return 0;
  3239. }
  3240. /*==========================================
  3241. *
  3242. *------------------------------------------*/
  3243. ACMD_FUNC(raisemap)
  3244. {
  3245. struct map_session_data* pl_sd;
  3246. struct s_mapiterator* iter;
  3247. nullpo_retr(-1, sd);
  3248. iter = mapit_getallusers();
  3249. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3250. if (sd->bl.m == pl_sd->bl.m)
  3251. atcommand_raise_sub(pl_sd);
  3252. mapit_free(iter);
  3253. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3254. return 0;
  3255. }
  3256. /*==========================================
  3257. *
  3258. *------------------------------------------*/
  3259. ACMD_FUNC(kick)
  3260. {
  3261. struct map_session_data *pl_sd;
  3262. nullpo_retr(-1, sd);
  3263. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3264. if (!message || !*message) {
  3265. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3266. return -1;
  3267. }
  3268. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3269. {
  3270. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3271. return -1;
  3272. }
  3273. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3274. {
  3275. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3276. return -1;
  3277. }
  3278. clif_GM_kick(sd, pl_sd);
  3279. return 0;
  3280. }
  3281. /*==========================================
  3282. *
  3283. *------------------------------------------*/
  3284. ACMD_FUNC(kickall)
  3285. {
  3286. struct map_session_data* pl_sd;
  3287. struct s_mapiterator* iter;
  3288. nullpo_retr(-1, sd);
  3289. iter = mapit_getallusers();
  3290. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3291. {
  3292. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3293. if (sd->status.account_id != pl_sd->status.account_id)
  3294. clif_GM_kick(NULL, pl_sd);
  3295. }
  3296. }
  3297. mapit_free(iter);
  3298. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3299. return 0;
  3300. }
  3301. /*==========================================
  3302. *
  3303. *------------------------------------------*/
  3304. ACMD_FUNC(allskill)
  3305. {
  3306. nullpo_retr(-1, sd);
  3307. pc_allskillup(sd); // all skills
  3308. sd->status.skill_point = 0; // 0 skill points
  3309. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3310. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3311. return 0;
  3312. }
  3313. /*==========================================
  3314. *
  3315. *------------------------------------------*/
  3316. ACMD_FUNC(questskill)
  3317. {
  3318. int skill_id;
  3319. nullpo_retr(-1, sd);
  3320. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3321. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3322. return -1;
  3323. }
  3324. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3325. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3326. return -1;
  3327. }
  3328. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3329. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3330. return -1;
  3331. }
  3332. if (pc_checkskill(sd, skill_id) > 0) {
  3333. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3334. return -1;
  3335. }
  3336. pc_skill(sd, skill_id, 1, 0);
  3337. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3338. return 0;
  3339. }
  3340. /*==========================================
  3341. *
  3342. *------------------------------------------*/
  3343. ACMD_FUNC(lostskill)
  3344. {
  3345. int skill_id;
  3346. nullpo_retr(-1, sd);
  3347. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3348. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3349. return -1;
  3350. }
  3351. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3352. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3353. return -1;
  3354. }
  3355. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3356. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3357. return -1;
  3358. }
  3359. if (pc_checkskill(sd, skill_id) == 0) {
  3360. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3361. return -1;
  3362. }
  3363. sd->status.skill[skill_id].lv = 0;
  3364. sd->status.skill[skill_id].flag = 0;
  3365. clif_deleteskill(sd,skill_id);
  3366. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3367. return 0;
  3368. }
  3369. /*==========================================
  3370. *
  3371. *------------------------------------------*/
  3372. ACMD_FUNC(spiritball)
  3373. {
  3374. int max_spiritballs;
  3375. int number;
  3376. nullpo_retr(-1, sd);
  3377. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3378. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3379. {
  3380. char msg[CHAT_SIZE_MAX];
  3381. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3382. clif_displaymessage(fd, msg);
  3383. return -1;
  3384. }
  3385. if( sd->spiritball > 0 )
  3386. pc_delspiritball(sd, sd->spiritball, 1);
  3387. sd->spiritball = number;
  3388. clif_spiritball(sd);
  3389. // no message, player can look the difference
  3390. return 0;
  3391. }
  3392. /*==========================================
  3393. *
  3394. *------------------------------------------*/
  3395. ACMD_FUNC(party)
  3396. {
  3397. char party[NAME_LENGTH];
  3398. nullpo_retr(-1, sd);
  3399. memset(party, '\0', sizeof(party));
  3400. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3401. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3402. return -1;
  3403. }
  3404. party_create(sd, party, 0, 0);
  3405. return 0;
  3406. }
  3407. /*==========================================
  3408. *
  3409. *------------------------------------------*/
  3410. ACMD_FUNC(guild)
  3411. {
  3412. char guild[NAME_LENGTH];
  3413. int prev;
  3414. nullpo_retr(-1, sd);
  3415. memset(guild, '\0', sizeof(guild));
  3416. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3417. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3418. return -1;
  3419. }
  3420. prev = battle_config.guild_emperium_check;
  3421. battle_config.guild_emperium_check = 0;
  3422. guild_create(sd, guild);
  3423. battle_config.guild_emperium_check = prev;
  3424. return 0;
  3425. }
  3426. /*==========================================
  3427. *
  3428. *------------------------------------------*/
  3429. ACMD_FUNC(agitstart)
  3430. {
  3431. nullpo_retr(-1, sd);
  3432. if (agit_flag == 1) {
  3433. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3434. return -1;
  3435. }
  3436. agit_flag = 1;
  3437. guild_agit_start();
  3438. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3439. return 0;
  3440. }
  3441. /*==========================================
  3442. *
  3443. *------------------------------------------*/
  3444. ACMD_FUNC(agitstart2)
  3445. {
  3446. nullpo_retr(-1, sd);
  3447. if (agit2_flag == 1) {
  3448. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3449. return -1;
  3450. }
  3451. agit2_flag = 1;
  3452. guild_agit2_start();
  3453. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3454. return 0;
  3455. }
  3456. /*==========================================
  3457. *
  3458. *------------------------------------------*/
  3459. ACMD_FUNC(agitend)
  3460. {
  3461. nullpo_retr(-1, sd);
  3462. if (agit_flag == 0) {
  3463. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3464. return -1;
  3465. }
  3466. agit_flag = 0;
  3467. guild_agit_end();
  3468. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3469. return 0;
  3470. }
  3471. /*==========================================
  3472. *
  3473. *------------------------------------------*/
  3474. ACMD_FUNC(agitend2)
  3475. {
  3476. nullpo_retr(-1, sd);
  3477. if (agit2_flag == 0) {
  3478. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3479. return -1;
  3480. }
  3481. agit2_flag = 0;
  3482. guild_agit2_end();
  3483. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3484. return 0;
  3485. }
  3486. /*==========================================
  3487. * @mapexit - shuts down the map server
  3488. *------------------------------------------*/
  3489. ACMD_FUNC(mapexit)
  3490. {
  3491. nullpo_retr(-1, sd);
  3492. do_shutdown();
  3493. return 0;
  3494. }
  3495. /*==========================================
  3496. * idsearch <part_of_name>: revrited by [Yor]
  3497. *------------------------------------------*/
  3498. ACMD_FUNC(idsearch)
  3499. {
  3500. char item_name[100];
  3501. unsigned int i, match;
  3502. struct item_data *item_array[MAX_SEARCH];
  3503. nullpo_retr(-1, sd);
  3504. memset(item_name, '\0', sizeof(item_name));
  3505. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3506. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3507. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3508. return -1;
  3509. }
  3510. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3511. clif_displaymessage(fd, atcmd_output);
  3512. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3513. if (match > MAX_SEARCH) {
  3514. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3515. clif_displaymessage(fd, atcmd_output);
  3516. match = MAX_SEARCH;
  3517. }
  3518. for(i = 0; i < match; i++) {
  3519. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3520. clif_displaymessage(fd, atcmd_output);
  3521. }
  3522. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3523. clif_displaymessage(fd, atcmd_output);
  3524. return 0;
  3525. }
  3526. /*==========================================
  3527. * Recall All Characters Online To Your Location
  3528. *------------------------------------------*/
  3529. ACMD_FUNC(recallall)
  3530. {
  3531. struct map_session_data* pl_sd;
  3532. struct s_mapiterator* iter;
  3533. int count;
  3534. nullpo_retr(-1, sd);
  3535. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3536. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3537. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3538. return -1;
  3539. }
  3540. count = 0;
  3541. iter = mapit_getallusers();
  3542. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3543. {
  3544. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3545. {
  3546. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3547. count++;
  3548. else {
  3549. if (pc_isdead(pl_sd)) { //Wake them up
  3550. pc_setstand(pl_sd);
  3551. pc_setrestartvalue(pl_sd,1);
  3552. }
  3553. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3554. }
  3555. }
  3556. }
  3557. mapit_free(iter);
  3558. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3559. if (count) {
  3560. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3561. clif_displaymessage(fd, atcmd_output);
  3562. }
  3563. return 0;
  3564. }
  3565. /*==========================================
  3566. * Recall online characters of a guild to your location
  3567. *------------------------------------------*/
  3568. ACMD_FUNC(guildrecall)
  3569. {
  3570. struct map_session_data* pl_sd;
  3571. struct s_mapiterator* iter;
  3572. int count;
  3573. char guild_name[NAME_LENGTH];
  3574. struct guild *g;
  3575. nullpo_retr(-1, sd);
  3576. memset(guild_name, '\0', sizeof(guild_name));
  3577. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3578. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3579. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3580. return -1;
  3581. }
  3582. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3583. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3584. return -1;
  3585. }
  3586. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3587. (g = guild_search(atoi(message))) == NULL)
  3588. {
  3589. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3590. return -1;
  3591. }
  3592. count = 0;
  3593. iter = mapit_getallusers();
  3594. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3595. {
  3596. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3597. {
  3598. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3599. continue; //Skip GMs greater than you.
  3600. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3601. count++;
  3602. else
  3603. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3604. }
  3605. }
  3606. mapit_free(iter);
  3607. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3608. clif_displaymessage(fd, atcmd_output);
  3609. if (count) {
  3610. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3611. clif_displaymessage(fd, atcmd_output);
  3612. }
  3613. return 0;
  3614. }
  3615. /*==========================================
  3616. * Recall online characters of a party to your location
  3617. *------------------------------------------*/
  3618. ACMD_FUNC(partyrecall)
  3619. {
  3620. struct map_session_data* pl_sd;
  3621. struct s_mapiterator* iter;
  3622. char party_name[NAME_LENGTH];
  3623. struct party_data *p;
  3624. int count;
  3625. nullpo_retr(-1, sd);
  3626. memset(party_name, '\0', sizeof(party_name));
  3627. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3628. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3629. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3630. return -1;
  3631. }
  3632. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3633. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3634. return -1;
  3635. }
  3636. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3637. (p = party_search(atoi(message))) == NULL)
  3638. {
  3639. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3640. return -1;
  3641. }
  3642. count = 0;
  3643. iter = mapit_getallusers();
  3644. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3645. {
  3646. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3647. {
  3648. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3649. continue; //Skip GMs greater than you.
  3650. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3651. count++;
  3652. else
  3653. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3654. }
  3655. }
  3656. mapit_free(iter);
  3657. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3658. clif_displaymessage(fd, atcmd_output);
  3659. if (count) {
  3660. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3661. clif_displaymessage(fd, atcmd_output);
  3662. }
  3663. return 0;
  3664. }
  3665. /*==========================================
  3666. *
  3667. *------------------------------------------*/
  3668. ACMD_FUNC(reloaditemdb)
  3669. {
  3670. nullpo_retr(-1, sd);
  3671. itemdb_reload();
  3672. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3673. return 0;
  3674. }
  3675. /*==========================================
  3676. *
  3677. *------------------------------------------*/
  3678. ACMD_FUNC(reloadmobdb)
  3679. {
  3680. nullpo_retr(-1, sd);
  3681. mob_reload();
  3682. read_petdb();
  3683. merc_reload();
  3684. read_mercenarydb();
  3685. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3686. return 0;
  3687. }
  3688. /*==========================================
  3689. *
  3690. *------------------------------------------*/
  3691. ACMD_FUNC(reloadskilldb)
  3692. {
  3693. nullpo_retr(-1, sd);
  3694. skill_reload();
  3695. merc_skill_reload();
  3696. read_mercenary_skilldb();
  3697. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3698. return 0;
  3699. }
  3700. /*==========================================
  3701. * @reloadatcommand - reloads atcommand_athena.conf
  3702. *------------------------------------------*/
  3703. void atcommand_doload();
  3704. ACMD_FUNC(reloadatcommand) {
  3705. atcommand_doload();
  3706. clif_displaymessage(fd, msg_txt(254));
  3707. return 0;
  3708. }
  3709. /*==========================================
  3710. * @reloadbattleconf - reloads battle_athena.conf
  3711. *------------------------------------------*/
  3712. ACMD_FUNC(reloadbattleconf)
  3713. {
  3714. struct Battle_Config prev_config;
  3715. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3716. battle_config_read(BATTLE_CONF_FILENAME);
  3717. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3718. || prev_config.item_rate_common != battle_config.item_rate_common
  3719. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3720. || prev_config.item_rate_card != battle_config.item_rate_card
  3721. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3722. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3723. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3724. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3725. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3726. || prev_config.item_rate_use != battle_config.item_rate_use
  3727. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3728. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3729. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3730. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3731. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3732. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3733. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3734. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3735. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3736. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3737. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3738. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3739. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3740. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3741. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3742. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3743. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3744. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3745. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3746. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3747. )
  3748. { // Exp or Drop rates changed.
  3749. mob_reload(); //Needed as well so rate changes take effect.
  3750. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3751. }
  3752. clif_displaymessage(fd, msg_txt(255));
  3753. return 0;
  3754. }
  3755. /*==========================================
  3756. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3757. *------------------------------------------*/
  3758. ACMD_FUNC(reloadstatusdb)
  3759. {
  3760. status_readdb();
  3761. clif_displaymessage(fd, msg_txt(256));
  3762. return 0;
  3763. }
  3764. /*==========================================
  3765. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3766. *------------------------------------------*/
  3767. ACMD_FUNC(reloadpcdb)
  3768. {
  3769. pc_readdb();
  3770. clif_displaymessage(fd, msg_txt(257));
  3771. return 0;
  3772. }
  3773. /*==========================================
  3774. * @reloadmotd - reloads motd.txt
  3775. *------------------------------------------*/
  3776. ACMD_FUNC(reloadmotd)
  3777. {
  3778. pc_read_motd();
  3779. clif_displaymessage(fd, msg_txt(268));
  3780. return 0;
  3781. }
  3782. /*==========================================
  3783. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3784. *------------------------------------------*/
  3785. ACMD_FUNC(reloadscript)
  3786. {
  3787. nullpo_retr(-1, sd);
  3788. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3789. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3790. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3791. flush_fifos();
  3792. script_reload();
  3793. npc_reload();
  3794. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3795. return 0;
  3796. }
  3797. /*==========================================
  3798. * @mapinfo [0-3] <map name> by MC_Cameri
  3799. * => Shows information about the map [map name]
  3800. * 0 = no additional information
  3801. * 1 = Show users in that map and their location
  3802. * 2 = Shows NPCs in that map
  3803. * 3 = Shows the shops/chats in that map (not implemented)
  3804. *------------------------------------------*/
  3805. ACMD_FUNC(mapinfo)
  3806. {
  3807. struct map_session_data* pl_sd;
  3808. struct s_mapiterator* iter;
  3809. struct npc_data *nd = NULL;
  3810. struct chat_data *cd = NULL;
  3811. char direction[12];
  3812. int i, m_id, chat_num, list = 0;
  3813. unsigned short m_index;
  3814. char mapname[24];
  3815. nullpo_retr(-1, sd);
  3816. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3817. memset(mapname, '\0', sizeof(mapname));
  3818. memset(direction, '\0', sizeof(direction));
  3819. sscanf(message, "%d %23[^\n]", &list, mapname);
  3820. if (list < 0 || list > 3) {
  3821. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3822. return -1;
  3823. }
  3824. if (mapname[0] == '\0') {
  3825. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3826. m_id = map_mapindex2mapid(sd->mapindex);
  3827. } else {
  3828. m_id = map_mapname2mapid(mapname);
  3829. }
  3830. if (m_id < 0) {
  3831. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3832. return -1;
  3833. }
  3834. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3835. clif_displaymessage(fd, "------ Map Info ------");
  3836. // count chats (for initial message)
  3837. chat_num = 0;
  3838. iter = mapit_getallusers();
  3839. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3840. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3841. chat_num++;
  3842. mapit_free(iter);
  3843. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
  3844. clif_displaymessage(fd, atcmd_output);
  3845. clif_displaymessage(fd, "------ Map Flags ------");
  3846. if (map[m_id].flag.town)
  3847. clif_displaymessage(fd, "Town Map");
  3848. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3849. clif_displaymessage(fd, "Autotrade Enabled");
  3850. else
  3851. clif_displaymessage(fd, "Autotrade Disabled");
  3852. if (map[m_id].flag.battleground)
  3853. clif_displaymessage(fd, "Battlegrounds ON");
  3854. strcpy(atcmd_output,"PvP Flags: ");
  3855. if (map[m_id].flag.pvp)
  3856. strcat(atcmd_output, "Pvp ON | ");
  3857. if (map[m_id].flag.pvp_noguild)
  3858. strcat(atcmd_output, "NoGuild | ");
  3859. if (map[m_id].flag.pvp_noparty)
  3860. strcat(atcmd_output, "NoParty | ");
  3861. if (map[m_id].flag.pvp_nightmaredrop)
  3862. strcat(atcmd_output, "NightmareDrop | ");
  3863. if (map[m_id].flag.pvp_nocalcrank)
  3864. strcat(atcmd_output, "NoCalcRank | ");
  3865. clif_displaymessage(fd, atcmd_output);
  3866. strcpy(atcmd_output,"GvG Flags: ");
  3867. if (map[m_id].flag.gvg)
  3868. strcat(atcmd_output, "GvG ON | ");
  3869. if (map[m_id].flag.gvg_dungeon)
  3870. strcat(atcmd_output, "GvG Dungeon | ");
  3871. if (map[m_id].flag.gvg_castle)
  3872. strcat(atcmd_output, "GvG Castle | ");
  3873. if (map[m_id].flag.gvg_noparty)
  3874. strcat(atcmd_output, "NoParty | ");
  3875. clif_displaymessage(fd, atcmd_output);
  3876. strcpy(atcmd_output,"Teleport Flags: ");
  3877. if (map[m_id].flag.noteleport)
  3878. strcat(atcmd_output, "NoTeleport | ");
  3879. if (map[m_id].flag.monster_noteleport)
  3880. strcat(atcmd_output, "Monster NoTeleport | ");
  3881. if (map[m_id].flag.nowarp)
  3882. strcat(atcmd_output, "NoWarp | ");
  3883. if (map[m_id].flag.nowarpto)
  3884. strcat(atcmd_output, "NoWarpTo | ");
  3885. if (map[m_id].flag.noreturn)
  3886. strcat(atcmd_output, "NoReturn | ");
  3887. if (map[m_id].flag.nogo)
  3888. strcat(atcmd_output, "NoGo | ");
  3889. if (map[m_id].flag.nomemo)
  3890. strcat(atcmd_output, "NoMemo | ");
  3891. clif_displaymessage(fd, atcmd_output);
  3892. 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");
  3893. clif_displaymessage(fd, atcmd_output);
  3894. if (map[m_id].flag.nosave) {
  3895. if (!map[m_id].save.map)
  3896. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3897. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3898. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3899. else
  3900. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3901. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3902. clif_displaymessage(fd, atcmd_output);
  3903. }
  3904. strcpy(atcmd_output,"Weather Flags: ");
  3905. if (map[m_id].flag.snow)
  3906. strcat(atcmd_output, "Snow | ");
  3907. if (map[m_id].flag.fog)
  3908. strcat(atcmd_output, "Fog | ");
  3909. if (map[m_id].flag.sakura)
  3910. strcat(atcmd_output, "Sakura | ");
  3911. if (map[m_id].flag.clouds)
  3912. strcat(atcmd_output, "Clouds | ");
  3913. if (map[m_id].flag.clouds2)
  3914. strcat(atcmd_output, "Clouds2 | ");
  3915. if (map[m_id].flag.fireworks)
  3916. strcat(atcmd_output, "Fireworks | ");
  3917. if (map[m_id].flag.leaves)
  3918. strcat(atcmd_output, "Leaves | ");
  3919. /**
  3920. * No longer available, keeping here just in case it's back someday. [Ind]
  3921. **/
  3922. //if (map[m_id].flag.rain)
  3923. // strcat(atcmd_output, "Rain | ");
  3924. if (map[m_id].flag.nightenabled)
  3925. strcat(atcmd_output, "Displays Night | ");
  3926. clif_displaymessage(fd, atcmd_output);
  3927. strcpy(atcmd_output,"Other Flags: ");
  3928. if (map[m_id].flag.nobranch)
  3929. strcat(atcmd_output, "NoBranch | ");
  3930. if (map[m_id].flag.notrade)
  3931. strcat(atcmd_output, "NoTrade | ");
  3932. if (map[m_id].flag.novending)
  3933. strcat(atcmd_output, "NoVending | ");
  3934. if (map[m_id].flag.nodrop)
  3935. strcat(atcmd_output, "NoDrop | ");
  3936. if (map[m_id].flag.noskill)
  3937. strcat(atcmd_output, "NoSkill | ");
  3938. if (map[m_id].flag.noicewall)
  3939. strcat(atcmd_output, "NoIcewall | ");
  3940. if (map[m_id].flag.allowks)
  3941. strcat(atcmd_output, "AllowKS | ");
  3942. if (map[m_id].flag.reset)
  3943. strcat(atcmd_output, "Reset | ");
  3944. clif_displaymessage(fd, atcmd_output);
  3945. strcpy(atcmd_output,"Other Flags: ");
  3946. if (map[m_id].nocommand)
  3947. strcat(atcmd_output, "NoCommand | ");
  3948. if (map[m_id].flag.nobaseexp)
  3949. strcat(atcmd_output, "NoBaseEXP | ");
  3950. if (map[m_id].flag.nojobexp)
  3951. strcat(atcmd_output, "NoJobEXP | ");
  3952. if (map[m_id].flag.nomobloot)
  3953. strcat(atcmd_output, "NoMobLoot | ");
  3954. if (map[m_id].flag.nomvploot)
  3955. strcat(atcmd_output, "NoMVPLoot | ");
  3956. if (map[m_id].flag.partylock)
  3957. strcat(atcmd_output, "PartyLock | ");
  3958. if (map[m_id].flag.guildlock)
  3959. strcat(atcmd_output, "GuildLock | ");
  3960. clif_displaymessage(fd, atcmd_output);
  3961. switch (list) {
  3962. case 0:
  3963. // Do nothing. It's list 0, no additional display.
  3964. break;
  3965. case 1:
  3966. clif_displaymessage(fd, "----- Players in Map -----");
  3967. iter = mapit_getallusers();
  3968. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3969. {
  3970. if (pl_sd->mapindex == m_index) {
  3971. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3972. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3973. clif_displaymessage(fd, atcmd_output);
  3974. }
  3975. }
  3976. mapit_free(iter);
  3977. break;
  3978. case 2:
  3979. clif_displaymessage(fd, "----- NPCs in Map -----");
  3980. for (i = 0; i < map[m_id].npc_num;)
  3981. {
  3982. nd = map[m_id].npc[i];
  3983. switch(nd->ud.dir) {
  3984. case 0: strcpy(direction, "North"); break;
  3985. case 1: strcpy(direction, "North West"); break;
  3986. case 2: strcpy(direction, "West"); break;
  3987. case 3: strcpy(direction, "South West"); break;
  3988. case 4: strcpy(direction, "South"); break;
  3989. case 5: strcpy(direction, "South East"); break;
  3990. case 6: strcpy(direction, "East"); break;
  3991. case 7: strcpy(direction, "North East"); break;
  3992. case 9: strcpy(direction, "North"); break;
  3993. default: strcpy(direction, "Unknown"); break;
  3994. }
  3995. if(strcmp(nd->name,nd->exname) == 0)
  3996. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3997. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3998. else
  3999. sprintf(atcmd_output, "NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d",
  4000. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  4001. clif_displaymessage(fd, atcmd_output);
  4002. }
  4003. break;
  4004. case 3:
  4005. clif_displaymessage(fd, "----- Chats in Map -----");
  4006. iter = mapit_getallusers();
  4007. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4008. {
  4009. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  4010. pl_sd->mapindex == m_index &&
  4011. cd->usersd[0] == pl_sd)
  4012. {
  4013. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  4014. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4015. clif_displaymessage(fd, atcmd_output);
  4016. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4017. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4018. clif_displaymessage(fd, atcmd_output);
  4019. }
  4020. }
  4021. mapit_free(iter);
  4022. break;
  4023. default: // normally impossible to arrive here
  4024. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4025. return -1;
  4026. break;
  4027. }
  4028. return 0;
  4029. }
  4030. /*==========================================
  4031. *
  4032. *------------------------------------------*/
  4033. ACMD_FUNC(mount_peco)
  4034. {
  4035. nullpo_retr(-1, sd);
  4036. if( pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4037. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  4038. clif_displaymessage(sd->fd,"You have mounted your Dragon");
  4039. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  4040. } else {
  4041. clif_displaymessage(sd->fd,"You have released your Dragon");
  4042. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  4043. }
  4044. return 0;
  4045. }
  4046. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4047. if( !(sd->sc.option&OPTION_MADOGEAR) ) {
  4048. clif_displaymessage(sd->fd,"You have mounted your Mado Gear");
  4049. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  4050. } else {
  4051. clif_displaymessage(sd->fd,"You have released your Mado Gear");
  4052. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  4053. }
  4054. return 0;
  4055. }
  4056. if (!pc_isriding(sd)) { // if actually no peco
  4057. if (!pc_checkskill(sd, KN_RIDING))
  4058. {
  4059. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  4060. return -1;
  4061. }
  4062. if (sd->disguise)
  4063. {
  4064. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  4065. return -1;
  4066. }
  4067. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4068. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  4069. } else { //Dismount
  4070. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4071. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  4072. }
  4073. return 0;
  4074. }
  4075. /*==========================================
  4076. *Spy Commands by Syrus22
  4077. *------------------------------------------*/
  4078. ACMD_FUNC(guildspy)
  4079. {
  4080. char guild_name[NAME_LENGTH];
  4081. struct guild *g;
  4082. nullpo_retr(-1, sd);
  4083. memset(guild_name, '\0', sizeof(guild_name));
  4084. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4085. if (!enable_spy)
  4086. {
  4087. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4088. return -1;
  4089. }
  4090. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4091. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4092. return -1;
  4093. }
  4094. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4095. (g = guild_search(atoi(message))) != NULL) {
  4096. if (sd->guildspy == g->guild_id) {
  4097. sd->guildspy = 0;
  4098. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4099. clif_displaymessage(fd, atcmd_output);
  4100. } else {
  4101. sd->guildspy = g->guild_id;
  4102. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4103. clif_displaymessage(fd, atcmd_output);
  4104. }
  4105. } else {
  4106. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  4107. return -1;
  4108. }
  4109. return 0;
  4110. }
  4111. /*==========================================
  4112. *
  4113. *------------------------------------------*/
  4114. ACMD_FUNC(partyspy)
  4115. {
  4116. char party_name[NAME_LENGTH];
  4117. struct party_data *p;
  4118. nullpo_retr(-1, sd);
  4119. memset(party_name, '\0', sizeof(party_name));
  4120. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4121. if (!enable_spy)
  4122. {
  4123. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4124. return -1;
  4125. }
  4126. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4127. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4128. return -1;
  4129. }
  4130. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4131. (p = party_search(atoi(message))) != NULL) {
  4132. if (sd->partyspy == p->party.party_id) {
  4133. sd->partyspy = 0;
  4134. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4135. clif_displaymessage(fd, atcmd_output);
  4136. } else {
  4137. sd->partyspy = p->party.party_id;
  4138. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4139. clif_displaymessage(fd, atcmd_output);
  4140. }
  4141. } else {
  4142. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  4143. return -1;
  4144. }
  4145. return 0;
  4146. }
  4147. /*==========================================
  4148. * @repairall [Valaris]
  4149. *------------------------------------------*/
  4150. ACMD_FUNC(repairall)
  4151. {
  4152. int count, i;
  4153. nullpo_retr(-1, sd);
  4154. count = 0;
  4155. for (i = 0; i < MAX_INVENTORY; i++) {
  4156. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4157. sd->status.inventory[i].attribute = 0;
  4158. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4159. count++;
  4160. }
  4161. }
  4162. if (count > 0) {
  4163. clif_misceffect(&sd->bl, 3);
  4164. clif_equiplist(sd);
  4165. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4166. } else {
  4167. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4168. return -1;
  4169. }
  4170. return 0;
  4171. }
  4172. /*==========================================
  4173. * @nuke [Valaris]
  4174. *------------------------------------------*/
  4175. ACMD_FUNC(nuke)
  4176. {
  4177. struct map_session_data *pl_sd;
  4178. nullpo_retr(-1, sd);
  4179. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4180. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4181. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4182. return -1;
  4183. }
  4184. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4185. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4186. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4187. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4188. } else {
  4189. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4190. return -1;
  4191. }
  4192. } else {
  4193. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4194. return -1;
  4195. }
  4196. return 0;
  4197. }
  4198. /*==========================================
  4199. * @tonpc
  4200. *------------------------------------------*/
  4201. ACMD_FUNC(tonpc)
  4202. {
  4203. char npcname[NAME_LENGTH+1];
  4204. struct npc_data *nd;
  4205. nullpo_retr(-1, sd);
  4206. memset(npcname, 0, sizeof(npcname));
  4207. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4208. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4209. return -1;
  4210. }
  4211. if ((nd = npc_name2id(npcname)) != NULL) {
  4212. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4213. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4214. else
  4215. return -1;
  4216. } else {
  4217. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4218. return -1;
  4219. }
  4220. return 0;
  4221. }
  4222. /*==========================================
  4223. *
  4224. *------------------------------------------*/
  4225. ACMD_FUNC(shownpc)
  4226. {
  4227. char NPCname[NAME_LENGTH+1];
  4228. nullpo_retr(-1, sd);
  4229. memset(NPCname, '\0', sizeof(NPCname));
  4230. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4231. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4232. return -1;
  4233. }
  4234. if (npc_name2id(NPCname) != NULL) {
  4235. npc_enable(NPCname, 1);
  4236. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4237. } else {
  4238. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4239. return -1;
  4240. }
  4241. return 0;
  4242. }
  4243. /*==========================================
  4244. *
  4245. *------------------------------------------*/
  4246. ACMD_FUNC(hidenpc)
  4247. {
  4248. char NPCname[NAME_LENGTH+1];
  4249. nullpo_retr(-1, sd);
  4250. memset(NPCname, '\0', sizeof(NPCname));
  4251. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4252. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4253. return -1;
  4254. }
  4255. if (npc_name2id(NPCname) == NULL) {
  4256. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4257. return -1;
  4258. }
  4259. npc_enable(NPCname, 0);
  4260. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4261. return 0;
  4262. }
  4263. ACMD_FUNC(loadnpc)
  4264. {
  4265. FILE *fp;
  4266. if (!message || !*message) {
  4267. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4268. return -1;
  4269. }
  4270. // check if script file exists
  4271. if ((fp = fopen(message, "r")) == NULL) {
  4272. clif_displaymessage(fd, msg_txt(261));
  4273. return -1;
  4274. }
  4275. fclose(fp);
  4276. // add to list of script sources and run it
  4277. npc_addsrcfile(message);
  4278. npc_parsesrcfile(message);
  4279. npc_read_event_script();
  4280. clif_displaymessage(fd, msg_txt(262));
  4281. return 0;
  4282. }
  4283. ACMD_FUNC(unloadnpc)
  4284. {
  4285. struct npc_data *nd;
  4286. char NPCname[NAME_LENGTH+1];
  4287. nullpo_retr(-1, sd);
  4288. memset(NPCname, '\0', sizeof(NPCname));
  4289. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4290. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4291. return -1;
  4292. }
  4293. if ((nd = npc_name2id(NPCname)) == NULL) {
  4294. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4295. return -1;
  4296. }
  4297. npc_unload_duplicates(nd);
  4298. npc_unload(nd);
  4299. npc_read_event_script();
  4300. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4301. return 0;
  4302. }
  4303. /*==========================================
  4304. * time in txt for time command (by [Yor])
  4305. *------------------------------------------*/
  4306. char* txt_time(unsigned int duration)
  4307. {
  4308. int days, hours, minutes, seconds;
  4309. char temp[CHAT_SIZE_MAX];
  4310. static char temp1[CHAT_SIZE_MAX];
  4311. memset(temp, '\0', sizeof(temp));
  4312. memset(temp1, '\0', sizeof(temp1));
  4313. days = duration / (60 * 60 * 24);
  4314. duration = duration - (60 * 60 * 24 * days);
  4315. hours = duration / (60 * 60);
  4316. duration = duration - (60 * 60 * hours);
  4317. minutes = duration / 60;
  4318. seconds = duration - (60 * minutes);
  4319. if (days < 2)
  4320. sprintf(temp, msg_txt(219), days); // %d day
  4321. else
  4322. sprintf(temp, msg_txt(220), days); // %d days
  4323. if (hours < 2)
  4324. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4325. else
  4326. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4327. if (minutes < 2)
  4328. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4329. else
  4330. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4331. if (seconds < 2)
  4332. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4333. else
  4334. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4335. return temp1;
  4336. }
  4337. /*==========================================
  4338. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4339. * Calculation management of GM modification (@day/@night GM commands) is done
  4340. *------------------------------------------*/
  4341. ACMD_FUNC(servertime)
  4342. {
  4343. const struct TimerData * timer_data;
  4344. const struct TimerData * timer_data2;
  4345. time_t time_server; // variable for number of seconds (used with time() function)
  4346. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4347. char temp[CHAT_SIZE_MAX];
  4348. nullpo_retr(-1, sd);
  4349. memset(temp, '\0', sizeof(temp));
  4350. time(&time_server); // get time in seconds since 1/1/1970
  4351. datetime = localtime(&time_server); // convert seconds in structure
  4352. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4353. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4354. clif_displaymessage(fd, temp);
  4355. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4356. if (night_flag == 0)
  4357. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4358. else
  4359. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4360. } else if (battle_config.night_duration == 0)
  4361. if (night_flag == 1) { // we start with night
  4362. timer_data = get_timer(day_timer_tid);
  4363. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4364. clif_displaymessage(fd, temp);
  4365. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4366. } else
  4367. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4368. else if (battle_config.day_duration == 0)
  4369. if (night_flag == 0) { // we start with day
  4370. timer_data = get_timer(night_timer_tid);
  4371. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4372. clif_displaymessage(fd, temp);
  4373. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4374. } else
  4375. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4376. else {
  4377. if (night_flag == 0) {
  4378. timer_data = get_timer(night_timer_tid);
  4379. timer_data2 = get_timer(day_timer_tid);
  4380. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4381. clif_displaymessage(fd, temp);
  4382. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4383. 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.
  4384. else
  4385. 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.
  4386. clif_displaymessage(fd, temp);
  4387. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4388. clif_displaymessage(fd, temp);
  4389. } else {
  4390. timer_data = get_timer(day_timer_tid);
  4391. timer_data2 = get_timer(night_timer_tid);
  4392. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4393. clif_displaymessage(fd, temp);
  4394. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4395. 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.
  4396. else
  4397. 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.
  4398. clif_displaymessage(fd, temp);
  4399. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4400. clif_displaymessage(fd, temp);
  4401. }
  4402. }
  4403. return 0;
  4404. }
  4405. //Added by Coltaro
  4406. //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...).
  4407. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4408. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4409. {
  4410. const int factor_year = 518400; //12*30*24*60 = 518400
  4411. const int factor_month = 43200; //30*24*60 = 43200
  4412. const int factor_day = 1440; //24*60 = 1440
  4413. const int factor_hour = 60;
  4414. *year = jailtime/factor_year;
  4415. jailtime -= *year*factor_year;
  4416. *month = jailtime/factor_month;
  4417. jailtime -= *month*factor_month;
  4418. *day = jailtime/factor_day;
  4419. jailtime -= *day*factor_day;
  4420. *hour = jailtime/factor_hour;
  4421. jailtime -= *hour*factor_hour;
  4422. *minute = jailtime;
  4423. *year = *year > 0? *year : 0;
  4424. *month = *month > 0? *month : 0;
  4425. *day = *day > 0? *day : 0;
  4426. *hour = *hour > 0? *hour : 0;
  4427. *minute = *minute > 0? *minute : 0;
  4428. return;
  4429. }
  4430. /*==========================================
  4431. * @jail <char_name> by [Yor]
  4432. * Special warp! No check with nowarp and nowarpto flag
  4433. *------------------------------------------*/
  4434. ACMD_FUNC(jail)
  4435. {
  4436. struct map_session_data *pl_sd;
  4437. int x, y;
  4438. unsigned short m_index;
  4439. nullpo_retr(-1, sd);
  4440. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4441. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4442. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4443. return -1;
  4444. }
  4445. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4446. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4447. return -1;
  4448. }
  4449. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4450. { // you can jail only lower or same GM
  4451. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4452. return -1;
  4453. }
  4454. if (pl_sd->sc.data[SC_JAILED])
  4455. {
  4456. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4457. return -1;
  4458. }
  4459. switch(rnd() % 2) { //Jail Locations
  4460. case 0:
  4461. m_index = mapindex_name2id(MAP_JAIL);
  4462. x = 24;
  4463. y = 75;
  4464. break;
  4465. default:
  4466. m_index = mapindex_name2id(MAP_JAIL);
  4467. x = 49;
  4468. y = 75;
  4469. break;
  4470. }
  4471. //Duration of INT_MAX to specify infinity.
  4472. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4473. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4474. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4475. return 0;
  4476. }
  4477. /*==========================================
  4478. * @unjail/@discharge <char_name> by [Yor]
  4479. * Special warp! No check with nowarp and nowarpto flag
  4480. *------------------------------------------*/
  4481. ACMD_FUNC(unjail)
  4482. {
  4483. struct map_session_data *pl_sd;
  4484. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4485. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4486. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4487. return -1;
  4488. }
  4489. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4490. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4491. return -1;
  4492. }
  4493. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4494. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4495. return -1;
  4496. }
  4497. if (!pl_sd->sc.data[SC_JAILED])
  4498. {
  4499. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4500. return -1;
  4501. }
  4502. //Reset jail time to 1 sec.
  4503. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4504. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4505. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4506. return 0;
  4507. }
  4508. ACMD_FUNC(jailfor)
  4509. {
  4510. struct map_session_data *pl_sd = NULL;
  4511. int year, month, day, hour, minute, value;
  4512. char * modif_p;
  4513. int jailtime = 0,x,y;
  4514. short m_index = 0;
  4515. nullpo_retr(-1, sd);
  4516. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4517. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4518. return -1;
  4519. }
  4520. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4521. modif_p = atcmd_output;
  4522. year = month = day = hour = minute = 0;
  4523. while (modif_p[0] != '\0') {
  4524. value = atoi(modif_p);
  4525. if (value == 0)
  4526. modif_p++;
  4527. else {
  4528. if (modif_p[0] == '-' || modif_p[0] == '+')
  4529. modif_p++;
  4530. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4531. modif_p++;
  4532. if (modif_p[0] == 'n') {
  4533. minute = value;
  4534. modif_p++;
  4535. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4536. minute = value;
  4537. modif_p = modif_p + 2;
  4538. } else if (modif_p[0] == 'h') {
  4539. hour = value;
  4540. modif_p++;
  4541. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4542. day = value;
  4543. modif_p++;
  4544. } else if (modif_p[0] == 'm') {
  4545. month = value;
  4546. modif_p++;
  4547. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4548. year = value;
  4549. modif_p++;
  4550. } else if (modif_p[0] != '\0') {
  4551. modif_p++;
  4552. }
  4553. }
  4554. }
  4555. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4556. clif_displaymessage(fd, "Invalid time for jail command.");
  4557. return -1;
  4558. }
  4559. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4560. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4561. return -1;
  4562. }
  4563. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4564. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4565. return -1;
  4566. }
  4567. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4568. if(jailtime==0) {
  4569. clif_displaymessage(fd, "Invalid time for jail command.");
  4570. return -1;
  4571. }
  4572. //Added by Coltaro
  4573. if(pl_sd->sc.data[SC_JAILED] &&
  4574. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4575. { //Update the player's jail time
  4576. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4577. if (jailtime <= 0) {
  4578. jailtime = 0;
  4579. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4580. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4581. } else {
  4582. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4583. 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
  4584. clif_displaymessage(pl_sd->fd, atcmd_output);
  4585. 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
  4586. clif_displaymessage(fd, atcmd_output);
  4587. }
  4588. } else if (jailtime < 0) {
  4589. clif_displaymessage(fd, "Invalid time for jail command.");
  4590. return -1;
  4591. }
  4592. //Jail locations, add more as you wish.
  4593. switch(rnd()%2)
  4594. {
  4595. case 1: //Jail #1
  4596. m_index = mapindex_name2id(MAP_JAIL);
  4597. x = 49; y = 75;
  4598. break;
  4599. default: //Default Jail
  4600. m_index = mapindex_name2id(MAP_JAIL);
  4601. x = 24; y = 75;
  4602. break;
  4603. }
  4604. 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).
  4605. return 0;
  4606. }
  4607. //By Coltaro
  4608. ACMD_FUNC(jailtime)
  4609. {
  4610. int year, month, day, hour, minute;
  4611. nullpo_retr(-1, sd);
  4612. if (!sd->sc.data[SC_JAILED]) {
  4613. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4614. return -1;
  4615. }
  4616. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4617. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4618. return 0;
  4619. }
  4620. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4621. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4622. return -1;
  4623. }
  4624. //Get remaining jail time
  4625. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4626. 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
  4627. clif_displaymessage(fd, atcmd_output);
  4628. return 0;
  4629. }
  4630. /*==========================================
  4631. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4632. *------------------------------------------*/
  4633. ACMD_FUNC(disguise)
  4634. {
  4635. int id = 0;
  4636. nullpo_retr(-1, sd);
  4637. if (!message || !*message) {
  4638. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4639. return -1;
  4640. }
  4641. if ((id = atoi(message)) > 0)
  4642. { //Acquired an ID
  4643. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4644. id = 0; //Invalid id for either mobs or npcs.
  4645. } else { //Acquired a Name
  4646. if ((id = mobdb_searchname(message)) == 0)
  4647. {
  4648. struct npc_data* nd = npc_name2id(message);
  4649. if (nd != NULL)
  4650. id = nd->class_;
  4651. }
  4652. }
  4653. if (id == 0)
  4654. {
  4655. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4656. return -1;
  4657. }
  4658. if(pc_isriding(sd))
  4659. {
  4660. //FIXME: wrong message [ultramage]
  4661. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4662. return -1;
  4663. }
  4664. pc_disguise(sd, id);
  4665. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4666. return 0;
  4667. }
  4668. /*==========================================
  4669. * DisguiseAll
  4670. *------------------------------------------*/
  4671. ACMD_FUNC(disguiseall)
  4672. {
  4673. int mob_id=0;
  4674. struct map_session_data *pl_sd;
  4675. struct s_mapiterator* iter;
  4676. nullpo_retr(-1, sd);
  4677. if (!message || !*message) {
  4678. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4679. return -1;
  4680. }
  4681. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4682. mob_id = atoi(message);
  4683. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4684. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4685. return -1;
  4686. }
  4687. iter = mapit_getallusers();
  4688. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4689. pc_disguise(pl_sd, mob_id);
  4690. mapit_free(iter);
  4691. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4692. return 0;
  4693. }
  4694. /*==========================================
  4695. * @undisguise by [Yor]
  4696. *------------------------------------------*/
  4697. ACMD_FUNC(undisguise)
  4698. {
  4699. nullpo_retr(-1, sd);
  4700. if (sd->disguise) {
  4701. pc_disguise(sd, 0);
  4702. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4703. } else {
  4704. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4705. return -1;
  4706. }
  4707. return 0;
  4708. }
  4709. /*==========================================
  4710. * UndisguiseAll
  4711. *------------------------------------------*/
  4712. ACMD_FUNC(undisguiseall)
  4713. {
  4714. struct map_session_data *pl_sd;
  4715. struct s_mapiterator* iter;
  4716. nullpo_retr(-1, sd);
  4717. iter = mapit_getallusers();
  4718. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4719. if( pl_sd->disguise )
  4720. pc_disguise(pl_sd, 0);
  4721. mapit_free(iter);
  4722. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4723. return 0;
  4724. }
  4725. /*==========================================
  4726. * @exp by [Skotlex]
  4727. *------------------------------------------*/
  4728. ACMD_FUNC(exp)
  4729. {
  4730. char output[CHAT_SIZE_MAX];
  4731. double nextb, nextj;
  4732. nullpo_retr(-1, sd);
  4733. memset(output, '\0', sizeof(output));
  4734. nextb = pc_nextbaseexp(sd);
  4735. if (nextb)
  4736. nextb = sd->status.base_exp*100.0/nextb;
  4737. nextj = pc_nextjobexp(sd);
  4738. if (nextj)
  4739. nextj = sd->status.job_exp*100.0/nextj;
  4740. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4741. clif_displaymessage(fd, output);
  4742. return 0;
  4743. }
  4744. /*==========================================
  4745. * @broadcast by [Valaris]
  4746. *------------------------------------------*/
  4747. ACMD_FUNC(broadcast)
  4748. {
  4749. nullpo_retr(-1, sd);
  4750. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4751. if (!message || !*message) {
  4752. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4753. return -1;
  4754. }
  4755. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4756. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4757. return 0;
  4758. }
  4759. /*==========================================
  4760. * @localbroadcast by [Valaris]
  4761. *------------------------------------------*/
  4762. ACMD_FUNC(localbroadcast)
  4763. {
  4764. nullpo_retr(-1, sd);
  4765. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4766. if (!message || !*message) {
  4767. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4768. return -1;
  4769. }
  4770. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4771. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4772. return 0;
  4773. }
  4774. /*==========================================
  4775. * @email <actual@email> <new@email> by [Yor]
  4776. *------------------------------------------*/
  4777. ACMD_FUNC(email)
  4778. {
  4779. char actual_email[100];
  4780. char new_email[100];
  4781. nullpo_retr(-1, sd);
  4782. memset(actual_email, '\0', sizeof(actual_email));
  4783. memset(new_email, '\0', sizeof(new_email));
  4784. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4785. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4786. return -1;
  4787. }
  4788. if (e_mail_check(actual_email) == 0) {
  4789. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4790. return -1;
  4791. } else if (e_mail_check(new_email) == 0) {
  4792. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4793. return -1;
  4794. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4795. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4796. return -1;
  4797. } else if (strcmpi(actual_email, new_email) == 0) {
  4798. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4799. return -1;
  4800. }
  4801. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4802. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4803. return 0;
  4804. }
  4805. /*==========================================
  4806. *@effect
  4807. *------------------------------------------*/
  4808. ACMD_FUNC(effect)
  4809. {
  4810. int type = 0, flag = 0;
  4811. nullpo_retr(-1, sd);
  4812. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4813. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4814. return -1;
  4815. }
  4816. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4817. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4818. return 0;
  4819. }
  4820. /*==========================================
  4821. * @killer by MouseJstr
  4822. * enable killing players even when not in pvp
  4823. *------------------------------------------*/
  4824. ACMD_FUNC(killer)
  4825. {
  4826. nullpo_retr(-1, sd);
  4827. sd->state.killer = !sd->state.killer;
  4828. if(sd->state.killer)
  4829. clif_displaymessage(fd, msg_txt(241));
  4830. else {
  4831. clif_displaymessage(fd, msg_txt(287));
  4832. pc_stop_attack(sd);
  4833. }
  4834. return 0;
  4835. }
  4836. /*==========================================
  4837. * @killable by MouseJstr
  4838. * enable other people killing you
  4839. *------------------------------------------*/
  4840. ACMD_FUNC(killable)
  4841. {
  4842. nullpo_retr(-1, sd);
  4843. sd->state.killable = !sd->state.killable;
  4844. if(sd->state.killable)
  4845. clif_displaymessage(fd, msg_txt(242));
  4846. else {
  4847. clif_displaymessage(fd, msg_txt(288));
  4848. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4849. }
  4850. return 0;
  4851. }
  4852. /*==========================================
  4853. * @skillon by MouseJstr
  4854. * turn skills on for the map
  4855. *------------------------------------------*/
  4856. ACMD_FUNC(skillon)
  4857. {
  4858. nullpo_retr(-1, sd);
  4859. map[sd->bl.m].flag.noskill = 0;
  4860. clif_displaymessage(fd, msg_txt(244));
  4861. return 0;
  4862. }
  4863. /*==========================================
  4864. * @skilloff by MouseJstr
  4865. * Turn skills off on the map
  4866. *------------------------------------------*/
  4867. ACMD_FUNC(skilloff)
  4868. {
  4869. nullpo_retr(-1, sd);
  4870. map[sd->bl.m].flag.noskill = 1;
  4871. clif_displaymessage(fd, msg_txt(243));
  4872. return 0;
  4873. }
  4874. /*==========================================
  4875. * @npcmove by MouseJstr
  4876. * move a npc
  4877. *------------------------------------------*/
  4878. ACMD_FUNC(npcmove)
  4879. {
  4880. int x = 0, y = 0, m;
  4881. struct npc_data *nd = 0;
  4882. nullpo_retr(-1, sd);
  4883. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4884. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4885. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4886. return -1;
  4887. }
  4888. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4889. {
  4890. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4891. return -1;
  4892. }
  4893. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4894. {
  4895. clif_displaymessage(fd, "NPC is not on this map.");
  4896. return -1; //Not on a map.
  4897. }
  4898. x = cap_value(x, 0, map[m].xs-1);
  4899. y = cap_value(y, 0, map[m].ys-1);
  4900. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4901. map_moveblock(&nd->bl, x, y, gettick());
  4902. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4903. clif_displaymessage(fd, "NPC moved.");
  4904. return 0;
  4905. }
  4906. /*==========================================
  4907. * @addwarp by MouseJstr
  4908. * Create a new static warp point.
  4909. *------------------------------------------*/
  4910. ACMD_FUNC(addwarp)
  4911. {
  4912. char mapname[32];
  4913. int x,y;
  4914. unsigned short m;
  4915. struct npc_data* nd;
  4916. nullpo_retr(-1, sd);
  4917. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4918. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4919. return -1;
  4920. }
  4921. m = mapindex_name2id(mapname);
  4922. if( m == 0 )
  4923. {
  4924. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4925. clif_displaymessage(fd, atcmd_output);
  4926. return -1;
  4927. }
  4928. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4929. if( nd == NULL )
  4930. return -1;
  4931. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4932. clif_displaymessage(fd, atcmd_output);
  4933. return 0;
  4934. }
  4935. /*==========================================
  4936. * @follow by [MouseJstr]
  4937. * Follow a player .. staying no more then 5 spaces away
  4938. *------------------------------------------*/
  4939. ACMD_FUNC(follow)
  4940. {
  4941. struct map_session_data *pl_sd = NULL;
  4942. nullpo_retr(-1, sd);
  4943. if (!message || !*message) {
  4944. if (sd->followtarget == -1)
  4945. return -1;
  4946. pc_stop_following (sd);
  4947. clif_displaymessage(fd, "Follow mode OFF.");
  4948. return 0;
  4949. }
  4950. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4951. {
  4952. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4953. return -1;
  4954. }
  4955. if (sd->followtarget == pl_sd->bl.id) {
  4956. pc_stop_following (sd);
  4957. clif_displaymessage(fd, "Follow mode OFF.");
  4958. } else {
  4959. pc_follow(sd, pl_sd->bl.id);
  4960. clif_displaymessage(fd, "Follow mode ON.");
  4961. }
  4962. return 0;
  4963. }
  4964. /*==========================================
  4965. * @dropall by [MouseJstr]
  4966. * Drop all your possession on the ground
  4967. *------------------------------------------*/
  4968. ACMD_FUNC(dropall)
  4969. {
  4970. int i;
  4971. nullpo_retr(-1, sd);
  4972. for (i = 0; i < MAX_INVENTORY; i++) {
  4973. if (sd->status.inventory[i].amount) {
  4974. if(sd->status.inventory[i].equip != 0)
  4975. pc_unequipitem(sd, i, 3);
  4976. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4977. }
  4978. }
  4979. return 0;
  4980. }
  4981. /*==========================================
  4982. * @storeall by [MouseJstr]
  4983. * Put everything into storage
  4984. *------------------------------------------*/
  4985. ACMD_FUNC(storeall)
  4986. {
  4987. int i;
  4988. nullpo_retr(-1, sd);
  4989. if (sd->state.storage_flag != 1)
  4990. { //Open storage.
  4991. if( storage_storageopen(sd) == 1 ) {
  4992. clif_displaymessage(fd, "You can't open the storage currently.");
  4993. return -1;
  4994. }
  4995. }
  4996. for (i = 0; i < MAX_INVENTORY; i++) {
  4997. if (sd->status.inventory[i].amount) {
  4998. if(sd->status.inventory[i].equip != 0)
  4999. pc_unequipitem(sd, i, 3);
  5000. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  5001. }
  5002. }
  5003. storage_storageclose(sd);
  5004. clif_displaymessage(fd, "It is done");
  5005. return 0;
  5006. }
  5007. /*==========================================
  5008. * @skillid by [MouseJstr]
  5009. * lookup a skill by name
  5010. *------------------------------------------*/
  5011. ACMD_FUNC(skillid)
  5012. {
  5013. int skillen, idx;
  5014. nullpo_retr(-1, sd);
  5015. if (!message || !*message)
  5016. {
  5017. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  5018. return -1;
  5019. }
  5020. skillen = strlen(message);
  5021. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  5022. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  5023. {
  5024. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5025. clif_displaymessage(fd, atcmd_output);
  5026. }
  5027. }
  5028. return 0;
  5029. }
  5030. /*==========================================
  5031. * @useskill by [MouseJstr]
  5032. * A way of using skills without having to find them in the skills menu
  5033. *------------------------------------------*/
  5034. ACMD_FUNC(useskill)
  5035. {
  5036. struct map_session_data *pl_sd = NULL;
  5037. struct block_list *bl;
  5038. int skillnum;
  5039. int skilllv;
  5040. char target[100];
  5041. nullpo_retr(-1, sd);
  5042. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5043. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5044. return -1;
  5045. }
  5046. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5047. {
  5048. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5049. return -1;
  5050. }
  5051. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5052. {
  5053. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5054. return -1;
  5055. }
  5056. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  5057. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5058. bl = &sd->hd->bl;
  5059. else
  5060. bl = &sd->bl;
  5061. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5062. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5063. else
  5064. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5065. return 0;
  5066. }
  5067. /*==========================================
  5068. * @displayskill by [Skotlex]
  5069. * Debug command to locate new skill IDs. It sends the
  5070. * three possible skill-effect packets to the area.
  5071. *------------------------------------------*/
  5072. ACMD_FUNC(displayskill)
  5073. {
  5074. struct status_data * status;
  5075. unsigned int tick;
  5076. int skillnum;
  5077. int skilllv = 1;
  5078. nullpo_retr(-1, sd);
  5079. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5080. {
  5081. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5082. return -1;
  5083. }
  5084. status = status_get_status_data(&sd->bl);
  5085. tick = gettick();
  5086. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  5087. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5088. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5089. return 0;
  5090. }
  5091. /*==========================================
  5092. * @skilltree by [MouseJstr]
  5093. * prints the skill tree for a player required to get to a skill
  5094. *------------------------------------------*/
  5095. ACMD_FUNC(skilltree)
  5096. {
  5097. struct map_session_data *pl_sd = NULL;
  5098. int skillnum;
  5099. int meets, j, c=0;
  5100. char target[NAME_LENGTH];
  5101. struct skill_tree_entry *ent;
  5102. nullpo_retr(-1, sd);
  5103. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5104. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5105. return -1;
  5106. }
  5107. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5108. {
  5109. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5110. return -1;
  5111. }
  5112. c = pc_calc_skilltree_normalize_job(pl_sd);
  5113. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5114. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, 1));
  5115. clif_displaymessage(fd, atcmd_output);
  5116. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  5117. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5118. {
  5119. sprintf(atcmd_output, "I do not believe the player can use that skill");
  5120. clif_displaymessage(fd, atcmd_output);
  5121. return 0;
  5122. }
  5123. ent = &skill_tree[c][j];
  5124. meets = 1;
  5125. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5126. {
  5127. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5128. {
  5129. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  5130. clif_displaymessage(fd, atcmd_output);
  5131. meets = 0;
  5132. }
  5133. }
  5134. if (meets == 1) {
  5135. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5136. clif_displaymessage(fd, atcmd_output);
  5137. }
  5138. return 0;
  5139. }
  5140. // Hand a ring with partners name on it to this char
  5141. void getring (struct map_session_data* sd)
  5142. {
  5143. int flag, item_id;
  5144. struct item item_tmp;
  5145. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5146. memset(&item_tmp, 0, sizeof(item_tmp));
  5147. item_tmp.nameid = item_id;
  5148. item_tmp.identify = 1;
  5149. item_tmp.card[0] = 255;
  5150. item_tmp.card[2] = sd->status.partner_id;
  5151. item_tmp.card[3] = sd->status.partner_id >> 16;
  5152. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5153. clif_additem(sd,0,0,flag);
  5154. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5155. }
  5156. }
  5157. /*==========================================
  5158. * @marry by [MouseJstr], fixed by Lupus
  5159. * Marry two players
  5160. *------------------------------------------*/
  5161. ACMD_FUNC(marry)
  5162. {
  5163. struct map_session_data *pl_sd1 = NULL;
  5164. struct map_session_data *pl_sd2 = NULL;
  5165. char player1[128], player2[128]; //Length used for return error msgs
  5166. nullpo_retr(-1, sd);
  5167. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5168. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5169. return -1;
  5170. }
  5171. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5172. sprintf(player2, "Cannot find player '%s' online", player1);
  5173. clif_displaymessage(fd, player2);
  5174. return -1;
  5175. }
  5176. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5177. sprintf(player1, "Cannot find player '%s' online", player2);
  5178. clif_displaymessage(fd, player1);
  5179. return -1;
  5180. }
  5181. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5182. clif_displaymessage(fd, "They are married.. wish them well");
  5183. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5184. // Auto-give named rings (Aru)
  5185. getring (pl_sd1);
  5186. getring (pl_sd2);
  5187. return 0;
  5188. }
  5189. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5190. return -1;
  5191. }
  5192. /*==========================================
  5193. * @divorce by [MouseJstr], fixed by [Lupus]
  5194. * divorce two players
  5195. *------------------------------------------*/
  5196. ACMD_FUNC(divorce)
  5197. {
  5198. struct map_session_data *pl_sd = NULL;
  5199. nullpo_retr(-1, sd);
  5200. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5201. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5202. return -1;
  5203. }
  5204. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5205. {
  5206. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5207. return -1;
  5208. }
  5209. if (pc_divorce(pl_sd) != 0) {
  5210. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5211. clif_displaymessage(fd, atcmd_output);
  5212. return -1;
  5213. }
  5214. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5215. clif_displaymessage(fd, atcmd_output);
  5216. return 0;
  5217. }
  5218. /*==========================================
  5219. * @changelook by [Celest]
  5220. *------------------------------------------*/
  5221. ACMD_FUNC(changelook)
  5222. {
  5223. int i, j = 0, k = 0;
  5224. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5225. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5226. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5227. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5228. return -1;
  5229. } else if (i == 2) {
  5230. if (j < 1) j = 1;
  5231. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5232. j = pos[j - 1];
  5233. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5234. k = j; // swap
  5235. j = LOOK_HEAD_TOP;
  5236. }
  5237. clif_changelook(&sd->bl,j,k);
  5238. return 0;
  5239. }
  5240. /*==========================================
  5241. * @autotrade by durf [Lupus] [Paradox924X]
  5242. * Turns on/off Autotrade for a specific player
  5243. *------------------------------------------*/
  5244. ACMD_FUNC(autotrade)
  5245. {
  5246. nullpo_retr(-1, sd);
  5247. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5248. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5249. return -1;
  5250. }
  5251. if( pc_isdead(sd) ) {
  5252. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  5253. return -1;
  5254. }
  5255. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5256. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  5257. return -1;
  5258. }
  5259. sd->state.autotrade = 1;
  5260. if( battle_config.at_timeout )
  5261. {
  5262. int timeout = atoi(message);
  5263. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  5264. }
  5265. clif_authfail_fd(fd, 15);
  5266. return 0;
  5267. }
  5268. /*==========================================
  5269. * @changegm by durf (changed by Lupus)
  5270. * Changes Master of your Guild to a specified guild member
  5271. *------------------------------------------*/
  5272. ACMD_FUNC(changegm)
  5273. {
  5274. struct guild *g;
  5275. struct map_session_data *pl_sd;
  5276. nullpo_retr(-1, sd);
  5277. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5278. {
  5279. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5280. return -1;
  5281. }
  5282. if( map[sd->bl.m].flag.guildlock )
  5283. {
  5284. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5285. return -1;
  5286. }
  5287. if( !message[0] )
  5288. {
  5289. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5290. return -1;
  5291. }
  5292. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5293. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5294. return -1;
  5295. }
  5296. guild_gm_change(sd->status.guild_id, pl_sd);
  5297. return 0;
  5298. }
  5299. /*==========================================
  5300. * @changeleader by Skotlex
  5301. * Changes the leader of a party.
  5302. *------------------------------------------*/
  5303. ACMD_FUNC(changeleader)
  5304. {
  5305. nullpo_retr(-1, sd);
  5306. if( !message[0] )
  5307. {
  5308. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5309. return -1;
  5310. }
  5311. if (party_changeleader(sd, map_nick2sd((char *) message)))
  5312. return 0;
  5313. return -1;
  5314. }
  5315. /*==========================================
  5316. * @partyoption by Skotlex
  5317. * Used to change the item share setting of a party.
  5318. *------------------------------------------*/
  5319. ACMD_FUNC(partyoption)
  5320. {
  5321. struct party_data *p;
  5322. int mi, option;
  5323. char w1[16], w2[16];
  5324. nullpo_retr(-1, sd);
  5325. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5326. {
  5327. clif_displaymessage(fd, msg_txt(282));
  5328. return -1;
  5329. }
  5330. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5331. if (mi == MAX_PARTY)
  5332. return -1; //Shouldn't happen
  5333. if (!p->party.member[mi].leader)
  5334. {
  5335. clif_displaymessage(fd, msg_txt(282));
  5336. return -1;
  5337. }
  5338. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5339. {
  5340. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5341. return -1;
  5342. }
  5343. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5344. //Change item share type.
  5345. if (option != p->party.item)
  5346. party_changeoption(sd, p->party.exp, option);
  5347. else
  5348. clif_displaymessage(fd, msg_txt(286));
  5349. return 0;
  5350. }
  5351. /*==========================================
  5352. * @autoloot by Upa-Kun
  5353. * Turns on/off AutoLoot for a specific player
  5354. *------------------------------------------*/
  5355. ACMD_FUNC(autoloot)
  5356. {
  5357. int rate;
  5358. double drate;
  5359. nullpo_retr(-1, sd);
  5360. // autoloot command without value
  5361. if(!message || !*message)
  5362. {
  5363. if (sd->state.autoloot)
  5364. rate = 0;
  5365. else
  5366. rate = 10000;
  5367. } else {
  5368. drate = atof(message);
  5369. rate = (int)(drate*100);
  5370. }
  5371. if (rate < 0) rate = 0;
  5372. if (rate > 10000) rate = 10000;
  5373. sd->state.autoloot = rate;
  5374. if (sd->state.autoloot) {
  5375. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5376. clif_displaymessage(fd, atcmd_output);
  5377. }else
  5378. clif_displaymessage(fd, "Autoloot is now off.");
  5379. return 0;
  5380. }
  5381. /*==========================================
  5382. * @alootid
  5383. *------------------------------------------*/
  5384. ACMD_FUNC(autolootitem)
  5385. {
  5386. struct item_data *item_data = NULL;
  5387. int i;
  5388. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5389. if (message && *message) {
  5390. if (message[0] == '+') {
  5391. message++;
  5392. action = 1;
  5393. }
  5394. else if (message[0] == '-') {
  5395. message++;
  5396. action = 2;
  5397. }
  5398. else if (!strcmp(message,"reset"))
  5399. action = 4;
  5400. }
  5401. if (action < 3) // add or remove
  5402. {
  5403. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5404. item_data = itemdb_searchname(message);
  5405. if (!item_data) {
  5406. // No items founds in the DB with Id or Name
  5407. clif_displaymessage(fd, "Item not found.");
  5408. return -1;
  5409. }
  5410. }
  5411. switch(action) {
  5412. case 1:
  5413. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5414. if (i != AUTOLOOTITEM_SIZE) {
  5415. clif_displaymessage(fd, "You're already autolooting this item.");
  5416. return -1;
  5417. }
  5418. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5419. if (i == AUTOLOOTITEM_SIZE) {
  5420. clif_displaymessage(fd, "Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.");
  5421. return -1;
  5422. }
  5423. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5424. sprintf(atcmd_output, "Autolooting item: '%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5425. clif_displaymessage(fd, atcmd_output);
  5426. sd->state.autolooting = 1;
  5427. break;
  5428. case 2:
  5429. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5430. if (i == AUTOLOOTITEM_SIZE) {
  5431. clif_displaymessage(fd, "You're currently not autolooting this item.");
  5432. return -1;
  5433. }
  5434. sd->state.autolootid[i] = 0;
  5435. sprintf(atcmd_output, "Removed item: '%s'/'%s' {%d} from your autolootitem list.", item_data->name, item_data->jname, item_data->nameid);
  5436. clif_displaymessage(fd, atcmd_output);
  5437. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5438. if (i == AUTOLOOTITEM_SIZE) {
  5439. sd->state.autolooting = 0;
  5440. }
  5441. break;
  5442. case 3:
  5443. sprintf(atcmd_output, "You can have %d items on your autolootitem list.", AUTOLOOTITEM_SIZE);
  5444. clif_displaymessage(fd, atcmd_output);
  5445. clif_displaymessage(fd, "To add item to the list, use \"@alootid +<item name or ID>\". To remove item use \"@alootid -<item name or ID>\".");
  5446. clif_displaymessage(fd, "\"@alootid reset\" will clear your autolootitem list.");
  5447. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5448. if (i == AUTOLOOTITEM_SIZE) {
  5449. clif_displaymessage(fd, "Your autolootitem list is empty.");
  5450. } else {
  5451. clif_displaymessage(fd, "Items on your autolootitem list:");
  5452. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5453. {
  5454. if (sd->state.autolootid[i] == 0)
  5455. continue;
  5456. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5457. ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
  5458. continue;
  5459. }
  5460. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5461. clif_displaymessage(fd, atcmd_output);
  5462. }
  5463. }
  5464. break;
  5465. case 4:
  5466. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5467. clif_displaymessage(fd, "Your autolootitem list has been reset.");
  5468. sd->state.autolooting = 0;
  5469. break;
  5470. }
  5471. return 0;
  5472. }
  5473. /**
  5474. * No longer available, keeping here just in case it's back someday. [Ind]
  5475. **/
  5476. /*==========================================
  5477. * It is made to rain.
  5478. *------------------------------------------*/
  5479. //ACMD_FUNC(rain)
  5480. //{
  5481. // nullpo_retr(-1, sd);
  5482. // if (map[sd->bl.m].flag.rain) {
  5483. // map[sd->bl.m].flag.rain=0;
  5484. // clif_weather(sd->bl.m);
  5485. // clif_displaymessage(fd, "The rain has stopped.");
  5486. // } else {
  5487. // map[sd->bl.m].flag.rain=1;
  5488. // clif_weather(sd->bl.m);
  5489. // clif_displaymessage(fd, "It is made to rain.");
  5490. // }
  5491. // return 0;
  5492. //}
  5493. /*==========================================
  5494. * It is made to snow.
  5495. *------------------------------------------*/
  5496. ACMD_FUNC(snow)
  5497. {
  5498. nullpo_retr(-1, sd);
  5499. if (map[sd->bl.m].flag.snow) {
  5500. map[sd->bl.m].flag.snow=0;
  5501. clif_weather(sd->bl.m);
  5502. clif_displaymessage(fd, "Snow has stopped falling.");
  5503. } else {
  5504. map[sd->bl.m].flag.snow=1;
  5505. clif_weather(sd->bl.m);
  5506. clif_displaymessage(fd, "It is made to snow.");
  5507. }
  5508. return 0;
  5509. }
  5510. /*==========================================
  5511. * Cherry tree snowstorm is made to fall. (Sakura)
  5512. *------------------------------------------*/
  5513. ACMD_FUNC(sakura)
  5514. {
  5515. nullpo_retr(-1, sd);
  5516. if (map[sd->bl.m].flag.sakura) {
  5517. map[sd->bl.m].flag.sakura=0;
  5518. clif_weather(sd->bl.m);
  5519. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5520. } else {
  5521. map[sd->bl.m].flag.sakura=1;
  5522. clif_weather(sd->bl.m);
  5523. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5524. }
  5525. return 0;
  5526. }
  5527. /*==========================================
  5528. * Clouds appear.
  5529. *------------------------------------------*/
  5530. ACMD_FUNC(clouds)
  5531. {
  5532. nullpo_retr(-1, sd);
  5533. if (map[sd->bl.m].flag.clouds) {
  5534. map[sd->bl.m].flag.clouds=0;
  5535. clif_weather(sd->bl.m);
  5536. clif_displaymessage(fd, "The clouds has disappear.");
  5537. } else {
  5538. map[sd->bl.m].flag.clouds=1;
  5539. clif_weather(sd->bl.m);
  5540. clif_displaymessage(fd, "Clouds appear.");
  5541. }
  5542. return 0;
  5543. }
  5544. /*==========================================
  5545. * Different type of clouds using effect 516
  5546. *------------------------------------------*/
  5547. ACMD_FUNC(clouds2)
  5548. {
  5549. nullpo_retr(-1, sd);
  5550. if (map[sd->bl.m].flag.clouds2) {
  5551. map[sd->bl.m].flag.clouds2=0;
  5552. clif_weather(sd->bl.m);
  5553. clif_displaymessage(fd, "The alternative clouds disappear.");
  5554. } else {
  5555. map[sd->bl.m].flag.clouds2=1;
  5556. clif_weather(sd->bl.m);
  5557. clif_displaymessage(fd, "Alternative clouds appear.");
  5558. }
  5559. return 0;
  5560. }
  5561. /*==========================================
  5562. * Fog hangs over.
  5563. *------------------------------------------*/
  5564. ACMD_FUNC(fog)
  5565. {
  5566. nullpo_retr(-1, sd);
  5567. if (map[sd->bl.m].flag.fog) {
  5568. map[sd->bl.m].flag.fog=0;
  5569. clif_weather(sd->bl.m);
  5570. clif_displaymessage(fd, "The fog has gone.");
  5571. } else {
  5572. map[sd->bl.m].flag.fog=1;
  5573. clif_weather(sd->bl.m);
  5574. clif_displaymessage(fd, "Fog hangs over.");
  5575. }
  5576. return 0;
  5577. }
  5578. /*==========================================
  5579. * Fallen leaves fall.
  5580. *------------------------------------------*/
  5581. ACMD_FUNC(leaves)
  5582. {
  5583. nullpo_retr(-1, sd);
  5584. if (map[sd->bl.m].flag.leaves) {
  5585. map[sd->bl.m].flag.leaves=0;
  5586. clif_weather(sd->bl.m);
  5587. clif_displaymessage(fd, "Leaves no longer fall.");
  5588. } else {
  5589. map[sd->bl.m].flag.leaves=1;
  5590. clif_weather(sd->bl.m);
  5591. clif_displaymessage(fd, "Fallen leaves fall.");
  5592. }
  5593. return 0;
  5594. }
  5595. /*==========================================
  5596. * Fireworks appear.
  5597. *------------------------------------------*/
  5598. ACMD_FUNC(fireworks)
  5599. {
  5600. nullpo_retr(-1, sd);
  5601. if (map[sd->bl.m].flag.fireworks) {
  5602. map[sd->bl.m].flag.fireworks=0;
  5603. clif_weather(sd->bl.m);
  5604. clif_displaymessage(fd, "Fireworks are ended.");
  5605. } else {
  5606. map[sd->bl.m].flag.fireworks=1;
  5607. clif_weather(sd->bl.m);
  5608. clif_displaymessage(fd, "Fireworks are launched.");
  5609. }
  5610. return 0;
  5611. }
  5612. /*==========================================
  5613. * Clearing Weather Effects by Dexity
  5614. *------------------------------------------*/
  5615. ACMD_FUNC(clearweather)
  5616. {
  5617. nullpo_retr(-1, sd);
  5618. /**
  5619. * No longer available, keeping here just in case it's back someday. [Ind]
  5620. **/
  5621. //map[sd->bl.m].flag.rain=0;
  5622. map[sd->bl.m].flag.snow=0;
  5623. map[sd->bl.m].flag.sakura=0;
  5624. map[sd->bl.m].flag.clouds=0;
  5625. map[sd->bl.m].flag.clouds2=0;
  5626. map[sd->bl.m].flag.fog=0;
  5627. map[sd->bl.m].flag.fireworks=0;
  5628. map[sd->bl.m].flag.leaves=0;
  5629. clif_weather(sd->bl.m);
  5630. clif_displaymessage(fd, msg_txt(291));
  5631. return 0;
  5632. }
  5633. /*===============================================================
  5634. * Sound Command - plays a sound for everyone around! [Codemaster]
  5635. *---------------------------------------------------------------*/
  5636. ACMD_FUNC(sound)
  5637. {
  5638. char sound_file[100];
  5639. memset(sound_file, '\0', sizeof(sound_file));
  5640. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5641. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5642. return -1;
  5643. }
  5644. if(strstr(sound_file, ".wav") == NULL)
  5645. strcat(sound_file, ".wav");
  5646. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5647. return 0;
  5648. }
  5649. /*==========================================
  5650. * MOB Search
  5651. *------------------------------------------*/
  5652. ACMD_FUNC(mobsearch)
  5653. {
  5654. char mob_name[100];
  5655. int mob_id;
  5656. int number = 0;
  5657. struct s_mapiterator* it;
  5658. nullpo_retr(-1, sd);
  5659. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5660. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5661. return -1;
  5662. }
  5663. if ((mob_id = atoi(mob_name)) == 0)
  5664. mob_id = mobdb_searchname(mob_name);
  5665. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5666. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5667. clif_displaymessage(fd, atcmd_output);
  5668. return -1;
  5669. }
  5670. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5671. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5672. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5673. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5674. clif_displaymessage(fd, atcmd_output);
  5675. it = mapit_geteachmob();
  5676. for(;;)
  5677. {
  5678. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5679. if( md == NULL )
  5680. break;// no more mobs
  5681. if( md->bl.m != sd->bl.m )
  5682. continue;
  5683. if( mob_id != -1 && md->class_ != mob_id )
  5684. continue;
  5685. ++number;
  5686. if( md->spawn_timer == INVALID_TIMER )
  5687. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5688. else
  5689. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5690. clif_displaymessage(fd, atcmd_output);
  5691. }
  5692. mapit_free(it);
  5693. return 0;
  5694. }
  5695. /*==========================================
  5696. * @cleanmap - cleans items on the ground
  5697. *------------------------------------------*/
  5698. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5699. {
  5700. nullpo_ret(bl);
  5701. map_clearflooritem(bl->id);
  5702. return 0;
  5703. }
  5704. ACMD_FUNC(cleanmap)
  5705. {
  5706. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5707. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5708. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5709. BL_ITEM);
  5710. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5711. return 0;
  5712. }
  5713. /*==========================================
  5714. * make a NPC/PET talk
  5715. * @npctalkc [SnakeDrak]
  5716. *------------------------------------------*/
  5717. ACMD_FUNC(npctalk)
  5718. {
  5719. char name[NAME_LENGTH],mes[100],temp[100];
  5720. struct npc_data *nd;
  5721. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5722. unsigned long color=0;
  5723. if (sd->sc.count && //no "chatting" while muted.
  5724. (sd->sc.data[SC_BERSERK] ||
  5725. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5726. return -1;
  5727. if(!ifcolor) {
  5728. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5729. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5730. return -1;
  5731. }
  5732. }
  5733. else {
  5734. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5735. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  5736. return -1;
  5737. }
  5738. }
  5739. if (!(nd = npc_name2id(name))) {
  5740. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5741. return -1;
  5742. }
  5743. strtok(name, "#"); // discard extra name identifier if present
  5744. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5745. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5746. else clif_message(&nd->bl, temp);
  5747. return 0;
  5748. }
  5749. ACMD_FUNC(pettalk)
  5750. {
  5751. char mes[100],temp[100];
  5752. struct pet_data *pd;
  5753. nullpo_retr(-1, sd);
  5754. if(!sd->status.pet_id || !(pd=sd->pd))
  5755. {
  5756. clif_displaymessage(fd, msg_txt(184));
  5757. return -1;
  5758. }
  5759. if (sd->sc.count && //no "chatting" while muted.
  5760. (sd->sc.data[SC_BERSERK] ||
  5761. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5762. return -1;
  5763. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5764. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5765. return -1;
  5766. }
  5767. if (message[0] == '/')
  5768. {// pet emotion processing
  5769. const char* emo[] = {
  5770. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5771. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5772. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5773. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5774. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5775. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5776. };
  5777. int i;
  5778. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5779. if( i < ARRAYLENGTH(emo) )
  5780. {
  5781. clif_emotion(&pd->bl, i);
  5782. return 0;
  5783. }
  5784. }
  5785. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5786. clif_message(&pd->bl, temp);
  5787. return 0;
  5788. }
  5789. /// @users - displays the number of players present on each map (and percentage)
  5790. /// #users displays on the target user instead of self
  5791. ACMD_FUNC(users)
  5792. {
  5793. char buf[CHAT_SIZE_MAX];
  5794. int i;
  5795. int users[MAX_MAPINDEX];
  5796. int users_all;
  5797. struct s_mapiterator* iter;
  5798. memset(users, 0, sizeof(users));
  5799. users_all = 0;
  5800. // count users on each map
  5801. iter = mapit_getallusers();
  5802. for(;;)
  5803. {
  5804. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5805. if( sd2 == NULL )
  5806. break;// no more users
  5807. if( sd2->mapindex >= MAX_MAPINDEX )
  5808. continue;// invalid mapindex
  5809. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5810. if( users_all < INT_MAX ) ++users_all;
  5811. }
  5812. mapit_free(iter);
  5813. // display results for each map
  5814. for( i = 0; i < MAX_MAPINDEX; ++i )
  5815. {
  5816. if( users[i] == 0 )
  5817. continue;// empty
  5818. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5819. clif_displaymessage(sd->fd, buf);
  5820. }
  5821. // display overall count
  5822. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5823. clif_displaymessage(sd->fd, buf);
  5824. return 0;
  5825. }
  5826. /*==========================================
  5827. *
  5828. *------------------------------------------*/
  5829. ACMD_FUNC(reset)
  5830. {
  5831. pc_resetstate(sd);
  5832. pc_resetskill(sd,1);
  5833. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5834. clif_displaymessage(fd, atcmd_output);
  5835. return 0;
  5836. }
  5837. /*==========================================
  5838. *
  5839. *------------------------------------------*/
  5840. ACMD_FUNC(summon)
  5841. {
  5842. char name[NAME_LENGTH];
  5843. int mob_id = 0;
  5844. int duration = 0;
  5845. struct mob_data *md;
  5846. unsigned int tick=gettick();
  5847. nullpo_retr(-1, sd);
  5848. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5849. {
  5850. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5851. return -1;
  5852. }
  5853. if (duration < 1)
  5854. duration =1;
  5855. else if (duration > 60)
  5856. duration =60;
  5857. if ((mob_id = atoi(name)) == 0)
  5858. mob_id = mobdb_searchname(name);
  5859. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5860. {
  5861. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5862. return -1;
  5863. }
  5864. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5865. if(!md)
  5866. return -1;
  5867. md->master_id=sd->bl.id;
  5868. md->special_state.ai=1;
  5869. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5870. clif_specialeffect(&md->bl,344,AREA);
  5871. mob_spawn(md);
  5872. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5873. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5874. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5875. return 0;
  5876. }
  5877. /*==========================================
  5878. * @adjcmdlvl by [MouseJstr]
  5879. *
  5880. * Temp adjust the GM level required to use a GM command
  5881. * Useful during beta testing to allow players to use GM commands for short periods of time
  5882. *------------------------------------------*/
  5883. ACMD_FUNC(adjcmdlvl)
  5884. {
  5885. int newlev, newremotelev;
  5886. char name[100];
  5887. AtCommandInfo* cmd;
  5888. nullpo_retr(-1, sd);
  5889. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  5890. {
  5891. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  5892. return -1;
  5893. }
  5894. cmd = get_atcommandinfo_byname(name);
  5895. if (cmd == NULL)
  5896. {
  5897. clif_displaymessage(fd, "@command not found.");
  5898. return -1;
  5899. }
  5900. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  5901. {
  5902. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5903. return -1;
  5904. }
  5905. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  5906. {
  5907. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5908. return -1;
  5909. }
  5910. else
  5911. {
  5912. cmd->level = newlev;
  5913. cmd->level2 = newremotelev;
  5914. clif_displaymessage(fd, "@command level changed.");
  5915. return 0;
  5916. }
  5917. }
  5918. /*==========================================
  5919. * @adjgmlvl by [MouseJstr]
  5920. * Create a temp GM
  5921. * Useful during beta testing to allow players to use GM commands for short periods of time
  5922. *------------------------------------------*/
  5923. ACMD_FUNC(adjgmlvl)
  5924. {
  5925. int newlev;
  5926. char user[NAME_LENGTH];
  5927. struct map_session_data *pl_sd;
  5928. nullpo_retr(-1, sd);
  5929. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5930. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5931. return -1;
  5932. }
  5933. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5934. {
  5935. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5936. return -1;
  5937. }
  5938. pl_sd->gmlevel = newlev;
  5939. return 0;
  5940. }
  5941. /*==========================================
  5942. * @trade by [MouseJstr]
  5943. * Open a trade window with a remote player
  5944. *------------------------------------------*/
  5945. ACMD_FUNC(trade)
  5946. {
  5947. struct map_session_data *pl_sd = NULL;
  5948. nullpo_retr(-1, sd);
  5949. if (!message || !*message) {
  5950. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5951. return -1;
  5952. }
  5953. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5954. {
  5955. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5956. return -1;
  5957. }
  5958. trade_traderequest(sd, pl_sd);
  5959. return 0;
  5960. }
  5961. /*==========================================
  5962. * @setbattleflag by [MouseJstr]
  5963. * set a battle_config flag without having to reboot
  5964. *------------------------------------------*/
  5965. ACMD_FUNC(setbattleflag)
  5966. {
  5967. char flag[128], value[128];
  5968. nullpo_retr(-1, sd);
  5969. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5970. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5971. return -1;
  5972. }
  5973. if (battle_set_value(flag, value) == 0)
  5974. {
  5975. clif_displaymessage(fd, "unknown battle_config flag");
  5976. return -1;
  5977. }
  5978. clif_displaymessage(fd, "battle_config set as requested");
  5979. return 0;
  5980. }
  5981. /*==========================================
  5982. * @unmute [Valaris]
  5983. *------------------------------------------*/
  5984. ACMD_FUNC(unmute)
  5985. {
  5986. struct map_session_data *pl_sd = NULL;
  5987. nullpo_retr(-1, sd);
  5988. if (!message || !*message) {
  5989. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5990. return -1;
  5991. }
  5992. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5993. {
  5994. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5995. return -1;
  5996. }
  5997. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5998. clif_displaymessage(sd->fd,"Player is not muted");
  5999. return -1;
  6000. }
  6001. pl_sd->status.manner = 0;
  6002. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6003. clif_displaymessage(sd->fd,"Player unmuted");
  6004. return 0;
  6005. }
  6006. /*==========================================
  6007. * @uptime by MC Cameri
  6008. *------------------------------------------*/
  6009. ACMD_FUNC(uptime)
  6010. {
  6011. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6012. minute = 60, days = 0, hours = 0, minutes = 0;
  6013. nullpo_retr(-1, sd);
  6014. seconds = get_uptime();
  6015. days = seconds/day;
  6016. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6017. hours = seconds/hour;
  6018. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6019. minutes = seconds/minute;
  6020. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6021. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  6022. clif_displaymessage(fd, atcmd_output);
  6023. return 0;
  6024. }
  6025. /*==========================================
  6026. * @changesex <sex>
  6027. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  6028. *------------------------------------------*/
  6029. ACMD_FUNC(changesex)
  6030. {
  6031. nullpo_retr(-1, sd);
  6032. chrif_changesex(sd);
  6033. return 0;
  6034. }
  6035. /*================================================
  6036. * @mute - Mutes a player for a set amount of time
  6037. *------------------------------------------------*/
  6038. ACMD_FUNC(mute)
  6039. {
  6040. struct map_session_data *pl_sd = NULL;
  6041. int manner;
  6042. nullpo_retr(-1, sd);
  6043. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6044. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  6045. return -1;
  6046. }
  6047. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  6048. {
  6049. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6050. return -1;
  6051. }
  6052. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  6053. {
  6054. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6055. return -1;
  6056. }
  6057. clif_manner_message(sd, 0);
  6058. clif_manner_message(pl_sd, 5);
  6059. if( pl_sd->status.manner < manner ) {
  6060. pl_sd->status.manner -= manner;
  6061. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6062. } else {
  6063. pl_sd->status.manner = 0;
  6064. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6065. }
  6066. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6067. return 0;
  6068. }
  6069. /*==========================================
  6070. * @refresh (like @jumpto <<yourself>>)
  6071. *------------------------------------------*/
  6072. ACMD_FUNC(refresh)
  6073. {
  6074. nullpo_retr(-1, sd);
  6075. clif_refresh(sd);
  6076. return 0;
  6077. }
  6078. /*==========================================
  6079. * @identify
  6080. * => GM's magnifier.
  6081. *------------------------------------------*/
  6082. ACMD_FUNC(identify)
  6083. {
  6084. int i,num;
  6085. nullpo_retr(-1, sd);
  6086. for(i=num=0;i<MAX_INVENTORY;i++){
  6087. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6088. num++;
  6089. }
  6090. }
  6091. if (num > 0) {
  6092. clif_item_identify_list(sd);
  6093. } else {
  6094. clif_displaymessage(fd,"There are no items to appraise.");
  6095. }
  6096. return 0;
  6097. }
  6098. /*==========================================
  6099. * @gmotd (Global MOTD)
  6100. * by davidsiaw :P
  6101. *------------------------------------------*/
  6102. ACMD_FUNC(gmotd)
  6103. {
  6104. char buf[CHAT_SIZE_MAX];
  6105. size_t len;
  6106. FILE* fp;
  6107. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6108. {
  6109. while( fgets(buf, sizeof(buf), fp) )
  6110. {
  6111. if( buf[0] == '/' && buf[1] == '/' )
  6112. {
  6113. continue;
  6114. }
  6115. len = strlen(buf);
  6116. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6117. {// strip trailing EOL characters
  6118. len--;
  6119. }
  6120. if( len )
  6121. {
  6122. buf[len] = 0;
  6123. intif_broadcast(buf, len+1, 0);
  6124. }
  6125. }
  6126. fclose(fp);
  6127. }
  6128. return 0;
  6129. }
  6130. ACMD_FUNC(misceffect)
  6131. {
  6132. int effect = 0;
  6133. nullpo_retr(-1, sd);
  6134. if (!message || !*message)
  6135. return -1;
  6136. if (sscanf(message, "%d", &effect) < 1)
  6137. return -1;
  6138. clif_misceffect(&sd->bl,effect);
  6139. return 0;
  6140. }
  6141. /*==========================================
  6142. * MAIL SYSTEM
  6143. *------------------------------------------*/
  6144. ACMD_FUNC(mail)
  6145. {
  6146. nullpo_ret(sd);
  6147. mail_openmail(sd);
  6148. return 0;
  6149. }
  6150. /*==========================================
  6151. * Show Monster DB Info v 1.0
  6152. * originally by [Lupus] eAthena
  6153. *------------------------------------------*/
  6154. ACMD_FUNC(mobinfo)
  6155. {
  6156. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  6157. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  6158. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  6159. char atcmd_output2[CHAT_SIZE_MAX];
  6160. struct item_data *item_data;
  6161. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6162. int count;
  6163. int i, j, k;
  6164. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6165. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6166. if (!message || !*message) {
  6167. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  6168. return -1;
  6169. }
  6170. // If monster identifier/name argument is a name
  6171. if ((i = mobdb_checkid(atoi(message))))
  6172. {
  6173. mob_array[0] = mob_db(i);
  6174. count = 1;
  6175. } else
  6176. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6177. if (!count) {
  6178. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6179. return -1;
  6180. }
  6181. if (count > MAX_SEARCH) {
  6182. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6183. clif_displaymessage(fd, atcmd_output);
  6184. count = MAX_SEARCH;
  6185. }
  6186. for (k = 0; k < count; k++) {
  6187. mob = mob_array[k];
  6188. // stats
  6189. if (mob->mexp)
  6190. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6191. else
  6192. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6193. clif_displaymessage(fd, atcmd_output);
  6194. 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);
  6195. clif_displaymessage(fd, atcmd_output);
  6196. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  6197. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  6198. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6199. clif_displaymessage(fd, atcmd_output);
  6200. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  6201. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6202. mob->range2 , mob->range3, msize[mob->status.size],
  6203. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6204. clif_displaymessage(fd, atcmd_output);
  6205. // drops
  6206. clif_displaymessage(fd, " Drops:");
  6207. strcpy(atcmd_output, " ");
  6208. j = 0;
  6209. for (i = 0; i < MAX_MOB_DROP; i++) {
  6210. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6211. continue;
  6212. if (item_data->slot)
  6213. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  6214. else
  6215. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  6216. strcat(atcmd_output, atcmd_output2);
  6217. if (++j % 3 == 0) {
  6218. clif_displaymessage(fd, atcmd_output);
  6219. strcpy(atcmd_output, " ");
  6220. }
  6221. }
  6222. if (j == 0)
  6223. clif_displaymessage(fd, "This monster has no drops.");
  6224. else if (j % 3 != 0)
  6225. clif_displaymessage(fd, atcmd_output);
  6226. // mvp
  6227. if (mob->mexp) {
  6228. sprintf(atcmd_output, " MVP Bonus EXP:%u", mob->mexp);
  6229. clif_displaymessage(fd, atcmd_output);
  6230. strcpy(atcmd_output, " MVP Items:");
  6231. j = 0;
  6232. for (i = 0; i < MAX_MVP_DROP; i++) {
  6233. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6234. continue;
  6235. if (mob->mvpitem[i].p > 0) {
  6236. j++;
  6237. if (j == 1)
  6238. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6239. else
  6240. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6241. strcat(atcmd_output, atcmd_output2);
  6242. }
  6243. }
  6244. if (j == 0)
  6245. clif_displaymessage(fd, "This monster has no MVP prizes.");
  6246. else
  6247. clif_displaymessage(fd, atcmd_output);
  6248. }
  6249. }
  6250. return 0;
  6251. }
  6252. /*=========================================
  6253. * @showmobs by KarLaeda
  6254. * => For 15 sec displays the mobs on minimap
  6255. *------------------------------------------*/
  6256. ACMD_FUNC(showmobs)
  6257. {
  6258. char mob_name[100];
  6259. int mob_id;
  6260. int number = 0;
  6261. struct s_mapiterator* it;
  6262. nullpo_retr(-1, sd);
  6263. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6264. return -1;
  6265. if((mob_id = atoi(mob_name)) == 0)
  6266. mob_id = mobdb_searchname(mob_name);
  6267. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6268. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6269. clif_displaymessage(fd, atcmd_output);
  6270. return 0;
  6271. }
  6272. // Uncomment the following line to show mini-bosses & MVP.
  6273. //#define SHOW_MVP
  6274. #ifndef SHOW_MVP
  6275. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6276. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6277. clif_displaymessage(fd, atcmd_output);
  6278. return 0;
  6279. }
  6280. #endif
  6281. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6282. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6283. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6284. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6285. mob_name, mapindex_id2name(sd->mapindex));
  6286. clif_displaymessage(fd, atcmd_output);
  6287. it = mapit_geteachmob();
  6288. for(;;)
  6289. {
  6290. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6291. if( md == NULL )
  6292. break;// no more mobs
  6293. if( md->bl.m != sd->bl.m )
  6294. continue;
  6295. if( mob_id != -1 && md->class_ != mob_id )
  6296. continue;
  6297. if( md->special_state.ai || md->master_id )
  6298. continue; // hide slaves and player summoned mobs
  6299. if( md->spawn_timer != INVALID_TIMER )
  6300. continue; // hide mobs waiting for respawn
  6301. ++number;
  6302. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6303. }
  6304. mapit_free(it);
  6305. return 0;
  6306. }
  6307. /*==========================================
  6308. * homunculus level up [orn]
  6309. *------------------------------------------*/
  6310. ACMD_FUNC(homlevel)
  6311. {
  6312. TBL_HOM * hd;
  6313. int level = 0, i = 0;
  6314. nullpo_retr(-1, sd);
  6315. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6316. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  6317. return -1;
  6318. }
  6319. if ( !merc_is_hom_active(sd->hd) ) {
  6320. clif_displaymessage(fd, "You do not have a homunculus.");
  6321. return -1;
  6322. }
  6323. hd = sd->hd;
  6324. for (i = 1; i <= level && hd->exp_next; i++){
  6325. hd->homunculus.exp += hd->exp_next;
  6326. merc_hom_levelup(hd);
  6327. }
  6328. status_calc_homunculus(hd,0);
  6329. status_percent_heal(&hd->bl, 100, 100);
  6330. clif_specialeffect(&hd->bl,568,AREA);
  6331. return 0;
  6332. }
  6333. /*==========================================
  6334. * homunculus evolution H [orn]
  6335. *------------------------------------------*/
  6336. ACMD_FUNC(homevolution)
  6337. {
  6338. nullpo_retr(-1, sd);
  6339. if ( !merc_is_hom_active(sd->hd) ) {
  6340. clif_displaymessage(fd, "You do not have a homunculus.");
  6341. return -1;
  6342. }
  6343. if ( !merc_hom_evolution(sd->hd) ) {
  6344. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6345. return -1;
  6346. }
  6347. clif_homskillinfoblock(sd);
  6348. return 0;
  6349. }
  6350. /*==========================================
  6351. * call choosen homunculus [orn]
  6352. *------------------------------------------*/
  6353. ACMD_FUNC(makehomun)
  6354. {
  6355. int homunid;
  6356. nullpo_retr(-1, sd);
  6357. if ( sd->status.hom_id ) {
  6358. clif_displaymessage(fd, msg_txt(450));
  6359. return -1;
  6360. }
  6361. if (!message || !*message) {
  6362. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6363. return -1;
  6364. }
  6365. homunid = atoi(message);
  6366. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6367. {
  6368. clif_displaymessage(fd, "Invalid Homunculus id.");
  6369. return -1;
  6370. }
  6371. merc_create_homunculus_request(sd,homunid);
  6372. return 0;
  6373. }
  6374. /*==========================================
  6375. * modify homunculus intimacy [orn]
  6376. *------------------------------------------*/
  6377. ACMD_FUNC(homfriendly)
  6378. {
  6379. int friendly = 0;
  6380. nullpo_retr(-1, sd);
  6381. if ( !merc_is_hom_active(sd->hd) ) {
  6382. clif_displaymessage(fd, "You do not have a homunculus.");
  6383. return -1;
  6384. }
  6385. if (!message || !*message) {
  6386. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6387. return -1;
  6388. }
  6389. friendly = atoi(message);
  6390. friendly = cap_value(friendly, 0, 1000);
  6391. sd->hd->homunculus.intimacy = friendly * 100 ;
  6392. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6393. return 0;
  6394. }
  6395. /*==========================================
  6396. * modify homunculus hunger [orn]
  6397. *------------------------------------------*/
  6398. ACMD_FUNC(homhungry)
  6399. {
  6400. int hungry = 0;
  6401. nullpo_retr(-1, sd);
  6402. if ( !merc_is_hom_active(sd->hd) ) {
  6403. clif_displaymessage(fd, "You do not have a homunculus.");
  6404. return -1;
  6405. }
  6406. if (!message || !*message) {
  6407. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6408. return -1;
  6409. }
  6410. hungry = atoi(message);
  6411. hungry = cap_value(hungry, 0, 100);
  6412. sd->hd->homunculus.hunger = hungry;
  6413. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6414. return 0;
  6415. }
  6416. /*==========================================
  6417. * make the homunculus speak [orn]
  6418. *------------------------------------------*/
  6419. ACMD_FUNC(homtalk)
  6420. {
  6421. char mes[100],temp[100];
  6422. nullpo_retr(-1, sd);
  6423. if (sd->sc.count && //no "chatting" while muted.
  6424. (sd->sc.data[SC_BERSERK] ||
  6425. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6426. return -1;
  6427. if ( !merc_is_hom_active(sd->hd) ) {
  6428. clif_displaymessage(fd, "You do not have a homunculus.");
  6429. return -1;
  6430. }
  6431. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6432. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6433. return -1;
  6434. }
  6435. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6436. clif_message(&sd->hd->bl, temp);
  6437. return 0;
  6438. }
  6439. /*==========================================
  6440. * Show homunculus stats
  6441. *------------------------------------------*/
  6442. ACMD_FUNC(hominfo)
  6443. {
  6444. struct homun_data *hd;
  6445. struct status_data *status;
  6446. nullpo_retr(-1, sd);
  6447. if ( !merc_is_hom_active(sd->hd) ) {
  6448. clif_displaymessage(fd, "You do not have a homunculus.");
  6449. return -1;
  6450. }
  6451. hd = sd->hd;
  6452. status = status_get_status_data(&hd->bl);
  6453. clif_displaymessage(fd, "Homunculus stats :");
  6454. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6455. status->hp, status->max_hp, status->sp, status->max_sp);
  6456. clif_displaymessage(fd, atcmd_output);
  6457. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6458. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6459. clif_displaymessage(fd, atcmd_output);
  6460. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6461. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6462. clif_displaymessage(fd, atcmd_output);
  6463. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6464. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6465. status->str, status->agi, status->vit,
  6466. status->int_, status->dex, status->luk);
  6467. clif_displaymessage(fd, atcmd_output);
  6468. return 0;
  6469. }
  6470. ACMD_FUNC(homstats)
  6471. {
  6472. struct homun_data *hd;
  6473. struct s_homunculus_db *db;
  6474. struct s_homunculus *hom;
  6475. int lv, min, max, evo;
  6476. nullpo_retr(-1, sd);
  6477. if ( !merc_is_hom_active(sd->hd) ) {
  6478. clif_displaymessage(fd, "You do not have a homunculus.");
  6479. return -1;
  6480. }
  6481. hd = sd->hd;
  6482. hom = &hd->homunculus;
  6483. db = hd->homunculusDB;
  6484. lv = hom->level;
  6485. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6486. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6487. clif_displaymessage(fd, atcmd_output);
  6488. lv--; //Since the first increase is at level 2.
  6489. evo = (hom->class_ == db->evo_class);
  6490. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6491. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6492. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6493. clif_displaymessage(fd, atcmd_output);
  6494. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6495. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6496. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6497. clif_displaymessage(fd, atcmd_output);
  6498. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6499. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6500. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6501. clif_displaymessage(fd, atcmd_output);
  6502. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6503. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6504. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6505. clif_displaymessage(fd, atcmd_output);
  6506. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6507. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6508. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6509. clif_displaymessage(fd, atcmd_output);
  6510. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6511. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6512. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6513. clif_displaymessage(fd, atcmd_output);
  6514. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6515. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6516. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6517. clif_displaymessage(fd, atcmd_output);
  6518. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6519. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6520. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6521. clif_displaymessage(fd, atcmd_output);
  6522. return 0;
  6523. }
  6524. ACMD_FUNC(homshuffle)
  6525. {
  6526. nullpo_retr(-1, sd);
  6527. if(!sd->hd)
  6528. return -1; // nothing to do
  6529. if(!merc_hom_shuffle(sd->hd))
  6530. return -1;
  6531. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6532. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6533. return 0;
  6534. }
  6535. /*==========================================
  6536. * Show Items DB Info v 1.0
  6537. * originally by [Lupus] eAthena
  6538. *------------------------------------------*/
  6539. ACMD_FUNC(iteminfo)
  6540. {
  6541. struct item_data *item_data, *item_array[MAX_SEARCH];
  6542. int i, count = 1;
  6543. if (!message || !*message) {
  6544. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6545. return -1;
  6546. }
  6547. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6548. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6549. if (!count) {
  6550. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6551. return -1;
  6552. }
  6553. if (count > MAX_SEARCH) {
  6554. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6555. clif_displaymessage(fd, atcmd_output);
  6556. count = MAX_SEARCH;
  6557. }
  6558. for (i = 0; i < count; i++) {
  6559. item_data = item_array[i];
  6560. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6561. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6562. itemdb_typename(item_data->type),
  6563. (item_data->script==NULL)? "None" : "With script"
  6564. );
  6565. clif_displaymessage(fd, atcmd_output);
  6566. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  6567. clif_displaymessage(fd, atcmd_output);
  6568. if (item_data->maxchance == -1)
  6569. strcpy(atcmd_output, " - Available in the shops only.");
  6570. else if (item_data->maxchance)
  6571. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6572. else
  6573. strcpy(atcmd_output, " - Monsters don't drop this item.");
  6574. clif_displaymessage(fd, atcmd_output);
  6575. }
  6576. return 0;
  6577. }
  6578. /*==========================================
  6579. * Show who drops the item.
  6580. *------------------------------------------*/
  6581. ACMD_FUNC(whodrops)
  6582. {
  6583. struct item_data *item_data, *item_array[MAX_SEARCH];
  6584. int i,j, count = 1;
  6585. if (!message || !*message) {
  6586. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6587. return -1;
  6588. }
  6589. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6590. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6591. if (!count) {
  6592. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6593. return -1;
  6594. }
  6595. if (count > MAX_SEARCH) {
  6596. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6597. clif_displaymessage(fd, atcmd_output);
  6598. count = MAX_SEARCH;
  6599. }
  6600. for (i = 0; i < count; i++) {
  6601. item_data = item_array[i];
  6602. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6603. clif_displaymessage(fd, atcmd_output);
  6604. if (item_data->mob[0].chance == 0) {
  6605. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6606. clif_displaymessage(fd, atcmd_output);
  6607. } else {
  6608. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6609. clif_displaymessage(fd, atcmd_output);
  6610. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6611. {
  6612. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6613. clif_displaymessage(fd, atcmd_output);
  6614. }
  6615. }
  6616. }
  6617. return 0;
  6618. }
  6619. ACMD_FUNC(whereis)
  6620. {
  6621. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6622. int count;
  6623. int i, j, k;
  6624. if (!message || !*message) {
  6625. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6626. return -1;
  6627. }
  6628. // If monster identifier/name argument is a name
  6629. if ((i = mobdb_checkid(atoi(message))))
  6630. {
  6631. mob_array[0] = mob_db(i);
  6632. count = 1;
  6633. } else
  6634. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6635. if (!count) {
  6636. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6637. return -1;
  6638. }
  6639. if (count > MAX_SEARCH) {
  6640. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6641. clif_displaymessage(fd, atcmd_output);
  6642. count = MAX_SEARCH;
  6643. }
  6644. for (k = 0; k < count; k++) {
  6645. mob = mob_array[k];
  6646. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6647. clif_displaymessage(fd, atcmd_output);
  6648. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6649. {
  6650. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6651. if (j < 0) continue;
  6652. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6653. clif_displaymessage(fd, atcmd_output);
  6654. }
  6655. if (i == 0)
  6656. clif_displaymessage(fd, "This monster does not spawn normally.");
  6657. }
  6658. return 0;
  6659. }
  6660. /*==========================================
  6661. * @adopt by [Veider]
  6662. * adopt a novice
  6663. *------------------------------------------*/
  6664. ACMD_FUNC(adopt)
  6665. {
  6666. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6667. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6668. char output[CHAT_SIZE_MAX];
  6669. nullpo_retr(-1, sd);
  6670. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6671. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6672. return -1;
  6673. }
  6674. if (battle_config.etc_log)
  6675. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6676. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6677. sprintf(output, "Cannot find player %s online", player1);
  6678. clif_displaymessage(fd, output);
  6679. return -1;
  6680. }
  6681. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6682. sprintf(output, "Cannot find player %s online", player2);
  6683. clif_displaymessage(fd, output);
  6684. return -1;
  6685. }
  6686. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6687. sprintf(output, "Cannot find player %s online", player3);
  6688. clif_displaymessage(fd, output);
  6689. return -1;
  6690. }
  6691. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6692. return -1;
  6693. }
  6694. clif_displaymessage(fd, "They are family... wish them luck");
  6695. return 0;
  6696. }
  6697. ACMD_FUNC(version)
  6698. {
  6699. const char * revision;
  6700. if ((revision = get_svn_revision()) != 0) {
  6701. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6702. clif_displaymessage(fd,atcmd_output);
  6703. } else
  6704. clif_displaymessage(fd,"Cannot determine SVN revision");
  6705. return 0;
  6706. }
  6707. /*==========================================
  6708. * @mutearea by MouseJstr
  6709. *------------------------------------------*/
  6710. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6711. {
  6712. int time, id;
  6713. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6714. if (pl_sd == NULL)
  6715. return 0;
  6716. id = va_arg(ap, int);
  6717. time = va_arg(ap, int);
  6718. if (id != bl->id && !pc_isGM(pl_sd)) {
  6719. pl_sd->status.manner -= time;
  6720. if (pl_sd->status.manner < 0)
  6721. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6722. else
  6723. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6724. }
  6725. return 0;
  6726. }
  6727. ACMD_FUNC(mutearea)
  6728. {
  6729. int time;
  6730. nullpo_ret(sd);
  6731. if (!message || !*message) {
  6732. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6733. return -1;
  6734. }
  6735. time = atoi(message);
  6736. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6737. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6738. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6739. return 0;
  6740. }
  6741. ACMD_FUNC(rates)
  6742. {
  6743. char buf[CHAT_SIZE_MAX];
  6744. nullpo_ret(sd);
  6745. memset(buf, '\0', sizeof(buf));
  6746. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  6747. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6748. clif_displaymessage(fd, buf);
  6749. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6750. battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
  6751. clif_displaymessage(fd, buf);
  6752. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6753. battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
  6754. clif_displaymessage(fd, buf);
  6755. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  6756. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6757. clif_displaymessage(fd, buf);
  6758. return 0;
  6759. }
  6760. /*==========================================
  6761. * @me by lordalfa
  6762. * => Displays the OUTPUT string on top of the Visible players Heads.
  6763. *------------------------------------------*/
  6764. ACMD_FUNC(me)
  6765. {
  6766. char tempmes[CHAT_SIZE_MAX];
  6767. nullpo_retr(-1, sd);
  6768. memset(tempmes, '\0', sizeof(tempmes));
  6769. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6770. if (sd->sc.count && //no "chatting" while muted.
  6771. (sd->sc.data[SC_BERSERK] ||
  6772. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6773. return -1;
  6774. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6775. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6776. return -1;
  6777. }
  6778. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6779. clif_disp_overhead(sd, atcmd_output);
  6780. return 0;
  6781. }
  6782. /*==========================================
  6783. * @size
  6784. * => Resize your character sprite. [Valaris]
  6785. *------------------------------------------*/
  6786. ACMD_FUNC(size)
  6787. {
  6788. int size=0;
  6789. nullpo_retr(-1, sd);
  6790. size = atoi(message);
  6791. if(sd->state.size) {
  6792. sd->state.size=0;
  6793. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6794. }
  6795. if(size==1) {
  6796. sd->state.size=1;
  6797. clif_specialeffect(&sd->bl,420,AREA);
  6798. } else if(size==2) {
  6799. sd->state.size=2;
  6800. clif_specialeffect(&sd->bl,422,AREA);
  6801. }
  6802. return 0;
  6803. }
  6804. /*==========================================
  6805. * @monsterignore
  6806. * => Makes monsters ignore you. [Valaris]
  6807. *------------------------------------------*/
  6808. ACMD_FUNC(monsterignore)
  6809. {
  6810. nullpo_retr(-1, sd);
  6811. if (!sd->state.monster_ignore) {
  6812. sd->state.monster_ignore = 1;
  6813. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6814. } else {
  6815. sd->state.monster_ignore = 0;
  6816. clif_displaymessage(sd->fd, "Returned to normal state.");
  6817. }
  6818. return 0;
  6819. }
  6820. /*==========================================
  6821. * @fakename
  6822. * => Gives your character a fake name. [Valaris]
  6823. *------------------------------------------*/
  6824. ACMD_FUNC(fakename)
  6825. {
  6826. nullpo_retr(-1, sd);
  6827. if( !message || !*message )
  6828. {
  6829. if( sd->fakename[0] )
  6830. {
  6831. sd->fakename[0] = '\0';
  6832. clif_charnameack(0, &sd->bl);
  6833. clif_displaymessage(sd->fd, "Returned to real name.");
  6834. return 0;
  6835. }
  6836. clif_displaymessage(sd->fd, "You must enter a name.");
  6837. return -1;
  6838. }
  6839. if( strlen(message) < 2 )
  6840. {
  6841. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  6842. return -1;
  6843. }
  6844. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6845. clif_charnameack(0, &sd->bl);
  6846. clif_displaymessage(sd->fd, "Fake name enabled.");
  6847. return 0;
  6848. }
  6849. /*==========================================
  6850. * Ragnarok Resources
  6851. *------------------------------------------*/
  6852. ACMD_FUNC(mapflag) {
  6853. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6854. #define setflag( cmd ) \
  6855. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6856. map[ sd->bl.m ].flag.cmd = flag;\
  6857. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6858. clif_displaymessage(sd->fd,atcmd_output);\
  6859. return 0;\
  6860. }
  6861. unsigned char flag_name[100];
  6862. int flag=9,i;
  6863. nullpo_retr(-1, sd);
  6864. memset(flag_name, '\0', sizeof(flag_name));
  6865. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6866. clif_displaymessage(sd->fd,"Enabled Mapflags in this map:");
  6867. clif_displaymessage(sd->fd,"----------------------------------");
  6868. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6869. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6870. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6871. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6872. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6873. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6874. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6875. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6876. checkflag(nogo); checkflag(nobaseexp);
  6877. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6878. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6879. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6880. clif_displaymessage(sd->fd," ");
  6881. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off 1=On)");
  6882. clif_displaymessage(sd->fd,"Use: \"@mapflag available\" to list the available mapflags");
  6883. return 1;
  6884. }
  6885. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6886. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6887. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6888. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6889. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6890. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6891. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6892. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6893. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6894. setflag(nogo); setflag(nobaseexp);
  6895. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6896. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6897. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6898. clif_displaymessage(sd->fd,"Invalid flag name or flag");
  6899. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off | 1=On)");
  6900. clif_displaymessage(sd->fd,"Available Flags:");
  6901. clif_displaymessage(sd->fd,"----------------------------------");
  6902. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6903. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6904. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6905. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6906. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6907. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6908. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6909. #undef checkflag
  6910. #undef setflag
  6911. return 0;
  6912. }
  6913. /*===================================
  6914. * Remove some messages
  6915. *-----------------------------------*/
  6916. ACMD_FUNC(showexp)
  6917. {
  6918. if (sd->state.showexp) {
  6919. sd->state.showexp = 0;
  6920. clif_displaymessage(fd, "Gained exp will not be shown.");
  6921. return 0;
  6922. }
  6923. sd->state.showexp = 1;
  6924. clif_displaymessage(fd, "Gained exp is now shown");
  6925. return 0;
  6926. }
  6927. ACMD_FUNC(showzeny)
  6928. {
  6929. if (sd->state.showzeny) {
  6930. sd->state.showzeny = 0;
  6931. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6932. return 0;
  6933. }
  6934. sd->state.showzeny = 1;
  6935. clif_displaymessage(fd, "Gained zeny is now shown");
  6936. return 0;
  6937. }
  6938. ACMD_FUNC(showdelay)
  6939. {
  6940. if (sd->state.showdelay) {
  6941. sd->state.showdelay = 0;
  6942. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6943. return 0;
  6944. }
  6945. sd->state.showdelay = 1;
  6946. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6947. return 0;
  6948. }
  6949. /*==========================================
  6950. * Duel organizing functions [LuzZza]
  6951. *
  6952. * @duel [limit|nick] - create a duel
  6953. * @invite <nick> - invite player
  6954. * @accept - accept invitation
  6955. * @reject - reject invitation
  6956. * @leave - leave duel
  6957. *------------------------------------------*/
  6958. ACMD_FUNC(invite)
  6959. {
  6960. unsigned int did = sd->duel_group;
  6961. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6962. if(did <= 0) {
  6963. // "Duel: @invite without @duel."
  6964. clif_displaymessage(fd, msg_txt(350));
  6965. return 0;
  6966. }
  6967. if(duel_list[did].max_players_limit > 0 &&
  6968. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6969. // "Duel: Limit of players is reached."
  6970. clif_displaymessage(fd, msg_txt(351));
  6971. return 0;
  6972. }
  6973. if(target_sd == NULL) {
  6974. // "Duel: Player not found."
  6975. clif_displaymessage(fd, msg_txt(352));
  6976. return 0;
  6977. }
  6978. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6979. // "Duel: Player already in duel."
  6980. clif_displaymessage(fd, msg_txt(353));
  6981. return 0;
  6982. }
  6983. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6984. {
  6985. sprintf(atcmd_output, msg_txt(364), message);
  6986. clif_displaymessage(fd, atcmd_output);
  6987. return 0;
  6988. }
  6989. duel_invite(did, sd, target_sd);
  6990. // "Duel: Invitation has been sent."
  6991. clif_displaymessage(fd, msg_txt(354));
  6992. return 0;
  6993. }
  6994. ACMD_FUNC(duel)
  6995. {
  6996. char output[CHAT_SIZE_MAX];
  6997. unsigned int maxpl=0, newduel;
  6998. struct map_session_data *target_sd;
  6999. if(sd->duel_group > 0) {
  7000. duel_showinfo(sd->duel_group, sd);
  7001. return 0;
  7002. }
  7003. if(sd->duel_invite > 0) {
  7004. // "Duel: @duel without @reject."
  7005. clif_displaymessage(fd, msg_txt(355));
  7006. return 0;
  7007. }
  7008. if(!duel_checktime(sd)) {
  7009. // "Duel: You can take part in duel only one time per %d minutes."
  7010. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  7011. clif_displaymessage(fd, output);
  7012. return 0;
  7013. }
  7014. if( message[0] ) {
  7015. if(sscanf(message, "%d", &maxpl) >= 1) {
  7016. if(maxpl < 2 || maxpl > 65535) {
  7017. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  7018. return 0;
  7019. }
  7020. duel_create(sd, maxpl);
  7021. } else {
  7022. target_sd = map_nick2sd((char *)message);
  7023. if(target_sd != NULL) {
  7024. if((newduel = duel_create(sd, 2)) != -1) {
  7025. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7026. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  7027. return 0;
  7028. }
  7029. duel_invite(newduel, sd, target_sd);
  7030. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  7031. }
  7032. } else {
  7033. // "Duel: Player not found."
  7034. clif_displaymessage(fd, msg_txt(352));
  7035. return 0;
  7036. }
  7037. }
  7038. } else
  7039. duel_create(sd, 0);
  7040. return 0;
  7041. }
  7042. ACMD_FUNC(leave)
  7043. {
  7044. if(sd->duel_group <= 0) {
  7045. // "Duel: @leave without @duel."
  7046. clif_displaymessage(fd, msg_txt(358));
  7047. return 0;
  7048. }
  7049. duel_leave(sd->duel_group, sd);
  7050. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  7051. return 0;
  7052. }
  7053. ACMD_FUNC(accept)
  7054. {
  7055. char output[CHAT_SIZE_MAX];
  7056. if(!duel_checktime(sd)) {
  7057. // "Duel: You can take part in duel only one time per %d minutes."
  7058. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  7059. clif_displaymessage(fd, output);
  7060. return 0;
  7061. }
  7062. if(sd->duel_invite <= 0) {
  7063. // "Duel: @accept without invititation."
  7064. clif_displaymessage(fd, msg_txt(360));
  7065. return 0;
  7066. }
  7067. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  7068. {
  7069. // "Duel: Limit of players is reached."
  7070. clif_displaymessage(fd, msg_txt(351));
  7071. return 0;
  7072. }
  7073. duel_accept(sd->duel_invite, sd);
  7074. // "Duel: Invitation has been accepted."
  7075. clif_displaymessage(fd, msg_txt(361));
  7076. return 0;
  7077. }
  7078. ACMD_FUNC(reject)
  7079. {
  7080. if(sd->duel_invite <= 0) {
  7081. // "Duel: @reject without invititation."
  7082. clif_displaymessage(fd, msg_txt(362));
  7083. return 0;
  7084. }
  7085. duel_reject(sd->duel_invite, sd);
  7086. // "Duel: Invitation has been rejected."
  7087. clif_displaymessage(fd, msg_txt(363));
  7088. return 0;
  7089. }
  7090. /*===================================
  7091. * Cash Points
  7092. *-----------------------------------*/
  7093. ACMD_FUNC(cash)
  7094. {
  7095. char output[128];
  7096. int value;
  7097. nullpo_retr(-1, sd);
  7098. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7099. clif_displaymessage(fd, "Please, enter an amount.");
  7100. return -1;
  7101. }
  7102. if( !strcmpi(command+1,"cash") )
  7103. {
  7104. if( value > 0 ) {
  7105. pc_getcash(sd, value, 0);
  7106. sprintf(output, msg_txt(505), value, sd->cashPoints);
  7107. clif_disp_onlyself(sd, output, strlen(output));
  7108. } else {
  7109. pc_paycash(sd, -value, 0);
  7110. sprintf(output, msg_txt(410), value, sd->cashPoints);
  7111. clif_disp_onlyself(sd, output, strlen(output));
  7112. }
  7113. }
  7114. else
  7115. { // @points
  7116. if( value > 0 ) {
  7117. pc_getcash(sd, 0, value);
  7118. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  7119. clif_disp_onlyself(sd, output, strlen(output));
  7120. } else {
  7121. pc_paycash(sd, -value, -value);
  7122. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  7123. clif_disp_onlyself(sd, output, strlen(output));
  7124. }
  7125. }
  7126. return 0;
  7127. }
  7128. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7129. ACMD_FUNC(clone)
  7130. {
  7131. int x=0,y=0,flag=0,master=0,i=0;
  7132. struct map_session_data *pl_sd=NULL;
  7133. if (!message || !*message) {
  7134. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  7135. return 0;
  7136. }
  7137. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7138. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7139. return 0;
  7140. }
  7141. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  7142. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  7143. return 0;
  7144. }
  7145. if (strcmpi(command+1, "clone") == 0)
  7146. flag = 1;
  7147. else if (strcmpi(command+1, "slaveclone") == 0) {
  7148. flag = 2;
  7149. master = sd->bl.id;
  7150. if (battle_config.atc_slave_clone_limit
  7151. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7152. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  7153. return 0;
  7154. }
  7155. }
  7156. do {
  7157. x = sd->bl.x + (rnd() % 10 - 5);
  7158. y = sd->bl.y + (rnd() % 10 - 5);
  7159. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7160. if (i >= 10) {
  7161. x = sd->bl.x;
  7162. y = sd->bl.y;
  7163. }
  7164. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7165. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7166. return 0;
  7167. }
  7168. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7169. return 0;
  7170. }
  7171. /*===================================
  7172. * Main chat [LuzZza]
  7173. * Usage: @main <on|off|message>
  7174. *-----------------------------------*/
  7175. ACMD_FUNC(main)
  7176. {
  7177. if( message[0] ) {
  7178. if(strcmpi(message, "on") == 0) {
  7179. if(!sd->state.mainchat) {
  7180. sd->state.mainchat = 1;
  7181. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7182. } else {
  7183. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  7184. }
  7185. } else if(strcmpi(message, "off") == 0) {
  7186. if(sd->state.mainchat) {
  7187. sd->state.mainchat = 0;
  7188. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  7189. } else {
  7190. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  7191. }
  7192. } else {
  7193. if(!sd->state.mainchat) {
  7194. sd->state.mainchat = 1;
  7195. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7196. }
  7197. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  7198. clif_displaymessage(fd, msg_txt(387));
  7199. return -1;
  7200. }
  7201. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  7202. // I use 0xFE000000 color for signalizing that this message is
  7203. // main chat message. 0xFE000000 is invalid color, same using
  7204. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  7205. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
  7206. // Chat logging type 'M' / Main Chat
  7207. log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  7208. }
  7209. } else {
  7210. if(sd->state.mainchat)
  7211. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  7212. else
  7213. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  7214. }
  7215. return 0;
  7216. }
  7217. /*=====================================
  7218. * Autorejecting Invites/Deals [LuzZza]
  7219. * Usage: @noask
  7220. *-------------------------------------*/
  7221. ACMD_FUNC(noask)
  7222. {
  7223. if(sd->state.noask) {
  7224. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  7225. sd->state.noask = 0;
  7226. } else {
  7227. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  7228. sd->state.noask = 1;
  7229. }
  7230. return 0;
  7231. }
  7232. /*=====================================
  7233. * Send a @request message to all GMs of lowest_gm_level.
  7234. * Usage: @request <petition>
  7235. *-------------------------------------*/
  7236. ACMD_FUNC(request)
  7237. {
  7238. if (!message || !*message) {
  7239. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  7240. return -1;
  7241. }
  7242. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  7243. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  7244. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7245. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  7246. return 0;
  7247. }
  7248. /*==========================================
  7249. * Feel (SG save map) Reset [HiddenDragon]
  7250. *------------------------------------------*/
  7251. ACMD_FUNC(feelreset)
  7252. {
  7253. pc_resetfeel(sd);
  7254. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  7255. return 0;
  7256. }
  7257. /*==========================================
  7258. * AUCTION SYSTEM
  7259. *------------------------------------------*/
  7260. ACMD_FUNC(auction)
  7261. {
  7262. nullpo_ret(sd);
  7263. clif_Auction_openwindow(sd);
  7264. return 0;
  7265. }
  7266. /*==========================================
  7267. * Kill Steal Protection
  7268. *------------------------------------------*/
  7269. ACMD_FUNC(ksprotection)
  7270. {
  7271. nullpo_retr(-1,sd);
  7272. if( sd->state.noks ) {
  7273. sd->state.noks = 0;
  7274. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  7275. }
  7276. else
  7277. {
  7278. if( !message || !*message || !strcmpi(message, "party") )
  7279. { // Default is Party
  7280. sd->state.noks = 2;
  7281. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7282. }
  7283. else if( !strcmpi(message, "self") )
  7284. {
  7285. sd->state.noks = 1;
  7286. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7287. }
  7288. else if( !strcmpi(message, "guild") )
  7289. {
  7290. sd->state.noks = 3;
  7291. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7292. }
  7293. else
  7294. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  7295. }
  7296. clif_displaymessage(fd, atcmd_output);
  7297. return 0;
  7298. }
  7299. /*==========================================
  7300. * Map Kill Steal Protection Setting
  7301. *------------------------------------------*/
  7302. ACMD_FUNC(allowks)
  7303. {
  7304. nullpo_retr(-1,sd);
  7305. if( map[sd->bl.m].flag.allowks ) {
  7306. map[sd->bl.m].flag.allowks = 0;
  7307. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7308. } else {
  7309. map[sd->bl.m].flag.allowks = 1;
  7310. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7311. }
  7312. clif_displaymessage(fd, atcmd_output);
  7313. return 0;
  7314. }
  7315. ACMD_FUNC(resetstat)
  7316. {
  7317. nullpo_retr(-1, sd);
  7318. pc_resetstate(sd);
  7319. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  7320. clif_displaymessage(fd, atcmd_output);
  7321. return 0;
  7322. }
  7323. ACMD_FUNC(resetskill)
  7324. {
  7325. nullpo_retr(-1,sd);
  7326. pc_resetskill(sd,1);
  7327. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  7328. clif_displaymessage(fd, atcmd_output);
  7329. return 0;
  7330. }
  7331. /*==========================================
  7332. * #storagelist: Displays the items list of a player's storage.
  7333. * #cartlist: Displays contents of target's cart.
  7334. * #itemlist: Displays contents of target's inventory.
  7335. *------------------------------------------*/
  7336. ACMD_FUNC(itemlist)
  7337. {
  7338. int i, j, count, counter;
  7339. const char* location;
  7340. const struct item* items;
  7341. int size;
  7342. StringBuf buf;
  7343. nullpo_retr(-1, sd);
  7344. if( strcmp(command+1, "storagelist") == 0 )
  7345. {
  7346. location = "storage";
  7347. items = sd->status.storage.items;
  7348. size = MAX_STORAGE;
  7349. }
  7350. else
  7351. if( strcmp(command+1, "cartlist") == 0 )
  7352. {
  7353. location = "cart";
  7354. items = sd->status.cart;
  7355. size = MAX_CART;
  7356. }
  7357. else
  7358. if( strcmp(command+1, "itemlist") == 0 )
  7359. {
  7360. location = "inventory";
  7361. items = sd->status.inventory;
  7362. size = MAX_INVENTORY;
  7363. }
  7364. else
  7365. return 1;
  7366. StringBuf_Init(&buf);
  7367. count = 0; // total slots occupied
  7368. counter = 0; // total items found
  7369. for( i = 0; i < size; ++i )
  7370. {
  7371. const struct item* it = &items[i];
  7372. struct item_data* itd;
  7373. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7374. continue;
  7375. counter += it->amount;
  7376. count++;
  7377. if( count == 1 )
  7378. {
  7379. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  7380. clif_displaymessage(fd, StringBuf_Value(&buf));
  7381. StringBuf_Clear(&buf);
  7382. }
  7383. if( it->refine )
  7384. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7385. else
  7386. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7387. if( it->equip )
  7388. {
  7389. char equipstr[CHAT_SIZE_MAX];
  7390. strcpy(equipstr, " | equipped: ");
  7391. if( it->equip & EQP_GARMENT )
  7392. strcat(equipstr, "garment, ");
  7393. if( it->equip & EQP_ACC_L )
  7394. strcat(equipstr, "left accessory, ");
  7395. if( it->equip & EQP_ARMOR )
  7396. strcat(equipstr, "body/armor, ");
  7397. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7398. strcat(equipstr, "right hand, ");
  7399. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7400. strcat(equipstr, "left hand, ");
  7401. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7402. strcat(equipstr, "both hands, ");
  7403. if( it->equip & EQP_SHOES )
  7404. strcat(equipstr, "feet, ");
  7405. if( it->equip & EQP_ACC_R )
  7406. strcat(equipstr, "right accessory, ");
  7407. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7408. strcat(equipstr, "lower head, ");
  7409. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7410. strcat(equipstr, "top head, ");
  7411. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7412. strcat(equipstr, "lower/top head, ");
  7413. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7414. strcat(equipstr, "mid head, ");
  7415. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7416. strcat(equipstr, "lower/mid head, ");
  7417. if( (it->equip & EQP_HELM) == EQP_HELM )
  7418. strcat(equipstr, "lower/mid/top head, ");
  7419. // remove final ', '
  7420. equipstr[strlen(equipstr) - 2] = '\0';
  7421. StringBuf_AppendStr(&buf, equipstr);
  7422. }
  7423. clif_displaymessage(fd, StringBuf_Value(&buf));
  7424. StringBuf_Clear(&buf);
  7425. if( it->card[0] == CARD0_PET )
  7426. {// pet egg
  7427. if (it->card[3])
  7428. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7429. else
  7430. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7431. }
  7432. else
  7433. if(it->card[0] == CARD0_FORGE)
  7434. {// forged item
  7435. StringBuf_Printf(&buf, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f);
  7436. }
  7437. else
  7438. if(it->card[0] == CARD0_CREATE)
  7439. {// created item
  7440. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  7441. }
  7442. else
  7443. {// normal item
  7444. int counter2 = 0;
  7445. for( j = 0; j < itd->slot; ++j )
  7446. {
  7447. struct item_data* card;
  7448. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7449. continue;
  7450. counter2++;
  7451. if( counter2 == 1 )
  7452. StringBuf_AppendStr(&buf, " -> (card(s): ");
  7453. if( counter2 != 1 )
  7454. StringBuf_AppendStr(&buf, ", ");
  7455. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7456. }
  7457. if( counter2 > 0 )
  7458. StringBuf_AppendStr(&buf, ")");
  7459. }
  7460. if( StringBuf_Length(&buf) > 0 )
  7461. clif_displaymessage(fd, StringBuf_Value(&buf));
  7462. StringBuf_Clear(&buf);
  7463. }
  7464. if( count == 0 )
  7465. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  7466. else
  7467. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  7468. clif_displaymessage(fd, StringBuf_Value(&buf));
  7469. StringBuf_Destroy(&buf);
  7470. return 0;
  7471. }
  7472. ACMD_FUNC(stats)
  7473. {
  7474. char job_jobname[100];
  7475. char output[CHAT_SIZE_MAX];
  7476. int i;
  7477. struct {
  7478. const char* format;
  7479. int value;
  7480. } output_table[] = {
  7481. { "Base Level - %d", 0 },
  7482. { NULL, 0 },
  7483. { "Hp - %d", 0 },
  7484. { "MaxHp - %d", 0 },
  7485. { "Sp - %d", 0 },
  7486. { "MaxSp - %d", 0 },
  7487. { "Str - %3d", 0 },
  7488. { "Agi - %3d", 0 },
  7489. { "Vit - %3d", 0 },
  7490. { "Int - %3d", 0 },
  7491. { "Dex - %3d", 0 },
  7492. { "Luk - %3d", 0 },
  7493. { "Zeny - %d", 0 },
  7494. { "Free SK Points - %d", 0 },
  7495. { "JobChangeLvl - %d", 0 },
  7496. { NULL, 0 }
  7497. };
  7498. memset(job_jobname, '\0', sizeof(job_jobname));
  7499. memset(output, '\0', sizeof(output));
  7500. //direct array initialization with variables is not standard C compliant.
  7501. output_table[0].value = sd->status.base_level;
  7502. output_table[1].format = job_jobname;
  7503. output_table[1].value = sd->status.job_level;
  7504. output_table[2].value = sd->status.hp;
  7505. output_table[3].value = sd->status.max_hp;
  7506. output_table[4].value = sd->status.sp;
  7507. output_table[5].value = sd->status.max_sp;
  7508. output_table[6].value = sd->status.str;
  7509. output_table[7].value = sd->status.agi;
  7510. output_table[8].value = sd->status.vit;
  7511. output_table[9].value = sd->status.int_;
  7512. output_table[10].value = sd->status.dex;
  7513. output_table[11].value = sd->status.luk;
  7514. output_table[12].value = sd->status.zeny;
  7515. output_table[13].value = sd->status.skill_point;
  7516. output_table[14].value = sd->change_level;
  7517. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7518. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7519. clif_displaymessage(fd, output);
  7520. for (i = 0; output_table[i].format != NULL; i++) {
  7521. sprintf(output, output_table[i].format, output_table[i].value);
  7522. clif_displaymessage(fd, output);
  7523. }
  7524. return 0;
  7525. }
  7526. ACMD_FUNC(delitem)
  7527. {
  7528. char item_name[100];
  7529. int nameid, amount = 0, total, idx;
  7530. struct item_data* id;
  7531. nullpo_retr(-1, sd);
  7532. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7533. {
  7534. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  7535. return -1;
  7536. }
  7537. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7538. {
  7539. nameid = id->nameid;
  7540. }
  7541. else
  7542. {
  7543. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7544. return -1;
  7545. }
  7546. total = amount;
  7547. // delete items
  7548. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7549. {
  7550. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7551. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7552. {// delete pet
  7553. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7554. }
  7555. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7556. amount-= delamount;
  7557. }
  7558. // notify target
  7559. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7560. clif_displaymessage(sd->fd, atcmd_output);
  7561. // notify source
  7562. if( amount == total )
  7563. {
  7564. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7565. }
  7566. else if( amount )
  7567. {
  7568. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7569. clif_displaymessage(fd, atcmd_output);
  7570. }
  7571. else
  7572. {
  7573. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7574. clif_displaymessage(fd, atcmd_output);
  7575. }
  7576. return 0;
  7577. }
  7578. /*==========================================
  7579. * Custom Fonts
  7580. *------------------------------------------*/
  7581. ACMD_FUNC(font)
  7582. {
  7583. int font_id;
  7584. nullpo_retr(-1,sd);
  7585. font_id = atoi(message);
  7586. if( font_id == 0 )
  7587. {
  7588. if( sd->user_font )
  7589. {
  7590. sd->user_font = 0;
  7591. clif_displaymessage(fd, "Returning to normal font.");
  7592. clif_font(sd);
  7593. }
  7594. else
  7595. {
  7596. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  7597. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  7598. }
  7599. }
  7600. else if( font_id < 0 || font_id > 9 )
  7601. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  7602. else if( font_id != sd->user_font )
  7603. {
  7604. sd->user_font = font_id;
  7605. clif_font(sd);
  7606. clif_displaymessage(fd, "Font changed.");
  7607. }
  7608. else
  7609. clif_displaymessage(fd, "Already using this font.");
  7610. return 0;
  7611. }
  7612. ACMD_FUNC(new_mount) {
  7613. clif_displaymessage(sd->fd,"NOTICE: If you crash with mount your LUA is outdated");
  7614. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7615. clif_displaymessage(sd->fd,"You have mounted.");
  7616. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7617. } else {
  7618. clif_displaymessage(sd->fd,"You have released your mount");
  7619. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7620. }
  7621. return 0;
  7622. }
  7623. /**
  7624. * Fills the reference of available commands in atcommand DBMap
  7625. **/
  7626. void atcommand_basecommands(void) {
  7627. /**
  7628. * Command reference list, place the base of your commands here
  7629. * Dev note: I'd love to get rid of this, if you have a better idea on this please share with the poor mortals
  7630. **/
  7631. AtCommandInfo atcommand_base[] = {
  7632. { "warp", 40,40, atcommand_mapmove }, // + /mm
  7633. { "where", 1,1, atcommand_where },
  7634. { "goto", 20,20, atcommand_jumpto }, // + /shift
  7635. { "jump", 40,40, atcommand_jump },
  7636. { "who", 20,20, atcommand_who },
  7637. { "who2", 20,20, atcommand_who2 },
  7638. { "who3", 20,20, atcommand_who3 },
  7639. { "whomap", 20,20, atcommand_whomap },
  7640. { "whomap2", 20,20, atcommand_whomap2 },
  7641. { "whomap3", 20,20, atcommand_whomap3 },
  7642. { "whogm", 20,20, atcommand_whogm },
  7643. { "save", 40,40, atcommand_save },
  7644. { "load", 40,40, atcommand_load },
  7645. { "speed", 40,40, atcommand_speed },
  7646. { "storage", 1,1, atcommand_storage },
  7647. { "gstorage", 50,50, atcommand_guildstorage },
  7648. { "option", 40,40, atcommand_option },
  7649. { "hide", 40,40, atcommand_hide }, // + /hide
  7650. { "job", 40,40, atcommand_jobchange },
  7651. { "die", 1,1, atcommand_die },
  7652. { "kill", 60,60, atcommand_kill },
  7653. { "alive", 60,60, atcommand_alive },
  7654. { "kami", 40,40, atcommand_kami },
  7655. { "kamib", 40,40, atcommand_kami },
  7656. { "kamic", 40,40, atcommand_kami },
  7657. { "heal", 40,60, atcommand_heal },
  7658. { "item", 60,60, atcommand_item },
  7659. { "item2", 60,60, atcommand_item2 },
  7660. { "itemreset", 40,40, atcommand_itemreset },
  7661. { "blvl", 60,60, atcommand_baselevelup },
  7662. { "jlvl", 60,60, atcommand_joblevelup },
  7663. { "help", 20,20, atcommand_help },
  7664. { "help2", 20,20, atcommand_help2 },
  7665. { "pvpoff", 40,40, atcommand_pvpoff },
  7666. { "pvpon", 40,40, atcommand_pvpon },
  7667. { "gvgoff", 40,40, atcommand_gvgoff },
  7668. { "gvgon", 40,40, atcommand_gvgon },
  7669. { "model", 20,20, atcommand_model },
  7670. { "go", 10,10, atcommand_go },
  7671. { "monster", 50,50, atcommand_monster },
  7672. { "monstersmall", 50,50, atcommand_monstersmall },
  7673. { "monsterbig", 50,50, atcommand_monsterbig },
  7674. { "killmonster", 60,60, atcommand_killmonster },
  7675. { "killmonster2", 40,40, atcommand_killmonster2 },
  7676. { "refine", 60,60, atcommand_refine },
  7677. { "produce", 60,60, atcommand_produce },
  7678. { "memo", 40,40, atcommand_memo },
  7679. { "gat", 99,99, atcommand_gat },
  7680. { "displaystatus", 99,99, atcommand_displaystatus },
  7681. { "stpoint", 60,60, atcommand_statuspoint },
  7682. { "skpoint", 60,60, atcommand_skillpoint },
  7683. { "zeny", 60,60, atcommand_zeny },
  7684. { "str", 60,60, atcommand_param },
  7685. { "agi", 60,60, atcommand_param },
  7686. { "vit", 60,60, atcommand_param },
  7687. { "int", 60,60, atcommand_param },
  7688. { "dex", 60,60, atcommand_param },
  7689. { "luk", 60,60, atcommand_param },
  7690. { "glvl", 60,60, atcommand_guildlevelup },
  7691. { "makeegg", 60,60, atcommand_makeegg },
  7692. { "hatch", 60,60, atcommand_hatch },
  7693. { "petfriendly", 40,40, atcommand_petfriendly },
  7694. { "pethungry", 40,40, atcommand_pethungry },
  7695. { "petrename", 1,1, atcommand_petrename },
  7696. { "recall", 60,60, atcommand_recall }, // + /recall
  7697. { "night", 80,80, atcommand_night },
  7698. { "day", 80,80, atcommand_day },
  7699. { "doom", 80,80, atcommand_doom },
  7700. { "doommap", 80,80, atcommand_doommap },
  7701. { "raise", 80,80, atcommand_raise },
  7702. { "raisemap", 80,80, atcommand_raisemap },
  7703. { "kick", 20,20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7704. { "kickall", 99,99, atcommand_kickall },
  7705. { "allskill", 60,60, atcommand_allskill },
  7706. { "questskill", 40,40, atcommand_questskill },
  7707. { "lostskill", 40,40, atcommand_lostskill },
  7708. { "spiritball", 40,40, atcommand_spiritball },
  7709. { "party", 1,1, atcommand_party },
  7710. { "guild", 50,50, atcommand_guild },
  7711. { "agitstart", 60,60, atcommand_agitstart },
  7712. { "agitend", 60,60, atcommand_agitend },
  7713. { "mapexit", 99,99, atcommand_mapexit },
  7714. { "idsearch", 60,60, atcommand_idsearch },
  7715. { "broadcast", 40,40, atcommand_broadcast }, // + /b and /nb
  7716. { "localbroadcast", 40,40, atcommand_localbroadcast }, // + /lb and /nlb
  7717. { "recallall", 80,80, atcommand_recallall },
  7718. { "reloaditemdb", 99,99, atcommand_reloaditemdb },
  7719. { "reloadmobdb", 99,99, atcommand_reloadmobdb },
  7720. { "reloadskilldb", 99,99, atcommand_reloadskilldb },
  7721. { "reloadscript", 99,99, atcommand_reloadscript },
  7722. { "reloadatcommand", 99,99, atcommand_reloadatcommand },
  7723. { "reloadbattleconf", 99,99, atcommand_reloadbattleconf },
  7724. { "reloadstatusdb", 99,99, atcommand_reloadstatusdb },
  7725. { "reloadpcdb", 99,99, atcommand_reloadpcdb },
  7726. { "reloadmotd", 99,99, atcommand_reloadmotd },
  7727. { "mapinfo", 99,99, atcommand_mapinfo },
  7728. { "dye", 40,40, atcommand_dye },
  7729. { "hairstyle", 40,40, atcommand_hair_style },
  7730. { "haircolor", 40,40, atcommand_hair_color },
  7731. { "allstats", 60,60, atcommand_stat_all },
  7732. { "block", 60,60, atcommand_char_block },
  7733. { "ban", 60,60, atcommand_char_ban },
  7734. { "unblock", 60,60, atcommand_char_unblock },
  7735. { "unban", 60,60, atcommand_char_unban },
  7736. { "mount", 20,20, atcommand_mount_peco },
  7737. { "guildspy", 60,60, atcommand_guildspy },
  7738. { "partyspy", 60,60, atcommand_partyspy },
  7739. { "repairall", 60,60, atcommand_repairall },
  7740. { "guildrecall", 60,60, atcommand_guildrecall },
  7741. { "partyrecall", 60,60, atcommand_partyrecall },
  7742. { "nuke", 60,60, atcommand_nuke },
  7743. { "shownpc", 80,80, atcommand_shownpc },
  7744. { "hidenpc", 80,80, atcommand_hidenpc },
  7745. { "loadnpc", 80,80, atcommand_loadnpc },
  7746. { "unloadnpc", 80,80, atcommand_unloadnpc },
  7747. { "time", 1,1, atcommand_servertime },
  7748. { "jail", 60,60, atcommand_jail },
  7749. { "unjail", 60,60, atcommand_unjail },
  7750. { "jailfor", 60,60, atcommand_jailfor },
  7751. { "jailtime", 1,1, atcommand_jailtime },
  7752. { "disguise", 20,20, atcommand_disguise },
  7753. { "undisguise", 20,20, atcommand_undisguise },
  7754. { "email", 1,1, atcommand_email },
  7755. { "effect", 40,40, atcommand_effect },
  7756. { "follow", 20,20, atcommand_follow },
  7757. { "addwarp", 60,60, atcommand_addwarp },
  7758. { "skillon", 80,80, atcommand_skillon },
  7759. { "skilloff", 80,80, atcommand_skilloff },
  7760. { "killer", 60,60, atcommand_killer },
  7761. { "npcmove", 80,80, atcommand_npcmove },
  7762. { "killable", 40,40, atcommand_killable },
  7763. { "dropall", 40,40, atcommand_dropall },
  7764. { "storeall", 40,40, atcommand_storeall },
  7765. { "skillid", 40,40, atcommand_skillid },
  7766. { "useskill", 40,40, atcommand_useskill },
  7767. { "displayskill", 99,99, atcommand_displayskill },
  7768. { "snow", 99,99, atcommand_snow },
  7769. { "sakura", 99,99, atcommand_sakura },
  7770. { "clouds", 99,99, atcommand_clouds },
  7771. { "clouds2", 99,99, atcommand_clouds2 },
  7772. { "fog", 99,99, atcommand_fog },
  7773. { "fireworks", 99,99, atcommand_fireworks },
  7774. { "leaves", 99,99, atcommand_leaves },
  7775. { "summon", 60,60, atcommand_summon },
  7776. { "adjgmlvl", 99,99, atcommand_adjgmlvl },
  7777. { "adjcmdlvl", 99,99, atcommand_adjcmdlvl },
  7778. { "trade", 60,60, atcommand_trade },
  7779. { "send", 99,99, atcommand_send },
  7780. { "setbattleflag", 99,99, atcommand_setbattleflag },
  7781. { "unmute", 80,80, atcommand_unmute },
  7782. { "clearweather", 99,99, atcommand_clearweather },
  7783. { "uptime", 1,1, atcommand_uptime },
  7784. { "changesex", 60,60, atcommand_changesex },
  7785. { "mute", 80,80, atcommand_mute },
  7786. { "refresh", 1,1, atcommand_refresh },
  7787. { "identify", 40,40, atcommand_identify },
  7788. { "gmotd", 20,20, atcommand_gmotd },
  7789. { "misceffect", 50,50, atcommand_misceffect },
  7790. { "mobsearch", 10,10, atcommand_mobsearch },
  7791. { "cleanmap", 40,40, atcommand_cleanmap },
  7792. { "npctalk", 20,20, atcommand_npctalk },
  7793. { "pettalk", 10,10, atcommand_pettalk },
  7794. { "users", 40,40, atcommand_users },
  7795. { "reset", 40,40, atcommand_reset },
  7796. { "skilltree", 40,40, atcommand_skilltree },
  7797. { "marry", 40,40, atcommand_marry },
  7798. { "divorce", 40,40, atcommand_divorce },
  7799. { "sound", 40,40, atcommand_sound },
  7800. { "undisguiseall", 99,99, atcommand_undisguiseall },
  7801. { "disguiseall", 99,99, atcommand_disguiseall },
  7802. { "changelook", 60,60, atcommand_changelook },
  7803. { "autoloot", 10,10, atcommand_autoloot },
  7804. { "alootid", 10,10, atcommand_autolootitem },
  7805. { "monsterinfo", 1,1, atcommand_mobinfo },
  7806. { "exp", 1,1, atcommand_exp },
  7807. { "adopt", 40,40, atcommand_adopt },
  7808. { "version", 1,1, atcommand_version },
  7809. { "mutearea", 99,99, atcommand_mutearea },
  7810. { "rates", 1,1, atcommand_rates },
  7811. { "iteminfo", 1,1, atcommand_iteminfo },
  7812. { "whodrops", 1,1, atcommand_whodrops },
  7813. { "whereis", 10,10, atcommand_whereis },
  7814. { "mapflag", 99,99, atcommand_mapflag },
  7815. { "me", 20,20, atcommand_me },
  7816. { "battleignore", 99,99, atcommand_monsterignore },
  7817. { "fakename", 20,20, atcommand_fakename },
  7818. { "size", 20,20, atcommand_size },
  7819. { "showexp", 10,10, atcommand_showexp},
  7820. { "showzeny", 10,10, atcommand_showzeny},
  7821. { "showdelay", 1,1, atcommand_showdelay},
  7822. { "autotrade", 10,10, atcommand_autotrade },
  7823. { "changegm", 10,10, atcommand_changegm },
  7824. { "changeleader", 10,10, atcommand_changeleader },
  7825. { "partyoption", 10,10, atcommand_partyoption},
  7826. { "invite", 1,1, atcommand_invite },
  7827. { "duel", 1,1, atcommand_duel },
  7828. { "leave", 1,1, atcommand_leave },
  7829. { "accept", 1,1, atcommand_accept },
  7830. { "reject", 1,1, atcommand_reject },
  7831. { "main", 1,1, atcommand_main },
  7832. { "clone", 50,50, atcommand_clone },
  7833. { "slaveclone", 50,50, atcommand_clone },
  7834. { "evilclone", 50,50, atcommand_clone },
  7835. { "tonpc", 40,40, atcommand_tonpc },
  7836. { "commands", 1,1, atcommand_commands },
  7837. { "noask", 1,1, atcommand_noask },
  7838. { "request", 20,20, atcommand_request },
  7839. { "hlvl", 60,60, atcommand_homlevel },
  7840. { "homevolve", 60,60, atcommand_homevolution },
  7841. { "makehomun", 60,60, atcommand_makehomun },
  7842. { "homfriendly", 60,60, atcommand_homfriendly },
  7843. { "homhungry", 60,60, atcommand_homhungry },
  7844. { "homtalk", 10,10, atcommand_homtalk },
  7845. { "hominfo", 1,1, atcommand_hominfo },
  7846. { "homstats", 1,1, atcommand_homstats },
  7847. { "homshuffle", 60,60, atcommand_homshuffle },
  7848. { "showmobs", 10,10, atcommand_showmobs },
  7849. { "feelreset", 10,10, atcommand_feelreset },
  7850. { "auction", 1,1, atcommand_auction },
  7851. { "mail", 1,1, atcommand_mail },
  7852. { "noks", 1,1, atcommand_ksprotection },
  7853. { "allowks", 40,40, atcommand_allowks },
  7854. { "cash", 60,60, atcommand_cash },
  7855. { "points", 60,60, atcommand_cash },
  7856. { "agitstart2", 60,60, atcommand_agitstart2 },
  7857. { "agitend2", 60,60, atcommand_agitend2 },
  7858. { "skreset", 60,60, atcommand_resetskill },
  7859. { "streset", 60,60, atcommand_resetstat },
  7860. { "storagelist", 40,40, atcommand_itemlist },
  7861. { "cartlist", 40,40, atcommand_itemlist },
  7862. { "itemlist", 40,40, atcommand_itemlist },
  7863. { "stats", 40,40, atcommand_stats },
  7864. { "delitem", 60,60, atcommand_delitem },
  7865. { "charcommands", 1,1, atcommand_charcommands },
  7866. { "font", 1,1, atcommand_font },
  7867. /**
  7868. * For Testing Purposes, not going to be here after we're done.
  7869. **/
  7870. { "newmount", 0,99, atcommand_new_mount },
  7871. };
  7872. AtCommandInfo* atcommand;
  7873. int i;
  7874. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7875. CREATE(atcommand, AtCommandInfo, 1);
  7876. safestrncpy(atcommand->command,atcommand_base[i].command,sizeof(atcommand->command));
  7877. atcommand->level = atcommand_base[i].level;
  7878. atcommand->level2 = atcommand_base[i].level2;
  7879. atcommand->func = atcommand_base[i].func;
  7880. strdb_put(atcommand_db, atcommand->command, atcommand);
  7881. }
  7882. return;
  7883. }
  7884. /*==========================================
  7885. * Command lookup functions
  7886. *------------------------------------------*/
  7887. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  7888. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  7889. if( strdb_exists(atcommand_db,name) )
  7890. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7891. return NULL;
  7892. }
  7893. /*==========================================
  7894. * Retrieve the command's required gm level
  7895. *------------------------------------------*/
  7896. int get_atcommand_level(const char* name) {
  7897. AtCommandInfo* info = (AtCommandInfo*)strdb_get(atcommand_db, name);
  7898. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7899. }
  7900. /// Executes an at-command.
  7901. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7902. {
  7903. char charname[NAME_LENGTH], params[100];
  7904. char charname2[NAME_LENGTH], params2[100];
  7905. char command[100];
  7906. char output[CHAT_SIZE_MAX];
  7907. int x, y, z;
  7908. int lv = 0;
  7909. //Reconstructed message
  7910. char atcmd_msg[CHAT_SIZE_MAX];
  7911. TBL_PC * ssd = NULL; //sd for target
  7912. AtCommandInfo * info;
  7913. nullpo_retr(false, sd);
  7914. //Shouldn't happen
  7915. if( !message || !*message )
  7916. return false;
  7917. //Block NOCHAT but do not display it as a normal message
  7918. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7919. return true;
  7920. // skip 10/11-langtype's codepage indicator, if detected
  7921. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7922. message += 3;
  7923. //Should display as a normal message
  7924. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7925. return false;
  7926. // type value 0 = server invoked: bypass restrictions
  7927. // 1 = player invoked
  7928. if( type )
  7929. {
  7930. //Commands are disabled on maps flagged as 'nocommand'
  7931. if( map[sd->bl.m].nocommand && pc_isGM(sd) < map[sd->bl.m].nocommand )
  7932. {
  7933. clif_displaymessage(fd, msg_txt(143));
  7934. return false;
  7935. }
  7936. //Displays as a normal message for Non-GMs
  7937. if( battle_config.atc_gmonly != 0 && pc_isGM(sd) == 0 )
  7938. return false;
  7939. }
  7940. while (*message == charcommand_symbol)
  7941. {
  7942. //Checks to see if #command has a name or a name + parameters.
  7943. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7944. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7945. //z always has the value of the scan that was successful
  7946. z = ( x > 1 ) ? x : y;
  7947. if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) ) {
  7948. if( pc_isGM(sd) ) {
  7949. sprintf(output, "%s failed. Player not found.", command);
  7950. clif_displaymessage(fd, output);
  7951. } else {
  7952. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7953. clif_displaymessage(fd, output);
  7954. }
  7955. return true;
  7956. }
  7957. //#command + name means the sufficient target was used and anything else after
  7958. //can be looked at by the actual command function since most scan to see if the
  7959. //right parameters are used.
  7960. if ( x > 2 ) {
  7961. sprintf(atcmd_msg, "%s %s", command, params);
  7962. break;
  7963. }
  7964. else if ( y > 2 ) {
  7965. sprintf(atcmd_msg, "%s %s", command, params2);
  7966. break;
  7967. }
  7968. //Regardless of what style the #command is used, if it's correct, it will always have
  7969. //this value if there is no parameter. Send it as just the #command
  7970. else if ( z == 2 ) {
  7971. sprintf(atcmd_msg, "%s", command);
  7972. break;
  7973. }
  7974. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7975. clif_displaymessage(fd, output);
  7976. return true;
  7977. }
  7978. if (*message == atcommand_symbol) {
  7979. //atcmd_msg is constructed above differently for charcommands
  7980. //it's copied from message if not a charcommand so it can
  7981. //pass through the rest of the code compatible with both symbols
  7982. sprintf(atcmd_msg, "%s", message);
  7983. }
  7984. //Clearing these to be used once more.
  7985. memset(command, '\0', sizeof(command));
  7986. memset(params, '\0', sizeof(params));
  7987. //check to see if any params exist within this command
  7988. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7989. params[0] = '\0';
  7990. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7991. if( (info = (AtCommandInfo*)strdb_get(atcommand_db, command+1)) == NULL || info->func == NULL || ( type && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2)) ) )
  7992. {
  7993. if( pc_isGM(sd) ) {
  7994. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7995. clif_displaymessage(fd, output);
  7996. return true;
  7997. } else
  7998. return false;
  7999. }
  8000. //Log atcommands
  8001. if( *atcmd_msg == atcommand_symbol )
  8002. log_atcommand(sd, info->level, atcmd_msg);
  8003. //Log Charcommands
  8004. else if( *atcmd_msg == charcommand_symbol && ssd != NULL )
  8005. log_atcommand(sd, info->level2, message);
  8006. //Attempt to use the command
  8007. if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
  8008. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8009. {
  8010. sprintf(output,msg_txt(154), command); // %s failed.
  8011. clif_displaymessage(fd, output);
  8012. }
  8013. if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
  8014. return true;
  8015. }
  8016. /**
  8017. * Splits and parses command aliases field
  8018. * Note: I'm not good (at all) with string manipulation, if you think you can improve, please do. I beg you.
  8019. **/
  8020. void atcommand_parse_aliases(char aliases[1024],AtCommandInfo* base) {
  8021. char *str[99], *p;
  8022. int i, max = 0;
  8023. p = aliases;
  8024. while( ISSPACE(*p) )//trim
  8025. ++p;
  8026. //I assume nobody is getting over 98 alises in the same command lol
  8027. for( i = 0; i < 99; i++ ) {
  8028. str[i] = p;
  8029. p = strchr(p,',');
  8030. if( p == NULL ) {
  8031. max = i+1;
  8032. break;// comma not found
  8033. }
  8034. *p = '\0';
  8035. ++p;
  8036. }
  8037. if( !str[0] )//no aliases at all
  8038. return;
  8039. for(i = 0; i < max;i++) {
  8040. AtCommandInfo* atcommand = NULL;
  8041. normalize_name(str[i]," ");//trim over
  8042. if( (atcommand = strdb_get(atcommand_db, str[i])) ) {
  8043. atcommand->level = base->level;
  8044. atcommand->level2 = base->level2;
  8045. continue;
  8046. }
  8047. CREATE(atcommand, AtCommandInfo, 1);
  8048. safestrncpy(atcommand->command,str[i],sizeof(atcommand->command));
  8049. atcommand->level = base->level;
  8050. atcommand->level2 = base->level2;
  8051. atcommand->func = base->func;
  8052. strdb_put(atcommand_db, atcommand->command, atcommand);
  8053. }
  8054. return;
  8055. }
  8056. /*==========================================
  8057. *
  8058. *------------------------------------------*/
  8059. int atcommand_config_read(const char* cfgName)
  8060. {
  8061. char line[1024], w1[1024], w2[1024], w3[1024], w4[1024];
  8062. AtCommandInfo* p;
  8063. FILE* fp;
  8064. int i;
  8065. if( (fp = fopen(cfgName, "r")) == NULL ) {
  8066. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  8067. return 1;
  8068. }
  8069. while( fgets(line, sizeof(line), fp) ) {
  8070. if( line[0] == '/' && line[1] == '/' )
  8071. continue;
  8072. if( ( i = sscanf(line,"%1023[^:]:%1023[^,],%1023[^[][%1023[^]]",w1,w2,w3,w4) ) >= 3 ) {
  8073. if( ( p = (AtCommandInfo*)strdb_get(atcommand_db, w1) ) != NULL ) {
  8074. p->level = atoi(w2);//update @level
  8075. p->level2 = atoi(w3);//update #level
  8076. /**
  8077. * Parse the alises
  8078. **/
  8079. if( i == 4 )
  8080. atcommand_parse_aliases(w4,p);
  8081. continue;//we're done move on
  8082. }
  8083. } else if( strcmpi(w1, "import") != 0 && strcmpi(w1, "command_symbol") != 0 && strcmpi(w1, "char_symbol") != 0 ) {
  8084. if( i > 1 )
  8085. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  8086. continue;
  8087. }
  8088. normalize_name(w2," ");//trim
  8089. if( strcmpi(w1, "import") == 0 )
  8090. atcommand_config_read(w2);
  8091. else if( strcmpi(w1, "command_symbol") == 0 &&
  8092. w2[0] > 31 && // control characters
  8093. w2[0] != '/' && // symbol of standard ragnarok GM commands
  8094. w2[0] != '%' && // symbol of party chat speaking
  8095. w2[0] != '$' && // symbol of guild chat speaking
  8096. w2[0] != '#' ) // remote symbol
  8097. atcommand_symbol = w2[0];
  8098. else if( strcmpi(w1, "char_symbol") == 0 &&
  8099. w2[0] > 31 &&
  8100. w2[0] != '/' &&
  8101. w2[0] != '%' &&
  8102. w2[0] != '$' &&
  8103. w2[0] != '@' )
  8104. charcommand_symbol = w2[0];
  8105. }
  8106. fclose(fp);
  8107. return 0;
  8108. }
  8109. static int atcommand_db_free(DBKey key,void *data,va_list va) {
  8110. aFree((AtCommandInfo*)data);
  8111. return 1;
  8112. }
  8113. void atcommand_db_clear() {
  8114. atcommand_db->foreach(atcommand_db,atcommand_db_free);
  8115. db_destroy(atcommand_db);
  8116. return;
  8117. }
  8118. void atcommand_doload() {
  8119. if( atcommand_db != NULL )
  8120. atcommand_db_clear();
  8121. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY, 0);
  8122. atcommand_basecommands();//fills initial atcommand_db with known commands
  8123. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8124. return;
  8125. }
  8126. void do_init_atcommand() {
  8127. atcommand_doload();
  8128. }
  8129. void do_final_atcommand() {
  8130. atcommand_db_clear();
  8131. return;
  8132. }
  8133. // commands that need to go _after_ the commands table
  8134. /*==========================================
  8135. * type: 1 = commands (@), 2 = charcommands (#)
  8136. *------------------------------------------*/
  8137. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, int type) {
  8138. char line_buff[CHATBOX_SIZE];
  8139. int gm_lvl = pc_isGM(sd), count = 0;
  8140. char* cur = line_buff;
  8141. AtCommandInfo* cmd;
  8142. DBIterator* iter = atcommand_db->iterator(atcommand_db);
  8143. memset(line_buff,' ',CHATBOX_SIZE);
  8144. line_buff[CHATBOX_SIZE-1] = 0;
  8145. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  8146. for( cmd = (AtCommandInfo*)iter->first(iter,NULL); iter->exists(iter); cmd = (AtCommandInfo*)iter->next(iter,NULL) ) {
  8147. unsigned int slen;
  8148. if( type == 1 && gm_lvl < cmd->level )
  8149. continue;
  8150. if( type == 2 && gm_lvl < cmd->level2 )
  8151. continue;
  8152. slen = strlen(cmd->command);
  8153. // flush the text buffer if this command won't fit into it
  8154. if( slen + cur - line_buff >= CHATBOX_SIZE )
  8155. {
  8156. clif_displaymessage(fd,line_buff);
  8157. cur = line_buff;
  8158. memset(line_buff,' ',CHATBOX_SIZE);
  8159. line_buff[CHATBOX_SIZE-1] = 0;
  8160. }
  8161. memcpy(cur,cmd->command,slen);
  8162. cur += slen+(10-slen%10);
  8163. count++;
  8164. }
  8165. iter->destroy(iter);
  8166. clif_displaymessage(fd,line_buff);
  8167. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  8168. clif_displaymessage(fd, atcmd_output);
  8169. return;
  8170. }
  8171. /*==========================================
  8172. * @commands Lists available @ commands to you
  8173. *------------------------------------------*/
  8174. ACMD_FUNC(commands)
  8175. {
  8176. atcommand_commands_sub(sd, fd, 1);
  8177. return 0;
  8178. }
  8179. /*==========================================
  8180. * @charcommands Lists available # commands to you
  8181. *------------------------------------------*/
  8182. ACMD_FUNC(charcommands)
  8183. {
  8184. atcommand_commands_sub(sd, fd, 2);
  8185. return 0;
  8186. }