atcommand.cpp 332 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "atcommand.hpp"
  4. #include <set>
  5. #include <unordered_map>
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include "../common/cbasetypes.hpp"
  9. #include "../common/database.hpp"
  10. #include "../common/cli.hpp"
  11. #include "../common/conf.hpp"
  12. #include "../common/malloc.hpp"
  13. #include "../common/mmo.hpp"
  14. #include "../common/nullpo.hpp"
  15. #include "../common/random.hpp"
  16. #include "../common/showmsg.hpp"
  17. #include "../common/socket.hpp"
  18. #include "../common/strlib.hpp"
  19. #include "../common/timer.hpp"
  20. #include "../common/utilities.hpp"
  21. #include "../common/utils.hpp"
  22. #include "achievement.hpp"
  23. #include "battle.hpp"
  24. #include "channel.hpp"
  25. #include "chat.hpp"
  26. #include "chrif.hpp"
  27. #include "clan.hpp"
  28. #include "clif.hpp"
  29. #include "duel.hpp"
  30. #include "elemental.hpp"
  31. #include "guild.hpp"
  32. #include "homunculus.hpp"
  33. #include "instance.hpp"
  34. #include "intif.hpp"
  35. #include "itemdb.hpp" // MAX_ITEMGROUP
  36. #include "log.hpp"
  37. #include "mail.hpp"
  38. #include "map.hpp"
  39. #include "mapreg.hpp"
  40. #include "mercenary.hpp"
  41. #include "mob.hpp"
  42. #include "npc.hpp"
  43. #include "party.hpp"
  44. #include "pc.hpp"
  45. #include "pc_groups.hpp"
  46. #include "pet.hpp"
  47. #include "quest.hpp"
  48. #include "script.hpp"
  49. #include "storage.hpp"
  50. #include "trade.hpp"
  51. using namespace rathena;
  52. #define ATCOMMAND_LENGTH 50
  53. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  54. typedef struct AtCommandInfo AtCommandInfo;
  55. int atcmd_binding_count = 0;
  56. /// Atcommand restriction usage
  57. enum e_atcmd_restict {
  58. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  59. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  60. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  61. };
  62. struct AtCommandInfo {
  63. char command[ATCOMMAND_LENGTH];
  64. AtCommandFunc func;
  65. char* at_groups; /// Quick @commands "can-use" lookup
  66. char* char_groups; /// Quick @charcommands "can-use" lookup
  67. uint8 restriction; /// Restrictions see enum e_restict
  68. };
  69. struct s_atcommand_alias_info{
  70. AtCommandInfo *command;
  71. std::set<std::string> aliases;
  72. std::string help;
  73. };
  74. char atcommand_symbol = '@'; // first char of the commands
  75. char charcommand_symbol = '#';
  76. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  77. static AtCommandInfo* get_atcommandinfo_byname( const char* name );
  78. class AtcommandAliasDatabase : public TypesafeYamlDatabase<std::string, s_atcommand_alias_info>{
  79. private:
  80. std::unordered_map<std::string, std::string> aliases;
  81. public:
  82. AtcommandAliasDatabase() : TypesafeYamlDatabase( "ATCOMMAND_DB", 1 ){
  83. }
  84. void clear();
  85. const std::string getDefaultLocation();
  86. uint64 parseBodyNode( const YAML::Node& node );
  87. const char* checkAlias( const char* alias );
  88. };
  89. void AtcommandAliasDatabase::clear(){
  90. TypesafeYamlDatabase::clear();
  91. this->aliases.clear();
  92. }
  93. const std::string AtcommandAliasDatabase::getDefaultLocation(){
  94. return std::string(conf_path) + "/atcommands.yml";
  95. }
  96. uint64 AtcommandAliasDatabase::parseBodyNode( const YAML::Node& node ){
  97. std::string command;
  98. if( !this->asString( node, "Command", command ) ){
  99. return 0;
  100. }
  101. AtCommandInfo* commandinfo = get_atcommandinfo_byname( command.c_str() );
  102. if( commandinfo == nullptr ){
  103. this->invalidWarning( node["Command"], "Command %s does not exist.\n", command.c_str() );
  104. return 0;
  105. }
  106. std::shared_ptr<s_atcommand_alias_info> info = this->find( command );
  107. bool exists = info != nullptr;
  108. if( !exists ){
  109. info = std::make_shared<s_atcommand_alias_info>();
  110. info->command = commandinfo;
  111. }
  112. if( this->nodeExists( node, "Help" ) ){
  113. std::string help;
  114. if( !this->asString( node, "Help", help ) ){
  115. return 0;
  116. }
  117. info->help = help;
  118. }
  119. if( this->nodeExists( node, "Aliases" ) ){
  120. const YAML::Node& aliasesNode = node["Aliases"];
  121. if( !aliasesNode.IsSequence() ){
  122. this->invalidWarning( aliasesNode, "Aliases should be a sequence.\n" );
  123. return 0;
  124. }
  125. for( const auto& subNode : aliasesNode ){
  126. std::string alias = subNode.as<std::string>();
  127. info->aliases.insert( alias );
  128. this->aliases[alias] = command;
  129. }
  130. }
  131. if( !exists ){
  132. this->put( command, info );
  133. }
  134. return 1;
  135. }
  136. const char* AtcommandAliasDatabase::checkAlias( const char* alias ){
  137. std::string alias_str( alias );
  138. std::string* command = util::umap_find( this->aliases, alias_str );
  139. if( command == nullptr ){
  140. return alias;
  141. }else{
  142. return command->c_str();
  143. }
  144. }
  145. AtcommandAliasDatabase atcommand_alias_db;
  146. static char atcmd_output[CHAT_SIZE_MAX];
  147. static char atcmd_player_name[NAME_LENGTH];
  148. const char *parent_cmd;
  149. struct atcmd_binding_data** atcmd_binding;
  150. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  151. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  152. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  153. // @commands (script-based)
  154. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  155. int i = 0;
  156. if( *name == atcommand_symbol || *name == charcommand_symbol )
  157. name++; // for backwards compatibility
  158. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  159. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  160. }
  161. /**
  162. * retrieves the help string associated with a given command.
  163. *
  164. * @param name the name of the command to retrieve help information for
  165. * @return the string associated with the command, or NULL
  166. */
  167. static const char* atcommand_help_string( const char* command ){
  168. // remove the prefix symbol for the raw name of the command
  169. if( *command == atcommand_symbol || *command == charcommand_symbol ){
  170. command++;
  171. }
  172. // convert alias to the real command name
  173. command = atcommand_alias_db.checkAlias( command );
  174. // attempt to find the first default help command
  175. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command );
  176. // failed to find the help property in the configuration file
  177. if( info == nullptr ){
  178. return nullptr;
  179. }
  180. // push the result from the method
  181. return info->help.c_str();
  182. }
  183. /*==========================================
  184. * @send (used for testing packet sends from the client)
  185. *------------------------------------------*/
  186. ACMD_FUNC(send)
  187. {
  188. int len=0,type;
  189. // read message type as hex number (without the 0x)
  190. if(!message || !*message ||
  191. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  192. || sscanf(message, "%8x", &type)==1) )
  193. {
  194. int i;
  195. for (i = 900; i <= 903; ++i)
  196. clif_displaymessage(fd, msg_txt(sd,i));
  197. return -1;
  198. }
  199. #define PARSE_ERROR(error,p) \
  200. {\
  201. clif_displaymessage(fd, (error));\
  202. sprintf(atcmd_output, ">%s", (p));\
  203. clif_displaymessage(fd, atcmd_output);\
  204. }
  205. //define PARSE_ERROR
  206. #define CHECK_EOS(p) \
  207. if(*(p) == 0){\
  208. clif_displaymessage(fd, "Unexpected end of string");\
  209. return -1;\
  210. }
  211. //define CHECK_EOS
  212. #define SKIP_VALUE(p) \
  213. {\
  214. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  215. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  216. }
  217. //define SKIP_VALUE
  218. #define GET_VALUE(p,num) \
  219. {\
  220. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  221. PARSE_ERROR("Invalid number in:",(p));\
  222. return -1;\
  223. }\
  224. }
  225. //define GET_VALUE
  226. if (type > 0 && type < MAX_PACKET_DB) {
  227. int off,end;
  228. long num;
  229. if(len)
  230. {// show packet length
  231. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  232. clif_displaymessage(fd, atcmd_output);
  233. return 0;
  234. }
  235. len=packet_db[type].len;
  236. off=2;
  237. if(len == 0)
  238. {// unknown packet - ERROR
  239. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  240. clif_displaymessage(fd, atcmd_output);
  241. return -1;
  242. } else if(len == -1)
  243. {// dynamic packet
  244. len=SHRT_MAX-4; // maximum length
  245. off=4;
  246. }
  247. WFIFOHEAD(fd, len);
  248. WFIFOW(fd,0)=TOW(type);
  249. // parse packet contents
  250. SKIP_VALUE(message);
  251. while(*message != 0 && off < len){
  252. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  253. {// default (byte)
  254. GET_VALUE(message,num);
  255. WFIFOB(fd,off)=TOB(num);
  256. ++off;
  257. } else if(TOUPPER(*message) == 'B')
  258. {// byte
  259. ++message;
  260. GET_VALUE(message,num);
  261. WFIFOB(fd,off)=TOB(num);
  262. ++off;
  263. } else if(TOUPPER(*message) == 'W')
  264. {// word (2 bytes)
  265. ++message;
  266. GET_VALUE(message,num);
  267. WFIFOW(fd,off)=TOW(num);
  268. off+=2;
  269. } else if(TOUPPER(*message) == 'L')
  270. {// long word (4 bytes)
  271. ++message;
  272. GET_VALUE(message,num);
  273. WFIFOL(fd,off)=TOL(num);
  274. off+=4;
  275. } else if(TOUPPER(*message) == 'S')
  276. {// string - escapes are valid
  277. // get string length - num <= 0 means not fixed length (default)
  278. ++message;
  279. if(*message == '"'){
  280. num=0;
  281. } else {
  282. GET_VALUE(message,num);
  283. while(*message != '"')
  284. {// find start of string
  285. if(*message == 0 || ISSPACE(*message)){
  286. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  287. return -1;
  288. }
  289. ++message;
  290. }
  291. }
  292. // parse string
  293. ++message;
  294. CHECK_EOS(message);
  295. end=(num<=0? 0: min(off+((int)num),len));
  296. for(; *message != '"' && (off < end || end == 0); ++off){
  297. if(*message == '\\'){
  298. ++message;
  299. CHECK_EOS(message);
  300. switch(*message){
  301. case 'a': num=0x07; break; // Bell
  302. case 'b': num=0x08; break; // Backspace
  303. case 't': num=0x09; break; // Horizontal tab
  304. case 'n': num=0x0A; break; // Line feed
  305. case 'v': num=0x0B; break; // Vertical tab
  306. case 'f': num=0x0C; break; // Form feed
  307. case 'r': num=0x0D; break; // Carriage return
  308. case 'e': num=0x1B; break; // Escape
  309. default: num=*message; break;
  310. case 'x': // Hexadecimal
  311. {
  312. ++message;
  313. CHECK_EOS(message);
  314. if(!ISXDIGIT(*message)){
  315. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  316. return -1;
  317. }
  318. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  319. if(ISXDIGIT(*message)){
  320. ++message;
  321. CHECK_EOS(message);
  322. num<<=8;
  323. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  324. }
  325. WFIFOB(fd,off)=TOB(num);
  326. ++message;
  327. CHECK_EOS(message);
  328. continue;
  329. }
  330. case '0':
  331. case '1':
  332. case '2':
  333. case '3':
  334. case '4':
  335. case '5':
  336. case '6':
  337. case '7': // Octal
  338. {
  339. num=*message-'0'; // 1st octal digit
  340. ++message;
  341. CHECK_EOS(message);
  342. if(ISDIGIT(*message) && *message < '8'){
  343. num<<=3;
  344. num+=*message-'0'; // 2nd octal digit
  345. ++message;
  346. CHECK_EOS(message);
  347. if(ISDIGIT(*message) && *message < '8'){
  348. num<<=3;
  349. num+=*message-'0'; // 3rd octal digit
  350. ++message;
  351. CHECK_EOS(message);
  352. }
  353. }
  354. WFIFOB(fd,off)=TOB(num);
  355. continue;
  356. }
  357. }
  358. } else
  359. num=*message;
  360. WFIFOB(fd,off)=TOB(num);
  361. ++message;
  362. CHECK_EOS(message);
  363. }//for
  364. while(*message != '"')
  365. {// ignore extra characters
  366. ++message;
  367. CHECK_EOS(message);
  368. }
  369. // terminate the string
  370. if(off < end)
  371. {// fill the rest with 0's
  372. memset(WFIFOP(fd,off),0,end-off);
  373. off=end;
  374. }
  375. } else
  376. {// unknown
  377. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  378. return -1;
  379. }
  380. SKIP_VALUE(message);
  381. }
  382. if(packet_db[type].len == -1)
  383. {// send dynamic packet
  384. WFIFOW(fd,2)=TOW(off);
  385. WFIFOSET(fd,off);
  386. } else
  387. {// send static packet
  388. if(off < len)
  389. memset(WFIFOP(fd,off),0,len-off);
  390. WFIFOSET(fd,len);
  391. }
  392. } else {
  393. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  394. return -1;
  395. }
  396. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  397. clif_displaymessage(fd, atcmd_output);
  398. return 0;
  399. #undef PARSE_ERROR
  400. #undef CHECK_EOS
  401. #undef SKIP_VALUE
  402. #undef GET_VALUE
  403. }
  404. /**
  405. * Retrieves map name suggestions for a given string.
  406. * This will first check if any map names contain the given string, and will
  407. * print out MAX_SUGGESTIONS results if any maps are found.
  408. * Otherwise, suggestions will be calculated through Levenshtein distance,
  409. * and up to 5 of the closest matches will be printed.
  410. *
  411. * @author Euphy
  412. */
  413. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  414. // Minimum length for suggestions is 2 characters
  415. if( strlen( name ) < 2 ){
  416. return;
  417. }
  418. std::vector<const char*> suggestions;
  419. suggestions.reserve( MAX_SUGGESTIONS );
  420. // check for maps that contain string
  421. for (int i = 0; i < map_num; i++) {
  422. struct map_data *mapdata = map_getmapdata(i);
  423. // Prevent suggestion of instance mapnames
  424. if( mapdata->instance_id != 0 ){
  425. continue;
  426. }
  427. if( strstr( mapdata->name, name ) != nullptr ){
  428. suggestions.push_back( mapdata->name );
  429. if( suggestions.size() == MAX_SUGGESTIONS ){
  430. break;
  431. }
  432. }
  433. }
  434. // if no maps found, search by edit distance
  435. if( suggestions.empty() ){
  436. // Levenshtein > 4 is bad
  437. const int LEVENSHTEIN_MAX = 4;
  438. std::unordered_map<int, std::vector<const char*>> maps;
  439. for (int i = 0; i < map_num; i++) {
  440. struct map_data *mapdata = map_getmapdata(i);
  441. // Prevent suggestion of instance mapnames
  442. if(mapdata->instance_id != 0 ){
  443. continue;
  444. }
  445. // Calculate the levenshtein distance of the two strings
  446. int distance = levenshtein(mapdata->name, name);
  447. // Check if it is above the maximum defined distance
  448. if( distance > LEVENSHTEIN_MAX ){
  449. continue;
  450. }
  451. std::vector<const char*>& vector = maps[distance];
  452. // Do not add more entries than required
  453. if( vector.size() == MAX_SUGGESTIONS ){
  454. continue;
  455. }
  456. vector.push_back(mapdata->name);
  457. }
  458. for( int distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){
  459. std::vector<const char*>& vector = maps[distance];
  460. for( const char* found_map : vector ){
  461. suggestions.push_back( found_map );
  462. if( suggestions.size() == MAX_SUGGESTIONS ){
  463. break;
  464. }
  465. }
  466. if( suggestions.size() == MAX_SUGGESTIONS ){
  467. break;
  468. }
  469. }
  470. }
  471. // If no suggestion could be made, do not output anything at all
  472. if( suggestions.empty() ){
  473. return;
  474. }
  475. char buffer[CHAT_SIZE_MAX];
  476. // build the suggestion string
  477. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  478. strcat(buffer, "\n");
  479. for( const char* suggestion : suggestions ){
  480. strcat(buffer, suggestion);
  481. strcat(buffer, " ");
  482. }
  483. clif_displaymessage(sd->fd, buffer);
  484. }
  485. /*==========================================
  486. * @rura, @warp, @mapmove
  487. *------------------------------------------*/
  488. ACMD_FUNC(mapmove)
  489. {
  490. char map_name[MAP_NAME_LENGTH_EXT];
  491. unsigned short mapindex;
  492. short x = 0, y = 0;
  493. int16 m = -1;
  494. nullpo_retr(-1, sd);
  495. memset(map_name, '\0', sizeof(map_name));
  496. if (!message || !*message ||
  497. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  498. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  499. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  500. return -1;
  501. }
  502. mapindex = mapindex_name2idx(map_name, nullptr);
  503. if (mapindex)
  504. m = map_mapindex2mapid(mapindex);
  505. if (m < 0) { // m < 0 means on different server! [Kevin]
  506. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  507. if (battle_config.warp_suggestions_enabled)
  508. warp_get_suggestions(sd, map_name);
  509. return -1;
  510. }
  511. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  512. { //This is to prevent the pc_setpos call from printing an error.
  513. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  514. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  515. x = y = 0; //Invalid cell, use random spot.
  516. }
  517. if ((map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, sd->group_level)) {
  518. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  519. return -1;
  520. }
  521. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  522. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  523. return -1;
  524. }
  525. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  526. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  527. return -1;
  528. }
  529. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  530. return 0;
  531. }
  532. /*==========================================
  533. * Displays where a character is. Corrected version by Silent. [Skotlex]
  534. *------------------------------------------*/
  535. ACMD_FUNC(where)
  536. {
  537. struct map_session_data* pl_sd;
  538. nullpo_retr(-1, sd);
  539. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  540. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  541. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  542. return -1;
  543. }
  544. pl_sd = map_nick2sd(atcmd_player_name,true);
  545. if (pl_sd == NULL ||
  546. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  547. (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))
  548. ) {
  549. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  550. return -1;
  551. }
  552. 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);
  553. clif_displaymessage(fd, atcmd_output);
  554. return 0;
  555. }
  556. /*==========================================
  557. *
  558. *------------------------------------------*/
  559. ACMD_FUNC(jumpto)
  560. {
  561. struct map_session_data *pl_sd = NULL;
  562. nullpo_retr(-1, sd);
  563. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  564. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  565. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  566. return -1;
  567. }
  568. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  569. {
  570. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  571. return -1;
  572. }
  573. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  574. {
  575. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  576. return -1;
  577. }
  578. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  579. {
  580. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  581. return -1;
  582. }
  583. if( pc_isdead(sd) )
  584. {
  585. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  586. return -1;
  587. }
  588. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  589. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  590. clif_displaymessage(fd, atcmd_output);
  591. return 0;
  592. }
  593. /*==========================================
  594. *
  595. *------------------------------------------*/
  596. ACMD_FUNC(jump)
  597. {
  598. short x = 0, y = 0;
  599. nullpo_retr(-1, sd);
  600. memset(atcmd_output, '\0', sizeof(atcmd_output));
  601. sscanf(message, "%6hd %6hd", &x, &y);
  602. if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  603. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  604. return -1;
  605. }
  606. if( pc_isdead(sd) )
  607. {
  608. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  609. return -1;
  610. }
  611. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  612. { //This is to prevent the pc_setpos call from printing an error.
  613. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  614. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  615. x = y = 0; //Invalid cell, use random spot.
  616. }
  617. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  618. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  619. clif_displaymessage(fd, atcmd_output);
  620. return 0;
  621. }
  622. /*==========================================
  623. * Display list of online characters with
  624. * various info.
  625. *------------------------------------------*/
  626. ACMD_FUNC(who) {
  627. struct map_session_data *pl_sd = NULL;
  628. struct s_mapiterator *iter = NULL;
  629. char player_name[NAME_LENGTH] = "";
  630. int count = 0;
  631. int level = 0;
  632. StringBuf buf;
  633. /**
  634. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  635. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  636. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  637. */
  638. int display_type = 1;
  639. int map_id = -1;
  640. nullpo_retr(-1, sd);
  641. if (strstr(command, "map") != NULL) {
  642. char map_name[MAP_NAME_LENGTH_EXT] = "";
  643. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  644. map_id = sd->bl.m;
  645. } else {
  646. sscanf(message, "%23s", player_name);
  647. }
  648. if (strstr(command, "2") != NULL)
  649. display_type = 2;
  650. else if (strstr(command, "3") != NULL)
  651. display_type = 3;
  652. level = pc_get_group_level(sd);
  653. StringBuf_Init(&buf);
  654. iter = mapit_getallusers();
  655. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  656. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  657. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  658. || (map_id >= 0 && pl_sd->bl.m != map_id))
  659. continue;
  660. switch (display_type) {
  661. case 2: {
  662. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  663. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  664. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  665. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  666. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  667. break;
  668. }
  669. case 3: {
  670. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  671. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  672. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  673. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  674. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  675. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  676. break;
  677. }
  678. default: {
  679. struct party_data *p = party_search(pl_sd->status.party_id);
  680. struct guild *g = pl_sd->guild;
  681. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  682. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  683. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  684. if (p != NULL)
  685. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  686. if (g != NULL)
  687. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  688. break;
  689. }
  690. }
  691. clif_displaymessage(fd, StringBuf_Value(&buf));
  692. StringBuf_Clear(&buf);
  693. count++;
  694. }
  695. }
  696. mapit_free(iter);
  697. if (map_id < 0) {
  698. if (count == 0)
  699. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  700. else if (count == 1)
  701. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  702. else
  703. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  704. } else {
  705. struct map_data *mapdata = map_getmapdata(map_id);
  706. if (count == 0)
  707. StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'.
  708. else if (count == 1)
  709. StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'.
  710. else
  711. StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'.
  712. }
  713. clif_displaymessage(fd, StringBuf_Value(&buf));
  714. StringBuf_Destroy(&buf);
  715. return 0;
  716. }
  717. /*==========================================
  718. *
  719. *------------------------------------------*/
  720. ACMD_FUNC(whogm)
  721. {
  722. struct map_session_data* pl_sd;
  723. struct s_mapiterator* iter;
  724. int j, count;
  725. int level;
  726. char match_text[CHAT_SIZE_MAX];
  727. char player_name[NAME_LENGTH];
  728. struct guild *g;
  729. struct party_data *p;
  730. nullpo_retr(-1, sd);
  731. memset(atcmd_output, '\0', sizeof(atcmd_output));
  732. memset(match_text, '\0', sizeof(match_text));
  733. memset(player_name, '\0', sizeof(player_name));
  734. if (sscanf(message, "%255[^\n]", match_text) < 1)
  735. strcpy(match_text, "");
  736. for (j = 0; match_text[j]; j++)
  737. match_text[j] = TOLOWER(match_text[j]);
  738. count = 0;
  739. level = pc_get_group_level(sd);
  740. iter = mapit_getallusers();
  741. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  742. {
  743. int pl_level = pc_get_group_level(pl_sd);
  744. if (!pl_level)
  745. continue;
  746. if (match_text[0])
  747. {
  748. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  749. for (j = 0; player_name[j]; j++)
  750. player_name[j] = TOLOWER(player_name[j]);
  751. // search with no case sensitive
  752. if (strstr(player_name, match_text) == NULL)
  753. continue;
  754. }
  755. if (pl_level > level) {
  756. if (pc_isinvisible(pl_sd))
  757. continue;
  758. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  759. clif_displaymessage(fd, atcmd_output);
  760. count++;
  761. continue;
  762. }
  763. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  764. pl_sd->status.name, pl_level,
  765. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  766. clif_displaymessage(fd, atcmd_output);
  767. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  768. pl_sd->status.base_level,
  769. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  770. clif_displaymessage(fd, atcmd_output);
  771. p = party_search(pl_sd->status.party_id);
  772. g = pl_sd->guild;
  773. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  774. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  775. clif_displaymessage(fd, atcmd_output);
  776. count++;
  777. }
  778. mapit_free(iter);
  779. if (count == 0)
  780. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  781. else if (count == 1)
  782. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  783. else {
  784. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  785. clif_displaymessage(fd, atcmd_output);
  786. }
  787. return 0;
  788. }
  789. /*==========================================
  790. *
  791. *------------------------------------------*/
  792. ACMD_FUNC(save)
  793. {
  794. nullpo_retr(-1, sd);
  795. if( map_getmapdata(sd->bl.m)->instance_id ) {
  796. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  797. return 1;
  798. }
  799. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  800. if (sd->status.pet_id > 0 && sd->pd)
  801. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  802. chrif_save(sd, CSAVE_NORMAL);
  803. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  804. return 0;
  805. }
  806. /*==========================================
  807. *
  808. *------------------------------------------*/
  809. ACMD_FUNC(load)
  810. {
  811. int16 m;
  812. nullpo_retr(-1, sd);
  813. m = map_mapindex2mapid(sd->status.save_point.map);
  814. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  815. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  816. return -1;
  817. }
  818. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  819. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  820. return -1;
  821. }
  822. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  823. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  824. return 0;
  825. }
  826. /*==========================================
  827. *
  828. *------------------------------------------*/
  829. ACMD_FUNC(speed)
  830. {
  831. short speed;
  832. nullpo_retr(-1, sd);
  833. memset(atcmd_output, '\0', sizeof(atcmd_output));
  834. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  835. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  836. clif_displaymessage(fd, atcmd_output);
  837. return -1;
  838. }
  839. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  840. if (speed < 0)
  841. sd->base_status.speed = DEFAULT_WALK_SPEED;
  842. else
  843. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  844. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  845. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  846. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  847. } else
  848. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  849. status_calc_bl(&sd->bl, SCB_SPEED);
  850. return 0;
  851. }
  852. /*==========================================
  853. *
  854. *------------------------------------------*/
  855. ACMD_FUNC(storage)
  856. {
  857. nullpo_retr(-1, sd);
  858. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  859. return -1;
  860. if (storage_storageopen(sd) == 1)
  861. { //Already open.
  862. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  863. return -1;
  864. }
  865. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  866. return 0;
  867. }
  868. /*==========================================
  869. *
  870. *------------------------------------------*/
  871. ACMD_FUNC(guildstorage)
  872. {
  873. nullpo_retr(-1, sd);
  874. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  875. return -1;
  876. switch (storage_guild_storageopen(sd)) {
  877. case GSTORAGE_OPEN:
  878. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  879. break;
  880. case GSTORAGE_STORAGE_ALREADY_OPEN:
  881. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  882. return -1;
  883. case GSTORAGE_ALREADY_OPEN:
  884. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  885. return -1;
  886. case GSTORAGE_NO_GUILD:
  887. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  888. return -1;
  889. case GSTORAGE_NO_STORAGE:
  890. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  891. return -1;
  892. case GSTORAGE_NO_PERMISSION:
  893. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  894. return -1;
  895. }
  896. return 0;
  897. }
  898. /*==========================================
  899. *
  900. *------------------------------------------*/
  901. ACMD_FUNC(option)
  902. {
  903. int param1 = 0, param2 = 0, param3 = 0;
  904. nullpo_retr(-1, sd);
  905. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  906. {// failed to match the parameters so inform the user of the options
  907. const char* text;
  908. // attempt to find the setting information for this command
  909. text = atcommand_help_string( command );
  910. // notify the user of the requirement to enter an option
  911. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  912. if( text )
  913. {// send the help text associated with this command
  914. clif_displaymessage( fd, text );
  915. }
  916. return -1;
  917. }
  918. sd->sc.opt1 = param1;
  919. sd->sc.opt2 = param2;
  920. pc_setoption(sd, param3);
  921. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  922. return 0;
  923. }
  924. /*==========================================
  925. *
  926. *------------------------------------------*/
  927. ACMD_FUNC(hide)
  928. {
  929. nullpo_retr(-1, sd);
  930. if (pc_isinvisible(sd)) {
  931. sd->sc.option &= ~OPTION_INVISIBLE;
  932. if (sd->disguise)
  933. status_set_viewdata(&sd->bl, sd->disguise);
  934. else
  935. status_set_viewdata(&sd->bl, sd->status.class_);
  936. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  937. // increment the number of pvp players on the map
  938. map_getmapdata(sd->bl.m)->users_pvp++;
  939. if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) )
  940. {// register the player for ranking calculations
  941. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  942. }
  943. //bugreport:2266
  944. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  945. } else {
  946. sd->sc.option |= OPTION_INVISIBLE;
  947. sd->vd.class_ = JT_INVISIBLE;
  948. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  949. // decrement the number of pvp players on the map
  950. map_getmapdata(sd->bl.m)->users_pvp--;
  951. if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER )
  952. {// unregister the player for ranking
  953. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  954. sd->pvp_timer = INVALID_TIMER;
  955. }
  956. }
  957. clif_changeoption(&sd->bl);
  958. return 0;
  959. }
  960. /*==========================================
  961. * Changes a character's class
  962. *------------------------------------------*/
  963. ACMD_FUNC(jobchange)
  964. {
  965. int job = 0, upper = 0;
  966. const char* text;
  967. nullpo_retr(-1, sd);
  968. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  969. int i;
  970. bool found = false;
  971. upper = 0;
  972. // Normal Jobs
  973. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  974. if (strncmpi(message, job_name(i), 16) == 0) {
  975. job = i;
  976. found = true;
  977. }
  978. }
  979. // High Jobs, Babys and Third
  980. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  981. if (strncmpi(message, job_name(i), 16) == 0) {
  982. job = i;
  983. found = true;
  984. }
  985. }
  986. if (!found) {
  987. text = atcommand_help_string(command);
  988. if (text)
  989. clif_displaymessage(fd, text);
  990. return -1;
  991. }
  992. }
  993. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  994. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  995. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE_KNIGHT2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  996. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2)
  997. { // Deny direct transformation into dummy jobs
  998. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  999. return 0;
  1000. }
  1001. if (pcdb_checkid(job))
  1002. {
  1003. if (pc_jobchange(sd, job, upper))
  1004. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  1005. else {
  1006. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  1007. return -1;
  1008. }
  1009. } else {
  1010. text = atcommand_help_string(command);
  1011. if (text)
  1012. clif_displaymessage(fd, text);
  1013. return -1;
  1014. }
  1015. return 0;
  1016. }
  1017. /*==========================================
  1018. *
  1019. *------------------------------------------*/
  1020. ACMD_FUNC(kill)
  1021. {
  1022. nullpo_retr(-1, sd);
  1023. status_kill(&sd->bl);
  1024. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1025. if (fd != sd->fd)
  1026. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1027. return 0;
  1028. }
  1029. /*==========================================
  1030. *
  1031. *------------------------------------------*/
  1032. ACMD_FUNC(alive)
  1033. {
  1034. nullpo_retr(-1, sd);
  1035. if (!status_revive(&sd->bl, 100, 100))
  1036. {
  1037. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  1038. return -1;
  1039. }
  1040. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1041. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1042. return 0;
  1043. }
  1044. /*==========================================
  1045. * +kamic [LuzZza]
  1046. *------------------------------------------*/
  1047. ACMD_FUNC(kami)
  1048. {
  1049. unsigned long color=0;
  1050. nullpo_retr(-1, sd);
  1051. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1052. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1053. if (!message || !*message) {
  1054. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1055. return -1;
  1056. }
  1057. sscanf(message, "%255[^\n]", atcmd_output);
  1058. if (strstr(command, "l") != NULL)
  1059. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  1060. else
  1061. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  1062. } else {
  1063. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1064. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1065. return -1;
  1066. }
  1067. if(color > 0xFFFFFF) {
  1068. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1069. return -1;
  1070. }
  1071. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1072. }
  1073. return 0;
  1074. }
  1075. /*==========================================
  1076. *
  1077. *------------------------------------------*/
  1078. ACMD_FUNC(heal)
  1079. {
  1080. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1081. nullpo_retr(-1, sd);
  1082. sscanf(message, "%11d %11d", &hp, &sp);
  1083. // some overflow checks
  1084. if( hp == INT_MIN ) hp++;
  1085. if( sp == INT_MIN ) sp++;
  1086. if ( hp == 0 && sp == 0 ) {
  1087. if (!status_percent_heal(&sd->bl, 100, 100))
  1088. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1089. else
  1090. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1091. return 0;
  1092. }
  1093. if ( hp > 0 && sp >= 0 ) {
  1094. if(!status_heal(&sd->bl, hp, sp, 0))
  1095. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1096. else
  1097. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1098. return 0;
  1099. }
  1100. if ( hp < 0 && sp <= 0 ) {
  1101. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0, 0);
  1102. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1103. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1104. return 0;
  1105. }
  1106. //Opposing signs.
  1107. if ( hp ) {
  1108. if (hp > 0)
  1109. status_heal(&sd->bl, hp, 0, 0);
  1110. else {
  1111. status_damage(NULL, &sd->bl, -hp, 0, 0, 0, 0);
  1112. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1113. }
  1114. }
  1115. if ( sp ) {
  1116. if (sp > 0)
  1117. status_heal(&sd->bl, 0, sp, 0);
  1118. else
  1119. status_damage(NULL, &sd->bl, 0, -sp, 0, 0, 0);
  1120. }
  1121. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1122. return 0;
  1123. }
  1124. /*==========================================
  1125. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1126. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1127. *------------------------------------------*/
  1128. ACMD_FUNC(item)
  1129. {
  1130. char item_name[100];
  1131. int number = 0, bound = BOUND_NONE;
  1132. char flag = 0;
  1133. struct item item_tmp;
  1134. struct item_data *item_data[10];
  1135. int get_count, i, j=0;
  1136. char *itemlist;
  1137. nullpo_retr(-1, sd);
  1138. memset(item_name, '\0', sizeof(item_name));
  1139. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1140. if (!strcmpi(parent_cmd,"itembound")) {
  1141. if (!message || !*message || (
  1142. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1143. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1144. {
  1145. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1146. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1147. return -1;
  1148. }
  1149. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1150. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1151. return -1;
  1152. }
  1153. } else if (!message || !*message || (
  1154. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1155. sscanf(message, "%99s %11d", item_name, &number) < 1
  1156. )) {
  1157. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1158. return -1;
  1159. }
  1160. itemlist = strtok(item_name, ":");
  1161. while (itemlist != NULL && j<10) {
  1162. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1163. (item_data[j] = itemdb_exists( strtoul( itemlist, nullptr, 10 ) ) ) == NULL){
  1164. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1165. return -1;
  1166. }
  1167. itemlist = strtok(NULL, ":"); //next itemline
  1168. j++;
  1169. }
  1170. if (number <= 0)
  1171. number = 1;
  1172. get_count = number;
  1173. for(j--; j>=0; j--){ //produce items in list
  1174. t_itemid item_id = item_data[j]->nameid;
  1175. //Check if it's stackable.
  1176. if (!itemdb_isstackable2(item_data[j]))
  1177. get_count = 1;
  1178. for (i = 0; i < number; i += get_count) {
  1179. // if not pet egg
  1180. if (!pet_create_egg(sd, item_id)) {
  1181. memset(&item_tmp, 0, sizeof(item_tmp));
  1182. item_tmp.nameid = item_id;
  1183. item_tmp.identify = 1;
  1184. item_tmp.bound = bound;
  1185. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1186. clif_additem(sd, 0, 0, flag);
  1187. }
  1188. }
  1189. }
  1190. if (flag == 0)
  1191. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1192. return 0;
  1193. }
  1194. /*==========================================
  1195. *
  1196. *------------------------------------------*/
  1197. ACMD_FUNC(item2)
  1198. {
  1199. struct item item_tmp;
  1200. struct item_data *item_data;
  1201. char item_name[100];
  1202. t_itemid item_id;
  1203. int number = 0, bound = BOUND_NONE;
  1204. int identify = 0, refine = 0, attr = 0;
  1205. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1206. nullpo_retr(-1, sd);
  1207. memset(item_name, '\0', sizeof(item_name));
  1208. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1209. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1210. if (!message || !*message || (
  1211. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1212. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1213. {
  1214. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1215. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1216. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1217. return -1;
  1218. }
  1219. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1220. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1221. return -1;
  1222. }
  1223. } else if ( !message || !*message || (
  1224. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1225. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1226. )) {
  1227. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1228. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1229. return -1;
  1230. }
  1231. if (number <= 0)
  1232. number = 1;
  1233. item_id = 0;
  1234. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1235. (item_data = itemdb_exists(strtoul(item_name, nullptr, 10))) != NULL)
  1236. item_id = item_data->nameid;
  1237. if (item_id > 500) {
  1238. int loop, get_count, i;
  1239. char flag = 0;
  1240. //Check if it's stackable.
  1241. if(!itemdb_isstackable2(item_data)){
  1242. loop = number;
  1243. get_count = 1;
  1244. }else{
  1245. loop = 1;
  1246. get_count = number;
  1247. }
  1248. if( itemdb_isequip2(item_data ) ){
  1249. refine = cap_value( refine, 0, MAX_REFINE );
  1250. }else{
  1251. // All other items cannot be refined and are always identified
  1252. identify = 1;
  1253. refine = attr = 0;
  1254. }
  1255. for (i = 0; i < loop; i++) {
  1256. // if not pet egg
  1257. if (!pet_create_egg(sd, item_id)) {
  1258. memset(&item_tmp, 0, sizeof(item_tmp));
  1259. item_tmp.nameid = item_id;
  1260. item_tmp.identify = identify;
  1261. item_tmp.refine = refine;
  1262. item_tmp.attribute = attr;
  1263. item_tmp.card[0] = c1;
  1264. item_tmp.card[1] = c2;
  1265. item_tmp.card[2] = c3;
  1266. item_tmp.card[3] = c4;
  1267. item_tmp.bound = bound;
  1268. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1269. clif_additem(sd, 0, 0, flag);
  1270. }
  1271. }
  1272. if (flag == 0)
  1273. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1274. } else {
  1275. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1276. return -1;
  1277. }
  1278. return 0;
  1279. }
  1280. /*==========================================
  1281. *
  1282. *------------------------------------------*/
  1283. ACMD_FUNC(itemreset)
  1284. {
  1285. int i;
  1286. nullpo_retr(-1, sd);
  1287. for (i = 0; i < MAX_INVENTORY; i++) {
  1288. if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0 && !itemdb_ishatched_egg(&sd->inventory.u.items_inventory[i])) {
  1289. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1290. }
  1291. }
  1292. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1293. return 0;
  1294. }
  1295. /*==========================================
  1296. * Atcommand @lvlup
  1297. *------------------------------------------*/
  1298. ACMD_FUNC(baselevelup)
  1299. {
  1300. int level=0, i=0, status_point=0;
  1301. nullpo_retr(-1, sd);
  1302. level = atoi(message);
  1303. if (!message || !*message || !level) {
  1304. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1305. return -1;
  1306. }
  1307. if (level > 0) {
  1308. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1309. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1310. return -1;
  1311. } // End Addition
  1312. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1313. level = pc_maxbaselv(sd) - sd->status.base_level;
  1314. for (i = 0; i < level; i++)
  1315. status_point += pc_gets_status_point(sd->status.base_level + i);
  1316. sd->status.status_point += status_point;
  1317. sd->status.base_level += (unsigned int)level;
  1318. status_calc_pc(sd, SCO_FORCE);
  1319. status_percent_heal(&sd->bl, 100, 100);
  1320. clif_misceffect(&sd->bl, 0);
  1321. for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) {
  1322. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j);
  1323. achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_);
  1324. }
  1325. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1326. } else {
  1327. if (sd->status.base_level == 1) {
  1328. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1329. return -1;
  1330. }
  1331. level*=-1;
  1332. if ((unsigned int)level >= sd->status.base_level)
  1333. level = sd->status.base_level-1;
  1334. for (i = 0; i > -level; i--)
  1335. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1336. if (sd->status.status_point < status_point)
  1337. pc_resetstate(sd);
  1338. if (sd->status.status_point < status_point)
  1339. sd->status.status_point = 0;
  1340. else
  1341. sd->status.status_point -= status_point;
  1342. sd->status.base_level -= (unsigned int)level;
  1343. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1344. status_calc_pc(sd, SCO_FORCE);
  1345. level*=-1;
  1346. }
  1347. sd->status.base_exp = 0;
  1348. clif_updatestatus(sd, SP_STATUSPOINT);
  1349. clif_updatestatus(sd, SP_BASELEVEL);
  1350. clif_updatestatus(sd, SP_BASEEXP);
  1351. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1352. pc_baselevelchanged(sd);
  1353. if(sd->status.party_id)
  1354. party_send_levelup(sd);
  1355. if( level > 0 && battle_config.atcommand_levelup_events )
  1356. npc_script_event(sd,NPCE_BASELVUP);
  1357. return 0;
  1358. }
  1359. /*==========================================
  1360. *
  1361. *------------------------------------------*/
  1362. ACMD_FUNC(joblevelup)
  1363. {
  1364. int level=0;
  1365. nullpo_retr(-1, sd);
  1366. level = atoi(message);
  1367. if (!message || !*message || !level) {
  1368. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1369. return -1;
  1370. }
  1371. if (level > 0) {
  1372. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1373. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1374. return -1;
  1375. }
  1376. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1377. level = pc_maxjoblv(sd) - sd->status.job_level;
  1378. sd->status.job_level += (unsigned int)level;
  1379. sd->status.skill_point += level;
  1380. clif_misceffect(&sd->bl, 1);
  1381. for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++)
  1382. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i);
  1383. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1384. } else {
  1385. if (sd->status.job_level == 1) {
  1386. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1387. return -1;
  1388. }
  1389. level *=-1;
  1390. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1391. level = sd->status.job_level-1;
  1392. sd->status.job_level -= (unsigned int)level;
  1393. if (sd->status.skill_point < level)
  1394. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1395. if (sd->status.skill_point < level)
  1396. sd->status.skill_point = 0;
  1397. else
  1398. sd->status.skill_point -= level;
  1399. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1400. level *=-1;
  1401. }
  1402. sd->status.job_exp = 0;
  1403. clif_updatestatus(sd, SP_JOBLEVEL);
  1404. clif_updatestatus(sd, SP_JOBEXP);
  1405. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1406. clif_updatestatus(sd, SP_SKILLPOINT);
  1407. status_calc_pc(sd, SCO_FORCE);
  1408. if( level > 0 && battle_config.atcommand_levelup_events )
  1409. npc_script_event(sd,NPCE_JOBLVUP);
  1410. return 0;
  1411. }
  1412. /*==========================================
  1413. * @help
  1414. *------------------------------------------*/
  1415. ACMD_FUNC(help){
  1416. const char *command_name = nullptr;
  1417. nullpo_retr(-1, sd);
  1418. if (!message || !*message) {
  1419. command_name = "help"; // If no command_name specified, display help for @help.
  1420. } else {
  1421. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1422. ++message;
  1423. command_name = atcommand_alias_db.checkAlias(message);
  1424. }
  1425. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1426. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1427. clif_displaymessage(fd, atcmd_output);
  1428. atcommand_get_suggestions(sd, command_name, true);
  1429. return -1;
  1430. }
  1431. // attempt to find the first default help command
  1432. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_name );
  1433. const char* text = info != nullptr ? info->help.c_str() : nullptr;
  1434. if( text == nullptr ){
  1435. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1436. clif_displaymessage(fd, atcmd_output);
  1437. atcommand_get_suggestions(sd, command_name, true);
  1438. return -1;
  1439. }
  1440. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1441. clif_displaymessage(fd, atcmd_output);
  1442. { // Display aliases
  1443. StringBuf buf;
  1444. bool has_aliases = false;
  1445. StringBuf_Init(&buf);
  1446. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1447. for( const std::string& alias : info->aliases ){
  1448. StringBuf_Printf( &buf, " %s", alias.c_str() );
  1449. has_aliases = true;
  1450. }
  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. /*==========================================
  1460. *
  1461. *------------------------------------------*/
  1462. ACMD_FUNC(pvpoff)
  1463. {
  1464. nullpo_retr(-1, sd);
  1465. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1466. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1467. return -1;
  1468. }
  1469. map_setmapflag(sd->bl.m, MF_PVP, false);
  1470. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1471. return 0;
  1472. }
  1473. /*==========================================
  1474. *
  1475. *------------------------------------------*/
  1476. ACMD_FUNC(pvpon)
  1477. {
  1478. nullpo_retr(-1, sd);
  1479. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1480. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1481. return -1;
  1482. }
  1483. map_setmapflag(sd->bl.m, MF_PVP, true);
  1484. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1485. return 0;
  1486. }
  1487. /*==========================================
  1488. *
  1489. *------------------------------------------*/
  1490. ACMD_FUNC(gvgoff)
  1491. {
  1492. nullpo_retr(-1, sd);
  1493. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1494. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1495. return -1;
  1496. }
  1497. map_setmapflag(sd->bl.m, MF_GVG, false);
  1498. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1499. return 0;
  1500. }
  1501. /*==========================================
  1502. *
  1503. *------------------------------------------*/
  1504. ACMD_FUNC(gvgon)
  1505. {
  1506. nullpo_retr(-1, sd);
  1507. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1508. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1509. return -1;
  1510. }
  1511. map_setmapflag(sd->bl.m, MF_GVG, true);
  1512. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1513. return 0;
  1514. }
  1515. /*==========================================
  1516. *
  1517. *------------------------------------------*/
  1518. ACMD_FUNC(model)
  1519. {
  1520. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1521. nullpo_retr(-1, sd);
  1522. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1523. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1524. sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1525. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1526. clif_displaymessage(fd, atcmd_output);
  1527. return -1;
  1528. }
  1529. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1530. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1531. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1532. pc_changelook(sd, LOOK_HAIR, hair_style);
  1533. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1534. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1535. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1536. } else {
  1537. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1538. return -1;
  1539. }
  1540. return 0;
  1541. }
  1542. /*==========================================
  1543. * @bodystyle [Rytech]
  1544. *------------------------------------------*/
  1545. ACMD_FUNC(bodystyle)
  1546. {
  1547. int body_style = 0;
  1548. nullpo_retr(-1, sd);
  1549. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1550. if (!(sd->class_ & JOBL_THIRD) || (sd->class_ & MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E || (sd->class_ & MAPID_THIRDMASK) == MAPID_STAR_EMPEROR || (sd->class_ & MAPID_THIRDMASK) == MAPID_SOUL_REAPER) {
  1551. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1552. return -1;
  1553. }
  1554. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1555. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1556. clif_displaymessage(fd, atcmd_output);
  1557. return -1;
  1558. }
  1559. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1560. pc_changelook(sd, LOOK_BODY2, body_style);
  1561. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1562. } else {
  1563. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1564. return -1;
  1565. }
  1566. return 0;
  1567. }
  1568. /*==========================================
  1569. * @dye && @ccolor
  1570. *------------------------------------------*/
  1571. ACMD_FUNC(dye)
  1572. {
  1573. int cloth_color = 0;
  1574. nullpo_retr(-1, sd);
  1575. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1576. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1577. sprintf(atcmd_output, msg_txt(sd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1578. clif_displaymessage(fd, atcmd_output);
  1579. return -1;
  1580. }
  1581. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1582. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1583. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1584. } else {
  1585. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1586. return -1;
  1587. }
  1588. return 0;
  1589. }
  1590. /*==========================================
  1591. * @hairstyle && @hstyle
  1592. *------------------------------------------*/
  1593. ACMD_FUNC(hair_style)
  1594. {
  1595. int hair_style = 0;
  1596. nullpo_retr(-1, sd);
  1597. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1598. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1599. sprintf(atcmd_output, msg_txt(sd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1600. clif_displaymessage(fd, atcmd_output);
  1601. return -1;
  1602. }
  1603. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1604. pc_changelook(sd, LOOK_HAIR, hair_style);
  1605. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1606. } else {
  1607. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1608. return -1;
  1609. }
  1610. return 0;
  1611. }
  1612. /*==========================================
  1613. * @haircolor && @hcolor
  1614. *------------------------------------------*/
  1615. ACMD_FUNC(hair_color)
  1616. {
  1617. int hair_color = 0;
  1618. nullpo_retr(-1, sd);
  1619. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1620. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1621. sprintf(atcmd_output, msg_txt(sd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1622. clif_displaymessage(fd, atcmd_output);
  1623. return -1;
  1624. }
  1625. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1626. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1627. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1628. } else {
  1629. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1630. return -1;
  1631. }
  1632. return 0;
  1633. }
  1634. /*==========================================
  1635. * @go [city_number or city_name] - Updated by Harbin
  1636. *------------------------------------------*/
  1637. ACMD_FUNC(go)
  1638. {
  1639. int i;
  1640. int town;
  1641. char map_name[MAP_NAME_LENGTH];
  1642. const struct {
  1643. char map[MAP_NAME_LENGTH];
  1644. int x, y;
  1645. } data[] = {
  1646. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1647. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1648. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1649. { MAP_PAYON, 162, 233 }, // 3=Payon
  1650. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1651. #ifdef RENEWAL
  1652. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1653. #else
  1654. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1655. #endif
  1656. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1657. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1658. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1659. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1660. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1661. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1662. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1663. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1664. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1665. #ifdef RENEWAL
  1666. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1667. #else
  1668. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1669. #endif
  1670. { MAP_JAIL, 23, 61 }, // 16=Prison
  1671. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1672. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1673. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1674. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1675. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1676. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1677. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1678. { MAP_VEINS, 216, 123 }, // 24=Veins
  1679. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1680. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1681. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1682. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1683. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1684. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1685. { MAP_MORA, 44, 151 }, // 31=Mora
  1686. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1687. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1688. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1689. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1690. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1691. };
  1692. nullpo_retr(-1, sd);
  1693. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1694. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1695. return 0;
  1696. }
  1697. memset(map_name, '\0', sizeof(map_name));
  1698. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1699. // get the number
  1700. town = atoi(message);
  1701. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1702. {// no value matched so send the list of locations
  1703. const char* text;
  1704. // attempt to find the text help string
  1705. text = atcommand_help_string( command );
  1706. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1707. if( text )
  1708. {// send the text to the client
  1709. clif_displaymessage( fd, text );
  1710. }
  1711. return -1;
  1712. }
  1713. // get possible name of the city
  1714. map_name[MAP_NAME_LENGTH-1] = '\0';
  1715. for (i = 0; map_name[i]; i++)
  1716. map_name[i] = TOLOWER(map_name[i]);
  1717. // try to identify the map name
  1718. if (strncmp(map_name, "prontera", 3) == 0) {
  1719. town = 0;
  1720. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1721. strncmp(map_name, "morroc", 4) == 0) {
  1722. town = 1;
  1723. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1724. town = 2;
  1725. } else if (strncmp(map_name, "payon", 3) == 0) {
  1726. town = 3;
  1727. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1728. town = 4;
  1729. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1730. town = 5;
  1731. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1732. town = 6;
  1733. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1734. strcmp(map_name, "christmas") == 0 ||
  1735. strncmp(map_name, "xmas", 3) == 0 ||
  1736. strncmp(map_name, "x-mas", 3) == 0) {
  1737. town = 7;
  1738. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1739. town = 8;
  1740. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1741. strncmp(map_name, "yuno", 3) == 0) {
  1742. town = 9;
  1743. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1744. town = 10;
  1745. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1746. strncmp(map_name, "gonryun", 3) == 0) {
  1747. town = 11;
  1748. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1749. town = 12;
  1750. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1751. town = 13;
  1752. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1753. town = 14;
  1754. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1755. strncmp(map_name, "startpoint", 3) == 0 ||
  1756. strncmp(map_name, "beginning", 3) == 0) {
  1757. town = 15;
  1758. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1759. strncmp(map_name, "prison", 3) == 0 ||
  1760. strncmp(map_name, "jail", 3) == 0) {
  1761. town = 16;
  1762. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1763. town = 17;
  1764. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1765. town = 18;
  1766. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1767. town = 19;
  1768. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1769. town = 20;
  1770. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1771. town = 21;
  1772. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1773. town = 22;
  1774. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1775. town = 23;
  1776. } else if (strncmp(map_name, "veins", 3) == 0) {
  1777. town = 24;
  1778. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1779. town = 25;
  1780. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1781. town = 26;
  1782. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1783. town = 27;
  1784. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1785. town = 28;
  1786. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1787. town = 29;
  1788. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1789. town = 30;
  1790. } else if (strcmp(map_name, "mora") == 0) {
  1791. town = 31;
  1792. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1793. town = 32;
  1794. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1795. town = 33;
  1796. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1797. town = 34;
  1798. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1799. town = 35;
  1800. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1801. town = 36;
  1802. }
  1803. if (town >= 0 && town < ARRAYLENGTH(data))
  1804. {
  1805. int16 m = map_mapname2mapid(data[town].map);
  1806. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1807. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1808. return -1;
  1809. }
  1810. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1811. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1812. return -1;
  1813. }
  1814. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1815. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1816. } else {
  1817. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1818. return -1;
  1819. }
  1820. } else { // if you arrive here, you have an error in town variable when reading of names
  1821. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1822. return -1;
  1823. }
  1824. return 0;
  1825. }
  1826. /*==========================================
  1827. *
  1828. *------------------------------------------*/
  1829. ACMD_FUNC(monster)
  1830. {
  1831. char name[NAME_LENGTH];
  1832. char monster[NAME_LENGTH];
  1833. char eventname[EVENT_NAME_LENGTH] = "";
  1834. int mob_id;
  1835. int number = 0;
  1836. int count;
  1837. int i, range;
  1838. short mx, my;
  1839. unsigned int size;
  1840. nullpo_retr(-1, sd);
  1841. memset(name, '\0', sizeof(name));
  1842. memset(monster, '\0', sizeof(monster));
  1843. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1844. if (!message || !*message) {
  1845. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1846. return -1;
  1847. }
  1848. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1849. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1850. //All data can be left as it is.
  1851. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1852. //Here, it is possible name was not given and we are using monster for it.
  1853. if (count < 3) //Blank mob's name.
  1854. name[0] = '\0';
  1855. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1856. //All data can be left as it is.
  1857. } else if (sscanf(message, "%23s", monster) > 0) {
  1858. //As before, name may be already filled.
  1859. name[0] = '\0';
  1860. } else {
  1861. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1862. return -1;
  1863. }
  1864. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1865. mob_id = mobdb_checkid(atoi(monster));
  1866. if (mob_id == 0) {
  1867. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1868. return -1;
  1869. }
  1870. if (mob_id == MOBID_EMPERIUM) {
  1871. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1872. return -1;
  1873. }
  1874. if (number <= 0)
  1875. number = 1;
  1876. if( !name[0] )
  1877. strcpy(name, "--ja--");
  1878. // 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
  1879. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1880. number = battle_config.atc_spawn_quantity_limit;
  1881. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1882. if (strcmp(parent_cmd, "monstersmall") == 0)
  1883. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1884. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1885. size = SZ_BIG;
  1886. else
  1887. size = SZ_SMALL;
  1888. if (battle_config.etc_log)
  1889. 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);
  1890. count = 0;
  1891. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1892. for (i = 0; i < number; i++) {
  1893. int k;
  1894. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1895. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1896. if(k) {
  1897. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1898. count ++;
  1899. }
  1900. }
  1901. if (count != 0)
  1902. if (number == count)
  1903. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1904. else {
  1905. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1906. clif_displaymessage(fd, atcmd_output);
  1907. }
  1908. else {
  1909. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1910. return -1;
  1911. }
  1912. return 0;
  1913. }
  1914. /*==========================================
  1915. *
  1916. *------------------------------------------*/
  1917. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1918. {
  1919. struct mob_data *md;
  1920. int flag;
  1921. nullpo_ret(md=(struct mob_data *)bl);
  1922. flag = va_arg(ap, int);
  1923. if (md->guardian_data)
  1924. return 0; //Do not touch WoE mobs!
  1925. if (flag)
  1926. status_zap(bl,md->status.hp, 0);
  1927. else
  1928. status_kill(bl);
  1929. return 1;
  1930. }
  1931. ACMD_FUNC(killmonster)
  1932. {
  1933. int map_id, drop_flag;
  1934. char map_name[MAP_NAME_LENGTH_EXT];
  1935. nullpo_retr(-1, sd);
  1936. memset(map_name, '\0', sizeof(map_name));
  1937. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1938. map_id = sd->bl.m;
  1939. else {
  1940. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1941. map_id = sd->bl.m;
  1942. }
  1943. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1944. drop_flag = strcmpi(parent_cmd, "killmonster2");
  1945. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1946. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1947. return 0;
  1948. }
  1949. /*==========================================
  1950. *
  1951. *------------------------------------------*/
  1952. ACMD_FUNC(refine)
  1953. {
  1954. int j, position = 0, refine = 0, current_position, final_refine;
  1955. int count;
  1956. nullpo_retr(-1, sd);
  1957. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1958. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1959. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1960. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1961. clif_displaymessage(fd, atcmd_output);
  1962. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1963. clif_displaymessage(fd, atcmd_output);
  1964. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1965. clif_displaymessage(fd, atcmd_output);
  1966. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1967. clif_displaymessage(fd, atcmd_output);
  1968. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1969. clif_displaymessage(fd, atcmd_output);
  1970. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1971. clif_displaymessage(fd, atcmd_output);
  1972. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1973. clif_displaymessage(fd, atcmd_output);
  1974. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1975. clif_displaymessage(fd, atcmd_output);
  1976. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1977. clif_displaymessage(fd, atcmd_output);
  1978. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1979. clif_displaymessage(fd, atcmd_output);
  1980. return -1;
  1981. }
  1982. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1983. count = 0;
  1984. for (j = 0; j < EQI_MAX; j++) {
  1985. int i;
  1986. if ((i = sd->equip_index[j]) < 0)
  1987. continue;
  1988. if(j == EQI_AMMO)
  1989. continue;
  1990. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1991. continue;
  1992. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  1993. continue;
  1994. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  1995. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  1996. sd->inventory.u.items_inventory[i].refine = final_refine;
  1997. current_position = sd->inventory.u.items_inventory[i].equip;
  1998. pc_unequipitem(sd, i, 3);
  1999. clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine);
  2000. clif_delitem(sd, i, 1, 3);
  2001. clif_additem(sd, i, 1, 0);
  2002. pc_equipitem(sd, i, current_position);
  2003. clif_misceffect(&sd->bl, 3);
  2004. achievement_update_objective(sd, AG_REFINE_SUCCESS, 2, sd->inventory_data[i]->wlv, sd->inventory.u.items_inventory[i].refine);
  2005. count++;
  2006. }
  2007. }
  2008. if (count == 0)
  2009. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2010. else if (count == 1)
  2011. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2012. else {
  2013. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2014. clif_displaymessage(fd, atcmd_output);
  2015. }
  2016. return 0;
  2017. }
  2018. /*==========================================
  2019. *
  2020. *------------------------------------------*/
  2021. ACMD_FUNC(produce)
  2022. {
  2023. char item_name[100];
  2024. t_itemid item_id;
  2025. int attribute = 0, star = 0;
  2026. struct item_data *item_data;
  2027. struct item tmp_item;
  2028. nullpo_retr(-1, sd);
  2029. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2030. memset(item_name, '\0', sizeof(item_name));
  2031. if (!message || !*message || (
  2032. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2033. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2034. )) {
  2035. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2036. return -1;
  2037. }
  2038. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  2039. (item_data = itemdb_exists( strtoul( item_name, nullptr, 10 ) ) ) == NULL ) {
  2040. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2041. return -1;
  2042. }
  2043. item_id = item_data->nameid;
  2044. if (itemdb_isequip2(item_data)) {
  2045. char flag = 0;
  2046. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2047. attribute = ATTRIBUTE_NORMAL;
  2048. if (star < MIN_STAR || star > MAX_STAR)
  2049. star = 0;
  2050. memset(&tmp_item, 0, sizeof tmp_item);
  2051. tmp_item.nameid = item_id;
  2052. tmp_item.amount = 1;
  2053. tmp_item.identify = 1;
  2054. tmp_item.card[0] = CARD0_FORGE;
  2055. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2056. ((star*5) << 8) + attribute:0;
  2057. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2058. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2059. clif_produceeffect(sd, 0, item_id);
  2060. clif_misceffect(&sd->bl, 3);
  2061. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2062. clif_additem(sd, 0, 0, flag);
  2063. } else {
  2064. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name.c_str()); // The item (%u: '%s') is not equipable.
  2065. clif_displaymessage(fd, atcmd_output);
  2066. return -1;
  2067. }
  2068. return 0;
  2069. }
  2070. /*==========================================
  2071. *
  2072. *------------------------------------------*/
  2073. ACMD_FUNC(memo)
  2074. {
  2075. int position = 0;
  2076. nullpo_retr(-1, sd);
  2077. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2078. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2079. {
  2080. int i;
  2081. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2082. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2083. {
  2084. if( sd->status.memo_point[i].map )
  2085. 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);
  2086. else
  2087. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2088. clif_displaymessage(sd->fd, atcmd_output);
  2089. }
  2090. return 0;
  2091. }
  2092. if( position < 0 || position >= MAX_MEMOPOINTS )
  2093. {
  2094. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2095. clif_displaymessage(fd, atcmd_output);
  2096. return -1;
  2097. }
  2098. return !pc_memo( sd, position );
  2099. }
  2100. /*==========================================
  2101. *
  2102. *------------------------------------------*/
  2103. ACMD_FUNC(gat)
  2104. {
  2105. int y;
  2106. nullpo_retr(-1, sd);
  2107. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2108. for (y = 2; y >= -2; y--) {
  2109. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2110. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2111. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2112. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2113. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2114. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2115. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2116. clif_displaymessage(fd, atcmd_output);
  2117. }
  2118. return 0;
  2119. }
  2120. /*==========================================
  2121. *
  2122. *------------------------------------------*/
  2123. ACMD_FUNC(displaystatus)
  2124. {
  2125. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2126. nullpo_retr(-1, sd);
  2127. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2128. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2129. return -1;
  2130. }
  2131. if (i < 2) flag = 1;
  2132. if (i < 3) tick = 0;
  2133. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2134. return 0;
  2135. }
  2136. /*==========================================
  2137. * @stpoint (Rewritten by [Yor])
  2138. *------------------------------------------*/
  2139. ACMD_FUNC(statuspoint)
  2140. {
  2141. int point;
  2142. unsigned int new_status_point;
  2143. if (!message || !*message || (point = atoi(message)) == 0) {
  2144. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2145. return -1;
  2146. }
  2147. if(point < 0)
  2148. {
  2149. if(sd->status.status_point < (unsigned int)(-point))
  2150. {
  2151. new_status_point = 0;
  2152. }
  2153. else
  2154. {
  2155. new_status_point = sd->status.status_point + point;
  2156. }
  2157. }
  2158. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2159. {
  2160. new_status_point = UINT_MAX;
  2161. }
  2162. else
  2163. {
  2164. new_status_point = sd->status.status_point + point;
  2165. }
  2166. if (new_status_point != sd->status.status_point) {
  2167. sd->status.status_point = new_status_point;
  2168. clif_updatestatus(sd, SP_STATUSPOINT);
  2169. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2170. } else {
  2171. if (point < 0)
  2172. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2173. else
  2174. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2175. return -1;
  2176. }
  2177. return 0;
  2178. }
  2179. /*==========================================
  2180. * @skpoint (Rewritten by [Yor])
  2181. *------------------------------------------*/
  2182. ACMD_FUNC(skillpoint)
  2183. {
  2184. int point;
  2185. unsigned int new_skill_point;
  2186. nullpo_retr(-1, sd);
  2187. if (!message || !*message || (point = atoi(message)) == 0) {
  2188. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2189. return -1;
  2190. }
  2191. if(point < 0)
  2192. {
  2193. if(sd->status.skill_point < (unsigned int)(-point))
  2194. {
  2195. new_skill_point = 0;
  2196. }
  2197. else
  2198. {
  2199. new_skill_point = sd->status.skill_point + point;
  2200. }
  2201. }
  2202. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2203. {
  2204. new_skill_point = UINT_MAX;
  2205. }
  2206. else
  2207. {
  2208. new_skill_point = sd->status.skill_point + point;
  2209. }
  2210. if (new_skill_point != sd->status.skill_point) {
  2211. sd->status.skill_point = new_skill_point;
  2212. clif_updatestatus(sd, SP_SKILLPOINT);
  2213. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2214. } else {
  2215. if (point < 0)
  2216. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2217. else
  2218. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2219. return -1;
  2220. }
  2221. return 0;
  2222. }
  2223. /*==========================================
  2224. * @zeny
  2225. *------------------------------------------*/
  2226. ACMD_FUNC(zeny)
  2227. {
  2228. int zeny=0, ret=-1;
  2229. nullpo_retr(-1, sd);
  2230. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2231. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2232. return -1;
  2233. }
  2234. if(zeny > 0){
  2235. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2236. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2237. }
  2238. else {
  2239. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2240. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2241. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2242. }
  2243. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2244. return 0;
  2245. }
  2246. /*==========================================
  2247. *
  2248. *------------------------------------------*/
  2249. ACMD_FUNC(param)
  2250. {
  2251. uint8 i;
  2252. int value = 0;
  2253. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2254. unsigned short new_value, *status[6], max_status[6];
  2255. //we don't use direct initialization because it isn't part of the c standard.
  2256. nullpo_retr(-1, sd);
  2257. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2258. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2259. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2260. return -1;
  2261. }
  2262. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2263. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2264. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2265. return -1;
  2266. }
  2267. status[0] = &sd->status.str;
  2268. status[1] = &sd->status.agi;
  2269. status[2] = &sd->status.vit;
  2270. status[3] = &sd->status.int_;
  2271. status[4] = &sd->status.dex;
  2272. status[5] = &sd->status.luk;
  2273. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2274. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2275. else {
  2276. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2277. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2278. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2279. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2280. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2281. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2282. }
  2283. if(value > 0 && *status[i] + value >= max_status[i])
  2284. new_value = max_status[i];
  2285. else if(value < 0 && *status[i] <= -value)
  2286. new_value = 1;
  2287. else
  2288. new_value = *status[i] + value;
  2289. if (new_value != *status[i]) {
  2290. *status[i] = new_value;
  2291. clif_updatestatus(sd, SP_STR + i);
  2292. clif_updatestatus(sd, SP_USTR + i);
  2293. status_calc_pc(sd, SCO_FORCE);
  2294. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2295. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2296. } else {
  2297. if (value < 0)
  2298. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2299. else
  2300. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2301. return -1;
  2302. }
  2303. return 0;
  2304. }
  2305. /*==========================================
  2306. * Stat all by fritz (rewritten by [Yor])
  2307. *------------------------------------------*/
  2308. ACMD_FUNC(stat_all)
  2309. {
  2310. int value = 0;
  2311. uint8 count, i;
  2312. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2313. //we don't use direct initialization because it isn't part of the c standard.
  2314. nullpo_retr(-1, sd);
  2315. status[0] = &sd->status.str;
  2316. status[1] = &sd->status.agi;
  2317. status[2] = &sd->status.vit;
  2318. status[3] = &sd->status.int_;
  2319. status[4] = &sd->status.dex;
  2320. status[5] = &sd->status.luk;
  2321. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2322. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2323. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2324. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2325. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2326. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2327. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2328. value = SHRT_MAX;
  2329. } else {
  2330. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2331. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2332. else {
  2333. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2334. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2335. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2336. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2337. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2338. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2339. }
  2340. }
  2341. count = 0;
  2342. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2343. short new_value;
  2344. if (value > 0 && *status[i] + value >= max_status[i])
  2345. new_value = max_status[i];
  2346. else if (value < 0 && *status[i] <= -value)
  2347. new_value = 1;
  2348. else
  2349. new_value = *status[i] + value;
  2350. if (new_value != *status[i]) {
  2351. *status[i] = new_value;
  2352. clif_updatestatus(sd, SP_STR + i);
  2353. clif_updatestatus(sd, SP_USTR + i);
  2354. count++;
  2355. }
  2356. }
  2357. if (count > 0) { // if at least 1 stat modified
  2358. status_calc_pc(sd, SCO_FORCE);
  2359. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2360. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2361. } else {
  2362. if (value < 0)
  2363. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2364. else
  2365. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2366. return -1;
  2367. }
  2368. return 0;
  2369. }
  2370. /*==========================================
  2371. *
  2372. *------------------------------------------*/
  2373. ACMD_FUNC(guildlevelup) {
  2374. int level = 0;
  2375. short added_level;
  2376. struct guild *guild_info;
  2377. nullpo_retr(-1, sd);
  2378. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2379. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2380. return -1;
  2381. }
  2382. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2383. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2384. return -1;
  2385. }
  2386. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2387. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2388. // return -1;
  2389. //}
  2390. added_level = (short)level;
  2391. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2392. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2393. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2394. added_level = 1 - guild_info->guild_lv;
  2395. if (added_level != 0) {
  2396. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2397. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2398. } else {
  2399. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2400. return -1;
  2401. }
  2402. return 0;
  2403. }
  2404. /*==========================================
  2405. *
  2406. *------------------------------------------*/
  2407. ACMD_FUNC(makeegg) {
  2408. struct item_data *item_data;
  2409. int id;
  2410. nullpo_retr(-1, sd);
  2411. if (!message || !*message) {
  2412. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2413. return -1;
  2414. }
  2415. // for monster name
  2416. if ((id = mobdb_searchname(message)) != 0)
  2417. ;
  2418. else
  2419. id = atoi(message);
  2420. std::shared_ptr<s_pet_db> pet = pet_db.find(id);
  2421. if( pet == nullptr ){
  2422. t_itemid nameid;
  2423. // for egg name
  2424. if( ( item_data = itemdb_searchname( message ) ) != nullptr ){
  2425. nameid = item_data->nameid;
  2426. }else{
  2427. nameid = strtoul( message, nullptr, 10 );
  2428. }
  2429. pet = pet_db_search( nameid, PET_EGG );
  2430. }
  2431. int res(-1);
  2432. if (pet != nullptr) {
  2433. std::shared_ptr<s_mob_db> mdb = mob_db.find(pet->class_);
  2434. if(mdb){
  2435. sd->catch_target_class = pet->class_;
  2436. if(intif_create_pet(sd->status.account_id, sd->status.char_id, pet->class_, mdb->lv, pet->EggID, 0, pet->intimate, 100, 0, 1, mdb->jname.c_str())){
  2437. res = 0;
  2438. } else {
  2439. res = -2; //char server down
  2440. }
  2441. }
  2442. }
  2443. switch(res){
  2444. case -1:
  2445. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2446. break;
  2447. case -2:
  2448. clif_displaymessage(fd, msg_txt(sd,407)); //charserver link broken
  2449. break;
  2450. }
  2451. return res;
  2452. }
  2453. /*==========================================
  2454. *
  2455. *------------------------------------------*/
  2456. ACMD_FUNC(hatch) {
  2457. nullpo_retr(-1, sd);
  2458. if (sd->status.pet_id <= 0)
  2459. clif_sendegg(sd);
  2460. else {
  2461. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2462. return -1;
  2463. }
  2464. return 0;
  2465. }
  2466. /*==========================================
  2467. *
  2468. *------------------------------------------*/
  2469. ACMD_FUNC(petfriendly) {
  2470. int friendly;
  2471. struct pet_data *pd;
  2472. nullpo_retr(-1, sd);
  2473. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2474. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2475. return -1;
  2476. }
  2477. pd = sd->pd;
  2478. if (!pd) {
  2479. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2480. return -1;
  2481. }
  2482. if (friendly < 0 || friendly > 1000)
  2483. {
  2484. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2485. return -1;
  2486. }
  2487. if (friendly == pd->pet.intimate) {
  2488. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2489. return -1;
  2490. }
  2491. pet_set_intimate(pd, friendly);
  2492. clif_send_petstatus(sd);
  2493. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2494. return 0;
  2495. }
  2496. /*==========================================
  2497. *
  2498. *------------------------------------------*/
  2499. ACMD_FUNC(pethungry)
  2500. {
  2501. int hungry;
  2502. struct pet_data *pd;
  2503. nullpo_retr(-1, sd);
  2504. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2505. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2506. return -1;
  2507. }
  2508. pd = sd->pd;
  2509. if (!sd->status.pet_id || !pd) {
  2510. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2511. return -1;
  2512. }
  2513. if (hungry < 0 || hungry > 100) {
  2514. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2515. return -1;
  2516. }
  2517. if (hungry == pd->pet.hungry) {
  2518. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2519. return -1;
  2520. }
  2521. pd->pet.hungry = hungry;
  2522. clif_send_petstatus(sd);
  2523. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2524. return 0;
  2525. }
  2526. /*==========================================
  2527. *
  2528. *------------------------------------------*/
  2529. ACMD_FUNC(petrename)
  2530. {
  2531. struct pet_data *pd;
  2532. nullpo_retr(-1, sd);
  2533. if (!sd->status.pet_id || !sd->pd) {
  2534. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2535. return -1;
  2536. }
  2537. pd = sd->pd;
  2538. if (!pd->pet.rename_flag) {
  2539. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2540. return -1;
  2541. }
  2542. pd->pet.rename_flag = 0;
  2543. intif_save_petdata(sd->status.account_id, &pd->pet);
  2544. clif_send_petstatus(sd);
  2545. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2546. return 0;
  2547. }
  2548. /*==========================================
  2549. *
  2550. *------------------------------------------*/
  2551. ACMD_FUNC(recall) {
  2552. struct map_session_data *pl_sd = NULL;
  2553. nullpo_retr(-1, sd);
  2554. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2555. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2556. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2557. return -1;
  2558. }
  2559. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2560. {
  2561. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2562. return -1;
  2563. }
  2564. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2565. {
  2566. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2567. return -1;
  2568. }
  2569. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2570. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2571. return -1;
  2572. }
  2573. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2574. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2575. return -1;
  2576. }
  2577. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2578. return -1;
  2579. }
  2580. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2581. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2582. return -1;
  2583. }
  2584. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2585. clif_displaymessage(fd, atcmd_output);
  2586. return 0;
  2587. }
  2588. /*==========================================
  2589. * charblock command (usage: charblock <player_name>)
  2590. * This command do a definitiv ban on a player
  2591. *------------------------------------------*/
  2592. ACMD_FUNC(char_block)
  2593. {
  2594. nullpo_retr(-1, sd);
  2595. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2596. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2597. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2598. clif_displaymessage(fd, atcmd_output);
  2599. return -1;
  2600. }
  2601. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2602. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2603. clif_displaymessage(fd, atcmd_output);
  2604. return 0;
  2605. }
  2606. /*==========================================
  2607. * accountban command (usage: ban <%time> <player_name>)
  2608. * charban command (usage: charban <%time> <player_name>)
  2609. * %time see common/timer.cpp::solve_time()
  2610. *------------------------------------------*/
  2611. ACMD_FUNC(char_ban)
  2612. {
  2613. char *modif_p, output[CHAT_SIZE_MAX];
  2614. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2615. enum chrif_req_op bantype;
  2616. nullpo_retr(-1, sd);
  2617. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2618. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2619. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2620. if (strcmpi(parent_cmd,"charban") == 0)
  2621. bantype = CHRIF_OP_BAN;
  2622. else if (strcmpi(parent_cmd,"ban") == 0)
  2623. bantype = CHRIF_OP_LOGIN_BAN;
  2624. else
  2625. return -1;
  2626. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2627. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2628. clif_displaymessage(fd, output);
  2629. return -1;
  2630. }
  2631. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2632. modif_p = atcmd_output;
  2633. timediff = (int32)solve_time(modif_p); //discard seconds
  2634. if (timediff == 0) { //allow negative ?
  2635. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2636. clif_displaymessage(fd, output);
  2637. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  2638. return -1;
  2639. }
  2640. if( timediff < 0 && (
  2641. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2642. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2643. ))
  2644. {
  2645. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2646. return -1;
  2647. }
  2648. if (bantype == CHRIF_OP_BAN)
  2649. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2650. else
  2651. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2652. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2653. clif_displaymessage(fd, output);
  2654. return 0;
  2655. }
  2656. /*==========================================
  2657. * charunblock command (usage: charunblock <player_name>)
  2658. *------------------------------------------*/
  2659. ACMD_FUNC(char_unblock)
  2660. {
  2661. nullpo_retr(-1, sd);
  2662. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2663. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2664. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2665. clif_displaymessage(fd, atcmd_output);
  2666. return -1;
  2667. }
  2668. // send answer to login server via char-server
  2669. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2670. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2671. clif_displaymessage(fd, atcmd_output);
  2672. return 0;
  2673. }
  2674. /*==========================================
  2675. * acc unban command (usage: unban <player_name>)
  2676. * char unban command (usage: charunban <player_name>)
  2677. *------------------------------------------*/
  2678. ACMD_FUNC(char_unban){
  2679. enum chrif_req_op unbantype;
  2680. nullpo_retr(-1, sd);
  2681. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2682. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2683. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2684. if (strcmpi(parent_cmd,"charunban") == 0)
  2685. unbantype = CHRIF_OP_UNBAN;
  2686. else if (strcmpi(parent_cmd,"unban") == 0)
  2687. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2688. else
  2689. return -1;
  2690. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2691. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2692. clif_displaymessage(fd, atcmd_output);
  2693. return -1;
  2694. }
  2695. if (unbantype == CHRIF_OP_UNBAN)
  2696. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2697. else
  2698. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2699. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2700. clif_displaymessage(fd, atcmd_output);
  2701. return 0;
  2702. }
  2703. /*==========================================
  2704. *
  2705. *------------------------------------------*/
  2706. ACMD_FUNC(night)
  2707. {
  2708. nullpo_retr(-1, sd);
  2709. if (night_flag != 1) {
  2710. map_night_timer(night_timer_tid, 0, 0, 1);
  2711. } else {
  2712. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2713. return -1;
  2714. }
  2715. return 0;
  2716. }
  2717. /*==========================================
  2718. *
  2719. *------------------------------------------*/
  2720. ACMD_FUNC(day)
  2721. {
  2722. nullpo_retr(-1, sd);
  2723. if (night_flag != 0) {
  2724. map_day_timer(day_timer_tid, 0, 0, 1);
  2725. } else {
  2726. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2727. return -1;
  2728. }
  2729. return 0;
  2730. }
  2731. /*==========================================
  2732. *
  2733. *------------------------------------------*/
  2734. ACMD_FUNC(doom)
  2735. {
  2736. struct map_session_data* pl_sd;
  2737. struct s_mapiterator* iter;
  2738. nullpo_retr(-1, sd);
  2739. iter = mapit_getallusers();
  2740. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2741. {
  2742. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2743. {
  2744. status_kill(&pl_sd->bl);
  2745. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2746. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2747. }
  2748. }
  2749. mapit_free(iter);
  2750. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2751. return 0;
  2752. }
  2753. /*==========================================
  2754. *
  2755. *------------------------------------------*/
  2756. ACMD_FUNC(doommap)
  2757. {
  2758. struct map_session_data* pl_sd;
  2759. struct s_mapiterator* iter;
  2760. nullpo_retr(-1, sd);
  2761. iter = mapit_getallusers();
  2762. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2763. {
  2764. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2765. {
  2766. status_kill(&pl_sd->bl);
  2767. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2768. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2769. }
  2770. }
  2771. mapit_free(iter);
  2772. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2773. return 0;
  2774. }
  2775. /*==========================================
  2776. *
  2777. *------------------------------------------*/
  2778. static void atcommand_raise_sub(struct map_session_data* sd) {
  2779. status_revive(&sd->bl, 100, 100);
  2780. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2781. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2782. }
  2783. /*==========================================
  2784. *
  2785. *------------------------------------------*/
  2786. ACMD_FUNC(raise)
  2787. {
  2788. struct map_session_data* pl_sd;
  2789. struct s_mapiterator* iter;
  2790. nullpo_retr(-1, sd);
  2791. iter = mapit_getallusers();
  2792. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2793. if( pc_isdead(pl_sd) )
  2794. atcommand_raise_sub(pl_sd);
  2795. mapit_free(iter);
  2796. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2797. return 0;
  2798. }
  2799. /*==========================================
  2800. *
  2801. *------------------------------------------*/
  2802. ACMD_FUNC(raisemap)
  2803. {
  2804. struct map_session_data* pl_sd;
  2805. struct s_mapiterator* iter;
  2806. nullpo_retr(-1, sd);
  2807. iter = mapit_getallusers();
  2808. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2809. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2810. atcommand_raise_sub(pl_sd);
  2811. mapit_free(iter);
  2812. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2813. return 0;
  2814. }
  2815. /*==========================================
  2816. *
  2817. *------------------------------------------*/
  2818. ACMD_FUNC(kick)
  2819. {
  2820. struct map_session_data *pl_sd;
  2821. nullpo_retr(-1, sd);
  2822. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2823. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2824. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2825. return -1;
  2826. }
  2827. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2828. {
  2829. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2830. return -1;
  2831. }
  2832. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2833. {
  2834. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2835. return -1;
  2836. }
  2837. clif_GM_kick(sd, pl_sd);
  2838. return 0;
  2839. }
  2840. /*==========================================
  2841. *
  2842. *------------------------------------------*/
  2843. ACMD_FUNC(kickall)
  2844. {
  2845. struct map_session_data* pl_sd;
  2846. struct s_mapiterator* iter;
  2847. nullpo_retr(-1, sd);
  2848. iter = mapit_getallusers();
  2849. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2850. {
  2851. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2852. if (sd->status.account_id != pl_sd->status.account_id)
  2853. clif_GM_kick(NULL, pl_sd);
  2854. }
  2855. }
  2856. mapit_free(iter);
  2857. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2858. return 0;
  2859. }
  2860. /*==========================================
  2861. *
  2862. *------------------------------------------*/
  2863. ACMD_FUNC(allskill)
  2864. {
  2865. nullpo_retr(-1, sd);
  2866. pc_allskillup(sd); // all skills
  2867. sd->status.skill_point = 0; // 0 skill points
  2868. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2869. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2870. return 0;
  2871. }
  2872. /*==========================================
  2873. *
  2874. *------------------------------------------*/
  2875. ACMD_FUNC(questskill)
  2876. {
  2877. uint16 skill_id;
  2878. nullpo_retr(-1, sd);
  2879. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2880. {// also send a list of skills applicable to this command
  2881. const char* text;
  2882. // attempt to find the text corresponding to this command
  2883. text = atcommand_help_string( command );
  2884. // send the error message as always
  2885. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2886. if( text )
  2887. {// send the skill ID list associated with this command
  2888. clif_displaymessage( fd, text );
  2889. }
  2890. return -1;
  2891. }
  2892. if (skill_id >= MAX_SKILL_ID) {
  2893. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2894. return -1;
  2895. }
  2896. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  2897. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2898. return -1;
  2899. }
  2900. if (pc_checkskill(sd, skill_id) > 0) {
  2901. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2902. return -1;
  2903. }
  2904. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2905. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2906. return 0;
  2907. }
  2908. /*==========================================
  2909. *
  2910. *------------------------------------------*/
  2911. ACMD_FUNC(lostskill)
  2912. {
  2913. uint16 skill_id = 0, sk_idx = 0;
  2914. nullpo_retr(-1, sd);
  2915. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2916. {// also send a list of skills applicable to this command
  2917. const char* text;
  2918. // attempt to find the text corresponding to this command
  2919. text = atcommand_help_string( command );
  2920. // send the error message as always
  2921. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2922. if( text )
  2923. {// send the skill ID list associated with this command
  2924. clif_displaymessage( fd, text );
  2925. }
  2926. return -1;
  2927. }
  2928. if (!(sk_idx = skill_get_index(skill_id))) {
  2929. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2930. return -1;
  2931. }
  2932. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  2933. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2934. return -1;
  2935. }
  2936. if (pc_checkskill(sd, skill_id) == 0) {
  2937. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2938. return -1;
  2939. }
  2940. sd->status.skill[sk_idx].lv = 0;
  2941. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2942. clif_deleteskill(sd,skill_id);
  2943. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2944. return 0;
  2945. }
  2946. /*==========================================
  2947. *
  2948. *------------------------------------------*/
  2949. ACMD_FUNC(spiritball)
  2950. {
  2951. uint32 max_spiritballs;
  2952. int number;
  2953. nullpo_retr(-1, sd);
  2954. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2955. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2956. {
  2957. char msg[CHAT_SIZE_MAX];
  2958. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2959. clif_displaymessage(fd, msg);
  2960. return -1;
  2961. }
  2962. if( sd->spiritball > 0 )
  2963. pc_delspiritball(sd, sd->spiritball, 1);
  2964. sd->spiritball = number;
  2965. clif_spiritball(&sd->bl);
  2966. // no message, player can look the difference
  2967. return 0;
  2968. }
  2969. ACMD_FUNC(soulball)
  2970. {
  2971. int number;
  2972. nullpo_retr(-1, sd);
  2973. if (!message || !*message || (number = atoi(message)) < 0 || number > MAX_SOUL_BALL) {
  2974. char msg[CHAT_SIZE_MAX];
  2975. safesnprintf(msg, sizeof(msg), "Usage: @soulball <number: 0-%d>", MAX_SOUL_BALL);
  2976. clif_displaymessage(fd, msg);
  2977. return -1;
  2978. }
  2979. if (sd->soulball > 0)
  2980. pc_delsoulball(sd, sd->soulball, true);
  2981. sd->soulball = number;
  2982. clif_soulball(sd);
  2983. return 0;
  2984. }
  2985. /*==========================================
  2986. *
  2987. *------------------------------------------*/
  2988. ACMD_FUNC(party)
  2989. {
  2990. char party[NAME_LENGTH];
  2991. nullpo_retr(-1, sd);
  2992. memset(party, '\0', sizeof(party));
  2993. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2994. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2995. return -1;
  2996. }
  2997. party_create(sd, party, 0, 0);
  2998. return 0;
  2999. }
  3000. /*==========================================
  3001. *
  3002. *------------------------------------------*/
  3003. ACMD_FUNC(guild)
  3004. {
  3005. char guild[NAME_LENGTH];
  3006. int prev;
  3007. nullpo_retr(-1, sd);
  3008. memset(guild, '\0', sizeof(guild));
  3009. if (sd->clan) {
  3010. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  3011. return -1;
  3012. }
  3013. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3014. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  3015. return -1;
  3016. }
  3017. prev = battle_config.guild_emperium_check;
  3018. battle_config.guild_emperium_check = 0;
  3019. guild_create(sd, guild);
  3020. battle_config.guild_emperium_check = prev;
  3021. return 0;
  3022. }
  3023. ACMD_FUNC(breakguild)
  3024. {
  3025. nullpo_retr(-1, sd);
  3026. if (sd->status.guild_id) { // Check if the player has a guild
  3027. struct guild *g;
  3028. g = sd->guild; // Search the guild
  3029. if (g) { // Check if guild was found
  3030. if (sd->state.gmaster_flag) { // Check if player is guild master
  3031. int ret = 0;
  3032. ret = guild_break(sd, g->name); // Break guild
  3033. if (ret) { // Check if anything went wrong
  3034. return 0; // Guild was broken
  3035. } else {
  3036. return -1; // Something went wrong
  3037. }
  3038. } else { // Not guild master
  3039. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3040. return -1;
  3041. }
  3042. } else { // Guild was not found. HOW?
  3043. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3044. return -1;
  3045. }
  3046. } else { // Player does not have a guild
  3047. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3048. return -1;
  3049. }
  3050. }
  3051. /**
  3052. * Start WoE:FE
  3053. */
  3054. ACMD_FUNC(agitstart)
  3055. {
  3056. nullpo_retr(-1, sd);
  3057. if( guild_agit_start() ){
  3058. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3059. return 0;
  3060. }else{
  3061. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3062. return -1;
  3063. }
  3064. }
  3065. /**
  3066. * Start WoE:SE
  3067. */
  3068. ACMD_FUNC(agitstart2)
  3069. {
  3070. nullpo_retr(-1, sd);
  3071. if( guild_agit2_start() ){
  3072. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3073. return 0;
  3074. }else{
  3075. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3076. return -1;
  3077. }
  3078. }
  3079. /**
  3080. * Start WoE:TE
  3081. */
  3082. ACMD_FUNC(agitstart3)
  3083. {
  3084. nullpo_retr(-1, sd);
  3085. if( guild_agit3_start() ){
  3086. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3087. return 0;
  3088. }else{
  3089. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3090. return -1;
  3091. }
  3092. }
  3093. /**
  3094. * End WoE:FE
  3095. */
  3096. ACMD_FUNC(agitend)
  3097. {
  3098. nullpo_retr(-1, sd);
  3099. if( guild_agit_end() ){
  3100. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3101. return 0;
  3102. }else{
  3103. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3104. return -1;
  3105. }
  3106. }
  3107. /**
  3108. * End WoE:SE
  3109. */
  3110. ACMD_FUNC(agitend2)
  3111. {
  3112. nullpo_retr(-1, sd);
  3113. if( guild_agit2_end() ){
  3114. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3115. return 0;
  3116. }else{
  3117. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3118. return -1;
  3119. }
  3120. }
  3121. /**
  3122. * End WoE:TE
  3123. */
  3124. ACMD_FUNC(agitend3)
  3125. {
  3126. nullpo_retr(-1, sd);
  3127. if( guild_agit3_end() ){
  3128. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3129. return 0;
  3130. }else{
  3131. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3132. return -1;
  3133. }
  3134. }
  3135. /*==========================================
  3136. * @mapexit - shuts down the map server
  3137. *------------------------------------------*/
  3138. ACMD_FUNC(mapexit)
  3139. {
  3140. nullpo_retr(-1, sd);
  3141. do_shutdown();
  3142. return 0;
  3143. }
  3144. /*==========================================
  3145. * idsearch <part_of_name>: revrited by [Yor]
  3146. *------------------------------------------*/
  3147. ACMD_FUNC(idsearch)
  3148. {
  3149. char item_name[100];
  3150. unsigned int i, match;
  3151. struct item_data *item_array[MAX_SEARCH];
  3152. nullpo_retr(-1, sd);
  3153. memset(item_name, '\0', sizeof(item_name));
  3154. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3155. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3156. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3157. return -1;
  3158. }
  3159. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3160. clif_displaymessage(fd, atcmd_output);
  3161. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3162. if (match == MAX_SEARCH) {
  3163. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3164. clif_displaymessage(fd, atcmd_output);
  3165. }
  3166. for(i = 0; i < match; i++) {
  3167. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->ename.c_str(), item_array[i]->nameid); // %s: %u
  3168. clif_displaymessage(fd, atcmd_output);
  3169. }
  3170. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3171. clif_displaymessage(fd, atcmd_output);
  3172. return 0;
  3173. }
  3174. /*==========================================
  3175. * Recall All Characters Online To Your Location
  3176. *------------------------------------------*/
  3177. ACMD_FUNC(recallall)
  3178. {
  3179. struct map_session_data* pl_sd;
  3180. struct s_mapiterator* iter;
  3181. int count;
  3182. nullpo_retr(-1, sd);
  3183. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3184. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3185. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3186. return -1;
  3187. }
  3188. count = 0;
  3189. iter = mapit_getallusers();
  3190. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3191. {
  3192. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3193. {
  3194. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3195. continue; // Don't waste time warping the character to the same place.
  3196. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3197. count++;
  3198. else {
  3199. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3200. count++;
  3201. }
  3202. }
  3203. }
  3204. }
  3205. mapit_free(iter);
  3206. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3207. if (count) {
  3208. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3209. clif_displaymessage(fd, atcmd_output);
  3210. }
  3211. return 0;
  3212. }
  3213. /*==========================================
  3214. * Recall online characters of a guild to your location
  3215. *------------------------------------------*/
  3216. ACMD_FUNC(guildrecall)
  3217. {
  3218. struct map_session_data* pl_sd;
  3219. struct s_mapiterator* iter;
  3220. int count;
  3221. char guild_name[NAME_LENGTH];
  3222. struct guild *g;
  3223. nullpo_retr(-1, sd);
  3224. memset(guild_name, '\0', sizeof(guild_name));
  3225. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3226. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3227. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3228. return -1;
  3229. }
  3230. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3231. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3232. return -1;
  3233. }
  3234. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3235. (g = guild_search(atoi(message))) == NULL)
  3236. {
  3237. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3238. return -1;
  3239. }
  3240. count = 0;
  3241. iter = mapit_getallusers();
  3242. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3243. {
  3244. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3245. {
  3246. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3247. continue; // Skip GMs greater than you... or chars already on the cell
  3248. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3249. count++;
  3250. else{
  3251. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3252. count++;
  3253. }
  3254. }
  3255. }
  3256. }
  3257. mapit_free(iter);
  3258. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3259. clif_displaymessage(fd, atcmd_output);
  3260. if (count) {
  3261. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3262. clif_displaymessage(fd, atcmd_output);
  3263. }
  3264. return 0;
  3265. }
  3266. /*==========================================
  3267. * Recall online characters of a party to your location
  3268. *------------------------------------------*/
  3269. ACMD_FUNC(partyrecall)
  3270. {
  3271. struct map_session_data* pl_sd;
  3272. struct s_mapiterator* iter;
  3273. char party_name[NAME_LENGTH];
  3274. struct party_data *p;
  3275. int count;
  3276. nullpo_retr(-1, sd);
  3277. memset(party_name, '\0', sizeof(party_name));
  3278. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3279. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3280. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3281. return -1;
  3282. }
  3283. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3284. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3285. return -1;
  3286. }
  3287. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3288. (p = party_search(atoi(message))) == NULL)
  3289. {
  3290. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3291. return -1;
  3292. }
  3293. count = 0;
  3294. iter = mapit_getallusers();
  3295. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3296. {
  3297. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3298. {
  3299. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3300. continue; // Skip GMs greater than you... or chars already on the cell
  3301. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3302. count++;
  3303. else{
  3304. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3305. count++;
  3306. }
  3307. }
  3308. }
  3309. }
  3310. mapit_free(iter);
  3311. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3312. clif_displaymessage(fd, atcmd_output);
  3313. if (count) {
  3314. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3315. clif_displaymessage(fd, atcmd_output);
  3316. }
  3317. return 0;
  3318. }
  3319. /*==========================================
  3320. *
  3321. *------------------------------------------*/
  3322. void atcommand_doload();
  3323. ACMD_FUNC(reload) {
  3324. nullpo_retr(-1, sd);
  3325. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3326. const char* text;
  3327. text = atcommand_help_string( command );
  3328. if(text)
  3329. clif_displaymessage( fd, text );
  3330. return -1;
  3331. }
  3332. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3333. itemdb_reload();
  3334. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3335. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3336. mob_reload();
  3337. pet_db.reload();
  3338. hom_reload();
  3339. mercenary_readdb();
  3340. mercenary_read_skilldb();
  3341. reload_elementaldb();
  3342. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3343. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3344. skill_reload();
  3345. hom_reload_skill();
  3346. reload_elemental_skilldb();
  3347. mercenary_read_skilldb();
  3348. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3349. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3350. config_t run_test;
  3351. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3352. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3353. return -1;
  3354. }
  3355. config_destroy(&run_test);
  3356. atcommand_doload();
  3357. pc_groups_reload();
  3358. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3359. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3360. struct Battle_Config prev_config;
  3361. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3362. battle_config_read(BATTLE_CONF_FILENAME);
  3363. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3364. || prev_config.item_rate_common != battle_config.item_rate_common
  3365. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3366. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3367. || prev_config.item_rate_card != battle_config.item_rate_card
  3368. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3369. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3370. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3371. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3372. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3373. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3374. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3375. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3376. || prev_config.item_rate_use != battle_config.item_rate_use
  3377. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3378. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3379. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3380. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3381. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3382. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3383. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3384. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3385. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3386. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3387. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3388. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3389. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3390. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3391. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3392. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3393. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3394. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3395. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3396. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3397. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3398. )
  3399. { // Exp or Drop rates changed.
  3400. mob_reload(); //Needed as well so rate changes take effect.
  3401. }
  3402. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3403. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3404. status_readdb();
  3405. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3406. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3407. pc_readdb();
  3408. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3409. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3410. pc_read_motd();
  3411. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3412. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3413. struct s_mapiterator* iter;
  3414. struct map_session_data* pl_sd;
  3415. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3416. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3417. iter = mapit_getallusers();
  3418. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3419. pc_close_npc(pl_sd,1);
  3420. clif_cutin(pl_sd, "", 255);
  3421. pl_sd->state.block_action &= ~(PCBLOCK_ALL ^ PCBLOCK_IMMUNE);
  3422. bg_queue_leave(pl_sd);
  3423. }
  3424. mapit_free(iter);
  3425. for (auto &bg : bg_queues) {
  3426. for (auto &bg_sd : bg->teama_members)
  3427. bg_team_leave(bg_sd, false, false); // Kick Team A from battlegrounds
  3428. for (auto &bg_sd : bg->teamb_members)
  3429. bg_team_leave(bg_sd, false, false); // Kick Team B from battlegrounds
  3430. bg_queue_clear(bg, true);
  3431. }
  3432. flush_fifos();
  3433. map_reloadnpc(true); // reload config files seeking for npcs
  3434. script_reload();
  3435. npc_reload();
  3436. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3437. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3438. map_msg_reload();
  3439. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3440. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3441. if (quest_db.reload())
  3442. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3443. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3444. if (instance_db.reload())
  3445. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3446. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3447. achievement_db_reload();
  3448. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3449. } else if (strstr(command, "attendancedb") || strncmp(message, "attendancedb", 4) == 0) {
  3450. attendance_db.reload();
  3451. clif_displaymessage(fd, msg_txt(sd, 795)); // Attendance database has been reloaded.
  3452. }
  3453. return 0;
  3454. }
  3455. /*==========================================
  3456. * @partysharelvl <share_range> [Akinari]
  3457. * Updates char server party share level range in runtime
  3458. * Temporary - Permanent update in inter_athena.conf
  3459. *------------------------------------------*/
  3460. ACMD_FUNC(partysharelvl) {
  3461. unsigned int share_lvl;
  3462. nullpo_retr(-1, sd);
  3463. if(!message || !*message) {
  3464. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3465. return -1;
  3466. } else {
  3467. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3468. }
  3469. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3470. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3471. else //Char server offline
  3472. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3473. return 0;
  3474. }
  3475. /*==========================================
  3476. * @mapinfo [0-3] <map name> by MC_Cameri
  3477. * => Shows information about the map [map name]
  3478. * 0 = no additional information
  3479. * 1 = Show users in that map and their location
  3480. * 2 = Shows NPCs in that map
  3481. * 3 = Shows the chats in that map
  3482. *------------------------------------------*/
  3483. ACMD_FUNC(mapinfo) {
  3484. struct map_session_data* pl_sd;
  3485. struct s_mapiterator* iter;
  3486. struct chat_data *cd = NULL;
  3487. char direction[12];
  3488. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3489. unsigned short m_index;
  3490. char mapname[MAP_NAME_LENGTH];
  3491. nullpo_retr(-1, sd);
  3492. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3493. memset(mapname, '\0', sizeof(mapname));
  3494. memset(direction, '\0', sizeof(direction));
  3495. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3496. if (list < 0 || list > 3) {
  3497. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3498. return -1;
  3499. }
  3500. if (mapname[0] == '\0') {
  3501. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3502. m_id = map_mapindex2mapid(sd->mapindex);
  3503. } else {
  3504. m_id = map_mapname2mapid(mapname);
  3505. }
  3506. if (m_id < 0) {
  3507. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3508. return -1;
  3509. }
  3510. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3511. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3512. // count chats (for initial message)
  3513. chat_num = 0;
  3514. iter = mapit_getallusers();
  3515. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3516. if( pl_sd->mapindex == m_index ) {
  3517. if( pl_sd->state.vending )
  3518. vend_num++;
  3519. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3520. chat_num++;
  3521. }
  3522. }
  3523. mapit_free(iter);
  3524. struct map_data *mapdata = map_getmapdata(m_id);
  3525. sprintf(atcmd_output, msg_txt(sd,1040), mapname, mapdata->users, mapdata->npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3526. clif_displaymessage(fd, atcmd_output);
  3527. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3528. if (map_getmapflag(m_id, MF_TOWN))
  3529. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3530. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3531. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3532. clif_displaymessage(fd, atcmd_output);
  3533. }
  3534. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3535. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3536. else
  3537. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3538. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3539. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3540. clif_displaymessage(fd, atcmd_output);
  3541. }
  3542. /* Skill damage adjustment info [Cydh] */
  3543. if (mapdata->flag[MF_SKILL_DAMAGE]) {
  3544. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3545. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3546. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3547. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3548. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3549. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3550. mapdata->damage_adjust.caster);
  3551. clif_displaymessage(fd, atcmd_output);
  3552. if (!mapdata->skill_damage.empty()) {
  3553. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3554. for (auto skilldmg : mapdata->skill_damage) {
  3555. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3556. skill_get_name(skilldmg.first),
  3557. skilldmg.second.rate[SKILLDMG_PC],
  3558. skilldmg.second.rate[SKILLDMG_MOB],
  3559. skilldmg.second.rate[SKILLDMG_BOSS],
  3560. skilldmg.second.rate[SKILLDMG_OTHER],
  3561. skilldmg.second.caster);
  3562. clif_displaymessage(fd,atcmd_output);
  3563. }
  3564. }
  3565. }
  3566. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3567. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3568. for (const auto &it : mapdata->skill_duration) {
  3569. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3570. clif_displaymessage(fd, atcmd_output);
  3571. }
  3572. }
  3573. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3574. if (map_getmapflag(m_id, MF_PVP))
  3575. strcat(atcmd_output, " Pvp ON |");
  3576. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3577. strcat(atcmd_output, " NoGuild |");
  3578. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3579. strcat(atcmd_output, " NoParty |");
  3580. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3581. strcat(atcmd_output, " NightmareDrop |");
  3582. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3583. strcat(atcmd_output, " NoCalcRank |");
  3584. clif_displaymessage(fd, atcmd_output);
  3585. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3586. if (map_getmapflag(m_id, MF_GVG))
  3587. strcat(atcmd_output, " GvG ON |");
  3588. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3589. strcat(atcmd_output, " GvG Dungeon |");
  3590. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3591. strcat(atcmd_output, " GvG Castle |");
  3592. if (map_getmapflag(m_id, MF_GVG_TE))
  3593. strcat(atcmd_output, " GvG TE |");
  3594. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3595. strcat(atcmd_output, " GvG TE Castle |");
  3596. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3597. strcat(atcmd_output, " NoParty |");
  3598. clif_displaymessage(fd, atcmd_output);
  3599. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3600. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3601. strcat(atcmd_output, " NoTeleport |");
  3602. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3603. strcat(atcmd_output, " Monster NoTeleport |");
  3604. if (map_getmapflag(m_id, MF_NOWARP))
  3605. strcat(atcmd_output, " NoWarp |");
  3606. if (map_getmapflag(m_id, MF_NOWARPTO))
  3607. strcat(atcmd_output, " NoWarpTo |");
  3608. if (map_getmapflag(m_id, MF_NORETURN))
  3609. strcat(atcmd_output, " NoReturn |");
  3610. if (map_getmapflag(m_id, MF_NOGO))
  3611. strcat(atcmd_output, " NoGo |"); //
  3612. if (map_getmapflag(m_id, MF_NOMEMO))
  3613. strcat(atcmd_output, " NoMemo |");
  3614. clif_displaymessage(fd, atcmd_output);
  3615. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3616. (map_getmapflag(m_id, MF_NOEXPPENALTY)) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map_getmapflag(m_id, MF_NOZENYPENALTY)) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3617. clif_displaymessage(fd, atcmd_output);
  3618. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3619. if (!mapdata->save.map)
  3620. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3621. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3622. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3623. clif_displaymessage(fd, atcmd_output);
  3624. }
  3625. else {
  3626. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3627. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3628. clif_displaymessage(fd, atcmd_output);
  3629. }
  3630. }
  3631. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3632. if (map_getmapflag(m_id, MF_SNOW))
  3633. strcat(atcmd_output, " Snow |");
  3634. if (map_getmapflag(m_id, MF_FOG))
  3635. strcat(atcmd_output, " Fog |");
  3636. if (map_getmapflag(m_id, MF_SAKURA))
  3637. strcat(atcmd_output, " Sakura |");
  3638. if (map_getmapflag(m_id, MF_CLOUDS))
  3639. strcat(atcmd_output, " Clouds |");
  3640. if (map_getmapflag(m_id, MF_CLOUDS2))
  3641. strcat(atcmd_output, " Clouds2 |");
  3642. if (map_getmapflag(m_id, MF_FIREWORKS))
  3643. strcat(atcmd_output, " Fireworks |");
  3644. if (map_getmapflag(m_id, MF_LEAVES))
  3645. strcat(atcmd_output, " Leaves |");
  3646. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3647. strcat(atcmd_output, " Displays Night |");
  3648. clif_displaymessage(fd, atcmd_output);
  3649. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3650. if (map_getmapflag(m_id, MF_NOBRANCH))
  3651. strcat(atcmd_output, " NoBranch |");
  3652. if (map_getmapflag(m_id, MF_NOTRADE))
  3653. strcat(atcmd_output, " NoTrade |");
  3654. if (map_getmapflag(m_id, MF_NOVENDING))
  3655. strcat(atcmd_output, " NoVending |");
  3656. if (map_getmapflag(m_id, MF_NODROP))
  3657. strcat(atcmd_output, " NoDrop |");
  3658. if (map_getmapflag(m_id, MF_NOSKILL))
  3659. strcat(atcmd_output, " NoSkill |");
  3660. if (map_getmapflag(m_id, MF_NOICEWALL))
  3661. strcat(atcmd_output, " NoIcewall |");
  3662. if (map_getmapflag(m_id, MF_ALLOWKS))
  3663. strcat(atcmd_output, " AllowKS |");
  3664. if (map_getmapflag(m_id, MF_RESET))
  3665. strcat(atcmd_output, " Reset |");
  3666. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3667. strcat(atcmd_output, " HideMobHPBar |");
  3668. clif_displaymessage(fd, atcmd_output);
  3669. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3670. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3671. strcat(atcmd_output, " NoCommand |");
  3672. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3673. strcat(atcmd_output, " NoBaseEXP |");
  3674. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3675. strcat(atcmd_output, " NoJobEXP |");
  3676. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3677. strcat(atcmd_output, " NoMobLoot |");
  3678. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3679. strcat(atcmd_output, " NoMVPLoot |");
  3680. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3681. strcat(atcmd_output, " PartyLock |");
  3682. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3683. strcat(atcmd_output, " GuildLock |");
  3684. if (map_getmapflag(m_id, MF_LOADEVENT))
  3685. strcat(atcmd_output, " Loadevent |");
  3686. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3687. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  3688. if (map_getmapflag(m_id, MF_NOUSECART))
  3689. strcat(atcmd_output, " NoUsecart |");
  3690. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  3691. strcat(atcmd_output, " NoItemConsumption |");
  3692. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  3693. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  3694. if (map_getmapflag(m_id, MF_NOMINEEFFECT))
  3695. strcat(atcmd_output, " NoMineEffect |");
  3696. if (map_getmapflag(m_id, MF_NOLOCKON))
  3697. strcat(atcmd_output, " NoLockOn |");
  3698. if (map_getmapflag(m_id, MF_NOTOMB))
  3699. strcat(atcmd_output, " NoTomb |");
  3700. if (map_getmapflag(m_id, MF_NOCOSTUME))
  3701. strcat(atcmd_output, " NoCostume |");
  3702. clif_displaymessage(fd, atcmd_output);
  3703. switch (list) {
  3704. case 0:
  3705. // Do nothing. It's list 0, no additional display.
  3706. break;
  3707. case 1:
  3708. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3709. iter = mapit_getallusers();
  3710. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3711. {
  3712. if (pl_sd->mapindex == m_index) {
  3713. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3714. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3715. clif_displaymessage(fd, atcmd_output);
  3716. }
  3717. }
  3718. mapit_free(iter);
  3719. break;
  3720. case 2:
  3721. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3722. for (i = 0; i < mapdata->npc_num;)
  3723. {
  3724. struct npc_data *nd = mapdata->npc[i];
  3725. switch(nd->ud.dir) {
  3726. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3727. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3728. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3729. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3730. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3731. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3732. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3733. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3734. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3735. }
  3736. if(strcmp(nd->name,nd->exname) == 0)
  3737. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3738. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3739. else
  3740. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3741. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3742. clif_displaymessage(fd, atcmd_output);
  3743. }
  3744. break;
  3745. case 3:
  3746. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3747. iter = mapit_getallusers();
  3748. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3749. {
  3750. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3751. pl_sd->mapindex == m_index &&
  3752. cd->usersd[0] == pl_sd)
  3753. {
  3754. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3755. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3756. clif_displaymessage(fd, atcmd_output);
  3757. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3758. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3759. clif_displaymessage(fd, atcmd_output);
  3760. }
  3761. }
  3762. mapit_free(iter);
  3763. break;
  3764. default: // normally impossible to arrive here
  3765. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3766. return -1;
  3767. break;
  3768. }
  3769. return 0;
  3770. }
  3771. /*==========================================
  3772. *
  3773. *------------------------------------------*/
  3774. ACMD_FUNC(mount_peco)
  3775. {
  3776. nullpo_retr(-1, sd);
  3777. if (sd->disguise) {
  3778. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3779. return -1;
  3780. }
  3781. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3782. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3783. unsigned int option = OPTION_DRAGON1;
  3784. if( message[0] ) {
  3785. int color = atoi(message);
  3786. option = ( color == 2 ? OPTION_DRAGON2 :
  3787. color == 3 ? OPTION_DRAGON3 :
  3788. color == 4 ? OPTION_DRAGON4 :
  3789. color == 5 ? OPTION_DRAGON5 :
  3790. OPTION_DRAGON1 );
  3791. }
  3792. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3793. pc_setoption(sd, sd->sc.option|option);
  3794. } else {
  3795. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3796. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3797. }
  3798. return 0;
  3799. }
  3800. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3801. if( !pc_isridingwug(sd) ) {
  3802. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3803. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3804. } else {
  3805. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3806. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3807. }
  3808. return 0;
  3809. }
  3810. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3811. if( !pc_ismadogear(sd) ) {
  3812. e_mado_type type = MADO_ROBOT;
  3813. if (message[0]) {
  3814. int tmp = strtol(message, nullptr, 10);
  3815. switch (tmp) {
  3816. case MADO_ROBOT:
  3817. case MADO_SUIT:
  3818. type = static_cast<e_mado_type>(tmp);
  3819. break;
  3820. default:
  3821. type = MADO_ROBOT;
  3822. break;
  3823. }
  3824. }
  3825. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3826. pc_setmadogear(sd, true, type);
  3827. } else {
  3828. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3829. pc_setmadogear(sd, false);
  3830. }
  3831. return 0;
  3832. }
  3833. if (!pc_isriding(sd)) { // if actually no peco
  3834. if (!pc_checkskill(sd, KN_RIDING)) {
  3835. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3836. return -1;
  3837. }
  3838. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3839. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3840. } else {//Dismount
  3841. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3842. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3843. }
  3844. return 0;
  3845. }
  3846. /*==========================================
  3847. *Spy Commands by Syrus22
  3848. *------------------------------------------*/
  3849. ACMD_FUNC(guildspy)
  3850. {
  3851. char guild_name[NAME_LENGTH];
  3852. struct guild *g;
  3853. nullpo_retr(-1, sd);
  3854. memset(guild_name, '\0', sizeof(guild_name));
  3855. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3856. if (!enable_spy)
  3857. {
  3858. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3859. return -1;
  3860. }
  3861. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3862. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3863. return -1;
  3864. }
  3865. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3866. (g = guild_search(atoi(message))) != NULL) {
  3867. if (sd->guildspy == g->guild_id) {
  3868. sd->guildspy = 0;
  3869. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3870. clif_displaymessage(fd, atcmd_output);
  3871. } else {
  3872. sd->guildspy = g->guild_id;
  3873. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3874. clif_displaymessage(fd, atcmd_output);
  3875. }
  3876. } else {
  3877. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3878. return -1;
  3879. }
  3880. return 0;
  3881. }
  3882. /*==========================================
  3883. *
  3884. *------------------------------------------*/
  3885. ACMD_FUNC(partyspy)
  3886. {
  3887. char party_name[NAME_LENGTH];
  3888. struct party_data *p;
  3889. nullpo_retr(-1, sd);
  3890. memset(party_name, '\0', sizeof(party_name));
  3891. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3892. if (!enable_spy)
  3893. {
  3894. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3895. return -1;
  3896. }
  3897. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3898. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3899. return -1;
  3900. }
  3901. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3902. (p = party_search(atoi(message))) != NULL) {
  3903. if (sd->partyspy == p->party.party_id) {
  3904. sd->partyspy = 0;
  3905. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3906. clif_displaymessage(fd, atcmd_output);
  3907. } else {
  3908. sd->partyspy = p->party.party_id;
  3909. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3910. clif_displaymessage(fd, atcmd_output);
  3911. }
  3912. } else {
  3913. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3914. return -1;
  3915. }
  3916. return 0;
  3917. }
  3918. ACMD_FUNC(clanspy){
  3919. char clan_name[NAME_LENGTH];
  3920. struct clan* c;
  3921. nullpo_retr(-1, sd);
  3922. memset(clan_name, '\0', sizeof(clan_name));
  3923. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3924. if( !enable_spy ){
  3925. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  3926. return -1;
  3927. }
  3928. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  3929. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  3930. return -1;
  3931. }
  3932. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  3933. (c = clan_search(atoi(message))) != NULL) {
  3934. if (sd->clanspy == c->id) {
  3935. sd->clanspy = 0;
  3936. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  3937. clif_displaymessage(fd, atcmd_output);
  3938. }
  3939. else {
  3940. sd->clanspy = c->id;
  3941. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  3942. clif_displaymessage(fd, atcmd_output);
  3943. }
  3944. }
  3945. else {
  3946. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  3947. return -1;
  3948. }
  3949. return 0;
  3950. }
  3951. /*==========================================
  3952. * @repairall [Valaris]
  3953. *------------------------------------------*/
  3954. ACMD_FUNC(repairall)
  3955. {
  3956. int count, i;
  3957. nullpo_retr(-1, sd);
  3958. count = 0;
  3959. for (i = 0; i < MAX_INVENTORY; i++) {
  3960. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1 && !itemdb_ishatched_egg(&sd->inventory.u.items_inventory[i])) {
  3961. sd->inventory.u.items_inventory[i].attribute = 0;
  3962. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  3963. count++;
  3964. }
  3965. }
  3966. if (count > 0) {
  3967. clif_misceffect(&sd->bl, 3);
  3968. clif_equiplist(sd);
  3969. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3970. } else {
  3971. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3972. return -1;
  3973. }
  3974. return 0;
  3975. }
  3976. /*==========================================
  3977. * @nuke [Valaris]
  3978. *------------------------------------------*/
  3979. ACMD_FUNC(nuke)
  3980. {
  3981. struct map_session_data *pl_sd;
  3982. nullpo_retr(-1, sd);
  3983. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3984. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3985. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3986. return -1;
  3987. }
  3988. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  3989. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3990. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3991. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3992. } else {
  3993. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3994. return -1;
  3995. }
  3996. } else {
  3997. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3998. return -1;
  3999. }
  4000. return 0;
  4001. }
  4002. /*==========================================
  4003. * @tonpc
  4004. *------------------------------------------*/
  4005. ACMD_FUNC(tonpc)
  4006. {
  4007. char npcname[NPC_NAME_LENGTH];
  4008. struct npc_data *nd;
  4009. nullpo_retr(-1, sd);
  4010. memset(npcname, 0, sizeof(npcname));
  4011. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  4012. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  4013. return -1;
  4014. }
  4015. if ((nd = npc_name2id(npcname)) != NULL) {
  4016. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  4017. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  4018. else
  4019. return -1;
  4020. } else {
  4021. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4022. return -1;
  4023. }
  4024. return 0;
  4025. }
  4026. /*==========================================
  4027. *
  4028. *------------------------------------------*/
  4029. ACMD_FUNC(shownpc)
  4030. {
  4031. char NPCname[NPC_NAME_LENGTH];
  4032. nullpo_retr(-1, sd);
  4033. memset(NPCname, '\0', sizeof(NPCname));
  4034. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4035. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  4036. return -1;
  4037. }
  4038. if (npc_name2id(NPCname) != NULL) {
  4039. npc_enable(NPCname, 1);
  4040. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4041. } else {
  4042. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4043. return -1;
  4044. }
  4045. return 0;
  4046. }
  4047. /*==========================================
  4048. *
  4049. *------------------------------------------*/
  4050. ACMD_FUNC(hidenpc)
  4051. {
  4052. char NPCname[NPC_NAME_LENGTH];
  4053. nullpo_retr(-1, sd);
  4054. memset(NPCname, '\0', sizeof(NPCname));
  4055. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4056. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4057. return -1;
  4058. }
  4059. if (npc_name2id(NPCname) == NULL) {
  4060. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4061. return -1;
  4062. }
  4063. npc_enable(NPCname, 0);
  4064. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4065. return 0;
  4066. }
  4067. ACMD_FUNC(loadnpc)
  4068. {
  4069. if (!message || !*message) {
  4070. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4071. return -1;
  4072. }
  4073. if (!npc_addsrcfile(message, true)) {
  4074. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4075. return -1;
  4076. }
  4077. npc_read_event_script();
  4078. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was loaded.\n", message );
  4079. npc_event_doall_path( script_config.init_event_name, message );
  4080. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4081. return 0;
  4082. }
  4083. ACMD_FUNC(unloadnpc)
  4084. {
  4085. struct npc_data *nd;
  4086. char NPCname[NPC_NAME_LENGTH];
  4087. nullpo_retr(-1, sd);
  4088. memset(NPCname, '\0', sizeof(NPCname));
  4089. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4090. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4091. return -1;
  4092. }
  4093. if ((nd = npc_name2id(NPCname)) == NULL) {
  4094. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4095. return -1;
  4096. }
  4097. npc_unload_duplicates(nd);
  4098. npc_unload(nd,true);
  4099. npc_read_event_script();
  4100. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4101. return 0;
  4102. }
  4103. ACMD_FUNC(reloadnpcfile) {
  4104. if (!message || !*message) {
  4105. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4106. return -1;
  4107. }
  4108. if (npc_unloadfile(message))
  4109. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4110. if (!npc_addsrcfile(message, true)) {
  4111. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4112. return -1;
  4113. }
  4114. npc_read_event_script();
  4115. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was reloaded.\n", message );
  4116. npc_event_doall_path( script_config.init_event_name, message );
  4117. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4118. return 0;
  4119. }
  4120. /*==========================================
  4121. * time in txt for time command (by [Yor])
  4122. *------------------------------------------*/
  4123. char* txt_time(t_tick duration_)
  4124. {
  4125. int days, hours, minutes, seconds;
  4126. char temp[CHAT_SIZE_MAX];
  4127. static char temp1[CHAT_SIZE_MAX];
  4128. memset(temp, '\0', sizeof(temp));
  4129. memset(temp1, '\0', sizeof(temp1));
  4130. // Cap it
  4131. int duration = (int)duration_;
  4132. days = duration / (60 * 60 * 24);
  4133. duration = duration - (60 * 60 * 24 * days);
  4134. hours = duration / (60 * 60);
  4135. duration = duration - (60 * 60 * hours);
  4136. minutes = duration / 60;
  4137. seconds = duration - (60 * minutes);
  4138. if (days == 1)
  4139. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4140. else if (days > 1)
  4141. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4142. if (hours == 1)
  4143. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4144. else if (hours > 1)
  4145. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4146. if (minutes < 2)
  4147. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4148. else
  4149. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4150. if (seconds == 1)
  4151. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4152. else if (seconds > 1)
  4153. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4154. return temp1;
  4155. }
  4156. /*==========================================
  4157. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4158. * Calculation management of GM modification (@day/@night GM commands) is done
  4159. *------------------------------------------*/
  4160. ACMD_FUNC(servertime)
  4161. {
  4162. const struct TimerData * timer_data;
  4163. time_t time_server; // variable for number of seconds (used with time() function)
  4164. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4165. char temp[CHAT_SIZE_MAX];
  4166. nullpo_retr(-1, sd);
  4167. memset(temp, '\0', sizeof(temp));
  4168. time(&time_server); // get time in seconds since 1/1/1970
  4169. datetime = localtime(&time_server); // convert seconds in structure
  4170. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4171. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4172. clif_displaymessage(fd, temp);
  4173. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4174. if (night_flag == 0)
  4175. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4176. else
  4177. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4178. } else if (battle_config.night_duration == 0)
  4179. if (night_flag == 1) { // we start with night
  4180. if ((timer_data = get_timer(day_timer_tid)) != nullptr) {
  4181. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4182. clif_displaymessage(fd, temp);
  4183. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4184. } else
  4185. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4186. } else
  4187. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4188. else if (battle_config.day_duration == 0)
  4189. if (night_flag == 0) { // we start with day
  4190. if ((timer_data = get_timer(night_timer_tid)) != nullptr) {
  4191. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4192. clif_displaymessage(fd, temp);
  4193. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4194. } else
  4195. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4196. } else
  4197. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4198. else {
  4199. const struct TimerData * timer_data2;
  4200. if (night_flag == 0) {
  4201. timer_data = get_timer(night_timer_tid);
  4202. timer_data2 = get_timer(day_timer_tid);
  4203. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4204. clif_displaymessage(fd, temp);
  4205. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4206. sprintf(temp, msg_txt(sd,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.
  4207. else
  4208. sprintf(temp, msg_txt(sd,237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4209. clif_displaymessage(fd, temp);
  4210. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4211. clif_displaymessage(fd, temp);
  4212. } else {
  4213. timer_data = get_timer(day_timer_tid);
  4214. timer_data2 = get_timer(night_timer_tid);
  4215. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4216. clif_displaymessage(fd, temp);
  4217. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4218. sprintf(temp, msg_txt(sd,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.
  4219. else
  4220. sprintf(temp, msg_txt(sd,239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4221. clif_displaymessage(fd, temp);
  4222. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4223. clif_displaymessage(fd, temp);
  4224. }
  4225. }
  4226. return 0;
  4227. }
  4228. /*==========================================
  4229. * @jail <char_name> by [Yor]
  4230. * Special warp! No check with nowarp and nowarpto flag
  4231. *------------------------------------------*/
  4232. ACMD_FUNC(jail)
  4233. {
  4234. struct map_session_data *pl_sd;
  4235. int x, y;
  4236. unsigned short m_index;
  4237. nullpo_retr(-1, sd);
  4238. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4239. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4240. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4241. return -1;
  4242. }
  4243. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4244. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4245. return -1;
  4246. }
  4247. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4248. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4249. return -1;
  4250. }
  4251. if (pl_sd->sc.data[SC_JAILED]) {
  4252. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4253. return -1;
  4254. }
  4255. switch(rnd() % 2) { //Jail Locations
  4256. case 0:
  4257. m_index = mapindex_name2id(MAP_JAIL);
  4258. x = 24;
  4259. y = 75;
  4260. break;
  4261. default:
  4262. m_index = mapindex_name2id(MAP_JAIL);
  4263. x = 49;
  4264. y = 75;
  4265. break;
  4266. }
  4267. //Duration of INT_MAX to specify infinity.
  4268. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4269. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4270. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4271. return 0;
  4272. }
  4273. /*==========================================
  4274. * @unjail/@discharge <char_name> by [Yor]
  4275. * Special warp! No check with nowarp and nowarpto flag
  4276. *------------------------------------------*/
  4277. ACMD_FUNC(unjail)
  4278. {
  4279. struct map_session_data *pl_sd;
  4280. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4281. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4282. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4283. return -1;
  4284. }
  4285. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4286. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4287. return -1;
  4288. }
  4289. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4290. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4291. return -1;
  4292. }
  4293. if (!pl_sd->sc.data[SC_JAILED]) {
  4294. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4295. return -1;
  4296. }
  4297. //Reset jail time to 1 sec.
  4298. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4299. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4300. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4301. return 0;
  4302. }
  4303. ACMD_FUNC(jailfor) {
  4304. struct map_session_data *pl_sd = NULL;
  4305. char * modif_p;
  4306. int jailtime = 0,x,y;
  4307. short m_index = 0;
  4308. nullpo_retr(-1, sd);
  4309. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4310. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4311. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4312. return -1;
  4313. }
  4314. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4315. modif_p = atcmd_output;
  4316. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4317. if (jailtime == 0) {
  4318. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4319. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  4320. return -1;
  4321. }
  4322. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4323. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4324. return -1;
  4325. }
  4326. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4327. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4328. return -1;
  4329. }
  4330. // Added by Coltaro
  4331. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4332. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4333. if (jailtime <= 0) {
  4334. jailtime = 0;
  4335. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4336. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4337. } else {
  4338. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4339. char timestr[21];
  4340. time_t now=time(NULL);
  4341. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4342. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1137),year,month,day,hour,minute); // %s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4343. clif_displaymessage(pl_sd->fd, atcmd_output);
  4344. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1138),year,month,day,hour,minute); // This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4345. clif_displaymessage(fd, atcmd_output);
  4346. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4347. sprintf(atcmd_output,"Release date is: %s",timestr);
  4348. clif_displaymessage(pl_sd->fd, atcmd_output);
  4349. clif_displaymessage(fd, atcmd_output);
  4350. }
  4351. } else if (jailtime < 0) {
  4352. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4353. return -1;
  4354. }
  4355. // Jail locations, add more as you wish.
  4356. switch(rnd()%2) {
  4357. case 1: // Jail #1
  4358. m_index = mapindex_name2id(MAP_JAIL);
  4359. x = 49; y = 75;
  4360. break;
  4361. default: // Default Jail
  4362. m_index = mapindex_name2id(MAP_JAIL);
  4363. x = 24; y = 75;
  4364. break;
  4365. }
  4366. sc_start4(NULL,&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).
  4367. return 0;
  4368. }
  4369. //By Coltaro
  4370. ACMD_FUNC(jailtime){
  4371. int year, month, day, hour, minute, second;
  4372. char timestr[21];
  4373. time_t now = time(NULL);
  4374. nullpo_retr(-1, sd);
  4375. if (!sd->sc.data[SC_JAILED]) {
  4376. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4377. return -1;
  4378. }
  4379. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4380. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4381. return 0;
  4382. }
  4383. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4384. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4385. return -1;
  4386. }
  4387. // Get remaining jail time
  4388. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4389. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4390. clif_displaymessage(fd, atcmd_output);
  4391. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4392. sprintf(atcmd_output,"Release date is: %s",timestr);
  4393. clif_displaymessage(fd, atcmd_output);
  4394. return 0;
  4395. }
  4396. /*==========================================
  4397. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4398. *------------------------------------------*/
  4399. ACMD_FUNC(disguise)
  4400. {
  4401. int id = 0;
  4402. nullpo_retr(-1, sd);
  4403. if (!message || !*message) {
  4404. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4405. return -1;
  4406. }
  4407. if ((id = atoi(message)) > 0)
  4408. { //Acquired an ID
  4409. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4410. id = 0; //Invalid id for either mobs or npcs.
  4411. } else { //Acquired a Name
  4412. if ((id = mobdb_searchname(message)) == 0)
  4413. {
  4414. struct npc_data* nd = npc_name2id(message);
  4415. if (nd != NULL)
  4416. id = nd->class_;
  4417. }
  4418. }
  4419. if (id == 0)
  4420. {
  4421. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4422. return -1;
  4423. }
  4424. if(pc_isriding(sd))
  4425. {
  4426. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4427. return -1;
  4428. }
  4429. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4430. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4431. return -1;
  4432. }
  4433. pc_disguise(sd, id);
  4434. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4435. return 0;
  4436. }
  4437. /*==========================================
  4438. * DisguiseAll
  4439. *------------------------------------------*/
  4440. ACMD_FUNC(disguiseall)
  4441. {
  4442. int mob_id=0;
  4443. struct map_session_data *pl_sd;
  4444. struct s_mapiterator* iter;
  4445. nullpo_retr(-1, sd);
  4446. if (!message || !*message) {
  4447. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4448. return -1;
  4449. }
  4450. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4451. mob_id = atoi(message);
  4452. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4453. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4454. return -1;
  4455. }
  4456. iter = mapit_getallusers();
  4457. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4458. pc_disguise(pl_sd, mob_id);
  4459. mapit_free(iter);
  4460. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4461. return 0;
  4462. }
  4463. /*==========================================
  4464. * DisguiseGuild
  4465. *------------------------------------------*/
  4466. ACMD_FUNC(disguiseguild)
  4467. {
  4468. int id = 0, i;
  4469. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4470. struct guild *g;
  4471. memset(monster, '\0', sizeof(monster));
  4472. memset(guild, '\0', sizeof(guild));
  4473. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4474. clif_displaymessage(fd, msg_txt(sd,1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4475. return -1;
  4476. }
  4477. if( (id = atoi(monster)) > 0 ) {
  4478. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4479. id = 0;
  4480. } else {
  4481. if( (id = mobdb_searchname(monster)) == 0 ) {
  4482. struct npc_data* nd = npc_name2id(monster);
  4483. if( nd != NULL )
  4484. id = nd->class_;
  4485. }
  4486. }
  4487. if( id == 0 ) {
  4488. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4489. return -1;
  4490. }
  4491. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4492. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4493. return -1;
  4494. }
  4495. for( i = 0; i < g->max_member; i++ ){
  4496. struct map_session_data *pl_sd;
  4497. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4498. pc_disguise(pl_sd, id);
  4499. }
  4500. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4501. return 0;
  4502. }
  4503. /*==========================================
  4504. * @undisguise by [Yor]
  4505. *------------------------------------------*/
  4506. ACMD_FUNC(undisguise)
  4507. {
  4508. nullpo_retr(-1, sd);
  4509. if (sd->disguise) {
  4510. pc_disguise(sd, 0);
  4511. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4512. } else {
  4513. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4514. return -1;
  4515. }
  4516. return 0;
  4517. }
  4518. /*==========================================
  4519. * UndisguiseAll
  4520. *------------------------------------------*/
  4521. ACMD_FUNC(undisguiseall)
  4522. {
  4523. struct map_session_data *pl_sd;
  4524. struct s_mapiterator* iter;
  4525. nullpo_retr(-1, sd);
  4526. iter = mapit_getallusers();
  4527. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4528. if( pl_sd->disguise )
  4529. pc_disguise(pl_sd, 0);
  4530. mapit_free(iter);
  4531. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4532. return 0;
  4533. }
  4534. /*==========================================
  4535. * UndisguiseGuild
  4536. *------------------------------------------*/
  4537. ACMD_FUNC(undisguiseguild)
  4538. {
  4539. char guild_name[NAME_LENGTH];
  4540. struct guild *g;
  4541. int i;
  4542. nullpo_retr(-1, sd);
  4543. memset(guild_name, '\0', sizeof(guild_name));
  4544. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4545. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4546. return -1;
  4547. }
  4548. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4549. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4550. return -1;
  4551. }
  4552. for(i = 0; i < g->max_member; i++){
  4553. struct map_session_data *pl_sd;
  4554. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4555. pc_disguise(pl_sd, 0);
  4556. }
  4557. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4558. return 0;
  4559. }
  4560. /*==========================================
  4561. * @exp by [Skotlex]
  4562. *------------------------------------------*/
  4563. ACMD_FUNC(exp)
  4564. {
  4565. char output[CHAT_SIZE_MAX];
  4566. double nextb, nextj;
  4567. nullpo_retr(-1, sd);
  4568. memset(output, '\0', sizeof(output));
  4569. nextb = (double)pc_nextbaseexp(sd);
  4570. if (nextb)
  4571. nextb = sd->status.base_exp*100.0/nextb;
  4572. nextj = (double)pc_nextjobexp(sd);
  4573. if (nextj)
  4574. nextj = sd->status.job_exp*100.0/nextj;
  4575. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4576. clif_displaymessage(fd, output);
  4577. return 0;
  4578. }
  4579. /*==========================================
  4580. * @broadcast by [Valaris]
  4581. *------------------------------------------*/
  4582. ACMD_FUNC(broadcast)
  4583. {
  4584. nullpo_retr(-1, sd);
  4585. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4586. if (!message || !*message) {
  4587. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4588. return -1;
  4589. }
  4590. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4591. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4592. return 0;
  4593. }
  4594. /*==========================================
  4595. * @localbroadcast by [Valaris]
  4596. *------------------------------------------*/
  4597. ACMD_FUNC(localbroadcast)
  4598. {
  4599. nullpo_retr(-1, sd);
  4600. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4601. if (!message || !*message) {
  4602. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4603. return -1;
  4604. }
  4605. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4606. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4607. return 0;
  4608. }
  4609. /*==========================================
  4610. * @email <actual@email> <new@email> by [Yor]
  4611. *------------------------------------------*/
  4612. ACMD_FUNC(email)
  4613. {
  4614. char actual_email[100];
  4615. char new_email[100];
  4616. nullpo_retr(-1, sd);
  4617. memset(actual_email, '\0', sizeof(actual_email));
  4618. memset(new_email, '\0', sizeof(new_email));
  4619. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4620. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4621. return -1;
  4622. }
  4623. if (e_mail_check(actual_email) == 0) {
  4624. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4625. return -1;
  4626. } else if (e_mail_check(new_email) == 0) {
  4627. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4628. return -1;
  4629. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4630. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4631. return -1;
  4632. } else if (strcmpi(actual_email, new_email) == 0) {
  4633. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4634. return -1;
  4635. }
  4636. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4637. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4638. return 0;
  4639. }
  4640. /*==========================================
  4641. *@effect
  4642. *------------------------------------------*/
  4643. ACMD_FUNC(effect)
  4644. {
  4645. int type = EF_NONE;
  4646. nullpo_retr(-1, sd);
  4647. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4648. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4649. return -1;
  4650. }
  4651. if( type <= EF_NONE || type >= EF_MAX ){
  4652. sprintf(atcmd_output, msg_txt(sd,1152),EF_NONE+1,EF_MAX-1); // Please enter a valid effect id in the range from %d to %d.
  4653. clif_displaymessage(fd, atcmd_output);
  4654. return -1;
  4655. }
  4656. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4657. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4658. return 0;
  4659. }
  4660. /*==========================================
  4661. * @killer by MouseJstr
  4662. * enable killing players even when not in pvp
  4663. *------------------------------------------*/
  4664. ACMD_FUNC(killer)
  4665. {
  4666. nullpo_retr(-1, sd);
  4667. sd->state.killer = !sd->state.killer;
  4668. if(sd->state.killer)
  4669. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4670. else {
  4671. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4672. pc_stop_attack(sd);
  4673. }
  4674. return 0;
  4675. }
  4676. /*==========================================
  4677. * @killable by MouseJstr
  4678. * enable other people killing you
  4679. *------------------------------------------*/
  4680. ACMD_FUNC(killable)
  4681. {
  4682. nullpo_retr(-1, sd);
  4683. sd->state.killable = !sd->state.killable;
  4684. if(sd->state.killable)
  4685. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4686. else {
  4687. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4688. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4689. }
  4690. return 0;
  4691. }
  4692. /*==========================================
  4693. * @skillon by MouseJstr
  4694. * turn skills on for the map
  4695. *------------------------------------------*/
  4696. ACMD_FUNC(skillon)
  4697. {
  4698. nullpo_retr(-1, sd);
  4699. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4700. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4701. return 0;
  4702. }
  4703. /*==========================================
  4704. * @skilloff by MouseJstr
  4705. * Turn skills off on the map
  4706. *------------------------------------------*/
  4707. ACMD_FUNC(skilloff)
  4708. {
  4709. nullpo_retr(-1, sd);
  4710. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  4711. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4712. return 0;
  4713. }
  4714. /*==========================================
  4715. * @npcmove by MouseJstr
  4716. * move a npc
  4717. *------------------------------------------*/
  4718. ACMD_FUNC(npcmove)
  4719. {
  4720. short x = 0, y = 0;
  4721. struct npc_data *nd = 0;
  4722. char npc_name[NPC_NAME_LENGTH];
  4723. nullpo_retr(-1, sd);
  4724. memset(npc_name, '\0', sizeof npc_name);
  4725. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4726. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4727. return -1;
  4728. }
  4729. if ((nd = npc_name2id(npc_name)) == NULL)
  4730. {
  4731. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4732. return -1;
  4733. }
  4734. if ( npc_movenpc( nd, x, y ) )
  4735. { //actually failed to move
  4736. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4737. return -1; //Not on a map.
  4738. } else
  4739. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4740. return 0;
  4741. }
  4742. /*==========================================
  4743. * @addwarp by MouseJstr
  4744. * Create a new static warp point.
  4745. *------------------------------------------*/
  4746. ACMD_FUNC(addwarp)
  4747. {
  4748. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4749. short x,y;
  4750. unsigned short m;
  4751. struct npc_data* nd;
  4752. nullpo_retr(-1, sd);
  4753. memset(warpname, '\0', sizeof(warpname));
  4754. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4755. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4756. return -1;
  4757. }
  4758. m = mapindex_name2id(mapname);
  4759. if( m == 0 )
  4760. {
  4761. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4762. clif_displaymessage(fd, atcmd_output);
  4763. return -1;
  4764. }
  4765. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4766. if( nd == NULL )
  4767. return -1;
  4768. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4769. clif_displaymessage(fd, atcmd_output);
  4770. return 0;
  4771. }
  4772. /*==========================================
  4773. * @follow by [MouseJstr]
  4774. * Follow a player .. staying no more then 5 spaces away
  4775. *------------------------------------------*/
  4776. ACMD_FUNC(follow)
  4777. {
  4778. struct map_session_data *pl_sd = NULL;
  4779. nullpo_retr(-1, sd);
  4780. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4781. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4782. if (sd->followtarget == -1)
  4783. return -1;
  4784. pc_stop_following (sd);
  4785. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4786. return 0;
  4787. }
  4788. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4789. {
  4790. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4791. return -1;
  4792. }
  4793. if (sd->followtarget == pl_sd->bl.id) {
  4794. pc_stop_following (sd);
  4795. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4796. } else {
  4797. pc_follow(sd, pl_sd->bl.id);
  4798. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4799. }
  4800. return 0;
  4801. }
  4802. /*==========================================
  4803. * @dropall by [MouseJstr] and [Xantara]
  4804. * Drops all your possession on the ground based on item type
  4805. *------------------------------------------*/
  4806. ACMD_FUNC(dropall)
  4807. {
  4808. int8 type = -1;
  4809. uint16 i, count = 0, count2 = 0;
  4810. struct item_data *item_data = NULL;
  4811. nullpo_retr(-1, sd);
  4812. if( message[0] ) {
  4813. type = atoi(message);
  4814. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4815. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4816. {
  4817. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  4818. clif_displaymessage(fd, msg_txt(sd,1493)); // Type List: (default) all = -1, healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
  4819. return -1;
  4820. }
  4821. }
  4822. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4823. if( sd->inventory.u.items_inventory[i].amount ) {
  4824. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4825. ShowDebug("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->inventory.u.items_inventory[i].nameid, sd->status.account_id, sd->status.char_id);
  4826. continue;
  4827. }
  4828. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4829. continue;
  4830. if( type == -1 || type == (uint8)item_data->type ) {
  4831. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4832. pc_unequipitem(sd, i, 3);
  4833. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  4834. pet_return_egg( sd, sd->pd );
  4835. }
  4836. pc_equipswitch_remove(sd, i);
  4837. int amount = sd->inventory.u.items_inventory[i].amount;
  4838. if(pc_dropitem(sd, i, amount))
  4839. count += amount;
  4840. else count2 += amount;
  4841. }
  4842. }
  4843. }
  4844. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4845. clif_displaymessage(fd, atcmd_output);
  4846. return 0;
  4847. }
  4848. /*==========================================
  4849. * @storeall by [MouseJstr]
  4850. * Put everything into storage
  4851. *------------------------------------------*/
  4852. ACMD_FUNC(storeall)
  4853. {
  4854. int i;
  4855. nullpo_retr(-1, sd);
  4856. if (sd->state.storage_flag != 1)
  4857. { //Open storage.
  4858. if( storage_storageopen(sd) == 1 ) {
  4859. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4860. return -1;
  4861. }
  4862. }
  4863. for (i = 0; i < MAX_INVENTORY; i++) {
  4864. if (sd->inventory.u.items_inventory[i].amount) {
  4865. if(sd->inventory.u.items_inventory[i].equip != 0)
  4866. pc_unequipitem(sd, i, 3);
  4867. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  4868. pet_return_egg( sd, sd->pd );
  4869. }
  4870. pc_equipswitch_remove(sd, i);
  4871. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  4872. }
  4873. }
  4874. storage_storageclose(sd);
  4875. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4876. return 0;
  4877. }
  4878. ACMD_FUNC(clearstorage)
  4879. {
  4880. int i, j;
  4881. nullpo_retr(-1, sd);
  4882. if (sd->state.storage_flag == 1) {
  4883. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4884. return -1;
  4885. }
  4886. if (sd->state.storage_flag == 3) {
  4887. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4888. return -1;
  4889. }
  4890. j = sd->storage.amount;
  4891. for (i = 0; i < j; ++i) {
  4892. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  4893. }
  4894. sd->state.storage_flag = 1;
  4895. storage_storageclose(sd);
  4896. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4897. return 0;
  4898. }
  4899. ACMD_FUNC(cleargstorage)
  4900. {
  4901. int i, j;
  4902. struct guild *g;
  4903. struct s_storage *gstorage;
  4904. nullpo_retr(-1, sd);
  4905. g = sd->guild;
  4906. if (g == NULL) {
  4907. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  4908. return -1;
  4909. }
  4910. if (sd->state.storage_flag == 1) {
  4911. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4912. return -1;
  4913. }
  4914. if (sd->state.storage_flag == 2) {
  4915. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  4916. return -1;
  4917. }
  4918. if (sd->state.storage_flag == 3) {
  4919. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4920. return -1;
  4921. }
  4922. gstorage = guild2storage2(sd->status.guild_id);
  4923. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4924. return -1;
  4925. }
  4926. j = gstorage->amount;
  4927. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4928. for (i = 0; i < j; ++i) {
  4929. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  4930. }
  4931. storage_guild_storageclose(sd);
  4932. gstorage->lock = false; // Cleaning done, release lock
  4933. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4934. return 0;
  4935. }
  4936. ACMD_FUNC(clearcart)
  4937. {
  4938. int i;
  4939. nullpo_retr(-1, sd);
  4940. if (pc_iscarton(sd) == 0) {
  4941. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4942. return -1;
  4943. }
  4944. if (sd->state.vending == 1) { //Somehow...
  4945. return -1;
  4946. }
  4947. for (i = 0; i < MAX_CART; i++) {
  4948. if (sd->cart.u.items_cart[i].nameid > 0)
  4949. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  4950. }
  4951. clif_clearcart(fd);
  4952. clif_updatestatus(sd,SP_CARTINFO);
  4953. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4954. return 0;
  4955. }
  4956. /*==========================================
  4957. * @skillid by [MouseJstr]
  4958. * lookup a skill by name
  4959. *------------------------------------------*/
  4960. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4961. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4962. ACMD_FUNC(skillid) {
  4963. int skillen, i, found = 0;
  4964. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4965. nullpo_retr(-1, sd);
  4966. if (!message || !*message) {
  4967. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4968. return -1;
  4969. }
  4970. skillen = strlen(message);
  4971. for(const auto & skill : skill_db) {
  4972. uint16 skill_id = skill.second->nameid;
  4973. uint16 idx = skill_get_index(skill_id);
  4974. const char *name = skill.second->name;
  4975. const char *desc = skill.second->desc;
  4976. if (strnicmp(name, message, skillen) == 0 || strnicmp(desc, message, skillen) == 0) {
  4977. sprintf(atcmd_output, msg_txt(sd,1164), skill_id, desc, name); // skill %d: %s (%s)
  4978. clif_displaymessage(fd, atcmd_output);
  4979. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(name,message) || stristr(desc,message) ) ) {
  4980. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), skill_id, desc, name); // // skill %d: %s (%s)
  4981. }
  4982. }
  4983. if( found ) {
  4984. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4985. clif_displaymessage(fd, atcmd_output);
  4986. }
  4987. for(i = 0; i < found; i++) { /* partials */
  4988. clif_displaymessage(fd, partials[i]);
  4989. }
  4990. return 0;
  4991. }
  4992. /*==========================================
  4993. * @useskill by [MouseJstr]
  4994. * A way of using skills without having to find them in the skills menu
  4995. *------------------------------------------*/
  4996. ACMD_FUNC(useskill)
  4997. {
  4998. struct map_session_data *pl_sd = NULL;
  4999. struct block_list *bl;
  5000. uint16 skill_id;
  5001. uint16 skill_lv;
  5002. nullpo_retr(-1, sd);
  5003. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5004. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  5005. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  5006. return -1;
  5007. }
  5008. if (!skill_id || !skill_db.find(skill_id)) {
  5009. clif_displaymessage(fd, msg_txt(sd, 198)); // This skill number doesn't exist.
  5010. return -1;
  5011. }
  5012. if (!skill_lv)
  5013. skill_lv = 1;
  5014. if(!strcmp(atcmd_player_name,"self"))
  5015. pl_sd = sd; //quick keyword
  5016. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
  5017. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5018. return -1;
  5019. }
  5020. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5021. {
  5022. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5023. return -1;
  5024. }
  5025. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5026. bl = &sd->hd->bl;
  5027. else
  5028. bl = &sd->bl;
  5029. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  5030. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  5031. else
  5032. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  5033. return 0;
  5034. }
  5035. /*==========================================
  5036. * @displayskill by [Skotlex]
  5037. * Debug command to locate new skill IDs. It sends the
  5038. * three possible skill-effect packets to the area.
  5039. *------------------------------------------*/
  5040. ACMD_FUNC(displayskill)
  5041. {
  5042. struct status_data * status;
  5043. t_tick tick;
  5044. uint16 skill_id;
  5045. uint16 skill_lv = 1;
  5046. nullpo_retr(-1, sd);
  5047. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  5048. {
  5049. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  5050. return -1;
  5051. }
  5052. status = status_get_status_data(&sd->bl);
  5053. tick = gettick();
  5054. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  5055. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  5056. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  5057. return 0;
  5058. }
  5059. /*==========================================
  5060. * @skilltree by [MouseJstr]
  5061. * prints the skill tree for a player required to get to a skill
  5062. *------------------------------------------*/
  5063. ACMD_FUNC(skilltree)
  5064. {
  5065. struct map_session_data *pl_sd = NULL;
  5066. uint16 skill_id;
  5067. int meets, i, j, c=0;
  5068. struct skill_tree_entry *ent;
  5069. nullpo_retr(-1, sd);
  5070. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5071. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  5072. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  5073. return -1;
  5074. }
  5075. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5076. {
  5077. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5078. return -1;
  5079. }
  5080. i = pc_calc_skilltree_normalize_job(pl_sd);
  5081. c = pc_mapid2jobid(i, pl_sd->status.sex);
  5082. sprintf(atcmd_output, msg_txt(sd,1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  5083. clif_displaymessage(fd, atcmd_output);
  5084. c = pc_class2idx(c);
  5085. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].skill_id == 0 || skill_tree[c][j].skill_id == skill_id );
  5086. if( j == MAX_SKILL_TREE || skill_tree[c][j].skill_id == 0 )
  5087. {
  5088. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5089. return 0;
  5090. }
  5091. ent = &skill_tree[c][j];
  5092. meets = 1;
  5093. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5094. {
  5095. if( ent->need[j].skill_id && pc_checkskill(sd,ent->need[j].skill_id) < ent->need[j].skill_lv)
  5096. {
  5097. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].skill_lv, skill_get_desc(ent->need[j].skill_id)); // Player requires level %d of skill %s.
  5098. clif_displaymessage(fd, atcmd_output);
  5099. meets = 0;
  5100. }
  5101. }
  5102. if (meets == 1) {
  5103. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5104. }
  5105. return 0;
  5106. }
  5107. // Hand a ring with partners name on it to this char
  5108. void getring (struct map_session_data* sd)
  5109. {
  5110. char flag = 0;
  5111. t_itemid item_id;
  5112. struct item item_tmp;
  5113. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5114. memset(&item_tmp, 0, sizeof(item_tmp));
  5115. item_tmp.nameid = item_id;
  5116. item_tmp.identify = 1;
  5117. item_tmp.card[0] = CARD0_FORGE;
  5118. item_tmp.card[2] = sd->status.partner_id;
  5119. item_tmp.card[3] = sd->status.partner_id >> 16;
  5120. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5121. clif_additem(sd,0,0,flag);
  5122. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  5123. }
  5124. }
  5125. /*==========================================
  5126. * @marry by [MouseJstr], fixed by Lupus
  5127. * Marry two players
  5128. *------------------------------------------*/
  5129. ACMD_FUNC(marry)
  5130. {
  5131. struct map_session_data *pl_sd = NULL;
  5132. nullpo_retr(-1, sd);
  5133. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5134. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5135. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5136. return -1;
  5137. }
  5138. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  5139. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5140. return -1;
  5141. }
  5142. if (pc_marriage(sd, pl_sd)) {
  5143. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5144. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5145. if( pl_sd->bl.m != sd->bl.m )
  5146. clif_wedding_effect(&sd->bl);
  5147. getring(sd); // Auto-give named rings (Aru)
  5148. getring(pl_sd);
  5149. return 0;
  5150. }
  5151. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5152. return -1;
  5153. }
  5154. /*==========================================
  5155. * @divorce by [MouseJstr], fixed by [Lupus]
  5156. * divorce two players
  5157. *------------------------------------------*/
  5158. ACMD_FUNC(divorce)
  5159. {
  5160. nullpo_retr(-1, sd);
  5161. if (!pc_divorce(sd)) {
  5162. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5163. clif_displaymessage(fd, atcmd_output);
  5164. return -1;
  5165. }
  5166. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5167. clif_displaymessage(fd, atcmd_output);
  5168. return 0;
  5169. }
  5170. /*==========================================
  5171. * @changelook by [Celest]
  5172. *------------------------------------------*/
  5173. ACMD_FUNC(changelook)
  5174. {
  5175. int i, j = 0, k = 0;
  5176. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5177. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5178. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5179. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5180. return -1;
  5181. } else if ( i == 2 ) {
  5182. if (j < 1 || j > 8)
  5183. j = 1;
  5184. j = pos[j - 1];
  5185. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5186. k = j; // swap
  5187. j = LOOK_HEAD_TOP;
  5188. }
  5189. clif_changelook(&sd->bl,j,k);
  5190. return 0;
  5191. }
  5192. /*==========================================
  5193. * @autotrade by durf [Lupus] [Paradox924X]
  5194. * Turns on/off Autotrade for a specific player
  5195. *------------------------------------------*/
  5196. ACMD_FUNC(autotrade) {
  5197. nullpo_retr(-1, sd);
  5198. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5199. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5200. return -1;
  5201. }
  5202. if( pc_isdead(sd) ) {
  5203. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5204. return -1;
  5205. }
  5206. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5207. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5208. return -1;
  5209. }
  5210. sd->state.autotrade = 1;
  5211. if (battle_config.autotrade_monsterignore)
  5212. sd->state.block_action |= PCBLOCK_IMMUNE;
  5213. if( sd->state.vending ){
  5214. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
  5215. Sql_ShowDebug( mmysql_handle );
  5216. }
  5217. }else if( sd->state.buyingstore ){
  5218. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
  5219. Sql_ShowDebug( mmysql_handle );
  5220. }
  5221. }
  5222. if( battle_config.at_timeout ) {
  5223. int timeout = atoi(message);
  5224. status_change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
  5225. }
  5226. if (battle_config.at_logout_event)
  5227. npc_script_event(sd, NPCE_LOGOUT); //Logout Event
  5228. channel_pcquit(sd,0xF); //leave all chan
  5229. clif_authfail_fd(sd->fd, 15);
  5230. chrif_save(sd, CSAVE_AUTOTRADE);
  5231. return 0;
  5232. }
  5233. /*==========================================
  5234. * @changegm by durf (changed by Lupus)
  5235. * Changes Master of your Guild to a specified guild member
  5236. *------------------------------------------*/
  5237. ACMD_FUNC(changegm)
  5238. {
  5239. struct guild *g;
  5240. struct map_session_data *pl_sd;
  5241. nullpo_retr(-1, sd);
  5242. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5243. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5244. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5245. return -1;
  5246. }
  5247. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5248. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5249. return -1;
  5250. }
  5251. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5252. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5253. return -1;
  5254. }
  5255. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5256. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5257. return -1;
  5258. }
  5259. if( !battle_config.guild_leaderchange_woe && is_agit_start() ){
  5260. #if PACKETVER >= 20151001
  5261. clif_msg(sd, GUILD_MASTER_WOE);
  5262. #else
  5263. clif_displaymessage(fd, msg_txt(sd,1513)); // Currently in WoE hours, unable to delegate Guild leader
  5264. #endif
  5265. return -1;
  5266. }
  5267. if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(NULL),sd->guild->last_leader_change) < battle_config.guild_leaderchange_delay ){
  5268. #if PACKETVER >= 20151001
  5269. clif_msg(sd, GUILD_MASTER_DELAY);
  5270. #else
  5271. clif_displaymessage(fd, msg_txt(sd,1514)); // You have to wait for a while before delegating a new Guild leader
  5272. #endif
  5273. return -1;
  5274. }
  5275. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5276. return 0;
  5277. }
  5278. /*==========================================
  5279. * @changeleader by Skotlex
  5280. * Changes the leader of a party.
  5281. *------------------------------------------*/
  5282. ACMD_FUNC(changeleader)
  5283. {
  5284. nullpo_retr(-1, sd);
  5285. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5286. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5287. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5288. return -1;
  5289. }
  5290. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
  5291. return 0;
  5292. }
  5293. /*==========================================
  5294. * @partyoption by Skotlex
  5295. * Used to change the item share setting of a party.
  5296. *------------------------------------------*/
  5297. ACMD_FUNC(partyoption)
  5298. {
  5299. struct party_data *p;
  5300. int mi, option;
  5301. char w1[16], w2[16];
  5302. nullpo_retr(-1, sd);
  5303. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5304. {
  5305. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5306. return -1;
  5307. }
  5308. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5309. if (mi == MAX_PARTY)
  5310. return -1; //Shouldn't happen
  5311. if (!p->party.member[mi].leader)
  5312. {
  5313. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5314. return -1;
  5315. }
  5316. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5317. {
  5318. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5319. return -1;
  5320. }
  5321. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5322. //Change item share type.
  5323. if (option != p->party.item)
  5324. party_changeoption(sd, p->party.exp, option);
  5325. else
  5326. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5327. return 0;
  5328. }
  5329. /*==========================================
  5330. * @autoloot by Upa-Kun
  5331. * Turns on/off AutoLoot for a specific player
  5332. *------------------------------------------*/
  5333. ACMD_FUNC(autoloot)
  5334. {
  5335. int rate;
  5336. nullpo_retr(-1, sd);
  5337. // autoloot command without value
  5338. if(!message || !*message)
  5339. {
  5340. if (sd->state.autoloot)
  5341. rate = 0;
  5342. else
  5343. rate = 10000;
  5344. } else {
  5345. double drate;
  5346. drate = atof(message);
  5347. rate = (int)(drate*100);
  5348. }
  5349. if (rate < 0) rate = 0;
  5350. if (rate > 10000) rate = 10000;
  5351. sd->state.autoloot = rate;
  5352. if (sd->state.autoloot) {
  5353. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  5354. clif_displaymessage(fd, atcmd_output);
  5355. }else
  5356. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5357. return 0;
  5358. }
  5359. /*==========================================
  5360. * @alootid
  5361. *------------------------------------------*/
  5362. ACMD_FUNC(autolootitem)
  5363. {
  5364. struct item_data *item_data = NULL;
  5365. int i;
  5366. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5367. nullpo_retr(-1, sd);
  5368. if (message && *message) {
  5369. if (message[0] == '+') {
  5370. message++;
  5371. action = 1;
  5372. }
  5373. else if (message[0] == '-') {
  5374. message++;
  5375. action = 2;
  5376. }
  5377. else if (!strcmp(message,"reset"))
  5378. action = 4;
  5379. }
  5380. if (action < 3) // add or remove
  5381. {
  5382. if ((item_data = itemdb_exists(strtoul(message, nullptr, 10))) == nullptr)
  5383. item_data = itemdb_searchname(message);
  5384. if (!item_data) {
  5385. // No items founds in the DB with Id or Name
  5386. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5387. return -1;
  5388. }
  5389. }
  5390. switch(action) {
  5391. case 1:
  5392. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5393. if (i != AUTOLOOTITEM_SIZE) {
  5394. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5395. return -1;
  5396. }
  5397. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5398. if (i == AUTOLOOTITEM_SIZE) {
  5399. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5400. return -1;
  5401. }
  5402. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5403. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name.c_str(), item_data->ename.c_str(), item_data->nameid); // Autolooting item: '%s'/'%s' {%u}
  5404. clif_displaymessage(fd, atcmd_output);
  5405. sd->state.autolooting = 1;
  5406. break;
  5407. case 2:
  5408. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5409. if (i == AUTOLOOTITEM_SIZE) {
  5410. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5411. return -1;
  5412. }
  5413. sd->state.autolootid[i] = 0;
  5414. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name.c_str(), item_data->ename.c_str(), item_data->nameid); // Removed item: '%s'/'%s' {%u} from your autolootitem list.
  5415. clif_displaymessage(fd, atcmd_output);
  5416. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5417. if (i == AUTOLOOTITEM_SIZE) {
  5418. sd->state.autolooting = 0;
  5419. }
  5420. break;
  5421. case 3:
  5422. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5423. clif_displaymessage(fd, atcmd_output);
  5424. clif_displaymessage(fd, msg_txt(sd,1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  5425. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5426. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5427. if (i == AUTOLOOTITEM_SIZE) {
  5428. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5429. } else {
  5430. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5431. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5432. {
  5433. if (sd->state.autolootid[i] == 0)
  5434. continue;
  5435. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5436. 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);
  5437. continue;
  5438. }
  5439. sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_data->ename.c_str(), item_data->nameid);
  5440. clif_displaymessage(fd, atcmd_output);
  5441. }
  5442. }
  5443. break;
  5444. case 4:
  5445. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5446. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5447. sd->state.autolooting = 0;
  5448. break;
  5449. }
  5450. return 0;
  5451. }
  5452. /*==========================================
  5453. * @autoloottype
  5454. * Flags:
  5455. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5456. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5457. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5458. * 262144: IT_CASH
  5459. *------------------------------------------
  5460. * Credits:
  5461. * chriser
  5462. * Aleos
  5463. *------------------------------------------*/
  5464. ACMD_FUNC(autoloottype)
  5465. {
  5466. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5467. enum item_types type= IT_UNKNOWN;
  5468. int ITEM_MAX = 1533;
  5469. nullpo_retr(-1, sd);
  5470. if (message && *message) {
  5471. if (message[0] == '+') {
  5472. message++;
  5473. action = 1;
  5474. }
  5475. else if (message[0] == '-') {
  5476. message++;
  5477. action = 2;
  5478. }
  5479. else if (!strcmp(message,"reset"))
  5480. action = 4;
  5481. }
  5482. if (action < 3) { // add or remove
  5483. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5484. type = IT_HEALING;
  5485. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5486. type = IT_USABLE;
  5487. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5488. type = IT_ETC;
  5489. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5490. type = IT_ARMOR;
  5491. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5492. type = IT_WEAPON;
  5493. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5494. type = IT_CARD;
  5495. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5496. type = IT_PETEGG;
  5497. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5498. type = IT_PETARMOR;
  5499. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5500. type = IT_AMMO;
  5501. else {
  5502. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5503. return -1;
  5504. }
  5505. }
  5506. switch (action) {
  5507. case 1:
  5508. if (sd->state.autoloottype&(1<<type)) {
  5509. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5510. return -1;
  5511. }
  5512. if (sd->state.autoloottype == ITEM_MAX) {
  5513. clif_displaymessage(fd, msg_txt(sd,1482)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -<type name or ID>.
  5514. return -1;
  5515. }
  5516. sd->state.autoloottype |= (1<<type); // Stores the type
  5517. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%u}
  5518. clif_displaymessage(fd, atcmd_output);
  5519. break;
  5520. case 2:
  5521. if (!(sd->state.autoloottype&(1<<type))) {
  5522. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5523. return -1;
  5524. }
  5525. sd->state.autoloottype &= ~(1<<type);
  5526. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%u} from your autoloottype list.
  5527. clif_displaymessage(fd, atcmd_output);
  5528. break;
  5529. case 3:
  5530. clif_displaymessage(fd, msg_txt(sd,1486)); // To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>".
  5531. clif_displaymessage(fd, msg_txt(sd,1487)); // Type List: healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
  5532. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5533. if (sd->state.autoloottype == 0)
  5534. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5535. else {
  5536. uint8 i = 0;
  5537. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5538. while (i < IT_MAX) {
  5539. if (sd->state.autoloottype&(1<<i)) {
  5540. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5541. clif_displaymessage(fd, atcmd_output);
  5542. }
  5543. i++;
  5544. }
  5545. }
  5546. break;
  5547. case 4:
  5548. sd->state.autoloottype = 0;
  5549. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5550. break;
  5551. }
  5552. return 0;
  5553. }
  5554. /*==========================================
  5555. * It is made to rain.
  5556. * No longer available, keeping here just in case it's back someday. [Ind]
  5557. *------------------------------------------*/
  5558. //ACMD_FUNC(rain)
  5559. //{
  5560. // nullpo_retr(-1, sd);
  5561. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5562. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5563. // clif_weather(sd->bl.m);
  5564. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5565. // } else {
  5566. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5567. // clif_weather(sd->bl.m);
  5568. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5569. // }
  5570. // return 0;
  5571. //}
  5572. /*==========================================
  5573. * It is made to snow.
  5574. *------------------------------------------*/
  5575. ACMD_FUNC(snow)
  5576. {
  5577. nullpo_retr(-1, sd);
  5578. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5579. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5580. clif_weather(sd->bl.m);
  5581. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5582. } else {
  5583. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5584. clif_weather(sd->bl.m);
  5585. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5586. }
  5587. return 0;
  5588. }
  5589. /*==========================================
  5590. * Cherry tree snowstorm is made to fall. (Sakura)
  5591. *------------------------------------------*/
  5592. ACMD_FUNC(sakura)
  5593. {
  5594. nullpo_retr(-1, sd);
  5595. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5596. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5597. clif_weather(sd->bl.m);
  5598. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5599. } else {
  5600. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  5601. clif_weather(sd->bl.m);
  5602. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5603. }
  5604. return 0;
  5605. }
  5606. /*==========================================
  5607. * Clouds appear.
  5608. *------------------------------------------*/
  5609. ACMD_FUNC(clouds)
  5610. {
  5611. nullpo_retr(-1, sd);
  5612. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  5613. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5614. clif_weather(sd->bl.m);
  5615. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5616. } else {
  5617. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  5618. clif_weather(sd->bl.m);
  5619. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5620. }
  5621. return 0;
  5622. }
  5623. /*==========================================
  5624. * Different type of clouds using effect 516
  5625. *------------------------------------------*/
  5626. ACMD_FUNC(clouds2)
  5627. {
  5628. nullpo_retr(-1, sd);
  5629. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  5630. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5631. clif_weather(sd->bl.m);
  5632. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5633. } else {
  5634. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  5635. clif_weather(sd->bl.m);
  5636. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5637. }
  5638. return 0;
  5639. }
  5640. /*==========================================
  5641. * Fog hangs over.
  5642. *------------------------------------------*/
  5643. ACMD_FUNC(fog)
  5644. {
  5645. nullpo_retr(-1, sd);
  5646. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  5647. map_setmapflag(sd->bl.m, MF_FOG, false);
  5648. clif_weather(sd->bl.m);
  5649. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5650. } else {
  5651. map_setmapflag(sd->bl.m, MF_FOG, true);
  5652. clif_weather(sd->bl.m);
  5653. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5654. }
  5655. return 0;
  5656. }
  5657. /*==========================================
  5658. * Fallen leaves fall.
  5659. *------------------------------------------*/
  5660. ACMD_FUNC(leaves)
  5661. {
  5662. nullpo_retr(-1, sd);
  5663. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  5664. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5665. clif_weather(sd->bl.m);
  5666. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5667. } else {
  5668. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  5669. clif_weather(sd->bl.m);
  5670. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5671. }
  5672. return 0;
  5673. }
  5674. /*==========================================
  5675. * Fireworks appear.
  5676. *------------------------------------------*/
  5677. ACMD_FUNC(fireworks)
  5678. {
  5679. nullpo_retr(-1, sd);
  5680. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  5681. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5682. clif_weather(sd->bl.m);
  5683. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5684. } else {
  5685. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  5686. clif_weather(sd->bl.m);
  5687. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5688. }
  5689. return 0;
  5690. }
  5691. /*==========================================
  5692. * Clearing Weather Effects by Dexity
  5693. *------------------------------------------*/
  5694. ACMD_FUNC(clearweather)
  5695. {
  5696. nullpo_retr(-1, sd);
  5697. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  5698. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5699. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5700. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5701. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5702. map_setmapflag(sd->bl.m, MF_FOG, false);
  5703. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5704. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5705. clif_weather(sd->bl.m);
  5706. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  5707. return 0;
  5708. }
  5709. /*===============================================================
  5710. * Sound Command - plays a sound for everyone around! [Codemaster]
  5711. *---------------------------------------------------------------*/
  5712. ACMD_FUNC(sound)
  5713. {
  5714. char sound_file[100];
  5715. memset(sound_file, '\0', sizeof(sound_file));
  5716. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5717. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5718. return -1;
  5719. }
  5720. if(strstr(sound_file, ".wav") == NULL)
  5721. strcat(sound_file, ".wav");
  5722. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5723. return 0;
  5724. }
  5725. /*==========================================
  5726. * MOB Search
  5727. *------------------------------------------*/
  5728. ACMD_FUNC(mobsearch)
  5729. {
  5730. nullpo_retr(-1, sd);
  5731. char mob_name[100]={0};
  5732. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5733. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5734. return -1;
  5735. }
  5736. int mob_id = strtol(mob_name, nullptr, 10);
  5737. if (mob_id == 0)
  5738. mob_id = mobdb_searchname(mob_name);
  5739. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  5740. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  5741. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5742. clif_displaymessage(fd, atcmd_output);
  5743. return -1;
  5744. }
  5745. strcpy(mob_name, mob->jname.c_str()); // --ja--
  5746. // strcpy(mob_name, mob->name.c_str()); // --en--
  5747. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5748. clif_displaymessage(fd, atcmd_output);
  5749. s_mapiterator* it = mapit_geteachmob();
  5750. int number = 0;
  5751. for(;;)
  5752. {
  5753. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5754. if( md == NULL )
  5755. break;// no more mobs
  5756. if( md->bl.m != sd->bl.m )
  5757. continue;
  5758. if( md->mob_id != mob_id )
  5759. continue;
  5760. ++number;
  5761. if( md->spawn_timer == INVALID_TIMER )
  5762. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5763. else
  5764. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5765. clif_displaymessage(fd, atcmd_output);
  5766. }
  5767. mapit_free(it);
  5768. return 0;
  5769. }
  5770. /*==========================================
  5771. * @cleanmap - cleans items on the ground
  5772. * @cleanarea - cleans items on the ground within an specified area
  5773. *------------------------------------------*/
  5774. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5775. {
  5776. nullpo_ret(bl);
  5777. map_clearflooritem(bl);
  5778. return 0;
  5779. }
  5780. ACMD_FUNC(cleanmap)
  5781. {
  5782. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5783. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5784. return 0;
  5785. }
  5786. ACMD_FUNC(cleanarea)
  5787. {
  5788. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5789. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5790. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
  5791. }
  5792. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5793. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
  5794. }
  5795. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5796. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5797. }
  5798. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5799. return 0;
  5800. }
  5801. /*==========================================
  5802. * make a NPC/PET talk
  5803. * @npctalkc [SnakeDrak]
  5804. *------------------------------------------*/
  5805. ACMD_FUNC(npctalk)
  5806. {
  5807. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  5808. struct npc_data *nd;
  5809. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5810. unsigned long color=0;
  5811. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  5812. return -1; //no "chatting" while muted.
  5813. if(!ifcolor) {
  5814. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  5815. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5816. return -1;
  5817. }
  5818. }
  5819. else {
  5820. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5821. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5822. return -1;
  5823. }
  5824. }
  5825. if (!(nd = npc_name2id(name))) {
  5826. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5827. return -1;
  5828. }
  5829. strtok(name, "#"); // discard extra name identifier if present
  5830. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5831. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  5832. else clif_disp_overhead(&nd->bl, temp);
  5833. return 0;
  5834. }
  5835. ACMD_FUNC(pettalk)
  5836. {
  5837. char mes[100],temp[CHAT_SIZE_MAX];
  5838. struct pet_data *pd;
  5839. nullpo_retr(-1, sd);
  5840. if ( battle_config.min_chat_delay ) {
  5841. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5842. return 0;
  5843. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5844. }
  5845. if(!sd->status.pet_id || !(pd=sd->pd))
  5846. {
  5847. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  5848. return -1;
  5849. }
  5850. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  5851. return -1; //no "chatting" while muted.
  5852. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5853. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5854. return -1;
  5855. }
  5856. if (message[0] == '/')
  5857. {// pet emotion processing
  5858. const char* emo[] = {
  5859. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5860. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5861. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5862. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5863. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5864. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5865. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5866. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5867. "/whisp"
  5868. };
  5869. int i;
  5870. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5871. if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
  5872. if( i < ARRAYLENGTH(emo) )
  5873. {
  5874. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5875. sd->emotionlasttime = time(NULL);
  5876. return 0;
  5877. }
  5878. sd->emotionlasttime = time(NULL);
  5879. clif_emotion(&pd->bl, i);
  5880. return 0;
  5881. }
  5882. }
  5883. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5884. clif_disp_overhead(&pd->bl, temp);
  5885. return 0;
  5886. }
  5887. /// @users - displays the number of players present on each map (and percentage)
  5888. /// #users displays on the target user instead of self
  5889. ACMD_FUNC(users)
  5890. {
  5891. char buf[CHAT_SIZE_MAX];
  5892. int i;
  5893. int users[MAX_MAPINDEX];
  5894. int users_all;
  5895. struct s_mapiterator* iter;
  5896. memset(users, 0, sizeof(users));
  5897. users_all = 0;
  5898. // count users on each map
  5899. iter = mapit_getallusers();
  5900. for(;;)
  5901. {
  5902. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5903. if( sd2 == NULL )
  5904. break;// no more users
  5905. if( sd2->mapindex >= MAX_MAPINDEX )
  5906. continue;// invalid mapindex
  5907. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5908. if( users_all < INT_MAX ) ++users_all;
  5909. }
  5910. mapit_free(iter);
  5911. // display results for each map
  5912. for( i = 0; i < MAX_MAPINDEX; ++i )
  5913. {
  5914. if( users[i] == 0 )
  5915. continue;// empty
  5916. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5917. clif_displaymessage(sd->fd, buf);
  5918. }
  5919. // display overall count
  5920. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5921. clif_displaymessage(sd->fd, buf);
  5922. return 0;
  5923. }
  5924. /*==========================================
  5925. *
  5926. *------------------------------------------*/
  5927. ACMD_FUNC(reset)
  5928. {
  5929. pc_resetstate(sd);
  5930. pc_resetskill(sd,1);
  5931. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5932. clif_displaymessage(fd, atcmd_output);
  5933. return 0;
  5934. }
  5935. /*==========================================
  5936. *
  5937. *------------------------------------------*/
  5938. ACMD_FUNC(summon)
  5939. {
  5940. char name[NAME_LENGTH];
  5941. int mob_id = 0;
  5942. int duration = 0;
  5943. struct mob_data *md;
  5944. t_tick tick=gettick();
  5945. nullpo_retr(-1, sd);
  5946. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5947. {
  5948. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5949. return -1;
  5950. }
  5951. if (duration < 1)
  5952. duration =1;
  5953. else if (duration > 60)
  5954. duration =60;
  5955. if ((mob_id = atoi(name)) == 0)
  5956. mob_id = mobdb_searchname(name);
  5957. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5958. {
  5959. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5960. return -1;
  5961. }
  5962. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5963. if(!md)
  5964. return -1;
  5965. md->master_id=sd->bl.id;
  5966. md->special_state.ai=AI_ATTACK;
  5967. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5968. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  5969. mob_spawn(md);
  5970. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5971. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5972. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5973. return 0;
  5974. }
  5975. /*==========================================
  5976. * @adjgroup
  5977. * Temporarily move player to another group
  5978. * Useful during beta testing to allow players to use GM commands for short periods of time
  5979. *------------------------------------------*/
  5980. ACMD_FUNC(adjgroup)
  5981. {
  5982. int new_group = 0;
  5983. nullpo_retr(-1, sd);
  5984. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5985. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5986. return -1;
  5987. }
  5988. if (!pc_group_exists(new_group)) {
  5989. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5990. return -1;
  5991. }
  5992. sd->group_id = new_group;
  5993. pc_group_pc_load(sd);/* update cache */
  5994. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5995. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5996. return 0;
  5997. }
  5998. /*==========================================
  5999. * @trade by [MouseJstr]
  6000. * Open a trade window with a remote player
  6001. *------------------------------------------*/
  6002. ACMD_FUNC(trade)
  6003. {
  6004. struct map_session_data *pl_sd = NULL;
  6005. nullpo_retr(-1, sd);
  6006. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6007. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6008. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  6009. return -1;
  6010. }
  6011. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  6012. {
  6013. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6014. return -1;
  6015. }
  6016. trade_traderequest(sd, pl_sd);
  6017. return 0;
  6018. }
  6019. /*==========================================
  6020. * @setbattleflag by [MouseJstr]
  6021. * set a battle_config flag without having to reboot
  6022. *------------------------------------------*/
  6023. ACMD_FUNC(setbattleflag)
  6024. {
  6025. char flag[128], value[128];
  6026. int reload = 0;
  6027. nullpo_retr(-1, sd);
  6028. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
  6029. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  6030. return -1;
  6031. }
  6032. if (battle_set_value(flag, value) == 0)
  6033. {
  6034. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  6035. return -1;
  6036. }
  6037. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  6038. if (reload)
  6039. mob_reload();
  6040. return 0;
  6041. }
  6042. /*==========================================
  6043. * @unmute [Valaris]
  6044. *------------------------------------------*/
  6045. ACMD_FUNC(unmute)
  6046. {
  6047. struct map_session_data *pl_sd = NULL;
  6048. nullpo_retr(-1, sd);
  6049. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6050. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6051. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6052. return -1;
  6053. }
  6054. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6055. {
  6056. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6057. return -1;
  6058. }
  6059. if(!pl_sd->sc.data[SC_NOCHAT]) {
  6060. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6061. return -1;
  6062. }
  6063. pl_sd->status.manner = 0;
  6064. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6065. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6066. return 0;
  6067. }
  6068. /*==========================================
  6069. * @uptime by MC Cameri
  6070. *------------------------------------------*/
  6071. ACMD_FUNC(uptime)
  6072. {
  6073. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6074. minute = 60, days = 0, hours = 0, minutes = 0;
  6075. nullpo_retr(-1, sd);
  6076. seconds = get_uptime();
  6077. days = seconds/day;
  6078. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6079. hours = seconds/hour;
  6080. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6081. minutes = seconds/minute;
  6082. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6083. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  6084. clif_displaymessage(fd, atcmd_output);
  6085. return 0;
  6086. }
  6087. /*==========================================
  6088. * @changesex
  6089. * => Changes one's account sex. Switch from male to female or visversa
  6090. *------------------------------------------*/
  6091. ACMD_FUNC(changesex)
  6092. {
  6093. int i;
  6094. nullpo_retr(-1, sd);
  6095. pc_resetskill(sd,4);
  6096. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6097. for (i = 0; i < EQI_MAX; i++) {
  6098. if (sd->equip_index[i] >= 0)
  6099. pc_unequipitem(sd, sd->equip_index[i], 3);
  6100. }
  6101. chrif_changesex(sd, true);
  6102. return 0;
  6103. }
  6104. /*==========================================
  6105. * @changecharsex
  6106. * => Changes one's character sex. Switch from male to female or visversa.
  6107. *------------------------------------------*/
  6108. ACMD_FUNC(changecharsex)
  6109. {
  6110. int i;
  6111. nullpo_retr(-1, sd);
  6112. pc_resetskill(sd,4);
  6113. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6114. for (i = 0; i < EQI_MAX; i++) {
  6115. if (sd->equip_index[i] >= 0)
  6116. pc_unequipitem(sd, sd->equip_index[i], 3);
  6117. }
  6118. chrif_changesex(sd, false);
  6119. return 0;
  6120. }
  6121. /*================================================
  6122. * @mute - Mutes a player for a set amount of time
  6123. *------------------------------------------------*/
  6124. ACMD_FUNC(mute)
  6125. {
  6126. struct map_session_data *pl_sd = NULL;
  6127. int manner;
  6128. nullpo_retr(-1, sd);
  6129. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6130. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6131. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6132. return -1;
  6133. }
  6134. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6135. {
  6136. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6137. return -1;
  6138. }
  6139. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6140. {
  6141. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6142. return -1;
  6143. }
  6144. clif_manner_message(sd, 0);
  6145. clif_manner_message(pl_sd, 5);
  6146. if( pl_sd->status.manner < manner ) {
  6147. pl_sd->status.manner -= manner;
  6148. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6149. } else {
  6150. pl_sd->status.manner = 0;
  6151. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6152. }
  6153. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6154. return 0;
  6155. }
  6156. /*==========================================
  6157. * @refresh (like @jumpto <<yourself>>)
  6158. *------------------------------------------*/
  6159. ACMD_FUNC(refresh)
  6160. {
  6161. nullpo_retr(-1, sd);
  6162. clif_refresh(sd);
  6163. return 0;
  6164. }
  6165. ACMD_FUNC(refreshall)
  6166. {
  6167. struct map_session_data* iter_sd;
  6168. struct s_mapiterator* iter;
  6169. nullpo_retr(-1, sd);
  6170. iter = mapit_getallusers();
  6171. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6172. clif_refresh(iter_sd);
  6173. mapit_free(iter);
  6174. return 0;
  6175. }
  6176. /*==========================================
  6177. * @identify
  6178. * => GM's magnifier.
  6179. *------------------------------------------*/
  6180. ACMD_FUNC(identify)
  6181. {
  6182. int i,num;
  6183. nullpo_retr(-1, sd);
  6184. for(i=num=0;i<MAX_INVENTORY;i++){
  6185. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6186. num++;
  6187. }
  6188. }
  6189. if (num > 0) {
  6190. clif_item_identify_list(sd);
  6191. } else {
  6192. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6193. }
  6194. return 0;
  6195. }
  6196. /*===============================================
  6197. * @identifyall
  6198. * => Indentify all items in inventory - Akinari
  6199. *-----------------------------------------------*/
  6200. ACMD_FUNC(identifyall)
  6201. {
  6202. nullpo_retr(-1, sd);
  6203. pc_identifyall(sd, true);
  6204. return 0;
  6205. }
  6206. /*==========================================
  6207. * @gmotd (Global MOTD)
  6208. * by davidsiaw :P
  6209. *------------------------------------------*/
  6210. ACMD_FUNC(gmotd)
  6211. {
  6212. FILE* fp;
  6213. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6214. {
  6215. char buf[CHAT_SIZE_MAX];
  6216. size_t len;
  6217. while( fgets(buf, sizeof(buf), fp) )
  6218. {
  6219. if( buf[0] == '/' && buf[1] == '/' )
  6220. {
  6221. continue;
  6222. }
  6223. len = strlen(buf);
  6224. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6225. {// strip trailing EOL characters
  6226. len--;
  6227. }
  6228. if( len )
  6229. {
  6230. buf[len] = 0;
  6231. intif_broadcast(buf, len+1, 0);
  6232. }
  6233. }
  6234. fclose(fp);
  6235. }
  6236. return 0;
  6237. }
  6238. ACMD_FUNC(misceffect)
  6239. {
  6240. int effect = 0;
  6241. nullpo_retr(-1, sd);
  6242. if (!message || !*message)
  6243. return -1;
  6244. if (sscanf(message, "%11d", &effect) < 1)
  6245. return -1;
  6246. clif_misceffect(&sd->bl,effect);
  6247. return 0;
  6248. }
  6249. /*==========================================
  6250. * MAIL SYSTEM
  6251. *------------------------------------------*/
  6252. ACMD_FUNC(mail)
  6253. {
  6254. nullpo_ret(sd);
  6255. mail_openmail(sd);
  6256. return 0;
  6257. }
  6258. /*==========================================
  6259. * Show Monster DB Info v 1.0
  6260. * originally by [Lupus]
  6261. *------------------------------------------*/
  6262. ACMD_FUNC(mobinfo)
  6263. {
  6264. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6265. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6266. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6267. char atcmd_output2[CHAT_SIZE_MAX];
  6268. struct item_data *item_data;
  6269. uint16 mob_ids[MAX_SEARCH];
  6270. int count;
  6271. int i, k;
  6272. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6273. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6274. if (!message || !*message) {
  6275. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6276. return -1;
  6277. }
  6278. // If monster identifier/name argument is a name
  6279. if ((i = mobdb_checkid(atoi(message))))
  6280. {
  6281. mob_ids[0] = i;
  6282. count = 1;
  6283. } else
  6284. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6285. if (!count) {
  6286. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6287. return -1;
  6288. }
  6289. if (count >= MAX_SEARCH) {
  6290. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6291. clif_displaymessage(fd, atcmd_output);
  6292. count = MAX_SEARCH;
  6293. }
  6294. for (k = 0; k < count; k++) {
  6295. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_ids[k]);
  6296. if (mob == nullptr)
  6297. continue;
  6298. t_exp base_exp = mob->base_exp;
  6299. t_exp job_exp = mob->job_exp;
  6300. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6301. base_exp += (base_exp * battle_config.vip_base_exp_increase) / 100;
  6302. job_exp += (job_exp * battle_config.vip_job_exp_increase) / 100;
  6303. }
  6304. #ifdef RENEWAL_EXP
  6305. if( battle_config.atcommand_mobinfo_type ) {
  6306. int penalty = pc_level_penalty_mod( sd, PENALTY_EXP, mob );
  6307. base_exp = base_exp * penalty / 100;
  6308. job_exp = job_exp * penalty / 100;
  6309. }
  6310. #endif
  6311. // stats
  6312. if( mob->get_bosstype() == BOSSTYPE_MVP )
  6313. sprintf(atcmd_output, msg_txt(sd,1240), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6314. else
  6315. sprintf(atcmd_output, msg_txt(sd,1241), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6316. clif_displaymessage(fd, atcmd_output);
  6317. sprintf(atcmd_output, msg_txt(sd,1242), mob->lv, mob->status.max_hp, base_exp, job_exp, MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%llu Job EXP:%llu HIT:%d FLEE:%d
  6318. clif_displaymessage(fd, atcmd_output);
  6319. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6320. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6321. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6322. clif_displaymessage(fd, atcmd_output);
  6323. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6324. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6325. mob->range2 , mob->range3, msize[mob->status.size],
  6326. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6327. clif_displaymessage(fd, atcmd_output);
  6328. // drops
  6329. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6330. strcpy(atcmd_output, " ");
  6331. unsigned int j = 0;
  6332. #ifdef RENEWAL_DROP
  6333. int penalty = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
  6334. #endif
  6335. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6336. int droprate;
  6337. if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].rate < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6338. continue;
  6339. droprate = mob->dropitem[i].rate;
  6340. #ifdef RENEWAL_DROP
  6341. if( battle_config.atcommand_mobinfo_type ) {
  6342. droprate = droprate * penalty / 100;
  6343. if (droprate <= 0 && !battle_config.drop_rate0item)
  6344. droprate = 1;
  6345. }
  6346. #endif
  6347. if (pc_isvip(sd)) // Display drop rate increase for VIP
  6348. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6349. if (item_data->slots)
  6350. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->ename.c_str(), item_data->slots, (float)droprate / 100);
  6351. else
  6352. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->ename.c_str(), (float)droprate / 100);
  6353. strcat(atcmd_output, atcmd_output2);
  6354. if (++j % 3 == 0) {
  6355. clif_displaymessage(fd, atcmd_output);
  6356. strcpy(atcmd_output, " ");
  6357. }
  6358. }
  6359. if (j == 0)
  6360. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6361. else if (j % 3 != 0)
  6362. clif_displaymessage(fd, atcmd_output);
  6363. // mvp
  6364. if( mob->get_bosstype() == BOSSTYPE_MVP ){
  6365. float mvppercent, mvpremain;
  6366. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%llu
  6367. clif_displaymessage(fd, atcmd_output);
  6368. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6369. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6370. j = 0;
  6371. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6372. if (mob->mvpitem[i].nameid == 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6373. continue;
  6374. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6375. mvppercent = (float)mob->mvpitem[i].rate * mvpremain / 10000.0f;
  6376. if(battle_config.item_drop_mvp_mode == 0) {
  6377. mvpremain -= mvppercent;
  6378. }
  6379. if (mvppercent > 0) {
  6380. j++;
  6381. if (j == 1) {
  6382. if (item_data->slots)
  6383. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->ename.c_str(), item_data->slots, mvppercent);
  6384. else
  6385. sprintf(atcmd_output2, " %s %02.02f%%", item_data->ename.c_str(), mvppercent);
  6386. } else {
  6387. if (item_data->slots)
  6388. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->ename.c_str(), item_data->slots, mvppercent);
  6389. else
  6390. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->ename.c_str(), mvppercent);
  6391. }
  6392. strcat(atcmd_output, atcmd_output2);
  6393. }
  6394. }
  6395. if (j == 0)
  6396. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6397. else
  6398. clif_displaymessage(fd, atcmd_output);
  6399. }
  6400. }
  6401. return 0;
  6402. }
  6403. /*=========================================
  6404. * @showmobs by KarLaeda
  6405. * => For 15 sec displays the mobs on minimap
  6406. *------------------------------------------*/
  6407. ACMD_FUNC(showmobs)
  6408. {
  6409. char mob_name[100];
  6410. int mob_id;
  6411. int number = 0;
  6412. struct s_mapiterator* it;
  6413. nullpo_retr(-1, sd);
  6414. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6415. return -1;
  6416. if((mob_id = strtol(mob_name, nullptr, 10)) == 0)
  6417. mob_id = mobdb_searchname(mob_name);
  6418. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6419. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6420. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6421. clif_displaymessage(fd, atcmd_output);
  6422. return 0;
  6423. }
  6424. if(status_has_mode(&mob->status,MD_STATUSIMMUNE) && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6425. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6426. return 0;
  6427. }
  6428. if(mob_id == strtol(mob_name, nullptr, 10) && !mob->jname.empty())
  6429. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6430. //strcpy(mob_name, mob->name.c_str()); // --en--
  6431. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6432. mob_name, mapindex_id2name(sd->mapindex));
  6433. clif_displaymessage(fd, atcmd_output);
  6434. it = mapit_geteachmob();
  6435. for(;;)
  6436. {
  6437. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6438. if( md == NULL )
  6439. break;// no more mobs
  6440. if( md->bl.m != sd->bl.m )
  6441. continue;
  6442. if( mob_id != -1 && md->mob_id != mob_id )
  6443. continue;
  6444. if( md->special_state.ai || md->master_id )
  6445. continue; // hide slaves and player summoned mobs
  6446. if( md->spawn_timer != INVALID_TIMER )
  6447. continue; // hide mobs waiting for respawn
  6448. ++number;
  6449. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6450. }
  6451. mapit_free(it);
  6452. return 0;
  6453. }
  6454. /*==========================================
  6455. * homunculus level up [orn]
  6456. *------------------------------------------*/
  6457. ACMD_FUNC(homlevel)
  6458. {
  6459. TBL_HOM * hd;
  6460. int level = 0, i = 0;
  6461. nullpo_retr(-1, sd);
  6462. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6463. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6464. return -1;
  6465. }
  6466. if ( !hom_is_active(sd->hd) ) {
  6467. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6468. return -1;
  6469. }
  6470. hd = sd->hd;
  6471. for (i = 1; i <= level && hd->exp_next; i++){
  6472. hd->homunculus.exp += hd->exp_next;
  6473. if( !hom_levelup(hd) )
  6474. break;
  6475. }
  6476. status_calc_homunculus(hd, SCO_NONE);
  6477. status_percent_heal(&hd->bl, 100, 100);
  6478. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6479. return 0;
  6480. }
  6481. /*==========================================
  6482. * homunculus evolution H [orn]
  6483. *------------------------------------------*/
  6484. ACMD_FUNC(homevolution)
  6485. {
  6486. nullpo_retr(-1, sd);
  6487. if ( !hom_is_active(sd->hd) ) {
  6488. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6489. return -1;
  6490. }
  6491. if ( !hom_evolution(sd->hd) ) {
  6492. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6493. return -1;
  6494. }
  6495. clif_homskillinfoblock(sd);
  6496. return 0;
  6497. }
  6498. ACMD_FUNC(hommutate)
  6499. {
  6500. int homun_id, m_class = 0, m_id;
  6501. nullpo_retr(-1, sd);
  6502. if (!hom_is_active(sd->hd)) {
  6503. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6504. return -1;
  6505. }
  6506. if (!message || !*message) {
  6507. homun_id = 6048 + (rnd() % 4);
  6508. } else {
  6509. homun_id = atoi(message);
  6510. }
  6511. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6512. m_id = hom_class2mapid(homun_id);
  6513. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6514. hom_mutate(sd->hd, homun_id);
  6515. } else {
  6516. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6517. }
  6518. return 0;
  6519. }
  6520. /*==========================================
  6521. * call choosen homunculus [orn]
  6522. *------------------------------------------*/
  6523. ACMD_FUNC(makehomun)
  6524. {
  6525. int homunid;
  6526. nullpo_retr(-1, sd);
  6527. if ( sd->status.hom_id ) {
  6528. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6529. return -1;
  6530. }
  6531. if (!message || !*message) {
  6532. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6533. return -1;
  6534. }
  6535. homunid = atoi(message);
  6536. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6537. {
  6538. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6539. return -1;
  6540. }
  6541. hom_create_request(sd,homunid);
  6542. return 0;
  6543. }
  6544. /*==========================================
  6545. * modify homunculus intimacy [orn]
  6546. *------------------------------------------*/
  6547. ACMD_FUNC(homfriendly)
  6548. {
  6549. int friendly = 0;
  6550. nullpo_retr(-1, sd);
  6551. if ( !hom_is_active(sd->hd) ) {
  6552. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6553. return -1;
  6554. }
  6555. if (!message || !*message) {
  6556. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6557. return -1;
  6558. }
  6559. friendly = atoi(message);
  6560. friendly = cap_value(friendly, 0, 1000);
  6561. sd->hd->homunculus.intimacy = friendly * 100 ;
  6562. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6563. return 0;
  6564. }
  6565. /*==========================================
  6566. * modify homunculus hunger [orn]
  6567. *------------------------------------------*/
  6568. ACMD_FUNC(homhungry)
  6569. {
  6570. int hungry = 0;
  6571. nullpo_retr(-1, sd);
  6572. if ( !hom_is_active(sd->hd) ) {
  6573. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6574. return -1;
  6575. }
  6576. if (!message || !*message) {
  6577. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6578. return -1;
  6579. }
  6580. hungry = atoi(message);
  6581. hungry = cap_value(hungry, 0, 100);
  6582. sd->hd->homunculus.hunger = hungry;
  6583. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6584. return 0;
  6585. }
  6586. /*==========================================
  6587. * make the homunculus speak [orn]
  6588. *------------------------------------------*/
  6589. ACMD_FUNC(homtalk)
  6590. {
  6591. char mes[100],temp[CHAT_SIZE_MAX];
  6592. nullpo_retr(-1, sd);
  6593. if ( battle_config.min_chat_delay ) {
  6594. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6595. return 0;
  6596. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6597. }
  6598. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6599. return -1; //no "chatting" while muted.
  6600. if ( !hom_is_active(sd->hd) ) {
  6601. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6602. return -1;
  6603. }
  6604. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6605. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6606. return -1;
  6607. }
  6608. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6609. clif_disp_overhead(&sd->hd->bl, temp);
  6610. return 0;
  6611. }
  6612. /*==========================================
  6613. * Show homunculus stats
  6614. *------------------------------------------*/
  6615. ACMD_FUNC(hominfo)
  6616. {
  6617. struct homun_data *hd;
  6618. struct status_data *status;
  6619. nullpo_retr(-1, sd);
  6620. if ( !hom_is_active(sd->hd) ) {
  6621. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6622. return -1;
  6623. }
  6624. hd = sd->hd;
  6625. status = status_get_status_data(&hd->bl);
  6626. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6627. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6628. status->hp, status->max_hp, status->sp, status->max_sp);
  6629. clif_displaymessage(fd, atcmd_output);
  6630. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6631. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6632. clif_displaymessage(fd, atcmd_output);
  6633. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6634. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6635. clif_displaymessage(fd, atcmd_output);
  6636. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6637. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6638. status->str, status->agi, status->vit,
  6639. status->int_, status->dex, status->luk);
  6640. clif_displaymessage(fd, atcmd_output);
  6641. return 0;
  6642. }
  6643. ACMD_FUNC(homstats)
  6644. {
  6645. struct homun_data *hd;
  6646. struct s_homunculus_db *db;
  6647. struct s_homunculus *hom;
  6648. int lv, min, max, evo;
  6649. nullpo_retr(-1, sd);
  6650. if ( !hom_is_active(sd->hd) ) {
  6651. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6652. return -1;
  6653. }
  6654. hd = sd->hd;
  6655. hom = &hd->homunculus;
  6656. db = hd->homunculusDB;
  6657. lv = hom->level;
  6658. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6659. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6660. clif_displaymessage(fd, atcmd_output);
  6661. lv--; //Since the first increase is at level 2.
  6662. evo = (hom->class_ == db->evo_class);
  6663. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6664. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6665. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6666. clif_displaymessage(fd, atcmd_output);
  6667. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6668. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6669. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6670. clif_displaymessage(fd, atcmd_output);
  6671. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6672. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6673. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6674. clif_displaymessage(fd, atcmd_output);
  6675. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6676. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6677. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6678. clif_displaymessage(fd, atcmd_output);
  6679. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6680. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6681. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6682. clif_displaymessage(fd, atcmd_output);
  6683. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6684. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6685. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6686. clif_displaymessage(fd, atcmd_output);
  6687. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6688. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6689. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6690. clif_displaymessage(fd, atcmd_output);
  6691. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6692. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6693. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6694. clif_displaymessage(fd, atcmd_output);
  6695. return 0;
  6696. }
  6697. ACMD_FUNC(homshuffle)
  6698. {
  6699. nullpo_retr(-1, sd);
  6700. if(!sd->hd)
  6701. return -1; // nothing to do
  6702. if(!hom_shuffle(sd->hd))
  6703. return -1;
  6704. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6705. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6706. return 0;
  6707. }
  6708. /*==========================================
  6709. * Show Items DB Info v 1.0
  6710. * originally by [Lupus]
  6711. *------------------------------------------*/
  6712. ACMD_FUNC(iteminfo)
  6713. {
  6714. struct item_data *item_array[MAX_SEARCH];
  6715. int i, count = 1;
  6716. if (!message || !*message) {
  6717. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6718. return -1;
  6719. }
  6720. if ((item_array[0] = itemdb_exists(strtoul(message, nullptr, 10))) == nullptr)
  6721. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6722. if (!count) {
  6723. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6724. return -1;
  6725. }
  6726. if (count == MAX_SEARCH) {
  6727. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6728. clif_displaymessage(fd, atcmd_output);
  6729. }
  6730. for (i = 0; i < count; i++) {
  6731. struct item_data * item_data = item_array[i];
  6732. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%u) Type: %s | Extra Effect: %s
  6733. item_data->name.c_str(),item_data->ename.c_str(),item_data->slots,item_data->nameid,
  6734. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
  6735. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6736. );
  6737. clif_displaymessage(fd, atcmd_output);
  6738. sprintf(atcmd_output, msg_txt(sd,1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  6739. clif_displaymessage(fd, atcmd_output);
  6740. if (item_data->maxchance == -1) {
  6741. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6742. clif_displaymessage(fd, atcmd_output);
  6743. }
  6744. else if (!battle_config.atcommand_mobinfo_type) {
  6745. if (item_data->maxchance)
  6746. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6747. else
  6748. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6749. clif_displaymessage(fd, atcmd_output);
  6750. }
  6751. }
  6752. return 0;
  6753. }
  6754. /*==========================================
  6755. * Show who drops the item.
  6756. *------------------------------------------*/
  6757. ACMD_FUNC(whodrops)
  6758. {
  6759. struct item_data *item_data, *item_array[MAX_SEARCH];
  6760. int i,j, count = 1;
  6761. if (!message || !*message) {
  6762. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6763. return -1;
  6764. }
  6765. if ((item_array[0] = itemdb_exists(strtoul(message, nullptr, 10))) == nullptr)
  6766. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6767. if (!count) {
  6768. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6769. return -1;
  6770. }
  6771. if (count == MAX_SEARCH) {
  6772. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6773. clif_displaymessage(fd, atcmd_output);
  6774. }
  6775. for (i = 0; i < count; i++) {
  6776. item_data = item_array[i];
  6777. sprintf(atcmd_output, msg_txt(sd,1285), item_data->ename.c_str(), item_data->slots, item_data->nameid); // Item: '%s'[%d] (ID:%u)
  6778. clif_displaymessage(fd, atcmd_output);
  6779. if (item_data->mob[0].chance == 0) {
  6780. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6781. clif_displaymessage(fd, atcmd_output);
  6782. } else {
  6783. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6784. clif_displaymessage(fd, atcmd_output);
  6785. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6786. {
  6787. int dropchance = item_data->mob[j].chance;
  6788. std::shared_ptr<s_mob_db> mob = mob_db.find(item_data->mob[j].id);
  6789. if(!mob) continue;
  6790. #ifdef RENEWAL_DROP
  6791. if( battle_config.atcommand_mobinfo_type )
  6792. dropchance = dropchance * pc_level_penalty_mod( sd, PENALTY_DROP, mob ) / 100;
  6793. #endif
  6794. if (pc_isvip(sd)) // Display item rate increase for VIP
  6795. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6796. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob->jname.c_str(), item_data->mob[j].id, dropchance/100.);
  6797. clif_displaymessage(fd, atcmd_output);
  6798. }
  6799. }
  6800. }
  6801. return 0;
  6802. }
  6803. ACMD_FUNC(whereis)
  6804. {
  6805. uint16 mob_ids[MAX_SEARCH] = {0};
  6806. int count = 0;
  6807. if (!message || !*message) {
  6808. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6809. return -1;
  6810. }
  6811. int i_message = atoi(message);
  6812. if (mobdb_checkid(i_message)) {
  6813. // ID given
  6814. mob_ids[0] = i_message;
  6815. count = 1;
  6816. } else {
  6817. // Name given, get all monster associated whith this name
  6818. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6819. }
  6820. if (count <= 0) {
  6821. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6822. return -1;
  6823. }
  6824. if (count >= MAX_SEARCH) {
  6825. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6826. clif_displaymessage(fd, atcmd_output);
  6827. count = MAX_SEARCH;
  6828. }
  6829. for (int i = 0; i < count; i++) {
  6830. uint16 mob_id = mob_ids[i];
  6831. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6832. if(!mob) continue;
  6833. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname.c_str()); // %s spawns in:
  6834. clif_displaymessage(fd, atcmd_output);
  6835. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  6836. if (spawns.size() <= 0) {
  6837. // This monster does not spawn normally.
  6838. clif_displaymessage(fd, msg_txt(sd,1290));
  6839. } else {
  6840. for(auto& spawn : spawns)
  6841. {
  6842. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  6843. if (mapid < 0)
  6844. continue;
  6845. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  6846. clif_displaymessage(fd, atcmd_output);
  6847. }
  6848. }
  6849. }
  6850. return 0;
  6851. }
  6852. ACMD_FUNC(version)
  6853. {
  6854. pc_show_version(sd);
  6855. return 0;
  6856. }
  6857. /*==========================================
  6858. * @mutearea by MouseJstr
  6859. *------------------------------------------*/
  6860. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6861. {
  6862. int time, id;
  6863. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6864. if (pl_sd == NULL)
  6865. return 0;
  6866. id = va_arg(ap, int);
  6867. time = va_arg(ap, int);
  6868. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6869. pl_sd->status.manner -= time;
  6870. if (pl_sd->status.manner < 0)
  6871. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6872. else
  6873. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6874. }
  6875. return 0;
  6876. }
  6877. ACMD_FUNC(mutearea)
  6878. {
  6879. int time;
  6880. nullpo_ret(sd);
  6881. if (!message || !*message) {
  6882. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6883. return -1;
  6884. }
  6885. time = atoi(message);
  6886. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  6887. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6888. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6889. return 0;
  6890. }
  6891. ACMD_FUNC(rates)
  6892. {
  6893. char buf[CHAT_SIZE_MAX];
  6894. nullpo_ret(sd);
  6895. memset(buf, '\0', sizeof(buf));
  6896. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6897. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  6898. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  6899. clif_displaymessage(fd, buf);
  6900. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6901. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6902. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6903. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6904. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6905. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6906. clif_displaymessage(fd, buf);
  6907. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6908. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6909. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6910. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6911. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6912. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6913. clif_displaymessage(fd, buf);
  6914. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6915. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6916. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6917. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6918. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6919. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6920. clif_displaymessage(fd, buf);
  6921. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6922. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6923. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6924. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6925. clif_displaymessage(fd, buf);
  6926. return 0;
  6927. }
  6928. /*==========================================
  6929. * @me by lordalfa
  6930. * => Displays the OUTPUT string on top of the Visible players Heads.
  6931. *------------------------------------------*/
  6932. ACMD_FUNC(me)
  6933. {
  6934. char tempmes[CHAT_SIZE_MAX];
  6935. nullpo_retr(-1, sd);
  6936. memset(tempmes, '\0', sizeof(tempmes));
  6937. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6938. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6939. return -1; //no "chatting" while muted.
  6940. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6941. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6942. return -1;
  6943. }
  6944. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6945. clif_disp_overhead(&sd->bl, atcmd_output);
  6946. return 0;
  6947. }
  6948. /*==========================================
  6949. * @size
  6950. * => Resize your character sprite. [Valaris]
  6951. *------------------------------------------*/
  6952. ACMD_FUNC(size)
  6953. {
  6954. int size = SZ_SMALL;
  6955. nullpo_retr(-1, sd);
  6956. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6957. if(sd->state.size) {
  6958. sd->state.size = SZ_SMALL;
  6959. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6960. }
  6961. sd->state.size = size;
  6962. if( size == SZ_MEDIUM )
  6963. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  6964. else if( size == SZ_BIG )
  6965. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  6966. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6967. return 0;
  6968. }
  6969. ACMD_FUNC(sizeall)
  6970. {
  6971. int size;
  6972. struct map_session_data *pl_sd;
  6973. struct s_mapiterator* iter;
  6974. size = atoi(message);
  6975. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6976. iter = mapit_getallusers();
  6977. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6978. if( pl_sd->state.size != size ) {
  6979. if( pl_sd->state.size ) {
  6980. pl_sd->state.size = SZ_SMALL;
  6981. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6982. }
  6983. pl_sd->state.size = size;
  6984. if( size == SZ_MEDIUM )
  6985. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6986. else if( size == SZ_BIG )
  6987. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6988. }
  6989. }
  6990. mapit_free(iter);
  6991. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6992. return 0;
  6993. }
  6994. ACMD_FUNC(sizeguild)
  6995. {
  6996. int size = SZ_SMALL, i;
  6997. char guild[NAME_LENGTH];
  6998. struct map_session_data *pl_sd;
  6999. struct guild *g;
  7000. nullpo_retr(-1, sd);
  7001. memset(guild, '\0', sizeof(guild));
  7002. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  7003. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  7004. return -1;
  7005. }
  7006. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  7007. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  7008. return -1;
  7009. }
  7010. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7011. for( i = 0; i < g->max_member; i++ ) {
  7012. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  7013. if( pl_sd->state.size ) {
  7014. pl_sd->state.size = SZ_SMALL;
  7015. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7016. }
  7017. pl_sd->state.size = size;
  7018. if( size == SZ_MEDIUM )
  7019. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7020. else if( size == SZ_BIG )
  7021. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7022. }
  7023. }
  7024. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7025. return 0;
  7026. }
  7027. /*==========================================
  7028. * @monsterignore
  7029. * => Makes monsters ignore you. [Valaris]
  7030. *------------------------------------------*/
  7031. ACMD_FUNC(monsterignore)
  7032. {
  7033. nullpo_retr(-1, sd);
  7034. if (sd->state.block_action & PCBLOCK_IMMUNE) {
  7035. sd->state.block_action &= ~PCBLOCK_IMMUNE;
  7036. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  7037. } else {
  7038. sd->state.block_action |= PCBLOCK_IMMUNE;
  7039. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  7040. }
  7041. return 0;
  7042. }
  7043. /*==========================================
  7044. * @fakename
  7045. * => Gives your character a fake name. [Valaris]
  7046. *------------------------------------------*/
  7047. ACMD_FUNC(fakename)
  7048. {
  7049. nullpo_retr(-1, sd);
  7050. if( !message || !*message )
  7051. {
  7052. if( sd->fakename[0] )
  7053. {
  7054. sd->fakename[0] = '\0';
  7055. clif_name_area(&sd->bl);
  7056. if (sd->disguise)
  7057. clif_name_self(&sd->bl);
  7058. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7059. return 0;
  7060. }
  7061. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7062. return -1;
  7063. }
  7064. if( strlen(message) < 2 )
  7065. {
  7066. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7067. return -1;
  7068. }
  7069. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7070. clif_name_area(&sd->bl);
  7071. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  7072. clif_name_self(&sd->bl);
  7073. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7074. return 0;
  7075. }
  7076. /*==========================================
  7077. * Ragnarok Resources
  7078. *------------------------------------------*/
  7079. ACMD_FUNC(mapflag) {
  7080. char flag_name[50];
  7081. short flag = 0, i, j;
  7082. std::string buf;
  7083. nullpo_retr(-1, sd);
  7084. memset(flag_name, '\0', sizeof(flag_name));
  7085. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  7086. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7087. clif_displaymessage(sd->fd,"----------------------------------");
  7088. for( i = MF_MIN; i < MF_MAX; i++ ){
  7089. union u_mapflag_args args = {};
  7090. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  7091. clif_displaymessage(sd->fd, flag_name);
  7092. }
  7093. }
  7094. clif_displaymessage(sd->fd," ");
  7095. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7096. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7097. return 1;
  7098. }
  7099. // Check if the list of mapflags was requested
  7100. if( strcasecmp(flag_name,"available") ){
  7101. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7102. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  7103. if( mapflag != MF_INVALID ){
  7104. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  7105. MF_PVP_NIGHTMAREDROP,
  7106. MF_RESTRICTED,
  7107. MF_NOCOMMAND,
  7108. MF_BEXP,
  7109. MF_JEXP,
  7110. MF_BATTLEGROUND,
  7111. MF_SKILL_DAMAGE,
  7112. MF_SKILL_DURATION };
  7113. if (flag && std::find(disabled_mf.begin(), disabled_mf.end(), mapflag) != disabled_mf.end()) {
  7114. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  7115. clif_displaymessage(sd->fd,atcmd_output);
  7116. } else {
  7117. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  7118. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  7119. clif_displaymessage(sd->fd,atcmd_output);
  7120. }
  7121. return 0;
  7122. }else{
  7123. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  7124. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  7125. return 1;
  7126. }
  7127. }
  7128. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7129. clif_displaymessage(sd->fd,"----------------------------------");
  7130. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  7131. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  7132. buf.append(flag_name);
  7133. if( (i + 1) < MF_MAX )
  7134. buf.append(", ");
  7135. j++;
  7136. }
  7137. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  7138. clif_displaymessage(sd->fd, buf.c_str() );
  7139. buf.clear();
  7140. j = 0;
  7141. }
  7142. }
  7143. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7144. return 0;
  7145. }
  7146. /*===================================
  7147. * Remove some messages
  7148. *-----------------------------------*/
  7149. ACMD_FUNC(showexp)
  7150. {
  7151. if (sd->state.showexp) {
  7152. sd->state.showexp = 0;
  7153. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7154. return 0;
  7155. }
  7156. sd->state.showexp = 1;
  7157. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7158. return 0;
  7159. }
  7160. ACMD_FUNC(showzeny)
  7161. {
  7162. if (sd->state.showzeny) {
  7163. sd->state.showzeny = 0;
  7164. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7165. return 0;
  7166. }
  7167. sd->state.showzeny = 1;
  7168. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7169. return 0;
  7170. }
  7171. ACMD_FUNC(showdelay)
  7172. {
  7173. if (sd->state.showdelay) {
  7174. sd->state.showdelay = 0;
  7175. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7176. return 0;
  7177. }
  7178. sd->state.showdelay = 1;
  7179. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7180. return 0;
  7181. }
  7182. /*==========================================
  7183. * Duel organizing functions [LuzZza]
  7184. *
  7185. * @duel [limit|nick] - create a duel
  7186. * @invite <nick> - invite player
  7187. * @accept - accept invitation
  7188. * @reject - reject invitation
  7189. * @leave - leave duel
  7190. *------------------------------------------*/
  7191. ACMD_FUNC(invite)
  7192. {
  7193. unsigned int did = sd->duel_group;
  7194. struct map_session_data *target_sd = NULL;
  7195. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7196. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7197. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7198. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7199. clif_displaymessage(fd, atcmd_output);
  7200. return -1;
  7201. }
  7202. if(did == 0 || !duel_exist(did) ) {
  7203. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7204. return 0;
  7205. }
  7206. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7207. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7208. return 0;
  7209. }
  7210. if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
  7211. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7212. return 0;
  7213. }
  7214. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7215. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7216. return 0;
  7217. }
  7218. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7219. {
  7220. sprintf(atcmd_output, msg_txt(sd,364), atcmd_player_name); // Duel: You can't invite %s because he/she isn't on the same map.
  7221. clif_displaymessage(fd, atcmd_output);
  7222. return 0;
  7223. }
  7224. duel_invite(did, sd, target_sd);
  7225. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7226. return 0;
  7227. }
  7228. ACMD_FUNC(duel)
  7229. {
  7230. unsigned int maxpl = 0;
  7231. if(sd->duel_group > 0) {
  7232. duel_showinfo(sd->duel_group, sd);
  7233. return 0;
  7234. }
  7235. if(sd->duel_invite > 0) {
  7236. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7237. return 0;
  7238. }
  7239. if(!duel_checktime(sd)) {
  7240. char output[CHAT_SIZE_MAX];
  7241. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7242. clif_displaymessage(fd, output);
  7243. return 0;
  7244. }
  7245. if( message[0] ) {
  7246. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7247. if(maxpl < 2 || maxpl > 65535) {
  7248. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7249. return 0;
  7250. }
  7251. duel_create(sd, maxpl);
  7252. } else {
  7253. struct map_session_data *target_sd = NULL;
  7254. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7255. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7256. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7257. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7258. clif_displaymessage(fd, atcmd_output);
  7259. return -1;
  7260. }
  7261. target_sd = map_nick2sd(atcmd_player_name,true);
  7262. if(target_sd != NULL) {
  7263. unsigned int newduel;
  7264. if((newduel = duel_create(sd, 2)) != -1) {
  7265. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7266. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7267. return 0;
  7268. }
  7269. duel_invite(newduel, sd, target_sd);
  7270. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7271. }
  7272. } else {
  7273. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7274. return 0;
  7275. }
  7276. }
  7277. } else
  7278. duel_create(sd, 0);
  7279. return 0;
  7280. }
  7281. ACMD_FUNC(leave)
  7282. {
  7283. if(sd->duel_group <= 0) {
  7284. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7285. return 0;
  7286. }
  7287. duel_leave(sd->duel_group, sd);
  7288. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7289. return 0;
  7290. }
  7291. ACMD_FUNC(accept)
  7292. {
  7293. if(!duel_checktime(sd)) {
  7294. char output[CHAT_SIZE_MAX];
  7295. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7296. clif_displaymessage(fd, output);
  7297. return 0;
  7298. }
  7299. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7300. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7301. return 0;
  7302. }
  7303. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7304. {
  7305. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7306. return 0;
  7307. }
  7308. duel_accept(sd->duel_invite, sd);
  7309. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7310. return 0;
  7311. }
  7312. ACMD_FUNC(reject)
  7313. {
  7314. if(sd->duel_invite <= 0) {
  7315. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7316. return 0;
  7317. }
  7318. duel_reject(sd->duel_invite, sd);
  7319. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7320. return 0;
  7321. }
  7322. /*===================================
  7323. * Cash Points
  7324. *-----------------------------------*/
  7325. ACMD_FUNC(cash)
  7326. {
  7327. char output[128];
  7328. int value;
  7329. int ret=0;
  7330. nullpo_retr(-1, sd);
  7331. // Since there is no cashpoint update packet we need to force updating like this
  7332. if( sd->state.cashshop_open ){
  7333. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7334. return -1;
  7335. }
  7336. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7337. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7338. return -1;
  7339. }
  7340. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7341. if( !strcmpi(parent_cmd,"cash") )
  7342. {
  7343. if( value > 0 ) {
  7344. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7345. // If this option is set, the message is already sent by pc function
  7346. if( !battle_config.cashshop_show_points ){
  7347. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7348. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7349. }
  7350. }
  7351. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7352. } else {
  7353. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7354. value = -sd->cashPoints;
  7355. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7356. // If this option is set, the message is already sent by pc function
  7357. if( !battle_config.cashshop_show_points ){
  7358. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7359. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7360. }
  7361. }
  7362. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7363. }
  7364. }
  7365. else
  7366. { // @points
  7367. if( value > 0 ) {
  7368. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7369. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7370. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7371. }
  7372. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7373. } else {
  7374. if (-value > sd->kafraPoints) //By command, if cash < value, force it to remove all
  7375. value = -sd->kafraPoints;
  7376. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7377. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7378. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7379. }
  7380. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7381. }
  7382. }
  7383. return 0;
  7384. }
  7385. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7386. ACMD_FUNC(clone)
  7387. {
  7388. int x=0,y=0,flag=0,master=0,i=0;
  7389. struct map_session_data *pl_sd=NULL;
  7390. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7391. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7392. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7393. return 0;
  7394. }
  7395. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
  7396. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7397. return 0;
  7398. }
  7399. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7400. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7401. return 0;
  7402. }
  7403. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7404. if (strcmpi(parent_cmd, "clone") == 0)
  7405. flag = 1;
  7406. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7407. flag = 2;
  7408. if(pc_isdead(sd)){
  7409. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7410. return 0;
  7411. }
  7412. master = sd->bl.id;
  7413. if (battle_config.atc_slave_clone_limit
  7414. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7415. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7416. return 0;
  7417. }
  7418. }
  7419. do {
  7420. x = sd->bl.x + (rnd() % 10 - 5);
  7421. y = sd->bl.y + (rnd() % 10 - 5);
  7422. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7423. if (i >= 10) {
  7424. x = sd->bl.x;
  7425. y = sd->bl.y;
  7426. }
  7427. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7428. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7429. return 0;
  7430. }
  7431. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7432. return 0;
  7433. }
  7434. /*=====================================
  7435. * Autorejecting Invites/Deals [LuzZza]
  7436. * Usage: @noask
  7437. *-------------------------------------*/
  7438. ACMD_FUNC(noask)
  7439. {
  7440. if(sd->state.noask) {
  7441. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7442. sd->state.noask = 0;
  7443. } else {
  7444. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7445. sd->state.noask = 1;
  7446. }
  7447. return 0;
  7448. }
  7449. /*=====================================
  7450. * Send a @request message to all GMs of lowest_gm_level.
  7451. * Usage: @request <petition>
  7452. *-------------------------------------*/
  7453. ACMD_FUNC(request)
  7454. {
  7455. if (!message || !*message) {
  7456. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7457. return -1;
  7458. }
  7459. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7460. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7461. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7462. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7463. return 0;
  7464. }
  7465. /*==========================================
  7466. * Feel (SG designated maps) Reset [HiddenDragon]
  7467. *------------------------------------------*/
  7468. ACMD_FUNC(feelreset)
  7469. {
  7470. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7471. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7472. return -1;
  7473. }
  7474. pc_resetfeel(sd);
  7475. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7476. return 0;
  7477. }
  7478. /*==========================================
  7479. * Hate (SG designated monsters) Reset
  7480. *------------------------------------------*/
  7481. ACMD_FUNC(hatereset)
  7482. {
  7483. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7484. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7485. return -1;
  7486. }
  7487. pc_resethate(sd);
  7488. clif_displaymessage(fd, msg_txt(sd,1515)); // Reset 'Hatred' monsters.
  7489. return 0;
  7490. }
  7491. /*==========================================
  7492. * AUCTION SYSTEM
  7493. *------------------------------------------*/
  7494. ACMD_FUNC(auction)
  7495. {
  7496. nullpo_ret(sd);
  7497. if (!battle_config.feature_auction) {
  7498. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7499. return 0;
  7500. }
  7501. clif_Auction_openwindow(sd);
  7502. return 0;
  7503. }
  7504. /*==========================================
  7505. * Kill Steal Protection
  7506. *------------------------------------------*/
  7507. ACMD_FUNC(ksprotection)
  7508. {
  7509. nullpo_retr(-1,sd);
  7510. if( sd->state.noks ) {
  7511. sd->state.noks = 0;
  7512. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7513. }
  7514. else
  7515. {
  7516. if( !message || !*message || !strcmpi(message, "party") )
  7517. { // Default is Party
  7518. sd->state.noks = 2;
  7519. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7520. }
  7521. else if( !strcmpi(message, "self") )
  7522. {
  7523. sd->state.noks = 1;
  7524. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7525. }
  7526. else if( !strcmpi(message, "guild") )
  7527. {
  7528. sd->state.noks = 3;
  7529. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7530. }
  7531. else
  7532. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7533. }
  7534. return 0;
  7535. }
  7536. /*==========================================
  7537. * Map Kill Steal Protection Setting
  7538. *------------------------------------------*/
  7539. ACMD_FUNC(allowks)
  7540. {
  7541. nullpo_retr(-1,sd);
  7542. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7543. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7544. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7545. } else {
  7546. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7547. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7548. }
  7549. return 0;
  7550. }
  7551. ACMD_FUNC(resetstat)
  7552. {
  7553. nullpo_retr(-1, sd);
  7554. pc_resetstate(sd);
  7555. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7556. clif_displaymessage(fd, atcmd_output);
  7557. return 0;
  7558. }
  7559. ACMD_FUNC(resetskill)
  7560. {
  7561. nullpo_retr(-1,sd);
  7562. pc_resetskill(sd,1);
  7563. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7564. clif_displaymessage(fd, atcmd_output);
  7565. return 0;
  7566. }
  7567. /*==========================================
  7568. * #storagelist: Displays the items list of a player's storage.
  7569. * #cartlist: Displays contents of target's cart.
  7570. * #itemlist: Displays contents of target's inventory.
  7571. *------------------------------------------*/
  7572. ACMD_FUNC(itemlist)
  7573. {
  7574. int i, j, count, counter;
  7575. const char* location;
  7576. const struct item* items;
  7577. int size;
  7578. StringBuf buf;
  7579. nullpo_retr(-1, sd);
  7580. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7581. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7582. location = "storage";
  7583. items = sd->storage.u.items_storage;
  7584. size = sd->storage.max_amount;
  7585. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7586. location = "cart";
  7587. items = sd->cart.u.items_cart;
  7588. size = MAX_CART;
  7589. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7590. location = "inventory";
  7591. items = sd->inventory.u.items_inventory;
  7592. size = MAX_INVENTORY;
  7593. } else
  7594. return 1;
  7595. StringBuf_Init(&buf);
  7596. count = 0; // total slots occupied
  7597. counter = 0; // total items found
  7598. for( i = 0; i < size; ++i ) {
  7599. const struct item* it = &items[i];
  7600. struct item_data* itd;
  7601. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7602. continue;
  7603. counter += it->amount;
  7604. count++;
  7605. if( count == 1 ) {
  7606. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7607. clif_displaymessage(fd, StringBuf_Value(&buf));
  7608. StringBuf_Clear(&buf);
  7609. }
  7610. if( it->refine )
  7611. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %u)", it->amount, itd->ename.c_str(), it->refine, itd->name.c_str(), it->nameid);
  7612. else
  7613. StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, itd->ename.c_str(), itd->name.c_str(), it->nameid);
  7614. if( it->equip ) {
  7615. char equipstr[CHAT_SIZE_MAX];
  7616. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7617. if( it->equip&EQP_GARMENT )
  7618. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7619. if( it->equip&EQP_ACC_L )
  7620. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7621. if( it->equip&EQP_ARMOR )
  7622. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7623. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7624. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7625. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7626. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7627. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7628. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7629. if( it->equip&EQP_SHOES )
  7630. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7631. if( it->equip&EQP_ACC_R )
  7632. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7633. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7634. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7635. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7636. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7637. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7638. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7639. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7640. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7641. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7642. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7643. if( (it->equip&EQP_HELM) == EQP_HELM )
  7644. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7645. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7646. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7647. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7648. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7649. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7650. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7651. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7652. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7653. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7654. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7655. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7656. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7657. if( it->equip&EQP_COSTUME_GARMENT )
  7658. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7659. //if( it->equip&EQP_COSTUME_FLOOR )
  7660. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7661. if( it->equip&EQP_AMMO )
  7662. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7663. if( it->equip&EQP_SHADOW_ARMOR )
  7664. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7665. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7666. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7667. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7668. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7669. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7670. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7671. if( it->equip&EQP_SHADOW_SHOES )
  7672. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7673. if( it->equip&EQP_SHADOW_ACC_R )
  7674. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7675. if( it->equip&EQP_SHADOW_ACC_L )
  7676. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7677. // remove final ', '
  7678. equipstr[strlen(equipstr) - 2] = '\0';
  7679. StringBuf_AppendStr(&buf, equipstr);
  7680. }
  7681. clif_displaymessage(fd, StringBuf_Value(&buf));
  7682. StringBuf_Clear(&buf);
  7683. if( it->card[0] == CARD0_PET ) { // pet egg
  7684. if (it->card[3]&1)
  7685. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7686. else
  7687. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7688. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7689. StringBuf_Printf(&buf, msg_txt(sd,1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
  7690. } else if(it->card[0] == CARD0_CREATE) { // created item
  7691. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7692. } else { // normal item
  7693. int counter2 = 0;
  7694. for( j = 0; j < itd->slots; ++j ) {
  7695. struct item_data* card;
  7696. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7697. continue;
  7698. counter2++;
  7699. if( counter2 == 1 )
  7700. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7701. if( counter2 != 1 )
  7702. StringBuf_AppendStr(&buf, ", ");
  7703. StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, card->ename.c_str(), card->nameid);
  7704. }
  7705. if( counter2 > 0 )
  7706. StringBuf_AppendStr(&buf, ")");
  7707. }
  7708. if( StringBuf_Length(&buf) > 0 )
  7709. clif_displaymessage(fd, StringBuf_Value(&buf));
  7710. StringBuf_Clear(&buf);
  7711. }
  7712. if( count == 0 )
  7713. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7714. else
  7715. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7716. clif_displaymessage(fd, StringBuf_Value(&buf));
  7717. StringBuf_Destroy(&buf);
  7718. return 0;
  7719. }
  7720. ACMD_FUNC(stats)
  7721. {
  7722. char job_jobname[100];
  7723. char output[CHAT_SIZE_MAX];
  7724. int i;
  7725. struct {
  7726. const char* format;
  7727. int value;
  7728. } output_table[] = {
  7729. { "Base Level - %d", 0 },
  7730. { NULL, 0 },
  7731. { "Hp - %d", 0 },
  7732. { "MaxHp - %d", 0 },
  7733. { "Sp - %d", 0 },
  7734. { "MaxSp - %d", 0 },
  7735. { "Str - %3d", 0 },
  7736. { "Agi - %3d", 0 },
  7737. { "Vit - %3d", 0 },
  7738. { "Int - %3d", 0 },
  7739. { "Dex - %3d", 0 },
  7740. { "Luk - %3d", 0 },
  7741. { "Zeny - %d", 0 },
  7742. { "Free SK Points - %d", 0 },
  7743. { "JobChangeLvl (2nd) - %d", 0 },
  7744. { "JobChangeLvl (3rd) - %d", 0 },
  7745. { NULL, 0 }
  7746. };
  7747. memset(job_jobname, '\0', sizeof(job_jobname));
  7748. memset(output, '\0', sizeof(output));
  7749. //direct array initialization with variables is not standard C compliant.
  7750. output_table[0].value = sd->status.base_level;
  7751. output_table[1].format = job_jobname;
  7752. output_table[1].value = sd->status.job_level;
  7753. output_table[2].value = sd->status.hp;
  7754. output_table[3].value = sd->status.max_hp;
  7755. output_table[4].value = sd->status.sp;
  7756. output_table[5].value = sd->status.max_sp;
  7757. output_table[6].value = sd->status.str;
  7758. output_table[7].value = sd->status.agi;
  7759. output_table[8].value = sd->status.vit;
  7760. output_table[9].value = sd->status.int_;
  7761. output_table[10].value = sd->status.dex;
  7762. output_table[11].value = sd->status.luk;
  7763. output_table[12].value = sd->status.zeny;
  7764. output_table[13].value = sd->status.skill_point;
  7765. output_table[14].value = sd->change_level_2nd;
  7766. output_table[15].value = sd->change_level_3rd;
  7767. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7768. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7769. clif_displaymessage(fd, output);
  7770. for (i = 0; output_table[i].format != NULL; i++) {
  7771. sprintf(output, output_table[i].format, output_table[i].value);
  7772. clif_displaymessage(fd, output);
  7773. }
  7774. return 0;
  7775. }
  7776. ACMD_FUNC(delitem)
  7777. {
  7778. char item_name[100];
  7779. t_itemid nameid;
  7780. int amount = 0, total, idx;
  7781. struct item_data* id;
  7782. nullpo_retr(-1, sd);
  7783. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7784. {
  7785. clif_displaymessage(fd, msg_txt(sd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  7786. return -1;
  7787. }
  7788. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists( strtoul( item_name, nullptr, 10 ) ) ) != NULL )
  7789. {
  7790. nameid = id->nameid;
  7791. }
  7792. else
  7793. {
  7794. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7795. return -1;
  7796. }
  7797. total = amount;
  7798. // delete items
  7799. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7800. {
  7801. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  7802. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  7803. {// delete pet
  7804. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  7805. }
  7806. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7807. amount-= delamount;
  7808. }
  7809. // notify target
  7810. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7811. clif_displaymessage(sd->fd, atcmd_output);
  7812. // notify source
  7813. if( amount == total )
  7814. {
  7815. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7816. }
  7817. else if( amount )
  7818. {
  7819. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7820. clif_displaymessage(fd, atcmd_output);
  7821. }
  7822. else
  7823. {
  7824. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7825. clif_displaymessage(fd, atcmd_output);
  7826. }
  7827. return 0;
  7828. }
  7829. /*==========================================
  7830. * Custom Fonts
  7831. *------------------------------------------*/
  7832. ACMD_FUNC(font)
  7833. {
  7834. int font_id;
  7835. nullpo_retr(-1,sd);
  7836. font_id = atoi(message);
  7837. if( font_id == 0 ) {
  7838. if( sd->status.font ) {
  7839. sd->status.font = 0;
  7840. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7841. clif_font(sd);
  7842. } else {
  7843. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7844. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7845. }
  7846. } else if( font_id < 0 || font_id > 9 )
  7847. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7848. else if( font_id != sd->status.font ) {
  7849. sd->status.font = font_id;
  7850. clif_font(sd);
  7851. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7852. } else
  7853. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7854. return 0;
  7855. }
  7856. /*==========================================
  7857. * type: 1 = commands (@), 2 = charcommands (#)
  7858. *------------------------------------------*/
  7859. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7860. {
  7861. char line_buff[CHATBOX_SIZE];
  7862. char* cur = line_buff;
  7863. AtCommandInfo* cmd;
  7864. DBIterator *iter = db_iterator(atcommand_db);
  7865. int count = 0;
  7866. memset(line_buff,' ',CHATBOX_SIZE);
  7867. line_buff[CHATBOX_SIZE-1] = 0;
  7868. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7869. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7870. unsigned int slen = 0;
  7871. switch( type ) {
  7872. case COMMAND_CHARCOMMAND:
  7873. if( cmd->char_groups[sd->group_pos] == 0 )
  7874. continue;
  7875. break;
  7876. case COMMAND_ATCOMMAND:
  7877. if( cmd->at_groups[sd->group_pos] == 0 )
  7878. continue;
  7879. break;
  7880. default:
  7881. continue;
  7882. }
  7883. slen = strlen(cmd->command);
  7884. // flush the text buffer if this command won't fit into it
  7885. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7886. clif_displaymessage(fd,line_buff);
  7887. cur = line_buff;
  7888. memset(line_buff,' ',CHATBOX_SIZE);
  7889. line_buff[CHATBOX_SIZE-1] = 0;
  7890. }
  7891. memcpy(cur,cmd->command,slen);
  7892. cur += slen+(10-slen%10);
  7893. count++;
  7894. }
  7895. dbi_destroy(iter);
  7896. clif_displaymessage(fd,line_buff);
  7897. if ( atcmd_binding_count ) {
  7898. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7899. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7900. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7901. unsigned int slen = strlen(atcmd_binding[i]->command);
  7902. if ( count_bind == 0 ) {
  7903. cur = line_buff;
  7904. memset(line_buff,' ',CHATBOX_SIZE);
  7905. line_buff[CHATBOX_SIZE-1] = 0;
  7906. clif_displaymessage(fd, "-----------------");
  7907. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7908. }
  7909. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7910. clif_displaymessage(fd,line_buff);
  7911. cur = line_buff;
  7912. memset(line_buff,' ',CHATBOX_SIZE);
  7913. line_buff[CHATBOX_SIZE-1] = 0;
  7914. }
  7915. memcpy(cur,atcmd_binding[i]->command,slen);
  7916. cur += slen+(10-slen%10);
  7917. count_bind++;
  7918. }
  7919. }
  7920. if ( count_bind )
  7921. clif_displaymessage(fd,line_buff);// last one
  7922. count += count_bind;
  7923. }
  7924. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7925. clif_displaymessage(fd, atcmd_output);
  7926. return;
  7927. }
  7928. /*==========================================
  7929. * @commands Lists available @ commands to you
  7930. *------------------------------------------*/
  7931. ACMD_FUNC(commands)
  7932. {
  7933. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7934. return 0;
  7935. }
  7936. /*==========================================
  7937. * @charcommands Lists available # commands to you
  7938. *------------------------------------------*/
  7939. ACMD_FUNC(charcommands) {
  7940. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7941. return 0;
  7942. }
  7943. /* for new mounts */
  7944. ACMD_FUNC(mount2) {
  7945. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7946. if (!sd->sc.data[SC_ALL_RIDING]) {
  7947. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7948. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  7949. } else {
  7950. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7951. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7952. }
  7953. return 0;
  7954. }
  7955. ACMD_FUNC(accinfo) {
  7956. char query[NAME_LENGTH];
  7957. char type = 0; // type = 1, get only account name
  7958. if (!message || !*message || strlen(message) > NAME_LENGTH
  7959. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7960. {
  7961. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7962. clif_displaymessage(fd, msg_txt(sd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  7963. return -1;
  7964. } else if (type != 0) {
  7965. type = type-'0'; //make it int
  7966. if (type != 1) {
  7967. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7968. return -1;
  7969. }
  7970. }
  7971. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7972. return 0;
  7973. }
  7974. /**
  7975. * @set <variable name{[index]}>{ <value>}
  7976. *
  7977. * Gets or sets a value of a non server variable.
  7978. * If a value is specified it is used to set the variable's value,
  7979. * if not the variable's value is read.
  7980. * In any case it reads and displays the variable's value.
  7981. *
  7982. * Original implementation by Ind
  7983. */
  7984. ACMD_FUNC(set) {
  7985. char reg[46], val[128], name[32];
  7986. int toset = 0, len;
  7987. uint32 index;
  7988. bool is_str = false;
  7989. int64 uid;
  7990. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7991. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7992. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7993. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7994. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7995. return -1;
  7996. }
  7997. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7998. if( reg[0] == '.' ) {
  7999. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  8000. return -1;
  8001. } else if( reg[0] == '\'' ) {
  8002. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  8003. return -1;
  8004. }
  8005. // Check if the user wanted to set an array
  8006. if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
  8007. // The user did not specify array brackets, so we set the index to zero
  8008. index = 0;
  8009. }
  8010. is_str = is_string_variable(name);
  8011. if( ( len = strlen(val) ) > 1 ) {
  8012. if( val[0] == '"' && val[len-1] == '"') {
  8013. val[len-1] = '\0'; //Strip quotes.
  8014. memmove(val, val+1, len-1);
  8015. }
  8016. }
  8017. // Only set the variable if there is a value for it
  8018. if( toset >= 2 ){
  8019. if( is_str ){
  8020. setd_sub_str( NULL, sd, name, index, val, NULL );
  8021. }else{
  8022. setd_sub_num( NULL, sd, name, index, strtoll( val, NULL, 10 ), NULL );
  8023. }
  8024. }
  8025. uid = reference_uid( add_str( name ), index );
  8026. if( is_str ) {// string variable
  8027. char* value;
  8028. switch( reg[0] ) {
  8029. case '@':
  8030. value = pc_readregstr(sd, uid);
  8031. break;
  8032. case '$':
  8033. value = mapreg_readregstr(uid);
  8034. break;
  8035. case '#':
  8036. if( reg[1] == '#' )
  8037. value = pc_readaccountreg2str(sd, uid);// global
  8038. else
  8039. value = pc_readaccountregstr(sd, uid);// local
  8040. break;
  8041. default:
  8042. value = pc_readglobalreg_str(sd, uid);
  8043. break;
  8044. }
  8045. if( value == NULL || *value == '\0' ){// empty string
  8046. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  8047. }else{
  8048. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
  8049. }
  8050. } else {// integer variable
  8051. int64 value;
  8052. switch( reg[0] ) {
  8053. case '@':
  8054. value = pc_readreg(sd, uid);
  8055. break;
  8056. case '$':
  8057. value = mapreg_readreg(uid);
  8058. break;
  8059. case '#':
  8060. if( reg[1] == '#' )
  8061. value = pc_readaccountreg2(sd, uid);// global
  8062. else
  8063. value = pc_readaccountreg(sd, uid);// local
  8064. break;
  8065. default:
  8066. value = pc_readglobalreg(sd, uid);
  8067. break;
  8068. }
  8069. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
  8070. }
  8071. clif_displaymessage(fd, atcmd_output);
  8072. return 0;
  8073. }
  8074. ACMD_FUNC(addperm) {
  8075. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  8076. bool add;
  8077. int i;
  8078. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  8079. add = (strcmpi(parent_cmd, "addperm") == 0);
  8080. if( !message || !*message ) {
  8081. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8082. clif_displaymessage(fd, atcmd_output);
  8083. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8084. for( i = 0; i < perm_size; i++ ) {
  8085. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8086. clif_displaymessage(fd, atcmd_output);
  8087. }
  8088. return -1;
  8089. }
  8090. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8091. if( i == perm_size ) {
  8092. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8093. clif_displaymessage(fd, atcmd_output);
  8094. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8095. for( i = 0; i < perm_size; i++ ) {
  8096. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8097. clif_displaymessage(fd, atcmd_output);
  8098. }
  8099. return -1;
  8100. }
  8101. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  8102. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8103. clif_displaymessage(fd, atcmd_output);
  8104. return -1;
  8105. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  8106. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8107. clif_displaymessage(fd, atcmd_output);
  8108. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8109. clif_displaymessage(fd, atcmd_output);
  8110. for( i = 0; i < perm_size; i++ ) {
  8111. if( sd->permissions&pc_g_permission_name[i].permission ) {
  8112. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8113. clif_displaymessage(fd, atcmd_output);
  8114. }
  8115. }
  8116. return -1;
  8117. }
  8118. if( add )
  8119. sd->permissions |= pc_g_permission_name[i].permission;
  8120. else
  8121. sd->permissions &=~ pc_g_permission_name[i].permission;
  8122. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8123. clif_displaymessage(fd, atcmd_output);
  8124. return 0;
  8125. }
  8126. ACMD_FUNC(unloadnpcfile) {
  8127. if( !message || !*message ) {
  8128. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8129. return -1;
  8130. }
  8131. if( npc_unloadfile(message) )
  8132. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8133. else {
  8134. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8135. return -1;
  8136. }
  8137. return 0;
  8138. }
  8139. ACMD_FUNC(cart) {
  8140. #define MC_CART_MDFY(idx, x) \
  8141. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8142. sd->status.skill[(idx)].lv = (x)?1:0; \
  8143. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8144. int val = atoi(message);
  8145. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8146. uint16 sk_idx = 0;
  8147. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8148. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8149. clif_displaymessage(fd, atcmd_output);
  8150. return -1;
  8151. }
  8152. if( val == 0 && !pc_iscarton(sd) ) {
  8153. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8154. return -1;
  8155. }
  8156. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8157. return -1;
  8158. if( need_skill ) {
  8159. MC_CART_MDFY(sk_idx,1);
  8160. }
  8161. if( !pc_setcart(sd, val) ) {
  8162. if( need_skill ) {
  8163. MC_CART_MDFY(sk_idx,0);
  8164. }
  8165. return -1;/* @cart failed */
  8166. }
  8167. if( need_skill ) {
  8168. MC_CART_MDFY(sk_idx,0);
  8169. }
  8170. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8171. return 0;
  8172. #undef MC_CART_MDFY
  8173. }
  8174. /* Channel System [Ind] */
  8175. ACMD_FUNC(join){
  8176. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8177. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8178. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8179. clif_displaymessage(fd, atcmd_output);
  8180. return -1;
  8181. }
  8182. return channel_pcjoin(sd, chname, pass);
  8183. }
  8184. /*
  8185. * Display available option for @channel command
  8186. * @command : the name of used command (for alias case)
  8187. */
  8188. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8189. {
  8190. int fd = sd->fd;
  8191. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8192. bool can_create = (can_delete || channel_config.private_channel.allow);
  8193. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8194. //option create
  8195. if( can_create ) {
  8196. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8197. clif_displaymessage(fd, atcmd_output);
  8198. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8199. }
  8200. //option delete
  8201. if(can_delete){
  8202. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8203. clif_displaymessage(fd, atcmd_output);
  8204. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8205. }
  8206. //option list
  8207. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8208. clif_displaymessage(fd, atcmd_output);
  8209. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8210. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8211. clif_displaymessage(fd, atcmd_output);
  8212. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8213. if( can_create ) {
  8214. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8215. clif_displaymessage(fd, atcmd_output);
  8216. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8217. }
  8218. //option setcolor
  8219. if(can_create){
  8220. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8221. clif_displaymessage(fd, atcmd_output);
  8222. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8223. }
  8224. //option join
  8225. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8226. clif_displaymessage(fd, atcmd_output);
  8227. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8228. //option leave
  8229. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8230. clif_displaymessage(fd, atcmd_output);
  8231. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8232. //option bindto
  8233. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8234. clif_displaymessage(fd, atcmd_output);
  8235. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8236. //option unbind
  8237. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8238. clif_displaymessage(fd, atcmd_output);
  8239. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8240. //option ban/unban/banlist
  8241. if( can_create ) {
  8242. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8243. clif_displaymessage(fd, atcmd_output);
  8244. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8245. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8246. clif_displaymessage(fd, atcmd_output);
  8247. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8248. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8249. clif_displaymessage(fd, atcmd_output);
  8250. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8251. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8252. clif_displaymessage(fd, atcmd_output);
  8253. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8254. }
  8255. //option setopt
  8256. if(can_create){
  8257. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8258. clif_displaymessage(fd, atcmd_output);
  8259. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8260. }
  8261. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8262. clif_displaymessage(fd, atcmd_output);
  8263. }
  8264. ACMD_FUNC(channel) {
  8265. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8266. sub1[0] = sub2[0] = '\0';
  8267. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8268. atcmd_channel_help(sd,command);
  8269. return 0;
  8270. }
  8271. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8272. return channel_pcdelete(sd,sub1);
  8273. } else if ( strcmpi(key,"list") == 0 ) {
  8274. return channel_display_list(sd,sub1);
  8275. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8276. return channel_pccolor(sd, sub1, sub2);
  8277. } else if ( strcmpi(key,"join") == 0 ) {
  8278. return channel_pcjoin(sd, sub1, sub2);
  8279. }else if ( strcmpi(key,"leave") == 0 ) {
  8280. return channel_pcleave(sd, sub1);
  8281. } else if ( strcmpi(key,"bindto") == 0 ) {
  8282. return channel_pcbind(sd, sub1);
  8283. } else if ( strcmpi(key,"unbind") == 0 ) {
  8284. return channel_pcunbind(sd);
  8285. } else if ( strcmpi(key,"ban") == 0 ) {
  8286. return channel_pcban(sd,sub1,sub2,0);
  8287. } else if ( strcmpi(key,"kick") == 0 ) {
  8288. return channel_pckick(sd,sub1,sub2);
  8289. } else if ( strcmpi(key,"banlist") == 0 ) {
  8290. return channel_pcban(sd,sub1,NULL,3);
  8291. } else if ( strcmpi(key,"unban") == 0 ) {
  8292. return channel_pcban(sd,sub1,sub2,1);
  8293. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8294. return channel_pcban(sd,sub1,NULL,2);
  8295. } else {
  8296. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8297. sub3[0] = sub4[0] = '\0';
  8298. sscanf(sub2, "%19s %19s", sub3, sub4);
  8299. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8300. if (sub4[0] != '\0') {
  8301. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8302. return -1;
  8303. }
  8304. return channel_pccreate(sd,sub1,sub3);
  8305. } else if ( strcmpi(key,"setopt") == 0 ) {
  8306. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8307. }
  8308. atcmd_channel_help(sd,command);
  8309. }
  8310. return 0;
  8311. }
  8312. ACMD_FUNC(fontcolor)
  8313. {
  8314. if( !message || !*message ) {
  8315. channel_display_list(sd,"colors");
  8316. return -1;
  8317. }
  8318. if( strcmpi(message,"Normal") == 0 ) {
  8319. sd->fontcolor = 0;
  8320. } else {
  8321. unsigned char k;
  8322. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8323. if( k == channel_config.colors_count ) {
  8324. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8325. clif_displaymessage(fd, atcmd_output);
  8326. return -1;
  8327. }
  8328. sd->fontcolor = k;
  8329. }
  8330. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8331. clif_displaymessage(fd, atcmd_output);
  8332. return 0;
  8333. }
  8334. ACMD_FUNC(langtype)
  8335. {
  8336. char langstr[8];
  8337. int i=0, fail=0;
  8338. memset(langstr, '\0', sizeof(langstr));
  8339. if(sscanf(message, "%3s", langstr) >= 1){
  8340. int lang=0;
  8341. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8342. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8343. char output[100];
  8344. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8345. sd->langtype = lang;
  8346. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8347. clif_displaymessage(fd,output);
  8348. return 0;
  8349. } else if (lang != -1) { //defined langage but failed check
  8350. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8351. return -1;
  8352. }
  8353. }
  8354. //wrong or no entry
  8355. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8356. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8357. while(fail != -1){ //out of range
  8358. fail = msg_checklangtype(i,false);
  8359. if(fail == 1)
  8360. clif_displaymessage(fd,msg_langtype2langstr(i));
  8361. i++;
  8362. }
  8363. return -1;
  8364. }
  8365. #ifdef VIP_ENABLE
  8366. ACMD_FUNC(vip) {
  8367. struct map_session_data *pl_sd = NULL;
  8368. char * modif_p;
  8369. int32 vipdifftime = 0;
  8370. time_t now=time(NULL);
  8371. nullpo_retr(-1, sd);
  8372. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8373. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8374. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8375. return -1;
  8376. }
  8377. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8378. modif_p = atcmd_output;
  8379. vipdifftime = (int32)solve_time(modif_p);
  8380. if (vipdifftime == 0) {
  8381. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8382. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  8383. return -1;
  8384. }
  8385. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8386. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8387. return -1;
  8388. }
  8389. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8390. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8391. return -1;
  8392. }
  8393. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8394. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8395. if (pl_sd->vip.time <= now) {
  8396. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8397. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8398. } else {
  8399. int year,month,day,hour,minute,second;
  8400. char timestr[21];
  8401. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8402. sprintf(atcmd_output,msg_txt(pl_sd,705),year,month,day,hour,minute); // Your VIP status is valid for %d years, %d months, %d days, %d hours and %d minutes.
  8403. clif_displaymessage(pl_sd->fd,atcmd_output);
  8404. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8405. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8406. clif_displaymessage(pl_sd->fd,atcmd_output);
  8407. if (pl_sd != sd) {
  8408. sprintf(atcmd_output,msg_txt(sd,706),pl_sd->status.name,year,month,day,hour,minute); // Player '%s' is now VIP for %d years, %d months, %d days, %d hours and %d minutes.
  8409. clif_displaymessage(fd,atcmd_output);
  8410. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8411. clif_displaymessage(fd,atcmd_output);
  8412. }
  8413. }
  8414. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8415. return 0;
  8416. }
  8417. /** Enable/disable rate info */
  8418. ACMD_FUNC(showrate) {
  8419. nullpo_retr(-1,sd);
  8420. if (!sd->vip.disableshowrate) {
  8421. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8422. sd->vip.disableshowrate = 1;
  8423. } else {
  8424. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8425. sd->vip.disableshowrate = 0;
  8426. }
  8427. clif_displaymessage(fd,atcmd_output);
  8428. return 0;
  8429. }
  8430. #endif
  8431. ACMD_FUNC(fullstrip) {
  8432. int i;
  8433. TBL_PC *tsd;
  8434. nullpo_retr(-1,sd);
  8435. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8436. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8437. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8438. return -1;
  8439. }
  8440. if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
  8441. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8442. return -1;
  8443. }
  8444. for( i = 0; i < EQI_MAX; i++ ) {
  8445. if( tsd->equip_index[ i ] >= 0 )
  8446. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8447. }
  8448. return 0;
  8449. }
  8450. ACMD_FUNC(changedress){
  8451. sc_type name2id[] = {
  8452. SC_WEDDING,
  8453. SC_XMAS,
  8454. SC_SUMMER,
  8455. SC_DRESSUP,
  8456. SC_HANBOK,
  8457. SC_OKTOBERFEST
  8458. };
  8459. for( sc_type type : name2id ) {
  8460. if( sd->sc.data[type] ) {
  8461. status_change_end( &sd->bl, type, INVALID_TIMER );
  8462. // You should only be able to have one - so we cancel here
  8463. break;
  8464. }
  8465. }
  8466. return 0;
  8467. }
  8468. ACMD_FUNC(costume) {
  8469. const char* names[] = {
  8470. "Wedding",
  8471. "Xmas",
  8472. "Summer",
  8473. "Summer2",
  8474. "Hanbok",
  8475. "Oktoberfest"
  8476. };
  8477. const int name2id[] = {
  8478. SC_WEDDING,
  8479. SC_XMAS,
  8480. SC_SUMMER,
  8481. SC_DRESSUP,
  8482. SC_HANBOK,
  8483. SC_OKTOBERFEST
  8484. };
  8485. unsigned short k = 0, len = ARRAYLENGTH(names);
  8486. if( !message || !*message ) {
  8487. for( k = 0; k < len; k++ ) {
  8488. if( sd->sc.data[name2id[k]] ) {
  8489. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8490. clif_displaymessage(sd->fd, atcmd_output);
  8491. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8492. return 0;
  8493. }
  8494. }
  8495. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8496. for( k = 0; k < len; k++ ) {
  8497. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8498. clif_displaymessage(sd->fd, atcmd_output);
  8499. }
  8500. return -1;
  8501. }
  8502. for( k = 0; k < len; k++ ) {
  8503. if( sd->sc.data[name2id[k]] ) {
  8504. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8505. clif_displaymessage(sd->fd, atcmd_output);
  8506. return -1;
  8507. }
  8508. }
  8509. for( k = 0; k < len; k++ )
  8510. if( strcmpi(message, names[k]) == 0 )
  8511. break;
  8512. if( k == len ) {
  8513. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8514. clif_displaymessage(sd->fd, atcmd_output);
  8515. return -1;
  8516. }
  8517. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  8518. return 0;
  8519. }
  8520. /**
  8521. * Clone other player's equipments
  8522. * Usage: @cloneequip <char name/ID>
  8523. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8524. * @author [Cydh], [Antares]
  8525. */
  8526. ACMD_FUNC(cloneequip) {
  8527. struct map_session_data *pl_sd;
  8528. nullpo_retr(-1, sd);
  8529. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8530. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8531. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8532. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8533. clif_displaymessage(fd, atcmd_output);
  8534. return -1;
  8535. }
  8536. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8537. clif_displaymessage(fd, msg_txt(sd, 3));
  8538. return -1;
  8539. }
  8540. if (sd == pl_sd) {
  8541. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8542. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8543. clif_displaymessage(fd, atcmd_output);
  8544. return -1;
  8545. }
  8546. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8547. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8548. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8549. clif_displaymessage(fd, atcmd_output);
  8550. return -1;
  8551. }
  8552. else {
  8553. int8 i;
  8554. for (i = 0; i < EQI_MAX; i++) {
  8555. short idx;
  8556. char flag = 0;
  8557. struct item tmp_item;
  8558. if ((idx = pl_sd->equip_index[i]) < 0)
  8559. continue;
  8560. if (i == EQI_AMMO)
  8561. continue;
  8562. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8563. continue;
  8564. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8565. if (itemdb_isspecial(tmp_item.card[0]))
  8566. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8567. tmp_item.bound = 0;
  8568. tmp_item.expire_time = 0;
  8569. tmp_item.unique_id = 0;
  8570. tmp_item.favorite = 0;
  8571. tmp_item.amount = 1;
  8572. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8573. clif_additem(sd, 0, 0, flag);
  8574. else
  8575. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8576. }
  8577. }
  8578. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8579. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8580. clif_displaymessage(fd, atcmd_output);
  8581. return 0;
  8582. }
  8583. /**
  8584. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8585. * Usage: @clonestat <char name/ID>
  8586. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8587. * @author [Cydh], [Antares]
  8588. */
  8589. ACMD_FUNC(clonestat) {
  8590. struct map_session_data *pl_sd;
  8591. nullpo_retr(-1, sd);
  8592. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8593. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8594. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8595. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8596. clif_displaymessage(fd, atcmd_output);
  8597. return -1;
  8598. }
  8599. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8600. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8601. return -1;
  8602. }
  8603. if (sd == pl_sd) {
  8604. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8605. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8606. clif_displaymessage(fd, atcmd_output);
  8607. return -1;
  8608. }
  8609. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8610. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8611. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8612. clif_displaymessage(fd, atcmd_output);
  8613. return -1;
  8614. }
  8615. else {
  8616. uint8 i;
  8617. short max_status[6];
  8618. pc_resetstate(sd);
  8619. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8620. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8621. else {
  8622. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8623. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8624. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8625. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8626. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8627. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8628. }
  8629. #define clonestat_check(cmd,stat)\
  8630. {\
  8631. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8632. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8633. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8634. clif_displaymessage(fd, atcmd_output);\
  8635. sd->status.cmd = max_status[(stat)];\
  8636. }\
  8637. else\
  8638. sd->status.cmd = pl_sd->status.cmd;\
  8639. }
  8640. clonestat_check(str, PARAM_STR);
  8641. clonestat_check(agi, PARAM_AGI);
  8642. clonestat_check(vit, PARAM_VIT);
  8643. clonestat_check(int_, PARAM_INT);
  8644. clonestat_check(dex, PARAM_DEX);
  8645. clonestat_check(luk, PARAM_LUK);
  8646. for (i = 0; i < PARAM_MAX; i++) {
  8647. clif_updatestatus(sd, SP_STR + i);
  8648. clif_updatestatus(sd, SP_USTR + i);
  8649. }
  8650. status_calc_pc(sd, SCO_FORCE);
  8651. }
  8652. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8653. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  8654. clif_displaymessage(fd, atcmd_output);
  8655. #undef clonestat_check
  8656. return 0;
  8657. }
  8658. /**
  8659. * Adopt a character.
  8660. * Usage: @adopt <char name>
  8661. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8662. */
  8663. ACMD_FUNC(adopt)
  8664. {
  8665. TBL_PC *b_sd;
  8666. enum adopt_responses response;
  8667. nullpo_retr(-1, sd);
  8668. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8669. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8670. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8671. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8672. clif_displaymessage(fd, atcmd_output);
  8673. return -1;
  8674. }
  8675. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8676. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8677. return -1;
  8678. }
  8679. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8680. if (response == ADOPT_ALLOWED) {
  8681. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8682. b_sd->adopt_invite = sd->status.account_id;
  8683. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8684. return 0;
  8685. }
  8686. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8687. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8688. return -1;
  8689. }
  8690. /**
  8691. * Opens the limited sale window.
  8692. * Usage: @limitedsale or client command /limitedsale on supported clients
  8693. */
  8694. ACMD_FUNC(limitedsale){
  8695. nullpo_retr(-1, sd);
  8696. clif_sale_open(sd);
  8697. return 0;
  8698. }
  8699. /**
  8700. * Displays camera information from the client.
  8701. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  8702. */
  8703. ACMD_FUNC(camerainfo){
  8704. nullpo_retr(-1, sd);
  8705. if( message == nullptr || message[0] == '\0' ){
  8706. clif_camerainfo( sd, true );
  8707. return 0;
  8708. }
  8709. float range = 0;
  8710. float rotation = 0;
  8711. float latitude = 0;
  8712. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  8713. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  8714. return -1;
  8715. }
  8716. clif_camerainfo( sd, false, range, rotation, latitude );
  8717. return 0;
  8718. }
  8719. ACMD_FUNC(resurrect) {
  8720. nullpo_retr(-1, sd);
  8721. if (!pc_revive_item(sd))
  8722. return -1;
  8723. return 0;
  8724. }
  8725. ACMD_FUNC(quest) {
  8726. uint8 i;
  8727. int quest_id = 0;
  8728. nullpo_retr(-1, sd);
  8729. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8730. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  8731. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  8732. clif_displaymessage(fd, atcmd_output);
  8733. return -1;
  8734. }
  8735. if (!quest_search(quest_id)) {
  8736. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  8737. clif_displaymessage(fd, atcmd_output);
  8738. return -1;
  8739. }
  8740. const char* type[] = { "setquest", "erasequest", "completequest", "checkquest" };
  8741. ARR_FIND( 0, ARRAYLENGTH(type), i, strcmpi(command+1, type[i]) == 0 );
  8742. switch(i) {
  8743. case 0:
  8744. if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
  8745. sprintf(atcmd_output, msg_txt(sd,1507), quest_id); // Character already has quest %d.
  8746. clif_displaymessage(fd, atcmd_output);
  8747. return -1;
  8748. }
  8749. quest_add(sd, quest_id);
  8750. pc_show_questinfo(sd);
  8751. break;
  8752. case 1:
  8753. if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
  8754. sprintf(atcmd_output, msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
  8755. clif_displaymessage(fd, atcmd_output);
  8756. return -1;
  8757. }
  8758. quest_delete(sd, quest_id);
  8759. pc_show_questinfo(sd);
  8760. break;
  8761. case 2:
  8762. if (quest_check(sd, quest_id, HAVEQUEST) < 0)
  8763. quest_add(sd, quest_id);
  8764. if (quest_check(sd, quest_id, HAVEQUEST) < 2)
  8765. quest_update_status(sd, quest_id, Q_COMPLETE);
  8766. pc_show_questinfo(sd);
  8767. break;
  8768. case 3:
  8769. sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
  8770. clif_displaymessage(fd, atcmd_output);
  8771. sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST)); // HAVEQUEST : %d
  8772. clif_displaymessage(fd, atcmd_output);
  8773. sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING)); // HUNTING : %d
  8774. clif_displaymessage(fd, atcmd_output);
  8775. sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME)); // PLAYTIME : %d
  8776. clif_displaymessage(fd, atcmd_output);
  8777. break;
  8778. }
  8779. return 0;
  8780. }
  8781. #include "../custom/atcommand.inc"
  8782. /**
  8783. * Fills the reference of available commands in atcommand DBMap
  8784. **/
  8785. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8786. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8787. // Define with restriction
  8788. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8789. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8790. void atcommand_basecommands(void) {
  8791. /**
  8792. * Command reference list, place the base of your commands here
  8793. * TODO: List all commands that causing crash
  8794. **/
  8795. AtCommandInfo atcommand_base[] = {
  8796. #include "../custom/atcommand_def.inc"
  8797. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8798. ACMD_DEF(where),
  8799. ACMD_DEF(jumpto),
  8800. ACMD_DEF(jump),
  8801. ACMD_DEF(who),
  8802. ACMD_DEF2("who2", who),
  8803. ACMD_DEF2("who3", who),
  8804. ACMD_DEF2("whomap", who),
  8805. ACMD_DEF2("whomap2", who),
  8806. ACMD_DEF2("whomap3", who),
  8807. ACMD_DEF(whogm),
  8808. ACMD_DEF(save),
  8809. ACMD_DEF(load),
  8810. ACMD_DEF(speed),
  8811. ACMD_DEF(storage),
  8812. ACMD_DEF(guildstorage),
  8813. ACMD_DEF(option),
  8814. ACMD_DEF(hide), // + /hide
  8815. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8816. ACMD_DEF(kill),
  8817. ACMD_DEF(alive),
  8818. ACMD_DEF(kami),
  8819. ACMD_DEF2("kamib", kami),
  8820. ACMD_DEF2("kamic", kami),
  8821. ACMD_DEF2("lkami", kami),
  8822. ACMD_DEF(heal),
  8823. ACMD_DEF(item),
  8824. ACMD_DEF(item2),
  8825. ACMD_DEF2("itembound",item),
  8826. ACMD_DEF2("itembound2",item2),
  8827. ACMD_DEF(itemreset),
  8828. ACMD_DEF(clearstorage),
  8829. ACMD_DEF(cleargstorage),
  8830. ACMD_DEF(clearcart),
  8831. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8832. ACMD_DEF2("jlvl", joblevelup),
  8833. ACMD_DEF(help),
  8834. ACMD_DEF(pvpoff),
  8835. ACMD_DEF(pvpon),
  8836. ACMD_DEF(gvgoff),
  8837. ACMD_DEF(gvgon),
  8838. ACMD_DEF(model),
  8839. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8840. ACMD_DEF(monster),
  8841. ACMD_DEF2("monstersmall", monster),
  8842. ACMD_DEF2("monsterbig", monster),
  8843. ACMD_DEF(killmonster),
  8844. ACMD_DEF2("killmonster2", killmonster),
  8845. ACMD_DEF(refine),
  8846. ACMD_DEF(produce),
  8847. ACMD_DEF(memo),
  8848. ACMD_DEF(gat),
  8849. ACMD_DEF(displaystatus),
  8850. ACMD_DEF2("stpoint", statuspoint),
  8851. ACMD_DEF2("skpoint", skillpoint),
  8852. ACMD_DEF(zeny),
  8853. ACMD_DEF2("str", param),
  8854. ACMD_DEF2("agi", param),
  8855. ACMD_DEF2("vit", param),
  8856. ACMD_DEF2("int", param),
  8857. ACMD_DEF2("dex", param),
  8858. ACMD_DEF2("luk", param),
  8859. ACMD_DEF2("glvl", guildlevelup),
  8860. ACMD_DEF(makeegg),
  8861. ACMD_DEF(hatch),
  8862. ACMD_DEF(petfriendly),
  8863. ACMD_DEF(pethungry),
  8864. ACMD_DEF(petrename),
  8865. ACMD_DEF(recall), // + /recall
  8866. ACMD_DEF(night),
  8867. ACMD_DEF(day),
  8868. ACMD_DEF(doom),
  8869. ACMD_DEF(doommap),
  8870. ACMD_DEF(raise),
  8871. ACMD_DEF(raisemap),
  8872. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8873. ACMD_DEF(kickall),
  8874. ACMD_DEF(allskill),
  8875. ACMD_DEF(questskill),
  8876. ACMD_DEF(lostskill),
  8877. ACMD_DEF(spiritball),
  8878. ACMD_DEF(soulball),
  8879. ACMD_DEF(party),
  8880. ACMD_DEF(guild),
  8881. ACMD_DEF(breakguild),
  8882. ACMD_DEF(agitstart),
  8883. ACMD_DEF(agitend),
  8884. ACMD_DEF(mapexit),
  8885. ACMD_DEF(idsearch),
  8886. ACMD_DEF(broadcast), // + /b and /nb
  8887. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8888. ACMD_DEF(recallall),
  8889. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8890. ACMD_DEF2("reloaditemdb", reload),
  8891. ACMD_DEF2("reloadmobdb", reload),
  8892. ACMD_DEF2("reloadskilldb", reload),
  8893. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8894. ACMD_DEF2("reloadatcommand", reload),
  8895. ACMD_DEF2("reloadbattleconf", reload),
  8896. ACMD_DEF2("reloadstatusdb", reload),
  8897. ACMD_DEF2("reloadpcdb", reload),
  8898. ACMD_DEF2("reloadmotd", reload),
  8899. ACMD_DEF2("reloadquestdb", reload),
  8900. ACMD_DEF2("reloadmsgconf", reload),
  8901. ACMD_DEF2("reloadinstancedb", reload),
  8902. ACMD_DEF2("reloadachievementdb",reload),
  8903. ACMD_DEF2("reloadattendancedb",reload),
  8904. ACMD_DEF(partysharelvl),
  8905. ACMD_DEF(mapinfo),
  8906. ACMD_DEF(dye),
  8907. ACMD_DEF2("hairstyle", hair_style),
  8908. ACMD_DEF2("haircolor", hair_color),
  8909. ACMD_DEF2("allstats", stat_all),
  8910. ACMD_DEF2("block", char_block),
  8911. ACMD_DEF2("ban", char_ban),
  8912. ACMD_DEF2("unblock", char_unblock),
  8913. ACMD_DEF2("unban", char_unban),
  8914. ACMD_DEF2("charban", char_ban),
  8915. ACMD_DEF2("charunban", char_unban),
  8916. ACMD_DEF2("mount", mount_peco),
  8917. ACMD_DEF(guildspy),
  8918. ACMD_DEF(partyspy),
  8919. ACMD_DEF(clanspy),
  8920. ACMD_DEF(repairall),
  8921. ACMD_DEF(guildrecall),
  8922. ACMD_DEF(partyrecall),
  8923. ACMD_DEF(nuke),
  8924. ACMD_DEF(shownpc),
  8925. ACMD_DEF(hidenpc),
  8926. ACMD_DEF(loadnpc),
  8927. ACMD_DEF(unloadnpc),
  8928. ACMD_DEF(reloadnpcfile),
  8929. ACMD_DEF2("time", servertime),
  8930. ACMD_DEF(jail),
  8931. ACMD_DEF(unjail),
  8932. ACMD_DEF(jailfor),
  8933. ACMD_DEF(jailtime),
  8934. ACMD_DEF(disguise),
  8935. ACMD_DEF(undisguise),
  8936. ACMD_DEF(email),
  8937. ACMD_DEF(effect),
  8938. ACMD_DEF(follow),
  8939. ACMD_DEF(addwarp),
  8940. ACMD_DEF(skillon),
  8941. ACMD_DEF(skilloff),
  8942. ACMD_DEF(killer),
  8943. ACMD_DEF(npcmove),
  8944. ACMD_DEF(killable),
  8945. ACMD_DEF(dropall),
  8946. ACMD_DEF(storeall),
  8947. ACMD_DEF(skillid),
  8948. ACMD_DEF(useskill),
  8949. ACMD_DEF(displayskill),
  8950. ACMD_DEF(snow),
  8951. ACMD_DEF(sakura),
  8952. ACMD_DEF(clouds),
  8953. ACMD_DEF(clouds2),
  8954. ACMD_DEF(fog),
  8955. ACMD_DEF(fireworks),
  8956. ACMD_DEF(leaves),
  8957. ACMD_DEF(summon),
  8958. ACMD_DEF(adjgroup),
  8959. ACMD_DEF(trade),
  8960. ACMD_DEF(send),
  8961. ACMD_DEF(setbattleflag),
  8962. ACMD_DEF(unmute),
  8963. ACMD_DEF(clearweather),
  8964. ACMD_DEF(uptime),
  8965. ACMD_DEF(changesex),
  8966. ACMD_DEF(changecharsex),
  8967. ACMD_DEF(mute),
  8968. ACMD_DEF(refresh),
  8969. ACMD_DEF(refreshall),
  8970. ACMD_DEF(identify),
  8971. ACMD_DEF(identifyall),
  8972. ACMD_DEF(gmotd),
  8973. ACMD_DEF(misceffect),
  8974. ACMD_DEF(mobsearch),
  8975. ACMD_DEF(cleanmap),
  8976. ACMD_DEF(cleanarea),
  8977. ACMD_DEF(npctalk),
  8978. ACMD_DEF(pettalk),
  8979. ACMD_DEF(users),
  8980. ACMD_DEF(reset),
  8981. ACMD_DEF(skilltree),
  8982. ACMD_DEF(marry),
  8983. ACMD_DEF(divorce),
  8984. ACMD_DEF(sound),
  8985. ACMD_DEF(undisguiseall),
  8986. ACMD_DEF(disguiseall),
  8987. ACMD_DEF(changelook),
  8988. ACMD_DEF(autoloot),
  8989. ACMD_DEF2("alootid", autolootitem),
  8990. ACMD_DEF(autoloottype),
  8991. ACMD_DEF(mobinfo),
  8992. ACMD_DEF(exp),
  8993. ACMD_DEF(version),
  8994. ACMD_DEF(mutearea),
  8995. ACMD_DEF(rates),
  8996. ACMD_DEF(iteminfo),
  8997. ACMD_DEF(whodrops),
  8998. ACMD_DEF(whereis),
  8999. ACMD_DEF(mapflag),
  9000. ACMD_DEF(me),
  9001. ACMD_DEF(monsterignore),
  9002. ACMD_DEF(fakename),
  9003. ACMD_DEF(size),
  9004. ACMD_DEF(showexp),
  9005. ACMD_DEF(showzeny),
  9006. ACMD_DEF(showdelay),
  9007. ACMD_DEF(autotrade),
  9008. ACMD_DEF(changegm),
  9009. ACMD_DEF(changeleader),
  9010. ACMD_DEF(partyoption),
  9011. ACMD_DEF(invite),
  9012. ACMD_DEF(duel),
  9013. ACMD_DEF(leave),
  9014. ACMD_DEF(accept),
  9015. ACMD_DEF(reject),
  9016. ACMD_DEF(clone),
  9017. ACMD_DEF2("slaveclone", clone),
  9018. ACMD_DEF2("evilclone", clone),
  9019. ACMD_DEF(tonpc),
  9020. ACMD_DEF(commands),
  9021. ACMD_DEF(noask),
  9022. ACMD_DEF(request),
  9023. ACMD_DEF(homlevel),
  9024. ACMD_DEF(homevolution),
  9025. ACMD_DEF(hommutate),
  9026. ACMD_DEF(makehomun),
  9027. ACMD_DEF(homfriendly),
  9028. ACMD_DEF(homhungry),
  9029. ACMD_DEF(homtalk),
  9030. ACMD_DEF(hominfo),
  9031. ACMD_DEF(homstats),
  9032. ACMD_DEF(homshuffle),
  9033. ACMD_DEF(showmobs),
  9034. ACMD_DEF(feelreset),
  9035. ACMD_DEF(hatereset),
  9036. ACMD_DEF(auction),
  9037. ACMD_DEF(mail),
  9038. ACMD_DEF2("noks", ksprotection),
  9039. ACMD_DEF(allowks),
  9040. ACMD_DEF(cash),
  9041. ACMD_DEF2("points", cash),
  9042. ACMD_DEF(agitstart2),
  9043. ACMD_DEF(agitend2),
  9044. ACMD_DEF(resetskill),
  9045. ACMD_DEF(resetstat),
  9046. ACMD_DEF2("storagelist", itemlist),
  9047. ACMD_DEF2("cartlist", itemlist),
  9048. ACMD_DEF2("itemlist", itemlist),
  9049. ACMD_DEF(stats),
  9050. ACMD_DEF(delitem),
  9051. ACMD_DEF(charcommands),
  9052. ACMD_DEF(font),
  9053. ACMD_DEF(accinfo),
  9054. ACMD_DEF(set),
  9055. ACMD_DEF(undisguiseguild),
  9056. ACMD_DEF(disguiseguild),
  9057. ACMD_DEF(sizeall),
  9058. ACMD_DEF(sizeguild),
  9059. ACMD_DEF(addperm),
  9060. ACMD_DEF2("rmvperm", addperm),
  9061. ACMD_DEF(unloadnpcfile),
  9062. ACMD_DEF(cart),
  9063. ACMD_DEF(mount2),
  9064. ACMD_DEF(join),
  9065. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  9066. ACMD_DEF(fontcolor),
  9067. ACMD_DEF(langtype),
  9068. #ifdef VIP_ENABLE
  9069. ACMD_DEF(vip),
  9070. ACMD_DEF(showrate),
  9071. #endif
  9072. ACMD_DEF(fullstrip),
  9073. ACMD_DEF(costume),
  9074. ACMD_DEF(cloneequip),
  9075. ACMD_DEF(clonestat),
  9076. ACMD_DEF(bodystyle),
  9077. ACMD_DEF(adopt),
  9078. ACMD_DEF(agitstart3),
  9079. ACMD_DEF(agitend3),
  9080. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9081. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9082. ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9083. ACMD_DEFR(resurrect, ATCMD_NOCONSOLE),
  9084. ACMD_DEF2("setquest", quest),
  9085. ACMD_DEF2("erasequest", quest),
  9086. ACMD_DEF2("completequest", quest),
  9087. ACMD_DEF2("checkquest", quest),
  9088. };
  9089. AtCommandInfo* atcommand;
  9090. int i;
  9091. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9092. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9093. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9094. continue;
  9095. }
  9096. CREATE(atcommand, AtCommandInfo, 1);
  9097. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9098. atcommand->func = atcommand_base[i].func;
  9099. atcommand->restriction = atcommand_base[i].restriction;
  9100. strdb_put(atcommand_db, atcommand->command, atcommand);
  9101. }
  9102. return;
  9103. }
  9104. /*==========================================
  9105. * Command lookup functions
  9106. *------------------------------------------*/
  9107. bool atcommand_exists(const char* name)
  9108. {
  9109. return strdb_exists(atcommand_db, name);
  9110. }
  9111. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9112. {
  9113. if (strdb_exists(atcommand_db, name))
  9114. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9115. return NULL;
  9116. }
  9117. /// AtCommand suggestion
  9118. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  9119. DBIterator* atcommand_iter;
  9120. AtCommandInfo* command_info = NULL;
  9121. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9122. char* full_match[MAX_SUGGESTIONS];
  9123. char* suggestions[MAX_SUGGESTIONS];
  9124. char* match;
  9125. int prefix_count = 0, full_count = 0;
  9126. bool can_use;
  9127. if (!battle_config.atcommand_suggestions_enabled)
  9128. return;
  9129. atcommand_iter = db_iterator(atcommand_db);
  9130. // Build the matches
  9131. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  9132. match = strstr(command_info->command, name);
  9133. can_use = pc_can_use_command(sd, command_info->command, type);
  9134. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9135. suggestions[prefix_count] = command_info->command;
  9136. ++prefix_count;
  9137. }
  9138. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  9139. full_match[full_count] = command_info->command;
  9140. ++full_count;
  9141. }
  9142. }
  9143. for( auto& pair : atcommand_alias_db ){
  9144. std::shared_ptr<s_atcommand_alias_info> info = pair.second;
  9145. if( pc_can_use_command( sd, info->command->command, type ) ){
  9146. for( const std::string& alias_str : info->aliases ){
  9147. char* alias = const_cast<char *>(alias_str.c_str());
  9148. match = strstr( alias, name );
  9149. if( prefix_count < MAX_SUGGESTIONS && match == alias ){
  9150. suggestions[prefix_count] = alias;
  9151. ++prefix_count;
  9152. }
  9153. if( full_count < MAX_SUGGESTIONS && match != NULL && match != alias ){
  9154. full_match[full_count] = alias;
  9155. ++full_count;
  9156. }
  9157. }
  9158. }
  9159. }
  9160. if ((full_count+prefix_count) > 0) {
  9161. char buffer[512];
  9162. int i;
  9163. // Merge full match and prefix match results
  9164. if (prefix_count < MAX_SUGGESTIONS) {
  9165. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9166. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9167. }
  9168. // Build the suggestion string
  9169. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  9170. strcat(buffer,"\n");
  9171. for(i=0; i < prefix_count; ++i) {
  9172. strcat(buffer,suggestions[i]);
  9173. strcat(buffer," ");
  9174. }
  9175. clif_displaymessage(sd->fd, buffer);
  9176. }
  9177. dbi_destroy(atcommand_iter);
  9178. }
  9179. /**
  9180. * Executes an at-command
  9181. * @param fd
  9182. * @param sd
  9183. * @param message
  9184. * @param type
  9185. * 0 : script call (atcommand)
  9186. * 1 : normal player @atcommand
  9187. * 2 : console (admin:@atcommand)
  9188. * 3 : script call (useatcmd)
  9189. */
  9190. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  9191. {
  9192. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  9193. char output[CHAT_SIZE_MAX];
  9194. //Reconstructed message
  9195. char atcmd_msg[CHAT_SIZE_MAX * 2];
  9196. TBL_PC * ssd = NULL; //sd for target
  9197. AtCommandInfo * info;
  9198. bool is_atcommand = true; // false if it's a charcommand
  9199. nullpo_retr(false, sd);
  9200. //Shouldn't happen
  9201. if ( !message || !*message )
  9202. return false;
  9203. //If cannot use atcomamnd while talking with NPC [Kichi]
  9204. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  9205. return false;
  9206. //Block NOCHAT but do not display it as a normal message
  9207. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  9208. return true;
  9209. // skip 10/11-langtype's codepage indicator, if detected
  9210. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9211. message += 3;
  9212. //Should display as a normal message
  9213. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9214. return false;
  9215. // type value 0|2 = script|console invoked: bypass restrictions
  9216. if ( type == 1 || type == 3) {
  9217. //Commands are disabled on maps flagged as 'nocommand'
  9218. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  9219. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  9220. return false;
  9221. }
  9222. }
  9223. if (*message == charcommand_symbol)
  9224. is_atcommand = false;
  9225. if (is_atcommand) { // @command
  9226. sprintf(atcmd_msg, "%s", message);
  9227. ssd = sd;
  9228. } else { // #command
  9229. char charname[NAME_LENGTH];
  9230. int n;
  9231. //Checks to see if #command has a name or a name + parameters.
  9232. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  9233. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  9234. ) {
  9235. if (pc_get_group_level(sd) == 0) {
  9236. if (n < 1)
  9237. return false; // No command found. Display as normal message.
  9238. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9239. if (!info || info->char_groups[sd->group_pos] == 0) // If we can't use or doesn't exist: don't even display the command failed message
  9240. return false;
  9241. }
  9242. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9243. clif_displaymessage(fd, output);
  9244. return true;
  9245. }
  9246. ssd = map_nick2sd(charname,true);
  9247. if (ssd == NULL) {
  9248. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9249. clif_displaymessage(fd, output);
  9250. return true;
  9251. }
  9252. if (n > 2)
  9253. sprintf(atcmd_msg, "%s %s", command, params);
  9254. else
  9255. sprintf(atcmd_msg, "%s", command);
  9256. }
  9257. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9258. sd->idletime = last_tick;
  9259. if (battle_config.hom_idle_no_share && sd->hd && battle_config.idletime_hom_option&IDLE_ATCOMMAND)
  9260. sd->idletime_hom = last_tick;
  9261. //Clearing these to be used once more.
  9262. memset(command, '\0', sizeof(command));
  9263. memset(params, '\0', sizeof(params));
  9264. //check to see if any params exist within this command
  9265. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9266. params[0] = '\0';
  9267. if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
  9268. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9269. clif_displaymessage(fd, output);
  9270. return true;
  9271. }
  9272. // @commands (script based)
  9273. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9274. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9275. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  9276. if( binding != NULL && binding->npc_event[0] &&
  9277. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9278. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9279. {
  9280. // Check if self or character invoking; if self == character invoked, then self invoke.
  9281. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9282. return true;
  9283. }
  9284. }
  9285. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9286. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9287. if (info == NULL) {
  9288. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9289. return false;
  9290. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9291. clif_displaymessage(fd, output);
  9292. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9293. return true;
  9294. }
  9295. //check restriction
  9296. if (info->restriction) {
  9297. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9298. return true;
  9299. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9300. return true;
  9301. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9302. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9303. return true;
  9304. }
  9305. // type == 1 : player invoked
  9306. if (type == 1) {
  9307. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9308. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9309. return false;
  9310. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9311. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9312. return true;
  9313. }
  9314. }
  9315. //Attempt to use the command
  9316. if ( (info->func(fd, ssd, command, params) != 0) )
  9317. {
  9318. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9319. clif_displaymessage(fd, output);
  9320. return true;
  9321. }
  9322. //Log only if successful.
  9323. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9324. return true;
  9325. }
  9326. void atcommand_db_load_groups(int* group_ids) {
  9327. DBIterator *iter = db_iterator(atcommand_db);
  9328. AtCommandInfo* cmd;
  9329. int i;
  9330. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9331. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9332. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9333. for(i = 0; i < pc_group_max; i++) {
  9334. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9335. cmd->at_groups[i] = 1;
  9336. else
  9337. cmd->at_groups[i] = 0;
  9338. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9339. cmd->char_groups[i] = 1;
  9340. else
  9341. cmd->char_groups[i] = 0;
  9342. }
  9343. }
  9344. dbi_destroy(iter);
  9345. return;
  9346. }
  9347. void atcommand_db_clear(void) {
  9348. if (atcommand_db != NULL) {
  9349. DBIterator *iter = db_iterator(atcommand_db);
  9350. AtCommandInfo* cmd;
  9351. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9352. aFree(cmd->at_groups);
  9353. aFree(cmd->char_groups);
  9354. }
  9355. dbi_destroy(iter);
  9356. db_destroy(atcommand_db);
  9357. }
  9358. atcommand_alias_db.clear();
  9359. }
  9360. void atcommand_doload(void) {
  9361. atcommand_db_clear();
  9362. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9363. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9364. atcommand_alias_db.load();
  9365. }
  9366. void do_init_atcommand(void) {
  9367. atcommand_doload();
  9368. }
  9369. void do_final_atcommand(void) {
  9370. atcommand_db_clear();
  9371. }