atcommand.c 256 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925
  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 "../common/conf.h"
  15. #include "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "clif.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "intif.h"
  22. #include "itemdb.h"
  23. #include "log.h"
  24. #include "map.h"
  25. #include "pc.h"
  26. #include "pc_groups.h" // groupid2name
  27. #include "status.h"
  28. #include "skill.h"
  29. #include "mob.h"
  30. #include "npc.h"
  31. #include "pet.h"
  32. #include "homunculus.h"
  33. #include "mail.h"
  34. #include "mercenary.h"
  35. #include "elemental.h"
  36. #include "party.h"
  37. #include "guild.h"
  38. #include "script.h"
  39. #include "storage.h"
  40. #include "trade.h"
  41. #include "unit.h"
  42. #include <stdio.h>
  43. #include <stdlib.h>
  44. #include <string.h>
  45. #include <math.h>
  46. #define ATCOMMAND_LENGTH 50
  47. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  48. #define MAX_MSG 1000
  49. typedef struct AtCommandInfo AtCommandInfo;
  50. typedef struct AliasInfo AliasInfo;
  51. struct AtCommandInfo {
  52. char command[ATCOMMAND_LENGTH];
  53. AtCommandFunc func;
  54. };
  55. struct AliasInfo {
  56. AtCommandInfo *command;
  57. char alias[ATCOMMAND_LENGTH];
  58. };
  59. char atcommand_symbol = '@'; // first char of the commands
  60. char charcommand_symbol = '#';
  61. static char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  62. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  63. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  64. static config_t atcommand_config;
  65. static char atcmd_output[CHAT_SIZE_MAX];
  66. static char atcmd_player_name[NAME_LENGTH];
  67. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  68. static const char* atcommand_checkalias(const char *aliasname); // @help
  69. //-----------------------------------------------------------
  70. // Return the message string of the specified number by [Yor]
  71. //-----------------------------------------------------------
  72. const char* msg_txt(int msg_number)
  73. {
  74. if (msg_number >= 0 && msg_number < MAX_MSG &&
  75. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  76. return msg_table[msg_number];
  77. return "??";
  78. }
  79. /*==========================================
  80. * Read Message Data
  81. *------------------------------------------*/
  82. int msg_config_read(const char* cfgName)
  83. {
  84. int msg_number;
  85. char line[1024], w1[1024], w2[1024];
  86. FILE *fp;
  87. static int called = 1;
  88. if ((fp = fopen(cfgName, "r")) == NULL) {
  89. ShowError("Messages file not found: %s\n", cfgName);
  90. return 1;
  91. }
  92. if ((--called) == 0)
  93. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  94. while(fgets(line, sizeof(line), fp))
  95. {
  96. if (line[0] == '/' && line[1] == '/')
  97. continue;
  98. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  99. continue;
  100. if (strcmpi(w1, "import") == 0)
  101. msg_config_read(w2);
  102. else
  103. {
  104. msg_number = atoi(w1);
  105. if (msg_number >= 0 && msg_number < MAX_MSG)
  106. {
  107. if (msg_table[msg_number] != NULL)
  108. aFree(msg_table[msg_number]);
  109. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  110. strcpy(msg_table[msg_number],w2);
  111. }
  112. }
  113. }
  114. fclose(fp);
  115. return 0;
  116. }
  117. /*==========================================
  118. * Cleanup Message Data
  119. *------------------------------------------*/
  120. void do_final_msg(void)
  121. {
  122. int i;
  123. for (i = 0; i < MAX_MSG; i++)
  124. aFree(msg_table[i]);
  125. }
  126. /*==========================================
  127. * @send (used for testing packet sends from the client)
  128. *------------------------------------------*/
  129. ACMD_FUNC(send)
  130. {
  131. int len=0,off,end,type;
  132. long num;
  133. // read message type as hex number (without the 0x)
  134. if(!message || !*message ||
  135. !((sscanf(message, "len %x", &type)==1 && (len=1))
  136. || sscanf(message, "%x", &type)==1) )
  137. {
  138. clif_displaymessage(fd, "Usage:");
  139. clif_displaymessage(fd, " @send len <packet hex number>");
  140. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  141. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  142. return -1;
  143. }
  144. #define PARSE_ERROR(error,p) \
  145. {\
  146. clif_displaymessage(fd, (error));\
  147. sprintf(atcmd_output, ">%s", (p));\
  148. clif_displaymessage(fd, atcmd_output);\
  149. }
  150. //define PARSE_ERROR
  151. #define CHECK_EOS(p) \
  152. if(*(p) == 0){\
  153. clif_displaymessage(fd, "Unexpected end of string");\
  154. return -1;\
  155. }
  156. //define CHECK_EOS
  157. #define SKIP_VALUE(p) \
  158. {\
  159. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  160. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  161. }
  162. //define SKIP_VALUE
  163. #define GET_VALUE(p,num) \
  164. {\
  165. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  166. PARSE_ERROR("Invalid number in:",(p));\
  167. return -1;\
  168. }\
  169. }
  170. //define GET_VALUE
  171. if (type > 0 && type < MAX_PACKET_DB) {
  172. if(len)
  173. {// show packet length
  174. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  175. clif_displaymessage(fd, atcmd_output);
  176. return 0;
  177. }
  178. len=packet_db[sd->packet_ver][type].len;
  179. off=2;
  180. if(len == 0)
  181. {// unknown packet - ERROR
  182. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  183. clif_displaymessage(fd, atcmd_output);
  184. return -1;
  185. } else if(len == -1)
  186. {// dynamic packet
  187. len=SHRT_MAX-4; // maximum length
  188. off=4;
  189. }
  190. WFIFOHEAD(fd, len);
  191. WFIFOW(fd,0)=TOW(type);
  192. // parse packet contents
  193. SKIP_VALUE(message);
  194. while(*message != 0 && off < len){
  195. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  196. {// default (byte)
  197. GET_VALUE(message,num);
  198. WFIFOB(fd,off)=TOB(num);
  199. ++off;
  200. } else if(TOUPPER(*message) == 'B')
  201. {// byte
  202. ++message;
  203. GET_VALUE(message,num);
  204. WFIFOB(fd,off)=TOB(num);
  205. ++off;
  206. } else if(TOUPPER(*message) == 'W')
  207. {// word (2 bytes)
  208. ++message;
  209. GET_VALUE(message,num);
  210. WFIFOW(fd,off)=TOW(num);
  211. off+=2;
  212. } else if(TOUPPER(*message) == 'L')
  213. {// long word (4 bytes)
  214. ++message;
  215. GET_VALUE(message,num);
  216. WFIFOL(fd,off)=TOL(num);
  217. off+=4;
  218. } else if(TOUPPER(*message) == 'S')
  219. {// string - escapes are valid
  220. // get string length - num <= 0 means not fixed length (default)
  221. ++message;
  222. if(*message == '"'){
  223. num=0;
  224. } else {
  225. GET_VALUE(message,num);
  226. while(*message != '"')
  227. {// find start of string
  228. if(*message == 0 || ISSPACE(*message)){
  229. PARSE_ERROR("Not a string:",message);
  230. return -1;
  231. }
  232. ++message;
  233. }
  234. }
  235. // parse string
  236. ++message;
  237. CHECK_EOS(message);
  238. end=(num<=0? 0: min(off+((int)num),len));
  239. for(; *message != '"' && (off < end || end == 0); ++off){
  240. if(*message == '\\'){
  241. ++message;
  242. CHECK_EOS(message);
  243. switch(*message){
  244. case 'a': num=0x07; break; // Bell
  245. case 'b': num=0x08; break; // Backspace
  246. case 't': num=0x09; break; // Horizontal tab
  247. case 'n': num=0x0A; break; // Line feed
  248. case 'v': num=0x0B; break; // Vertical tab
  249. case 'f': num=0x0C; break; // Form feed
  250. case 'r': num=0x0D; break; // Carriage return
  251. case 'e': num=0x1B; break; // Escape
  252. default: num=*message; break;
  253. case 'x': // Hexadecimal
  254. {
  255. ++message;
  256. CHECK_EOS(message);
  257. if(!ISXDIGIT(*message)){
  258. PARSE_ERROR("Not a hexadecimal digit:",message);
  259. return -1;
  260. }
  261. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  262. if(ISXDIGIT(*message)){
  263. ++message;
  264. CHECK_EOS(message);
  265. num<<=8;
  266. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  267. }
  268. WFIFOB(fd,off)=TOB(num);
  269. ++message;
  270. CHECK_EOS(message);
  271. continue;
  272. }
  273. case '0':
  274. case '1':
  275. case '2':
  276. case '3':
  277. case '4':
  278. case '5':
  279. case '6':
  280. case '7': // Octal
  281. {
  282. num=*message-'0'; // 1st octal digit
  283. ++message;
  284. CHECK_EOS(message);
  285. if(ISDIGIT(*message) && *message < '8'){
  286. num<<=3;
  287. num+=*message-'0'; // 2nd octal digit
  288. ++message;
  289. CHECK_EOS(message);
  290. if(ISDIGIT(*message) && *message < '8'){
  291. num<<=3;
  292. num+=*message-'0'; // 3rd octal digit
  293. ++message;
  294. CHECK_EOS(message);
  295. }
  296. }
  297. WFIFOB(fd,off)=TOB(num);
  298. continue;
  299. }
  300. }
  301. } else
  302. num=*message;
  303. WFIFOB(fd,off)=TOB(num);
  304. ++message;
  305. CHECK_EOS(message);
  306. }//for
  307. while(*message != '"')
  308. {// ignore extra characters
  309. ++message;
  310. CHECK_EOS(message);
  311. }
  312. // terminate the string
  313. if(off < end)
  314. {// fill the rest with 0's
  315. memset(WFIFOP(fd,off),0,end-off);
  316. off=end;
  317. }
  318. } else
  319. {// unknown
  320. PARSE_ERROR("Unknown type of value in:",message);
  321. return -1;
  322. }
  323. SKIP_VALUE(message);
  324. }
  325. if(packet_db[sd->packet_ver][type].len == -1)
  326. {// send dynamic packet
  327. WFIFOW(fd,2)=TOW(off);
  328. WFIFOSET(fd,off);
  329. } else
  330. {// send static packet
  331. if(off < len)
  332. memset(WFIFOP(fd,off),0,len-off);
  333. WFIFOSET(fd,len);
  334. }
  335. } else {
  336. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  337. return -1;
  338. }
  339. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  340. clif_displaymessage(fd, atcmd_output);
  341. return 0;
  342. #undef PARSE_ERROR
  343. #undef CHECK_EOS
  344. #undef SKIP_VALUE
  345. #undef GET_VALUE
  346. }
  347. /*==========================================
  348. * @rura, @warp, @mapmove
  349. *------------------------------------------*/
  350. ACMD_FUNC(mapmove)
  351. {
  352. char map_name[MAP_NAME_LENGTH_EXT];
  353. unsigned short mapindex;
  354. short x = 0, y = 0;
  355. int m = -1;
  356. nullpo_retr(-1, sd);
  357. memset(map_name, '\0', sizeof(map_name));
  358. if (!message || !*message ||
  359. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  360. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  361. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  362. return -1;
  363. }
  364. mapindex = mapindex_name2id(map_name);
  365. if (mapindex)
  366. m = map_mapindex2mapid(mapindex);
  367. if (!mapindex) { // m < 0 means on different server! [Kevin]
  368. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  369. return -1;
  370. }
  371. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  372. { //This is to prevent the pc_setpos call from printing an error.
  373. clif_displaymessage(fd, msg_txt(2));
  374. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  375. x = y = 0; //Invalid cell, use random spot.
  376. }
  377. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  378. clif_displaymessage(fd, msg_txt(247));
  379. return -1;
  380. }
  381. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  382. clif_displaymessage(fd, msg_txt(248));
  383. return -1;
  384. }
  385. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  386. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  387. return -1;
  388. }
  389. clif_displaymessage(fd, msg_txt(0)); // Warped.
  390. return 0;
  391. }
  392. /*==========================================
  393. * Displays where a character is. Corrected version by Silent. [Skotlex]
  394. *------------------------------------------*/
  395. ACMD_FUNC(where)
  396. {
  397. struct map_session_data* pl_sd;
  398. nullpo_retr(-1, sd);
  399. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  400. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  401. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  402. return -1;
  403. }
  404. pl_sd = map_nick2sd(atcmd_player_name);
  405. if (pl_sd == NULL ||
  406. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  407. (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  408. ) {
  409. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  410. return -1;
  411. }
  412. 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);
  413. clif_displaymessage(fd, atcmd_output);
  414. return 0;
  415. }
  416. /*==========================================
  417. *
  418. *------------------------------------------*/
  419. ACMD_FUNC(jumpto)
  420. {
  421. struct map_session_data *pl_sd = NULL;
  422. nullpo_retr(-1, sd);
  423. if (!message || !*message) {
  424. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  425. return -1;
  426. }
  427. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  428. {
  429. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  430. return -1;
  431. }
  432. if (pl_sd == sd)
  433. {
  434. clif_displaymessage(fd, "But you are already where you are...");
  435. return -1;
  436. }
  437. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  438. {
  439. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  440. return -1;
  441. }
  442. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  443. {
  444. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  445. return -1;
  446. }
  447. if( pc_isdead(sd) )
  448. {
  449. clif_displaymessage(fd, "You cannot use this command when dead.");
  450. return -1;
  451. }
  452. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  453. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  454. clif_displaymessage(fd, atcmd_output);
  455. return 0;
  456. }
  457. /*==========================================
  458. *
  459. *------------------------------------------*/
  460. ACMD_FUNC(jump)
  461. {
  462. short x = 0, y = 0;
  463. nullpo_retr(-1, sd);
  464. memset(atcmd_output, '\0', sizeof(atcmd_output));
  465. sscanf(message, "%hd %hd", &x, &y);
  466. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  467. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  468. return -1;
  469. }
  470. if( pc_isdead(sd) )
  471. {
  472. clif_displaymessage(fd, "You cannot use this command when dead.");
  473. return -1;
  474. }
  475. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  476. { //This is to prevent the pc_setpos call from printing an error.
  477. clif_displaymessage(fd, msg_txt(2));
  478. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  479. x = y = 0; //Invalid cell, use random spot.
  480. }
  481. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  482. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  483. clif_displaymessage(fd, atcmd_output);
  484. return 0;
  485. }
  486. /*==========================================
  487. * Display list of online characters with
  488. * various info.
  489. *------------------------------------------*/
  490. ACMD_FUNC(who)
  491. {
  492. struct map_session_data *pl_sd = NULL;
  493. struct s_mapiterator *iter = NULL;
  494. char map_name[MAP_NAME_LENGTH_EXT] = "";
  495. char player_name[NAME_LENGTH] = "";
  496. int count = 0;
  497. int level = 0;
  498. StringBuf buf;
  499. /**
  500. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  501. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  502. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  503. */
  504. int display_type = 1;
  505. int map_id = -1;
  506. nullpo_retr(-1, sd);
  507. if (strstr(command, "map") != NULL) {
  508. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  509. map_id = sd->bl.m;
  510. } else {
  511. sscanf(message, "%23s", player_name);
  512. }
  513. if (strstr(command, "2") != NULL)
  514. display_type = 2;
  515. else if (strstr(command, "3") != NULL)
  516. display_type = 3;
  517. level = pc_get_group_level(sd);
  518. StringBuf_Init(&buf);
  519. iter = mapit_getallusers();
  520. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  521. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  522. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  523. || (map_id >= 0 && pl_sd->bl.m != map_id))
  524. continue;
  525. switch (display_type) {
  526. case 2: {
  527. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  528. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  529. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  530. StringBuf_Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level,
  531. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  532. break;
  533. }
  534. case 3: {
  535. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  536. StringBuf_Printf(&buf, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  537. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  538. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  539. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  540. StringBuf_Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  541. break;
  542. }
  543. default: {
  544. struct party_data *p = party_search(pl_sd->status.party_id);
  545. struct guild *g = guild_search(pl_sd->status.guild_id);
  546. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  547. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  548. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  549. if (p != NULL)
  550. StringBuf_Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'"
  551. if (g != NULL)
  552. StringBuf_Printf(&buf, msg_txt(346), g->name); // " | Guild: '%s'"
  553. break;
  554. }
  555. }
  556. clif_displaymessage(fd, StringBuf_Value(&buf));
  557. StringBuf_Clear(&buf);
  558. count++;
  559. }
  560. }
  561. mapit_free(iter);
  562. if (map_id < 0) {
  563. if (count == 0)
  564. StringBuf_Printf(&buf, msg_txt(28)); // No player found.
  565. else if (count == 1)
  566. StringBuf_Printf(&buf, msg_txt(29)); // 1 player found.
  567. else
  568. StringBuf_Printf(&buf, msg_txt(30), count); // %d players found.
  569. } else {
  570. if (count == 0)
  571. StringBuf_Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  572. else if (count == 1)
  573. StringBuf_Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  574. else
  575. StringBuf_Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  576. }
  577. clif_displaymessage(fd, StringBuf_Value(&buf));
  578. StringBuf_Destroy(&buf);
  579. return 0;
  580. }
  581. /*==========================================
  582. *
  583. *------------------------------------------*/
  584. ACMD_FUNC(whogm)
  585. {
  586. struct map_session_data* pl_sd;
  587. struct s_mapiterator* iter;
  588. int j, count;
  589. int pl_level, level;
  590. char match_text[CHAT_SIZE_MAX];
  591. char player_name[NAME_LENGTH];
  592. struct guild *g;
  593. struct party_data *p;
  594. nullpo_retr(-1, sd);
  595. memset(atcmd_output, '\0', sizeof(atcmd_output));
  596. memset(match_text, '\0', sizeof(match_text));
  597. memset(player_name, '\0', sizeof(player_name));
  598. if (sscanf(message, "%199[^\n]", match_text) < 1)
  599. strcpy(match_text, "");
  600. for (j = 0; match_text[j]; j++)
  601. match_text[j] = TOLOWER(match_text[j]);
  602. count = 0;
  603. level = pc_get_group_level(sd);
  604. iter = mapit_getallusers();
  605. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  606. {
  607. pl_level = pc_get_group_level(pl_sd);
  608. if (!pl_level)
  609. continue;
  610. if (match_text[0])
  611. {
  612. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  613. for (j = 0; player_name[j]; j++)
  614. player_name[j] = TOLOWER(player_name[j]);
  615. // search with no case sensitive
  616. if (strstr(player_name, match_text) == NULL)
  617. continue;
  618. }
  619. if (pl_level > level) {
  620. if (pl_sd->sc.option & OPTION_INVISIBLE)
  621. continue;
  622. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  623. clif_displaymessage(fd, atcmd_output);
  624. count++;
  625. continue;
  626. }
  627. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  628. pl_sd->status.name, pl_level,
  629. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  630. clif_displaymessage(fd, atcmd_output);
  631. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  632. pl_sd->status.base_level,
  633. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  634. clif_displaymessage(fd, atcmd_output);
  635. p = party_search(pl_sd->status.party_id);
  636. g = guild_search(pl_sd->status.guild_id);
  637. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  638. p?p->party.name:"None", g?g->name:"None");
  639. clif_displaymessage(fd, atcmd_output);
  640. count++;
  641. }
  642. mapit_free(iter);
  643. if (count == 0)
  644. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  645. else if (count == 1)
  646. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  647. else {
  648. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  649. clif_displaymessage(fd, atcmd_output);
  650. }
  651. return 0;
  652. }
  653. /*==========================================
  654. *
  655. *------------------------------------------*/
  656. ACMD_FUNC(save)
  657. {
  658. nullpo_retr(-1, sd);
  659. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  660. if (sd->status.pet_id > 0 && sd->pd)
  661. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  662. chrif_save(sd,0);
  663. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  664. return 0;
  665. }
  666. /*==========================================
  667. *
  668. *------------------------------------------*/
  669. ACMD_FUNC(load)
  670. {
  671. int m;
  672. nullpo_retr(-1, sd);
  673. m = map_mapindex2mapid(sd->status.save_point.map);
  674. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  675. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  676. return -1;
  677. }
  678. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  679. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  680. return -1;
  681. }
  682. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  683. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  684. return 0;
  685. }
  686. /*==========================================
  687. *
  688. *------------------------------------------*/
  689. ACMD_FUNC(speed)
  690. {
  691. int speed;
  692. nullpo_retr(-1, sd);
  693. memset(atcmd_output, '\0', sizeof(atcmd_output));
  694. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  695. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  696. clif_displaymessage(fd, atcmd_output);
  697. return -1;
  698. }
  699. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  700. status_calc_bl(&sd->bl, SCB_SPEED);
  701. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  702. return 0;
  703. }
  704. /*==========================================
  705. *
  706. *------------------------------------------*/
  707. ACMD_FUNC(storage)
  708. {
  709. nullpo_retr(-1, sd);
  710. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  711. return -1;
  712. if (storage_storageopen(sd) == 1)
  713. { //Already open.
  714. clif_displaymessage(fd, msg_txt(250));
  715. return -1;
  716. }
  717. clif_displaymessage(fd, "Storage opened.");
  718. return 0;
  719. }
  720. /*==========================================
  721. *
  722. *------------------------------------------*/
  723. ACMD_FUNC(guildstorage)
  724. {
  725. nullpo_retr(-1, sd);
  726. if (!sd->status.guild_id) {
  727. clif_displaymessage(fd, msg_txt(252));
  728. return -1;
  729. }
  730. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  731. return -1;
  732. if (sd->state.storage_flag == 1) {
  733. clif_displaymessage(fd, msg_txt(250));
  734. return -1;
  735. }
  736. if (sd->state.storage_flag == 2) {
  737. clif_displaymessage(fd, msg_txt(251));
  738. return -1;
  739. }
  740. storage_guild_storageopen(sd);
  741. clif_displaymessage(fd, "Guild storage opened.");
  742. return 0;
  743. }
  744. /*==========================================
  745. *
  746. *------------------------------------------*/
  747. ACMD_FUNC(option)
  748. {
  749. int param1 = 0, param2 = 0, param3 = 0;
  750. nullpo_retr(-1, sd);
  751. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  752. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  753. return -1;
  754. }
  755. sd->sc.opt1 = param1;
  756. sd->sc.opt2 = param2;
  757. pc_setoption(sd, param3);
  758. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  759. return 0;
  760. }
  761. /*==========================================
  762. *
  763. *------------------------------------------*/
  764. ACMD_FUNC(hide)
  765. {
  766. nullpo_retr(-1, sd);
  767. if (sd->sc.option & OPTION_INVISIBLE) {
  768. sd->sc.option &= ~OPTION_INVISIBLE;
  769. if (sd->disguise)
  770. status_set_viewdata(&sd->bl, sd->disguise);
  771. else
  772. status_set_viewdata(&sd->bl, sd->status.class_);
  773. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  774. // increment the number of pvp players on the map
  775. map[sd->bl.m].users_pvp++;
  776. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  777. {// register the player for ranking calculations
  778. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  779. }
  780. //bugreport:2266
  781. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  782. } else {
  783. sd->sc.option |= OPTION_INVISIBLE;
  784. sd->vd.class_ = INVISIBLE_CLASS;
  785. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  786. // decrement the number of pvp players on the map
  787. map[sd->bl.m].users_pvp--;
  788. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  789. {// unregister the player for ranking
  790. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  791. sd->pvp_timer = INVALID_TIMER;
  792. }
  793. }
  794. clif_changeoption(&sd->bl);
  795. return 0;
  796. }
  797. /*==========================================
  798. * Changes a character's class
  799. *------------------------------------------*/
  800. ACMD_FUNC(jobchange)
  801. {
  802. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  803. int job = 0, upper = 0;
  804. nullpo_retr(-1, sd);
  805. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  806. {
  807. int i, found = 0;
  808. const struct { char name[24]; int id; } jobs[] = {
  809. { "novice", 0 },
  810. { "swordman", 1 },
  811. { "swordsman", 1 },
  812. { "magician", 2 },
  813. { "mage", 2 },
  814. { "archer", 3 },
  815. { "acolyte", 4 },
  816. { "merchant", 5 },
  817. { "thief", 6 },
  818. { "knight", 7 },
  819. { "priest", 8 },
  820. { "priestess", 8 },
  821. { "wizard", 9 },
  822. { "blacksmith", 10 },
  823. { "hunter", 11 },
  824. { "assassin", 12 },
  825. { "crusader", 14 },
  826. { "monk", 15 },
  827. { "sage", 16 },
  828. { "rogue", 17 },
  829. { "alchemist", 18 },
  830. { "bard", 19 },
  831. { "dancer", 20 },
  832. { "super novice", 23 },
  833. { "supernovice", 23 },
  834. { "gunslinger", 24 },
  835. { "gunner", 24 },
  836. { "ninja", 25 },
  837. { "novice high", 4001 },
  838. { "high novice", 4001 },
  839. { "swordman high", 4002 },
  840. { "swordsman high", 4002 },
  841. { "magician high", 4003 },
  842. { "mage high", 4003 },
  843. { "archer high", 4004 },
  844. { "acolyte high", 4005 },
  845. { "merchant high", 4006 },
  846. { "thief high", 4007 },
  847. { "lord knight", 4008 },
  848. { "high priest", 4009 },
  849. { "high priestess", 4009 },
  850. { "high wizard", 4010 },
  851. { "whitesmith", 4011 },
  852. { "sniper", 4012 },
  853. { "assassin cross", 4013 },
  854. { "paladin", 4015 },
  855. { "champion", 4016 },
  856. { "professor", 4017 },
  857. { "stalker", 4018 },
  858. { "creator", 4019 },
  859. { "clown", 4020 },
  860. { "gypsy", 4021 },
  861. { "baby novice", 4023 },
  862. { "baby swordman", 4024 },
  863. { "baby swordsman", 4024 },
  864. { "baby magician", 4025 },
  865. { "baby mage", 4025 },
  866. { "baby archer", 4026 },
  867. { "baby acolyte", 4027 },
  868. { "baby merchant", 4028 },
  869. { "baby thief", 4029 },
  870. { "baby knight", 4030 },
  871. { "baby priest", 4031 },
  872. { "baby priestess", 4031 },
  873. { "baby wizard", 4032 },
  874. { "baby blacksmith",4033 },
  875. { "baby hunter", 4034 },
  876. { "baby assassin", 4035 },
  877. { "baby crusader", 4037 },
  878. { "baby monk", 4038 },
  879. { "baby sage", 4039 },
  880. { "baby rogue", 4040 },
  881. { "baby alchemist", 4041 },
  882. { "baby bard", 4042 },
  883. { "baby dancer", 4043 },
  884. { "super baby", 4045 },
  885. { "taekwon", 4046 },
  886. { "taekwon boy", 4046 },
  887. { "taekwon girl", 4046 },
  888. { "star gladiator", 4047 },
  889. { "soul linker", 4049 },
  890. { "gangsi", 4050 },
  891. { "bongun", 4050 },
  892. { "munak", 4050 },
  893. { "death knight", 4051 },
  894. { "dark collector", 4052 },
  895. { "rune knight", 4054 },
  896. { "warlock", 4055 },
  897. { "ranger", 4056 },
  898. { "arch bishop", 4057 },
  899. { "mechanic", 4058 },
  900. { "guillotine", 4059 },
  901. { "rune knight2", 4060 },
  902. { "warlock2", 4061 },
  903. { "ranger2", 4062 },
  904. { "arch bishop2", 4063 },
  905. { "mechanic2", 4064 },
  906. { "guillotine2", 4065 },
  907. { "royal guard", 4066 },
  908. { "sorcerer", 4067 },
  909. { "minstrel", 4068 },
  910. { "wanderer", 4069 },
  911. { "sura", 4070 },
  912. { "genetic", 4071 },
  913. { "shadow chaser", 4072 },
  914. { "royal guard2", 4073 },
  915. { "sorcerer2", 4074 },
  916. { "minstrel2", 4075 },
  917. { "wanderer2", 4076 },
  918. { "sura2", 4077 },
  919. { "genetic2", 4078 },
  920. { "shadow chaser2", 4079 },
  921. { "baby rune", 4096 },
  922. { "baby warlock", 4097 },
  923. { "baby ranger", 4098 },
  924. { "baby bishop", 4099 },
  925. { "baby mechanic", 4100 },
  926. { "baby cross", 4101 },
  927. { "baby guard", 4102 },
  928. { "baby sorcerer", 4103 },
  929. { "baby minstrel", 4104 },
  930. { "baby wanderer", 4105 },
  931. { "baby sura", 4106 },
  932. { "baby genetic", 4107 },
  933. { "baby chaser", 4108 },
  934. { "super novice e", 4190 },
  935. { "super baby e", 4191 },
  936. { "kagerou", 4211 },
  937. { "oboro", 4212 },
  938. };
  939. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  940. if (strncmpi(message, jobs[i].name, 16) == 0) {
  941. job = jobs[i].id;
  942. upper = 0;
  943. found = 1;
  944. break;
  945. }
  946. }
  947. if (!found) {
  948. clif_displaymessage(fd, "Please, enter a job ID (usage: @job/@jobchange <job name/ID>).");
  949. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  950. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Magician 3 Archer");
  951. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  952. clif_displaymessage(fd, "----- 2nd Class -----");
  953. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  954. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  955. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  956. clif_displaymessage(fd, " 20 Dancer");
  957. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  958. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Magician High 4004 Archer High");
  959. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  960. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  961. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  962. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  963. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  964. clif_displaymessage(fd, "4021 Gypsy");
  965. clif_displaymessage(fd, "----- 3rd Class (Regular) -----");
  966. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  967. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  968. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  969. clif_displaymessage(fd, "4072 Shadow Chaser");
  970. clif_displaymessage(fd, "----- 3rd Class (Transcendent) -----");
  971. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  972. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  973. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  974. clif_displaymessage(fd, "4079 Shadow Chaser");
  975. clif_displaymessage(fd, "----- Expanded Class -----");
  976. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 4045 Super Baby");
  977. clif_displaymessage(fd, "4046 Taekwon 4047 Star Gladiator 4049 Soul Linker 4050 Gangsi");
  978. clif_displaymessage(fd, "4051 Death Knight 4052 Dark Collector 4190 Ex. Super Novice 4191 Ex. Super Baby");
  979. clif_displaymessage(fd, "4211 Kagerou 4212 Oboro");
  980. clif_displaymessage(fd, "----- Baby Novice And Baby 1st Class -----");
  981. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordman 4025 Baby Magician 4026 Baby Archer");
  982. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief");
  983. clif_displaymessage(fd, "---- Baby 2nd Class ----");
  984. clif_displaymessage(fd, "4030 Baby Knight 4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith");
  985. clif_displaymessage(fd, "4034 Baby Hunter 4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk");
  986. clif_displaymessage(fd, "4039 Baby Sage 4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard");
  987. clif_displaymessage(fd, "4043 Baby Dancer");
  988. clif_displaymessage(fd, "---- Baby 3rd Class ----");
  989. clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger 4099 Baby Arch Bishop");
  990. clif_displaymessage(fd, "4100 Baby Mechanic 4101 Baby Glt. Cross 4102 Baby Royal Guard 4103 Baby Sorcerer");
  991. clif_displaymessage(fd, "4104 Baby Minstrel 4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  992. clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  993. //clif_displaymessage(fd, "---- Modes And Others ----");
  994. //clif_displaymessage(fd, " 22 Wedding 26 Christmas 27 Summer 4048 Star Gladiator (Union)");
  995. return -1;
  996. }
  997. }
  998. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27 || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  999. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  1000. ) // Deny direct transformation into dummy jobs
  1001. {clif_displaymessage(fd, "You can not change to this job by command.");
  1002. return 0;}
  1003. if (pcdb_checkid(job))
  1004. {
  1005. if (pc_jobchange(sd, job, upper) == 0)
  1006. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1007. else {
  1008. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1009. return -1;
  1010. }
  1011. } else {
  1012. clif_displaymessage(fd, "Please enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1013. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1014. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Magician 3 Archer");
  1015. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1016. clif_displaymessage(fd, "----- 2nd Class -----");
  1017. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1018. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1019. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1020. clif_displaymessage(fd, " 20 Dancer");
  1021. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1022. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Magician High 4004 Archer High");
  1023. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1024. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1025. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1026. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1027. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1028. clif_displaymessage(fd, "4021 Gypsy");
  1029. clif_displaymessage(fd, "----- 3rd Class (Regular) -----");
  1030. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1031. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1032. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1033. clif_displaymessage(fd, "4072 Shadow Chaser");
  1034. clif_displaymessage(fd, "----- 3rd Class (Transcendent) -----");
  1035. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1036. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1037. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1038. clif_displaymessage(fd, "4079 Shadow Chaser");
  1039. clif_displaymessage(fd, "----- Expanded Class -----");
  1040. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 4045 Super Baby");
  1041. clif_displaymessage(fd, "4046 Taekwon 4047 Star Gladiator 4049 Soul Linker 4050 Gangsi");
  1042. clif_displaymessage(fd, "4051 Death Knight 4052 Dark Collector 4190 Ex. Super Novice 4191 Ex. Super Baby");
  1043. clif_displaymessage(fd, "4211 Kagerou 4212 Oboro");
  1044. clif_displaymessage(fd, "----- Baby Novice And Baby 1st Class -----");
  1045. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordman 4025 Baby Magician 4026 Baby Archer");
  1046. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief");
  1047. clif_displaymessage(fd, "---- Baby 2nd Class ----");
  1048. clif_displaymessage(fd, "4030 Baby Knight 4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith");
  1049. clif_displaymessage(fd, "4034 Baby Hunter 4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk");
  1050. clif_displaymessage(fd, "4039 Baby Sage 4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard");
  1051. clif_displaymessage(fd, "4043 Baby Dancer");
  1052. clif_displaymessage(fd, "---- Baby 3rd Class ----");
  1053. clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger 4099 Baby Arch Bishop");
  1054. clif_displaymessage(fd, "4100 Baby Mechanic 4101 Baby Glt. Cross 4102 Baby Royal Guard 4103 Baby Sorcerer");
  1055. clif_displaymessage(fd, "4104 Baby Minstrel 4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1056. clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1057. //clif_displaymessage(fd, "---- Modes And Others ----");
  1058. //clif_displaymessage(fd, " 22 Wedding 26 Christmas 27 Summer 4048 Star Gladiator (Union)");
  1059. return -1;
  1060. }
  1061. return 0;
  1062. }
  1063. /*==========================================
  1064. *
  1065. *------------------------------------------*/
  1066. ACMD_FUNC(kill)
  1067. {
  1068. nullpo_retr(-1, sd);
  1069. status_kill(&sd->bl);
  1070. clif_displaymessage(sd->fd, msg_txt(13)); // A pity! You've died.
  1071. if (fd != sd->fd)
  1072. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1073. return 0;
  1074. }
  1075. /*==========================================
  1076. *
  1077. *------------------------------------------*/
  1078. ACMD_FUNC(alive)
  1079. {
  1080. nullpo_retr(-1, sd);
  1081. if (!status_revive(&sd->bl, 100, 100))
  1082. {
  1083. clif_displaymessage(fd, "You're not dead.");
  1084. return -1;
  1085. }
  1086. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1087. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1088. return 0;
  1089. }
  1090. /*==========================================
  1091. * +kamic [LuzZza]
  1092. *------------------------------------------*/
  1093. ACMD_FUNC(kami)
  1094. {
  1095. unsigned long color=0;
  1096. nullpo_retr(-1, sd);
  1097. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1098. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1099. if (!message || !*message) {
  1100. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1101. return -1;
  1102. }
  1103. sscanf(message, "%199[^\n]", atcmd_output);
  1104. if (strstr(command, "l") != NULL)
  1105. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  1106. else
  1107. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1108. } else {
  1109. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1110. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1111. return -1;
  1112. }
  1113. if(color > 0xFFFFFF) {
  1114. clif_displaymessage(fd, "Invalid color.");
  1115. return -1;
  1116. }
  1117. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1118. }
  1119. return 0;
  1120. }
  1121. /*==========================================
  1122. *
  1123. *------------------------------------------*/
  1124. ACMD_FUNC(heal)
  1125. {
  1126. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1127. nullpo_retr(-1, sd);
  1128. sscanf(message, "%d %d", &hp, &sp);
  1129. // some overflow checks
  1130. if( hp == INT_MIN ) hp++;
  1131. if( sp == INT_MIN ) sp++;
  1132. if ( hp == 0 && sp == 0 ) {
  1133. if (!status_percent_heal(&sd->bl, 100, 100))
  1134. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1135. else
  1136. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1137. return 0;
  1138. }
  1139. if ( hp > 0 && sp >= 0 ) {
  1140. if(!status_heal(&sd->bl, hp, sp, 0))
  1141. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1142. else
  1143. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1144. return 0;
  1145. }
  1146. if ( hp < 0 && sp <= 0 ) {
  1147. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1148. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1149. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1150. return 0;
  1151. }
  1152. //Opposing signs.
  1153. if ( hp ) {
  1154. if (hp > 0)
  1155. status_heal(&sd->bl, hp, 0, 0);
  1156. else {
  1157. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1158. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1159. }
  1160. }
  1161. if ( sp ) {
  1162. if (sp > 0)
  1163. status_heal(&sd->bl, 0, sp, 0);
  1164. else
  1165. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1166. }
  1167. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1168. return 0;
  1169. }
  1170. /*==========================================
  1171. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1172. *------------------------------------------*/
  1173. ACMD_FUNC(item)
  1174. {
  1175. char item_name[100];
  1176. int number = 0, item_id, flag;
  1177. struct item item_tmp;
  1178. struct item_data *item_data;
  1179. int get_count, i;
  1180. nullpo_retr(-1, sd);
  1181. memset(item_name, '\0', sizeof(item_name));
  1182. if (!message || !*message || (
  1183. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1184. sscanf(message, "%99s %d", item_name, &number) < 1
  1185. )) {
  1186. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1187. return -1;
  1188. }
  1189. if (number <= 0)
  1190. number = 1;
  1191. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1192. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1193. {
  1194. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1195. return -1;
  1196. }
  1197. item_id = item_data->nameid;
  1198. get_count = number;
  1199. //Check if it's stackable.
  1200. if (!itemdb_isstackable2(item_data))
  1201. get_count = 1;
  1202. for (i = 0; i < number; i += get_count) {
  1203. // if not pet egg
  1204. if (!pet_create_egg(sd, item_id)) {
  1205. memset(&item_tmp, 0, sizeof(item_tmp));
  1206. item_tmp.nameid = item_id;
  1207. item_tmp.identify = 1;
  1208. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1209. clif_additem(sd, 0, 0, flag);
  1210. }
  1211. }
  1212. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1213. return 0;
  1214. }
  1215. /*==========================================
  1216. *
  1217. *------------------------------------------*/
  1218. ACMD_FUNC(item2)
  1219. {
  1220. struct item item_tmp;
  1221. struct item_data *item_data;
  1222. char item_name[100];
  1223. int item_id, number = 0;
  1224. int identify = 0, refine = 0, attr = 0;
  1225. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1226. int flag;
  1227. int loop, get_count, i;
  1228. nullpo_retr(-1, sd);
  1229. memset(item_name, '\0', sizeof(item_name));
  1230. if (!message || !*message || (
  1231. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1232. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1233. )) {
  1234. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1235. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1236. return -1;
  1237. }
  1238. if (number <= 0)
  1239. number = 1;
  1240. item_id = 0;
  1241. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1242. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1243. item_id = item_data->nameid;
  1244. if (item_id > 500) {
  1245. loop = 1;
  1246. get_count = number;
  1247. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1248. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1249. loop = number;
  1250. get_count = 1;
  1251. if (item_data->type == IT_PETEGG) {
  1252. identify = 1;
  1253. refine = 0;
  1254. }
  1255. if (item_data->type == IT_PETARMOR)
  1256. refine = 0;
  1257. if (refine > MAX_REFINE)
  1258. refine = MAX_REFINE;
  1259. } else {
  1260. identify = 1;
  1261. refine = attr = 0;
  1262. }
  1263. for (i = 0; i < loop; i++) {
  1264. memset(&item_tmp, 0, sizeof(item_tmp));
  1265. item_tmp.nameid = item_id;
  1266. item_tmp.identify = identify;
  1267. item_tmp.refine = refine;
  1268. item_tmp.attribute = attr;
  1269. item_tmp.card[0] = c1;
  1270. item_tmp.card[1] = c2;
  1271. item_tmp.card[2] = c3;
  1272. item_tmp.card[3] = c4;
  1273. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1274. clif_additem(sd, 0, 0, flag);
  1275. }
  1276. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1277. } else {
  1278. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1279. return -1;
  1280. }
  1281. return 0;
  1282. }
  1283. /*==========================================
  1284. *
  1285. *------------------------------------------*/
  1286. ACMD_FUNC(itemreset)
  1287. {
  1288. int i;
  1289. nullpo_retr(-1, sd);
  1290. for (i = 0; i < MAX_INVENTORY; i++) {
  1291. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1292. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1293. }
  1294. }
  1295. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1296. return 0;
  1297. }
  1298. /*==========================================
  1299. * Atcommand @lvlup
  1300. *------------------------------------------*/
  1301. ACMD_FUNC(baselevelup)
  1302. {
  1303. int level=0, i=0, status_point=0;
  1304. nullpo_retr(-1, sd);
  1305. level = atoi(message);
  1306. if (!message || !*message || !level) {
  1307. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1308. return -1;
  1309. }
  1310. if (level > 0) {
  1311. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1312. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1313. return -1;
  1314. } // End Addition
  1315. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1316. level = pc_maxbaselv(sd) - sd->status.base_level;
  1317. for (i = 0; i < level; i++)
  1318. status_point += pc_gets_status_point(sd->status.base_level + i);
  1319. sd->status.status_point += status_point;
  1320. sd->status.base_level += (unsigned int)level;
  1321. status_percent_heal(&sd->bl, 100, 100);
  1322. clif_misceffect(&sd->bl, 0);
  1323. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1324. } else {
  1325. if (sd->status.base_level == 1) {
  1326. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1327. return -1;
  1328. }
  1329. level*=-1;
  1330. if ((unsigned int)level >= sd->status.base_level)
  1331. level = sd->status.base_level-1;
  1332. for (i = 0; i > -level; i--)
  1333. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1334. if (sd->status.status_point < status_point)
  1335. pc_resetstate(sd);
  1336. if (sd->status.status_point < status_point)
  1337. sd->status.status_point = 0;
  1338. else
  1339. sd->status.status_point -= status_point;
  1340. sd->status.base_level -= (unsigned int)level;
  1341. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1342. }
  1343. sd->status.base_exp = 0;
  1344. clif_updatestatus(sd, SP_STATUSPOINT);
  1345. clif_updatestatus(sd, SP_BASELEVEL);
  1346. clif_updatestatus(sd, SP_BASEEXP);
  1347. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1348. status_calc_pc(sd, 0);
  1349. if(sd->status.party_id)
  1350. party_send_levelup(sd);
  1351. return 0;
  1352. }
  1353. /*==========================================
  1354. *
  1355. *------------------------------------------*/
  1356. ACMD_FUNC(joblevelup)
  1357. {
  1358. int level=0;
  1359. nullpo_retr(-1, sd);
  1360. level = atoi(message);
  1361. if (!message || !*message || !level) {
  1362. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1363. return -1;
  1364. }
  1365. if (level > 0) {
  1366. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1367. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1368. return -1;
  1369. }
  1370. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1371. level = pc_maxjoblv(sd) - sd->status.job_level;
  1372. sd->status.job_level += (unsigned int)level;
  1373. sd->status.skill_point += level;
  1374. clif_misceffect(&sd->bl, 1);
  1375. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1376. } else {
  1377. if (sd->status.job_level == 1) {
  1378. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1379. return -1;
  1380. }
  1381. level *=-1;
  1382. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1383. level = sd->status.job_level-1;
  1384. sd->status.job_level -= (unsigned int)level;
  1385. if (sd->status.skill_point < level)
  1386. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1387. if (sd->status.skill_point < level)
  1388. sd->status.skill_point = 0;
  1389. else
  1390. sd->status.skill_point -= level;
  1391. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1392. }
  1393. sd->status.job_exp = 0;
  1394. clif_updatestatus(sd, SP_JOBLEVEL);
  1395. clif_updatestatus(sd, SP_JOBEXP);
  1396. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1397. clif_updatestatus(sd, SP_SKILLPOINT);
  1398. status_calc_pc(sd, 0);
  1399. return 0;
  1400. }
  1401. /*==========================================
  1402. * @help
  1403. *------------------------------------------*/
  1404. ACMD_FUNC(help)
  1405. {
  1406. config_setting_t *help;
  1407. const char *text = NULL;
  1408. const char *command_name = NULL;
  1409. char *default_command = "help";
  1410. nullpo_retr(-1, sd);
  1411. help = config_lookup(&atcommand_config, "help");
  1412. if (help == NULL) {
  1413. clif_displaymessage(fd, msg_txt(27)); // "Commands help is not available."
  1414. return -1;
  1415. }
  1416. if (!message || !*message) {
  1417. command_name = default_command; // If no command_name specified, display help for @help.
  1418. } else {
  1419. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1420. ++message;
  1421. command_name = atcommand_checkalias(message);
  1422. }
  1423. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1424. sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command"
  1425. clif_displaymessage(fd, atcmd_output);
  1426. return -1;
  1427. }
  1428. if (!config_setting_lookup_string(help, command_name, &text)) {
  1429. clif_displaymessage(fd, "There is no help for this command_name.");
  1430. return -1;
  1431. }
  1432. sprintf(atcmd_output, "Help for command %c%s:", atcommand_symbol, command_name);
  1433. clif_displaymessage(fd, atcmd_output);
  1434. { // Display aliases
  1435. DBIterator* iter;
  1436. AtCommandInfo *command_info;
  1437. AliasInfo *alias_info = NULL;
  1438. StringBuf buf;
  1439. bool has_aliases = false;
  1440. StringBuf_Init(&buf);
  1441. StringBuf_AppendStr(&buf, "Available aliases:");
  1442. command_info = get_atcommandinfo_byname(command_name);
  1443. iter = db_iterator(atcommand_alias_db);
  1444. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1445. if (alias_info->command == command_info) {
  1446. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1447. has_aliases = true;
  1448. }
  1449. }
  1450. dbi_destroy(iter);
  1451. if (has_aliases)
  1452. clif_displaymessage(fd, StringBuf_Value(&buf));
  1453. StringBuf_Destroy(&buf);
  1454. }
  1455. // Display help contents
  1456. clif_displaymessage(fd, text);
  1457. return 0;
  1458. }
  1459. // helper function, used in foreach calls to stop auto-attack timers
  1460. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1461. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1462. {
  1463. struct unit_data *ud = unit_bl2ud(bl);
  1464. int id = va_arg(ap, int);
  1465. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1466. {
  1467. unit_stop_attack(bl);
  1468. return 1;
  1469. }
  1470. return 0;
  1471. }
  1472. /*==========================================
  1473. *
  1474. *------------------------------------------*/
  1475. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1476. {
  1477. TBL_PC* sd = (TBL_PC*)bl;
  1478. clif_pvpset(sd, 0, 0, 2);
  1479. if (sd->pvp_timer != INVALID_TIMER) {
  1480. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1481. sd->pvp_timer = INVALID_TIMER;
  1482. }
  1483. return 0;
  1484. }
  1485. ACMD_FUNC(pvpoff)
  1486. {
  1487. nullpo_retr(-1, sd);
  1488. if (!map[sd->bl.m].flag.pvp) {
  1489. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1490. return -1;
  1491. }
  1492. map[sd->bl.m].flag.pvp = 0;
  1493. if (!battle_config.pk_mode)
  1494. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1495. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1496. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1497. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1498. return 0;
  1499. }
  1500. /*==========================================
  1501. *
  1502. *------------------------------------------*/
  1503. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1504. {
  1505. TBL_PC* sd = (TBL_PC*)bl;
  1506. if (sd->pvp_timer == INVALID_TIMER) {
  1507. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1508. sd->pvp_rank = 0;
  1509. sd->pvp_lastusers = 0;
  1510. sd->pvp_point = 5;
  1511. sd->pvp_won = 0;
  1512. sd->pvp_lost = 0;
  1513. }
  1514. return 0;
  1515. }
  1516. ACMD_FUNC(pvpon)
  1517. {
  1518. nullpo_retr(-1, sd);
  1519. if (map[sd->bl.m].flag.pvp) {
  1520. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1521. return -1;
  1522. }
  1523. map[sd->bl.m].flag.pvp = 1;
  1524. if (!battle_config.pk_mode)
  1525. {// display pvp circle and rank
  1526. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1527. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1528. }
  1529. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1530. return 0;
  1531. }
  1532. /*==========================================
  1533. *
  1534. *------------------------------------------*/
  1535. ACMD_FUNC(gvgoff)
  1536. {
  1537. nullpo_retr(-1, sd);
  1538. if (!map[sd->bl.m].flag.gvg) {
  1539. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1540. return -1;
  1541. }
  1542. map[sd->bl.m].flag.gvg = 0;
  1543. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1544. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1545. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1546. return 0;
  1547. }
  1548. /*==========================================
  1549. *
  1550. *------------------------------------------*/
  1551. ACMD_FUNC(gvgon)
  1552. {
  1553. nullpo_retr(-1, sd);
  1554. if (map[sd->bl.m].flag.gvg) {
  1555. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1556. return -1;
  1557. }
  1558. map[sd->bl.m].flag.gvg = 1;
  1559. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1560. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1561. return 0;
  1562. }
  1563. /*==========================================
  1564. *
  1565. *------------------------------------------*/
  1566. ACMD_FUNC(model)
  1567. {
  1568. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1569. nullpo_retr(-1, sd);
  1570. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1571. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1572. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1573. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1574. clif_displaymessage(fd, atcmd_output);
  1575. return -1;
  1576. }
  1577. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1578. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1579. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1580. pc_changelook(sd, LOOK_HAIR, hair_style);
  1581. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1582. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1583. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1584. } else {
  1585. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1586. return -1;
  1587. }
  1588. return 0;
  1589. }
  1590. /*==========================================
  1591. * @dye && @ccolor
  1592. *------------------------------------------*/
  1593. ACMD_FUNC(dye)
  1594. {
  1595. int cloth_color = 0;
  1596. nullpo_retr(-1, sd);
  1597. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1598. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1599. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1600. clif_displaymessage(fd, atcmd_output);
  1601. return -1;
  1602. }
  1603. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1604. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1605. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1606. } else {
  1607. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1608. return -1;
  1609. }
  1610. return 0;
  1611. }
  1612. /*==========================================
  1613. * @hairstyle && @hstyle
  1614. *------------------------------------------*/
  1615. ACMD_FUNC(hair_style)
  1616. {
  1617. int hair_style = 0;
  1618. nullpo_retr(-1, sd);
  1619. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1620. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1621. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1622. clif_displaymessage(fd, atcmd_output);
  1623. return -1;
  1624. }
  1625. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1626. pc_changelook(sd, LOOK_HAIR, hair_style);
  1627. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1628. } else {
  1629. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1630. return -1;
  1631. }
  1632. return 0;
  1633. }
  1634. /*==========================================
  1635. * @haircolor && @hcolor
  1636. *------------------------------------------*/
  1637. ACMD_FUNC(hair_color)
  1638. {
  1639. int hair_color = 0;
  1640. nullpo_retr(-1, sd);
  1641. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1642. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1643. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1644. clif_displaymessage(fd, atcmd_output);
  1645. return -1;
  1646. }
  1647. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1648. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1649. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1650. } else {
  1651. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1652. return -1;
  1653. }
  1654. return 0;
  1655. }
  1656. /*==========================================
  1657. * @go [city_number or city_name] - Updated by Harbin
  1658. *------------------------------------------*/
  1659. ACMD_FUNC(go)
  1660. {
  1661. int i;
  1662. int town;
  1663. char map_name[MAP_NAME_LENGTH];
  1664. int m;
  1665. const struct {
  1666. char map[MAP_NAME_LENGTH];
  1667. int x, y;
  1668. } data[] = {
  1669. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1670. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1671. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1672. { MAP_PAYON, 162, 233 }, // 3=Payon
  1673. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1674. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1675. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1676. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1677. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1678. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1679. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1680. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1681. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1682. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1683. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1684. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1685. { MAP_JAIL, 23, 61 }, // 16=Prison
  1686. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1687. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1688. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1689. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1690. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1691. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1692. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1693. { MAP_VEINS, 216, 123 }, // 24=Veins
  1694. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1695. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1696. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1697. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  1698. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1699. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1700. { MAP_MORA, 44, 151 }, // 31=Mora
  1701. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1702. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1703. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1704. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1705. };
  1706. nullpo_retr(-1, sd);
  1707. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1708. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1709. return 0;
  1710. }
  1711. memset(map_name, '\0', sizeof(map_name));
  1712. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1713. // get the number
  1714. town = atoi(message);
  1715. // if no value, display all value
  1716. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1717. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  1718. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  1719. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1720. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1721. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1722. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1723. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1724. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1725. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1726. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  1727. clif_displaymessage(fd, " 24=Veins 25=Moscovia 26=Midgard Camp");
  1728. clif_displaymessage(fd, " 27=Manuk 28=Splendide 29=Brasilis");
  1729. clif_displaymessage(fd, " 30=El Dicastes 31=Mora 32=Dewata");
  1730. clif_displaymessage(fd, " 33=Malangdo Island 34=Malaya Port 35=Eclage");
  1731. return -1;
  1732. }
  1733. // get possible name of the city
  1734. map_name[MAP_NAME_LENGTH-1] = '\0';
  1735. for (i = 0; map_name[i]; i++)
  1736. map_name[i] = TOLOWER(map_name[i]);
  1737. // try to identify the map name
  1738. if (strncmp(map_name, "prontera", 3) == 0) {
  1739. town = 0;
  1740. } else if (strncmp(map_name, "morocc", 3) == 0) {
  1741. town = 1;
  1742. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1743. town = 2;
  1744. } else if (strncmp(map_name, "payon", 3) == 0 ||
  1745. strncmp(map_name, "paion", 3) == 0) {
  1746. town = 3;
  1747. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1748. town = 4;
  1749. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  1750. strncmp(map_name, "islude", 3) == 0) {
  1751. town = 5;
  1752. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  1753. strcmp(map_name, "al") == 0) {
  1754. town = 6;
  1755. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1756. strcmp(map_name, "christmas") == 0 ||
  1757. strncmp(map_name, "xmas", 3) == 0 ||
  1758. strncmp(map_name, "x-mas", 3) == 0) {
  1759. town = 7;
  1760. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1761. town = 8;
  1762. } else if (strncmp(map_name, "yuno", 3) == 0) {
  1763. town = 9;
  1764. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1765. town = 10;
  1766. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  1767. town = 11;
  1768. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1769. town = 12;
  1770. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1771. town = 13;
  1772. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1773. town = 14;
  1774. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1775. strncmp(map_name, "startpoint", 3) == 0 ||
  1776. strncmp(map_name, "begining", 3) == 0) {
  1777. town = 15;
  1778. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1779. strncmp(map_name, "prison", 3) == 0 ||
  1780. strncmp(map_name, "jails", 3) == 0) {
  1781. town = 16;
  1782. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  1783. strncmp(map_name, "jawai", 3) == 0) {
  1784. town = 17;
  1785. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  1786. strncmp(map_name, "ayotaya", 3) == 0) {
  1787. town = 18;
  1788. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  1789. strncmp(map_name, "ainbroch", 5) == 0) {
  1790. town = 19;
  1791. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1792. town = 20;
  1793. } else if (strncmp(map_name, "einbech", 3) == 0) {
  1794. town = 21;
  1795. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1796. town = 22;
  1797. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1798. town = 23;
  1799. } else if (strncmp(map_name, "veins", 3) == 0) {
  1800. town = 24;
  1801. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1802. town = 25;
  1803. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1804. town = 26;
  1805. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1806. town = 27;
  1807. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1808. town = 28;
  1809. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1810. town = 29;
  1811. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1812. town = 30;
  1813. } else if (strncmp(map_name, "mora", 3) == 0) {
  1814. town = 31;
  1815. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1816. town = 32;
  1817. } else if (strncmp(map_name, "malangdo", 3) == 0) {
  1818. town = 33;
  1819. } else if (strncmp(map_name, "malaya", 3) == 0) {
  1820. town = 34;
  1821. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1822. town = 35;
  1823. }
  1824. if (town >= 0 && town < ARRAYLENGTH(data))
  1825. {
  1826. m = map_mapname2mapid(data[town].map);
  1827. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1828. clif_displaymessage(fd, msg_txt(247));
  1829. return -1;
  1830. }
  1831. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1832. clif_displaymessage(fd, msg_txt(248));
  1833. return -1;
  1834. }
  1835. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1836. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1837. } else {
  1838. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1839. return -1;
  1840. }
  1841. } else { // if you arrive here, you have an error in town variable when reading of names
  1842. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1843. return -1;
  1844. }
  1845. return 0;
  1846. }
  1847. /*==========================================
  1848. *
  1849. *------------------------------------------*/
  1850. ACMD_FUNC(monster)
  1851. {
  1852. char name[NAME_LENGTH];
  1853. char monster[NAME_LENGTH];
  1854. char eventname[EVENT_NAME_LENGTH] = "";
  1855. int mob_id;
  1856. int number = 0;
  1857. int count;
  1858. int i, k, range;
  1859. short mx, my;
  1860. nullpo_retr(-1, sd);
  1861. memset(name, '\0', sizeof(name));
  1862. memset(monster, '\0', sizeof(monster));
  1863. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1864. if (!message || !*message) {
  1865. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  1866. return -1;
  1867. }
  1868. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1869. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1870. //All data can be left as it is.
  1871. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1872. //Here, it is possible name was not given and we are using monster for it.
  1873. if (count < 3) //Blank mob's name.
  1874. name[0] = '\0';
  1875. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1876. //All data can be left as it is.
  1877. } else if (sscanf(message, "%23s", monster) > 0) {
  1878. //As before, name may be already filled.
  1879. name[0] = '\0';
  1880. } else {
  1881. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  1882. return -1;
  1883. }
  1884. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1885. mob_id = mobdb_checkid(atoi(monster));
  1886. if (mob_id == 0) {
  1887. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1888. return -1;
  1889. }
  1890. if (mob_id == MOBID_EMPERIUM) {
  1891. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  1892. return -1;
  1893. }
  1894. if (number <= 0)
  1895. number = 1;
  1896. if( !name[0] )
  1897. strcpy(name, "--ja--");
  1898. // 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
  1899. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1900. number = battle_config.atc_spawn_quantity_limit;
  1901. if (strcmp(command+1, "monstersmall") == 0)
  1902. strcpy(eventname, "2");
  1903. else if (strcmp(command+1, "monsterbig") == 0)
  1904. strcpy(eventname, "4");
  1905. if (battle_config.etc_log)
  1906. 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);
  1907. count = 0;
  1908. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1909. for (i = 0; i < number; i++) {
  1910. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1911. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname);
  1912. count += (k != 0) ? 1 : 0;
  1913. }
  1914. if (count != 0)
  1915. if (number == count)
  1916. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  1917. else {
  1918. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  1919. clif_displaymessage(fd, atcmd_output);
  1920. }
  1921. else {
  1922. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1923. return -1;
  1924. }
  1925. return 0;
  1926. }
  1927. /*==========================================
  1928. *
  1929. *------------------------------------------*/
  1930. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1931. {
  1932. struct mob_data *md;
  1933. int flag;
  1934. nullpo_ret(md=(struct mob_data *)bl);
  1935. flag = va_arg(ap, int);
  1936. if (md->guardian_data)
  1937. return 0; //Do not touch WoE mobs!
  1938. if (flag)
  1939. status_zap(bl,md->status.hp, 0);
  1940. else
  1941. status_kill(bl);
  1942. return 1;
  1943. }
  1944. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  1945. {
  1946. int map_id;
  1947. char map_name[MAP_NAME_LENGTH_EXT];
  1948. if (!sd) return;
  1949. memset(map_name, '\0', sizeof(map_name));
  1950. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1951. map_id = sd->bl.m;
  1952. else {
  1953. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1954. map_id = sd->bl.m;
  1955. }
  1956. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  1957. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  1958. return;
  1959. }
  1960. ACMD_FUNC(killmonster)
  1961. {
  1962. atcommand_killmonster_sub(fd, sd, message, 1);
  1963. return 0;
  1964. }
  1965. /*==========================================
  1966. *
  1967. *------------------------------------------*/
  1968. ACMD_FUNC(killmonster2)
  1969. {
  1970. atcommand_killmonster_sub(fd, sd, message, 0);
  1971. return 0;
  1972. }
  1973. /*==========================================
  1974. *
  1975. *------------------------------------------*/
  1976. ACMD_FUNC(refine)
  1977. {
  1978. int i,j, position = 0, refine = 0, current_position, final_refine;
  1979. int count;
  1980. nullpo_retr(-1, sd);
  1981. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1982. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1983. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  1984. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  1985. clif_displaymessage(fd, atcmd_output);
  1986. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  1987. clif_displaymessage(fd, atcmd_output);
  1988. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  1989. clif_displaymessage(fd, atcmd_output);
  1990. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  1991. clif_displaymessage(fd, atcmd_output);
  1992. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  1993. clif_displaymessage(fd, atcmd_output);
  1994. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  1995. clif_displaymessage(fd, atcmd_output);
  1996. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  1997. clif_displaymessage(fd, atcmd_output);
  1998. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  1999. clif_displaymessage(fd, atcmd_output);
  2000. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2001. clif_displaymessage(fd, atcmd_output);
  2002. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2003. clif_displaymessage(fd, atcmd_output);
  2004. return -1;
  2005. }
  2006. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2007. count = 0;
  2008. for (j = 0; j < EQI_MAX-1; j++) {
  2009. if ((i = sd->equip_index[j]) < 0)
  2010. continue;
  2011. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2012. continue;
  2013. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2014. continue;
  2015. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2016. continue;
  2017. if(position && !(sd->status.inventory[i].equip & position))
  2018. continue;
  2019. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2020. if (sd->status.inventory[i].refine != final_refine) {
  2021. sd->status.inventory[i].refine = final_refine;
  2022. current_position = sd->status.inventory[i].equip;
  2023. pc_unequipitem(sd, i, 3);
  2024. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2025. clif_delitem(sd, i, 1, 3);
  2026. clif_additem(sd, i, 1, 0);
  2027. pc_equipitem(sd, i, current_position);
  2028. clif_misceffect(&sd->bl, 3);
  2029. count++;
  2030. }
  2031. }
  2032. if (count == 0)
  2033. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2034. else if (count == 1)
  2035. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2036. else {
  2037. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2038. clif_displaymessage(fd, atcmd_output);
  2039. }
  2040. return 0;
  2041. }
  2042. /*==========================================
  2043. *
  2044. *------------------------------------------*/
  2045. ACMD_FUNC(produce)
  2046. {
  2047. char item_name[100];
  2048. int item_id, attribute = 0, star = 0;
  2049. int flag = 0;
  2050. struct item_data *item_data;
  2051. struct item tmp_item;
  2052. nullpo_retr(-1, sd);
  2053. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2054. memset(item_name, '\0', sizeof(item_name));
  2055. if (!message || !*message || (
  2056. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2057. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2058. )) {
  2059. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2060. return -1;
  2061. }
  2062. item_id = 0;
  2063. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2064. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2065. {
  2066. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2067. return -1;
  2068. }
  2069. item_id = item_data->nameid;
  2070. if (itemdb_isequip2(item_data)) {
  2071. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2072. attribute = ATTRIBUTE_NORMAL;
  2073. if (star < MIN_STAR || star > MAX_STAR)
  2074. star = 0;
  2075. memset(&tmp_item, 0, sizeof tmp_item);
  2076. tmp_item.nameid = item_id;
  2077. tmp_item.amount = 1;
  2078. tmp_item.identify = 1;
  2079. tmp_item.card[0] = CARD0_FORGE;
  2080. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2081. ((star*5) << 8) + attribute:0;
  2082. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2083. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2084. clif_produceeffect(sd, 0, item_id);
  2085. clif_misceffect(&sd->bl, 3);
  2086. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2087. clif_additem(sd, 0, 0, flag);
  2088. } else {
  2089. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2090. clif_displaymessage(fd, atcmd_output);
  2091. return -1;
  2092. }
  2093. return 0;
  2094. }
  2095. /*==========================================
  2096. *
  2097. *------------------------------------------*/
  2098. ACMD_FUNC(memo)
  2099. {
  2100. int position = 0;
  2101. nullpo_retr(-1, sd);
  2102. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2103. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2104. {
  2105. int i;
  2106. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2107. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2108. {
  2109. if( sd->status.memo_point[i].map )
  2110. 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);
  2111. else
  2112. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2113. clif_displaymessage(sd->fd, atcmd_output);
  2114. }
  2115. return 0;
  2116. }
  2117. if( position < 0 || position >= MAX_MEMOPOINTS )
  2118. {
  2119. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2120. clif_displaymessage(fd, atcmd_output);
  2121. return -1;
  2122. }
  2123. pc_memo(sd, position);
  2124. return 0;
  2125. }
  2126. /*==========================================
  2127. *
  2128. *------------------------------------------*/
  2129. ACMD_FUNC(gat)
  2130. {
  2131. int y;
  2132. nullpo_retr(-1, sd);
  2133. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2134. for (y = 2; y >= -2; y--) {
  2135. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2136. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2137. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2138. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2139. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2140. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2141. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2142. clif_displaymessage(fd, atcmd_output);
  2143. }
  2144. return 0;
  2145. }
  2146. /*==========================================
  2147. *
  2148. *------------------------------------------*/
  2149. ACMD_FUNC(displaystatus)
  2150. {
  2151. int i, type, flag, tick;
  2152. nullpo_retr(-1, sd);
  2153. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2154. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2155. return -1;
  2156. }
  2157. if (i < 2) flag = 1;
  2158. if (i < 3) tick = 0;
  2159. clif_status_change(&sd->bl, type, flag, tick, 0, 0, 0);
  2160. return 0;
  2161. }
  2162. /*==========================================
  2163. * @stpoint (Rewritten by [Yor])
  2164. *------------------------------------------*/
  2165. ACMD_FUNC(statuspoint)
  2166. {
  2167. int point;
  2168. unsigned int new_status_point;
  2169. if (!message || !*message || (point = atoi(message)) == 0) {
  2170. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2171. return -1;
  2172. }
  2173. if(point < 0)
  2174. {
  2175. if(sd->status.status_point < (unsigned int)(-point))
  2176. {
  2177. new_status_point = 0;
  2178. }
  2179. else
  2180. {
  2181. new_status_point = sd->status.status_point + point;
  2182. }
  2183. }
  2184. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2185. {
  2186. new_status_point = UINT_MAX;
  2187. }
  2188. else
  2189. {
  2190. new_status_point = sd->status.status_point + point;
  2191. }
  2192. if (new_status_point != sd->status.status_point) {
  2193. sd->status.status_point = new_status_point;
  2194. clif_updatestatus(sd, SP_STATUSPOINT);
  2195. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2196. } else {
  2197. if (point < 0)
  2198. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2199. else
  2200. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2201. return -1;
  2202. }
  2203. return 0;
  2204. }
  2205. /*==========================================
  2206. * @skpoint (Rewritten by [Yor])
  2207. *------------------------------------------*/
  2208. ACMD_FUNC(skillpoint)
  2209. {
  2210. int point;
  2211. unsigned int new_skill_point;
  2212. nullpo_retr(-1, sd);
  2213. if (!message || !*message || (point = atoi(message)) == 0) {
  2214. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2215. return -1;
  2216. }
  2217. if(point < 0)
  2218. {
  2219. if(sd->status.skill_point < (unsigned int)(-point))
  2220. {
  2221. new_skill_point = 0;
  2222. }
  2223. else
  2224. {
  2225. new_skill_point = sd->status.skill_point + point;
  2226. }
  2227. }
  2228. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2229. {
  2230. new_skill_point = UINT_MAX;
  2231. }
  2232. else
  2233. {
  2234. new_skill_point = sd->status.skill_point + point;
  2235. }
  2236. if (new_skill_point != sd->status.skill_point) {
  2237. sd->status.skill_point = new_skill_point;
  2238. clif_updatestatus(sd, SP_SKILLPOINT);
  2239. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2240. } else {
  2241. if (point < 0)
  2242. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2243. else
  2244. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2245. return -1;
  2246. }
  2247. return 0;
  2248. }
  2249. /*==========================================
  2250. * @zeny (Rewritten by [Yor])
  2251. *------------------------------------------*/
  2252. ACMD_FUNC(zeny)
  2253. {
  2254. int zeny, new_zeny;
  2255. nullpo_retr(-1, sd);
  2256. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2257. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2258. return -1;
  2259. }
  2260. new_zeny = sd->status.zeny + zeny;
  2261. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2262. new_zeny = MAX_ZENY;
  2263. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2264. new_zeny = 0;
  2265. if (new_zeny != sd->status.zeny) {
  2266. sd->status.zeny = new_zeny;
  2267. clif_updatestatus(sd, SP_ZENY);
  2268. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2269. } else {
  2270. if (zeny < 0)
  2271. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2272. else
  2273. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2274. return -1;
  2275. }
  2276. return 0;
  2277. }
  2278. /*==========================================
  2279. *
  2280. *------------------------------------------*/
  2281. ACMD_FUNC(param)
  2282. {
  2283. int i, value = 0, new_value, max;
  2284. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2285. short* status[6];
  2286. //we don't use direct initialization because it isn't part of the c standard.
  2287. nullpo_retr(-1, sd);
  2288. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2289. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2290. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2291. clif_displaymessage(fd, atcmd_output);
  2292. return -1;
  2293. }
  2294. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2295. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2296. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2297. clif_displaymessage(fd, atcmd_output);
  2298. return -1;
  2299. }
  2300. status[0] = &sd->status.str;
  2301. status[1] = &sd->status.agi;
  2302. status[2] = &sd->status.vit;
  2303. status[3] = &sd->status.int_;
  2304. status[4] = &sd->status.dex;
  2305. status[5] = &sd->status.luk;
  2306. if( battle_config.atcommand_max_stat_bypass )
  2307. max = SHRT_MAX;
  2308. else
  2309. max = pc_maxparameter(sd);
  2310. if(value < 0 && *status[i] <= -value) {
  2311. new_value = 1;
  2312. } else if(max - *status[i] < value) {
  2313. new_value = max;
  2314. } else {
  2315. new_value = *status[i] + value;
  2316. }
  2317. if (new_value != *status[i]) {
  2318. *status[i] = new_value;
  2319. clif_updatestatus(sd, SP_STR + i);
  2320. clif_updatestatus(sd, SP_USTR + i);
  2321. status_calc_pc(sd, 0);
  2322. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2323. } else {
  2324. if (value < 0)
  2325. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2326. else
  2327. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2328. return -1;
  2329. }
  2330. return 0;
  2331. }
  2332. /*==========================================
  2333. * Stat all by fritz (rewritten by [Yor])
  2334. *------------------------------------------*/
  2335. ACMD_FUNC(stat_all)
  2336. {
  2337. int index, count, value, max, new_value;
  2338. short* status[6];
  2339. //we don't use direct initialization because it isn't part of the c standard.
  2340. nullpo_retr(-1, sd);
  2341. status[0] = &sd->status.str;
  2342. status[1] = &sd->status.agi;
  2343. status[2] = &sd->status.vit;
  2344. status[3] = &sd->status.int_;
  2345. status[4] = &sd->status.dex;
  2346. status[5] = &sd->status.luk;
  2347. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2348. value = pc_maxparameter(sd);
  2349. max = pc_maxparameter(sd);
  2350. } else {
  2351. if( battle_config.atcommand_max_stat_bypass )
  2352. max = SHRT_MAX;
  2353. else
  2354. max = pc_maxparameter(sd);
  2355. }
  2356. count = 0;
  2357. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2358. if (value > 0 && *status[index] > max - value)
  2359. new_value = max;
  2360. else if (value < 0 && *status[index] <= -value)
  2361. new_value = 1;
  2362. else
  2363. new_value = *status[index] +value;
  2364. if (new_value != (int)*status[index]) {
  2365. *status[index] = new_value;
  2366. clif_updatestatus(sd, SP_STR + index);
  2367. clif_updatestatus(sd, SP_USTR + index);
  2368. count++;
  2369. }
  2370. }
  2371. if (count > 0) { // if at least 1 stat modified
  2372. status_calc_pc(sd, 0);
  2373. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2374. } else {
  2375. if (value < 0)
  2376. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2377. else
  2378. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2379. return -1;
  2380. }
  2381. return 0;
  2382. }
  2383. /*==========================================
  2384. *
  2385. *------------------------------------------*/
  2386. ACMD_FUNC(guildlevelup)
  2387. {
  2388. int level = 0;
  2389. short added_level;
  2390. struct guild *guild_info;
  2391. nullpo_retr(-1, sd);
  2392. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2393. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2394. return -1;
  2395. }
  2396. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2397. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2398. return -1;
  2399. }
  2400. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2401. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2402. // return -1;
  2403. //}
  2404. added_level = (short)level;
  2405. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2406. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2407. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2408. added_level = 1 - guild_info->guild_lv;
  2409. if (added_level != 0) {
  2410. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2411. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2412. } else {
  2413. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2414. return -1;
  2415. }
  2416. return 0;
  2417. }
  2418. /*==========================================
  2419. *
  2420. *------------------------------------------*/
  2421. ACMD_FUNC(makeegg)
  2422. {
  2423. struct item_data *item_data;
  2424. int id, pet_id;
  2425. nullpo_retr(-1, sd);
  2426. if (!message || !*message) {
  2427. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2428. return -1;
  2429. }
  2430. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2431. id = item_data->nameid;
  2432. else
  2433. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2434. ;
  2435. else
  2436. id = atoi(message);
  2437. pet_id = search_petDB_index(id, PET_CLASS);
  2438. if (pet_id < 0)
  2439. pet_id = search_petDB_index(id, PET_EGG);
  2440. if (pet_id >= 0) {
  2441. sd->catch_target_class = pet_db[pet_id].class_;
  2442. intif_create_pet(
  2443. sd->status.account_id, sd->status.char_id,
  2444. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2445. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2446. 100, 0, 1, pet_db[pet_id].jname);
  2447. } else {
  2448. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2449. return -1;
  2450. }
  2451. return 0;
  2452. }
  2453. /*==========================================
  2454. *
  2455. *------------------------------------------*/
  2456. ACMD_FUNC(hatch)
  2457. {
  2458. nullpo_retr(-1, sd);
  2459. if (sd->status.pet_id <= 0)
  2460. clif_sendegg(sd);
  2461. else {
  2462. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2463. return -1;
  2464. }
  2465. return 0;
  2466. }
  2467. /*==========================================
  2468. *
  2469. *------------------------------------------*/
  2470. ACMD_FUNC(petfriendly)
  2471. {
  2472. int friendly;
  2473. struct pet_data *pd;
  2474. nullpo_retr(-1, sd);
  2475. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2476. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2477. return -1;
  2478. }
  2479. pd = sd->pd;
  2480. if (!pd) {
  2481. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2482. return -1;
  2483. }
  2484. if (friendly < 0 || friendly > 1000)
  2485. {
  2486. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2487. return -1;
  2488. }
  2489. if (friendly == pd->pet.intimate) {
  2490. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2491. return -1;
  2492. }
  2493. pet_set_intimate(pd, friendly);
  2494. clif_send_petstatus(sd);
  2495. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2496. return 0;
  2497. }
  2498. /*==========================================
  2499. *
  2500. *------------------------------------------*/
  2501. ACMD_FUNC(pethungry)
  2502. {
  2503. int hungry;
  2504. struct pet_data *pd;
  2505. nullpo_retr(-1, sd);
  2506. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2507. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2508. return -1;
  2509. }
  2510. pd = sd->pd;
  2511. if (!sd->status.pet_id || !pd) {
  2512. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2513. return -1;
  2514. }
  2515. if (hungry < 0 || hungry > 100) {
  2516. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2517. return -1;
  2518. }
  2519. if (hungry == pd->pet.hungry) {
  2520. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2521. return -1;
  2522. }
  2523. pd->pet.hungry = hungry;
  2524. clif_send_petstatus(sd);
  2525. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2526. return 0;
  2527. }
  2528. /*==========================================
  2529. *
  2530. *------------------------------------------*/
  2531. ACMD_FUNC(petrename)
  2532. {
  2533. struct pet_data *pd;
  2534. nullpo_retr(-1, sd);
  2535. if (!sd->status.pet_id || !sd->pd) {
  2536. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2537. return -1;
  2538. }
  2539. pd = sd->pd;
  2540. if (!pd->pet.rename_flag) {
  2541. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2542. return -1;
  2543. }
  2544. pd->pet.rename_flag = 0;
  2545. intif_save_petdata(sd->status.account_id, &pd->pet);
  2546. clif_send_petstatus(sd);
  2547. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2548. return 0;
  2549. }
  2550. /*==========================================
  2551. *
  2552. *------------------------------------------*/
  2553. ACMD_FUNC(recall)
  2554. {
  2555. struct map_session_data *pl_sd = NULL;
  2556. nullpo_retr(-1, sd);
  2557. if (!message || !*message) {
  2558. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2559. return -1;
  2560. }
  2561. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2562. {
  2563. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2564. return -1;
  2565. }
  2566. if (pl_sd == sd)
  2567. {
  2568. clif_displaymessage(fd, "You are already where you are...");
  2569. return -1;
  2570. }
  2571. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2572. {
  2573. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2574. return -1;
  2575. }
  2576. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2577. clif_displaymessage(fd, "You are not authorised to warp someone to your actual map.");
  2578. return -1;
  2579. }
  2580. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2581. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2582. return -1;
  2583. }
  2584. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2585. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2586. clif_displaymessage(fd, atcmd_output);
  2587. return 0;
  2588. }
  2589. /*==========================================
  2590. * charblock command (usage: charblock <player_name>)
  2591. * This command do a definitiv ban on a player
  2592. *------------------------------------------*/
  2593. ACMD_FUNC(char_block)
  2594. {
  2595. nullpo_retr(-1, sd);
  2596. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2597. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2598. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2599. return -1;
  2600. }
  2601. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2602. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2603. return 0;
  2604. }
  2605. /*==========================================
  2606. * charban command (usage: charban <time> <player_name>)
  2607. * This command do a limited ban on a player
  2608. * Time is done as follows:
  2609. * Adjustment value (-1, 1, +1, etc...)
  2610. * Modified element:
  2611. * a or y: year
  2612. * m: month
  2613. * j or d: day
  2614. * h: hour
  2615. * mn: minute
  2616. * s: second
  2617. * <example> @ban +1m-2mn1s-6y test_player
  2618. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2619. *------------------------------------------*/
  2620. ACMD_FUNC(char_ban)
  2621. {
  2622. char * modif_p;
  2623. int year, month, day, hour, minute, second, value;
  2624. time_t timestamp;
  2625. struct tm *tmtime;
  2626. nullpo_retr(-1, sd);
  2627. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2628. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2629. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2630. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2631. return -1;
  2632. }
  2633. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2634. modif_p = atcmd_output;
  2635. year = month = day = hour = minute = second = 0;
  2636. while (modif_p[0] != '\0') {
  2637. value = atoi(modif_p);
  2638. if (value == 0)
  2639. modif_p++;
  2640. else {
  2641. if (modif_p[0] == '-' || modif_p[0] == '+')
  2642. modif_p++;
  2643. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2644. modif_p++;
  2645. if (modif_p[0] == 's') {
  2646. second = value;
  2647. modif_p++;
  2648. } else if (modif_p[0] == 'n') {
  2649. minute = value;
  2650. modif_p++;
  2651. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2652. minute = value;
  2653. modif_p = modif_p + 2;
  2654. } else if (modif_p[0] == 'h') {
  2655. hour = value;
  2656. modif_p++;
  2657. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2658. day = value;
  2659. modif_p++;
  2660. } else if (modif_p[0] == 'm') {
  2661. month = value;
  2662. modif_p++;
  2663. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2664. year = value;
  2665. modif_p++;
  2666. } else if (modif_p[0] != '\0') {
  2667. modif_p++;
  2668. }
  2669. }
  2670. }
  2671. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2672. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2673. return -1;
  2674. }
  2675. /**
  2676. * We now check if you can adjust the ban to negative (and if this is the case)
  2677. **/
  2678. timestamp = time(NULL);
  2679. tmtime = localtime(&timestamp);
  2680. tmtime->tm_year = tmtime->tm_year + year;
  2681. tmtime->tm_mon = tmtime->tm_mon + month;
  2682. tmtime->tm_mday = tmtime->tm_mday + day;
  2683. tmtime->tm_hour = tmtime->tm_hour + hour;
  2684. tmtime->tm_min = tmtime->tm_min + minute;
  2685. tmtime->tm_sec = tmtime->tm_sec + second;
  2686. timestamp = mktime(tmtime);
  2687. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2688. clif_displaymessage(fd,"You are not allowed to reduce the length of a ban");
  2689. return -1;
  2690. }
  2691. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2692. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2693. return 0;
  2694. }
  2695. /*==========================================
  2696. * charunblock command (usage: charunblock <player_name>)
  2697. *------------------------------------------*/
  2698. ACMD_FUNC(char_unblock)
  2699. {
  2700. nullpo_retr(-1, sd);
  2701. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2702. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2703. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  2704. return -1;
  2705. }
  2706. // send answer to login server via char-server
  2707. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2708. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2709. return 0;
  2710. }
  2711. /*==========================================
  2712. * charunban command (usage: charunban <player_name>)
  2713. *------------------------------------------*/
  2714. ACMD_FUNC(char_unban)
  2715. {
  2716. nullpo_retr(-1, sd);
  2717. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2718. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2719. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  2720. return -1;
  2721. }
  2722. // send answer to login server via char-server
  2723. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2724. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2725. return 0;
  2726. }
  2727. /*==========================================
  2728. *
  2729. *------------------------------------------*/
  2730. ACMD_FUNC(night)
  2731. {
  2732. nullpo_retr(-1, sd);
  2733. if (night_flag != 1) {
  2734. map_night_timer(night_timer_tid, 0, 0, 1);
  2735. } else {
  2736. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  2737. return -1;
  2738. }
  2739. return 0;
  2740. }
  2741. /*==========================================
  2742. *
  2743. *------------------------------------------*/
  2744. ACMD_FUNC(day)
  2745. {
  2746. nullpo_retr(-1, sd);
  2747. if (night_flag != 0) {
  2748. map_day_timer(day_timer_tid, 0, 0, 1);
  2749. } else {
  2750. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  2751. return -1;
  2752. }
  2753. return 0;
  2754. }
  2755. /*==========================================
  2756. *
  2757. *------------------------------------------*/
  2758. ACMD_FUNC(doom)
  2759. {
  2760. struct map_session_data* pl_sd;
  2761. struct s_mapiterator* iter;
  2762. nullpo_retr(-1, sd);
  2763. iter = mapit_getallusers();
  2764. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2765. {
  2766. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2767. {
  2768. status_kill(&pl_sd->bl);
  2769. clif_specialeffect(&pl_sd->bl,450,AREA);
  2770. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2771. }
  2772. }
  2773. mapit_free(iter);
  2774. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2775. return 0;
  2776. }
  2777. /*==========================================
  2778. *
  2779. *------------------------------------------*/
  2780. ACMD_FUNC(doommap)
  2781. {
  2782. struct map_session_data* pl_sd;
  2783. struct s_mapiterator* iter;
  2784. nullpo_retr(-1, sd);
  2785. iter = mapit_getallusers();
  2786. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2787. {
  2788. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2789. {
  2790. status_kill(&pl_sd->bl);
  2791. clif_specialeffect(&pl_sd->bl,450,AREA);
  2792. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2793. }
  2794. }
  2795. mapit_free(iter);
  2796. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2797. return 0;
  2798. }
  2799. /*==========================================
  2800. *
  2801. *------------------------------------------*/
  2802. static void atcommand_raise_sub(struct map_session_data* sd)
  2803. {
  2804. if (!status_isdead(&sd->bl))
  2805. return;
  2806. if(!status_revive(&sd->bl, 100, 100))
  2807. return;
  2808. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2809. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  2810. }
  2811. /*==========================================
  2812. *
  2813. *------------------------------------------*/
  2814. ACMD_FUNC(raise)
  2815. {
  2816. struct map_session_data* pl_sd;
  2817. struct s_mapiterator* iter;
  2818. nullpo_retr(-1, sd);
  2819. iter = mapit_getallusers();
  2820. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2821. atcommand_raise_sub(pl_sd);
  2822. mapit_free(iter);
  2823. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2824. return 0;
  2825. }
  2826. /*==========================================
  2827. *
  2828. *------------------------------------------*/
  2829. ACMD_FUNC(raisemap)
  2830. {
  2831. struct map_session_data* pl_sd;
  2832. struct s_mapiterator* iter;
  2833. nullpo_retr(-1, sd);
  2834. iter = mapit_getallusers();
  2835. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2836. if (sd->bl.m == pl_sd->bl.m)
  2837. atcommand_raise_sub(pl_sd);
  2838. mapit_free(iter);
  2839. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2840. return 0;
  2841. }
  2842. /*==========================================
  2843. *
  2844. *------------------------------------------*/
  2845. ACMD_FUNC(kick)
  2846. {
  2847. struct map_session_data *pl_sd;
  2848. nullpo_retr(-1, sd);
  2849. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2850. if (!message || !*message) {
  2851. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  2852. return -1;
  2853. }
  2854. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2855. {
  2856. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2857. return -1;
  2858. }
  2859. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2860. {
  2861. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2862. return -1;
  2863. }
  2864. clif_GM_kick(sd, pl_sd);
  2865. return 0;
  2866. }
  2867. /*==========================================
  2868. *
  2869. *------------------------------------------*/
  2870. ACMD_FUNC(kickall)
  2871. {
  2872. struct map_session_data* pl_sd;
  2873. struct s_mapiterator* iter;
  2874. nullpo_retr(-1, sd);
  2875. iter = mapit_getallusers();
  2876. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2877. {
  2878. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2879. if (sd->status.account_id != pl_sd->status.account_id)
  2880. clif_GM_kick(NULL, pl_sd);
  2881. }
  2882. }
  2883. mapit_free(iter);
  2884. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  2885. return 0;
  2886. }
  2887. /*==========================================
  2888. *
  2889. *------------------------------------------*/
  2890. ACMD_FUNC(allskill)
  2891. {
  2892. nullpo_retr(-1, sd);
  2893. pc_allskillup(sd); // all skills
  2894. sd->status.skill_point = 0; // 0 skill points
  2895. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2896. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  2897. return 0;
  2898. }
  2899. /*==========================================
  2900. *
  2901. *------------------------------------------*/
  2902. ACMD_FUNC(questskill)
  2903. {
  2904. int skill_id;
  2905. nullpo_retr(-1, sd);
  2906. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  2907. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  2908. return -1;
  2909. }
  2910. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  2911. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2912. return -1;
  2913. }
  2914. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2915. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2916. return -1;
  2917. }
  2918. if (pc_checkskill(sd, skill_id) > 0) {
  2919. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  2920. return -1;
  2921. }
  2922. pc_skill(sd, skill_id, 1, 0);
  2923. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  2924. return 0;
  2925. }
  2926. /*==========================================
  2927. *
  2928. *------------------------------------------*/
  2929. ACMD_FUNC(lostskill)
  2930. {
  2931. int skill_id;
  2932. nullpo_retr(-1, sd);
  2933. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  2934. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  2935. return -1;
  2936. }
  2937. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  2938. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2939. return -1;
  2940. }
  2941. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2942. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2943. return -1;
  2944. }
  2945. if (pc_checkskill(sd, skill_id) == 0) {
  2946. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  2947. return -1;
  2948. }
  2949. sd->status.skill[skill_id].lv = 0;
  2950. sd->status.skill[skill_id].flag = 0;
  2951. clif_deleteskill(sd,skill_id);
  2952. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  2953. return 0;
  2954. }
  2955. /*==========================================
  2956. *
  2957. *------------------------------------------*/
  2958. ACMD_FUNC(spiritball)
  2959. {
  2960. int max_spiritballs;
  2961. int number;
  2962. nullpo_retr(-1, sd);
  2963. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2964. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2965. {
  2966. char msg[CHAT_SIZE_MAX];
  2967. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  2968. clif_displaymessage(fd, msg);
  2969. return -1;
  2970. }
  2971. if( sd->spiritball > 0 )
  2972. pc_delspiritball(sd, sd->spiritball, 1);
  2973. sd->spiritball = number;
  2974. clif_spiritball(sd);
  2975. // no message, player can look the difference
  2976. return 0;
  2977. }
  2978. /*==========================================
  2979. *
  2980. *------------------------------------------*/
  2981. ACMD_FUNC(party)
  2982. {
  2983. char party[NAME_LENGTH];
  2984. nullpo_retr(-1, sd);
  2985. memset(party, '\0', sizeof(party));
  2986. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2987. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  2988. return -1;
  2989. }
  2990. party_create(sd, party, 0, 0);
  2991. return 0;
  2992. }
  2993. /*==========================================
  2994. *
  2995. *------------------------------------------*/
  2996. ACMD_FUNC(guild)
  2997. {
  2998. char guild[NAME_LENGTH];
  2999. int prev;
  3000. nullpo_retr(-1, sd);
  3001. memset(guild, '\0', sizeof(guild));
  3002. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3003. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3004. return -1;
  3005. }
  3006. prev = battle_config.guild_emperium_check;
  3007. battle_config.guild_emperium_check = 0;
  3008. guild_create(sd, guild);
  3009. battle_config.guild_emperium_check = prev;
  3010. return 0;
  3011. }
  3012. /*==========================================
  3013. *
  3014. *------------------------------------------*/
  3015. ACMD_FUNC(agitstart)
  3016. {
  3017. nullpo_retr(-1, sd);
  3018. if (agit_flag == 1) {
  3019. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3020. return -1;
  3021. }
  3022. agit_flag = 1;
  3023. guild_agit_start();
  3024. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3025. return 0;
  3026. }
  3027. /*==========================================
  3028. *
  3029. *------------------------------------------*/
  3030. ACMD_FUNC(agitstart2)
  3031. {
  3032. nullpo_retr(-1, sd);
  3033. if (agit2_flag == 1) {
  3034. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3035. return -1;
  3036. }
  3037. agit2_flag = 1;
  3038. guild_agit2_start();
  3039. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3040. return 0;
  3041. }
  3042. /*==========================================
  3043. *
  3044. *------------------------------------------*/
  3045. ACMD_FUNC(agitend)
  3046. {
  3047. nullpo_retr(-1, sd);
  3048. if (agit_flag == 0) {
  3049. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3050. return -1;
  3051. }
  3052. agit_flag = 0;
  3053. guild_agit_end();
  3054. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3055. return 0;
  3056. }
  3057. /*==========================================
  3058. *
  3059. *------------------------------------------*/
  3060. ACMD_FUNC(agitend2)
  3061. {
  3062. nullpo_retr(-1, sd);
  3063. if (agit2_flag == 0) {
  3064. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3065. return -1;
  3066. }
  3067. agit2_flag = 0;
  3068. guild_agit2_end();
  3069. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3070. return 0;
  3071. }
  3072. /*==========================================
  3073. * @mapexit - shuts down the map server
  3074. *------------------------------------------*/
  3075. ACMD_FUNC(mapexit)
  3076. {
  3077. nullpo_retr(-1, sd);
  3078. do_shutdown();
  3079. return 0;
  3080. }
  3081. /*==========================================
  3082. * idsearch <part_of_name>: revrited by [Yor]
  3083. *------------------------------------------*/
  3084. ACMD_FUNC(idsearch)
  3085. {
  3086. char item_name[100];
  3087. unsigned int i, match;
  3088. struct item_data *item_array[MAX_SEARCH];
  3089. nullpo_retr(-1, sd);
  3090. memset(item_name, '\0', sizeof(item_name));
  3091. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3092. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3093. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3094. return -1;
  3095. }
  3096. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3097. clif_displaymessage(fd, atcmd_output);
  3098. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3099. if (match > MAX_SEARCH) {
  3100. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3101. clif_displaymessage(fd, atcmd_output);
  3102. match = MAX_SEARCH;
  3103. }
  3104. for(i = 0; i < match; i++) {
  3105. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3106. clif_displaymessage(fd, atcmd_output);
  3107. }
  3108. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3109. clif_displaymessage(fd, atcmd_output);
  3110. return 0;
  3111. }
  3112. /*==========================================
  3113. * Recall All Characters Online To Your Location
  3114. *------------------------------------------*/
  3115. ACMD_FUNC(recallall)
  3116. {
  3117. struct map_session_data* pl_sd;
  3118. struct s_mapiterator* iter;
  3119. int count;
  3120. nullpo_retr(-1, sd);
  3121. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3122. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3123. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3124. return -1;
  3125. }
  3126. count = 0;
  3127. iter = mapit_getallusers();
  3128. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3129. {
  3130. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3131. {
  3132. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3133. count++;
  3134. else {
  3135. if (pc_isdead(pl_sd)) { //Wake them up
  3136. pc_setstand(pl_sd);
  3137. pc_setrestartvalue(pl_sd,1);
  3138. }
  3139. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3140. }
  3141. }
  3142. }
  3143. mapit_free(iter);
  3144. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3145. if (count) {
  3146. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3147. clif_displaymessage(fd, atcmd_output);
  3148. }
  3149. return 0;
  3150. }
  3151. /*==========================================
  3152. * Recall online characters of a guild to your location
  3153. *------------------------------------------*/
  3154. ACMD_FUNC(guildrecall)
  3155. {
  3156. struct map_session_data* pl_sd;
  3157. struct s_mapiterator* iter;
  3158. int count;
  3159. char guild_name[NAME_LENGTH];
  3160. struct guild *g;
  3161. nullpo_retr(-1, sd);
  3162. memset(guild_name, '\0', sizeof(guild_name));
  3163. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3164. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3165. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3166. return -1;
  3167. }
  3168. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3169. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3170. return -1;
  3171. }
  3172. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3173. (g = guild_search(atoi(message))) == NULL)
  3174. {
  3175. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3176. return -1;
  3177. }
  3178. count = 0;
  3179. iter = mapit_getallusers();
  3180. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3181. {
  3182. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3183. {
  3184. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3185. continue; //Skip GMs greater than you.
  3186. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3187. count++;
  3188. else
  3189. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3190. }
  3191. }
  3192. mapit_free(iter);
  3193. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3194. clif_displaymessage(fd, atcmd_output);
  3195. if (count) {
  3196. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3197. clif_displaymessage(fd, atcmd_output);
  3198. }
  3199. return 0;
  3200. }
  3201. /*==========================================
  3202. * Recall online characters of a party to your location
  3203. *------------------------------------------*/
  3204. ACMD_FUNC(partyrecall)
  3205. {
  3206. struct map_session_data* pl_sd;
  3207. struct s_mapiterator* iter;
  3208. char party_name[NAME_LENGTH];
  3209. struct party_data *p;
  3210. int count;
  3211. nullpo_retr(-1, sd);
  3212. memset(party_name, '\0', sizeof(party_name));
  3213. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3214. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3215. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3216. return -1;
  3217. }
  3218. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3219. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3220. return -1;
  3221. }
  3222. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3223. (p = party_search(atoi(message))) == NULL)
  3224. {
  3225. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3226. return -1;
  3227. }
  3228. count = 0;
  3229. iter = mapit_getallusers();
  3230. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3231. {
  3232. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3233. {
  3234. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3235. continue; //Skip GMs greater than you.
  3236. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3237. count++;
  3238. else
  3239. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3240. }
  3241. }
  3242. mapit_free(iter);
  3243. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3244. clif_displaymessage(fd, atcmd_output);
  3245. if (count) {
  3246. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3247. clif_displaymessage(fd, atcmd_output);
  3248. }
  3249. return 0;
  3250. }
  3251. /*==========================================
  3252. *
  3253. *------------------------------------------*/
  3254. ACMD_FUNC(reloaditemdb)
  3255. {
  3256. nullpo_retr(-1, sd);
  3257. itemdb_reload();
  3258. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3259. return 0;
  3260. }
  3261. /*==========================================
  3262. *
  3263. *------------------------------------------*/
  3264. ACMD_FUNC(reloadmobdb)
  3265. {
  3266. nullpo_retr(-1, sd);
  3267. mob_reload();
  3268. read_petdb();
  3269. merc_reload();
  3270. read_mercenarydb();
  3271. reload_elementaldb();
  3272. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3273. return 0;
  3274. }
  3275. /*==========================================
  3276. *
  3277. *------------------------------------------*/
  3278. ACMD_FUNC(reloadskilldb)
  3279. {
  3280. nullpo_retr(-1, sd);
  3281. skill_reload();
  3282. merc_skill_reload();
  3283. reload_elemental_skilldb();
  3284. read_mercenary_skilldb();
  3285. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3286. return 0;
  3287. }
  3288. /*==========================================
  3289. * @reloadatcommand - reloads atcommand_athena.conf groups.conf
  3290. *------------------------------------------*/
  3291. void atcommand_doload();
  3292. ACMD_FUNC(reloadatcommand) {
  3293. atcommand_doload();
  3294. pc_groups_reload();
  3295. clif_displaymessage(fd, msg_txt(254));
  3296. return 0;
  3297. }
  3298. /*==========================================
  3299. * @reloadbattleconf - reloads battle_athena.conf
  3300. *------------------------------------------*/
  3301. ACMD_FUNC(reloadbattleconf)
  3302. {
  3303. struct Battle_Config prev_config;
  3304. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3305. battle_config_read(BATTLE_CONF_FILENAME);
  3306. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3307. || prev_config.item_rate_common != battle_config.item_rate_common
  3308. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3309. || prev_config.item_rate_card != battle_config.item_rate_card
  3310. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3311. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3312. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3313. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3314. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3315. || prev_config.item_rate_use != battle_config.item_rate_use
  3316. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3317. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3318. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3319. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3320. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3321. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3322. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3323. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3324. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3325. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3326. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3327. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3328. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3329. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3330. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3331. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3332. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3333. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3334. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3335. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3336. )
  3337. { // Exp or Drop rates changed.
  3338. mob_reload(); //Needed as well so rate changes take effect.
  3339. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3340. }
  3341. clif_displaymessage(fd, msg_txt(255));
  3342. return 0;
  3343. }
  3344. /*==========================================
  3345. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3346. *------------------------------------------*/
  3347. ACMD_FUNC(reloadstatusdb)
  3348. {
  3349. status_readdb();
  3350. clif_displaymessage(fd, msg_txt(256));
  3351. return 0;
  3352. }
  3353. /*==========================================
  3354. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3355. *------------------------------------------*/
  3356. ACMD_FUNC(reloadpcdb)
  3357. {
  3358. pc_readdb();
  3359. clif_displaymessage(fd, msg_txt(257));
  3360. return 0;
  3361. }
  3362. /*==========================================
  3363. * @reloadmotd - reloads motd.txt
  3364. *------------------------------------------*/
  3365. ACMD_FUNC(reloadmotd)
  3366. {
  3367. pc_read_motd();
  3368. clif_displaymessage(fd, msg_txt(268));
  3369. return 0;
  3370. }
  3371. /*==========================================
  3372. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3373. *------------------------------------------*/
  3374. ACMD_FUNC(reloadscript)
  3375. {
  3376. nullpo_retr(-1, sd);
  3377. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3378. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3379. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3380. flush_fifos();
  3381. script_reload();
  3382. npc_reload();
  3383. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3384. return 0;
  3385. }
  3386. /*==========================================
  3387. * @mapinfo [0-3] <map name> by MC_Cameri
  3388. * => Shows information about the map [map name]
  3389. * 0 = no additional information
  3390. * 1 = Show users in that map and their location
  3391. * 2 = Shows NPCs in that map
  3392. * 3 = Shows the shops/chats in that map (not implemented)
  3393. *------------------------------------------*/
  3394. ACMD_FUNC(mapinfo)
  3395. {
  3396. struct map_session_data* pl_sd;
  3397. struct s_mapiterator* iter;
  3398. struct npc_data *nd = NULL;
  3399. struct chat_data *cd = NULL;
  3400. char direction[12];
  3401. int i, m_id, chat_num, list = 0;
  3402. unsigned short m_index;
  3403. char mapname[24];
  3404. nullpo_retr(-1, sd);
  3405. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3406. memset(mapname, '\0', sizeof(mapname));
  3407. memset(direction, '\0', sizeof(direction));
  3408. sscanf(message, "%d %23[^\n]", &list, mapname);
  3409. if (list < 0 || list > 3) {
  3410. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3411. return -1;
  3412. }
  3413. if (mapname[0] == '\0') {
  3414. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3415. m_id = map_mapindex2mapid(sd->mapindex);
  3416. } else {
  3417. m_id = map_mapname2mapid(mapname);
  3418. }
  3419. if (m_id < 0) {
  3420. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3421. return -1;
  3422. }
  3423. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3424. clif_displaymessage(fd, "------ Map Info ------");
  3425. // count chats (for initial message)
  3426. chat_num = 0;
  3427. iter = mapit_getallusers();
  3428. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3429. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3430. chat_num++;
  3431. mapit_free(iter);
  3432. 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);
  3433. clif_displaymessage(fd, atcmd_output);
  3434. clif_displaymessage(fd, "------ Map Flags ------");
  3435. if (map[m_id].flag.town)
  3436. clif_displaymessage(fd, "Town Map");
  3437. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3438. clif_displaymessage(fd, "Autotrade Enabled");
  3439. else
  3440. clif_displaymessage(fd, "Autotrade Disabled");
  3441. if (map[m_id].flag.battleground)
  3442. clif_displaymessage(fd, "Battlegrounds ON");
  3443. strcpy(atcmd_output,"PvP Flags: ");
  3444. if (map[m_id].flag.pvp)
  3445. strcat(atcmd_output, "Pvp ON | ");
  3446. if (map[m_id].flag.pvp_noguild)
  3447. strcat(atcmd_output, "NoGuild | ");
  3448. if (map[m_id].flag.pvp_noparty)
  3449. strcat(atcmd_output, "NoParty | ");
  3450. if (map[m_id].flag.pvp_nightmaredrop)
  3451. strcat(atcmd_output, "NightmareDrop | ");
  3452. if (map[m_id].flag.pvp_nocalcrank)
  3453. strcat(atcmd_output, "NoCalcRank | ");
  3454. clif_displaymessage(fd, atcmd_output);
  3455. strcpy(atcmd_output,"GvG Flags: ");
  3456. if (map[m_id].flag.gvg)
  3457. strcat(atcmd_output, "GvG ON | ");
  3458. if (map[m_id].flag.gvg_dungeon)
  3459. strcat(atcmd_output, "GvG Dungeon | ");
  3460. if (map[m_id].flag.gvg_castle)
  3461. strcat(atcmd_output, "GvG Castle | ");
  3462. if (map[m_id].flag.gvg_noparty)
  3463. strcat(atcmd_output, "NoParty | ");
  3464. clif_displaymessage(fd, atcmd_output);
  3465. strcpy(atcmd_output,"Teleport Flags: ");
  3466. if (map[m_id].flag.noteleport)
  3467. strcat(atcmd_output, "NoTeleport | ");
  3468. if (map[m_id].flag.monster_noteleport)
  3469. strcat(atcmd_output, "Monster NoTeleport | ");
  3470. if (map[m_id].flag.nowarp)
  3471. strcat(atcmd_output, "NoWarp | ");
  3472. if (map[m_id].flag.nowarpto)
  3473. strcat(atcmd_output, "NoWarpTo | ");
  3474. if (map[m_id].flag.noreturn)
  3475. strcat(atcmd_output, "NoReturn | ");
  3476. if (map[m_id].flag.nogo)
  3477. strcat(atcmd_output, "NoGo | ");
  3478. if (map[m_id].flag.nomemo)
  3479. strcat(atcmd_output, "NoMemo | ");
  3480. clif_displaymessage(fd, atcmd_output);
  3481. 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");
  3482. clif_displaymessage(fd, atcmd_output);
  3483. if (map[m_id].flag.nosave) {
  3484. if (!map[m_id].save.map)
  3485. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3486. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3487. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3488. else
  3489. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3490. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3491. clif_displaymessage(fd, atcmd_output);
  3492. }
  3493. strcpy(atcmd_output,"Weather Flags: ");
  3494. if (map[m_id].flag.snow)
  3495. strcat(atcmd_output, "Snow | ");
  3496. if (map[m_id].flag.fog)
  3497. strcat(atcmd_output, "Fog | ");
  3498. if (map[m_id].flag.sakura)
  3499. strcat(atcmd_output, "Sakura | ");
  3500. if (map[m_id].flag.clouds)
  3501. strcat(atcmd_output, "Clouds | ");
  3502. if (map[m_id].flag.clouds2)
  3503. strcat(atcmd_output, "Clouds2 | ");
  3504. if (map[m_id].flag.fireworks)
  3505. strcat(atcmd_output, "Fireworks | ");
  3506. if (map[m_id].flag.leaves)
  3507. strcat(atcmd_output, "Leaves | ");
  3508. /**
  3509. * No longer available, keeping here just in case it's back someday. [Ind]
  3510. **/
  3511. //if (map[m_id].flag.rain)
  3512. // strcat(atcmd_output, "Rain | ");
  3513. if (map[m_id].flag.nightenabled)
  3514. strcat(atcmd_output, "Displays Night | ");
  3515. clif_displaymessage(fd, atcmd_output);
  3516. strcpy(atcmd_output,"Other Flags: ");
  3517. if (map[m_id].flag.nobranch)
  3518. strcat(atcmd_output, "NoBranch | ");
  3519. if (map[m_id].flag.notrade)
  3520. strcat(atcmd_output, "NoTrade | ");
  3521. if (map[m_id].flag.novending)
  3522. strcat(atcmd_output, "NoVending | ");
  3523. if (map[m_id].flag.nodrop)
  3524. strcat(atcmd_output, "NoDrop | ");
  3525. if (map[m_id].flag.noskill)
  3526. strcat(atcmd_output, "NoSkill | ");
  3527. if (map[m_id].flag.noicewall)
  3528. strcat(atcmd_output, "NoIcewall | ");
  3529. if (map[m_id].flag.allowks)
  3530. strcat(atcmd_output, "AllowKS | ");
  3531. if (map[m_id].flag.reset)
  3532. strcat(atcmd_output, "Reset | ");
  3533. clif_displaymessage(fd, atcmd_output);
  3534. strcpy(atcmd_output,"Other Flags: ");
  3535. if (map[m_id].nocommand)
  3536. strcat(atcmd_output, "NoCommand | ");
  3537. if (map[m_id].flag.nobaseexp)
  3538. strcat(atcmd_output, "NoBaseEXP | ");
  3539. if (map[m_id].flag.nojobexp)
  3540. strcat(atcmd_output, "NoJobEXP | ");
  3541. if (map[m_id].flag.nomobloot)
  3542. strcat(atcmd_output, "NoMobLoot | ");
  3543. if (map[m_id].flag.nomvploot)
  3544. strcat(atcmd_output, "NoMVPLoot | ");
  3545. if (map[m_id].flag.partylock)
  3546. strcat(atcmd_output, "PartyLock | ");
  3547. if (map[m_id].flag.guildlock)
  3548. strcat(atcmd_output, "GuildLock | ");
  3549. clif_displaymessage(fd, atcmd_output);
  3550. switch (list) {
  3551. case 0:
  3552. // Do nothing. It's list 0, no additional display.
  3553. break;
  3554. case 1:
  3555. clif_displaymessage(fd, "----- Players in Map -----");
  3556. iter = mapit_getallusers();
  3557. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3558. {
  3559. if (pl_sd->mapindex == m_index) {
  3560. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3561. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3562. clif_displaymessage(fd, atcmd_output);
  3563. }
  3564. }
  3565. mapit_free(iter);
  3566. break;
  3567. case 2:
  3568. clif_displaymessage(fd, "----- NPCs in Map -----");
  3569. for (i = 0; i < map[m_id].npc_num;)
  3570. {
  3571. nd = map[m_id].npc[i];
  3572. switch(nd->ud.dir) {
  3573. case 0: strcpy(direction, "North"); break;
  3574. case 1: strcpy(direction, "North West"); break;
  3575. case 2: strcpy(direction, "West"); break;
  3576. case 3: strcpy(direction, "South West"); break;
  3577. case 4: strcpy(direction, "South"); break;
  3578. case 5: strcpy(direction, "South East"); break;
  3579. case 6: strcpy(direction, "East"); break;
  3580. case 7: strcpy(direction, "North East"); break;
  3581. case 9: strcpy(direction, "North"); break;
  3582. default: strcpy(direction, "Unknown"); break;
  3583. }
  3584. if(strcmp(nd->name,nd->exname) == 0)
  3585. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3586. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3587. else
  3588. sprintf(atcmd_output, "NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d",
  3589. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3590. clif_displaymessage(fd, atcmd_output);
  3591. }
  3592. break;
  3593. case 3:
  3594. clif_displaymessage(fd, "----- Chats in Map -----");
  3595. iter = mapit_getallusers();
  3596. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3597. {
  3598. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3599. pl_sd->mapindex == m_index &&
  3600. cd->usersd[0] == pl_sd)
  3601. {
  3602. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  3603. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3604. clif_displaymessage(fd, atcmd_output);
  3605. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3606. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3607. clif_displaymessage(fd, atcmd_output);
  3608. }
  3609. }
  3610. mapit_free(iter);
  3611. break;
  3612. default: // normally impossible to arrive here
  3613. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3614. return -1;
  3615. break;
  3616. }
  3617. return 0;
  3618. }
  3619. /*==========================================
  3620. *
  3621. *------------------------------------------*/
  3622. ACMD_FUNC(mount_peco)
  3623. {
  3624. nullpo_retr(-1, sd);
  3625. if (sd->disguise) {
  3626. clif_displaymessage(fd, msg_txt(212)); // Cannot mount while in disguise.
  3627. return -1;
  3628. }
  3629. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3630. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3631. clif_displaymessage(sd->fd,"You have mounted your Dragon");
  3632. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3633. } else {
  3634. clif_displaymessage(sd->fd,"You have released your Dragon");
  3635. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3636. }
  3637. return 0;
  3638. }
  3639. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  3640. if( !pc_isridingwug(sd) ) {
  3641. clif_displaymessage(sd->fd,"You have mounted your Wug");
  3642. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3643. } else {
  3644. clif_displaymessage(sd->fd,"You have released your Wug");
  3645. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3646. }
  3647. return 0;
  3648. }
  3649. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3650. if( !(sd->sc.option&OPTION_MADOGEAR) ) {
  3651. clif_displaymessage(sd->fd,"You have mounted your Mado Gear");
  3652. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3653. } else {
  3654. clif_displaymessage(sd->fd,"You have released your Mado Gear");
  3655. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3656. }
  3657. return 0;
  3658. }
  3659. if (!pc_isriding(sd)) { // if actually no peco
  3660. if (!pc_checkskill(sd, KN_RIDING)) {
  3661. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  3662. return -1;
  3663. }
  3664. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3665. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  3666. } else {//Dismount
  3667. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3668. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  3669. }
  3670. return 0;
  3671. }
  3672. /*==========================================
  3673. *Spy Commands by Syrus22
  3674. *------------------------------------------*/
  3675. ACMD_FUNC(guildspy)
  3676. {
  3677. char guild_name[NAME_LENGTH];
  3678. struct guild *g;
  3679. nullpo_retr(-1, sd);
  3680. memset(guild_name, '\0', sizeof(guild_name));
  3681. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3682. if (!enable_spy)
  3683. {
  3684. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3685. return -1;
  3686. }
  3687. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3688. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3689. return -1;
  3690. }
  3691. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3692. (g = guild_search(atoi(message))) != NULL) {
  3693. if (sd->guildspy == g->guild_id) {
  3694. sd->guildspy = 0;
  3695. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3696. clif_displaymessage(fd, atcmd_output);
  3697. } else {
  3698. sd->guildspy = g->guild_id;
  3699. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3700. clif_displaymessage(fd, atcmd_output);
  3701. }
  3702. } else {
  3703. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  3704. return -1;
  3705. }
  3706. return 0;
  3707. }
  3708. /*==========================================
  3709. *
  3710. *------------------------------------------*/
  3711. ACMD_FUNC(partyspy)
  3712. {
  3713. char party_name[NAME_LENGTH];
  3714. struct party_data *p;
  3715. nullpo_retr(-1, sd);
  3716. memset(party_name, '\0', sizeof(party_name));
  3717. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3718. if (!enable_spy)
  3719. {
  3720. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3721. return -1;
  3722. }
  3723. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3724. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3725. return -1;
  3726. }
  3727. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3728. (p = party_search(atoi(message))) != NULL) {
  3729. if (sd->partyspy == p->party.party_id) {
  3730. sd->partyspy = 0;
  3731. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3732. clif_displaymessage(fd, atcmd_output);
  3733. } else {
  3734. sd->partyspy = p->party.party_id;
  3735. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3736. clif_displaymessage(fd, atcmd_output);
  3737. }
  3738. } else {
  3739. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  3740. return -1;
  3741. }
  3742. return 0;
  3743. }
  3744. /*==========================================
  3745. * @repairall [Valaris]
  3746. *------------------------------------------*/
  3747. ACMD_FUNC(repairall)
  3748. {
  3749. int count, i;
  3750. nullpo_retr(-1, sd);
  3751. count = 0;
  3752. for (i = 0; i < MAX_INVENTORY; i++) {
  3753. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3754. sd->status.inventory[i].attribute = 0;
  3755. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3756. count++;
  3757. }
  3758. }
  3759. if (count > 0) {
  3760. clif_misceffect(&sd->bl, 3);
  3761. clif_equiplist(sd);
  3762. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3763. } else {
  3764. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3765. return -1;
  3766. }
  3767. return 0;
  3768. }
  3769. /*==========================================
  3770. * @nuke [Valaris]
  3771. *------------------------------------------*/
  3772. ACMD_FUNC(nuke)
  3773. {
  3774. struct map_session_data *pl_sd;
  3775. nullpo_retr(-1, sd);
  3776. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3777. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3778. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  3779. return -1;
  3780. }
  3781. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3782. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3783. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3784. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3785. } else {
  3786. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3787. return -1;
  3788. }
  3789. } else {
  3790. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3791. return -1;
  3792. }
  3793. return 0;
  3794. }
  3795. /*==========================================
  3796. * @tonpc
  3797. *------------------------------------------*/
  3798. ACMD_FUNC(tonpc)
  3799. {
  3800. char npcname[NAME_LENGTH+1];
  3801. struct npc_data *nd;
  3802. nullpo_retr(-1, sd);
  3803. memset(npcname, 0, sizeof(npcname));
  3804. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3805. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  3806. return -1;
  3807. }
  3808. if ((nd = npc_name2id(npcname)) != NULL) {
  3809. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3810. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3811. else
  3812. return -1;
  3813. } else {
  3814. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3815. return -1;
  3816. }
  3817. return 0;
  3818. }
  3819. /*==========================================
  3820. *
  3821. *------------------------------------------*/
  3822. ACMD_FUNC(shownpc)
  3823. {
  3824. char NPCname[NAME_LENGTH+1];
  3825. nullpo_retr(-1, sd);
  3826. memset(NPCname, '\0', sizeof(NPCname));
  3827. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3828. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  3829. return -1;
  3830. }
  3831. if (npc_name2id(NPCname) != NULL) {
  3832. npc_enable(NPCname, 1);
  3833. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  3834. } else {
  3835. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3836. return -1;
  3837. }
  3838. return 0;
  3839. }
  3840. /*==========================================
  3841. *
  3842. *------------------------------------------*/
  3843. ACMD_FUNC(hidenpc)
  3844. {
  3845. char NPCname[NAME_LENGTH+1];
  3846. nullpo_retr(-1, sd);
  3847. memset(NPCname, '\0', sizeof(NPCname));
  3848. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3849. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  3850. return -1;
  3851. }
  3852. if (npc_name2id(NPCname) == NULL) {
  3853. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3854. return -1;
  3855. }
  3856. npc_enable(NPCname, 0);
  3857. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3858. return 0;
  3859. }
  3860. ACMD_FUNC(loadnpc)
  3861. {
  3862. FILE *fp;
  3863. if (!message || !*message) {
  3864. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  3865. return -1;
  3866. }
  3867. // check if script file exists
  3868. if ((fp = fopen(message, "r")) == NULL) {
  3869. clif_displaymessage(fd, msg_txt(261));
  3870. return -1;
  3871. }
  3872. fclose(fp);
  3873. // add to list of script sources and run it
  3874. npc_addsrcfile(message);
  3875. npc_parsesrcfile(message);
  3876. npc_read_event_script();
  3877. clif_displaymessage(fd, msg_txt(262));
  3878. return 0;
  3879. }
  3880. ACMD_FUNC(unloadnpc)
  3881. {
  3882. struct npc_data *nd;
  3883. char NPCname[NAME_LENGTH+1];
  3884. nullpo_retr(-1, sd);
  3885. memset(NPCname, '\0', sizeof(NPCname));
  3886. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3887. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  3888. return -1;
  3889. }
  3890. if ((nd = npc_name2id(NPCname)) == NULL) {
  3891. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3892. return -1;
  3893. }
  3894. npc_unload_duplicates(nd);
  3895. npc_unload(nd);
  3896. npc_read_event_script();
  3897. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3898. return 0;
  3899. }
  3900. /*==========================================
  3901. * time in txt for time command (by [Yor])
  3902. *------------------------------------------*/
  3903. char* txt_time(unsigned int duration)
  3904. {
  3905. int days, hours, minutes, seconds;
  3906. char temp[CHAT_SIZE_MAX];
  3907. static char temp1[CHAT_SIZE_MAX];
  3908. memset(temp, '\0', sizeof(temp));
  3909. memset(temp1, '\0', sizeof(temp1));
  3910. days = duration / (60 * 60 * 24);
  3911. duration = duration - (60 * 60 * 24 * days);
  3912. hours = duration / (60 * 60);
  3913. duration = duration - (60 * 60 * hours);
  3914. minutes = duration / 60;
  3915. seconds = duration - (60 * minutes);
  3916. if (days < 2)
  3917. sprintf(temp, msg_txt(219), days); // %d day
  3918. else
  3919. sprintf(temp, msg_txt(220), days); // %d days
  3920. if (hours < 2)
  3921. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  3922. else
  3923. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  3924. if (minutes < 2)
  3925. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  3926. else
  3927. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  3928. if (seconds < 2)
  3929. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  3930. else
  3931. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  3932. return temp1;
  3933. }
  3934. /*==========================================
  3935. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3936. * Calculation management of GM modification (@day/@night GM commands) is done
  3937. *------------------------------------------*/
  3938. ACMD_FUNC(servertime)
  3939. {
  3940. const struct TimerData * timer_data;
  3941. const struct TimerData * timer_data2;
  3942. time_t time_server; // variable for number of seconds (used with time() function)
  3943. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3944. char temp[CHAT_SIZE_MAX];
  3945. nullpo_retr(-1, sd);
  3946. memset(temp, '\0', sizeof(temp));
  3947. time(&time_server); // get time in seconds since 1/1/1970
  3948. datetime = localtime(&time_server); // convert seconds in structure
  3949. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3950. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3951. clif_displaymessage(fd, temp);
  3952. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3953. if (night_flag == 0)
  3954. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3955. else
  3956. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3957. } else if (battle_config.night_duration == 0)
  3958. if (night_flag == 1) { // we start with night
  3959. timer_data = get_timer(day_timer_tid);
  3960. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  3961. clif_displaymessage(fd, temp);
  3962. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  3963. } else
  3964. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3965. else if (battle_config.day_duration == 0)
  3966. if (night_flag == 0) { // we start with day
  3967. timer_data = get_timer(night_timer_tid);
  3968. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3969. clif_displaymessage(fd, temp);
  3970. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  3971. } else
  3972. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3973. else {
  3974. if (night_flag == 0) {
  3975. timer_data = get_timer(night_timer_tid);
  3976. timer_data2 = get_timer(day_timer_tid);
  3977. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3978. clif_displaymessage(fd, temp);
  3979. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3980. 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.
  3981. else
  3982. 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.
  3983. clif_displaymessage(fd, temp);
  3984. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3985. clif_displaymessage(fd, temp);
  3986. } else {
  3987. timer_data = get_timer(day_timer_tid);
  3988. timer_data2 = get_timer(night_timer_tid);
  3989. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  3990. clif_displaymessage(fd, temp);
  3991. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3992. 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.
  3993. else
  3994. 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.
  3995. clif_displaymessage(fd, temp);
  3996. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3997. clif_displaymessage(fd, temp);
  3998. }
  3999. }
  4000. return 0;
  4001. }
  4002. //Added by Coltaro
  4003. //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...).
  4004. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4005. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4006. {
  4007. const int factor_year = 518400; //12*30*24*60 = 518400
  4008. const int factor_month = 43200; //30*24*60 = 43200
  4009. const int factor_day = 1440; //24*60 = 1440
  4010. const int factor_hour = 60;
  4011. *year = jailtime/factor_year;
  4012. jailtime -= *year*factor_year;
  4013. *month = jailtime/factor_month;
  4014. jailtime -= *month*factor_month;
  4015. *day = jailtime/factor_day;
  4016. jailtime -= *day*factor_day;
  4017. *hour = jailtime/factor_hour;
  4018. jailtime -= *hour*factor_hour;
  4019. *minute = jailtime;
  4020. *year = *year > 0? *year : 0;
  4021. *month = *month > 0? *month : 0;
  4022. *day = *day > 0? *day : 0;
  4023. *hour = *hour > 0? *hour : 0;
  4024. *minute = *minute > 0? *minute : 0;
  4025. return;
  4026. }
  4027. /*==========================================
  4028. * @jail <char_name> by [Yor]
  4029. * Special warp! No check with nowarp and nowarpto flag
  4030. *------------------------------------------*/
  4031. ACMD_FUNC(jail)
  4032. {
  4033. struct map_session_data *pl_sd;
  4034. int x, y;
  4035. unsigned short m_index;
  4036. nullpo_retr(-1, sd);
  4037. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4038. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4039. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4040. return -1;
  4041. }
  4042. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4043. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4044. return -1;
  4045. }
  4046. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  4047. { // you can jail only lower or same GM
  4048. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4049. return -1;
  4050. }
  4051. if (pl_sd->sc.data[SC_JAILED])
  4052. {
  4053. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4054. return -1;
  4055. }
  4056. switch(rnd() % 2) { //Jail Locations
  4057. case 0:
  4058. m_index = mapindex_name2id(MAP_JAIL);
  4059. x = 24;
  4060. y = 75;
  4061. break;
  4062. default:
  4063. m_index = mapindex_name2id(MAP_JAIL);
  4064. x = 49;
  4065. y = 75;
  4066. break;
  4067. }
  4068. //Duration of INT_MAX to specify infinity.
  4069. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4070. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4071. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4072. return 0;
  4073. }
  4074. /*==========================================
  4075. * @unjail/@discharge <char_name> by [Yor]
  4076. * Special warp! No check with nowarp and nowarpto flag
  4077. *------------------------------------------*/
  4078. ACMD_FUNC(unjail)
  4079. {
  4080. struct map_session_data *pl_sd;
  4081. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4082. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4083. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4084. return -1;
  4085. }
  4086. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4087. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4088. return -1;
  4089. }
  4090. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4091. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4092. return -1;
  4093. }
  4094. if (!pl_sd->sc.data[SC_JAILED])
  4095. {
  4096. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4097. return -1;
  4098. }
  4099. //Reset jail time to 1 sec.
  4100. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4101. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4102. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4103. return 0;
  4104. }
  4105. ACMD_FUNC(jailfor)
  4106. {
  4107. struct map_session_data *pl_sd = NULL;
  4108. int year, month, day, hour, minute, value;
  4109. char * modif_p;
  4110. int jailtime = 0,x,y;
  4111. short m_index = 0;
  4112. nullpo_retr(-1, sd);
  4113. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4114. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4115. return -1;
  4116. }
  4117. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4118. modif_p = atcmd_output;
  4119. year = month = day = hour = minute = 0;
  4120. while (modif_p[0] != '\0') {
  4121. value = atoi(modif_p);
  4122. if (value == 0)
  4123. modif_p++;
  4124. else {
  4125. if (modif_p[0] == '-' || modif_p[0] == '+')
  4126. modif_p++;
  4127. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4128. modif_p++;
  4129. if (modif_p[0] == 'n') {
  4130. minute = value;
  4131. modif_p++;
  4132. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4133. minute = value;
  4134. modif_p = modif_p + 2;
  4135. } else if (modif_p[0] == 'h') {
  4136. hour = value;
  4137. modif_p++;
  4138. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4139. day = value;
  4140. modif_p++;
  4141. } else if (modif_p[0] == 'm') {
  4142. month = value;
  4143. modif_p++;
  4144. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4145. year = value;
  4146. modif_p++;
  4147. } else if (modif_p[0] != '\0') {
  4148. modif_p++;
  4149. }
  4150. }
  4151. }
  4152. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4153. clif_displaymessage(fd, "Invalid time for jail command.");
  4154. return -1;
  4155. }
  4156. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4157. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4158. return -1;
  4159. }
  4160. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4161. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4162. return -1;
  4163. }
  4164. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4165. if(jailtime==0) {
  4166. clif_displaymessage(fd, "Invalid time for jail command.");
  4167. return -1;
  4168. }
  4169. //Added by Coltaro
  4170. if(pl_sd->sc.data[SC_JAILED] &&
  4171. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4172. { //Update the player's jail time
  4173. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4174. if (jailtime <= 0) {
  4175. jailtime = 0;
  4176. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4177. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4178. } else {
  4179. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4180. 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
  4181. clif_displaymessage(pl_sd->fd, atcmd_output);
  4182. 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
  4183. clif_displaymessage(fd, atcmd_output);
  4184. }
  4185. } else if (jailtime < 0) {
  4186. clif_displaymessage(fd, "Invalid time for jail command.");
  4187. return -1;
  4188. }
  4189. //Jail locations, add more as you wish.
  4190. switch(rnd()%2)
  4191. {
  4192. case 1: //Jail #1
  4193. m_index = mapindex_name2id(MAP_JAIL);
  4194. x = 49; y = 75;
  4195. break;
  4196. default: //Default Jail
  4197. m_index = mapindex_name2id(MAP_JAIL);
  4198. x = 24; y = 75;
  4199. break;
  4200. }
  4201. 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).
  4202. return 0;
  4203. }
  4204. //By Coltaro
  4205. ACMD_FUNC(jailtime)
  4206. {
  4207. int year, month, day, hour, minute;
  4208. nullpo_retr(-1, sd);
  4209. if (!sd->sc.data[SC_JAILED]) {
  4210. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4211. return -1;
  4212. }
  4213. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4214. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4215. return 0;
  4216. }
  4217. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4218. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4219. return -1;
  4220. }
  4221. //Get remaining jail time
  4222. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4223. 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
  4224. clif_displaymessage(fd, atcmd_output);
  4225. return 0;
  4226. }
  4227. /*==========================================
  4228. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4229. *------------------------------------------*/
  4230. ACMD_FUNC(disguise)
  4231. {
  4232. int id = 0;
  4233. nullpo_retr(-1, sd);
  4234. if (!message || !*message) {
  4235. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4236. return -1;
  4237. }
  4238. if ((id = atoi(message)) > 0)
  4239. { //Acquired an ID
  4240. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4241. id = 0; //Invalid id for either mobs or npcs.
  4242. } else { //Acquired a Name
  4243. if ((id = mobdb_searchname(message)) == 0)
  4244. {
  4245. struct npc_data* nd = npc_name2id(message);
  4246. if (nd != NULL)
  4247. id = nd->class_;
  4248. }
  4249. }
  4250. if (id == 0)
  4251. {
  4252. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4253. return -1;
  4254. }
  4255. if(pc_isriding(sd))
  4256. {
  4257. //FIXME: wrong message [ultramage]
  4258. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4259. return -1;
  4260. }
  4261. pc_disguise(sd, id);
  4262. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4263. return 0;
  4264. }
  4265. /*==========================================
  4266. * DisguiseAll
  4267. *------------------------------------------*/
  4268. ACMD_FUNC(disguiseall)
  4269. {
  4270. int mob_id=0;
  4271. struct map_session_data *pl_sd;
  4272. struct s_mapiterator* iter;
  4273. nullpo_retr(-1, sd);
  4274. if (!message || !*message) {
  4275. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4276. return -1;
  4277. }
  4278. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4279. mob_id = atoi(message);
  4280. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4281. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4282. return -1;
  4283. }
  4284. iter = mapit_getallusers();
  4285. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4286. pc_disguise(pl_sd, mob_id);
  4287. mapit_free(iter);
  4288. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4289. return 0;
  4290. }
  4291. /*==========================================
  4292. * @undisguise by [Yor]
  4293. *------------------------------------------*/
  4294. ACMD_FUNC(undisguise)
  4295. {
  4296. nullpo_retr(-1, sd);
  4297. if (sd->disguise) {
  4298. pc_disguise(sd, 0);
  4299. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4300. } else {
  4301. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4302. return -1;
  4303. }
  4304. return 0;
  4305. }
  4306. /*==========================================
  4307. * UndisguiseAll
  4308. *------------------------------------------*/
  4309. ACMD_FUNC(undisguiseall)
  4310. {
  4311. struct map_session_data *pl_sd;
  4312. struct s_mapiterator* iter;
  4313. nullpo_retr(-1, sd);
  4314. iter = mapit_getallusers();
  4315. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4316. if( pl_sd->disguise )
  4317. pc_disguise(pl_sd, 0);
  4318. mapit_free(iter);
  4319. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4320. return 0;
  4321. }
  4322. /*==========================================
  4323. * @exp by [Skotlex]
  4324. *------------------------------------------*/
  4325. ACMD_FUNC(exp)
  4326. {
  4327. char output[CHAT_SIZE_MAX];
  4328. double nextb, nextj;
  4329. nullpo_retr(-1, sd);
  4330. memset(output, '\0', sizeof(output));
  4331. nextb = pc_nextbaseexp(sd);
  4332. if (nextb)
  4333. nextb = sd->status.base_exp*100.0/nextb;
  4334. nextj = pc_nextjobexp(sd);
  4335. if (nextj)
  4336. nextj = sd->status.job_exp*100.0/nextj;
  4337. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4338. clif_displaymessage(fd, output);
  4339. return 0;
  4340. }
  4341. /*==========================================
  4342. * @broadcast by [Valaris]
  4343. *------------------------------------------*/
  4344. ACMD_FUNC(broadcast)
  4345. {
  4346. nullpo_retr(-1, sd);
  4347. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4348. if (!message || !*message) {
  4349. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4350. return -1;
  4351. }
  4352. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4353. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4354. return 0;
  4355. }
  4356. /*==========================================
  4357. * @localbroadcast by [Valaris]
  4358. *------------------------------------------*/
  4359. ACMD_FUNC(localbroadcast)
  4360. {
  4361. nullpo_retr(-1, sd);
  4362. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4363. if (!message || !*message) {
  4364. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4365. return -1;
  4366. }
  4367. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4368. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4369. return 0;
  4370. }
  4371. /*==========================================
  4372. * @email <actual@email> <new@email> by [Yor]
  4373. *------------------------------------------*/
  4374. ACMD_FUNC(email)
  4375. {
  4376. char actual_email[100];
  4377. char new_email[100];
  4378. nullpo_retr(-1, sd);
  4379. memset(actual_email, '\0', sizeof(actual_email));
  4380. memset(new_email, '\0', sizeof(new_email));
  4381. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4382. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4383. return -1;
  4384. }
  4385. if (e_mail_check(actual_email) == 0) {
  4386. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4387. return -1;
  4388. } else if (e_mail_check(new_email) == 0) {
  4389. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4390. return -1;
  4391. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4392. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4393. return -1;
  4394. } else if (strcmpi(actual_email, new_email) == 0) {
  4395. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4396. return -1;
  4397. }
  4398. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4399. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4400. return 0;
  4401. }
  4402. /*==========================================
  4403. *@effect
  4404. *------------------------------------------*/
  4405. ACMD_FUNC(effect)
  4406. {
  4407. int type = 0, flag = 0;
  4408. nullpo_retr(-1, sd);
  4409. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4410. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4411. return -1;
  4412. }
  4413. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4414. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4415. return 0;
  4416. }
  4417. /*==========================================
  4418. * @killer by MouseJstr
  4419. * enable killing players even when not in pvp
  4420. *------------------------------------------*/
  4421. ACMD_FUNC(killer)
  4422. {
  4423. nullpo_retr(-1, sd);
  4424. sd->state.killer = !sd->state.killer;
  4425. if(sd->state.killer)
  4426. clif_displaymessage(fd, msg_txt(241));
  4427. else {
  4428. clif_displaymessage(fd, msg_txt(287));
  4429. pc_stop_attack(sd);
  4430. }
  4431. return 0;
  4432. }
  4433. /*==========================================
  4434. * @killable by MouseJstr
  4435. * enable other people killing you
  4436. *------------------------------------------*/
  4437. ACMD_FUNC(killable)
  4438. {
  4439. nullpo_retr(-1, sd);
  4440. sd->state.killable = !sd->state.killable;
  4441. if(sd->state.killable)
  4442. clif_displaymessage(fd, msg_txt(242));
  4443. else {
  4444. clif_displaymessage(fd, msg_txt(288));
  4445. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4446. }
  4447. return 0;
  4448. }
  4449. /*==========================================
  4450. * @skillon by MouseJstr
  4451. * turn skills on for the map
  4452. *------------------------------------------*/
  4453. ACMD_FUNC(skillon)
  4454. {
  4455. nullpo_retr(-1, sd);
  4456. map[sd->bl.m].flag.noskill = 0;
  4457. clif_displaymessage(fd, msg_txt(244));
  4458. return 0;
  4459. }
  4460. /*==========================================
  4461. * @skilloff by MouseJstr
  4462. * Turn skills off on the map
  4463. *------------------------------------------*/
  4464. ACMD_FUNC(skilloff)
  4465. {
  4466. nullpo_retr(-1, sd);
  4467. map[sd->bl.m].flag.noskill = 1;
  4468. clif_displaymessage(fd, msg_txt(243));
  4469. return 0;
  4470. }
  4471. /*==========================================
  4472. * @npcmove by MouseJstr
  4473. * move a npc
  4474. *------------------------------------------*/
  4475. ACMD_FUNC(npcmove)
  4476. {
  4477. int x = 0, y = 0, m;
  4478. struct npc_data *nd = 0;
  4479. nullpo_retr(-1, sd);
  4480. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4481. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4482. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4483. return -1;
  4484. }
  4485. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4486. {
  4487. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4488. return -1;
  4489. }
  4490. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4491. {
  4492. clif_displaymessage(fd, "NPC is not on this map.");
  4493. return -1; //Not on a map.
  4494. }
  4495. x = cap_value(x, 0, map[m].xs-1);
  4496. y = cap_value(y, 0, map[m].ys-1);
  4497. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4498. map_moveblock(&nd->bl, x, y, gettick());
  4499. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4500. clif_displaymessage(fd, "NPC moved.");
  4501. return 0;
  4502. }
  4503. /*==========================================
  4504. * @addwarp by MouseJstr
  4505. * Create a new static warp point.
  4506. *------------------------------------------*/
  4507. ACMD_FUNC(addwarp)
  4508. {
  4509. char mapname[32];
  4510. int x,y;
  4511. unsigned short m;
  4512. struct npc_data* nd;
  4513. nullpo_retr(-1, sd);
  4514. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4515. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4516. return -1;
  4517. }
  4518. m = mapindex_name2id(mapname);
  4519. if( m == 0 )
  4520. {
  4521. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4522. clif_displaymessage(fd, atcmd_output);
  4523. return -1;
  4524. }
  4525. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4526. if( nd == NULL )
  4527. return -1;
  4528. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4529. clif_displaymessage(fd, atcmd_output);
  4530. return 0;
  4531. }
  4532. /*==========================================
  4533. * @follow by [MouseJstr]
  4534. * Follow a player .. staying no more then 5 spaces away
  4535. *------------------------------------------*/
  4536. ACMD_FUNC(follow)
  4537. {
  4538. struct map_session_data *pl_sd = NULL;
  4539. nullpo_retr(-1, sd);
  4540. if (!message || !*message) {
  4541. if (sd->followtarget == -1)
  4542. return -1;
  4543. pc_stop_following (sd);
  4544. clif_displaymessage(fd, "Follow mode OFF.");
  4545. return 0;
  4546. }
  4547. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4548. {
  4549. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4550. return -1;
  4551. }
  4552. if (sd->followtarget == pl_sd->bl.id) {
  4553. pc_stop_following (sd);
  4554. clif_displaymessage(fd, "Follow mode OFF.");
  4555. } else {
  4556. pc_follow(sd, pl_sd->bl.id);
  4557. clif_displaymessage(fd, "Follow mode ON.");
  4558. }
  4559. return 0;
  4560. }
  4561. /*==========================================
  4562. * @dropall by [MouseJstr]
  4563. * Drop all your possession on the ground
  4564. *------------------------------------------*/
  4565. ACMD_FUNC(dropall)
  4566. {
  4567. int i;
  4568. nullpo_retr(-1, sd);
  4569. for (i = 0; i < MAX_INVENTORY; i++) {
  4570. if (sd->status.inventory[i].amount) {
  4571. if(sd->status.inventory[i].equip != 0)
  4572. pc_unequipitem(sd, i, 3);
  4573. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4574. }
  4575. }
  4576. return 0;
  4577. }
  4578. /*==========================================
  4579. * @storeall by [MouseJstr]
  4580. * Put everything into storage
  4581. *------------------------------------------*/
  4582. ACMD_FUNC(storeall)
  4583. {
  4584. int i;
  4585. nullpo_retr(-1, sd);
  4586. if (sd->state.storage_flag != 1)
  4587. { //Open storage.
  4588. if( storage_storageopen(sd) == 1 ) {
  4589. clif_displaymessage(fd, "You can't open the storage currently.");
  4590. return -1;
  4591. }
  4592. }
  4593. for (i = 0; i < MAX_INVENTORY; i++) {
  4594. if (sd->status.inventory[i].amount) {
  4595. if(sd->status.inventory[i].equip != 0)
  4596. pc_unequipitem(sd, i, 3);
  4597. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4598. }
  4599. }
  4600. storage_storageclose(sd);
  4601. clif_displaymessage(fd, "It is done");
  4602. return 0;
  4603. }
  4604. /*==========================================
  4605. * @skillid by [MouseJstr]
  4606. * lookup a skill by name
  4607. *------------------------------------------*/
  4608. ACMD_FUNC(skillid)
  4609. {
  4610. int skillen, idx;
  4611. nullpo_retr(-1, sd);
  4612. if (!message || !*message)
  4613. {
  4614. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4615. return -1;
  4616. }
  4617. skillen = strlen(message);
  4618. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4619. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4620. {
  4621. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4622. clif_displaymessage(fd, atcmd_output);
  4623. }
  4624. }
  4625. return 0;
  4626. }
  4627. /*==========================================
  4628. * @useskill by [MouseJstr]
  4629. * A way of using skills without having to find them in the skills menu
  4630. *------------------------------------------*/
  4631. ACMD_FUNC(useskill)
  4632. {
  4633. struct map_session_data *pl_sd = NULL;
  4634. struct block_list *bl;
  4635. int skillnum;
  4636. int skilllv;
  4637. char target[100];
  4638. nullpo_retr(-1, sd);
  4639. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4640. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4641. return -1;
  4642. }
  4643. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4644. {
  4645. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4646. return -1;
  4647. }
  4648. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4649. {
  4650. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4651. return -1;
  4652. }
  4653. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4654. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4655. bl = &sd->hd->bl;
  4656. else
  4657. bl = &sd->bl;
  4658. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4659. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4660. else
  4661. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4662. return 0;
  4663. }
  4664. /*==========================================
  4665. * @displayskill by [Skotlex]
  4666. * Debug command to locate new skill IDs. It sends the
  4667. * three possible skill-effect packets to the area.
  4668. *------------------------------------------*/
  4669. ACMD_FUNC(displayskill)
  4670. {
  4671. struct status_data * status;
  4672. unsigned int tick;
  4673. int skillnum;
  4674. int skilllv = 1;
  4675. nullpo_retr(-1, sd);
  4676. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4677. {
  4678. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4679. return -1;
  4680. }
  4681. status = status_get_status_data(&sd->bl);
  4682. tick = gettick();
  4683. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4684. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4685. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4686. return 0;
  4687. }
  4688. /*==========================================
  4689. * @skilltree by [MouseJstr]
  4690. * prints the skill tree for a player required to get to a skill
  4691. *------------------------------------------*/
  4692. ACMD_FUNC(skilltree)
  4693. {
  4694. struct map_session_data *pl_sd = NULL;
  4695. int skillnum;
  4696. int meets, j, c=0;
  4697. char target[NAME_LENGTH];
  4698. struct skill_tree_entry *ent;
  4699. nullpo_retr(-1, sd);
  4700. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4701. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4702. return -1;
  4703. }
  4704. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4705. {
  4706. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4707. return -1;
  4708. }
  4709. c = pc_calc_skilltree_normalize_job(pl_sd);
  4710. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4711. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, NV_BASIC));
  4712. clif_displaymessage(fd, atcmd_output);
  4713. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  4714. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4715. {
  4716. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4717. clif_displaymessage(fd, atcmd_output);
  4718. return 0;
  4719. }
  4720. ent = &skill_tree[c][j];
  4721. meets = 1;
  4722. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4723. {
  4724. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4725. {
  4726. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  4727. clif_displaymessage(fd, atcmd_output);
  4728. meets = 0;
  4729. }
  4730. }
  4731. if (meets == 1) {
  4732. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4733. clif_displaymessage(fd, atcmd_output);
  4734. }
  4735. return 0;
  4736. }
  4737. // Hand a ring with partners name on it to this char
  4738. void getring (struct map_session_data* sd)
  4739. {
  4740. int flag, item_id;
  4741. struct item item_tmp;
  4742. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4743. memset(&item_tmp, 0, sizeof(item_tmp));
  4744. item_tmp.nameid = item_id;
  4745. item_tmp.identify = 1;
  4746. item_tmp.card[0] = 255;
  4747. item_tmp.card[2] = sd->status.partner_id;
  4748. item_tmp.card[3] = sd->status.partner_id >> 16;
  4749. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4750. clif_additem(sd,0,0,flag);
  4751. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4752. }
  4753. }
  4754. /*==========================================
  4755. * @marry by [MouseJstr], fixed by Lupus
  4756. * Marry two players
  4757. *------------------------------------------*/
  4758. ACMD_FUNC(marry)
  4759. {
  4760. struct map_session_data *pl_sd = NULL;
  4761. char player_name[NAME_LENGTH] = "";
  4762. nullpo_retr(-1, sd);
  4763. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4764. clif_displaymessage(fd, "Usage: @marry <player name>");
  4765. return -1;
  4766. }
  4767. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4768. clif_displaymessage(fd, msg_txt(3));
  4769. return -1;
  4770. }
  4771. if (pc_marriage(sd, pl_sd) == 0) {
  4772. clif_displaymessage(fd, "They are married.. wish them well.");
  4773. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4774. getring(sd); // Auto-give named rings (Aru)
  4775. getring(pl_sd);
  4776. return 0;
  4777. }
  4778. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  4779. return -1;
  4780. }
  4781. /*==========================================
  4782. * @divorce by [MouseJstr], fixed by [Lupus]
  4783. * divorce two players
  4784. *------------------------------------------*/
  4785. ACMD_FUNC(divorce)
  4786. {
  4787. nullpo_retr(-1, sd);
  4788. if (pc_divorce(sd) != 0) {
  4789. sprintf(atcmd_output, "'%s' is not married.", sd->status.name);
  4790. clif_displaymessage(fd, atcmd_output);
  4791. return -1;
  4792. }
  4793. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", sd->status.name);
  4794. clif_displaymessage(fd, atcmd_output);
  4795. return 0;
  4796. }
  4797. /*==========================================
  4798. * @changelook by [Celest]
  4799. *------------------------------------------*/
  4800. ACMD_FUNC(changelook)
  4801. {
  4802. int i, j = 0, k = 0;
  4803. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  4804. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4805. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  4806. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  4807. return -1;
  4808. } else if (i == 2) {
  4809. if (j < 1) j = 1;
  4810. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  4811. j = pos[j - 1];
  4812. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  4813. k = j; // swap
  4814. j = LOOK_HEAD_TOP;
  4815. }
  4816. clif_changelook(&sd->bl,j,k);
  4817. return 0;
  4818. }
  4819. /*==========================================
  4820. * @autotrade by durf [Lupus] [Paradox924X]
  4821. * Turns on/off Autotrade for a specific player
  4822. *------------------------------------------*/
  4823. ACMD_FUNC(autotrade)
  4824. {
  4825. nullpo_retr(-1, sd);
  4826. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4827. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  4828. return -1;
  4829. }
  4830. if( pc_isdead(sd) ) {
  4831. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  4832. return -1;
  4833. }
  4834. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4835. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  4836. return -1;
  4837. }
  4838. sd->state.autotrade = 1;
  4839. if( battle_config.at_timeout )
  4840. {
  4841. int timeout = atoi(message);
  4842. 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);
  4843. }
  4844. clif_authfail_fd(fd, 15);
  4845. return 0;
  4846. }
  4847. /*==========================================
  4848. * @changegm by durf (changed by Lupus)
  4849. * Changes Master of your Guild to a specified guild member
  4850. *------------------------------------------*/
  4851. ACMD_FUNC(changegm)
  4852. {
  4853. struct guild *g;
  4854. struct map_session_data *pl_sd;
  4855. nullpo_retr(-1, sd);
  4856. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  4857. {
  4858. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  4859. return -1;
  4860. }
  4861. if( map[sd->bl.m].flag.guildlock )
  4862. {
  4863. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  4864. return -1;
  4865. }
  4866. if( !message[0] )
  4867. {
  4868. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  4869. return -1;
  4870. }
  4871. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4872. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  4873. return -1;
  4874. }
  4875. guild_gm_change(sd->status.guild_id, pl_sd);
  4876. return 0;
  4877. }
  4878. /*==========================================
  4879. * @changeleader by Skotlex
  4880. * Changes the leader of a party.
  4881. *------------------------------------------*/
  4882. ACMD_FUNC(changeleader)
  4883. {
  4884. nullpo_retr(-1, sd);
  4885. if( !message[0] )
  4886. {
  4887. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  4888. return -1;
  4889. }
  4890. if (party_changeleader(sd, map_nick2sd((char *) message)))
  4891. return 0;
  4892. return -1;
  4893. }
  4894. /*==========================================
  4895. * @partyoption by Skotlex
  4896. * Used to change the item share setting of a party.
  4897. *------------------------------------------*/
  4898. ACMD_FUNC(partyoption)
  4899. {
  4900. struct party_data *p;
  4901. int mi, option;
  4902. char w1[16], w2[16];
  4903. nullpo_retr(-1, sd);
  4904. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4905. {
  4906. clif_displaymessage(fd, msg_txt(282));
  4907. return -1;
  4908. }
  4909. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4910. if (mi == MAX_PARTY)
  4911. return -1; //Shouldn't happen
  4912. if (!p->party.member[mi].leader)
  4913. {
  4914. clif_displaymessage(fd, msg_txt(282));
  4915. return -1;
  4916. }
  4917. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4918. {
  4919. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  4920. return -1;
  4921. }
  4922. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4923. //Change item share type.
  4924. if (option != p->party.item)
  4925. party_changeoption(sd, p->party.exp, option);
  4926. else
  4927. clif_displaymessage(fd, msg_txt(286));
  4928. return 0;
  4929. }
  4930. /*==========================================
  4931. * @autoloot by Upa-Kun
  4932. * Turns on/off AutoLoot for a specific player
  4933. *------------------------------------------*/
  4934. ACMD_FUNC(autoloot)
  4935. {
  4936. int rate;
  4937. double drate;
  4938. nullpo_retr(-1, sd);
  4939. // autoloot command without value
  4940. if(!message || !*message)
  4941. {
  4942. if (sd->state.autoloot)
  4943. rate = 0;
  4944. else
  4945. rate = 10000;
  4946. } else {
  4947. drate = atof(message);
  4948. rate = (int)(drate*100);
  4949. }
  4950. if (rate < 0) rate = 0;
  4951. if (rate > 10000) rate = 10000;
  4952. sd->state.autoloot = rate;
  4953. if (sd->state.autoloot) {
  4954. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  4955. clif_displaymessage(fd, atcmd_output);
  4956. }else
  4957. clif_displaymessage(fd, "Autoloot is now off.");
  4958. return 0;
  4959. }
  4960. /*==========================================
  4961. * @alootid
  4962. *------------------------------------------*/
  4963. ACMD_FUNC(autolootitem)
  4964. {
  4965. struct item_data *item_data = NULL;
  4966. int i;
  4967. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4968. if (message && *message) {
  4969. if (message[0] == '+') {
  4970. message++;
  4971. action = 1;
  4972. }
  4973. else if (message[0] == '-') {
  4974. message++;
  4975. action = 2;
  4976. }
  4977. else if (!strcmp(message,"reset"))
  4978. action = 4;
  4979. }
  4980. if (action < 3) // add or remove
  4981. {
  4982. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  4983. item_data = itemdb_searchname(message);
  4984. if (!item_data) {
  4985. // No items founds in the DB with Id or Name
  4986. clif_displaymessage(fd, "Item not found.");
  4987. return -1;
  4988. }
  4989. }
  4990. switch(action) {
  4991. case 1:
  4992. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4993. if (i != AUTOLOOTITEM_SIZE) {
  4994. clif_displaymessage(fd, "You're already autolooting this item.");
  4995. return -1;
  4996. }
  4997. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  4998. if (i == AUTOLOOTITEM_SIZE) {
  4999. clif_displaymessage(fd, "Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.");
  5000. return -1;
  5001. }
  5002. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5003. sprintf(atcmd_output, "Autolooting item: '%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5004. clif_displaymessage(fd, atcmd_output);
  5005. sd->state.autolooting = 1;
  5006. break;
  5007. case 2:
  5008. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5009. if (i == AUTOLOOTITEM_SIZE) {
  5010. clif_displaymessage(fd, "You're currently not autolooting this item.");
  5011. return -1;
  5012. }
  5013. sd->state.autolootid[i] = 0;
  5014. sprintf(atcmd_output, "Removed item: '%s'/'%s' {%d} from your autolootitem list.", item_data->name, item_data->jname, item_data->nameid);
  5015. clif_displaymessage(fd, atcmd_output);
  5016. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5017. if (i == AUTOLOOTITEM_SIZE) {
  5018. sd->state.autolooting = 0;
  5019. }
  5020. break;
  5021. case 3:
  5022. sprintf(atcmd_output, "You can have %d items on your autolootitem list.", AUTOLOOTITEM_SIZE);
  5023. clif_displaymessage(fd, atcmd_output);
  5024. clif_displaymessage(fd, "To add item to the list, use \"@alootid +<item name or ID>\". To remove item use \"@alootid -<item name or ID>\".");
  5025. clif_displaymessage(fd, "\"@alootid reset\" will clear your autolootitem list.");
  5026. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5027. if (i == AUTOLOOTITEM_SIZE) {
  5028. clif_displaymessage(fd, "Your autolootitem list is empty.");
  5029. } else {
  5030. clif_displaymessage(fd, "Items on your autolootitem list:");
  5031. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5032. {
  5033. if (sd->state.autolootid[i] == 0)
  5034. continue;
  5035. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5036. 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);
  5037. continue;
  5038. }
  5039. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5040. clif_displaymessage(fd, atcmd_output);
  5041. }
  5042. }
  5043. break;
  5044. case 4:
  5045. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5046. clif_displaymessage(fd, "Your autolootitem list has been reset.");
  5047. sd->state.autolooting = 0;
  5048. break;
  5049. }
  5050. return 0;
  5051. }
  5052. /**
  5053. * No longer available, keeping here just in case it's back someday. [Ind]
  5054. **/
  5055. /*==========================================
  5056. * It is made to rain.
  5057. *------------------------------------------*/
  5058. //ACMD_FUNC(rain)
  5059. //{
  5060. // nullpo_retr(-1, sd);
  5061. // if (map[sd->bl.m].flag.rain) {
  5062. // map[sd->bl.m].flag.rain=0;
  5063. // clif_weather(sd->bl.m);
  5064. // clif_displaymessage(fd, "The rain has stopped.");
  5065. // } else {
  5066. // map[sd->bl.m].flag.rain=1;
  5067. // clif_weather(sd->bl.m);
  5068. // clif_displaymessage(fd, "It is made to rain.");
  5069. // }
  5070. // return 0;
  5071. //}
  5072. /*==========================================
  5073. * It is made to snow.
  5074. *------------------------------------------*/
  5075. ACMD_FUNC(snow)
  5076. {
  5077. nullpo_retr(-1, sd);
  5078. if (map[sd->bl.m].flag.snow) {
  5079. map[sd->bl.m].flag.snow=0;
  5080. clif_weather(sd->bl.m);
  5081. clif_displaymessage(fd, "Snow has stopped falling.");
  5082. } else {
  5083. map[sd->bl.m].flag.snow=1;
  5084. clif_weather(sd->bl.m);
  5085. clif_displaymessage(fd, "It is made to snow.");
  5086. }
  5087. return 0;
  5088. }
  5089. /*==========================================
  5090. * Cherry tree snowstorm is made to fall. (Sakura)
  5091. *------------------------------------------*/
  5092. ACMD_FUNC(sakura)
  5093. {
  5094. nullpo_retr(-1, sd);
  5095. if (map[sd->bl.m].flag.sakura) {
  5096. map[sd->bl.m].flag.sakura=0;
  5097. clif_weather(sd->bl.m);
  5098. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5099. } else {
  5100. map[sd->bl.m].flag.sakura=1;
  5101. clif_weather(sd->bl.m);
  5102. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5103. }
  5104. return 0;
  5105. }
  5106. /*==========================================
  5107. * Clouds appear.
  5108. *------------------------------------------*/
  5109. ACMD_FUNC(clouds)
  5110. {
  5111. nullpo_retr(-1, sd);
  5112. if (map[sd->bl.m].flag.clouds) {
  5113. map[sd->bl.m].flag.clouds=0;
  5114. clif_weather(sd->bl.m);
  5115. clif_displaymessage(fd, "The clouds has disappear.");
  5116. } else {
  5117. map[sd->bl.m].flag.clouds=1;
  5118. clif_weather(sd->bl.m);
  5119. clif_displaymessage(fd, "Clouds appear.");
  5120. }
  5121. return 0;
  5122. }
  5123. /*==========================================
  5124. * Different type of clouds using effect 516
  5125. *------------------------------------------*/
  5126. ACMD_FUNC(clouds2)
  5127. {
  5128. nullpo_retr(-1, sd);
  5129. if (map[sd->bl.m].flag.clouds2) {
  5130. map[sd->bl.m].flag.clouds2=0;
  5131. clif_weather(sd->bl.m);
  5132. clif_displaymessage(fd, "The alternative clouds disappear.");
  5133. } else {
  5134. map[sd->bl.m].flag.clouds2=1;
  5135. clif_weather(sd->bl.m);
  5136. clif_displaymessage(fd, "Alternative clouds appear.");
  5137. }
  5138. return 0;
  5139. }
  5140. /*==========================================
  5141. * Fog hangs over.
  5142. *------------------------------------------*/
  5143. ACMD_FUNC(fog)
  5144. {
  5145. nullpo_retr(-1, sd);
  5146. if (map[sd->bl.m].flag.fog) {
  5147. map[sd->bl.m].flag.fog=0;
  5148. clif_weather(sd->bl.m);
  5149. clif_displaymessage(fd, "The fog has gone.");
  5150. } else {
  5151. map[sd->bl.m].flag.fog=1;
  5152. clif_weather(sd->bl.m);
  5153. clif_displaymessage(fd, "Fog hangs over.");
  5154. }
  5155. return 0;
  5156. }
  5157. /*==========================================
  5158. * Fallen leaves fall.
  5159. *------------------------------------------*/
  5160. ACMD_FUNC(leaves)
  5161. {
  5162. nullpo_retr(-1, sd);
  5163. if (map[sd->bl.m].flag.leaves) {
  5164. map[sd->bl.m].flag.leaves=0;
  5165. clif_weather(sd->bl.m);
  5166. clif_displaymessage(fd, "Leaves no longer fall.");
  5167. } else {
  5168. map[sd->bl.m].flag.leaves=1;
  5169. clif_weather(sd->bl.m);
  5170. clif_displaymessage(fd, "Fallen leaves fall.");
  5171. }
  5172. return 0;
  5173. }
  5174. /*==========================================
  5175. * Fireworks appear.
  5176. *------------------------------------------*/
  5177. ACMD_FUNC(fireworks)
  5178. {
  5179. nullpo_retr(-1, sd);
  5180. if (map[sd->bl.m].flag.fireworks) {
  5181. map[sd->bl.m].flag.fireworks=0;
  5182. clif_weather(sd->bl.m);
  5183. clif_displaymessage(fd, "Fireworks are ended.");
  5184. } else {
  5185. map[sd->bl.m].flag.fireworks=1;
  5186. clif_weather(sd->bl.m);
  5187. clif_displaymessage(fd, "Fireworks are launched.");
  5188. }
  5189. return 0;
  5190. }
  5191. /*==========================================
  5192. * Clearing Weather Effects by Dexity
  5193. *------------------------------------------*/
  5194. ACMD_FUNC(clearweather)
  5195. {
  5196. nullpo_retr(-1, sd);
  5197. /**
  5198. * No longer available, keeping here just in case it's back someday. [Ind]
  5199. **/
  5200. //map[sd->bl.m].flag.rain=0;
  5201. map[sd->bl.m].flag.snow=0;
  5202. map[sd->bl.m].flag.sakura=0;
  5203. map[sd->bl.m].flag.clouds=0;
  5204. map[sd->bl.m].flag.clouds2=0;
  5205. map[sd->bl.m].flag.fog=0;
  5206. map[sd->bl.m].flag.fireworks=0;
  5207. map[sd->bl.m].flag.leaves=0;
  5208. clif_weather(sd->bl.m);
  5209. clif_displaymessage(fd, msg_txt(291));
  5210. return 0;
  5211. }
  5212. /*===============================================================
  5213. * Sound Command - plays a sound for everyone around! [Codemaster]
  5214. *---------------------------------------------------------------*/
  5215. ACMD_FUNC(sound)
  5216. {
  5217. char sound_file[100];
  5218. memset(sound_file, '\0', sizeof(sound_file));
  5219. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5220. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5221. return -1;
  5222. }
  5223. if(strstr(sound_file, ".wav") == NULL)
  5224. strcat(sound_file, ".wav");
  5225. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5226. return 0;
  5227. }
  5228. /*==========================================
  5229. * MOB Search
  5230. *------------------------------------------*/
  5231. ACMD_FUNC(mobsearch)
  5232. {
  5233. char mob_name[100];
  5234. int mob_id;
  5235. int number = 0;
  5236. struct s_mapiterator* it;
  5237. nullpo_retr(-1, sd);
  5238. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5239. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5240. return -1;
  5241. }
  5242. if ((mob_id = atoi(mob_name)) == 0)
  5243. mob_id = mobdb_searchname(mob_name);
  5244. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5245. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5246. clif_displaymessage(fd, atcmd_output);
  5247. return -1;
  5248. }
  5249. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5250. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5251. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5252. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5253. clif_displaymessage(fd, atcmd_output);
  5254. it = mapit_geteachmob();
  5255. for(;;)
  5256. {
  5257. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5258. if( md == NULL )
  5259. break;// no more mobs
  5260. if( md->bl.m != sd->bl.m )
  5261. continue;
  5262. if( mob_id != -1 && md->class_ != mob_id )
  5263. continue;
  5264. ++number;
  5265. if( md->spawn_timer == INVALID_TIMER )
  5266. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5267. else
  5268. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5269. clif_displaymessage(fd, atcmd_output);
  5270. }
  5271. mapit_free(it);
  5272. return 0;
  5273. }
  5274. /*==========================================
  5275. * @cleanmap - cleans items on the ground
  5276. *------------------------------------------*/
  5277. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5278. {
  5279. nullpo_ret(bl);
  5280. map_clearflooritem(bl->id);
  5281. return 0;
  5282. }
  5283. ACMD_FUNC(cleanmap)
  5284. {
  5285. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5286. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5287. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5288. BL_ITEM);
  5289. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5290. return 0;
  5291. }
  5292. /*==========================================
  5293. * make a NPC/PET talk
  5294. * @npctalkc [SnakeDrak]
  5295. *------------------------------------------*/
  5296. ACMD_FUNC(npctalk)
  5297. {
  5298. char name[NAME_LENGTH],mes[100],temp[100];
  5299. struct npc_data *nd;
  5300. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5301. unsigned long color=0;
  5302. if (sd->sc.count && //no "chatting" while muted.
  5303. (sd->sc.data[SC_BERSERK] ||
  5304. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5305. return -1;
  5306. if(!ifcolor) {
  5307. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5308. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5309. return -1;
  5310. }
  5311. }
  5312. else {
  5313. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5314. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  5315. return -1;
  5316. }
  5317. }
  5318. if (!(nd = npc_name2id(name))) {
  5319. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5320. return -1;
  5321. }
  5322. strtok(name, "#"); // discard extra name identifier if present
  5323. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5324. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5325. else clif_message(&nd->bl, temp);
  5326. return 0;
  5327. }
  5328. ACMD_FUNC(pettalk)
  5329. {
  5330. char mes[100],temp[100];
  5331. struct pet_data *pd;
  5332. nullpo_retr(-1, sd);
  5333. if(!sd->status.pet_id || !(pd=sd->pd))
  5334. {
  5335. clif_displaymessage(fd, msg_txt(184));
  5336. return -1;
  5337. }
  5338. if (sd->sc.count && //no "chatting" while muted.
  5339. (sd->sc.data[SC_BERSERK] ||
  5340. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5341. return -1;
  5342. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5343. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5344. return -1;
  5345. }
  5346. if (message[0] == '/')
  5347. {// pet emotion processing
  5348. const char* emo[] = {
  5349. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5350. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5351. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5352. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5353. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5354. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5355. };
  5356. int i;
  5357. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5358. if( i < ARRAYLENGTH(emo) )
  5359. {
  5360. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5361. sd->emotionlasttime = time(NULL);
  5362. clif_skill_fail(sd, 1, 0, 1);
  5363. return 0;
  5364. }
  5365. sd->emotionlasttime = time(NULL);
  5366. clif_emotion(&pd->bl, i);
  5367. return 0;
  5368. }
  5369. }
  5370. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5371. clif_message(&pd->bl, temp);
  5372. return 0;
  5373. }
  5374. /// @users - displays the number of players present on each map (and percentage)
  5375. /// #users displays on the target user instead of self
  5376. ACMD_FUNC(users)
  5377. {
  5378. char buf[CHAT_SIZE_MAX];
  5379. int i;
  5380. int users[MAX_MAPINDEX];
  5381. int users_all;
  5382. struct s_mapiterator* iter;
  5383. memset(users, 0, sizeof(users));
  5384. users_all = 0;
  5385. // count users on each map
  5386. iter = mapit_getallusers();
  5387. for(;;)
  5388. {
  5389. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5390. if( sd2 == NULL )
  5391. break;// no more users
  5392. if( sd2->mapindex >= MAX_MAPINDEX )
  5393. continue;// invalid mapindex
  5394. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5395. if( users_all < INT_MAX ) ++users_all;
  5396. }
  5397. mapit_free(iter);
  5398. // display results for each map
  5399. for( i = 0; i < MAX_MAPINDEX; ++i )
  5400. {
  5401. if( users[i] == 0 )
  5402. continue;// empty
  5403. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5404. clif_displaymessage(sd->fd, buf);
  5405. }
  5406. // display overall count
  5407. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5408. clif_displaymessage(sd->fd, buf);
  5409. return 0;
  5410. }
  5411. /*==========================================
  5412. *
  5413. *------------------------------------------*/
  5414. ACMD_FUNC(reset)
  5415. {
  5416. pc_resetstate(sd);
  5417. pc_resetskill(sd,1);
  5418. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5419. clif_displaymessage(fd, atcmd_output);
  5420. return 0;
  5421. }
  5422. /*==========================================
  5423. *
  5424. *------------------------------------------*/
  5425. ACMD_FUNC(summon)
  5426. {
  5427. char name[NAME_LENGTH];
  5428. int mob_id = 0;
  5429. int duration = 0;
  5430. struct mob_data *md;
  5431. unsigned int tick=gettick();
  5432. nullpo_retr(-1, sd);
  5433. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5434. {
  5435. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5436. return -1;
  5437. }
  5438. if (duration < 1)
  5439. duration =1;
  5440. else if (duration > 60)
  5441. duration =60;
  5442. if ((mob_id = atoi(name)) == 0)
  5443. mob_id = mobdb_searchname(name);
  5444. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5445. {
  5446. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5447. return -1;
  5448. }
  5449. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5450. if(!md)
  5451. return -1;
  5452. md->master_id=sd->bl.id;
  5453. md->special_state.ai=1;
  5454. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5455. clif_specialeffect(&md->bl,344,AREA);
  5456. mob_spawn(md);
  5457. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5458. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5459. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5460. return 0;
  5461. }
  5462. /*==========================================
  5463. * @adjgroup
  5464. * Temporarily move player to another group
  5465. * Useful during beta testing to allow players to use GM commands for short periods of time
  5466. *------------------------------------------*/
  5467. ACMD_FUNC(adjgroup)
  5468. {
  5469. int new_group = 0;
  5470. nullpo_retr(-1, sd);
  5471. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5472. clif_displaymessage(fd, "Usage: @adjgroup <group_id>");
  5473. return -1;
  5474. }
  5475. if (!pc_group_exists(new_group)) {
  5476. clif_displaymessage(fd, "Specified group does not exists.");
  5477. return -1;
  5478. }
  5479. sd->group_id = new_group;
  5480. clif_displaymessage(fd, "Group changed successfully.");
  5481. clif_displaymessage(sd->fd, "Your group has changed.");
  5482. return 0;
  5483. }
  5484. /*==========================================
  5485. * @trade by [MouseJstr]
  5486. * Open a trade window with a remote player
  5487. *------------------------------------------*/
  5488. ACMD_FUNC(trade)
  5489. {
  5490. struct map_session_data *pl_sd = NULL;
  5491. nullpo_retr(-1, sd);
  5492. if (!message || !*message) {
  5493. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5494. return -1;
  5495. }
  5496. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5497. {
  5498. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5499. return -1;
  5500. }
  5501. trade_traderequest(sd, pl_sd);
  5502. return 0;
  5503. }
  5504. /*==========================================
  5505. * @setbattleflag by [MouseJstr]
  5506. * set a battle_config flag without having to reboot
  5507. *------------------------------------------*/
  5508. ACMD_FUNC(setbattleflag)
  5509. {
  5510. char flag[128], value[128];
  5511. nullpo_retr(-1, sd);
  5512. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5513. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5514. return -1;
  5515. }
  5516. if (battle_set_value(flag, value) == 0)
  5517. {
  5518. clif_displaymessage(fd, "unknown battle_config flag");
  5519. return -1;
  5520. }
  5521. clif_displaymessage(fd, "battle_config set as requested");
  5522. return 0;
  5523. }
  5524. /*==========================================
  5525. * @unmute [Valaris]
  5526. *------------------------------------------*/
  5527. ACMD_FUNC(unmute)
  5528. {
  5529. struct map_session_data *pl_sd = NULL;
  5530. nullpo_retr(-1, sd);
  5531. if (!message || !*message) {
  5532. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5533. return -1;
  5534. }
  5535. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5536. {
  5537. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5538. return -1;
  5539. }
  5540. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5541. clif_displaymessage(sd->fd,"Player is not muted");
  5542. return -1;
  5543. }
  5544. pl_sd->status.manner = 0;
  5545. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5546. clif_displaymessage(sd->fd,"Player unmuted");
  5547. return 0;
  5548. }
  5549. /*==========================================
  5550. * @uptime by MC Cameri
  5551. *------------------------------------------*/
  5552. ACMD_FUNC(uptime)
  5553. {
  5554. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5555. minute = 60, days = 0, hours = 0, minutes = 0;
  5556. nullpo_retr(-1, sd);
  5557. seconds = get_uptime();
  5558. days = seconds/day;
  5559. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5560. hours = seconds/hour;
  5561. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5562. minutes = seconds/minute;
  5563. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5564. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5565. clif_displaymessage(fd, atcmd_output);
  5566. return 0;
  5567. }
  5568. /*==========================================
  5569. * @changesex <sex>
  5570. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5571. *------------------------------------------*/
  5572. ACMD_FUNC(changesex)
  5573. {
  5574. nullpo_retr(-1, sd);
  5575. pc_resetskill(sd,4);
  5576. chrif_changesex(sd);
  5577. return 0;
  5578. }
  5579. /*================================================
  5580. * @mute - Mutes a player for a set amount of time
  5581. *------------------------------------------------*/
  5582. ACMD_FUNC(mute)
  5583. {
  5584. struct map_session_data *pl_sd = NULL;
  5585. int manner;
  5586. nullpo_retr(-1, sd);
  5587. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5588. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5589. return -1;
  5590. }
  5591. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5592. {
  5593. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5594. return -1;
  5595. }
  5596. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5597. {
  5598. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5599. return -1;
  5600. }
  5601. clif_manner_message(sd, 0);
  5602. clif_manner_message(pl_sd, 5);
  5603. if( pl_sd->status.manner < manner ) {
  5604. pl_sd->status.manner -= manner;
  5605. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5606. } else {
  5607. pl_sd->status.manner = 0;
  5608. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5609. }
  5610. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5611. return 0;
  5612. }
  5613. /*==========================================
  5614. * @refresh (like @jumpto <<yourself>>)
  5615. *------------------------------------------*/
  5616. ACMD_FUNC(refresh)
  5617. {
  5618. nullpo_retr(-1, sd);
  5619. clif_refresh(sd);
  5620. return 0;
  5621. }
  5622. /*==========================================
  5623. * @identify
  5624. * => GM's magnifier.
  5625. *------------------------------------------*/
  5626. ACMD_FUNC(identify)
  5627. {
  5628. int i,num;
  5629. nullpo_retr(-1, sd);
  5630. for(i=num=0;i<MAX_INVENTORY;i++){
  5631. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5632. num++;
  5633. }
  5634. }
  5635. if (num > 0) {
  5636. clif_item_identify_list(sd);
  5637. } else {
  5638. clif_displaymessage(fd,"There are no items to appraise.");
  5639. }
  5640. return 0;
  5641. }
  5642. /*==========================================
  5643. * @gmotd (Global MOTD)
  5644. * by davidsiaw :P
  5645. *------------------------------------------*/
  5646. ACMD_FUNC(gmotd)
  5647. {
  5648. char buf[CHAT_SIZE_MAX];
  5649. size_t len;
  5650. FILE* fp;
  5651. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5652. {
  5653. while( fgets(buf, sizeof(buf), fp) )
  5654. {
  5655. if( buf[0] == '/' && buf[1] == '/' )
  5656. {
  5657. continue;
  5658. }
  5659. len = strlen(buf);
  5660. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5661. {// strip trailing EOL characters
  5662. len--;
  5663. }
  5664. if( len )
  5665. {
  5666. buf[len] = 0;
  5667. intif_broadcast(buf, len+1, 0);
  5668. }
  5669. }
  5670. fclose(fp);
  5671. }
  5672. return 0;
  5673. }
  5674. ACMD_FUNC(misceffect)
  5675. {
  5676. int effect = 0;
  5677. nullpo_retr(-1, sd);
  5678. if (!message || !*message)
  5679. return -1;
  5680. if (sscanf(message, "%d", &effect) < 1)
  5681. return -1;
  5682. clif_misceffect(&sd->bl,effect);
  5683. return 0;
  5684. }
  5685. /*==========================================
  5686. * MAIL SYSTEM
  5687. *------------------------------------------*/
  5688. ACMD_FUNC(mail)
  5689. {
  5690. nullpo_ret(sd);
  5691. mail_openmail(sd);
  5692. return 0;
  5693. }
  5694. /*==========================================
  5695. * Show Monster DB Info v 1.0
  5696. * originally by [Lupus] eAthena
  5697. *------------------------------------------*/
  5698. ACMD_FUNC(mobinfo)
  5699. {
  5700. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5701. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5702. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5703. char atcmd_output2[CHAT_SIZE_MAX];
  5704. struct item_data *item_data;
  5705. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5706. int count;
  5707. int i, j, k;
  5708. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5709. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5710. if (!message || !*message) {
  5711. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5712. return -1;
  5713. }
  5714. // If monster identifier/name argument is a name
  5715. if ((i = mobdb_checkid(atoi(message))))
  5716. {
  5717. mob_array[0] = mob_db(i);
  5718. count = 1;
  5719. } else
  5720. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5721. if (!count) {
  5722. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5723. return -1;
  5724. }
  5725. if (count > MAX_SEARCH) {
  5726. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5727. clif_displaymessage(fd, atcmd_output);
  5728. count = MAX_SEARCH;
  5729. }
  5730. for (k = 0; k < count; k++) {
  5731. mob = mob_array[k];
  5732. // stats
  5733. if (mob->mexp)
  5734. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5735. else
  5736. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5737. clif_displaymessage(fd, atcmd_output);
  5738. 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);
  5739. clif_displaymessage(fd, atcmd_output);
  5740. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5741. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5742. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5743. clif_displaymessage(fd, atcmd_output);
  5744. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5745. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5746. mob->range2 , mob->range3, msize[mob->status.size],
  5747. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5748. clif_displaymessage(fd, atcmd_output);
  5749. // drops
  5750. clif_displaymessage(fd, " Drops:");
  5751. strcpy(atcmd_output, " ");
  5752. j = 0;
  5753. for (i = 0; i < MAX_MOB_DROP; i++) {
  5754. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5755. continue;
  5756. if (item_data->slot)
  5757. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5758. else
  5759. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5760. strcat(atcmd_output, atcmd_output2);
  5761. if (++j % 3 == 0) {
  5762. clif_displaymessage(fd, atcmd_output);
  5763. strcpy(atcmd_output, " ");
  5764. }
  5765. }
  5766. if (j == 0)
  5767. clif_displaymessage(fd, "This monster has no drops.");
  5768. else if (j % 3 != 0)
  5769. clif_displaymessage(fd, atcmd_output);
  5770. // mvp
  5771. if (mob->mexp) {
  5772. sprintf(atcmd_output, " MVP Bonus EXP:%u", mob->mexp);
  5773. clif_displaymessage(fd, atcmd_output);
  5774. strcpy(atcmd_output, " MVP Items:");
  5775. j = 0;
  5776. for (i = 0; i < MAX_MVP_DROP; i++) {
  5777. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5778. continue;
  5779. if (mob->mvpitem[i].p > 0) {
  5780. j++;
  5781. if (j == 1)
  5782. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5783. else
  5784. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5785. strcat(atcmd_output, atcmd_output2);
  5786. }
  5787. }
  5788. if (j == 0)
  5789. clif_displaymessage(fd, "This monster has no MVP prizes.");
  5790. else
  5791. clif_displaymessage(fd, atcmd_output);
  5792. }
  5793. }
  5794. return 0;
  5795. }
  5796. /*=========================================
  5797. * @showmobs by KarLaeda
  5798. * => For 15 sec displays the mobs on minimap
  5799. *------------------------------------------*/
  5800. ACMD_FUNC(showmobs)
  5801. {
  5802. char mob_name[100];
  5803. int mob_id;
  5804. int number = 0;
  5805. struct s_mapiterator* it;
  5806. nullpo_retr(-1, sd);
  5807. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5808. return -1;
  5809. if((mob_id = atoi(mob_name)) == 0)
  5810. mob_id = mobdb_searchname(mob_name);
  5811. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5812. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5813. clif_displaymessage(fd, atcmd_output);
  5814. return 0;
  5815. }
  5816. // Uncomment the following line to show mini-bosses & MVP.
  5817. //#define SHOW_MVP
  5818. #ifndef SHOW_MVP
  5819. if(mob_db(mob_id)->status.mode&MD_BOSS){
  5820. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  5821. clif_displaymessage(fd, atcmd_output);
  5822. return 0;
  5823. }
  5824. #endif
  5825. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5826. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5827. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5828. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  5829. mob_name, mapindex_id2name(sd->mapindex));
  5830. clif_displaymessage(fd, atcmd_output);
  5831. it = mapit_geteachmob();
  5832. for(;;)
  5833. {
  5834. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5835. if( md == NULL )
  5836. break;// no more mobs
  5837. if( md->bl.m != sd->bl.m )
  5838. continue;
  5839. if( mob_id != -1 && md->class_ != mob_id )
  5840. continue;
  5841. if( md->special_state.ai || md->master_id )
  5842. continue; // hide slaves and player summoned mobs
  5843. if( md->spawn_timer != INVALID_TIMER )
  5844. continue; // hide mobs waiting for respawn
  5845. ++number;
  5846. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5847. }
  5848. mapit_free(it);
  5849. return 0;
  5850. }
  5851. /*==========================================
  5852. * homunculus level up [orn]
  5853. *------------------------------------------*/
  5854. ACMD_FUNC(homlevel)
  5855. {
  5856. TBL_HOM * hd;
  5857. int level = 0, i = 0;
  5858. nullpo_retr(-1, sd);
  5859. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  5860. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  5861. return -1;
  5862. }
  5863. if ( !merc_is_hom_active(sd->hd) ) {
  5864. clif_displaymessage(fd, "You do not have a homunculus.");
  5865. return -1;
  5866. }
  5867. hd = sd->hd;
  5868. for (i = 1; i <= level && hd->exp_next; i++){
  5869. hd->homunculus.exp += hd->exp_next;
  5870. merc_hom_levelup(hd);
  5871. }
  5872. status_calc_homunculus(hd,0);
  5873. status_percent_heal(&hd->bl, 100, 100);
  5874. clif_specialeffect(&hd->bl,568,AREA);
  5875. return 0;
  5876. }
  5877. /*==========================================
  5878. * homunculus evolution H [orn]
  5879. *------------------------------------------*/
  5880. ACMD_FUNC(homevolution)
  5881. {
  5882. nullpo_retr(-1, sd);
  5883. if ( !merc_is_hom_active(sd->hd) ) {
  5884. clif_displaymessage(fd, "You do not have a homunculus.");
  5885. return -1;
  5886. }
  5887. if ( !merc_hom_evolution(sd->hd) ) {
  5888. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  5889. return -1;
  5890. }
  5891. clif_homskillinfoblock(sd);
  5892. return 0;
  5893. }
  5894. /*==========================================
  5895. * call choosen homunculus [orn]
  5896. *------------------------------------------*/
  5897. ACMD_FUNC(makehomun)
  5898. {
  5899. int homunid;
  5900. nullpo_retr(-1, sd);
  5901. if ( sd->status.hom_id ) {
  5902. clif_displaymessage(fd, msg_txt(450));
  5903. return -1;
  5904. }
  5905. if (!message || !*message) {
  5906. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  5907. return -1;
  5908. }
  5909. homunid = atoi(message);
  5910. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  5911. {
  5912. clif_displaymessage(fd, "Invalid Homunculus id.");
  5913. return -1;
  5914. }
  5915. merc_create_homunculus_request(sd,homunid);
  5916. return 0;
  5917. }
  5918. /*==========================================
  5919. * modify homunculus intimacy [orn]
  5920. *------------------------------------------*/
  5921. ACMD_FUNC(homfriendly)
  5922. {
  5923. int friendly = 0;
  5924. nullpo_retr(-1, sd);
  5925. if ( !merc_is_hom_active(sd->hd) ) {
  5926. clif_displaymessage(fd, "You do not have a homunculus.");
  5927. return -1;
  5928. }
  5929. if (!message || !*message) {
  5930. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  5931. return -1;
  5932. }
  5933. friendly = atoi(message);
  5934. friendly = cap_value(friendly, 0, 1000);
  5935. sd->hd->homunculus.intimacy = friendly * 100 ;
  5936. clif_send_homdata(sd,SP_INTIMATE,friendly);
  5937. return 0;
  5938. }
  5939. /*==========================================
  5940. * modify homunculus hunger [orn]
  5941. *------------------------------------------*/
  5942. ACMD_FUNC(homhungry)
  5943. {
  5944. int hungry = 0;
  5945. nullpo_retr(-1, sd);
  5946. if ( !merc_is_hom_active(sd->hd) ) {
  5947. clif_displaymessage(fd, "You do not have a homunculus.");
  5948. return -1;
  5949. }
  5950. if (!message || !*message) {
  5951. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  5952. return -1;
  5953. }
  5954. hungry = atoi(message);
  5955. hungry = cap_value(hungry, 0, 100);
  5956. sd->hd->homunculus.hunger = hungry;
  5957. clif_send_homdata(sd,SP_HUNGRY,hungry);
  5958. return 0;
  5959. }
  5960. /*==========================================
  5961. * make the homunculus speak [orn]
  5962. *------------------------------------------*/
  5963. ACMD_FUNC(homtalk)
  5964. {
  5965. char mes[100],temp[100];
  5966. nullpo_retr(-1, sd);
  5967. if (sd->sc.count && //no "chatting" while muted.
  5968. (sd->sc.data[SC_BERSERK] ||
  5969. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5970. return -1;
  5971. if ( !merc_is_hom_active(sd->hd) ) {
  5972. clif_displaymessage(fd, "You do not have a homunculus.");
  5973. return -1;
  5974. }
  5975. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5976. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  5977. return -1;
  5978. }
  5979. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  5980. clif_message(&sd->hd->bl, temp);
  5981. return 0;
  5982. }
  5983. /*==========================================
  5984. * Show homunculus stats
  5985. *------------------------------------------*/
  5986. ACMD_FUNC(hominfo)
  5987. {
  5988. struct homun_data *hd;
  5989. struct status_data *status;
  5990. nullpo_retr(-1, sd);
  5991. if ( !merc_is_hom_active(sd->hd) ) {
  5992. clif_displaymessage(fd, "You do not have a homunculus.");
  5993. return -1;
  5994. }
  5995. hd = sd->hd;
  5996. status = status_get_status_data(&hd->bl);
  5997. clif_displaymessage(fd, "Homunculus stats :");
  5998. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  5999. status->hp, status->max_hp, status->sp, status->max_sp);
  6000. clif_displaymessage(fd, atcmd_output);
  6001. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6002. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6003. clif_displaymessage(fd, atcmd_output);
  6004. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6005. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6006. clif_displaymessage(fd, atcmd_output);
  6007. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6008. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6009. status->str, status->agi, status->vit,
  6010. status->int_, status->dex, status->luk);
  6011. clif_displaymessage(fd, atcmd_output);
  6012. return 0;
  6013. }
  6014. ACMD_FUNC(homstats)
  6015. {
  6016. struct homun_data *hd;
  6017. struct s_homunculus_db *db;
  6018. struct s_homunculus *hom;
  6019. int lv, min, max, evo;
  6020. nullpo_retr(-1, sd);
  6021. if ( !merc_is_hom_active(sd->hd) ) {
  6022. clif_displaymessage(fd, "You do not have a homunculus.");
  6023. return -1;
  6024. }
  6025. hd = sd->hd;
  6026. hom = &hd->homunculus;
  6027. db = hd->homunculusDB;
  6028. lv = hom->level;
  6029. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6030. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6031. clif_displaymessage(fd, atcmd_output);
  6032. lv--; //Since the first increase is at level 2.
  6033. evo = (hom->class_ == db->evo_class);
  6034. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6035. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6036. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6037. clif_displaymessage(fd, atcmd_output);
  6038. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6039. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6040. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6041. clif_displaymessage(fd, atcmd_output);
  6042. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6043. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6044. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6045. clif_displaymessage(fd, atcmd_output);
  6046. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6047. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6048. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6049. clif_displaymessage(fd, atcmd_output);
  6050. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6051. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6052. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6053. clif_displaymessage(fd, atcmd_output);
  6054. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6055. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6056. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6057. clif_displaymessage(fd, atcmd_output);
  6058. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6059. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6060. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6061. clif_displaymessage(fd, atcmd_output);
  6062. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6063. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6064. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6065. clif_displaymessage(fd, atcmd_output);
  6066. return 0;
  6067. }
  6068. ACMD_FUNC(homshuffle)
  6069. {
  6070. nullpo_retr(-1, sd);
  6071. if(!sd->hd)
  6072. return -1; // nothing to do
  6073. if(!merc_hom_shuffle(sd->hd))
  6074. return -1;
  6075. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6076. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6077. return 0;
  6078. }
  6079. /*==========================================
  6080. * Show Items DB Info v 1.0
  6081. * originally by [Lupus] eAthena
  6082. *------------------------------------------*/
  6083. ACMD_FUNC(iteminfo)
  6084. {
  6085. struct item_data *item_data, *item_array[MAX_SEARCH];
  6086. int i, count = 1;
  6087. if (!message || !*message) {
  6088. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6089. return -1;
  6090. }
  6091. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6092. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6093. if (!count) {
  6094. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6095. return -1;
  6096. }
  6097. if (count > MAX_SEARCH) {
  6098. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6099. clif_displaymessage(fd, atcmd_output);
  6100. count = MAX_SEARCH;
  6101. }
  6102. for (i = 0; i < count; i++) {
  6103. item_data = item_array[i];
  6104. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6105. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6106. itemdb_typename(item_data->type),
  6107. (item_data->script==NULL)? "None" : "With script"
  6108. );
  6109. clif_displaymessage(fd, atcmd_output);
  6110. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  6111. clif_displaymessage(fd, atcmd_output);
  6112. if (item_data->maxchance == -1)
  6113. strcpy(atcmd_output, " - Available in the shops only.");
  6114. else if (item_data->maxchance)
  6115. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6116. else
  6117. strcpy(atcmd_output, " - Monsters don't drop this item.");
  6118. clif_displaymessage(fd, atcmd_output);
  6119. }
  6120. return 0;
  6121. }
  6122. /*==========================================
  6123. * Show who drops the item.
  6124. *------------------------------------------*/
  6125. ACMD_FUNC(whodrops)
  6126. {
  6127. struct item_data *item_data, *item_array[MAX_SEARCH];
  6128. int i,j, count = 1;
  6129. if (!message || !*message) {
  6130. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6131. return -1;
  6132. }
  6133. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6134. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6135. if (!count) {
  6136. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6137. return -1;
  6138. }
  6139. if (count > MAX_SEARCH) {
  6140. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6141. clif_displaymessage(fd, atcmd_output);
  6142. count = MAX_SEARCH;
  6143. }
  6144. for (i = 0; i < count; i++) {
  6145. item_data = item_array[i];
  6146. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6147. clif_displaymessage(fd, atcmd_output);
  6148. if (item_data->mob[0].chance == 0) {
  6149. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6150. clif_displaymessage(fd, atcmd_output);
  6151. } else {
  6152. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6153. clif_displaymessage(fd, atcmd_output);
  6154. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6155. {
  6156. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6157. clif_displaymessage(fd, atcmd_output);
  6158. }
  6159. }
  6160. }
  6161. return 0;
  6162. }
  6163. ACMD_FUNC(whereis)
  6164. {
  6165. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6166. int count;
  6167. int i, j, k;
  6168. if (!message || !*message) {
  6169. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6170. return -1;
  6171. }
  6172. // If monster identifier/name argument is a name
  6173. if ((i = mobdb_checkid(atoi(message))))
  6174. {
  6175. mob_array[0] = mob_db(i);
  6176. count = 1;
  6177. } else
  6178. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6179. if (!count) {
  6180. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6181. return -1;
  6182. }
  6183. if (count > MAX_SEARCH) {
  6184. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6185. clif_displaymessage(fd, atcmd_output);
  6186. count = MAX_SEARCH;
  6187. }
  6188. for (k = 0; k < count; k++) {
  6189. mob = mob_array[k];
  6190. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6191. clif_displaymessage(fd, atcmd_output);
  6192. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6193. {
  6194. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6195. if (j < 0) continue;
  6196. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6197. clif_displaymessage(fd, atcmd_output);
  6198. }
  6199. if (i == 0)
  6200. clif_displaymessage(fd, "This monster does not spawn normally.");
  6201. }
  6202. return 0;
  6203. }
  6204. /*==========================================
  6205. * @adopt by [Veider]
  6206. * adopt a novice
  6207. *------------------------------------------*/
  6208. ACMD_FUNC(adopt)
  6209. {
  6210. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6211. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6212. char output[CHAT_SIZE_MAX];
  6213. nullpo_retr(-1, sd);
  6214. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6215. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6216. return -1;
  6217. }
  6218. if (battle_config.etc_log)
  6219. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6220. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6221. sprintf(output, "Cannot find player %s online", player1);
  6222. clif_displaymessage(fd, output);
  6223. return -1;
  6224. }
  6225. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6226. sprintf(output, "Cannot find player %s online", player2);
  6227. clif_displaymessage(fd, output);
  6228. return -1;
  6229. }
  6230. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6231. sprintf(output, "Cannot find player %s online", player3);
  6232. clif_displaymessage(fd, output);
  6233. return -1;
  6234. }
  6235. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6236. return -1;
  6237. }
  6238. clif_displaymessage(fd, "They are family... wish them luck");
  6239. return 0;
  6240. }
  6241. ACMD_FUNC(version)
  6242. {
  6243. const char * revision;
  6244. if ((revision = get_svn_revision()) != 0) {
  6245. sprintf(atcmd_output,"rAthena Version SVN r%s",revision);
  6246. clif_displaymessage(fd,atcmd_output);
  6247. } else
  6248. clif_displaymessage(fd,"Cannot determine SVN revision");
  6249. return 0;
  6250. }
  6251. /*==========================================
  6252. * @mutearea by MouseJstr
  6253. *------------------------------------------*/
  6254. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6255. {
  6256. int time, id;
  6257. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6258. if (pl_sd == NULL)
  6259. return 0;
  6260. id = va_arg(ap, int);
  6261. time = va_arg(ap, int);
  6262. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6263. pl_sd->status.manner -= time;
  6264. if (pl_sd->status.manner < 0)
  6265. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6266. else
  6267. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6268. }
  6269. return 0;
  6270. }
  6271. ACMD_FUNC(mutearea)
  6272. {
  6273. int time;
  6274. nullpo_ret(sd);
  6275. if (!message || !*message) {
  6276. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6277. return -1;
  6278. }
  6279. time = atoi(message);
  6280. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6281. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6282. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6283. return 0;
  6284. }
  6285. ACMD_FUNC(rates)
  6286. {
  6287. char buf[CHAT_SIZE_MAX];
  6288. nullpo_ret(sd);
  6289. memset(buf, '\0', sizeof(buf));
  6290. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  6291. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6292. clif_displaymessage(fd, buf);
  6293. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6294. 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.);
  6295. clif_displaymessage(fd, buf);
  6296. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6297. 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.);
  6298. clif_displaymessage(fd, buf);
  6299. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  6300. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6301. clif_displaymessage(fd, buf);
  6302. return 0;
  6303. }
  6304. /*==========================================
  6305. * @me by lordalfa
  6306. * => Displays the OUTPUT string on top of the Visible players Heads.
  6307. *------------------------------------------*/
  6308. ACMD_FUNC(me)
  6309. {
  6310. char tempmes[CHAT_SIZE_MAX];
  6311. nullpo_retr(-1, sd);
  6312. memset(tempmes, '\0', sizeof(tempmes));
  6313. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6314. if (sd->sc.count && //no "chatting" while muted.
  6315. (sd->sc.data[SC_BERSERK] ||
  6316. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6317. return -1;
  6318. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6319. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6320. return -1;
  6321. }
  6322. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6323. clif_disp_overhead(sd, atcmd_output);
  6324. return 0;
  6325. }
  6326. /*==========================================
  6327. * @size
  6328. * => Resize your character sprite. [Valaris]
  6329. *------------------------------------------*/
  6330. ACMD_FUNC(size)
  6331. {
  6332. int size=0;
  6333. nullpo_retr(-1, sd);
  6334. size = atoi(message);
  6335. if(sd->state.size) {
  6336. sd->state.size=0;
  6337. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6338. }
  6339. if(size==1) {
  6340. sd->state.size=1;
  6341. clif_specialeffect(&sd->bl,420,AREA);
  6342. } else if(size==2) {
  6343. sd->state.size=2;
  6344. clif_specialeffect(&sd->bl,422,AREA);
  6345. }
  6346. return 0;
  6347. }
  6348. /*==========================================
  6349. * @monsterignore
  6350. * => Makes monsters ignore you. [Valaris]
  6351. *------------------------------------------*/
  6352. ACMD_FUNC(monsterignore)
  6353. {
  6354. nullpo_retr(-1, sd);
  6355. if (!sd->state.monster_ignore) {
  6356. sd->state.monster_ignore = 1;
  6357. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6358. } else {
  6359. sd->state.monster_ignore = 0;
  6360. clif_displaymessage(sd->fd, "Returned to normal state.");
  6361. }
  6362. return 0;
  6363. }
  6364. /*==========================================
  6365. * @fakename
  6366. * => Gives your character a fake name. [Valaris]
  6367. *------------------------------------------*/
  6368. ACMD_FUNC(fakename)
  6369. {
  6370. nullpo_retr(-1, sd);
  6371. if( !message || !*message )
  6372. {
  6373. if( sd->fakename[0] )
  6374. {
  6375. sd->fakename[0] = '\0';
  6376. clif_charnameack(0, &sd->bl);
  6377. clif_displaymessage(sd->fd, "Returned to real name.");
  6378. return 0;
  6379. }
  6380. clif_displaymessage(sd->fd, "You must enter a name.");
  6381. return -1;
  6382. }
  6383. if( strlen(message) < 2 )
  6384. {
  6385. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  6386. return -1;
  6387. }
  6388. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6389. clif_charnameack(0, &sd->bl);
  6390. clif_displaymessage(sd->fd, "Fake name enabled.");
  6391. return 0;
  6392. }
  6393. /*==========================================
  6394. * Ragnarok Resources
  6395. *------------------------------------------*/
  6396. ACMD_FUNC(mapflag) {
  6397. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6398. #define setflag( cmd ) \
  6399. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6400. map[ sd->bl.m ].flag.cmd = flag;\
  6401. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6402. clif_displaymessage(sd->fd,atcmd_output);\
  6403. return 0;\
  6404. }
  6405. unsigned char flag_name[100];
  6406. int flag=9,i;
  6407. nullpo_retr(-1, sd);
  6408. memset(flag_name, '\0', sizeof(flag_name));
  6409. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6410. clif_displaymessage(sd->fd,"Enabled Mapflags in this map:");
  6411. clif_displaymessage(sd->fd,"----------------------------------");
  6412. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6413. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6414. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6415. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6416. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6417. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6418. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6419. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6420. checkflag(nogo); checkflag(nobaseexp);
  6421. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6422. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6423. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6424. clif_displaymessage(sd->fd," ");
  6425. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off 1=On)");
  6426. clif_displaymessage(sd->fd,"Use: \"@mapflag available\" to list the available mapflags");
  6427. return 1;
  6428. }
  6429. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6430. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6431. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6432. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6433. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6434. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6435. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6436. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6437. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6438. setflag(nogo); setflag(nobaseexp);
  6439. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6440. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6441. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6442. clif_displaymessage(sd->fd,"Invalid flag name or flag");
  6443. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off | 1=On)");
  6444. clif_displaymessage(sd->fd,"Available Flags:");
  6445. clif_displaymessage(sd->fd,"----------------------------------");
  6446. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6447. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6448. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6449. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6450. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6451. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6452. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6453. #undef checkflag
  6454. #undef setflag
  6455. return 0;
  6456. }
  6457. /*===================================
  6458. * Remove some messages
  6459. *-----------------------------------*/
  6460. ACMD_FUNC(showexp)
  6461. {
  6462. if (sd->state.showexp) {
  6463. sd->state.showexp = 0;
  6464. clif_displaymessage(fd, "Gained exp will not be shown.");
  6465. return 0;
  6466. }
  6467. sd->state.showexp = 1;
  6468. clif_displaymessage(fd, "Gained exp is now shown");
  6469. return 0;
  6470. }
  6471. ACMD_FUNC(showzeny)
  6472. {
  6473. if (sd->state.showzeny) {
  6474. sd->state.showzeny = 0;
  6475. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6476. return 0;
  6477. }
  6478. sd->state.showzeny = 1;
  6479. clif_displaymessage(fd, "Gained zeny is now shown");
  6480. return 0;
  6481. }
  6482. ACMD_FUNC(showdelay)
  6483. {
  6484. if (sd->state.showdelay) {
  6485. sd->state.showdelay = 0;
  6486. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6487. return 0;
  6488. }
  6489. sd->state.showdelay = 1;
  6490. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6491. return 0;
  6492. }
  6493. /*==========================================
  6494. * Duel organizing functions [LuzZza]
  6495. *
  6496. * @duel [limit|nick] - create a duel
  6497. * @invite <nick> - invite player
  6498. * @accept - accept invitation
  6499. * @reject - reject invitation
  6500. * @leave - leave duel
  6501. *------------------------------------------*/
  6502. ACMD_FUNC(invite)
  6503. {
  6504. unsigned int did = sd->duel_group;
  6505. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6506. if(did <= 0) {
  6507. // "Duel: @invite without @duel."
  6508. clif_displaymessage(fd, msg_txt(350));
  6509. return 0;
  6510. }
  6511. if(duel_list[did].max_players_limit > 0 &&
  6512. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6513. // "Duel: Limit of players is reached."
  6514. clif_displaymessage(fd, msg_txt(351));
  6515. return 0;
  6516. }
  6517. if(target_sd == NULL) {
  6518. // "Duel: Player not found."
  6519. clif_displaymessage(fd, msg_txt(352));
  6520. return 0;
  6521. }
  6522. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6523. // "Duel: Player already in duel."
  6524. clif_displaymessage(fd, msg_txt(353));
  6525. return 0;
  6526. }
  6527. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6528. {
  6529. sprintf(atcmd_output, msg_txt(364), message);
  6530. clif_displaymessage(fd, atcmd_output);
  6531. return 0;
  6532. }
  6533. duel_invite(did, sd, target_sd);
  6534. // "Duel: Invitation has been sent."
  6535. clif_displaymessage(fd, msg_txt(354));
  6536. return 0;
  6537. }
  6538. ACMD_FUNC(duel)
  6539. {
  6540. char output[CHAT_SIZE_MAX];
  6541. unsigned int maxpl=0, newduel;
  6542. struct map_session_data *target_sd;
  6543. if(sd->duel_group > 0) {
  6544. duel_showinfo(sd->duel_group, sd);
  6545. return 0;
  6546. }
  6547. if(sd->duel_invite > 0) {
  6548. // "Duel: @duel without @reject."
  6549. clif_displaymessage(fd, msg_txt(355));
  6550. return 0;
  6551. }
  6552. if(!duel_checktime(sd)) {
  6553. // "Duel: You can take part in duel only one time per %d minutes."
  6554. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6555. clif_displaymessage(fd, output);
  6556. return 0;
  6557. }
  6558. if( message[0] ) {
  6559. if(sscanf(message, "%d", &maxpl) >= 1) {
  6560. if(maxpl < 2 || maxpl > 65535) {
  6561. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6562. return 0;
  6563. }
  6564. duel_create(sd, maxpl);
  6565. } else {
  6566. target_sd = map_nick2sd((char *)message);
  6567. if(target_sd != NULL) {
  6568. if((newduel = duel_create(sd, 2)) != -1) {
  6569. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6570. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6571. return 0;
  6572. }
  6573. duel_invite(newduel, sd, target_sd);
  6574. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6575. }
  6576. } else {
  6577. // "Duel: Player not found."
  6578. clif_displaymessage(fd, msg_txt(352));
  6579. return 0;
  6580. }
  6581. }
  6582. } else
  6583. duel_create(sd, 0);
  6584. return 0;
  6585. }
  6586. ACMD_FUNC(leave)
  6587. {
  6588. if(sd->duel_group <= 0) {
  6589. // "Duel: @leave without @duel."
  6590. clif_displaymessage(fd, msg_txt(358));
  6591. return 0;
  6592. }
  6593. duel_leave(sd->duel_group, sd);
  6594. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6595. return 0;
  6596. }
  6597. ACMD_FUNC(accept)
  6598. {
  6599. char output[CHAT_SIZE_MAX];
  6600. if(!duel_checktime(sd)) {
  6601. // "Duel: You can take part in duel only one time per %d minutes."
  6602. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6603. clif_displaymessage(fd, output);
  6604. return 0;
  6605. }
  6606. if(sd->duel_invite <= 0) {
  6607. // "Duel: @accept without invititation."
  6608. clif_displaymessage(fd, msg_txt(360));
  6609. return 0;
  6610. }
  6611. 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 )
  6612. {
  6613. // "Duel: Limit of players is reached."
  6614. clif_displaymessage(fd, msg_txt(351));
  6615. return 0;
  6616. }
  6617. duel_accept(sd->duel_invite, sd);
  6618. // "Duel: Invitation has been accepted."
  6619. clif_displaymessage(fd, msg_txt(361));
  6620. return 0;
  6621. }
  6622. ACMD_FUNC(reject)
  6623. {
  6624. if(sd->duel_invite <= 0) {
  6625. // "Duel: @reject without invititation."
  6626. clif_displaymessage(fd, msg_txt(362));
  6627. return 0;
  6628. }
  6629. duel_reject(sd->duel_invite, sd);
  6630. // "Duel: Invitation has been rejected."
  6631. clif_displaymessage(fd, msg_txt(363));
  6632. return 0;
  6633. }
  6634. /*===================================
  6635. * Cash Points
  6636. *-----------------------------------*/
  6637. ACMD_FUNC(cash)
  6638. {
  6639. char output[128];
  6640. int value;
  6641. nullpo_retr(-1, sd);
  6642. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6643. clif_displaymessage(fd, "Please, enter an amount.");
  6644. return -1;
  6645. }
  6646. if( !strcmpi(command+1,"cash") )
  6647. {
  6648. if( value > 0 ) {
  6649. pc_getcash(sd, value, 0);
  6650. sprintf(output, msg_txt(505), value, sd->cashPoints);
  6651. clif_disp_onlyself(sd, output, strlen(output));
  6652. } else {
  6653. pc_paycash(sd, -value, 0);
  6654. sprintf(output, msg_txt(410), value, sd->cashPoints);
  6655. clif_disp_onlyself(sd, output, strlen(output));
  6656. }
  6657. }
  6658. else
  6659. { // @points
  6660. if( value > 0 ) {
  6661. pc_getcash(sd, 0, value);
  6662. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  6663. clif_disp_onlyself(sd, output, strlen(output));
  6664. } else {
  6665. pc_paycash(sd, -value, -value);
  6666. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  6667. clif_disp_onlyself(sd, output, strlen(output));
  6668. }
  6669. }
  6670. return 0;
  6671. }
  6672. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6673. ACMD_FUNC(clone)
  6674. {
  6675. int x=0,y=0,flag=0,master=0,i=0;
  6676. struct map_session_data *pl_sd=NULL;
  6677. if (!message || !*message) {
  6678. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6679. return 0;
  6680. }
  6681. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6682. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6683. return 0;
  6684. }
  6685. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6686. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6687. return 0;
  6688. }
  6689. if (strcmpi(command+1, "clone") == 0)
  6690. flag = 1;
  6691. else if (strcmpi(command+1, "slaveclone") == 0) {
  6692. flag = 2;
  6693. master = sd->bl.id;
  6694. if (battle_config.atc_slave_clone_limit
  6695. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6696. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6697. return 0;
  6698. }
  6699. }
  6700. do {
  6701. x = sd->bl.x + (rnd() % 10 - 5);
  6702. y = sd->bl.y + (rnd() % 10 - 5);
  6703. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6704. if (i >= 10) {
  6705. x = sd->bl.x;
  6706. y = sd->bl.y;
  6707. }
  6708. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6709. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6710. return 0;
  6711. }
  6712. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6713. return 0;
  6714. }
  6715. /*===================================
  6716. * Main chat [LuzZza]
  6717. * Usage: @main <on|off|message>
  6718. *-----------------------------------*/
  6719. ACMD_FUNC(main)
  6720. {
  6721. if( message[0] ) {
  6722. if(strcmpi(message, "on") == 0) {
  6723. if(!sd->state.mainchat) {
  6724. sd->state.mainchat = 1;
  6725. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6726. } else {
  6727. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6728. }
  6729. } else if(strcmpi(message, "off") == 0) {
  6730. if(sd->state.mainchat) {
  6731. sd->state.mainchat = 0;
  6732. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6733. } else {
  6734. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6735. }
  6736. } else {
  6737. if(!sd->state.mainchat) {
  6738. sd->state.mainchat = 1;
  6739. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6740. }
  6741. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6742. clif_displaymessage(fd, msg_txt(387));
  6743. return -1;
  6744. }
  6745. // send the message using inter-server system
  6746. intif_main_message( sd, message );
  6747. }
  6748. } else {
  6749. if(sd->state.mainchat)
  6750. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6751. else
  6752. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6753. }
  6754. return 0;
  6755. }
  6756. /*=====================================
  6757. * Autorejecting Invites/Deals [LuzZza]
  6758. * Usage: @noask
  6759. *-------------------------------------*/
  6760. ACMD_FUNC(noask)
  6761. {
  6762. if(sd->state.noask) {
  6763. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6764. sd->state.noask = 0;
  6765. } else {
  6766. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6767. sd->state.noask = 1;
  6768. }
  6769. return 0;
  6770. }
  6771. /*=====================================
  6772. * Send a @request message to all GMs of lowest_gm_level.
  6773. * Usage: @request <petition>
  6774. *-------------------------------------*/
  6775. ACMD_FUNC(request)
  6776. {
  6777. if (!message || !*message) {
  6778. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6779. return -1;
  6780. }
  6781. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6782. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6783. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6784. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6785. return 0;
  6786. }
  6787. /*==========================================
  6788. * Feel (SG save map) Reset [HiddenDragon]
  6789. *------------------------------------------*/
  6790. ACMD_FUNC(feelreset)
  6791. {
  6792. pc_resetfeel(sd);
  6793. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  6794. return 0;
  6795. }
  6796. /*==========================================
  6797. * AUCTION SYSTEM
  6798. *------------------------------------------*/
  6799. ACMD_FUNC(auction)
  6800. {
  6801. nullpo_ret(sd);
  6802. clif_Auction_openwindow(sd);
  6803. return 0;
  6804. }
  6805. /*==========================================
  6806. * Kill Steal Protection
  6807. *------------------------------------------*/
  6808. ACMD_FUNC(ksprotection)
  6809. {
  6810. nullpo_retr(-1,sd);
  6811. if( sd->state.noks ) {
  6812. sd->state.noks = 0;
  6813. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  6814. }
  6815. else
  6816. {
  6817. if( !message || !*message || !strcmpi(message, "party") )
  6818. { // Default is Party
  6819. sd->state.noks = 2;
  6820. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  6821. }
  6822. else if( !strcmpi(message, "self") )
  6823. {
  6824. sd->state.noks = 1;
  6825. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  6826. }
  6827. else if( !strcmpi(message, "guild") )
  6828. {
  6829. sd->state.noks = 3;
  6830. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  6831. }
  6832. else
  6833. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  6834. }
  6835. clif_displaymessage(fd, atcmd_output);
  6836. return 0;
  6837. }
  6838. /*==========================================
  6839. * Map Kill Steal Protection Setting
  6840. *------------------------------------------*/
  6841. ACMD_FUNC(allowks)
  6842. {
  6843. nullpo_retr(-1,sd);
  6844. if( map[sd->bl.m].flag.allowks ) {
  6845. map[sd->bl.m].flag.allowks = 0;
  6846. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  6847. } else {
  6848. map[sd->bl.m].flag.allowks = 1;
  6849. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  6850. }
  6851. clif_displaymessage(fd, atcmd_output);
  6852. return 0;
  6853. }
  6854. ACMD_FUNC(resetstat)
  6855. {
  6856. nullpo_retr(-1, sd);
  6857. pc_resetstate(sd);
  6858. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  6859. clif_displaymessage(fd, atcmd_output);
  6860. return 0;
  6861. }
  6862. ACMD_FUNC(resetskill)
  6863. {
  6864. nullpo_retr(-1,sd);
  6865. pc_resetskill(sd,1);
  6866. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  6867. clif_displaymessage(fd, atcmd_output);
  6868. return 0;
  6869. }
  6870. /*==========================================
  6871. * #storagelist: Displays the items list of a player's storage.
  6872. * #cartlist: Displays contents of target's cart.
  6873. * #itemlist: Displays contents of target's inventory.
  6874. *------------------------------------------*/
  6875. ACMD_FUNC(itemlist)
  6876. {
  6877. int i, j, count, counter;
  6878. const char* location;
  6879. const struct item* items;
  6880. int size;
  6881. StringBuf buf;
  6882. nullpo_retr(-1, sd);
  6883. if( strcmp(command+1, "storagelist") == 0 )
  6884. {
  6885. location = "storage";
  6886. items = sd->status.storage.items;
  6887. size = MAX_STORAGE;
  6888. }
  6889. else
  6890. if( strcmp(command+1, "cartlist") == 0 )
  6891. {
  6892. location = "cart";
  6893. items = sd->status.cart;
  6894. size = MAX_CART;
  6895. }
  6896. else
  6897. if( strcmp(command+1, "itemlist") == 0 )
  6898. {
  6899. location = "inventory";
  6900. items = sd->status.inventory;
  6901. size = MAX_INVENTORY;
  6902. }
  6903. else
  6904. return 1;
  6905. StringBuf_Init(&buf);
  6906. count = 0; // total slots occupied
  6907. counter = 0; // total items found
  6908. for( i = 0; i < size; ++i )
  6909. {
  6910. const struct item* it = &items[i];
  6911. struct item_data* itd;
  6912. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  6913. continue;
  6914. counter += it->amount;
  6915. count++;
  6916. if( count == 1 )
  6917. {
  6918. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  6919. clif_displaymessage(fd, StringBuf_Value(&buf));
  6920. StringBuf_Clear(&buf);
  6921. }
  6922. if( it->refine )
  6923. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  6924. else
  6925. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  6926. if( it->equip )
  6927. {
  6928. char equipstr[CHAT_SIZE_MAX];
  6929. strcpy(equipstr, " | equipped: ");
  6930. if( it->equip & EQP_GARMENT )
  6931. strcat(equipstr, "garment, ");
  6932. if( it->equip & EQP_ACC_L )
  6933. strcat(equipstr, "left accessory, ");
  6934. if( it->equip & EQP_ARMOR )
  6935. strcat(equipstr, "body/armor, ");
  6936. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  6937. strcat(equipstr, "right hand, ");
  6938. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  6939. strcat(equipstr, "left hand, ");
  6940. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  6941. strcat(equipstr, "both hands, ");
  6942. if( it->equip & EQP_SHOES )
  6943. strcat(equipstr, "feet, ");
  6944. if( it->equip & EQP_ACC_R )
  6945. strcat(equipstr, "right accessory, ");
  6946. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  6947. strcat(equipstr, "lower head, ");
  6948. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  6949. strcat(equipstr, "top head, ");
  6950. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  6951. strcat(equipstr, "lower/top head, ");
  6952. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  6953. strcat(equipstr, "mid head, ");
  6954. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  6955. strcat(equipstr, "lower/mid head, ");
  6956. if( (it->equip & EQP_HELM) == EQP_HELM )
  6957. strcat(equipstr, "lower/mid/top head, ");
  6958. // remove final ', '
  6959. equipstr[strlen(equipstr) - 2] = '\0';
  6960. StringBuf_AppendStr(&buf, equipstr);
  6961. }
  6962. clif_displaymessage(fd, StringBuf_Value(&buf));
  6963. StringBuf_Clear(&buf);
  6964. if( it->card[0] == CARD0_PET )
  6965. {// pet egg
  6966. if (it->card[3])
  6967. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  6968. else
  6969. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  6970. }
  6971. else
  6972. if(it->card[0] == CARD0_FORGE)
  6973. {// forged item
  6974. 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);
  6975. }
  6976. else
  6977. if(it->card[0] == CARD0_CREATE)
  6978. {// created item
  6979. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  6980. }
  6981. else
  6982. {// normal item
  6983. int counter2 = 0;
  6984. for( j = 0; j < itd->slot; ++j )
  6985. {
  6986. struct item_data* card;
  6987. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  6988. continue;
  6989. counter2++;
  6990. if( counter2 == 1 )
  6991. StringBuf_AppendStr(&buf, " -> (card(s): ");
  6992. if( counter2 != 1 )
  6993. StringBuf_AppendStr(&buf, ", ");
  6994. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  6995. }
  6996. if( counter2 > 0 )
  6997. StringBuf_AppendStr(&buf, ")");
  6998. }
  6999. if( StringBuf_Length(&buf) > 0 )
  7000. clif_displaymessage(fd, StringBuf_Value(&buf));
  7001. StringBuf_Clear(&buf);
  7002. }
  7003. if( count == 0 )
  7004. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  7005. else
  7006. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  7007. clif_displaymessage(fd, StringBuf_Value(&buf));
  7008. StringBuf_Destroy(&buf);
  7009. return 0;
  7010. }
  7011. ACMD_FUNC(stats)
  7012. {
  7013. char job_jobname[100];
  7014. char output[CHAT_SIZE_MAX];
  7015. int i;
  7016. struct {
  7017. const char* format;
  7018. int value;
  7019. } output_table[] = {
  7020. { "Base Level - %d", 0 },
  7021. { NULL, 0 },
  7022. { "Hp - %d", 0 },
  7023. { "MaxHp - %d", 0 },
  7024. { "Sp - %d", 0 },
  7025. { "MaxSp - %d", 0 },
  7026. { "Str - %3d", 0 },
  7027. { "Agi - %3d", 0 },
  7028. { "Vit - %3d", 0 },
  7029. { "Int - %3d", 0 },
  7030. { "Dex - %3d", 0 },
  7031. { "Luk - %3d", 0 },
  7032. { "Zeny - %d", 0 },
  7033. { "Free SK Points - %d", 0 },
  7034. { "JobChangeLvl (2nd) - %d", 0 },
  7035. { "JobChangeLvl (3rd) - %d", 0 },
  7036. { NULL, 0 }
  7037. };
  7038. memset(job_jobname, '\0', sizeof(job_jobname));
  7039. memset(output, '\0', sizeof(output));
  7040. //direct array initialization with variables is not standard C compliant.
  7041. output_table[0].value = sd->status.base_level;
  7042. output_table[1].format = job_jobname;
  7043. output_table[1].value = sd->status.job_level;
  7044. output_table[2].value = sd->status.hp;
  7045. output_table[3].value = sd->status.max_hp;
  7046. output_table[4].value = sd->status.sp;
  7047. output_table[5].value = sd->status.max_sp;
  7048. output_table[6].value = sd->status.str;
  7049. output_table[7].value = sd->status.agi;
  7050. output_table[8].value = sd->status.vit;
  7051. output_table[9].value = sd->status.int_;
  7052. output_table[10].value = sd->status.dex;
  7053. output_table[11].value = sd->status.luk;
  7054. output_table[12].value = sd->status.zeny;
  7055. output_table[13].value = sd->status.skill_point;
  7056. output_table[14].value = sd->change_level_2nd;
  7057. output_table[15].value = sd->change_level_3rd;
  7058. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7059. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7060. clif_displaymessage(fd, output);
  7061. for (i = 0; output_table[i].format != NULL; i++) {
  7062. sprintf(output, output_table[i].format, output_table[i].value);
  7063. clif_displaymessage(fd, output);
  7064. }
  7065. return 0;
  7066. }
  7067. ACMD_FUNC(delitem)
  7068. {
  7069. char item_name[100];
  7070. int nameid, amount = 0, total, idx;
  7071. struct item_data* id;
  7072. nullpo_retr(-1, sd);
  7073. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7074. {
  7075. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  7076. return -1;
  7077. }
  7078. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7079. {
  7080. nameid = id->nameid;
  7081. }
  7082. else
  7083. {
  7084. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7085. return -1;
  7086. }
  7087. total = amount;
  7088. // delete items
  7089. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7090. {
  7091. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7092. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7093. {// delete pet
  7094. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7095. }
  7096. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7097. amount-= delamount;
  7098. }
  7099. // notify target
  7100. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7101. clif_displaymessage(sd->fd, atcmd_output);
  7102. // notify source
  7103. if( amount == total )
  7104. {
  7105. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7106. }
  7107. else if( amount )
  7108. {
  7109. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7110. clif_displaymessage(fd, atcmd_output);
  7111. }
  7112. else
  7113. {
  7114. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7115. clif_displaymessage(fd, atcmd_output);
  7116. }
  7117. return 0;
  7118. }
  7119. /*==========================================
  7120. * Custom Fonts
  7121. *------------------------------------------*/
  7122. ACMD_FUNC(font)
  7123. {
  7124. int font_id;
  7125. nullpo_retr(-1,sd);
  7126. font_id = atoi(message);
  7127. if( font_id == 0 )
  7128. {
  7129. if( sd->user_font )
  7130. {
  7131. sd->user_font = 0;
  7132. clif_displaymessage(fd, "Returning to normal font.");
  7133. clif_font(sd);
  7134. }
  7135. else
  7136. {
  7137. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  7138. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  7139. }
  7140. }
  7141. else if( font_id < 0 || font_id > 9 )
  7142. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  7143. else if( font_id != sd->user_font )
  7144. {
  7145. sd->user_font = font_id;
  7146. clif_font(sd);
  7147. clif_displaymessage(fd, "Font changed.");
  7148. }
  7149. else
  7150. clif_displaymessage(fd, "Already using this font.");
  7151. return 0;
  7152. }
  7153. /*==========================================
  7154. * type: 1 = commands (@), 2 = charcommands (#)
  7155. *------------------------------------------*/
  7156. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7157. {
  7158. char line_buff[CHATBOX_SIZE];
  7159. char* cur = line_buff;
  7160. AtCommandInfo* cmd;
  7161. DBIterator *iter = db_iterator(atcommand_db);
  7162. int count = 0;
  7163. memset(line_buff,' ',CHATBOX_SIZE);
  7164. line_buff[CHATBOX_SIZE-1] = 0;
  7165. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7166. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7167. unsigned int slen = 0;
  7168. if (!pc_can_use_command(sd, cmd->command, type))
  7169. continue;
  7170. slen = strlen(cmd->command);
  7171. // flush the text buffer if this command won't fit into it
  7172. if ( slen + cur - line_buff >= CHATBOX_SIZE )
  7173. {
  7174. clif_displaymessage(fd,line_buff);
  7175. cur = line_buff;
  7176. memset(line_buff,' ',CHATBOX_SIZE);
  7177. line_buff[CHATBOX_SIZE-1] = 0;
  7178. }
  7179. memcpy(cur,cmd->command,slen);
  7180. cur += slen+(10-slen%10);
  7181. count++;
  7182. }
  7183. dbi_destroy(iter);
  7184. clif_displaymessage(fd,line_buff);
  7185. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7186. clif_displaymessage(fd, atcmd_output);
  7187. return;
  7188. }
  7189. /*==========================================
  7190. * @commands Lists available @ commands to you
  7191. *------------------------------------------*/
  7192. ACMD_FUNC(commands)
  7193. {
  7194. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7195. return 0;
  7196. }
  7197. /*==========================================
  7198. * @charcommands Lists available # commands to you
  7199. *------------------------------------------*/
  7200. ACMD_FUNC(charcommands)
  7201. {
  7202. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7203. return 0;
  7204. }
  7205. ACMD_FUNC(new_mount) {
  7206. if( pc_cant_newmount(sd) && !(sd->sc.option&OPTION_MOUNTING) ) {
  7207. clif_displaymessage(sd->fd,"Your character cannot mount a new mount");
  7208. return -1;
  7209. }
  7210. clif_displaymessage(sd->fd,"NOTICE: If you crash with mount your LUA is outdated");
  7211. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7212. clif_displaymessage(sd->fd,"You have mounted.");
  7213. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7214. } else {
  7215. clif_displaymessage(sd->fd,"You have released your mount");
  7216. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7217. }
  7218. return 0;
  7219. }
  7220. /**
  7221. * Fills the reference of available commands in atcommand DBMap
  7222. **/
  7223. #define ACMD_DEF(x) { #x, atcommand_ ## x }
  7224. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x }
  7225. void atcommand_basecommands(void) {
  7226. /**
  7227. * Command reference list, place the base of your commands here
  7228. **/
  7229. AtCommandInfo atcommand_base[] = {
  7230. ACMD_DEF2("warp", mapmove),
  7231. ACMD_DEF(where),
  7232. ACMD_DEF(jumpto),
  7233. ACMD_DEF(jump),
  7234. ACMD_DEF(who),
  7235. ACMD_DEF2("who2", who),
  7236. ACMD_DEF2("who3", who),
  7237. ACMD_DEF2("whomap", who),
  7238. ACMD_DEF2("whomap2", who),
  7239. ACMD_DEF2("whomap3", who),
  7240. ACMD_DEF(whogm),
  7241. ACMD_DEF(save),
  7242. ACMD_DEF(load),
  7243. ACMD_DEF(speed),
  7244. ACMD_DEF(storage),
  7245. ACMD_DEF(guildstorage),
  7246. ACMD_DEF(option),
  7247. ACMD_DEF(hide), // + /hide
  7248. ACMD_DEF(jobchange),
  7249. ACMD_DEF(kill),
  7250. ACMD_DEF(alive),
  7251. ACMD_DEF(kami),
  7252. ACMD_DEF2("kamib", kami),
  7253. ACMD_DEF2("kamic", kami),
  7254. ACMD_DEF2("lkami", kami),
  7255. ACMD_DEF(heal),
  7256. ACMD_DEF(item),
  7257. ACMD_DEF(item2),
  7258. ACMD_DEF(itemreset),
  7259. ACMD_DEF2("blvl", baselevelup),
  7260. ACMD_DEF2("jlvl", joblevelup),
  7261. ACMD_DEF(help),
  7262. ACMD_DEF(pvpoff),
  7263. ACMD_DEF(pvpon),
  7264. ACMD_DEF(gvgoff),
  7265. ACMD_DEF(gvgon),
  7266. ACMD_DEF(model),
  7267. ACMD_DEF(go),
  7268. ACMD_DEF(monster),
  7269. ACMD_DEF2("monstersmall", monster),
  7270. ACMD_DEF2("monsterbig", monster),
  7271. ACMD_DEF(killmonster),
  7272. ACMD_DEF(killmonster2),
  7273. ACMD_DEF(refine),
  7274. ACMD_DEF(produce),
  7275. ACMD_DEF(memo),
  7276. ACMD_DEF(gat),
  7277. ACMD_DEF(displaystatus),
  7278. ACMD_DEF2("stpoint", statuspoint),
  7279. ACMD_DEF2("skpoint", skillpoint),
  7280. ACMD_DEF(zeny),
  7281. ACMD_DEF2("str", param),
  7282. ACMD_DEF2("agi", param),
  7283. ACMD_DEF2("vit", param),
  7284. ACMD_DEF2("int", param),
  7285. ACMD_DEF2("dex", param),
  7286. ACMD_DEF2("luk", param),
  7287. ACMD_DEF2("glvl", guildlevelup),
  7288. ACMD_DEF(makeegg),
  7289. ACMD_DEF(hatch),
  7290. ACMD_DEF(petfriendly),
  7291. ACMD_DEF(pethungry),
  7292. ACMD_DEF(petrename),
  7293. ACMD_DEF(recall), // + /recall
  7294. ACMD_DEF(night),
  7295. ACMD_DEF(day),
  7296. ACMD_DEF(doom),
  7297. ACMD_DEF(doommap),
  7298. ACMD_DEF(raise),
  7299. ACMD_DEF(raisemap),
  7300. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  7301. ACMD_DEF(kickall),
  7302. ACMD_DEF(allskill),
  7303. ACMD_DEF(questskill),
  7304. ACMD_DEF(lostskill),
  7305. ACMD_DEF(spiritball),
  7306. ACMD_DEF(party),
  7307. ACMD_DEF(guild),
  7308. ACMD_DEF(agitstart),
  7309. ACMD_DEF(agitend),
  7310. ACMD_DEF(mapexit),
  7311. ACMD_DEF(idsearch),
  7312. ACMD_DEF(broadcast), // + /b and /nb
  7313. ACMD_DEF(localbroadcast), // + /lb and /nlb
  7314. ACMD_DEF(recallall),
  7315. ACMD_DEF(reloaditemdb),
  7316. ACMD_DEF(reloadmobdb),
  7317. ACMD_DEF(reloadskilldb),
  7318. ACMD_DEF(reloadscript),
  7319. ACMD_DEF(reloadatcommand),
  7320. ACMD_DEF(reloadbattleconf),
  7321. ACMD_DEF(reloadstatusdb),
  7322. ACMD_DEF(reloadpcdb),
  7323. ACMD_DEF(reloadmotd),
  7324. ACMD_DEF(mapinfo),
  7325. ACMD_DEF(dye),
  7326. ACMD_DEF2("hairstyle", hair_style),
  7327. ACMD_DEF2("haircolor", hair_color),
  7328. ACMD_DEF2("allstats", stat_all),
  7329. ACMD_DEF2("block", char_block),
  7330. ACMD_DEF2("ban", char_ban),
  7331. ACMD_DEF2("unblock", char_unblock),
  7332. ACMD_DEF2("unban", char_unban),
  7333. ACMD_DEF2("mount", mount_peco),
  7334. ACMD_DEF(guildspy),
  7335. ACMD_DEF(partyspy),
  7336. ACMD_DEF(repairall),
  7337. ACMD_DEF(guildrecall),
  7338. ACMD_DEF(partyrecall),
  7339. ACMD_DEF(nuke),
  7340. ACMD_DEF(shownpc),
  7341. ACMD_DEF(hidenpc),
  7342. ACMD_DEF(loadnpc),
  7343. ACMD_DEF(unloadnpc),
  7344. ACMD_DEF2("time", servertime),
  7345. ACMD_DEF(jail),
  7346. ACMD_DEF(unjail),
  7347. ACMD_DEF(jailfor),
  7348. ACMD_DEF(jailtime),
  7349. ACMD_DEF(disguise),
  7350. ACMD_DEF(undisguise),
  7351. ACMD_DEF(email),
  7352. ACMD_DEF(effect),
  7353. ACMD_DEF(follow),
  7354. ACMD_DEF(addwarp),
  7355. ACMD_DEF(skillon),
  7356. ACMD_DEF(skilloff),
  7357. ACMD_DEF(killer),
  7358. ACMD_DEF(npcmove),
  7359. ACMD_DEF(killable),
  7360. ACMD_DEF(dropall),
  7361. ACMD_DEF(storeall),
  7362. ACMD_DEF(skillid),
  7363. ACMD_DEF(useskill),
  7364. ACMD_DEF(displayskill),
  7365. ACMD_DEF(snow),
  7366. ACMD_DEF(sakura),
  7367. ACMD_DEF(clouds),
  7368. ACMD_DEF(clouds2),
  7369. ACMD_DEF(fog),
  7370. ACMD_DEF(fireworks),
  7371. ACMD_DEF(leaves),
  7372. ACMD_DEF(summon),
  7373. ACMD_DEF(adjgroup),
  7374. ACMD_DEF(trade),
  7375. ACMD_DEF(send),
  7376. ACMD_DEF(setbattleflag),
  7377. ACMD_DEF(unmute),
  7378. ACMD_DEF(clearweather),
  7379. ACMD_DEF(uptime),
  7380. ACMD_DEF(changesex),
  7381. ACMD_DEF(mute),
  7382. ACMD_DEF(refresh),
  7383. ACMD_DEF(identify),
  7384. ACMD_DEF(gmotd),
  7385. ACMD_DEF(misceffect),
  7386. ACMD_DEF(mobsearch),
  7387. ACMD_DEF(cleanmap),
  7388. ACMD_DEF(npctalk),
  7389. ACMD_DEF(pettalk),
  7390. ACMD_DEF(users),
  7391. ACMD_DEF(reset),
  7392. ACMD_DEF(skilltree),
  7393. ACMD_DEF(marry),
  7394. ACMD_DEF(divorce),
  7395. ACMD_DEF(sound),
  7396. ACMD_DEF(undisguiseall),
  7397. ACMD_DEF(disguiseall),
  7398. ACMD_DEF(changelook),
  7399. ACMD_DEF(autoloot),
  7400. ACMD_DEF2("alootid", autolootitem),
  7401. ACMD_DEF(mobinfo),
  7402. ACMD_DEF(exp),
  7403. ACMD_DEF(adopt),
  7404. ACMD_DEF(version),
  7405. ACMD_DEF(mutearea),
  7406. ACMD_DEF(rates),
  7407. ACMD_DEF(iteminfo),
  7408. ACMD_DEF(whodrops),
  7409. ACMD_DEF(whereis),
  7410. ACMD_DEF(mapflag),
  7411. ACMD_DEF(me),
  7412. ACMD_DEF(monsterignore),
  7413. ACMD_DEF(fakename),
  7414. ACMD_DEF(size),
  7415. ACMD_DEF(showexp),
  7416. ACMD_DEF(showzeny),
  7417. ACMD_DEF(showdelay),
  7418. ACMD_DEF(autotrade),
  7419. ACMD_DEF(changegm),
  7420. ACMD_DEF(changeleader),
  7421. ACMD_DEF(partyoption),
  7422. ACMD_DEF(invite),
  7423. ACMD_DEF(duel),
  7424. ACMD_DEF(leave),
  7425. ACMD_DEF(accept),
  7426. ACMD_DEF(reject),
  7427. ACMD_DEF(main),
  7428. ACMD_DEF(clone),
  7429. ACMD_DEF2("slaveclone", clone),
  7430. ACMD_DEF2("evilclone", clone),
  7431. ACMD_DEF(tonpc),
  7432. ACMD_DEF(commands),
  7433. ACMD_DEF(noask),
  7434. ACMD_DEF(request),
  7435. ACMD_DEF(homlevel),
  7436. ACMD_DEF(homevolution),
  7437. ACMD_DEF(makehomun),
  7438. ACMD_DEF(homfriendly),
  7439. ACMD_DEF(homhungry),
  7440. ACMD_DEF(homtalk),
  7441. ACMD_DEF(hominfo),
  7442. ACMD_DEF(homstats),
  7443. ACMD_DEF(homshuffle),
  7444. ACMD_DEF(showmobs),
  7445. ACMD_DEF(feelreset),
  7446. ACMD_DEF(auction),
  7447. ACMD_DEF(mail),
  7448. ACMD_DEF2("noks", ksprotection),
  7449. ACMD_DEF(allowks),
  7450. ACMD_DEF(cash),
  7451. ACMD_DEF2("points", cash),
  7452. ACMD_DEF(agitstart2),
  7453. ACMD_DEF(agitend2),
  7454. ACMD_DEF2("skreset", resetskill),
  7455. ACMD_DEF2("streset", resetstat),
  7456. ACMD_DEF2("storagelist", itemlist),
  7457. ACMD_DEF2("cartlist", itemlist),
  7458. ACMD_DEF2("itemlist", itemlist),
  7459. ACMD_DEF(stats),
  7460. ACMD_DEF(delitem),
  7461. ACMD_DEF(charcommands),
  7462. ACMD_DEF(font),
  7463. /**
  7464. * For Testing Purposes, not going to be here after we're done.
  7465. **/
  7466. ACMD_DEF2("newmount", new_mount),
  7467. };
  7468. AtCommandInfo* atcommand;
  7469. int i;
  7470. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7471. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  7472. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  7473. continue;
  7474. }
  7475. CREATE(atcommand, AtCommandInfo, 1);
  7476. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  7477. atcommand->func = atcommand_base[i].func;
  7478. strdb_put(atcommand_db, atcommand->command, atcommand);
  7479. }
  7480. return;
  7481. }
  7482. /*==========================================
  7483. * Command lookup functions
  7484. *------------------------------------------*/
  7485. bool atcommand_exists(const char* name)
  7486. {
  7487. return strdb_exists(atcommand_db, name);
  7488. }
  7489. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  7490. {
  7491. if (strdb_exists(atcommand_db, name))
  7492. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7493. return NULL;
  7494. }
  7495. static const char* atcommand_checkalias(const char *aliasname)
  7496. {
  7497. AliasInfo *alias_info = NULL;
  7498. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  7499. return alias_info->command->command;
  7500. return aliasname;
  7501. }
  7502. /// Executes an at-command.
  7503. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7504. {
  7505. char charname[NAME_LENGTH], params[100];
  7506. char charname2[NAME_LENGTH], params2[100];
  7507. char command[100];
  7508. char output[CHAT_SIZE_MAX];
  7509. //Reconstructed message
  7510. char atcmd_msg[CHAT_SIZE_MAX];
  7511. TBL_PC * ssd = NULL; //sd for target
  7512. AtCommandInfo * info;
  7513. nullpo_retr(false, sd);
  7514. //Shouldn't happen
  7515. if ( !message || !*message )
  7516. return false;
  7517. //Block NOCHAT but do not display it as a normal message
  7518. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7519. return true;
  7520. // skip 10/11-langtype's codepage indicator, if detected
  7521. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7522. message += 3;
  7523. //Should display as a normal message
  7524. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7525. return false;
  7526. // type value 0 = server invoked: bypass restrictions
  7527. // 1 = player invoked
  7528. if ( type == 1) {
  7529. //Commands are disabled on maps flagged as 'nocommand'
  7530. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  7531. clif_displaymessage(fd, msg_txt(143));
  7532. return false;
  7533. }
  7534. }
  7535. if (*message == charcommand_symbol) {
  7536. do {
  7537. int x, y, z;
  7538. //Checks to see if #command has a name or a name + parameters.
  7539. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7540. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7541. //z always has the value of the scan that was successful
  7542. z = ( x > 1 ) ? x : y;
  7543. //#command + name means the sufficient target was used and anything else after
  7544. //can be looked at by the actual command function since most scan to see if the
  7545. //right parameters are used.
  7546. if ( x > 2 ) {
  7547. sprintf(atcmd_msg, "%s %s", command, params);
  7548. break;
  7549. }
  7550. else if ( y > 2 ) {
  7551. sprintf(atcmd_msg, "%s %s", command, params2);
  7552. break;
  7553. }
  7554. //Regardless of what style the #command is used, if it's correct, it will always have
  7555. //this value if there is no parameter. Send it as just the #command
  7556. else if ( z == 2 ) {
  7557. sprintf(atcmd_msg, "%s", command);
  7558. break;
  7559. }
  7560. sprintf(output, "Charcommand failed. Usage: %c<command> <char name> <params>.", charcommand_symbol);
  7561. clif_displaymessage(fd, output);
  7562. return true;
  7563. } while(0);
  7564. }
  7565. else if (*message == atcommand_symbol) {
  7566. //atcmd_msg is constructed above differently for charcommands
  7567. //it's copied from message if not a charcommand so it can
  7568. //pass through the rest of the code compatible with both symbols
  7569. sprintf(atcmd_msg, "%s", message);
  7570. }
  7571. //Clearing these to be used once more.
  7572. memset(command, '\0', sizeof(command));
  7573. memset(params, '\0', sizeof(params));
  7574. //check to see if any params exist within this command
  7575. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7576. params[0] = '\0';
  7577. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7578. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  7579. if (info == NULL)
  7580. {
  7581. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  7582. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7583. clif_displaymessage(fd, output);
  7584. return true;
  7585. } else
  7586. return false;
  7587. }
  7588. // type == 1 : player invoked
  7589. if (type == 1) {
  7590. if ((*command == atcommand_symbol && !pc_can_use_command(sd, atcommand_checkalias(command + 1), COMMAND_ATCOMMAND)) ||
  7591. (*command == charcommand_symbol && !pc_can_use_command(sd, atcommand_checkalias(command + 1), COMMAND_CHARCOMMAND))) {
  7592. return false;
  7593. }
  7594. }
  7595. // Check if target is valid only if confirmed that player can use command.
  7596. if (*message == charcommand_symbol &&
  7597. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  7598. sprintf(output, "%s failed. Player not found.", command);
  7599. clif_displaymessage(fd, output);
  7600. return true;
  7601. }
  7602. //Attempt to use the command
  7603. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  7604. {
  7605. sprintf(output,msg_txt(154), command); // %s failed.
  7606. clif_displaymessage(fd, output);
  7607. return true;
  7608. }
  7609. //Log only if successful.
  7610. if ( *atcmd_msg == atcommand_symbol )
  7611. log_atcommand(sd, atcmd_msg);
  7612. else if ( *atcmd_msg == charcommand_symbol )
  7613. log_atcommand(sd, message);
  7614. return true;
  7615. }
  7616. /*==========================================
  7617. *
  7618. *------------------------------------------*/
  7619. static void atcommand_config_read(const char* config_filename)
  7620. {
  7621. config_setting_t *aliases = NULL, *help = NULL;
  7622. const char *symbol = NULL;
  7623. int num_aliases = 0;
  7624. if (conf_read_file(&atcommand_config, config_filename))
  7625. return;
  7626. // Command symbols
  7627. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  7628. if (ISPRINT(*symbol) && // no control characters
  7629. *symbol != '/' && // symbol of client commands
  7630. *symbol != '%' && // symbol of party chat
  7631. *symbol != '$' && // symbol of guild chat
  7632. *symbol != charcommand_symbol)
  7633. atcommand_symbol = *symbol;
  7634. }
  7635. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  7636. if (ISPRINT(*symbol) && // no control characters
  7637. *symbol != '/' && // symbol of client commands
  7638. *symbol != '%' && // symbol of party chat
  7639. *symbol != '$' && // symbol of guild chat
  7640. *symbol != atcommand_symbol)
  7641. charcommand_symbol = *symbol;
  7642. }
  7643. // Command aliases
  7644. aliases = config_lookup(&atcommand_config, "aliases");
  7645. if (aliases != NULL) {
  7646. int i = 0;
  7647. int count = config_setting_length(aliases);
  7648. for (i = 0; i < count; ++i) {
  7649. config_setting_t *command = NULL;
  7650. const char *commandname = NULL;
  7651. int j = 0, alias_count = 0;
  7652. AtCommandInfo *commandinfo = NULL;
  7653. command = config_setting_get_elem(aliases, i);
  7654. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  7655. continue;
  7656. commandname = config_setting_name(command);
  7657. if (!atcommand_exists(commandname)) {
  7658. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  7659. continue;
  7660. }
  7661. commandinfo = get_atcommandinfo_byname(commandname);
  7662. alias_count = config_setting_length(command);
  7663. for (j = 0; j < alias_count; ++j) {
  7664. const char *alias = config_setting_get_string_elem(command, j);
  7665. if (alias != NULL) {
  7666. AliasInfo *alias_info;
  7667. if (strdb_exists(atcommand_alias_db, alias)) {
  7668. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  7669. continue;
  7670. }
  7671. CREATE(alias_info, AliasInfo, 1);
  7672. alias_info->command = commandinfo;
  7673. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  7674. strdb_put(atcommand_alias_db, alias, alias_info);
  7675. ++num_aliases;
  7676. }
  7677. }
  7678. }
  7679. }
  7680. // Commands help
  7681. // We only check if all commands exist
  7682. help = config_lookup(&atcommand_config, "help");
  7683. if (help != NULL) {
  7684. int count = config_setting_length(help);
  7685. int i;
  7686. for (i = 0; i < count; ++i) {
  7687. config_setting_t *command = NULL;
  7688. const char *commandname = NULL;
  7689. command = config_setting_get_elem(help, i);
  7690. commandname = config_setting_name(command);
  7691. if (!atcommand_exists(commandname))
  7692. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  7693. }
  7694. }
  7695. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  7696. return;
  7697. }
  7698. void atcommand_db_clear(void)
  7699. {
  7700. if (atcommand_db != NULL)
  7701. db_destroy(atcommand_db);
  7702. if (atcommand_alias_db != NULL)
  7703. db_destroy(atcommand_alias_db);
  7704. }
  7705. void atcommand_doload(void)
  7706. {
  7707. atcommand_db_clear();
  7708. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  7709. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  7710. atcommand_basecommands(); //fills initial atcommand_db with known commands
  7711. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  7712. }
  7713. void do_init_atcommand(void)
  7714. {
  7715. atcommand_doload();
  7716. }
  7717. void do_final_atcommand(void)
  7718. {
  7719. atcommand_db_clear();
  7720. }