atcommand.cpp 327 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "atcommand.hpp"
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include "../common/cbasetypes.h"
  7. #include "../common/mmo.h"
  8. #include "../common/timer.h"
  9. #include "../common/nullpo.h"
  10. #include "../common/showmsg.h"
  11. #include "../common/malloc.h"
  12. #include "../common/random.h"
  13. #include "../common/socket.h"
  14. #include "../common/strlib.h"
  15. #include "../common/utils.h"
  16. #include "../common/utilities.hpp"
  17. #include "../common/conf.h"
  18. #include "map.hpp"
  19. #include "battle.hpp"
  20. #include "chat.hpp"
  21. #include "channel.hpp"
  22. #include "chrif.hpp"
  23. #include "duel.hpp"
  24. #include "instance.hpp"
  25. #include "intif.hpp"
  26. #include "pet.hpp"
  27. #include "homunculus.hpp"
  28. #include "mail.hpp"
  29. #include "mercenary.hpp"
  30. #include "elemental.hpp"
  31. #include "party.hpp"
  32. #include "script.hpp"
  33. #include "storage.hpp"
  34. #include "trade.hpp"
  35. #include "mapreg.hpp"
  36. #include "quest.hpp"
  37. #include "pc.hpp"
  38. #include "pc_groups.hpp"
  39. #include "npc.hpp"
  40. #include "guild.hpp"
  41. #include "clif.hpp"
  42. #include "log.hpp"
  43. #include "itemdb.hpp" // MAX_ITEMGROUP
  44. #include "mob.hpp"
  45. #include "achievement.hpp"
  46. #include "clan.hpp"
  47. #define ATCOMMAND_LENGTH 50
  48. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  49. typedef struct AtCommandInfo AtCommandInfo;
  50. typedef struct AliasInfo AliasInfo;
  51. int atcmd_binding_count = 0;
  52. /// Atcommand restriction usage
  53. enum e_atcmd_restict {
  54. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  55. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  56. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  57. };
  58. struct AtCommandInfo {
  59. char command[ATCOMMAND_LENGTH];
  60. AtCommandFunc func;
  61. char* at_groups; /// Quick @commands "can-use" lookup
  62. char* char_groups; /// Quick @charcommands "can-use" lookup
  63. uint8 restriction; /// Restrictions see enum e_restict
  64. };
  65. struct AliasInfo {
  66. AtCommandInfo *command;
  67. char alias[ATCOMMAND_LENGTH];
  68. };
  69. char atcommand_symbol = '@'; // first char of the commands
  70. char charcommand_symbol = '#';
  71. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  72. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  73. static config_t atcommand_config;
  74. static char atcmd_output[CHAT_SIZE_MAX];
  75. static char atcmd_player_name[NAME_LENGTH];
  76. const char *parent_cmd;
  77. struct atcmd_binding_data** atcmd_binding;
  78. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  79. static const char* atcommand_checkalias(const char *aliasname); // @help
  80. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  81. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  82. // @commands (script-based)
  83. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  84. int i = 0;
  85. if( *name == atcommand_symbol || *name == charcommand_symbol )
  86. name++; // for backwards compatibility
  87. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  88. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  89. }
  90. /**
  91. * retrieves the help string associated with a given command.
  92. *
  93. * @param name the name of the command to retrieve help information for
  94. * @return the string associated with the command, or NULL
  95. */
  96. static const char* atcommand_help_string(const char* command)
  97. {
  98. const char* str = NULL;
  99. config_setting_t* info;
  100. if( *command == atcommand_symbol || *command == charcommand_symbol )
  101. {// remove the prefix symbol for the raw name of the command
  102. command ++;
  103. }
  104. // convert alias to the real command name
  105. command = atcommand_checkalias(command);
  106. // attempt to find the first default help command
  107. info = config_lookup(&atcommand_config, "help");
  108. if( info == NULL )
  109. {// failed to find the help property in the configuration file
  110. return NULL;
  111. }
  112. if( !config_setting_lookup_string( info, command, &str ) )
  113. {// failed to find the matching help string
  114. return NULL;
  115. }
  116. // push the result from the method
  117. return str;
  118. }
  119. /*==========================================
  120. * @send (used for testing packet sends from the client)
  121. *------------------------------------------*/
  122. ACMD_FUNC(send)
  123. {
  124. int len=0,type;
  125. // read message type as hex number (without the 0x)
  126. if(!message || !*message ||
  127. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  128. || sscanf(message, "%8x", &type)==1) )
  129. {
  130. int i;
  131. for (i = 900; i <= 903; ++i)
  132. clif_displaymessage(fd, msg_txt(sd,i));
  133. return -1;
  134. }
  135. #define PARSE_ERROR(error,p) \
  136. {\
  137. clif_displaymessage(fd, (error));\
  138. sprintf(atcmd_output, ">%s", (p));\
  139. clif_displaymessage(fd, atcmd_output);\
  140. }
  141. //define PARSE_ERROR
  142. #define CHECK_EOS(p) \
  143. if(*(p) == 0){\
  144. clif_displaymessage(fd, "Unexpected end of string");\
  145. return -1;\
  146. }
  147. //define CHECK_EOS
  148. #define SKIP_VALUE(p) \
  149. {\
  150. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  151. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  152. }
  153. //define SKIP_VALUE
  154. #define GET_VALUE(p,num) \
  155. {\
  156. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  157. PARSE_ERROR("Invalid number in:",(p));\
  158. return -1;\
  159. }\
  160. }
  161. //define GET_VALUE
  162. if (type > 0 && type < MAX_PACKET_DB) {
  163. int off,end;
  164. long num;
  165. if(len)
  166. {// show packet length
  167. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  168. clif_displaymessage(fd, atcmd_output);
  169. return 0;
  170. }
  171. len=packet_db[type].len;
  172. off=2;
  173. if(len == 0)
  174. {// unknown packet - ERROR
  175. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  176. clif_displaymessage(fd, atcmd_output);
  177. return -1;
  178. } else if(len == -1)
  179. {// dynamic packet
  180. len=SHRT_MAX-4; // maximum length
  181. off=4;
  182. }
  183. WFIFOHEAD(fd, len);
  184. WFIFOW(fd,0)=TOW(type);
  185. // parse packet contents
  186. SKIP_VALUE(message);
  187. while(*message != 0 && off < len){
  188. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  189. {// default (byte)
  190. GET_VALUE(message,num);
  191. WFIFOB(fd,off)=TOB(num);
  192. ++off;
  193. } else if(TOUPPER(*message) == 'B')
  194. {// byte
  195. ++message;
  196. GET_VALUE(message,num);
  197. WFIFOB(fd,off)=TOB(num);
  198. ++off;
  199. } else if(TOUPPER(*message) == 'W')
  200. {// word (2 bytes)
  201. ++message;
  202. GET_VALUE(message,num);
  203. WFIFOW(fd,off)=TOW(num);
  204. off+=2;
  205. } else if(TOUPPER(*message) == 'L')
  206. {// long word (4 bytes)
  207. ++message;
  208. GET_VALUE(message,num);
  209. WFIFOL(fd,off)=TOL(num);
  210. off+=4;
  211. } else if(TOUPPER(*message) == 'S')
  212. {// string - escapes are valid
  213. // get string length - num <= 0 means not fixed length (default)
  214. ++message;
  215. if(*message == '"'){
  216. num=0;
  217. } else {
  218. GET_VALUE(message,num);
  219. while(*message != '"')
  220. {// find start of string
  221. if(*message == 0 || ISSPACE(*message)){
  222. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  223. return -1;
  224. }
  225. ++message;
  226. }
  227. }
  228. // parse string
  229. ++message;
  230. CHECK_EOS(message);
  231. end=(num<=0? 0: min(off+((int)num),len));
  232. for(; *message != '"' && (off < end || end == 0); ++off){
  233. if(*message == '\\'){
  234. ++message;
  235. CHECK_EOS(message);
  236. switch(*message){
  237. case 'a': num=0x07; break; // Bell
  238. case 'b': num=0x08; break; // Backspace
  239. case 't': num=0x09; break; // Horizontal tab
  240. case 'n': num=0x0A; break; // Line feed
  241. case 'v': num=0x0B; break; // Vertical tab
  242. case 'f': num=0x0C; break; // Form feed
  243. case 'r': num=0x0D; break; // Carriage return
  244. case 'e': num=0x1B; break; // Escape
  245. default: num=*message; break;
  246. case 'x': // Hexadecimal
  247. {
  248. ++message;
  249. CHECK_EOS(message);
  250. if(!ISXDIGIT(*message)){
  251. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  252. return -1;
  253. }
  254. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  255. if(ISXDIGIT(*message)){
  256. ++message;
  257. CHECK_EOS(message);
  258. num<<=8;
  259. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  260. }
  261. WFIFOB(fd,off)=TOB(num);
  262. ++message;
  263. CHECK_EOS(message);
  264. continue;
  265. }
  266. case '0':
  267. case '1':
  268. case '2':
  269. case '3':
  270. case '4':
  271. case '5':
  272. case '6':
  273. case '7': // Octal
  274. {
  275. num=*message-'0'; // 1st octal digit
  276. ++message;
  277. CHECK_EOS(message);
  278. if(ISDIGIT(*message) && *message < '8'){
  279. num<<=3;
  280. num+=*message-'0'; // 2nd octal digit
  281. ++message;
  282. CHECK_EOS(message);
  283. if(ISDIGIT(*message) && *message < '8'){
  284. num<<=3;
  285. num+=*message-'0'; // 3rd octal digit
  286. ++message;
  287. CHECK_EOS(message);
  288. }
  289. }
  290. WFIFOB(fd,off)=TOB(num);
  291. continue;
  292. }
  293. }
  294. } else
  295. num=*message;
  296. WFIFOB(fd,off)=TOB(num);
  297. ++message;
  298. CHECK_EOS(message);
  299. }//for
  300. while(*message != '"')
  301. {// ignore extra characters
  302. ++message;
  303. CHECK_EOS(message);
  304. }
  305. // terminate the string
  306. if(off < end)
  307. {// fill the rest with 0's
  308. memset(WFIFOP(fd,off),0,end-off);
  309. off=end;
  310. }
  311. } else
  312. {// unknown
  313. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  314. return -1;
  315. }
  316. SKIP_VALUE(message);
  317. }
  318. if(packet_db[type].len == -1)
  319. {// send dynamic packet
  320. WFIFOW(fd,2)=TOW(off);
  321. WFIFOSET(fd,off);
  322. } else
  323. {// send static packet
  324. if(off < len)
  325. memset(WFIFOP(fd,off),0,len-off);
  326. WFIFOSET(fd,len);
  327. }
  328. } else {
  329. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  330. return -1;
  331. }
  332. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  333. clif_displaymessage(fd, atcmd_output);
  334. return 0;
  335. #undef PARSE_ERROR
  336. #undef CHECK_EOS
  337. #undef SKIP_VALUE
  338. #undef GET_VALUE
  339. }
  340. /**
  341. * Retrieves map name suggestions for a given string.
  342. * This will first check if any map names contain the given string, and will
  343. * print out MAX_SUGGESTIONS results if any maps are found.
  344. * Otherwise, suggestions will be calculated through Levenshtein distance,
  345. * and up to 5 of the closest matches will be printed.
  346. *
  347. * @author Euphy
  348. */
  349. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  350. char buffer[512];
  351. int i, count = 0;
  352. if (strlen(name) < 2)
  353. return;
  354. // build the suggestion string
  355. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  356. strcat(buffer, "\n");
  357. // check for maps that contain string
  358. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  359. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  360. strcat(buffer, map[i].name);
  361. strcat(buffer, " ");
  362. if (++count >= MAX_SUGGESTIONS)
  363. break;
  364. }
  365. }
  366. // if no maps found, search by edit distance
  367. if (!count) {
  368. unsigned int distance[MAX_MAP_PER_SERVER][2];
  369. int j;
  370. // calculate Levenshtein distance for all maps
  371. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  372. if (strlen(map[i].name) < 4) // invalid map name?
  373. distance[i][0] = INT_MAX;
  374. else {
  375. distance[i][0] = levenshtein(map[i].name, name);
  376. distance[i][1] = i;
  377. }
  378. }
  379. // selection sort elements as needed
  380. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  381. for (i = 0; i < count; i++) {
  382. int min = i;
  383. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  384. if (distance[j][0] < distance[min][0])
  385. min = j;
  386. }
  387. // print map name
  388. if (distance[min][0] > 4) { // awful results, don't bother
  389. if (!i) return;
  390. break;
  391. }
  392. strcat(buffer, map[distance[min][1]].name);
  393. strcat(buffer, " ");
  394. // swap elements
  395. SWAP(distance[i][0], distance[min][0]);
  396. SWAP(distance[i][1], distance[min][1]);
  397. }
  398. }
  399. clif_displaymessage(sd->fd, buffer);
  400. }
  401. /*==========================================
  402. * @rura, @warp, @mapmove
  403. *------------------------------------------*/
  404. ACMD_FUNC(mapmove)
  405. {
  406. char map_name[MAP_NAME_LENGTH_EXT];
  407. unsigned short mapindex;
  408. short x = 0, y = 0;
  409. int16 m = -1;
  410. nullpo_retr(-1, sd);
  411. memset(map_name, '\0', sizeof(map_name));
  412. if (!message || !*message ||
  413. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  414. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  415. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  416. return -1;
  417. }
  418. mapindex = mapindex_name2id(map_name);
  419. if (mapindex)
  420. m = map_mapindex2mapid(mapindex);
  421. if (!mapindex) { // m < 0 means on different server! [Kevin]
  422. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  423. if (battle_config.warp_suggestions_enabled)
  424. warp_get_suggestions(sd, map_name);
  425. return -1;
  426. }
  427. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  428. { //This is to prevent the pc_setpos call from printing an error.
  429. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  430. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  431. x = y = 0; //Invalid cell, use random spot.
  432. }
  433. if ((map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, sd->group_level)) {
  434. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  435. return -1;
  436. }
  437. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  438. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  439. return -1;
  440. }
  441. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  442. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  443. return -1;
  444. }
  445. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  446. return 0;
  447. }
  448. /*==========================================
  449. * Displays where a character is. Corrected version by Silent. [Skotlex]
  450. *------------------------------------------*/
  451. ACMD_FUNC(where)
  452. {
  453. struct map_session_data* pl_sd;
  454. nullpo_retr(-1, sd);
  455. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  456. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  457. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  458. return -1;
  459. }
  460. pl_sd = map_nick2sd(atcmd_player_name,true);
  461. if (pl_sd == NULL ||
  462. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  463. (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))
  464. ) {
  465. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  466. return -1;
  467. }
  468. 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);
  469. clif_displaymessage(fd, atcmd_output);
  470. return 0;
  471. }
  472. /*==========================================
  473. *
  474. *------------------------------------------*/
  475. ACMD_FUNC(jumpto)
  476. {
  477. struct map_session_data *pl_sd = NULL;
  478. nullpo_retr(-1, sd);
  479. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  480. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  481. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  482. return -1;
  483. }
  484. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  485. {
  486. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  487. return -1;
  488. }
  489. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  490. {
  491. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  492. return -1;
  493. }
  494. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  495. {
  496. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  497. return -1;
  498. }
  499. if( pc_isdead(sd) )
  500. {
  501. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  502. return -1;
  503. }
  504. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  505. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  506. clif_displaymessage(fd, atcmd_output);
  507. return 0;
  508. }
  509. /*==========================================
  510. *
  511. *------------------------------------------*/
  512. ACMD_FUNC(jump)
  513. {
  514. short x = 0, y = 0;
  515. nullpo_retr(-1, sd);
  516. memset(atcmd_output, '\0', sizeof(atcmd_output));
  517. sscanf(message, "%6hd %6hd", &x, &y);
  518. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  519. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  520. return -1;
  521. }
  522. if( pc_isdead(sd) )
  523. {
  524. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  525. return -1;
  526. }
  527. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  528. { //This is to prevent the pc_setpos call from printing an error.
  529. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  530. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  531. x = y = 0; //Invalid cell, use random spot.
  532. }
  533. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  534. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  535. clif_displaymessage(fd, atcmd_output);
  536. return 0;
  537. }
  538. /*==========================================
  539. * Display list of online characters with
  540. * various info.
  541. *------------------------------------------*/
  542. ACMD_FUNC(who) {
  543. struct map_session_data *pl_sd = NULL;
  544. struct s_mapiterator *iter = NULL;
  545. char player_name[NAME_LENGTH] = "";
  546. int count = 0;
  547. int level = 0;
  548. StringBuf buf;
  549. /**
  550. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  551. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  552. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  553. */
  554. int display_type = 1;
  555. int map_id = -1;
  556. nullpo_retr(-1, sd);
  557. if (strstr(command, "map") != NULL) {
  558. char map_name[MAP_NAME_LENGTH_EXT] = "";
  559. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  560. map_id = sd->bl.m;
  561. } else {
  562. sscanf(message, "%23s", player_name);
  563. }
  564. if (strstr(command, "2") != NULL)
  565. display_type = 2;
  566. else if (strstr(command, "3") != NULL)
  567. display_type = 3;
  568. level = pc_get_group_level(sd);
  569. StringBuf_Init(&buf);
  570. iter = mapit_getallusers();
  571. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  572. 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
  573. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  574. || (map_id >= 0 && pl_sd->bl.m != map_id))
  575. continue;
  576. switch (display_type) {
  577. case 2: {
  578. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  579. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  580. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  581. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  582. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  583. break;
  584. }
  585. case 3: {
  586. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  587. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  588. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  589. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  590. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  591. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  592. break;
  593. }
  594. default: {
  595. struct party_data *p = party_search(pl_sd->status.party_id);
  596. struct guild *g = pl_sd->guild;
  597. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  598. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  599. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  600. if (p != NULL)
  601. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  602. if (g != NULL)
  603. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  604. break;
  605. }
  606. }
  607. clif_displaymessage(fd, StringBuf_Value(&buf));
  608. StringBuf_Clear(&buf);
  609. count++;
  610. }
  611. }
  612. mapit_free(iter);
  613. if (map_id < 0) {
  614. if (count == 0)
  615. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  616. else if (count == 1)
  617. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  618. else
  619. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  620. } else {
  621. if (count == 0)
  622. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  623. else if (count == 1)
  624. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  625. else
  626. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  627. }
  628. clif_displaymessage(fd, StringBuf_Value(&buf));
  629. StringBuf_Destroy(&buf);
  630. return 0;
  631. }
  632. /*==========================================
  633. *
  634. *------------------------------------------*/
  635. ACMD_FUNC(whogm)
  636. {
  637. struct map_session_data* pl_sd;
  638. struct s_mapiterator* iter;
  639. int j, count;
  640. int level;
  641. char match_text[CHAT_SIZE_MAX];
  642. char player_name[NAME_LENGTH];
  643. struct guild *g;
  644. struct party_data *p;
  645. nullpo_retr(-1, sd);
  646. memset(atcmd_output, '\0', sizeof(atcmd_output));
  647. memset(match_text, '\0', sizeof(match_text));
  648. memset(player_name, '\0', sizeof(player_name));
  649. if (sscanf(message, "%255[^\n]", match_text) < 1)
  650. strcpy(match_text, "");
  651. for (j = 0; match_text[j]; j++)
  652. match_text[j] = TOLOWER(match_text[j]);
  653. count = 0;
  654. level = pc_get_group_level(sd);
  655. iter = mapit_getallusers();
  656. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  657. {
  658. int pl_level = pc_get_group_level(pl_sd);
  659. if (!pl_level)
  660. continue;
  661. if (match_text[0])
  662. {
  663. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  664. for (j = 0; player_name[j]; j++)
  665. player_name[j] = TOLOWER(player_name[j]);
  666. // search with no case sensitive
  667. if (strstr(player_name, match_text) == NULL)
  668. continue;
  669. }
  670. if (pl_level > level) {
  671. if (pc_isinvisible(pl_sd))
  672. continue;
  673. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  674. clif_displaymessage(fd, atcmd_output);
  675. count++;
  676. continue;
  677. }
  678. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  679. pl_sd->status.name, pl_level,
  680. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  681. clif_displaymessage(fd, atcmd_output);
  682. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  683. pl_sd->status.base_level,
  684. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  685. clif_displaymessage(fd, atcmd_output);
  686. p = party_search(pl_sd->status.party_id);
  687. g = pl_sd->guild;
  688. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  689. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  690. clif_displaymessage(fd, atcmd_output);
  691. count++;
  692. }
  693. mapit_free(iter);
  694. if (count == 0)
  695. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  696. else if (count == 1)
  697. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  698. else {
  699. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  700. clif_displaymessage(fd, atcmd_output);
  701. }
  702. return 0;
  703. }
  704. /*==========================================
  705. *
  706. *------------------------------------------*/
  707. ACMD_FUNC(save)
  708. {
  709. nullpo_retr(-1, sd);
  710. if( map[sd->bl.m].instance_id ) {
  711. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  712. return 1;
  713. }
  714. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  715. if (sd->status.pet_id > 0 && sd->pd)
  716. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  717. chrif_save(sd, CSAVE_NORMAL);
  718. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  719. return 0;
  720. }
  721. /*==========================================
  722. *
  723. *------------------------------------------*/
  724. ACMD_FUNC(load)
  725. {
  726. int16 m;
  727. nullpo_retr(-1, sd);
  728. m = map_mapindex2mapid(sd->status.save_point.map);
  729. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  730. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  731. return -1;
  732. }
  733. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  734. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  735. return -1;
  736. }
  737. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  738. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  739. return 0;
  740. }
  741. /*==========================================
  742. *
  743. *------------------------------------------*/
  744. ACMD_FUNC(speed)
  745. {
  746. short speed;
  747. nullpo_retr(-1, sd);
  748. memset(atcmd_output, '\0', sizeof(atcmd_output));
  749. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  750. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  751. clif_displaymessage(fd, atcmd_output);
  752. return -1;
  753. }
  754. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  755. if (speed < 0)
  756. sd->base_status.speed = DEFAULT_WALK_SPEED;
  757. else
  758. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  759. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  760. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  761. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  762. } else
  763. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  764. status_calc_bl(&sd->bl, SCB_SPEED);
  765. return 0;
  766. }
  767. /*==========================================
  768. *
  769. *------------------------------------------*/
  770. ACMD_FUNC(storage)
  771. {
  772. nullpo_retr(-1, sd);
  773. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  774. return -1;
  775. if (storage_storageopen(sd) == 1)
  776. { //Already open.
  777. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  778. return -1;
  779. }
  780. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  781. return 0;
  782. }
  783. /*==========================================
  784. *
  785. *------------------------------------------*/
  786. ACMD_FUNC(guildstorage)
  787. {
  788. nullpo_retr(-1, sd);
  789. if (!sd->status.guild_id) {
  790. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  791. return -1;
  792. }
  793. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  794. return -1;
  795. if (sd->state.storage_flag == 1) {
  796. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  797. return -1;
  798. }
  799. if (sd->state.storage_flag == 2) {
  800. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  801. return -1;
  802. }
  803. if (sd->state.storage_flag == 3) {
  804. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  805. return -1;
  806. }
  807. storage_guild_storageopen(sd);
  808. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  809. return 0;
  810. }
  811. /*==========================================
  812. *
  813. *------------------------------------------*/
  814. ACMD_FUNC(option)
  815. {
  816. int param1 = 0, param2 = 0, param3 = 0;
  817. nullpo_retr(-1, sd);
  818. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  819. {// failed to match the parameters so inform the user of the options
  820. const char* text;
  821. // attempt to find the setting information for this command
  822. text = atcommand_help_string( command );
  823. // notify the user of the requirement to enter an option
  824. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  825. if( text )
  826. {// send the help text associated with this command
  827. clif_displaymessage( fd, text );
  828. }
  829. return -1;
  830. }
  831. sd->sc.opt1 = param1;
  832. sd->sc.opt2 = param2;
  833. pc_setoption(sd, param3);
  834. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  835. return 0;
  836. }
  837. /*==========================================
  838. *
  839. *------------------------------------------*/
  840. ACMD_FUNC(hide)
  841. {
  842. nullpo_retr(-1, sd);
  843. if (pc_isinvisible(sd)) {
  844. sd->sc.option &= ~OPTION_INVISIBLE;
  845. if (sd->disguise)
  846. status_set_viewdata(&sd->bl, sd->disguise);
  847. else
  848. status_set_viewdata(&sd->bl, sd->status.class_);
  849. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  850. // increment the number of pvp players on the map
  851. map[sd->bl.m].users_pvp++;
  852. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  853. {// register the player for ranking calculations
  854. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  855. }
  856. //bugreport:2266
  857. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  858. } else {
  859. sd->sc.option |= OPTION_INVISIBLE;
  860. sd->vd.class_ = JT_INVISIBLE;
  861. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  862. // decrement the number of pvp players on the map
  863. map[sd->bl.m].users_pvp--;
  864. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  865. {// unregister the player for ranking
  866. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  867. sd->pvp_timer = INVALID_TIMER;
  868. }
  869. }
  870. clif_changeoption(&sd->bl);
  871. return 0;
  872. }
  873. /*==========================================
  874. * Changes a character's class
  875. *------------------------------------------*/
  876. ACMD_FUNC(jobchange)
  877. {
  878. int job = 0, upper = 0;
  879. const char* text;
  880. nullpo_retr(-1, sd);
  881. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  882. int i;
  883. bool found = false;
  884. upper = 0;
  885. // Normal Jobs
  886. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  887. if (strncmpi(message, job_name(i), 16) == 0) {
  888. job = i;
  889. found = true;
  890. }
  891. }
  892. // High Jobs, Babys and Third
  893. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  894. if (strncmpi(message, job_name(i), 16) == 0) {
  895. job = i;
  896. found = true;
  897. }
  898. }
  899. if (!found) {
  900. text = atcommand_help_string(command);
  901. if (text)
  902. clif_displaymessage(fd, text);
  903. return -1;
  904. }
  905. }
  906. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  907. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  908. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2)
  909. { // Deny direct transformation into dummy jobs
  910. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  911. return 0;
  912. }
  913. if (pcdb_checkid(job))
  914. {
  915. if (pc_jobchange(sd, job, upper))
  916. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  917. else {
  918. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  919. return -1;
  920. }
  921. } else {
  922. text = atcommand_help_string(command);
  923. if (text)
  924. clif_displaymessage(fd, text);
  925. return -1;
  926. }
  927. return 0;
  928. }
  929. /*==========================================
  930. *
  931. *------------------------------------------*/
  932. ACMD_FUNC(kill)
  933. {
  934. nullpo_retr(-1, sd);
  935. status_kill(&sd->bl);
  936. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  937. if (fd != sd->fd)
  938. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  939. return 0;
  940. }
  941. /*==========================================
  942. *
  943. *------------------------------------------*/
  944. ACMD_FUNC(alive)
  945. {
  946. nullpo_retr(-1, sd);
  947. if (!status_revive(&sd->bl, 100, 100))
  948. {
  949. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  950. return -1;
  951. }
  952. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  953. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  954. return 0;
  955. }
  956. /*==========================================
  957. * +kamic [LuzZza]
  958. *------------------------------------------*/
  959. ACMD_FUNC(kami)
  960. {
  961. unsigned long color=0;
  962. nullpo_retr(-1, sd);
  963. memset(atcmd_output, '\0', sizeof(atcmd_output));
  964. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  965. if (!message || !*message) {
  966. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  967. return -1;
  968. }
  969. sscanf(message, "%255[^\n]", atcmd_output);
  970. if (strstr(command, "l") != NULL)
  971. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  972. else
  973. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  974. } else {
  975. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  976. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  977. return -1;
  978. }
  979. if(color > 0xFFFFFF) {
  980. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  981. return -1;
  982. }
  983. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  984. }
  985. return 0;
  986. }
  987. /*==========================================
  988. *
  989. *------------------------------------------*/
  990. ACMD_FUNC(heal)
  991. {
  992. int hp = 0, sp = 0; // [Valaris] thanks to fov
  993. nullpo_retr(-1, sd);
  994. sscanf(message, "%11d %11d", &hp, &sp);
  995. // some overflow checks
  996. if( hp == INT_MIN ) hp++;
  997. if( sp == INT_MIN ) sp++;
  998. if ( hp == 0 && sp == 0 ) {
  999. if (!status_percent_heal(&sd->bl, 100, 100))
  1000. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1001. else
  1002. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1003. return 0;
  1004. }
  1005. if ( hp > 0 && sp >= 0 ) {
  1006. if(!status_heal(&sd->bl, hp, sp, 0))
  1007. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1008. else
  1009. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1010. return 0;
  1011. }
  1012. if ( hp < 0 && sp <= 0 ) {
  1013. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1014. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1015. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1016. return 0;
  1017. }
  1018. //Opposing signs.
  1019. if ( hp ) {
  1020. if (hp > 0)
  1021. status_heal(&sd->bl, hp, 0, 0);
  1022. else {
  1023. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1024. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1025. }
  1026. }
  1027. if ( sp ) {
  1028. if (sp > 0)
  1029. status_heal(&sd->bl, 0, sp, 0);
  1030. else
  1031. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1032. }
  1033. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1034. return 0;
  1035. }
  1036. /*==========================================
  1037. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1038. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1039. *------------------------------------------*/
  1040. ACMD_FUNC(item)
  1041. {
  1042. char item_name[100];
  1043. int number = 0, bound = BOUND_NONE;
  1044. char flag = 0;
  1045. struct item item_tmp;
  1046. struct item_data *item_data[10];
  1047. int get_count, i, j=0;
  1048. char *itemlist;
  1049. nullpo_retr(-1, sd);
  1050. memset(item_name, '\0', sizeof(item_name));
  1051. parent_cmd = atcommand_checkalias(command+1);
  1052. if (!strcmpi(parent_cmd,"itembound")) {
  1053. if (!message || !*message || (
  1054. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1055. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1056. {
  1057. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1058. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1059. return -1;
  1060. }
  1061. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1062. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1063. return -1;
  1064. }
  1065. } else if (!message || !*message || (
  1066. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1067. sscanf(message, "%99s %11d", item_name, &number) < 1
  1068. )) {
  1069. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1070. return -1;
  1071. }
  1072. itemlist = strtok(item_name, ":");
  1073. while (itemlist != NULL && j<10) {
  1074. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1075. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1076. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1077. return -1;
  1078. }
  1079. itemlist = strtok(NULL, ":"); //next itemline
  1080. j++;
  1081. }
  1082. if (number <= 0)
  1083. number = 1;
  1084. get_count = number;
  1085. for(j--; j>=0; j--){ //produce items in list
  1086. unsigned short item_id = item_data[j]->nameid;
  1087. //Check if it's stackable.
  1088. if (!itemdb_isstackable2(item_data[j]))
  1089. get_count = 1;
  1090. for (i = 0; i < number; i += get_count) {
  1091. // if not pet egg
  1092. if (!pet_create_egg(sd, item_id)) {
  1093. memset(&item_tmp, 0, sizeof(item_tmp));
  1094. item_tmp.nameid = item_id;
  1095. item_tmp.identify = 1;
  1096. item_tmp.bound = bound;
  1097. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1098. clif_additem(sd, 0, 0, flag);
  1099. }
  1100. }
  1101. }
  1102. if (flag == 0)
  1103. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1104. return 0;
  1105. }
  1106. /*==========================================
  1107. *
  1108. *------------------------------------------*/
  1109. ACMD_FUNC(item2)
  1110. {
  1111. struct item item_tmp;
  1112. struct item_data *item_data;
  1113. char item_name[100];
  1114. unsigned short item_id;
  1115. int number = 0, bound = BOUND_NONE;
  1116. int identify = 0, refine = 0, attr = 0;
  1117. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1118. nullpo_retr(-1, sd);
  1119. memset(item_name, '\0', sizeof(item_name));
  1120. parent_cmd = atcommand_checkalias(command+1);
  1121. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1122. if (!message || !*message || (
  1123. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1124. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1125. {
  1126. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1127. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1128. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1129. return -1;
  1130. }
  1131. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1132. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1133. return -1;
  1134. }
  1135. } else if ( !message || !*message || (
  1136. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1137. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1138. )) {
  1139. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1140. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1141. return -1;
  1142. }
  1143. if (number <= 0)
  1144. number = 1;
  1145. item_id = 0;
  1146. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1147. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1148. item_id = item_data->nameid;
  1149. if (item_id > 500) {
  1150. int loop, get_count, i;
  1151. char flag = 0;
  1152. //Check if it's stackable.
  1153. if(!itemdb_isstackable2(item_data)){
  1154. loop = number;
  1155. get_count = 1;
  1156. }else{
  1157. loop = 1;
  1158. get_count = number;
  1159. }
  1160. if( itemdb_isequip2(item_data ) ){
  1161. refine = cap_value( refine, 0, MAX_REFINE );
  1162. }else{
  1163. // All other items cannot be refined and are always identified
  1164. identify = 1;
  1165. refine = attr = 0;
  1166. }
  1167. for (i = 0; i < loop; i++) {
  1168. // if not pet egg
  1169. if (!pet_create_egg(sd, item_id)) {
  1170. memset(&item_tmp, 0, sizeof(item_tmp));
  1171. item_tmp.nameid = item_id;
  1172. item_tmp.identify = identify;
  1173. item_tmp.refine = refine;
  1174. item_tmp.attribute = attr;
  1175. item_tmp.card[0] = c1;
  1176. item_tmp.card[1] = c2;
  1177. item_tmp.card[2] = c3;
  1178. item_tmp.card[3] = c4;
  1179. item_tmp.bound = bound;
  1180. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1181. clif_additem(sd, 0, 0, flag);
  1182. }
  1183. }
  1184. if (flag == 0)
  1185. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1186. } else {
  1187. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1188. return -1;
  1189. }
  1190. return 0;
  1191. }
  1192. /*==========================================
  1193. *
  1194. *------------------------------------------*/
  1195. ACMD_FUNC(itemreset)
  1196. {
  1197. int i;
  1198. nullpo_retr(-1, sd);
  1199. for (i = 0; i < MAX_INVENTORY; i++) {
  1200. if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0) {
  1201. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1202. }
  1203. }
  1204. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1205. return 0;
  1206. }
  1207. /*==========================================
  1208. * Atcommand @lvlup
  1209. *------------------------------------------*/
  1210. ACMD_FUNC(baselevelup)
  1211. {
  1212. int level=0, i=0, status_point=0;
  1213. nullpo_retr(-1, sd);
  1214. level = atoi(message);
  1215. if (!message || !*message || !level) {
  1216. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1217. return -1;
  1218. }
  1219. if (level > 0) {
  1220. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1221. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1222. return -1;
  1223. } // End Addition
  1224. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1225. level = pc_maxbaselv(sd) - sd->status.base_level;
  1226. for (i = 0; i < level; i++)
  1227. status_point += pc_gets_status_point(sd->status.base_level + i);
  1228. sd->status.status_point += status_point;
  1229. sd->status.base_level += (unsigned int)level;
  1230. status_calc_pc(sd, SCO_FORCE);
  1231. status_percent_heal(&sd->bl, 100, 100);
  1232. clif_misceffect(&sd->bl, 0);
  1233. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.base_level);
  1234. achievement_update_objective(sd, AG_GOAL_STATUS, 2, sd->status.base_level, sd->status.class_);
  1235. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1236. } else {
  1237. if (sd->status.base_level == 1) {
  1238. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1239. return -1;
  1240. }
  1241. level*=-1;
  1242. if ((unsigned int)level >= sd->status.base_level)
  1243. level = sd->status.base_level-1;
  1244. for (i = 0; i > -level; i--)
  1245. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1246. if (sd->status.status_point < status_point)
  1247. pc_resetstate(sd);
  1248. if (sd->status.status_point < status_point)
  1249. sd->status.status_point = 0;
  1250. else
  1251. sd->status.status_point -= status_point;
  1252. sd->status.base_level -= (unsigned int)level;
  1253. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1254. status_calc_pc(sd, SCO_FORCE);
  1255. level*=-1;
  1256. }
  1257. sd->status.base_exp = 0;
  1258. clif_updatestatus(sd, SP_STATUSPOINT);
  1259. clif_updatestatus(sd, SP_BASELEVEL);
  1260. clif_updatestatus(sd, SP_BASEEXP);
  1261. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1262. pc_baselevelchanged(sd);
  1263. if(sd->status.party_id)
  1264. party_send_levelup(sd);
  1265. if( level > 0 && battle_config.atcommand_levelup_events )
  1266. npc_script_event(sd,NPCE_BASELVUP);
  1267. return 0;
  1268. }
  1269. /*==========================================
  1270. *
  1271. *------------------------------------------*/
  1272. ACMD_FUNC(joblevelup)
  1273. {
  1274. int level=0;
  1275. nullpo_retr(-1, sd);
  1276. level = atoi(message);
  1277. if (!message || !*message || !level) {
  1278. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1279. return -1;
  1280. }
  1281. if (level > 0) {
  1282. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1283. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1284. return -1;
  1285. }
  1286. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1287. level = pc_maxjoblv(sd) - sd->status.job_level;
  1288. sd->status.job_level += (unsigned int)level;
  1289. sd->status.skill_point += level;
  1290. clif_misceffect(&sd->bl, 1);
  1291. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.job_level);
  1292. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1293. } else {
  1294. if (sd->status.job_level == 1) {
  1295. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1296. return -1;
  1297. }
  1298. level *=-1;
  1299. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1300. level = sd->status.job_level-1;
  1301. sd->status.job_level -= (unsigned int)level;
  1302. if (sd->status.skill_point < level)
  1303. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1304. if (sd->status.skill_point < level)
  1305. sd->status.skill_point = 0;
  1306. else
  1307. sd->status.skill_point -= level;
  1308. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1309. level *=-1;
  1310. }
  1311. sd->status.job_exp = 0;
  1312. clif_updatestatus(sd, SP_JOBLEVEL);
  1313. clif_updatestatus(sd, SP_JOBEXP);
  1314. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1315. clif_updatestatus(sd, SP_SKILLPOINT);
  1316. status_calc_pc(sd, SCO_FORCE);
  1317. if( level > 0 && battle_config.atcommand_levelup_events )
  1318. npc_script_event(sd,NPCE_JOBLVUP);
  1319. return 0;
  1320. }
  1321. /*==========================================
  1322. * @help
  1323. *------------------------------------------*/
  1324. ACMD_FUNC(help)
  1325. {
  1326. config_setting_t *help;
  1327. const char *text = NULL;
  1328. const char *command_name = NULL;
  1329. const char *default_command = "help";
  1330. nullpo_retr(-1, sd);
  1331. help = config_lookup(&atcommand_config, "help");
  1332. if (help == NULL) {
  1333. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1334. return -1;
  1335. }
  1336. if (!message || !*message) {
  1337. command_name = default_command; // If no command_name specified, display help for @help.
  1338. } else {
  1339. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1340. ++message;
  1341. command_name = atcommand_checkalias(message);
  1342. }
  1343. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1344. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1345. clif_displaymessage(fd, atcmd_output);
  1346. atcommand_get_suggestions(sd, command_name, true);
  1347. return -1;
  1348. }
  1349. if (!config_setting_lookup_string(help, command_name, &text)) {
  1350. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1351. clif_displaymessage(fd, atcmd_output);
  1352. atcommand_get_suggestions(sd, command_name, true);
  1353. return -1;
  1354. }
  1355. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1356. clif_displaymessage(fd, atcmd_output);
  1357. { // Display aliases
  1358. DBIterator* iter;
  1359. AtCommandInfo *command_info;
  1360. AliasInfo *alias_info = NULL;
  1361. StringBuf buf;
  1362. bool has_aliases = false;
  1363. StringBuf_Init(&buf);
  1364. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1365. command_info = get_atcommandinfo_byname(command_name);
  1366. iter = db_iterator(atcommand_alias_db);
  1367. for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
  1368. if (alias_info->command == command_info) {
  1369. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1370. has_aliases = true;
  1371. }
  1372. }
  1373. dbi_destroy(iter);
  1374. if (has_aliases)
  1375. clif_displaymessage(fd, StringBuf_Value(&buf));
  1376. StringBuf_Destroy(&buf);
  1377. }
  1378. // Display help contents
  1379. clif_displaymessage(fd, text);
  1380. return 0;
  1381. }
  1382. // helper function, used in foreach calls to stop auto-attack timers
  1383. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1384. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1385. {
  1386. struct unit_data *ud = unit_bl2ud(bl);
  1387. int id = va_arg(ap, int);
  1388. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1389. {
  1390. unit_stop_attack(bl);
  1391. return 1;
  1392. }
  1393. return 0;
  1394. }
  1395. /*==========================================
  1396. *
  1397. *------------------------------------------*/
  1398. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1399. {
  1400. TBL_PC* sd = (TBL_PC*)bl;
  1401. clif_pvpset(sd, 0, 0, 2);
  1402. if (sd->pvp_timer != INVALID_TIMER) {
  1403. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1404. sd->pvp_timer = INVALID_TIMER;
  1405. }
  1406. return 0;
  1407. }
  1408. ACMD_FUNC(pvpoff)
  1409. {
  1410. nullpo_retr(-1, sd);
  1411. if (!map[sd->bl.m].flag.pvp) {
  1412. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1413. return -1;
  1414. }
  1415. map[sd->bl.m].flag.pvp = 0;
  1416. if (!battle_config.pk_mode){
  1417. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1418. }
  1419. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1420. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1421. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1422. return 0;
  1423. }
  1424. /*==========================================
  1425. *
  1426. *------------------------------------------*/
  1427. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1428. {
  1429. TBL_PC* sd = (TBL_PC*)bl;
  1430. if (sd->pvp_timer == INVALID_TIMER) {
  1431. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1432. sd->pvp_rank = 0;
  1433. sd->pvp_lastusers = 0;
  1434. sd->pvp_point = 5;
  1435. sd->pvp_won = 0;
  1436. sd->pvp_lost = 0;
  1437. }
  1438. return 0;
  1439. }
  1440. ACMD_FUNC(pvpon)
  1441. {
  1442. nullpo_retr(-1, sd);
  1443. if (map[sd->bl.m].flag.pvp) {
  1444. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1445. return -1;
  1446. }
  1447. map[sd->bl.m].flag.pvp = 1;
  1448. if (!battle_config.pk_mode) {// display pvp circle and rank
  1449. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1450. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1451. }
  1452. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1453. return 0;
  1454. }
  1455. /*==========================================
  1456. *
  1457. *------------------------------------------*/
  1458. ACMD_FUNC(gvgoff)
  1459. {
  1460. nullpo_retr(-1, sd);
  1461. if (!map[sd->bl.m].flag.gvg) {
  1462. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1463. return -1;
  1464. }
  1465. map[sd->bl.m].flag.gvg = 0;
  1466. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1467. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1468. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1469. return 0;
  1470. }
  1471. /*==========================================
  1472. *
  1473. *------------------------------------------*/
  1474. ACMD_FUNC(gvgon)
  1475. {
  1476. nullpo_retr(-1, sd);
  1477. if (map[sd->bl.m].flag.gvg) {
  1478. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1479. return -1;
  1480. }
  1481. map[sd->bl.m].flag.gvg = 1;
  1482. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1483. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1484. return 0;
  1485. }
  1486. /*==========================================
  1487. *
  1488. *------------------------------------------*/
  1489. ACMD_FUNC(model)
  1490. {
  1491. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1492. nullpo_retr(-1, sd);
  1493. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1494. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1495. 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>).
  1496. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1497. clif_displaymessage(fd, atcmd_output);
  1498. return -1;
  1499. }
  1500. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1501. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1502. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1503. pc_changelook(sd, LOOK_HAIR, hair_style);
  1504. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1505. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1506. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1507. } else {
  1508. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1509. return -1;
  1510. }
  1511. return 0;
  1512. }
  1513. /*==========================================
  1514. * @bodystyle [Rytech]
  1515. *------------------------------------------*/
  1516. ACMD_FUNC(bodystyle)
  1517. {
  1518. int body_style = 0;
  1519. nullpo_retr(-1, sd);
  1520. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1521. if (!(sd->class_&JOBL_THIRD)) {
  1522. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1523. return -1;
  1524. }
  1525. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1526. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1527. clif_displaymessage(fd, atcmd_output);
  1528. return -1;
  1529. }
  1530. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1531. pc_changelook(sd, LOOK_BODY2, body_style);
  1532. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1533. } else {
  1534. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1535. return -1;
  1536. }
  1537. return 0;
  1538. }
  1539. /*==========================================
  1540. * @dye && @ccolor
  1541. *------------------------------------------*/
  1542. ACMD_FUNC(dye)
  1543. {
  1544. int cloth_color = 0;
  1545. nullpo_retr(-1, sd);
  1546. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1547. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1548. 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>).
  1549. clif_displaymessage(fd, atcmd_output);
  1550. return -1;
  1551. }
  1552. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1553. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1554. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1555. } else {
  1556. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1557. return -1;
  1558. }
  1559. return 0;
  1560. }
  1561. /*==========================================
  1562. * @hairstyle && @hstyle
  1563. *------------------------------------------*/
  1564. ACMD_FUNC(hair_style)
  1565. {
  1566. int hair_style = 0;
  1567. nullpo_retr(-1, sd);
  1568. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1569. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1570. 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>).
  1571. clif_displaymessage(fd, atcmd_output);
  1572. return -1;
  1573. }
  1574. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1575. pc_changelook(sd, LOOK_HAIR, hair_style);
  1576. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1577. } else {
  1578. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1579. return -1;
  1580. }
  1581. return 0;
  1582. }
  1583. /*==========================================
  1584. * @haircolor && @hcolor
  1585. *------------------------------------------*/
  1586. ACMD_FUNC(hair_color)
  1587. {
  1588. int hair_color = 0;
  1589. nullpo_retr(-1, sd);
  1590. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1591. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1592. 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>).
  1593. clif_displaymessage(fd, atcmd_output);
  1594. return -1;
  1595. }
  1596. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1597. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1598. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1599. } else {
  1600. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1601. return -1;
  1602. }
  1603. return 0;
  1604. }
  1605. /*==========================================
  1606. * @go [city_number or city_name] - Updated by Harbin
  1607. *------------------------------------------*/
  1608. ACMD_FUNC(go)
  1609. {
  1610. int i;
  1611. int town;
  1612. char map_name[MAP_NAME_LENGTH];
  1613. const struct {
  1614. char map[MAP_NAME_LENGTH];
  1615. int x, y;
  1616. } data[] = {
  1617. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1618. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1619. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1620. { MAP_PAYON, 162, 233 }, // 3=Payon
  1621. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1622. #ifdef RENEWAL
  1623. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1624. #else
  1625. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1626. #endif
  1627. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1628. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1629. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1630. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1631. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1632. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1633. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1634. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1635. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1636. #ifdef RENEWAL
  1637. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1638. #else
  1639. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1640. #endif
  1641. { MAP_JAIL, 23, 61 }, // 16=Prison
  1642. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1643. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1644. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1645. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1646. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1647. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1648. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1649. { MAP_VEINS, 216, 123 }, // 24=Veins
  1650. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1651. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1652. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1653. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1654. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1655. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1656. { MAP_MORA, 44, 151 }, // 31=Mora
  1657. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1658. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1659. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1660. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1661. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1662. };
  1663. nullpo_retr(-1, sd);
  1664. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1665. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1666. return 0;
  1667. }
  1668. memset(map_name, '\0', sizeof(map_name));
  1669. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1670. // get the number
  1671. town = atoi(message);
  1672. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1673. {// no value matched so send the list of locations
  1674. const char* text;
  1675. // attempt to find the text help string
  1676. text = atcommand_help_string( command );
  1677. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1678. if( text )
  1679. {// send the text to the client
  1680. clif_displaymessage( fd, text );
  1681. }
  1682. return -1;
  1683. }
  1684. // get possible name of the city
  1685. map_name[MAP_NAME_LENGTH-1] = '\0';
  1686. for (i = 0; map_name[i]; i++)
  1687. map_name[i] = TOLOWER(map_name[i]);
  1688. // try to identify the map name
  1689. if (strncmp(map_name, "prontera", 3) == 0) {
  1690. town = 0;
  1691. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1692. strncmp(map_name, "morroc", 4) == 0) {
  1693. town = 1;
  1694. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1695. town = 2;
  1696. } else if (strncmp(map_name, "payon", 3) == 0) {
  1697. town = 3;
  1698. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1699. town = 4;
  1700. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1701. town = 5;
  1702. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1703. town = 6;
  1704. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1705. strcmp(map_name, "christmas") == 0 ||
  1706. strncmp(map_name, "xmas", 3) == 0 ||
  1707. strncmp(map_name, "x-mas", 3) == 0) {
  1708. town = 7;
  1709. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1710. town = 8;
  1711. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1712. strncmp(map_name, "yuno", 3) == 0) {
  1713. town = 9;
  1714. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1715. town = 10;
  1716. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1717. strncmp(map_name, "gonryun", 3) == 0) {
  1718. town = 11;
  1719. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1720. town = 12;
  1721. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1722. town = 13;
  1723. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1724. town = 14;
  1725. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1726. strncmp(map_name, "startpoint", 3) == 0 ||
  1727. strncmp(map_name, "beginning", 3) == 0) {
  1728. town = 15;
  1729. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1730. strncmp(map_name, "prison", 3) == 0 ||
  1731. strncmp(map_name, "jail", 3) == 0) {
  1732. town = 16;
  1733. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1734. town = 17;
  1735. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1736. town = 18;
  1737. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1738. town = 19;
  1739. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1740. town = 20;
  1741. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1742. town = 21;
  1743. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1744. town = 22;
  1745. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1746. town = 23;
  1747. } else if (strncmp(map_name, "veins", 3) == 0) {
  1748. town = 24;
  1749. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1750. town = 25;
  1751. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1752. town = 26;
  1753. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1754. town = 27;
  1755. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1756. town = 28;
  1757. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1758. town = 29;
  1759. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1760. town = 30;
  1761. } else if (strcmp(map_name, "mora") == 0) {
  1762. town = 31;
  1763. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1764. town = 32;
  1765. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1766. town = 33;
  1767. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1768. town = 34;
  1769. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1770. town = 35;
  1771. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1772. town = 36;
  1773. }
  1774. if (town >= 0 && town < ARRAYLENGTH(data))
  1775. {
  1776. int16 m = map_mapname2mapid(data[town].map);
  1777. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1778. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1779. return -1;
  1780. }
  1781. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1782. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1783. return -1;
  1784. }
  1785. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1786. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1787. } else {
  1788. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1789. return -1;
  1790. }
  1791. } else { // if you arrive here, you have an error in town variable when reading of names
  1792. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1793. return -1;
  1794. }
  1795. return 0;
  1796. }
  1797. /*==========================================
  1798. *
  1799. *------------------------------------------*/
  1800. ACMD_FUNC(monster)
  1801. {
  1802. char name[NAME_LENGTH];
  1803. char monster[NAME_LENGTH];
  1804. char eventname[EVENT_NAME_LENGTH] = "";
  1805. int mob_id;
  1806. int number = 0;
  1807. int count;
  1808. int i, range;
  1809. short mx, my;
  1810. unsigned int size;
  1811. nullpo_retr(-1, sd);
  1812. memset(name, '\0', sizeof(name));
  1813. memset(monster, '\0', sizeof(monster));
  1814. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1815. if (!message || !*message) {
  1816. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1817. return -1;
  1818. }
  1819. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1820. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1821. //All data can be left as it is.
  1822. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1823. //Here, it is possible name was not given and we are using monster for it.
  1824. if (count < 3) //Blank mob's name.
  1825. name[0] = '\0';
  1826. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1827. //All data can be left as it is.
  1828. } else if (sscanf(message, "%23s", monster) > 0) {
  1829. //As before, name may be already filled.
  1830. name[0] = '\0';
  1831. } else {
  1832. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1833. return -1;
  1834. }
  1835. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1836. mob_id = mobdb_checkid(atoi(monster));
  1837. if (mob_id == 0) {
  1838. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1839. return -1;
  1840. }
  1841. if (mob_id == MOBID_EMPERIUM) {
  1842. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1843. return -1;
  1844. }
  1845. if (number <= 0)
  1846. number = 1;
  1847. if( !name[0] )
  1848. strcpy(name, "--ja--");
  1849. // 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
  1850. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1851. number = battle_config.atc_spawn_quantity_limit;
  1852. parent_cmd = atcommand_checkalias(command+1);
  1853. if (strcmp(parent_cmd, "monstersmall") == 0)
  1854. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1855. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1856. size = SZ_BIG;
  1857. else
  1858. size = SZ_SMALL;
  1859. if (battle_config.etc_log)
  1860. 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);
  1861. count = 0;
  1862. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1863. for (i = 0; i < number; i++) {
  1864. int k;
  1865. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1866. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1867. if(k) {
  1868. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1869. count ++;
  1870. }
  1871. }
  1872. if (count != 0)
  1873. if (number == count)
  1874. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1875. else {
  1876. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1877. clif_displaymessage(fd, atcmd_output);
  1878. }
  1879. else {
  1880. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1881. return -1;
  1882. }
  1883. return 0;
  1884. }
  1885. /*==========================================
  1886. *
  1887. *------------------------------------------*/
  1888. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1889. {
  1890. struct mob_data *md;
  1891. int flag;
  1892. nullpo_ret(md=(struct mob_data *)bl);
  1893. flag = va_arg(ap, int);
  1894. if (md->guardian_data)
  1895. return 0; //Do not touch WoE mobs!
  1896. if (flag)
  1897. status_zap(bl,md->status.hp, 0);
  1898. else
  1899. status_kill(bl);
  1900. return 1;
  1901. }
  1902. ACMD_FUNC(killmonster)
  1903. {
  1904. int map_id, drop_flag;
  1905. char map_name[MAP_NAME_LENGTH_EXT];
  1906. nullpo_retr(-1, sd);
  1907. memset(map_name, '\0', sizeof(map_name));
  1908. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1909. map_id = sd->bl.m;
  1910. else {
  1911. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1912. map_id = sd->bl.m;
  1913. }
  1914. parent_cmd = atcommand_checkalias(command+1);
  1915. drop_flag = strcmp(parent_cmd, "killmonster2");
  1916. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1917. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1918. return 0;
  1919. }
  1920. /*==========================================
  1921. *
  1922. *------------------------------------------*/
  1923. ACMD_FUNC(refine)
  1924. {
  1925. int j, position = 0, refine = 0, current_position, final_refine;
  1926. int count;
  1927. nullpo_retr(-1, sd);
  1928. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1929. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1930. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1931. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1932. clif_displaymessage(fd, atcmd_output);
  1933. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1934. clif_displaymessage(fd, atcmd_output);
  1935. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1936. clif_displaymessage(fd, atcmd_output);
  1937. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1938. clif_displaymessage(fd, atcmd_output);
  1939. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1940. clif_displaymessage(fd, atcmd_output);
  1941. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1942. clif_displaymessage(fd, atcmd_output);
  1943. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1944. clif_displaymessage(fd, atcmd_output);
  1945. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1946. clif_displaymessage(fd, atcmd_output);
  1947. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1948. clif_displaymessage(fd, atcmd_output);
  1949. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1950. clif_displaymessage(fd, atcmd_output);
  1951. return -1;
  1952. }
  1953. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1954. count = 0;
  1955. for (j = 0; j < EQI_MAX; j++) {
  1956. int i;
  1957. if ((i = sd->equip_index[j]) < 0)
  1958. continue;
  1959. if(j == EQI_AMMO)
  1960. continue;
  1961. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1962. continue;
  1963. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  1964. continue;
  1965. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  1966. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  1967. sd->inventory.u.items_inventory[i].refine = final_refine;
  1968. current_position = sd->inventory.u.items_inventory[i].equip;
  1969. pc_unequipitem(sd, i, 3);
  1970. clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine);
  1971. clif_delitem(sd, i, 1, 3);
  1972. clif_additem(sd, i, 1, 0);
  1973. pc_equipitem(sd, i, current_position);
  1974. clif_misceffect(&sd->bl, 3);
  1975. achievement_update_objective(sd, AG_REFINE_SUCCESS, 2, sd->inventory_data[i]->wlv, sd->inventory.u.items_inventory[i].refine);
  1976. count++;
  1977. }
  1978. }
  1979. if (count == 0)
  1980. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1981. else if (count == 1)
  1982. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1983. else {
  1984. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1985. clif_displaymessage(fd, atcmd_output);
  1986. }
  1987. return 0;
  1988. }
  1989. /*==========================================
  1990. *
  1991. *------------------------------------------*/
  1992. ACMD_FUNC(produce)
  1993. {
  1994. char item_name[100];
  1995. unsigned short item_id;
  1996. int attribute = 0, star = 0;
  1997. struct item_data *item_data;
  1998. struct item tmp_item;
  1999. nullpo_retr(-1, sd);
  2000. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2001. memset(item_name, '\0', sizeof(item_name));
  2002. if (!message || !*message || (
  2003. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2004. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2005. )) {
  2006. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2007. return -1;
  2008. }
  2009. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  2010. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  2011. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2012. return -1;
  2013. }
  2014. item_id = item_data->nameid;
  2015. if (itemdb_isequip2(item_data)) {
  2016. char flag = 0;
  2017. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2018. attribute = ATTRIBUTE_NORMAL;
  2019. if (star < MIN_STAR || star > MAX_STAR)
  2020. star = 0;
  2021. memset(&tmp_item, 0, sizeof tmp_item);
  2022. tmp_item.nameid = item_id;
  2023. tmp_item.amount = 1;
  2024. tmp_item.identify = 1;
  2025. tmp_item.card[0] = CARD0_FORGE;
  2026. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2027. ((star*5) << 8) + attribute:0;
  2028. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2029. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2030. clif_produceeffect(sd, 0, item_id);
  2031. clif_misceffect(&sd->bl, 3);
  2032. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2033. clif_additem(sd, 0, 0, flag);
  2034. } else {
  2035. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  2036. clif_displaymessage(fd, atcmd_output);
  2037. return -1;
  2038. }
  2039. return 0;
  2040. }
  2041. /*==========================================
  2042. *
  2043. *------------------------------------------*/
  2044. ACMD_FUNC(memo)
  2045. {
  2046. int position = 0;
  2047. nullpo_retr(-1, sd);
  2048. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2049. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2050. {
  2051. int i;
  2052. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2053. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2054. {
  2055. if( sd->status.memo_point[i].map )
  2056. 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);
  2057. else
  2058. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2059. clif_displaymessage(sd->fd, atcmd_output);
  2060. }
  2061. return 0;
  2062. }
  2063. if( position < 0 || position >= MAX_MEMOPOINTS )
  2064. {
  2065. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2066. clif_displaymessage(fd, atcmd_output);
  2067. return -1;
  2068. }
  2069. return !pc_memo( sd, position );
  2070. }
  2071. /*==========================================
  2072. *
  2073. *------------------------------------------*/
  2074. ACMD_FUNC(gat)
  2075. {
  2076. int y;
  2077. nullpo_retr(-1, sd);
  2078. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2079. for (y = 2; y >= -2; y--) {
  2080. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2081. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2082. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2083. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2084. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2085. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2086. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2087. clif_displaymessage(fd, atcmd_output);
  2088. }
  2089. return 0;
  2090. }
  2091. /*==========================================
  2092. *
  2093. *------------------------------------------*/
  2094. ACMD_FUNC(displaystatus)
  2095. {
  2096. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2097. nullpo_retr(-1, sd);
  2098. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2099. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2100. return -1;
  2101. }
  2102. if (i < 2) flag = 1;
  2103. if (i < 3) tick = 0;
  2104. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2105. return 0;
  2106. }
  2107. /*==========================================
  2108. * @stpoint (Rewritten by [Yor])
  2109. *------------------------------------------*/
  2110. ACMD_FUNC(statuspoint)
  2111. {
  2112. int point;
  2113. unsigned int new_status_point;
  2114. if (!message || !*message || (point = atoi(message)) == 0) {
  2115. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2116. return -1;
  2117. }
  2118. if(point < 0)
  2119. {
  2120. if(sd->status.status_point < (unsigned int)(-point))
  2121. {
  2122. new_status_point = 0;
  2123. }
  2124. else
  2125. {
  2126. new_status_point = sd->status.status_point + point;
  2127. }
  2128. }
  2129. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2130. {
  2131. new_status_point = UINT_MAX;
  2132. }
  2133. else
  2134. {
  2135. new_status_point = sd->status.status_point + point;
  2136. }
  2137. if (new_status_point != sd->status.status_point) {
  2138. sd->status.status_point = new_status_point;
  2139. clif_updatestatus(sd, SP_STATUSPOINT);
  2140. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2141. } else {
  2142. if (point < 0)
  2143. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2144. else
  2145. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2146. return -1;
  2147. }
  2148. return 0;
  2149. }
  2150. /*==========================================
  2151. * @skpoint (Rewritten by [Yor])
  2152. *------------------------------------------*/
  2153. ACMD_FUNC(skillpoint)
  2154. {
  2155. int point;
  2156. unsigned int new_skill_point;
  2157. nullpo_retr(-1, sd);
  2158. if (!message || !*message || (point = atoi(message)) == 0) {
  2159. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2160. return -1;
  2161. }
  2162. if(point < 0)
  2163. {
  2164. if(sd->status.skill_point < (unsigned int)(-point))
  2165. {
  2166. new_skill_point = 0;
  2167. }
  2168. else
  2169. {
  2170. new_skill_point = sd->status.skill_point + point;
  2171. }
  2172. }
  2173. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2174. {
  2175. new_skill_point = UINT_MAX;
  2176. }
  2177. else
  2178. {
  2179. new_skill_point = sd->status.skill_point + point;
  2180. }
  2181. if (new_skill_point != sd->status.skill_point) {
  2182. sd->status.skill_point = new_skill_point;
  2183. clif_updatestatus(sd, SP_SKILLPOINT);
  2184. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2185. } else {
  2186. if (point < 0)
  2187. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2188. else
  2189. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2190. return -1;
  2191. }
  2192. return 0;
  2193. }
  2194. /*==========================================
  2195. * @zeny
  2196. *------------------------------------------*/
  2197. ACMD_FUNC(zeny)
  2198. {
  2199. int zeny=0, ret=-1;
  2200. nullpo_retr(-1, sd);
  2201. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2202. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2203. return -1;
  2204. }
  2205. if(zeny > 0){
  2206. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2207. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2208. }
  2209. else {
  2210. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2211. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2212. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2213. }
  2214. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2215. return 0;
  2216. }
  2217. /*==========================================
  2218. *
  2219. *------------------------------------------*/
  2220. ACMD_FUNC(param)
  2221. {
  2222. uint8 i;
  2223. int value = 0;
  2224. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2225. unsigned short new_value, *status[6], max_status[6];
  2226. //we don't use direct initialization because it isn't part of the c standard.
  2227. nullpo_retr(-1, sd);
  2228. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2229. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2230. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2231. return -1;
  2232. }
  2233. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2234. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2235. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2236. return -1;
  2237. }
  2238. status[0] = &sd->status.str;
  2239. status[1] = &sd->status.agi;
  2240. status[2] = &sd->status.vit;
  2241. status[3] = &sd->status.int_;
  2242. status[4] = &sd->status.dex;
  2243. status[5] = &sd->status.luk;
  2244. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2245. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2246. else {
  2247. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2248. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2249. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2250. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2251. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2252. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2253. }
  2254. if(value > 0 && *status[i] + value >= max_status[i])
  2255. new_value = max_status[i];
  2256. else if(value < 0 && *status[i] <= -value)
  2257. new_value = 1;
  2258. else
  2259. new_value = *status[i] + value;
  2260. if (new_value != *status[i]) {
  2261. *status[i] = new_value;
  2262. clif_updatestatus(sd, SP_STR + i);
  2263. clif_updatestatus(sd, SP_USTR + i);
  2264. status_calc_pc(sd, SCO_FORCE);
  2265. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2266. } else {
  2267. if (value < 0)
  2268. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2269. else
  2270. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2271. return -1;
  2272. }
  2273. return 0;
  2274. }
  2275. /*==========================================
  2276. * Stat all by fritz (rewritten by [Yor])
  2277. *------------------------------------------*/
  2278. ACMD_FUNC(stat_all)
  2279. {
  2280. int value = 0;
  2281. uint8 count, i;
  2282. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2283. //we don't use direct initialization because it isn't part of the c standard.
  2284. nullpo_retr(-1, sd);
  2285. status[0] = &sd->status.str;
  2286. status[1] = &sd->status.agi;
  2287. status[2] = &sd->status.vit;
  2288. status[3] = &sd->status.int_;
  2289. status[4] = &sd->status.dex;
  2290. status[5] = &sd->status.luk;
  2291. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2292. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2293. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2294. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2295. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2296. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2297. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2298. value = SHRT_MAX;
  2299. } else {
  2300. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2301. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2302. else {
  2303. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2304. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2305. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2306. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2307. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2308. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2309. }
  2310. }
  2311. count = 0;
  2312. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2313. short new_value;
  2314. if (value > 0 && *status[i] + value >= max_status[i])
  2315. new_value = max_status[i];
  2316. else if (value < 0 && *status[i] <= -value)
  2317. new_value = 1;
  2318. else
  2319. new_value = *status[i] + value;
  2320. if (new_value != *status[i]) {
  2321. *status[i] = new_value;
  2322. clif_updatestatus(sd, SP_STR + i);
  2323. clif_updatestatus(sd, SP_USTR + i);
  2324. count++;
  2325. }
  2326. }
  2327. if (count > 0) { // if at least 1 stat modified
  2328. status_calc_pc(sd, SCO_FORCE);
  2329. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2330. } else {
  2331. if (value < 0)
  2332. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2333. else
  2334. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2335. return -1;
  2336. }
  2337. return 0;
  2338. }
  2339. /*==========================================
  2340. *
  2341. *------------------------------------------*/
  2342. ACMD_FUNC(guildlevelup) {
  2343. int level = 0;
  2344. short added_level;
  2345. struct guild *guild_info;
  2346. nullpo_retr(-1, sd);
  2347. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2348. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2349. return -1;
  2350. }
  2351. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2352. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2353. return -1;
  2354. }
  2355. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2356. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2357. // return -1;
  2358. //}
  2359. added_level = (short)level;
  2360. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2361. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2362. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2363. added_level = 1 - guild_info->guild_lv;
  2364. if (added_level != 0) {
  2365. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2366. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2367. } else {
  2368. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2369. return -1;
  2370. }
  2371. return 0;
  2372. }
  2373. /*==========================================
  2374. *
  2375. *------------------------------------------*/
  2376. ACMD_FUNC(makeegg) {
  2377. struct item_data *item_data;
  2378. int id;
  2379. struct s_pet_db* pet;
  2380. nullpo_retr(-1, sd);
  2381. if (!message || !*message) {
  2382. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2383. return -1;
  2384. }
  2385. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2386. id = item_data->nameid;
  2387. else
  2388. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2389. ;
  2390. else
  2391. id = atoi(message);
  2392. pet = pet_db(id);
  2393. if (!pet)
  2394. pet = pet_db_search(id, PET_EGG);
  2395. if (pet != nullptr) {
  2396. sd->catch_target_class = pet->class_;
  2397. intif_create_pet(sd->status.account_id, sd->status.char_id, pet->class_, mob_db(pet->class_)->lv, pet->EggID, 0, pet->intimate, 100, 0, 1, pet->jname);
  2398. } else {
  2399. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2400. return -1;
  2401. }
  2402. return 0;
  2403. }
  2404. /*==========================================
  2405. *
  2406. *------------------------------------------*/
  2407. ACMD_FUNC(hatch) {
  2408. nullpo_retr(-1, sd);
  2409. if (sd->status.pet_id <= 0)
  2410. clif_sendegg(sd);
  2411. else {
  2412. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2413. return -1;
  2414. }
  2415. return 0;
  2416. }
  2417. /*==========================================
  2418. *
  2419. *------------------------------------------*/
  2420. ACMD_FUNC(petfriendly) {
  2421. int friendly;
  2422. struct pet_data *pd;
  2423. nullpo_retr(-1, sd);
  2424. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2425. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2426. return -1;
  2427. }
  2428. pd = sd->pd;
  2429. if (!pd) {
  2430. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2431. return -1;
  2432. }
  2433. if (friendly < 0 || friendly > 1000)
  2434. {
  2435. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2436. return -1;
  2437. }
  2438. if (friendly == pd->pet.intimate) {
  2439. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2440. return -1;
  2441. }
  2442. pet_set_intimate(pd, friendly);
  2443. clif_send_petstatus(sd);
  2444. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2445. return 0;
  2446. }
  2447. /*==========================================
  2448. *
  2449. *------------------------------------------*/
  2450. ACMD_FUNC(pethungry)
  2451. {
  2452. int hungry;
  2453. struct pet_data *pd;
  2454. nullpo_retr(-1, sd);
  2455. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2456. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2457. return -1;
  2458. }
  2459. pd = sd->pd;
  2460. if (!sd->status.pet_id || !pd) {
  2461. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2462. return -1;
  2463. }
  2464. if (hungry < 0 || hungry > 100) {
  2465. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2466. return -1;
  2467. }
  2468. if (hungry == pd->pet.hungry) {
  2469. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2470. return -1;
  2471. }
  2472. pd->pet.hungry = hungry;
  2473. clif_send_petstatus(sd);
  2474. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2475. return 0;
  2476. }
  2477. /*==========================================
  2478. *
  2479. *------------------------------------------*/
  2480. ACMD_FUNC(petrename)
  2481. {
  2482. struct pet_data *pd;
  2483. nullpo_retr(-1, sd);
  2484. if (!sd->status.pet_id || !sd->pd) {
  2485. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2486. return -1;
  2487. }
  2488. pd = sd->pd;
  2489. if (!pd->pet.rename_flag) {
  2490. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2491. return -1;
  2492. }
  2493. pd->pet.rename_flag = 0;
  2494. intif_save_petdata(sd->status.account_id, &pd->pet);
  2495. clif_send_petstatus(sd);
  2496. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2497. return 0;
  2498. }
  2499. /*==========================================
  2500. *
  2501. *------------------------------------------*/
  2502. ACMD_FUNC(recall) {
  2503. struct map_session_data *pl_sd = NULL;
  2504. nullpo_retr(-1, sd);
  2505. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2506. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2507. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2508. return -1;
  2509. }
  2510. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2511. {
  2512. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2513. return -1;
  2514. }
  2515. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2516. {
  2517. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2518. return -1;
  2519. }
  2520. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2521. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2522. return -1;
  2523. }
  2524. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2525. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2526. return -1;
  2527. }
  2528. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2529. return -1;
  2530. }
  2531. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2532. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2533. return -1;
  2534. }
  2535. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2536. clif_displaymessage(fd, atcmd_output);
  2537. return 0;
  2538. }
  2539. /*==========================================
  2540. * charblock command (usage: charblock <player_name>)
  2541. * This command do a definitiv ban on a player
  2542. *------------------------------------------*/
  2543. ACMD_FUNC(char_block)
  2544. {
  2545. nullpo_retr(-1, sd);
  2546. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2547. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2548. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2549. clif_displaymessage(fd, atcmd_output);
  2550. return -1;
  2551. }
  2552. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2553. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2554. clif_displaymessage(fd, atcmd_output);
  2555. return 0;
  2556. }
  2557. /*==========================================
  2558. * accountban command (usage: ban <%time> <player_name>)
  2559. * charban command (usage: charban <%time> <player_name>)
  2560. * %time see common/timer.c::solve_time()
  2561. *------------------------------------------*/
  2562. ACMD_FUNC(char_ban)
  2563. {
  2564. char *modif_p, output[CHAT_SIZE_MAX];
  2565. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2566. enum chrif_req_op bantype;
  2567. nullpo_retr(-1, sd);
  2568. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2569. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2570. parent_cmd = atcommand_checkalias(command+1);
  2571. if (strcmpi(parent_cmd,"charban") == 0)
  2572. bantype = CHRIF_OP_BAN;
  2573. else if (strcmpi(parent_cmd,"ban") == 0)
  2574. bantype = CHRIF_OP_LOGIN_BAN;
  2575. else
  2576. return -1;
  2577. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2578. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2579. clif_displaymessage(fd, output);
  2580. return -1;
  2581. }
  2582. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2583. modif_p = atcmd_output;
  2584. timediff = (int32)solve_time(modif_p); //discard seconds
  2585. if (timediff == 0) { //allow negative ?
  2586. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2587. clif_displaymessage(fd, output);
  2588. 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.
  2589. return -1;
  2590. }
  2591. if( timediff < 0 && (
  2592. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2593. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2594. ))
  2595. {
  2596. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2597. return -1;
  2598. }
  2599. if (bantype == CHRIF_OP_BAN)
  2600. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2601. else
  2602. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2603. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2604. clif_displaymessage(fd, output);
  2605. return 0;
  2606. }
  2607. /*==========================================
  2608. * charunblock command (usage: charunblock <player_name>)
  2609. *------------------------------------------*/
  2610. ACMD_FUNC(char_unblock)
  2611. {
  2612. nullpo_retr(-1, sd);
  2613. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2614. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2615. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2616. clif_displaymessage(fd, atcmd_output);
  2617. return -1;
  2618. }
  2619. // send answer to login server via char-server
  2620. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2621. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2622. clif_displaymessage(fd, atcmd_output);
  2623. return 0;
  2624. }
  2625. /*==========================================
  2626. * acc unban command (usage: unban <player_name>)
  2627. * char unban command (usage: charunban <player_name>)
  2628. *------------------------------------------*/
  2629. ACMD_FUNC(char_unban){
  2630. enum chrif_req_op unbantype;
  2631. nullpo_retr(-1, sd);
  2632. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2633. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2634. parent_cmd = atcommand_checkalias(command+1);
  2635. if (strcmpi(parent_cmd,"charunban") == 0)
  2636. unbantype = CHRIF_OP_UNBAN;
  2637. else if (strcmpi(parent_cmd,"unban") == 0)
  2638. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2639. else
  2640. return -1;
  2641. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2642. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2643. clif_displaymessage(fd, atcmd_output);
  2644. return -1;
  2645. }
  2646. if (unbantype == CHRIF_OP_UNBAN)
  2647. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2648. else
  2649. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2650. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2651. clif_displaymessage(fd, atcmd_output);
  2652. return 0;
  2653. }
  2654. /*==========================================
  2655. *
  2656. *------------------------------------------*/
  2657. ACMD_FUNC(night)
  2658. {
  2659. nullpo_retr(-1, sd);
  2660. if (night_flag != 1) {
  2661. map_night_timer(night_timer_tid, 0, 0, 1);
  2662. } else {
  2663. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2664. return -1;
  2665. }
  2666. return 0;
  2667. }
  2668. /*==========================================
  2669. *
  2670. *------------------------------------------*/
  2671. ACMD_FUNC(day)
  2672. {
  2673. nullpo_retr(-1, sd);
  2674. if (night_flag != 0) {
  2675. map_day_timer(day_timer_tid, 0, 0, 1);
  2676. } else {
  2677. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2678. return -1;
  2679. }
  2680. return 0;
  2681. }
  2682. /*==========================================
  2683. *
  2684. *------------------------------------------*/
  2685. ACMD_FUNC(doom)
  2686. {
  2687. struct map_session_data* pl_sd;
  2688. struct s_mapiterator* iter;
  2689. nullpo_retr(-1, sd);
  2690. iter = mapit_getallusers();
  2691. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2692. {
  2693. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2694. {
  2695. status_kill(&pl_sd->bl);
  2696. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2697. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2698. }
  2699. }
  2700. mapit_free(iter);
  2701. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2702. return 0;
  2703. }
  2704. /*==========================================
  2705. *
  2706. *------------------------------------------*/
  2707. ACMD_FUNC(doommap)
  2708. {
  2709. struct map_session_data* pl_sd;
  2710. struct s_mapiterator* iter;
  2711. nullpo_retr(-1, sd);
  2712. iter = mapit_getallusers();
  2713. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2714. {
  2715. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2716. {
  2717. status_kill(&pl_sd->bl);
  2718. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2719. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2720. }
  2721. }
  2722. mapit_free(iter);
  2723. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2724. return 0;
  2725. }
  2726. /*==========================================
  2727. *
  2728. *------------------------------------------*/
  2729. static void atcommand_raise_sub(struct map_session_data* sd) {
  2730. status_revive(&sd->bl, 100, 100);
  2731. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2732. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2733. }
  2734. /*==========================================
  2735. *
  2736. *------------------------------------------*/
  2737. ACMD_FUNC(raise)
  2738. {
  2739. struct map_session_data* pl_sd;
  2740. struct s_mapiterator* iter;
  2741. nullpo_retr(-1, sd);
  2742. iter = mapit_getallusers();
  2743. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2744. if( pc_isdead(pl_sd) )
  2745. atcommand_raise_sub(pl_sd);
  2746. mapit_free(iter);
  2747. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2748. return 0;
  2749. }
  2750. /*==========================================
  2751. *
  2752. *------------------------------------------*/
  2753. ACMD_FUNC(raisemap)
  2754. {
  2755. struct map_session_data* pl_sd;
  2756. struct s_mapiterator* iter;
  2757. nullpo_retr(-1, sd);
  2758. iter = mapit_getallusers();
  2759. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2760. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2761. atcommand_raise_sub(pl_sd);
  2762. mapit_free(iter);
  2763. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2764. return 0;
  2765. }
  2766. /*==========================================
  2767. *
  2768. *------------------------------------------*/
  2769. ACMD_FUNC(kick)
  2770. {
  2771. struct map_session_data *pl_sd;
  2772. nullpo_retr(-1, sd);
  2773. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2774. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2775. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2776. return -1;
  2777. }
  2778. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2779. {
  2780. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2781. return -1;
  2782. }
  2783. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2784. {
  2785. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2786. return -1;
  2787. }
  2788. clif_GM_kick(sd, pl_sd);
  2789. return 0;
  2790. }
  2791. /*==========================================
  2792. *
  2793. *------------------------------------------*/
  2794. ACMD_FUNC(kickall)
  2795. {
  2796. struct map_session_data* pl_sd;
  2797. struct s_mapiterator* iter;
  2798. nullpo_retr(-1, sd);
  2799. iter = mapit_getallusers();
  2800. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2801. {
  2802. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2803. if (sd->status.account_id != pl_sd->status.account_id)
  2804. clif_GM_kick(NULL, pl_sd);
  2805. }
  2806. }
  2807. mapit_free(iter);
  2808. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2809. return 0;
  2810. }
  2811. /*==========================================
  2812. *
  2813. *------------------------------------------*/
  2814. ACMD_FUNC(allskill)
  2815. {
  2816. nullpo_retr(-1, sd);
  2817. pc_allskillup(sd); // all skills
  2818. sd->status.skill_point = 0; // 0 skill points
  2819. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2820. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2821. return 0;
  2822. }
  2823. /*==========================================
  2824. *
  2825. *------------------------------------------*/
  2826. ACMD_FUNC(questskill)
  2827. {
  2828. uint16 skill_id;
  2829. nullpo_retr(-1, sd);
  2830. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2831. {// also send a list of skills applicable to this command
  2832. const char* text;
  2833. // attempt to find the text corresponding to this command
  2834. text = atcommand_help_string( command );
  2835. // send the error message as always
  2836. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2837. if( text )
  2838. {// send the skill ID list associated with this command
  2839. clif_displaymessage( fd, text );
  2840. }
  2841. return -1;
  2842. }
  2843. if (skill_id >= MAX_SKILL_ID) {
  2844. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2845. return -1;
  2846. }
  2847. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2848. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2849. return -1;
  2850. }
  2851. if (pc_checkskill(sd, skill_id) > 0) {
  2852. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2853. return -1;
  2854. }
  2855. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2856. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2857. return 0;
  2858. }
  2859. /*==========================================
  2860. *
  2861. *------------------------------------------*/
  2862. ACMD_FUNC(lostskill)
  2863. {
  2864. uint16 skill_id = 0, sk_idx = 0;
  2865. nullpo_retr(-1, sd);
  2866. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2867. {// also send a list of skills applicable to this command
  2868. const char* text;
  2869. // attempt to find the text corresponding to this command
  2870. text = atcommand_help_string( command );
  2871. // send the error message as always
  2872. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2873. if( text )
  2874. {// send the skill ID list associated with this command
  2875. clif_displaymessage( fd, text );
  2876. }
  2877. return -1;
  2878. }
  2879. if (!(sk_idx = skill_get_index(skill_id))) {
  2880. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2881. return -1;
  2882. }
  2883. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2884. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2885. return -1;
  2886. }
  2887. if (pc_checkskill(sd, skill_id) == 0) {
  2888. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2889. return -1;
  2890. }
  2891. sd->status.skill[sk_idx].lv = 0;
  2892. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2893. clif_deleteskill(sd,skill_id);
  2894. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2895. return 0;
  2896. }
  2897. /*==========================================
  2898. *
  2899. *------------------------------------------*/
  2900. ACMD_FUNC(spiritball)
  2901. {
  2902. uint32 max_spiritballs;
  2903. int number;
  2904. nullpo_retr(-1, sd);
  2905. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2906. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2907. {
  2908. char msg[CHAT_SIZE_MAX];
  2909. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2910. clif_displaymessage(fd, msg);
  2911. return -1;
  2912. }
  2913. if( sd->spiritball > 0 )
  2914. pc_delspiritball(sd, sd->spiritball, 1);
  2915. sd->spiritball = number;
  2916. clif_spiritball(&sd->bl);
  2917. // no message, player can look the difference
  2918. return 0;
  2919. }
  2920. /*==========================================
  2921. *
  2922. *------------------------------------------*/
  2923. ACMD_FUNC(party)
  2924. {
  2925. char party[NAME_LENGTH];
  2926. nullpo_retr(-1, sd);
  2927. memset(party, '\0', sizeof(party));
  2928. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2929. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2930. return -1;
  2931. }
  2932. party_create(sd, party, 0, 0);
  2933. return 0;
  2934. }
  2935. /*==========================================
  2936. *
  2937. *------------------------------------------*/
  2938. ACMD_FUNC(guild)
  2939. {
  2940. char guild[NAME_LENGTH];
  2941. int prev;
  2942. nullpo_retr(-1, sd);
  2943. memset(guild, '\0', sizeof(guild));
  2944. if (sd->clan) {
  2945. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  2946. return -1;
  2947. }
  2948. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2949. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2950. return -1;
  2951. }
  2952. prev = battle_config.guild_emperium_check;
  2953. battle_config.guild_emperium_check = 0;
  2954. guild_create(sd, guild);
  2955. battle_config.guild_emperium_check = prev;
  2956. return 0;
  2957. }
  2958. ACMD_FUNC(breakguild)
  2959. {
  2960. nullpo_retr(-1, sd);
  2961. if (sd->status.guild_id) { // Check if the player has a guild
  2962. struct guild *g;
  2963. g = sd->guild; // Search the guild
  2964. if (g) { // Check if guild was found
  2965. if (sd->state.gmaster_flag) { // Check if player is guild master
  2966. int ret = 0;
  2967. ret = guild_break(sd, g->name); // Break guild
  2968. if (ret) { // Check if anything went wrong
  2969. return 0; // Guild was broken
  2970. } else {
  2971. return -1; // Something went wrong
  2972. }
  2973. } else { // Not guild master
  2974. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2975. return -1;
  2976. }
  2977. } else { // Guild was not found. HOW?
  2978. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2979. return -1;
  2980. }
  2981. } else { // Player does not have a guild
  2982. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2983. return -1;
  2984. }
  2985. }
  2986. /**
  2987. * Start WoE:FE
  2988. */
  2989. ACMD_FUNC(agitstart)
  2990. {
  2991. nullpo_retr(-1, sd);
  2992. if( guild_agit_start() ){
  2993. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2994. return 0;
  2995. }else{
  2996. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2997. return -1;
  2998. }
  2999. }
  3000. /**
  3001. * Start WoE:SE
  3002. */
  3003. ACMD_FUNC(agitstart2)
  3004. {
  3005. nullpo_retr(-1, sd);
  3006. if( guild_agit2_start() ){
  3007. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3008. return 0;
  3009. }else{
  3010. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3011. return -1;
  3012. }
  3013. }
  3014. /**
  3015. * Start WoE:TE
  3016. */
  3017. ACMD_FUNC(agitstart3)
  3018. {
  3019. nullpo_retr(-1, sd);
  3020. if( guild_agit3_start() ){
  3021. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3022. return 0;
  3023. }else{
  3024. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3025. return -1;
  3026. }
  3027. }
  3028. /**
  3029. * End WoE:FE
  3030. */
  3031. ACMD_FUNC(agitend)
  3032. {
  3033. nullpo_retr(-1, sd);
  3034. if( guild_agit_end() ){
  3035. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3036. return 0;
  3037. }else{
  3038. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3039. return -1;
  3040. }
  3041. }
  3042. /**
  3043. * End WoE:SE
  3044. */
  3045. ACMD_FUNC(agitend2)
  3046. {
  3047. nullpo_retr(-1, sd);
  3048. if( guild_agit2_end() ){
  3049. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3050. return 0;
  3051. }else{
  3052. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3053. return -1;
  3054. }
  3055. }
  3056. /**
  3057. * End WoE:TE
  3058. */
  3059. ACMD_FUNC(agitend3)
  3060. {
  3061. nullpo_retr(-1, sd);
  3062. if( guild_agit3_end() ){
  3063. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3064. return 0;
  3065. }else{
  3066. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3067. return -1;
  3068. }
  3069. }
  3070. /*==========================================
  3071. * @mapexit - shuts down the map server
  3072. *------------------------------------------*/
  3073. ACMD_FUNC(mapexit)
  3074. {
  3075. nullpo_retr(-1, sd);
  3076. do_shutdown();
  3077. return 0;
  3078. }
  3079. /*==========================================
  3080. * idsearch <part_of_name>: revrited by [Yor]
  3081. *------------------------------------------*/
  3082. ACMD_FUNC(idsearch)
  3083. {
  3084. char item_name[100];
  3085. unsigned int i, match;
  3086. struct item_data *item_array[MAX_SEARCH];
  3087. nullpo_retr(-1, sd);
  3088. memset(item_name, '\0', sizeof(item_name));
  3089. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3090. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3091. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3092. return -1;
  3093. }
  3094. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3095. clif_displaymessage(fd, atcmd_output);
  3096. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3097. if (match == MAX_SEARCH) {
  3098. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3099. clif_displaymessage(fd, atcmd_output);
  3100. }
  3101. for(i = 0; i < match; i++) {
  3102. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3103. clif_displaymessage(fd, atcmd_output);
  3104. }
  3105. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3106. clif_displaymessage(fd, atcmd_output);
  3107. return 0;
  3108. }
  3109. /*==========================================
  3110. * Recall All Characters Online To Your Location
  3111. *------------------------------------------*/
  3112. ACMD_FUNC(recallall)
  3113. {
  3114. struct map_session_data* pl_sd;
  3115. struct s_mapiterator* iter;
  3116. int count;
  3117. nullpo_retr(-1, sd);
  3118. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3119. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3120. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3121. return -1;
  3122. }
  3123. count = 0;
  3124. iter = mapit_getallusers();
  3125. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3126. {
  3127. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3128. {
  3129. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3130. continue; // Don't waste time warping the character to the same place.
  3131. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3132. count++;
  3133. else {
  3134. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3135. count++;
  3136. }
  3137. }
  3138. }
  3139. }
  3140. mapit_free(iter);
  3141. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3142. if (count) {
  3143. 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.
  3144. clif_displaymessage(fd, atcmd_output);
  3145. }
  3146. return 0;
  3147. }
  3148. /*==========================================
  3149. * Recall online characters of a guild to your location
  3150. *------------------------------------------*/
  3151. ACMD_FUNC(guildrecall)
  3152. {
  3153. struct map_session_data* pl_sd;
  3154. struct s_mapiterator* iter;
  3155. int count;
  3156. char guild_name[NAME_LENGTH];
  3157. struct guild *g;
  3158. nullpo_retr(-1, sd);
  3159. memset(guild_name, '\0', sizeof(guild_name));
  3160. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3161. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3162. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3163. return -1;
  3164. }
  3165. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3166. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3167. return -1;
  3168. }
  3169. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3170. (g = guild_search(atoi(message))) == NULL)
  3171. {
  3172. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3173. return -1;
  3174. }
  3175. count = 0;
  3176. iter = mapit_getallusers();
  3177. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3178. {
  3179. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3180. {
  3181. 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))
  3182. continue; // Skip GMs greater than you... or chars already on the cell
  3183. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3184. count++;
  3185. else{
  3186. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3187. count++;
  3188. }
  3189. }
  3190. }
  3191. }
  3192. mapit_free(iter);
  3193. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3194. clif_displaymessage(fd, atcmd_output);
  3195. if (count) {
  3196. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3197. clif_displaymessage(fd, atcmd_output);
  3198. }
  3199. return 0;
  3200. }
  3201. /*==========================================
  3202. * Recall online characters of a party to your location
  3203. *------------------------------------------*/
  3204. ACMD_FUNC(partyrecall)
  3205. {
  3206. struct map_session_data* pl_sd;
  3207. struct s_mapiterator* iter;
  3208. char party_name[NAME_LENGTH];
  3209. struct party_data *p;
  3210. int count;
  3211. nullpo_retr(-1, sd);
  3212. memset(party_name, '\0', sizeof(party_name));
  3213. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3214. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3215. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3216. return -1;
  3217. }
  3218. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3219. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3220. return -1;
  3221. }
  3222. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3223. (p = party_search(atoi(message))) == NULL)
  3224. {
  3225. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3226. return -1;
  3227. }
  3228. count = 0;
  3229. iter = mapit_getallusers();
  3230. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3231. {
  3232. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3233. {
  3234. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3235. continue; // Skip GMs greater than you... or chars already on the cell
  3236. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3237. count++;
  3238. else{
  3239. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3240. count++;
  3241. }
  3242. }
  3243. }
  3244. }
  3245. mapit_free(iter);
  3246. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3247. clif_displaymessage(fd, atcmd_output);
  3248. if (count) {
  3249. 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.
  3250. clif_displaymessage(fd, atcmd_output);
  3251. }
  3252. return 0;
  3253. }
  3254. /*==========================================
  3255. *
  3256. *------------------------------------------*/
  3257. void atcommand_doload();
  3258. ACMD_FUNC(reload) {
  3259. nullpo_retr(-1, sd);
  3260. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3261. const char* text;
  3262. text = atcommand_help_string( command );
  3263. if(text)
  3264. clif_displaymessage( fd, text );
  3265. return -1;
  3266. }
  3267. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3268. itemdb_reload();
  3269. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3270. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3271. mob_reload();
  3272. read_petdb();
  3273. hom_reload();
  3274. mercenary_readdb();
  3275. mercenary_read_skilldb();
  3276. reload_elementaldb();
  3277. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3278. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3279. skill_reload();
  3280. hom_reload_skill();
  3281. reload_elemental_skilldb();
  3282. mercenary_read_skilldb();
  3283. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3284. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3285. config_t run_test;
  3286. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3287. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3288. return -1;
  3289. }
  3290. config_destroy(&run_test);
  3291. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3292. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3293. return -1;
  3294. }
  3295. config_destroy(&run_test);
  3296. atcommand_doload();
  3297. pc_groups_reload();
  3298. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3299. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3300. struct Battle_Config prev_config;
  3301. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3302. battle_config_read(BATTLE_CONF_FILENAME);
  3303. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3304. || prev_config.item_rate_common != battle_config.item_rate_common
  3305. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3306. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3307. || prev_config.item_rate_card != battle_config.item_rate_card
  3308. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3309. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3310. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3311. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3312. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3313. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3314. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3315. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3316. || prev_config.item_rate_use != battle_config.item_rate_use
  3317. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3318. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3319. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3320. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3321. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3322. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3323. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3324. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3325. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3326. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3327. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3328. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3329. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3330. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3331. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3332. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3333. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3334. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3335. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3336. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3337. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3338. )
  3339. { // Exp or Drop rates changed.
  3340. mob_reload(); //Needed as well so rate changes take effect.
  3341. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3342. }
  3343. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3344. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3345. status_readdb();
  3346. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3347. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3348. pc_readdb();
  3349. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3350. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3351. pc_read_motd();
  3352. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3353. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3354. struct s_mapiterator* iter;
  3355. struct map_session_data* pl_sd;
  3356. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3357. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3358. iter = mapit_getallusers();
  3359. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3360. pc_close_npc(pl_sd,2);
  3361. mapit_free(iter);
  3362. flush_fifos();
  3363. map_reloadnpc(true); // reload config files seeking for npcs
  3364. script_reload();
  3365. npc_reload();
  3366. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3367. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3368. map_msg_reload();
  3369. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3370. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3371. do_reload_quest();
  3372. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3373. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3374. instance_reload();
  3375. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3376. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3377. achievement_db_reload();
  3378. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3379. }
  3380. return 0;
  3381. }
  3382. /*==========================================
  3383. * @partysharelvl <share_range> [Akinari]
  3384. * Updates char server party share level range in runtime
  3385. * Temporary - Permanent update in inter_athena.conf
  3386. *------------------------------------------*/
  3387. ACMD_FUNC(partysharelvl) {
  3388. unsigned int share_lvl;
  3389. nullpo_retr(-1, sd);
  3390. if(!message || !*message) {
  3391. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3392. return -1;
  3393. } else {
  3394. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3395. }
  3396. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3397. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3398. else //Char server offline
  3399. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3400. return 0;
  3401. }
  3402. /*==========================================
  3403. * @mapinfo [0-3] <map name> by MC_Cameri
  3404. * => Shows information about the map [map name]
  3405. * 0 = no additional information
  3406. * 1 = Show users in that map and their location
  3407. * 2 = Shows NPCs in that map
  3408. * 3 = Shows the chats in that map
  3409. *------------------------------------------*/
  3410. ACMD_FUNC(mapinfo) {
  3411. struct map_session_data* pl_sd;
  3412. struct s_mapiterator* iter;
  3413. struct chat_data *cd = NULL;
  3414. char direction[12];
  3415. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3416. unsigned short m_index;
  3417. char mapname[24];
  3418. nullpo_retr(-1, sd);
  3419. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3420. memset(mapname, '\0', sizeof(mapname));
  3421. memset(direction, '\0', sizeof(direction));
  3422. sscanf(message, "%11d %23[^\n]", &list, mapname);
  3423. if (list < 0 || list > 3) {
  3424. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3425. return -1;
  3426. }
  3427. if (mapname[0] == '\0') {
  3428. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3429. m_id = map_mapindex2mapid(sd->mapindex);
  3430. } else {
  3431. m_id = map_mapname2mapid(mapname);
  3432. }
  3433. if (m_id < 0) {
  3434. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3435. return -1;
  3436. }
  3437. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3438. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3439. // count chats (for initial message)
  3440. chat_num = 0;
  3441. iter = mapit_getallusers();
  3442. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3443. if( pl_sd->mapindex == m_index ) {
  3444. if( pl_sd->state.vending )
  3445. vend_num++;
  3446. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3447. chat_num++;
  3448. }
  3449. }
  3450. mapit_free(iter);
  3451. sprintf(atcmd_output, msg_txt(sd,1040), mapname, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3452. clif_displaymessage(fd, atcmd_output);
  3453. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3454. if (map[m_id].flag.town)
  3455. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3456. if (map[m_id].flag.restricted){
  3457. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3458. clif_displaymessage(fd, atcmd_output);
  3459. }
  3460. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3461. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3462. else
  3463. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3464. if (map[m_id].flag.battleground){
  3465. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3466. clif_displaymessage(fd, atcmd_output);
  3467. }
  3468. /* Skill damage adjustment info [Cydh] */
  3469. #ifdef ADJUST_SKILL_DAMAGE
  3470. if (map[m_id].flag.skill_damage) {
  3471. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3472. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3473. ,map[m_id].adjust.damage.pc
  3474. ,map[m_id].adjust.damage.mob
  3475. ,map[m_id].adjust.damage.boss
  3476. ,map[m_id].adjust.damage.other
  3477. ,map[m_id].adjust.damage.caster);
  3478. clif_displaymessage(fd, atcmd_output);
  3479. if (map[m_id].skill_damage.count) {
  3480. uint8 j;
  3481. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3482. for (j = 0; j < map[m_id].skill_damage.count; j++) {
  3483. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3484. ,j+1
  3485. ,skill_get_name(map[m_id].skill_damage.entries[j]->skill_id)
  3486. ,map[m_id].skill_damage.entries[j]->pc
  3487. ,map[m_id].skill_damage.entries[j]->mob
  3488. ,map[m_id].skill_damage.entries[j]->boss
  3489. ,map[m_id].skill_damage.entries[j]->other
  3490. ,map[m_id].skill_damage.entries[j]->caster);
  3491. clif_displaymessage(fd,atcmd_output);
  3492. }
  3493. }
  3494. }
  3495. #endif
  3496. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3497. if (map[m_id].flag.pvp)
  3498. strcat(atcmd_output, " Pvp ON |");
  3499. if (map[m_id].flag.pvp_noguild)
  3500. strcat(atcmd_output, " NoGuild |");
  3501. if (map[m_id].flag.pvp_noparty)
  3502. strcat(atcmd_output, " NoParty |");
  3503. if (map[m_id].flag.pvp_nightmaredrop)
  3504. strcat(atcmd_output, " NightmareDrop |");
  3505. if (map[m_id].flag.pvp_nocalcrank)
  3506. strcat(atcmd_output, " NoCalcRank |");
  3507. clif_displaymessage(fd, atcmd_output);
  3508. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3509. if (map[m_id].flag.gvg)
  3510. strcat(atcmd_output, " GvG ON |");
  3511. if (map[m_id].flag.gvg_dungeon)
  3512. strcat(atcmd_output, " GvG Dungeon |");
  3513. if (map[m_id].flag.gvg_castle)
  3514. strcat(atcmd_output, " GvG Castle |");
  3515. if (map[m_id].flag.gvg_te)
  3516. strcat(atcmd_output, " GvG TE |");
  3517. if (map[m_id].flag.gvg_te_castle)
  3518. strcat(atcmd_output, " GvG TE Castle |");
  3519. if (map[m_id].flag.gvg_noparty)
  3520. strcat(atcmd_output, " NoParty |");
  3521. clif_displaymessage(fd, atcmd_output);
  3522. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3523. if (map[m_id].flag.noteleport)
  3524. strcat(atcmd_output, " NoTeleport |");
  3525. if (map[m_id].flag.monster_noteleport)
  3526. strcat(atcmd_output, " Monster NoTeleport |");
  3527. if (map[m_id].flag.nowarp)
  3528. strcat(atcmd_output, " NoWarp |");
  3529. if (map[m_id].flag.nowarpto)
  3530. strcat(atcmd_output, " NoWarpTo |");
  3531. if (map[m_id].flag.noreturn)
  3532. strcat(atcmd_output, " NoReturn |");
  3533. if (map[m_id].flag.nogo)
  3534. strcat(atcmd_output, " NoGo |"); //
  3535. if (map[m_id].flag.nomemo)
  3536. strcat(atcmd_output, " NoMemo |");
  3537. clif_displaymessage(fd, atcmd_output);
  3538. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3539. (map[m_id].flag.noexppenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map[m_id].flag.nozenypenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3540. clif_displaymessage(fd, atcmd_output);
  3541. if (map[m_id].flag.nosave) {
  3542. if (!map[m_id].save.map)
  3543. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3544. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3545. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3546. clif_displaymessage(fd, atcmd_output);
  3547. }
  3548. else {
  3549. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3550. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3551. clif_displaymessage(fd, atcmd_output);
  3552. }
  3553. }
  3554. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3555. if (map[m_id].flag.snow)
  3556. strcat(atcmd_output, " Snow |");
  3557. if (map[m_id].flag.fog)
  3558. strcat(atcmd_output, " Fog |");
  3559. if (map[m_id].flag.sakura)
  3560. strcat(atcmd_output, " Sakura |");
  3561. if (map[m_id].flag.clouds)
  3562. strcat(atcmd_output, " Clouds |");
  3563. if (map[m_id].flag.clouds2)
  3564. strcat(atcmd_output, " Clouds2 |");
  3565. if (map[m_id].flag.fireworks)
  3566. strcat(atcmd_output, " Fireworks |");
  3567. if (map[m_id].flag.leaves)
  3568. strcat(atcmd_output, " Leaves |");
  3569. if (map[m_id].flag.nightenabled)
  3570. strcat(atcmd_output, " Displays Night |");
  3571. clif_displaymessage(fd, atcmd_output);
  3572. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3573. if (map[m_id].flag.nobranch)
  3574. strcat(atcmd_output, " NoBranch |");
  3575. if (map[m_id].flag.notrade)
  3576. strcat(atcmd_output, " NoTrade |");
  3577. if (map[m_id].flag.novending)
  3578. strcat(atcmd_output, " NoVending |");
  3579. if (map[m_id].flag.nodrop)
  3580. strcat(atcmd_output, " NoDrop |");
  3581. if (map[m_id].flag.noskill)
  3582. strcat(atcmd_output, " NoSkill |");
  3583. if (map[m_id].flag.noicewall)
  3584. strcat(atcmd_output, " NoIcewall |");
  3585. if (map[m_id].flag.allowks)
  3586. strcat(atcmd_output, " AllowKS |");
  3587. if (map[m_id].flag.reset)
  3588. strcat(atcmd_output, " Reset |");
  3589. if (map[m_id].flag.hidemobhpbar)
  3590. strcat(atcmd_output, " HideMobHPBar |");
  3591. clif_displaymessage(fd, atcmd_output);
  3592. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3593. if (map[m_id].nocommand)
  3594. strcat(atcmd_output, " NoCommand |");
  3595. if (map[m_id].flag.nobaseexp)
  3596. strcat(atcmd_output, " NoBaseEXP |");
  3597. if (map[m_id].flag.nojobexp)
  3598. strcat(atcmd_output, " NoJobEXP |");
  3599. if (map[m_id].flag.nomobloot)
  3600. strcat(atcmd_output, " NoMobLoot |");
  3601. if (map[m_id].flag.nomvploot)
  3602. strcat(atcmd_output, " NoMVPLoot |");
  3603. if (map[m_id].flag.partylock)
  3604. strcat(atcmd_output, " PartyLock |");
  3605. if (map[m_id].flag.guildlock)
  3606. strcat(atcmd_output, " GuildLock |");
  3607. if (map[m_id].flag.loadevent)
  3608. strcat(atcmd_output, " Loadevent |");
  3609. if (map[m_id].flag.chmautojoin)
  3610. strcat(atcmd_output, " Chmautojoin |");
  3611. if (map[m_id].flag.nousecart)
  3612. strcat(atcmd_output, " NoUsecart |");
  3613. if (map[m_id].flag.noitemconsumption)
  3614. strcat(atcmd_output, " NoItemConsumption |");
  3615. if (map[m_id].flag.nosumstarmiracle)
  3616. strcat(atcmd_output, " NoSumStarMiracle |");
  3617. if (map[m_id].flag.nomineeffect)
  3618. strcat(atcmd_output, " NoMineEffect |");
  3619. if (map[m_id].flag.nolockon)
  3620. strcat(atcmd_output, " NoLockOn |");
  3621. if (map[m_id].flag.notomb)
  3622. strcat(atcmd_output, " NoTomb |");
  3623. if (map[m_id].flag.nocostume)
  3624. strcat(atcmd_output, " NoCostume |");
  3625. clif_displaymessage(fd, atcmd_output);
  3626. switch (list) {
  3627. case 0:
  3628. // Do nothing. It's list 0, no additional display.
  3629. break;
  3630. case 1:
  3631. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3632. iter = mapit_getallusers();
  3633. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3634. {
  3635. if (pl_sd->mapindex == m_index) {
  3636. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3637. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3638. clif_displaymessage(fd, atcmd_output);
  3639. }
  3640. }
  3641. mapit_free(iter);
  3642. break;
  3643. case 2:
  3644. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3645. for (i = 0; i < map[m_id].npc_num;)
  3646. {
  3647. struct npc_data *nd = map[m_id].npc[i];
  3648. switch(nd->ud.dir) {
  3649. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3650. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3651. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3652. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3653. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3654. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3655. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3656. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3657. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3658. }
  3659. if(strcmp(nd->name,nd->exname) == 0)
  3660. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3661. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3662. else
  3663. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3664. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3665. clif_displaymessage(fd, atcmd_output);
  3666. }
  3667. break;
  3668. case 3:
  3669. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3670. iter = mapit_getallusers();
  3671. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3672. {
  3673. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3674. pl_sd->mapindex == m_index &&
  3675. cd->usersd[0] == pl_sd)
  3676. {
  3677. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3678. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3679. clif_displaymessage(fd, atcmd_output);
  3680. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3681. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3682. clif_displaymessage(fd, atcmd_output);
  3683. }
  3684. }
  3685. mapit_free(iter);
  3686. break;
  3687. default: // normally impossible to arrive here
  3688. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3689. return -1;
  3690. break;
  3691. }
  3692. return 0;
  3693. }
  3694. /*==========================================
  3695. *
  3696. *------------------------------------------*/
  3697. ACMD_FUNC(mount_peco)
  3698. {
  3699. nullpo_retr(-1, sd);
  3700. if (sd->disguise) {
  3701. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3702. return -1;
  3703. }
  3704. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3705. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3706. unsigned int option = OPTION_DRAGON1;
  3707. if( message[0] ) {
  3708. int color = atoi(message);
  3709. option = ( color == 2 ? OPTION_DRAGON2 :
  3710. color == 3 ? OPTION_DRAGON3 :
  3711. color == 4 ? OPTION_DRAGON4 :
  3712. color == 5 ? OPTION_DRAGON5 :
  3713. OPTION_DRAGON1 );
  3714. }
  3715. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3716. pc_setoption(sd, sd->sc.option|option);
  3717. } else {
  3718. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3719. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3720. }
  3721. return 0;
  3722. }
  3723. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3724. if( !pc_isridingwug(sd) ) {
  3725. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3726. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3727. } else {
  3728. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3729. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3730. }
  3731. return 0;
  3732. }
  3733. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3734. if( !pc_ismadogear(sd) ) {
  3735. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3736. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3737. } else {
  3738. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3739. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3740. }
  3741. return 0;
  3742. }
  3743. if (!pc_isriding(sd)) { // if actually no peco
  3744. if (!pc_checkskill(sd, KN_RIDING)) {
  3745. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3746. return -1;
  3747. }
  3748. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3749. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3750. } else {//Dismount
  3751. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3752. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3753. }
  3754. return 0;
  3755. }
  3756. /*==========================================
  3757. *Spy Commands by Syrus22
  3758. *------------------------------------------*/
  3759. ACMD_FUNC(guildspy)
  3760. {
  3761. char guild_name[NAME_LENGTH];
  3762. struct guild *g;
  3763. nullpo_retr(-1, sd);
  3764. memset(guild_name, '\0', sizeof(guild_name));
  3765. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3766. if (!enable_spy)
  3767. {
  3768. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3769. return -1;
  3770. }
  3771. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3772. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3773. return -1;
  3774. }
  3775. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3776. (g = guild_search(atoi(message))) != NULL) {
  3777. if (sd->guildspy == g->guild_id) {
  3778. sd->guildspy = 0;
  3779. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3780. clif_displaymessage(fd, atcmd_output);
  3781. } else {
  3782. sd->guildspy = g->guild_id;
  3783. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3784. clif_displaymessage(fd, atcmd_output);
  3785. }
  3786. } else {
  3787. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3788. return -1;
  3789. }
  3790. return 0;
  3791. }
  3792. /*==========================================
  3793. *
  3794. *------------------------------------------*/
  3795. ACMD_FUNC(partyspy)
  3796. {
  3797. char party_name[NAME_LENGTH];
  3798. struct party_data *p;
  3799. nullpo_retr(-1, sd);
  3800. memset(party_name, '\0', sizeof(party_name));
  3801. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3802. if (!enable_spy)
  3803. {
  3804. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3805. return -1;
  3806. }
  3807. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3808. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3809. return -1;
  3810. }
  3811. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3812. (p = party_search(atoi(message))) != NULL) {
  3813. if (sd->partyspy == p->party.party_id) {
  3814. sd->partyspy = 0;
  3815. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3816. clif_displaymessage(fd, atcmd_output);
  3817. } else {
  3818. sd->partyspy = p->party.party_id;
  3819. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3820. clif_displaymessage(fd, atcmd_output);
  3821. }
  3822. } else {
  3823. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3824. return -1;
  3825. }
  3826. return 0;
  3827. }
  3828. ACMD_FUNC(clanspy){
  3829. char clan_name[NAME_LENGTH];
  3830. struct clan* c;
  3831. nullpo_retr(-1, sd);
  3832. memset(clan_name, '\0', sizeof(clan_name));
  3833. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3834. if( !enable_spy ){
  3835. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  3836. return -1;
  3837. }
  3838. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  3839. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  3840. return -1;
  3841. }
  3842. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  3843. (c = clan_search(atoi(message))) != NULL) {
  3844. if (sd->clanspy == c->id) {
  3845. sd->clanspy = 0;
  3846. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  3847. clif_displaymessage(fd, atcmd_output);
  3848. }
  3849. else {
  3850. sd->clanspy = c->id;
  3851. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  3852. clif_displaymessage(fd, atcmd_output);
  3853. }
  3854. }
  3855. else {
  3856. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  3857. return -1;
  3858. }
  3859. return 0;
  3860. }
  3861. /*==========================================
  3862. * @repairall [Valaris]
  3863. *------------------------------------------*/
  3864. ACMD_FUNC(repairall)
  3865. {
  3866. int count, i;
  3867. nullpo_retr(-1, sd);
  3868. count = 0;
  3869. for (i = 0; i < MAX_INVENTORY; i++) {
  3870. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1) {
  3871. sd->inventory.u.items_inventory[i].attribute = 0;
  3872. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  3873. count++;
  3874. }
  3875. }
  3876. if (count > 0) {
  3877. clif_misceffect(&sd->bl, 3);
  3878. clif_equiplist(sd);
  3879. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3880. } else {
  3881. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3882. return -1;
  3883. }
  3884. return 0;
  3885. }
  3886. /*==========================================
  3887. * @nuke [Valaris]
  3888. *------------------------------------------*/
  3889. ACMD_FUNC(nuke)
  3890. {
  3891. struct map_session_data *pl_sd;
  3892. nullpo_retr(-1, sd);
  3893. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3894. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3895. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3896. return -1;
  3897. }
  3898. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  3899. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3900. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3901. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3902. } else {
  3903. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3904. return -1;
  3905. }
  3906. } else {
  3907. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3908. return -1;
  3909. }
  3910. return 0;
  3911. }
  3912. /*==========================================
  3913. * @tonpc
  3914. *------------------------------------------*/
  3915. ACMD_FUNC(tonpc)
  3916. {
  3917. char npcname[NPC_NAME_LENGTH];
  3918. struct npc_data *nd;
  3919. nullpo_retr(-1, sd);
  3920. memset(npcname, 0, sizeof(npcname));
  3921. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  3922. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3923. return -1;
  3924. }
  3925. if ((nd = npc_name2id(npcname)) != NULL) {
  3926. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  3927. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3928. else
  3929. return -1;
  3930. } else {
  3931. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3932. return -1;
  3933. }
  3934. return 0;
  3935. }
  3936. /*==========================================
  3937. *
  3938. *------------------------------------------*/
  3939. ACMD_FUNC(shownpc)
  3940. {
  3941. char NPCname[NPC_NAME_LENGTH];
  3942. nullpo_retr(-1, sd);
  3943. memset(NPCname, '\0', sizeof(NPCname));
  3944. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3945. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3946. return -1;
  3947. }
  3948. if (npc_name2id(NPCname) != NULL) {
  3949. npc_enable(NPCname, 1);
  3950. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3951. } else {
  3952. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3953. return -1;
  3954. }
  3955. return 0;
  3956. }
  3957. /*==========================================
  3958. *
  3959. *------------------------------------------*/
  3960. ACMD_FUNC(hidenpc)
  3961. {
  3962. char NPCname[NPC_NAME_LENGTH];
  3963. nullpo_retr(-1, sd);
  3964. memset(NPCname, '\0', sizeof(NPCname));
  3965. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3966. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3967. return -1;
  3968. }
  3969. if (npc_name2id(NPCname) == NULL) {
  3970. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3971. return -1;
  3972. }
  3973. npc_enable(NPCname, 0);
  3974. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3975. return 0;
  3976. }
  3977. ACMD_FUNC(loadnpc)
  3978. {
  3979. if (!message || !*message) {
  3980. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3981. return -1;
  3982. }
  3983. if (!npc_addsrcfile(message, true)) {
  3984. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  3985. return -1;
  3986. }
  3987. npc_read_event_script();
  3988. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  3989. return 0;
  3990. }
  3991. ACMD_FUNC(unloadnpc)
  3992. {
  3993. struct npc_data *nd;
  3994. char NPCname[NPC_NAME_LENGTH];
  3995. nullpo_retr(-1, sd);
  3996. memset(NPCname, '\0', sizeof(NPCname));
  3997. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3998. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3999. return -1;
  4000. }
  4001. if ((nd = npc_name2id(NPCname)) == NULL) {
  4002. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4003. return -1;
  4004. }
  4005. npc_unload_duplicates(nd);
  4006. npc_unload(nd,true);
  4007. npc_read_event_script();
  4008. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4009. return 0;
  4010. }
  4011. ACMD_FUNC(reloadnpcfile) {
  4012. if (!message || !*message) {
  4013. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4014. return -1;
  4015. }
  4016. if (npc_unloadfile(message))
  4017. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4018. if (!npc_addsrcfile(message, true)) {
  4019. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4020. return -1;
  4021. }
  4022. npc_read_event_script();
  4023. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4024. return 0;
  4025. }
  4026. /*==========================================
  4027. * time in txt for time command (by [Yor])
  4028. *------------------------------------------*/
  4029. char* txt_time(unsigned int duration)
  4030. {
  4031. int days, hours, minutes, seconds;
  4032. char temp[CHAT_SIZE_MAX];
  4033. static char temp1[CHAT_SIZE_MAX];
  4034. memset(temp, '\0', sizeof(temp));
  4035. memset(temp1, '\0', sizeof(temp1));
  4036. days = duration / (60 * 60 * 24);
  4037. duration = duration - (60 * 60 * 24 * days);
  4038. hours = duration / (60 * 60);
  4039. duration = duration - (60 * 60 * hours);
  4040. minutes = duration / 60;
  4041. seconds = duration - (60 * minutes);
  4042. if (days == 1)
  4043. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4044. else if (days > 1)
  4045. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4046. if (hours == 1)
  4047. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4048. else if (hours > 1)
  4049. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4050. if (minutes < 2)
  4051. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4052. else
  4053. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4054. if (seconds == 1)
  4055. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4056. else if (seconds > 1)
  4057. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4058. return temp1;
  4059. }
  4060. /*==========================================
  4061. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4062. * Calculation management of GM modification (@day/@night GM commands) is done
  4063. *------------------------------------------*/
  4064. ACMD_FUNC(servertime)
  4065. {
  4066. const struct TimerData * timer_data;
  4067. time_t time_server; // variable for number of seconds (used with time() function)
  4068. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4069. char temp[CHAT_SIZE_MAX];
  4070. nullpo_retr(-1, sd);
  4071. memset(temp, '\0', sizeof(temp));
  4072. time(&time_server); // get time in seconds since 1/1/1970
  4073. datetime = localtime(&time_server); // convert seconds in structure
  4074. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4075. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4076. clif_displaymessage(fd, temp);
  4077. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4078. if (night_flag == 0)
  4079. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4080. else
  4081. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4082. } else if (battle_config.night_duration == 0)
  4083. if (night_flag == 1) { // we start with night
  4084. timer_data = get_timer(day_timer_tid);
  4085. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4086. clif_displaymessage(fd, temp);
  4087. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4088. } else
  4089. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4090. else if (battle_config.day_duration == 0)
  4091. if (night_flag == 0) { // we start with day
  4092. timer_data = get_timer(night_timer_tid);
  4093. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4094. clif_displaymessage(fd, temp);
  4095. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4096. } else
  4097. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4098. else {
  4099. const struct TimerData * timer_data2;
  4100. if (night_flag == 0) {
  4101. timer_data = get_timer(night_timer_tid);
  4102. timer_data2 = get_timer(day_timer_tid);
  4103. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4104. clif_displaymessage(fd, temp);
  4105. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4106. 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.
  4107. else
  4108. 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.
  4109. clif_displaymessage(fd, temp);
  4110. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4111. clif_displaymessage(fd, temp);
  4112. } else {
  4113. timer_data = get_timer(day_timer_tid);
  4114. timer_data2 = get_timer(night_timer_tid);
  4115. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4116. clif_displaymessage(fd, temp);
  4117. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4118. 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.
  4119. else
  4120. 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.
  4121. clif_displaymessage(fd, temp);
  4122. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4123. clif_displaymessage(fd, temp);
  4124. }
  4125. }
  4126. return 0;
  4127. }
  4128. /*==========================================
  4129. * @jail <char_name> by [Yor]
  4130. * Special warp! No check with nowarp and nowarpto flag
  4131. *------------------------------------------*/
  4132. ACMD_FUNC(jail)
  4133. {
  4134. struct map_session_data *pl_sd;
  4135. int x, y;
  4136. unsigned short m_index;
  4137. nullpo_retr(-1, sd);
  4138. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4139. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4140. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4141. return -1;
  4142. }
  4143. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4144. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4145. return -1;
  4146. }
  4147. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4148. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4149. return -1;
  4150. }
  4151. if (pl_sd->sc.data[SC_JAILED]) {
  4152. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4153. return -1;
  4154. }
  4155. switch(rnd() % 2) { //Jail Locations
  4156. case 0:
  4157. m_index = mapindex_name2id(MAP_JAIL);
  4158. x = 24;
  4159. y = 75;
  4160. break;
  4161. default:
  4162. m_index = mapindex_name2id(MAP_JAIL);
  4163. x = 49;
  4164. y = 75;
  4165. break;
  4166. }
  4167. //Duration of INT_MAX to specify infinity.
  4168. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4169. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4170. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4171. return 0;
  4172. }
  4173. /*==========================================
  4174. * @unjail/@discharge <char_name> by [Yor]
  4175. * Special warp! No check with nowarp and nowarpto flag
  4176. *------------------------------------------*/
  4177. ACMD_FUNC(unjail)
  4178. {
  4179. struct map_session_data *pl_sd;
  4180. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4181. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4182. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4183. return -1;
  4184. }
  4185. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4186. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4187. return -1;
  4188. }
  4189. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4190. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4191. return -1;
  4192. }
  4193. if (!pl_sd->sc.data[SC_JAILED]) {
  4194. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4195. return -1;
  4196. }
  4197. //Reset jail time to 1 sec.
  4198. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4199. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4200. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4201. return 0;
  4202. }
  4203. ACMD_FUNC(jailfor) {
  4204. struct map_session_data *pl_sd = NULL;
  4205. char * modif_p;
  4206. int jailtime = 0,x,y;
  4207. short m_index = 0;
  4208. nullpo_retr(-1, sd);
  4209. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4210. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4211. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4212. return -1;
  4213. }
  4214. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4215. modif_p = atcmd_output;
  4216. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4217. if (jailtime == 0) {
  4218. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4219. 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.
  4220. return -1;
  4221. }
  4222. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4223. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4224. return -1;
  4225. }
  4226. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4227. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4228. return -1;
  4229. }
  4230. // Added by Coltaro
  4231. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4232. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4233. if (jailtime <= 0) {
  4234. jailtime = 0;
  4235. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4236. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4237. } else {
  4238. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4239. char timestr[21];
  4240. time_t now=time(NULL);
  4241. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4242. 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
  4243. clif_displaymessage(pl_sd->fd, atcmd_output);
  4244. 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
  4245. clif_displaymessage(fd, atcmd_output);
  4246. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4247. sprintf(atcmd_output,"Release date is: %s",timestr);
  4248. clif_displaymessage(pl_sd->fd, atcmd_output);
  4249. clif_displaymessage(fd, atcmd_output);
  4250. }
  4251. } else if (jailtime < 0) {
  4252. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4253. return -1;
  4254. }
  4255. // Jail locations, add more as you wish.
  4256. switch(rnd()%2) {
  4257. case 1: // Jail #1
  4258. m_index = mapindex_name2id(MAP_JAIL);
  4259. x = 49; y = 75;
  4260. break;
  4261. default: // Default Jail
  4262. m_index = mapindex_name2id(MAP_JAIL);
  4263. x = 24; y = 75;
  4264. break;
  4265. }
  4266. 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).
  4267. return 0;
  4268. }
  4269. //By Coltaro
  4270. ACMD_FUNC(jailtime){
  4271. int year, month, day, hour, minute, second;
  4272. char timestr[21];
  4273. time_t now = time(NULL);
  4274. nullpo_retr(-1, sd);
  4275. if (!sd->sc.data[SC_JAILED]) {
  4276. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4277. return -1;
  4278. }
  4279. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4280. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4281. return 0;
  4282. }
  4283. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4284. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4285. return -1;
  4286. }
  4287. // Get remaining jail time
  4288. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4289. 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
  4290. clif_displaymessage(fd, atcmd_output);
  4291. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4292. sprintf(atcmd_output,"Release date is: %s",timestr);
  4293. clif_displaymessage(fd, atcmd_output);
  4294. return 0;
  4295. }
  4296. /*==========================================
  4297. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4298. *------------------------------------------*/
  4299. ACMD_FUNC(disguise)
  4300. {
  4301. int id = 0;
  4302. nullpo_retr(-1, sd);
  4303. if (!message || !*message) {
  4304. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4305. return -1;
  4306. }
  4307. if ((id = atoi(message)) > 0)
  4308. { //Acquired an ID
  4309. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4310. id = 0; //Invalid id for either mobs or npcs.
  4311. } else { //Acquired a Name
  4312. if ((id = mobdb_searchname(message)) == 0)
  4313. {
  4314. struct npc_data* nd = npc_name2id(message);
  4315. if (nd != NULL)
  4316. id = nd->class_;
  4317. }
  4318. }
  4319. if (id == 0)
  4320. {
  4321. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4322. return -1;
  4323. }
  4324. if(pc_isriding(sd))
  4325. {
  4326. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4327. return -1;
  4328. }
  4329. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4330. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4331. return -1;
  4332. }
  4333. pc_disguise(sd, id);
  4334. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4335. return 0;
  4336. }
  4337. /*==========================================
  4338. * DisguiseAll
  4339. *------------------------------------------*/
  4340. ACMD_FUNC(disguiseall)
  4341. {
  4342. int mob_id=0;
  4343. struct map_session_data *pl_sd;
  4344. struct s_mapiterator* iter;
  4345. nullpo_retr(-1, sd);
  4346. if (!message || !*message) {
  4347. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4348. return -1;
  4349. }
  4350. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4351. mob_id = atoi(message);
  4352. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4353. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4354. return -1;
  4355. }
  4356. iter = mapit_getallusers();
  4357. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4358. pc_disguise(pl_sd, mob_id);
  4359. mapit_free(iter);
  4360. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4361. return 0;
  4362. }
  4363. /*==========================================
  4364. * DisguiseGuild
  4365. *------------------------------------------*/
  4366. ACMD_FUNC(disguiseguild)
  4367. {
  4368. int id = 0, i;
  4369. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4370. struct guild *g;
  4371. memset(monster, '\0', sizeof(monster));
  4372. memset(guild, '\0', sizeof(guild));
  4373. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4374. 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>).
  4375. return -1;
  4376. }
  4377. if( (id = atoi(monster)) > 0 ) {
  4378. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4379. id = 0;
  4380. } else {
  4381. if( (id = mobdb_searchname(monster)) == 0 ) {
  4382. struct npc_data* nd = npc_name2id(monster);
  4383. if( nd != NULL )
  4384. id = nd->class_;
  4385. }
  4386. }
  4387. if( id == 0 ) {
  4388. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4389. return -1;
  4390. }
  4391. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4392. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4393. return -1;
  4394. }
  4395. for( i = 0; i < g->max_member; i++ ){
  4396. struct map_session_data *pl_sd;
  4397. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4398. pc_disguise(pl_sd, id);
  4399. }
  4400. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4401. return 0;
  4402. }
  4403. /*==========================================
  4404. * @undisguise by [Yor]
  4405. *------------------------------------------*/
  4406. ACMD_FUNC(undisguise)
  4407. {
  4408. nullpo_retr(-1, sd);
  4409. if (sd->disguise) {
  4410. pc_disguise(sd, 0);
  4411. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4412. } else {
  4413. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4414. return -1;
  4415. }
  4416. return 0;
  4417. }
  4418. /*==========================================
  4419. * UndisguiseAll
  4420. *------------------------------------------*/
  4421. ACMD_FUNC(undisguiseall)
  4422. {
  4423. struct map_session_data *pl_sd;
  4424. struct s_mapiterator* iter;
  4425. nullpo_retr(-1, sd);
  4426. iter = mapit_getallusers();
  4427. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4428. if( pl_sd->disguise )
  4429. pc_disguise(pl_sd, 0);
  4430. mapit_free(iter);
  4431. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4432. return 0;
  4433. }
  4434. /*==========================================
  4435. * UndisguiseGuild
  4436. *------------------------------------------*/
  4437. ACMD_FUNC(undisguiseguild)
  4438. {
  4439. char guild_name[NAME_LENGTH];
  4440. struct guild *g;
  4441. int i;
  4442. nullpo_retr(-1, sd);
  4443. memset(guild_name, '\0', sizeof(guild_name));
  4444. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4445. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4446. return -1;
  4447. }
  4448. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4449. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4450. return -1;
  4451. }
  4452. for(i = 0; i < g->max_member; i++){
  4453. struct map_session_data *pl_sd;
  4454. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4455. pc_disguise(pl_sd, 0);
  4456. }
  4457. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4458. return 0;
  4459. }
  4460. /*==========================================
  4461. * @exp by [Skotlex]
  4462. *------------------------------------------*/
  4463. ACMD_FUNC(exp)
  4464. {
  4465. char output[CHAT_SIZE_MAX];
  4466. double nextb, nextj;
  4467. nullpo_retr(-1, sd);
  4468. memset(output, '\0', sizeof(output));
  4469. nextb = pc_nextbaseexp(sd);
  4470. if (nextb)
  4471. nextb = sd->status.base_exp*100.0/nextb;
  4472. nextj = pc_nextjobexp(sd);
  4473. if (nextj)
  4474. nextj = sd->status.job_exp*100.0/nextj;
  4475. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4476. clif_displaymessage(fd, output);
  4477. return 0;
  4478. }
  4479. /*==========================================
  4480. * @broadcast by [Valaris]
  4481. *------------------------------------------*/
  4482. ACMD_FUNC(broadcast)
  4483. {
  4484. nullpo_retr(-1, sd);
  4485. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4486. if (!message || !*message) {
  4487. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4488. return -1;
  4489. }
  4490. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4491. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4492. return 0;
  4493. }
  4494. /*==========================================
  4495. * @localbroadcast by [Valaris]
  4496. *------------------------------------------*/
  4497. ACMD_FUNC(localbroadcast)
  4498. {
  4499. nullpo_retr(-1, sd);
  4500. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4501. if (!message || !*message) {
  4502. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4503. return -1;
  4504. }
  4505. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4506. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4507. return 0;
  4508. }
  4509. /*==========================================
  4510. * @email <actual@email> <new@email> by [Yor]
  4511. *------------------------------------------*/
  4512. ACMD_FUNC(email)
  4513. {
  4514. char actual_email[100];
  4515. char new_email[100];
  4516. nullpo_retr(-1, sd);
  4517. memset(actual_email, '\0', sizeof(actual_email));
  4518. memset(new_email, '\0', sizeof(new_email));
  4519. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4520. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4521. return -1;
  4522. }
  4523. if (e_mail_check(actual_email) == 0) {
  4524. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4525. return -1;
  4526. } else if (e_mail_check(new_email) == 0) {
  4527. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4528. return -1;
  4529. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4530. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4531. return -1;
  4532. } else if (strcmpi(actual_email, new_email) == 0) {
  4533. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4534. return -1;
  4535. }
  4536. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4537. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4538. return 0;
  4539. }
  4540. /*==========================================
  4541. *@effect
  4542. *------------------------------------------*/
  4543. ACMD_FUNC(effect)
  4544. {
  4545. int type = EF_NONE;
  4546. nullpo_retr(-1, sd);
  4547. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4548. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4549. return -1;
  4550. }
  4551. if( type <= EF_NONE || type >= EF_MAX ){
  4552. 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.
  4553. clif_displaymessage(fd, atcmd_output);
  4554. return -1;
  4555. }
  4556. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4557. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4558. return 0;
  4559. }
  4560. /*==========================================
  4561. * @killer by MouseJstr
  4562. * enable killing players even when not in pvp
  4563. *------------------------------------------*/
  4564. ACMD_FUNC(killer)
  4565. {
  4566. nullpo_retr(-1, sd);
  4567. sd->state.killer = !sd->state.killer;
  4568. if(sd->state.killer)
  4569. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4570. else {
  4571. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4572. pc_stop_attack(sd);
  4573. }
  4574. return 0;
  4575. }
  4576. /*==========================================
  4577. * @killable by MouseJstr
  4578. * enable other people killing you
  4579. *------------------------------------------*/
  4580. ACMD_FUNC(killable)
  4581. {
  4582. nullpo_retr(-1, sd);
  4583. sd->state.killable = !sd->state.killable;
  4584. if(sd->state.killable)
  4585. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4586. else {
  4587. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4588. map_foreachinallrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4589. }
  4590. return 0;
  4591. }
  4592. /*==========================================
  4593. * @skillon by MouseJstr
  4594. * turn skills on for the map
  4595. *------------------------------------------*/
  4596. ACMD_FUNC(skillon)
  4597. {
  4598. nullpo_retr(-1, sd);
  4599. map[sd->bl.m].flag.noskill = 0;
  4600. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4601. return 0;
  4602. }
  4603. /*==========================================
  4604. * @skilloff by MouseJstr
  4605. * Turn skills off on the map
  4606. *------------------------------------------*/
  4607. ACMD_FUNC(skilloff)
  4608. {
  4609. nullpo_retr(-1, sd);
  4610. map[sd->bl.m].flag.noskill = 1;
  4611. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4612. return 0;
  4613. }
  4614. /*==========================================
  4615. * @npcmove by MouseJstr
  4616. * move a npc
  4617. *------------------------------------------*/
  4618. ACMD_FUNC(npcmove)
  4619. {
  4620. short x = 0, y = 0;
  4621. struct npc_data *nd = 0;
  4622. char npc_name[NPC_NAME_LENGTH];
  4623. nullpo_retr(-1, sd);
  4624. memset(npc_name, '\0', sizeof npc_name);
  4625. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4626. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4627. return -1;
  4628. }
  4629. if ((nd = npc_name2id(npc_name)) == NULL)
  4630. {
  4631. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4632. return -1;
  4633. }
  4634. if ( npc_movenpc( nd, x, y ) )
  4635. { //actually failed to move
  4636. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4637. return -1; //Not on a map.
  4638. } else
  4639. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4640. return 0;
  4641. }
  4642. /*==========================================
  4643. * @addwarp by MouseJstr
  4644. * Create a new static warp point.
  4645. *------------------------------------------*/
  4646. ACMD_FUNC(addwarp)
  4647. {
  4648. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4649. short x,y;
  4650. unsigned short m;
  4651. struct npc_data* nd;
  4652. nullpo_retr(-1, sd);
  4653. memset(warpname, '\0', sizeof(warpname));
  4654. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4655. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4656. return -1;
  4657. }
  4658. m = mapindex_name2id(mapname);
  4659. if( m == 0 )
  4660. {
  4661. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4662. clif_displaymessage(fd, atcmd_output);
  4663. return -1;
  4664. }
  4665. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4666. if( nd == NULL )
  4667. return -1;
  4668. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4669. clif_displaymessage(fd, atcmd_output);
  4670. return 0;
  4671. }
  4672. /*==========================================
  4673. * @follow by [MouseJstr]
  4674. * Follow a player .. staying no more then 5 spaces away
  4675. *------------------------------------------*/
  4676. ACMD_FUNC(follow)
  4677. {
  4678. struct map_session_data *pl_sd = NULL;
  4679. nullpo_retr(-1, sd);
  4680. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4681. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4682. if (sd->followtarget == -1)
  4683. return -1;
  4684. pc_stop_following (sd);
  4685. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4686. return 0;
  4687. }
  4688. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4689. {
  4690. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4691. return -1;
  4692. }
  4693. if (sd->followtarget == pl_sd->bl.id) {
  4694. pc_stop_following (sd);
  4695. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4696. } else {
  4697. pc_follow(sd, pl_sd->bl.id);
  4698. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4699. }
  4700. return 0;
  4701. }
  4702. /*==========================================
  4703. * @dropall by [MouseJstr] and [Xantara]
  4704. * Drops all your possession on the ground based on item type
  4705. *------------------------------------------*/
  4706. ACMD_FUNC(dropall)
  4707. {
  4708. int8 type = -1;
  4709. uint16 i, count = 0, count2 = 0;
  4710. struct item_data *item_data = NULL;
  4711. nullpo_retr(-1, sd);
  4712. if( message[0] ) {
  4713. type = atoi(message);
  4714. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4715. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4716. {
  4717. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  4718. 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
  4719. return -1;
  4720. }
  4721. }
  4722. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4723. if( sd->inventory.u.items_inventory[i].amount ) {
  4724. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4725. 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);
  4726. continue;
  4727. }
  4728. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4729. continue;
  4730. if( type == -1 || type == (uint8)item_data->type ) {
  4731. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4732. pc_unequipitem(sd, i, 3);
  4733. if(pc_dropitem(sd, i, sd->inventory.u.items_inventory[i].amount))
  4734. count += sd->inventory.u.items_inventory[i].amount;
  4735. else count2 += sd->inventory.u.items_inventory[i].amount;
  4736. }
  4737. }
  4738. }
  4739. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4740. clif_displaymessage(fd, atcmd_output);
  4741. return 0;
  4742. }
  4743. /*==========================================
  4744. * @storeall by [MouseJstr]
  4745. * Put everything into storage
  4746. *------------------------------------------*/
  4747. ACMD_FUNC(storeall)
  4748. {
  4749. int i;
  4750. nullpo_retr(-1, sd);
  4751. if (sd->state.storage_flag != 1)
  4752. { //Open storage.
  4753. if( storage_storageopen(sd) == 1 ) {
  4754. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4755. return -1;
  4756. }
  4757. }
  4758. for (i = 0; i < MAX_INVENTORY; i++) {
  4759. if (sd->inventory.u.items_inventory[i].amount) {
  4760. if(sd->inventory.u.items_inventory[i].equip != 0)
  4761. pc_unequipitem(sd, i, 3);
  4762. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  4763. }
  4764. }
  4765. storage_storageclose(sd);
  4766. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4767. return 0;
  4768. }
  4769. ACMD_FUNC(clearstorage)
  4770. {
  4771. int i, j;
  4772. nullpo_retr(-1, sd);
  4773. if (sd->state.storage_flag == 1) {
  4774. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4775. return -1;
  4776. }
  4777. if (sd->state.storage_flag == 3) {
  4778. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4779. return -1;
  4780. }
  4781. j = sd->storage.amount;
  4782. for (i = 0; i < j; ++i) {
  4783. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  4784. }
  4785. sd->state.storage_flag = 1;
  4786. storage_storageclose(sd);
  4787. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4788. return 0;
  4789. }
  4790. ACMD_FUNC(cleargstorage)
  4791. {
  4792. int i, j;
  4793. struct guild *g;
  4794. struct s_storage *gstorage;
  4795. nullpo_retr(-1, sd);
  4796. g = sd->guild;
  4797. if (g == NULL) {
  4798. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  4799. return -1;
  4800. }
  4801. if (sd->state.storage_flag == 1) {
  4802. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4803. return -1;
  4804. }
  4805. if (sd->state.storage_flag == 2) {
  4806. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  4807. return -1;
  4808. }
  4809. if (sd->state.storage_flag == 3) {
  4810. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4811. return -1;
  4812. }
  4813. gstorage = guild2storage2(sd->status.guild_id);
  4814. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4815. return -1;
  4816. }
  4817. j = gstorage->amount;
  4818. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4819. for (i = 0; i < j; ++i) {
  4820. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  4821. }
  4822. storage_guild_storageclose(sd);
  4823. gstorage->lock = false; // Cleaning done, release lock
  4824. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4825. return 0;
  4826. }
  4827. ACMD_FUNC(clearcart)
  4828. {
  4829. int i;
  4830. nullpo_retr(-1, sd);
  4831. if (pc_iscarton(sd) == 0) {
  4832. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4833. return -1;
  4834. }
  4835. if (sd->state.vending == 1) { //Somehow...
  4836. return -1;
  4837. }
  4838. for (i = 0; i < MAX_CART; i++) {
  4839. if (sd->cart.u.items_cart[i].nameid > 0)
  4840. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  4841. }
  4842. clif_clearcart(fd);
  4843. clif_updatestatus(sd,SP_CARTINFO);
  4844. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4845. return 0;
  4846. }
  4847. /*==========================================
  4848. * @skillid by [MouseJstr]
  4849. * lookup a skill by name
  4850. *------------------------------------------*/
  4851. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4852. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4853. ACMD_FUNC(skillid) {
  4854. int skillen, i, found = 0;
  4855. DBIterator* iter;
  4856. DBKey key;
  4857. DBData *data;
  4858. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4859. nullpo_retr(-1, sd);
  4860. if (!message || !*message) {
  4861. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4862. return -1;
  4863. }
  4864. skillen = strlen(message);
  4865. iter = db_iterator(skilldb_name2id);
  4866. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4867. int idx = skill_get_index(db_data2i(data));
  4868. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4869. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4870. clif_displaymessage(fd, atcmd_output);
  4871. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4872. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // // skill %d: %s (%s)
  4873. }
  4874. }
  4875. dbi_destroy(iter);
  4876. if( found ) {
  4877. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4878. clif_displaymessage(fd, atcmd_output);
  4879. }
  4880. for(i = 0; i < found; i++) { /* partials */
  4881. clif_displaymessage(fd, partials[i]);
  4882. }
  4883. return 0;
  4884. }
  4885. /*==========================================
  4886. * @useskill by [MouseJstr]
  4887. * A way of using skills without having to find them in the skills menu
  4888. *------------------------------------------*/
  4889. ACMD_FUNC(useskill)
  4890. {
  4891. struct map_session_data *pl_sd = NULL;
  4892. struct block_list *bl;
  4893. uint16 skill_id;
  4894. uint16 skill_lv;
  4895. nullpo_retr(-1, sd);
  4896. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4897. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  4898. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  4899. return -1;
  4900. }
  4901. if(!strcmp(atcmd_player_name,"self"))
  4902. pl_sd = sd; //quick keyword
  4903. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
  4904. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4905. return -1;
  4906. }
  4907. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4908. {
  4909. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4910. return -1;
  4911. }
  4912. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4913. bl = &sd->hd->bl;
  4914. else
  4915. bl = &sd->bl;
  4916. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4917. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4918. else
  4919. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4920. return 0;
  4921. }
  4922. /*==========================================
  4923. * @displayskill by [Skotlex]
  4924. * Debug command to locate new skill IDs. It sends the
  4925. * three possible skill-effect packets to the area.
  4926. *------------------------------------------*/
  4927. ACMD_FUNC(displayskill)
  4928. {
  4929. struct status_data * status;
  4930. unsigned int tick;
  4931. uint16 skill_id;
  4932. uint16 skill_lv = 1;
  4933. nullpo_retr(-1, sd);
  4934. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4935. {
  4936. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4937. return -1;
  4938. }
  4939. status = status_get_status_data(&sd->bl);
  4940. tick = gettick();
  4941. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  4942. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4943. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4944. return 0;
  4945. }
  4946. /*==========================================
  4947. * @skilltree by [MouseJstr]
  4948. * prints the skill tree for a player required to get to a skill
  4949. *------------------------------------------*/
  4950. ACMD_FUNC(skilltree)
  4951. {
  4952. struct map_session_data *pl_sd = NULL;
  4953. uint16 skill_id;
  4954. int meets, i, j, c=0;
  4955. struct skill_tree_entry *ent;
  4956. nullpo_retr(-1, sd);
  4957. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4958. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  4959. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  4960. return -1;
  4961. }
  4962. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4963. {
  4964. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4965. return -1;
  4966. }
  4967. i = pc_calc_skilltree_normalize_job(pl_sd);
  4968. c = pc_mapid2jobid(i, pl_sd->status.sex);
  4969. 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).
  4970. clif_displaymessage(fd, atcmd_output);
  4971. c = pc_class2idx(c);
  4972. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].skill_id == 0 || skill_tree[c][j].skill_id == skill_id );
  4973. if( j == MAX_SKILL_TREE || skill_tree[c][j].skill_id == 0 )
  4974. {
  4975. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4976. return 0;
  4977. }
  4978. ent = &skill_tree[c][j];
  4979. meets = 1;
  4980. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4981. {
  4982. if( ent->need[j].skill_id && pc_checkskill(sd,ent->need[j].skill_id) < ent->need[j].skill_lv)
  4983. {
  4984. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].skill_lv, skill_db[skill_get_index(ent->need[j].skill_id)]->desc); // Player requires level %d of skill %s.
  4985. clif_displaymessage(fd, atcmd_output);
  4986. meets = 0;
  4987. }
  4988. }
  4989. if (meets == 1) {
  4990. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4991. }
  4992. return 0;
  4993. }
  4994. // Hand a ring with partners name on it to this char
  4995. void getring (struct map_session_data* sd)
  4996. {
  4997. char flag = 0;
  4998. unsigned short item_id;
  4999. struct item item_tmp;
  5000. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5001. memset(&item_tmp, 0, sizeof(item_tmp));
  5002. item_tmp.nameid = item_id;
  5003. item_tmp.identify = 1;
  5004. item_tmp.card[0] = 255;
  5005. item_tmp.card[2] = sd->status.partner_id;
  5006. item_tmp.card[3] = sd->status.partner_id >> 16;
  5007. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5008. clif_additem(sd,0,0,flag);
  5009. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  5010. }
  5011. }
  5012. /*==========================================
  5013. * @marry by [MouseJstr], fixed by Lupus
  5014. * Marry two players
  5015. *------------------------------------------*/
  5016. ACMD_FUNC(marry)
  5017. {
  5018. struct map_session_data *pl_sd = NULL;
  5019. nullpo_retr(-1, sd);
  5020. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5021. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5022. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5023. return -1;
  5024. }
  5025. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  5026. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5027. return -1;
  5028. }
  5029. if (pc_marriage(sd, pl_sd)) {
  5030. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5031. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5032. if( pl_sd->bl.m != sd->bl.m )
  5033. clif_wedding_effect(&sd->bl);
  5034. getring(sd); // Auto-give named rings (Aru)
  5035. getring(pl_sd);
  5036. return 0;
  5037. }
  5038. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5039. return -1;
  5040. }
  5041. /*==========================================
  5042. * @divorce by [MouseJstr], fixed by [Lupus]
  5043. * divorce two players
  5044. *------------------------------------------*/
  5045. ACMD_FUNC(divorce)
  5046. {
  5047. nullpo_retr(-1, sd);
  5048. if (!pc_divorce(sd)) {
  5049. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5050. clif_displaymessage(fd, atcmd_output);
  5051. return -1;
  5052. }
  5053. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5054. clif_displaymessage(fd, atcmd_output);
  5055. return 0;
  5056. }
  5057. /*==========================================
  5058. * @changelook by [Celest]
  5059. *------------------------------------------*/
  5060. ACMD_FUNC(changelook)
  5061. {
  5062. int i, j = 0, k = 0;
  5063. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5064. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5065. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5066. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5067. return -1;
  5068. } else if ( i == 2 ) {
  5069. if (j < 1 || j > 8)
  5070. j = 1;
  5071. j = pos[j - 1];
  5072. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5073. k = j; // swap
  5074. j = LOOK_HEAD_TOP;
  5075. }
  5076. clif_changelook(&sd->bl,j,k);
  5077. return 0;
  5078. }
  5079. /*==========================================
  5080. * @autotrade by durf [Lupus] [Paradox924X]
  5081. * Turns on/off Autotrade for a specific player
  5082. *------------------------------------------*/
  5083. ACMD_FUNC(autotrade) {
  5084. nullpo_retr(-1, sd);
  5085. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5086. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5087. return -1;
  5088. }
  5089. if( pc_isdead(sd) ) {
  5090. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5091. return -1;
  5092. }
  5093. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5094. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5095. return -1;
  5096. }
  5097. sd->state.autotrade = 1;
  5098. if (battle_config.autotrade_monsterignore)
  5099. sd->state.monster_ignore = 1;
  5100. if( sd->state.vending ){
  5101. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
  5102. Sql_ShowDebug( mmysql_handle );
  5103. }
  5104. }else if( sd->state.buyingstore ){
  5105. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
  5106. Sql_ShowDebug( mmysql_handle );
  5107. }
  5108. }
  5109. if( battle_config.at_timeout ) {
  5110. int timeout = atoi(message);
  5111. 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);
  5112. }
  5113. channel_pcquit(sd,0xF); //leave all chan
  5114. clif_authfail_fd(sd->fd, 15);
  5115. chrif_save(sd, CSAVE_AUTOTRADE);
  5116. return 0;
  5117. }
  5118. /*==========================================
  5119. * @changegm by durf (changed by Lupus)
  5120. * Changes Master of your Guild to a specified guild member
  5121. *------------------------------------------*/
  5122. ACMD_FUNC(changegm)
  5123. {
  5124. struct guild *g;
  5125. struct map_session_data *pl_sd;
  5126. nullpo_retr(-1, sd);
  5127. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5128. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5129. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5130. return -1;
  5131. }
  5132. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  5133. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5134. return -1;
  5135. }
  5136. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5137. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5138. return -1;
  5139. }
  5140. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5141. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5142. return -1;
  5143. }
  5144. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5145. return 0;
  5146. }
  5147. /*==========================================
  5148. * @changeleader by Skotlex
  5149. * Changes the leader of a party.
  5150. *------------------------------------------*/
  5151. ACMD_FUNC(changeleader)
  5152. {
  5153. nullpo_retr(-1, sd);
  5154. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5155. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5156. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5157. return -1;
  5158. }
  5159. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
  5160. return 0;
  5161. }
  5162. /*==========================================
  5163. * @partyoption by Skotlex
  5164. * Used to change the item share setting of a party.
  5165. *------------------------------------------*/
  5166. ACMD_FUNC(partyoption)
  5167. {
  5168. struct party_data *p;
  5169. int mi, option;
  5170. char w1[16], w2[16];
  5171. nullpo_retr(-1, sd);
  5172. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5173. {
  5174. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5175. return -1;
  5176. }
  5177. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5178. if (mi == MAX_PARTY)
  5179. return -1; //Shouldn't happen
  5180. if (!p->party.member[mi].leader)
  5181. {
  5182. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5183. return -1;
  5184. }
  5185. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5186. {
  5187. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5188. return -1;
  5189. }
  5190. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5191. //Change item share type.
  5192. if (option != p->party.item)
  5193. party_changeoption(sd, p->party.exp, option);
  5194. else
  5195. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5196. return 0;
  5197. }
  5198. /*==========================================
  5199. * @autoloot by Upa-Kun
  5200. * Turns on/off AutoLoot for a specific player
  5201. *------------------------------------------*/
  5202. ACMD_FUNC(autoloot)
  5203. {
  5204. int rate;
  5205. nullpo_retr(-1, sd);
  5206. // autoloot command without value
  5207. if(!message || !*message)
  5208. {
  5209. if (sd->state.autoloot)
  5210. rate = 0;
  5211. else
  5212. rate = 10000;
  5213. } else {
  5214. double drate;
  5215. drate = atof(message);
  5216. rate = (int)(drate*100);
  5217. }
  5218. if (rate < 0) rate = 0;
  5219. if (rate > 10000) rate = 10000;
  5220. sd->state.autoloot = rate;
  5221. if (sd->state.autoloot) {
  5222. 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.
  5223. clif_displaymessage(fd, atcmd_output);
  5224. }else
  5225. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5226. return 0;
  5227. }
  5228. /*==========================================
  5229. * @alootid
  5230. *------------------------------------------*/
  5231. ACMD_FUNC(autolootitem)
  5232. {
  5233. struct item_data *item_data = NULL;
  5234. int i;
  5235. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5236. nullpo_retr(-1, sd);
  5237. if (message && *message) {
  5238. if (message[0] == '+') {
  5239. message++;
  5240. action = 1;
  5241. }
  5242. else if (message[0] == '-') {
  5243. message++;
  5244. action = 2;
  5245. }
  5246. else if (!strcmp(message,"reset"))
  5247. action = 4;
  5248. }
  5249. if (action < 3) // add or remove
  5250. {
  5251. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5252. item_data = itemdb_searchname(message);
  5253. if (!item_data) {
  5254. // No items founds in the DB with Id or Name
  5255. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5256. return -1;
  5257. }
  5258. }
  5259. switch(action) {
  5260. case 1:
  5261. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5262. if (i != AUTOLOOTITEM_SIZE) {
  5263. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5264. return -1;
  5265. }
  5266. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5267. if (i == AUTOLOOTITEM_SIZE) {
  5268. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5269. return -1;
  5270. }
  5271. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5272. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5273. clif_displaymessage(fd, atcmd_output);
  5274. sd->state.autolooting = 1;
  5275. break;
  5276. case 2:
  5277. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5278. if (i == AUTOLOOTITEM_SIZE) {
  5279. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5280. return -1;
  5281. }
  5282. sd->state.autolootid[i] = 0;
  5283. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5284. clif_displaymessage(fd, atcmd_output);
  5285. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5286. if (i == AUTOLOOTITEM_SIZE) {
  5287. sd->state.autolooting = 0;
  5288. }
  5289. break;
  5290. case 3:
  5291. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5292. clif_displaymessage(fd, atcmd_output);
  5293. 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>".
  5294. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5295. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5296. if (i == AUTOLOOTITEM_SIZE) {
  5297. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5298. } else {
  5299. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5300. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5301. {
  5302. if (sd->state.autolootid[i] == 0)
  5303. continue;
  5304. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5305. 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);
  5306. continue;
  5307. }
  5308. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5309. clif_displaymessage(fd, atcmd_output);
  5310. }
  5311. }
  5312. break;
  5313. case 4:
  5314. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5315. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5316. sd->state.autolooting = 0;
  5317. break;
  5318. }
  5319. return 0;
  5320. }
  5321. /*==========================================
  5322. * @autoloottype
  5323. * Flags:
  5324. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5325. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5326. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5327. * 262144: IT_CASH
  5328. *------------------------------------------
  5329. * Credits:
  5330. * chriser
  5331. * Aleos
  5332. *------------------------------------------*/
  5333. ACMD_FUNC(autoloottype)
  5334. {
  5335. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5336. enum item_types type= IT_UNKNOWN;
  5337. int ITEM_MAX = 1533;
  5338. nullpo_retr(-1, sd);
  5339. if (message && *message) {
  5340. if (message[0] == '+') {
  5341. message++;
  5342. action = 1;
  5343. }
  5344. else if (message[0] == '-') {
  5345. message++;
  5346. action = 2;
  5347. }
  5348. else if (!strcmp(message,"reset"))
  5349. action = 4;
  5350. }
  5351. if (action < 3) { // add or remove
  5352. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5353. type = IT_HEALING;
  5354. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5355. type = IT_USABLE;
  5356. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5357. type = IT_ETC;
  5358. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5359. type = IT_ARMOR;
  5360. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5361. type = IT_WEAPON;
  5362. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5363. type = IT_CARD;
  5364. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5365. type = IT_PETEGG;
  5366. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5367. type = IT_PETARMOR;
  5368. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5369. type = IT_AMMO;
  5370. else {
  5371. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5372. return -1;
  5373. }
  5374. }
  5375. switch (action) {
  5376. case 1:
  5377. if (sd->state.autoloottype&(1<<type)) {
  5378. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5379. return -1;
  5380. }
  5381. if (sd->state.autoloottype == ITEM_MAX) {
  5382. 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>.
  5383. return -1;
  5384. }
  5385. sd->state.autoloottype |= (1<<type); // Stores the type
  5386. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5387. clif_displaymessage(fd, atcmd_output);
  5388. break;
  5389. case 2:
  5390. if (!(sd->state.autoloottype&(1<<type))) {
  5391. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5392. return -1;
  5393. }
  5394. sd->state.autoloottype &= ~(1<<type);
  5395. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5396. clif_displaymessage(fd, atcmd_output);
  5397. break;
  5398. case 3:
  5399. 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>".
  5400. 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
  5401. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5402. if (sd->state.autoloottype == 0)
  5403. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5404. else {
  5405. uint8 i = 0;
  5406. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5407. while (i < IT_MAX) {
  5408. if (sd->state.autoloottype&(1<<i)) {
  5409. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5410. clif_displaymessage(fd, atcmd_output);
  5411. }
  5412. i++;
  5413. }
  5414. }
  5415. break;
  5416. case 4:
  5417. sd->state.autoloottype = 0;
  5418. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5419. break;
  5420. }
  5421. return 0;
  5422. }
  5423. /**
  5424. * No longer available, keeping here just in case it's back someday. [Ind]
  5425. **/
  5426. /*==========================================
  5427. * It is made to rain.
  5428. *------------------------------------------*/
  5429. //ACMD_FUNC(rain)
  5430. //{
  5431. // nullpo_retr(-1, sd);
  5432. // if (map[sd->bl.m].flag.rain) {
  5433. // map[sd->bl.m].flag.rain=0;
  5434. // clif_weather(sd->bl.m);
  5435. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5436. // } else {
  5437. // map[sd->bl.m].flag.rain=1;
  5438. // clif_weather(sd->bl.m);
  5439. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5440. // }
  5441. // return 0;
  5442. //}
  5443. /*==========================================
  5444. * It is made to snow.
  5445. *------------------------------------------*/
  5446. ACMD_FUNC(snow)
  5447. {
  5448. nullpo_retr(-1, sd);
  5449. if (map[sd->bl.m].flag.snow) {
  5450. map[sd->bl.m].flag.snow=0;
  5451. clif_weather(sd->bl.m);
  5452. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5453. } else {
  5454. map[sd->bl.m].flag.snow=1;
  5455. clif_weather(sd->bl.m);
  5456. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5457. }
  5458. return 0;
  5459. }
  5460. /*==========================================
  5461. * Cherry tree snowstorm is made to fall. (Sakura)
  5462. *------------------------------------------*/
  5463. ACMD_FUNC(sakura)
  5464. {
  5465. nullpo_retr(-1, sd);
  5466. if (map[sd->bl.m].flag.sakura) {
  5467. map[sd->bl.m].flag.sakura=0;
  5468. clif_weather(sd->bl.m);
  5469. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5470. } else {
  5471. map[sd->bl.m].flag.sakura=1;
  5472. clif_weather(sd->bl.m);
  5473. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5474. }
  5475. return 0;
  5476. }
  5477. /*==========================================
  5478. * Clouds appear.
  5479. *------------------------------------------*/
  5480. ACMD_FUNC(clouds)
  5481. {
  5482. nullpo_retr(-1, sd);
  5483. if (map[sd->bl.m].flag.clouds) {
  5484. map[sd->bl.m].flag.clouds=0;
  5485. clif_weather(sd->bl.m);
  5486. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5487. } else {
  5488. map[sd->bl.m].flag.clouds=1;
  5489. clif_weather(sd->bl.m);
  5490. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5491. }
  5492. return 0;
  5493. }
  5494. /*==========================================
  5495. * Different type of clouds using effect 516
  5496. *------------------------------------------*/
  5497. ACMD_FUNC(clouds2)
  5498. {
  5499. nullpo_retr(-1, sd);
  5500. if (map[sd->bl.m].flag.clouds2) {
  5501. map[sd->bl.m].flag.clouds2=0;
  5502. clif_weather(sd->bl.m);
  5503. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5504. } else {
  5505. map[sd->bl.m].flag.clouds2=1;
  5506. clif_weather(sd->bl.m);
  5507. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5508. }
  5509. return 0;
  5510. }
  5511. /*==========================================
  5512. * Fog hangs over.
  5513. *------------------------------------------*/
  5514. ACMD_FUNC(fog)
  5515. {
  5516. nullpo_retr(-1, sd);
  5517. if (map[sd->bl.m].flag.fog) {
  5518. map[sd->bl.m].flag.fog=0;
  5519. clif_weather(sd->bl.m);
  5520. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5521. } else {
  5522. map[sd->bl.m].flag.fog=1;
  5523. clif_weather(sd->bl.m);
  5524. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5525. }
  5526. return 0;
  5527. }
  5528. /*==========================================
  5529. * Fallen leaves fall.
  5530. *------------------------------------------*/
  5531. ACMD_FUNC(leaves)
  5532. {
  5533. nullpo_retr(-1, sd);
  5534. if (map[sd->bl.m].flag.leaves) {
  5535. map[sd->bl.m].flag.leaves=0;
  5536. clif_weather(sd->bl.m);
  5537. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5538. } else {
  5539. map[sd->bl.m].flag.leaves=1;
  5540. clif_weather(sd->bl.m);
  5541. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5542. }
  5543. return 0;
  5544. }
  5545. /*==========================================
  5546. * Fireworks appear.
  5547. *------------------------------------------*/
  5548. ACMD_FUNC(fireworks)
  5549. {
  5550. nullpo_retr(-1, sd);
  5551. if (map[sd->bl.m].flag.fireworks) {
  5552. map[sd->bl.m].flag.fireworks=0;
  5553. clif_weather(sd->bl.m);
  5554. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5555. } else {
  5556. map[sd->bl.m].flag.fireworks=1;
  5557. clif_weather(sd->bl.m);
  5558. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5559. }
  5560. return 0;
  5561. }
  5562. /*==========================================
  5563. * Clearing Weather Effects by Dexity
  5564. *------------------------------------------*/
  5565. ACMD_FUNC(clearweather)
  5566. {
  5567. nullpo_retr(-1, sd);
  5568. /**
  5569. * No longer available, keeping here just in case it's back someday. [Ind]
  5570. **/
  5571. //map[sd->bl.m].flag.rain=0;
  5572. map[sd->bl.m].flag.snow=0;
  5573. map[sd->bl.m].flag.sakura=0;
  5574. map[sd->bl.m].flag.clouds=0;
  5575. map[sd->bl.m].flag.clouds2=0;
  5576. map[sd->bl.m].flag.fog=0;
  5577. map[sd->bl.m].flag.fireworks=0;
  5578. map[sd->bl.m].flag.leaves=0;
  5579. clif_weather(sd->bl.m);
  5580. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  5581. return 0;
  5582. }
  5583. /*===============================================================
  5584. * Sound Command - plays a sound for everyone around! [Codemaster]
  5585. *---------------------------------------------------------------*/
  5586. ACMD_FUNC(sound)
  5587. {
  5588. char sound_file[100];
  5589. memset(sound_file, '\0', sizeof(sound_file));
  5590. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5591. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5592. return -1;
  5593. }
  5594. if(strstr(sound_file, ".wav") == NULL)
  5595. strcat(sound_file, ".wav");
  5596. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5597. return 0;
  5598. }
  5599. /*==========================================
  5600. * MOB Search
  5601. *------------------------------------------*/
  5602. ACMD_FUNC(mobsearch)
  5603. {
  5604. char mob_name[100];
  5605. int mob_id;
  5606. int number = 0;
  5607. struct s_mapiterator* it;
  5608. nullpo_retr(-1, sd);
  5609. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5610. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5611. return -1;
  5612. }
  5613. if ((mob_id = atoi(mob_name)) == 0)
  5614. mob_id = mobdb_searchname(mob_name);
  5615. if( mobdb_checkid(mob_id) == 0){
  5616. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5617. clif_displaymessage(fd, atcmd_output);
  5618. return -1;
  5619. }
  5620. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5621. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5622. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5623. clif_displaymessage(fd, atcmd_output);
  5624. it = mapit_geteachmob();
  5625. for(;;)
  5626. {
  5627. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5628. if( md == NULL )
  5629. break;// no more mobs
  5630. if( md->bl.m != sd->bl.m )
  5631. continue;
  5632. if( md->mob_id != mob_id )
  5633. continue;
  5634. ++number;
  5635. if( md->spawn_timer == INVALID_TIMER )
  5636. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5637. else
  5638. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5639. clif_displaymessage(fd, atcmd_output);
  5640. }
  5641. mapit_free(it);
  5642. return 0;
  5643. }
  5644. /*==========================================
  5645. * @cleanmap - cleans items on the ground
  5646. * @cleanarea - cleans items on the ground within an specified area
  5647. *------------------------------------------*/
  5648. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5649. {
  5650. nullpo_ret(bl);
  5651. map_clearflooritem(bl);
  5652. return 0;
  5653. }
  5654. ACMD_FUNC(cleanmap)
  5655. {
  5656. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5657. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5658. return 0;
  5659. }
  5660. ACMD_FUNC(cleanarea)
  5661. {
  5662. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5663. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5664. 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);
  5665. }
  5666. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5667. 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);
  5668. }
  5669. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5670. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5671. }
  5672. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5673. return 0;
  5674. }
  5675. /*==========================================
  5676. * make a NPC/PET talk
  5677. * @npctalkc [SnakeDrak]
  5678. *------------------------------------------*/
  5679. ACMD_FUNC(npctalk)
  5680. {
  5681. char name[NPC_NAME_LENGTH],mes[100],temp[100];
  5682. struct npc_data *nd;
  5683. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5684. unsigned long color=0;
  5685. if (sd->sc.cant.chat)
  5686. return -1; //no "chatting" while muted.
  5687. if(!ifcolor) {
  5688. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  5689. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5690. return -1;
  5691. }
  5692. }
  5693. else {
  5694. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5695. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5696. return -1;
  5697. }
  5698. }
  5699. if (!(nd = npc_name2id(name))) {
  5700. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5701. return -1;
  5702. }
  5703. strtok(name, "#"); // discard extra name identifier if present
  5704. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5705. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  5706. else clif_disp_overhead(&nd->bl, temp);
  5707. return 0;
  5708. }
  5709. ACMD_FUNC(pettalk)
  5710. {
  5711. char mes[100],temp[100];
  5712. struct pet_data *pd;
  5713. nullpo_retr(-1, sd);
  5714. if ( battle_config.min_chat_delay ) {
  5715. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5716. return 0;
  5717. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5718. }
  5719. if(!sd->status.pet_id || !(pd=sd->pd))
  5720. {
  5721. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  5722. return -1;
  5723. }
  5724. if (sd->sc.cant.chat)
  5725. return -1; //no "chatting" while muted.
  5726. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5727. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5728. return -1;
  5729. }
  5730. if (message[0] == '/')
  5731. {// pet emotion processing
  5732. const char* emo[] = {
  5733. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5734. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5735. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5736. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5737. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5738. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5739. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5740. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5741. "/whisp"
  5742. };
  5743. int i;
  5744. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5745. if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
  5746. if( i < ARRAYLENGTH(emo) )
  5747. {
  5748. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5749. sd->emotionlasttime = time(NULL);
  5750. return 0;
  5751. }
  5752. sd->emotionlasttime = time(NULL);
  5753. clif_emotion(&pd->bl, i);
  5754. return 0;
  5755. }
  5756. }
  5757. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5758. clif_disp_overhead(&pd->bl, temp);
  5759. return 0;
  5760. }
  5761. /// @users - displays the number of players present on each map (and percentage)
  5762. /// #users displays on the target user instead of self
  5763. ACMD_FUNC(users)
  5764. {
  5765. char buf[CHAT_SIZE_MAX];
  5766. int i;
  5767. int users[MAX_MAPINDEX];
  5768. int users_all;
  5769. struct s_mapiterator* iter;
  5770. memset(users, 0, sizeof(users));
  5771. users_all = 0;
  5772. // count users on each map
  5773. iter = mapit_getallusers();
  5774. for(;;)
  5775. {
  5776. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5777. if( sd2 == NULL )
  5778. break;// no more users
  5779. if( sd2->mapindex >= MAX_MAPINDEX )
  5780. continue;// invalid mapindex
  5781. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5782. if( users_all < INT_MAX ) ++users_all;
  5783. }
  5784. mapit_free(iter);
  5785. // display results for each map
  5786. for( i = 0; i < MAX_MAPINDEX; ++i )
  5787. {
  5788. if( users[i] == 0 )
  5789. continue;// empty
  5790. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5791. clif_displaymessage(sd->fd, buf);
  5792. }
  5793. // display overall count
  5794. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5795. clif_displaymessage(sd->fd, buf);
  5796. return 0;
  5797. }
  5798. /*==========================================
  5799. *
  5800. *------------------------------------------*/
  5801. ACMD_FUNC(reset)
  5802. {
  5803. pc_resetstate(sd);
  5804. pc_resetskill(sd,1);
  5805. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5806. clif_displaymessage(fd, atcmd_output);
  5807. return 0;
  5808. }
  5809. /*==========================================
  5810. *
  5811. *------------------------------------------*/
  5812. ACMD_FUNC(summon)
  5813. {
  5814. char name[NAME_LENGTH];
  5815. int mob_id = 0;
  5816. int duration = 0;
  5817. struct mob_data *md;
  5818. unsigned int tick=gettick();
  5819. nullpo_retr(-1, sd);
  5820. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5821. {
  5822. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5823. return -1;
  5824. }
  5825. if (duration < 1)
  5826. duration =1;
  5827. else if (duration > 60)
  5828. duration =60;
  5829. if ((mob_id = atoi(name)) == 0)
  5830. mob_id = mobdb_searchname(name);
  5831. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5832. {
  5833. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5834. return -1;
  5835. }
  5836. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5837. if(!md)
  5838. return -1;
  5839. md->master_id=sd->bl.id;
  5840. md->special_state.ai=AI_ATTACK;
  5841. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5842. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  5843. mob_spawn(md);
  5844. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5845. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5846. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5847. return 0;
  5848. }
  5849. /*==========================================
  5850. * @adjgroup
  5851. * Temporarily move player to another group
  5852. * Useful during beta testing to allow players to use GM commands for short periods of time
  5853. *------------------------------------------*/
  5854. ACMD_FUNC(adjgroup)
  5855. {
  5856. int new_group = 0;
  5857. nullpo_retr(-1, sd);
  5858. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5859. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5860. return -1;
  5861. }
  5862. if (!pc_group_exists(new_group)) {
  5863. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5864. return -1;
  5865. }
  5866. sd->group_id = new_group;
  5867. pc_group_pc_load(sd);/* update cache */
  5868. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5869. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5870. return 0;
  5871. }
  5872. /*==========================================
  5873. * @trade by [MouseJstr]
  5874. * Open a trade window with a remote player
  5875. *------------------------------------------*/
  5876. ACMD_FUNC(trade)
  5877. {
  5878. struct map_session_data *pl_sd = NULL;
  5879. nullpo_retr(-1, sd);
  5880. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5881. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5882. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5883. return -1;
  5884. }
  5885. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5886. {
  5887. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5888. return -1;
  5889. }
  5890. trade_traderequest(sd, pl_sd);
  5891. return 0;
  5892. }
  5893. /*==========================================
  5894. * @setbattleflag by [MouseJstr]
  5895. * set a battle_config flag without having to reboot
  5896. *------------------------------------------*/
  5897. ACMD_FUNC(setbattleflag)
  5898. {
  5899. char flag[128], value[128];
  5900. int reload = 0;
  5901. nullpo_retr(-1, sd);
  5902. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
  5903. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  5904. return -1;
  5905. }
  5906. if (battle_set_value(flag, value) == 0)
  5907. {
  5908. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5909. return -1;
  5910. }
  5911. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5912. if (reload)
  5913. mob_reload();
  5914. return 0;
  5915. }
  5916. /*==========================================
  5917. * @unmute [Valaris]
  5918. *------------------------------------------*/
  5919. ACMD_FUNC(unmute)
  5920. {
  5921. struct map_session_data *pl_sd = NULL;
  5922. nullpo_retr(-1, sd);
  5923. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5924. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5925. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5926. return -1;
  5927. }
  5928. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  5929. {
  5930. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5931. return -1;
  5932. }
  5933. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5934. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5935. return -1;
  5936. }
  5937. pl_sd->status.manner = 0;
  5938. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5939. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5940. return 0;
  5941. }
  5942. /*==========================================
  5943. * @uptime by MC Cameri
  5944. *------------------------------------------*/
  5945. ACMD_FUNC(uptime)
  5946. {
  5947. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5948. minute = 60, days = 0, hours = 0, minutes = 0;
  5949. nullpo_retr(-1, sd);
  5950. seconds = get_uptime();
  5951. days = seconds/day;
  5952. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5953. hours = seconds/hour;
  5954. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5955. minutes = seconds/minute;
  5956. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5957. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  5958. clif_displaymessage(fd, atcmd_output);
  5959. return 0;
  5960. }
  5961. /*==========================================
  5962. * @changesex
  5963. * => Changes one's account sex. Switch from male to female or visversa
  5964. *------------------------------------------*/
  5965. ACMD_FUNC(changesex)
  5966. {
  5967. int i;
  5968. nullpo_retr(-1, sd);
  5969. pc_resetskill(sd,4);
  5970. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5971. for (i = 0; i < EQI_MAX; i++) {
  5972. if (sd->equip_index[i] >= 0)
  5973. pc_unequipitem(sd, sd->equip_index[i], 3);
  5974. }
  5975. chrif_changesex(sd, true);
  5976. return 0;
  5977. }
  5978. /*==========================================
  5979. * @changecharsex
  5980. * => Changes one's character sex. Switch from male to female or visversa.
  5981. *------------------------------------------*/
  5982. ACMD_FUNC(changecharsex)
  5983. {
  5984. int i;
  5985. nullpo_retr(-1, sd);
  5986. pc_resetskill(sd,4);
  5987. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5988. for (i = 0; i < EQI_MAX; i++) {
  5989. if (sd->equip_index[i] >= 0)
  5990. pc_unequipitem(sd, sd->equip_index[i], 3);
  5991. }
  5992. chrif_changesex(sd, false);
  5993. return 0;
  5994. }
  5995. /*================================================
  5996. * @mute - Mutes a player for a set amount of time
  5997. *------------------------------------------------*/
  5998. ACMD_FUNC(mute)
  5999. {
  6000. struct map_session_data *pl_sd = NULL;
  6001. int manner;
  6002. nullpo_retr(-1, sd);
  6003. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6004. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6005. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6006. return -1;
  6007. }
  6008. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6009. {
  6010. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6011. return -1;
  6012. }
  6013. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6014. {
  6015. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6016. return -1;
  6017. }
  6018. clif_manner_message(sd, 0);
  6019. clif_manner_message(pl_sd, 5);
  6020. if( pl_sd->status.manner < manner ) {
  6021. pl_sd->status.manner -= manner;
  6022. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6023. } else {
  6024. pl_sd->status.manner = 0;
  6025. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6026. }
  6027. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6028. return 0;
  6029. }
  6030. /*==========================================
  6031. * @refresh (like @jumpto <<yourself>>)
  6032. *------------------------------------------*/
  6033. ACMD_FUNC(refresh)
  6034. {
  6035. nullpo_retr(-1, sd);
  6036. clif_refresh(sd);
  6037. return 0;
  6038. }
  6039. ACMD_FUNC(refreshall)
  6040. {
  6041. struct map_session_data* iter_sd;
  6042. struct s_mapiterator* iter;
  6043. nullpo_retr(-1, sd);
  6044. iter = mapit_getallusers();
  6045. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6046. clif_refresh(iter_sd);
  6047. mapit_free(iter);
  6048. return 0;
  6049. }
  6050. /*==========================================
  6051. * @identify
  6052. * => GM's magnifier.
  6053. *------------------------------------------*/
  6054. ACMD_FUNC(identify)
  6055. {
  6056. int i,num;
  6057. nullpo_retr(-1, sd);
  6058. for(i=num=0;i<MAX_INVENTORY;i++){
  6059. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6060. num++;
  6061. }
  6062. }
  6063. if (num > 0) {
  6064. clif_item_identify_list(sd);
  6065. } else {
  6066. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6067. }
  6068. return 0;
  6069. }
  6070. /*===============================================
  6071. * @identifyall
  6072. * => Indentify all items in inventory - Akinari
  6073. *-----------------------------------------------*/
  6074. ACMD_FUNC(identifyall)
  6075. {
  6076. int i;
  6077. nullpo_retr(-1, sd);
  6078. for(i=0; i<MAX_INVENTORY; i++) {
  6079. if (sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6080. sd->inventory.u.items_inventory[i].identify = 1;
  6081. clif_item_identified(sd,i,0);
  6082. }
  6083. }
  6084. return 0;
  6085. }
  6086. /*==========================================
  6087. * @gmotd (Global MOTD)
  6088. * by davidsiaw :P
  6089. *------------------------------------------*/
  6090. ACMD_FUNC(gmotd)
  6091. {
  6092. FILE* fp;
  6093. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6094. {
  6095. char buf[CHAT_SIZE_MAX];
  6096. size_t len;
  6097. while( fgets(buf, sizeof(buf), fp) )
  6098. {
  6099. if( buf[0] == '/' && buf[1] == '/' )
  6100. {
  6101. continue;
  6102. }
  6103. len = strlen(buf);
  6104. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6105. {// strip trailing EOL characters
  6106. len--;
  6107. }
  6108. if( len )
  6109. {
  6110. buf[len] = 0;
  6111. intif_broadcast(buf, len+1, 0);
  6112. }
  6113. }
  6114. fclose(fp);
  6115. }
  6116. return 0;
  6117. }
  6118. ACMD_FUNC(misceffect)
  6119. {
  6120. int effect = 0;
  6121. nullpo_retr(-1, sd);
  6122. if (!message || !*message)
  6123. return -1;
  6124. if (sscanf(message, "%11d", &effect) < 1)
  6125. return -1;
  6126. clif_misceffect(&sd->bl,effect);
  6127. return 0;
  6128. }
  6129. /*==========================================
  6130. * MAIL SYSTEM
  6131. *------------------------------------------*/
  6132. ACMD_FUNC(mail)
  6133. {
  6134. nullpo_ret(sd);
  6135. mail_openmail(sd);
  6136. return 0;
  6137. }
  6138. /*==========================================
  6139. * Show Monster DB Info v 1.0
  6140. * originally by [Lupus]
  6141. *------------------------------------------*/
  6142. ACMD_FUNC(mobinfo)
  6143. {
  6144. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6145. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6146. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6147. char atcmd_output2[CHAT_SIZE_MAX];
  6148. struct item_data *item_data;
  6149. struct mob_db *mob;
  6150. uint16 mob_ids[MAX_SEARCH];
  6151. int count;
  6152. int i, k;
  6153. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6154. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6155. if (!message || !*message) {
  6156. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6157. return -1;
  6158. }
  6159. // If monster identifier/name argument is a name
  6160. if ((i = mobdb_checkid(atoi(message))))
  6161. {
  6162. mob_ids[0] = i;
  6163. count = 1;
  6164. } else
  6165. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6166. if (!count) {
  6167. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6168. return -1;
  6169. }
  6170. if (count >= MAX_SEARCH) {
  6171. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6172. clif_displaymessage(fd, atcmd_output);
  6173. count = MAX_SEARCH;
  6174. }
  6175. for (k = 0; k < count; k++) {
  6176. unsigned int j,base_exp,job_exp;
  6177. mob = mob_db(mob_ids[k]);
  6178. base_exp = mob->base_exp;
  6179. job_exp = mob->job_exp;
  6180. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6181. base_exp = (base_exp * battle_config.vip_base_exp_increase) / 100;
  6182. job_exp = (job_exp * battle_config.vip_job_exp_increase) / 100;
  6183. }
  6184. #ifdef RENEWAL_EXP
  6185. if( battle_config.atcommand_mobinfo_type ) {
  6186. base_exp = base_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6187. job_exp = job_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6188. }
  6189. #endif
  6190. // stats
  6191. if (mob->mexp)
  6192. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6193. else
  6194. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6195. clif_displaymessage(fd, atcmd_output);
  6196. 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:%u Job EXP:%u HIT:%d FLEE:%d
  6197. clif_displaymessage(fd, atcmd_output);
  6198. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6199. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6200. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6201. clif_displaymessage(fd, atcmd_output);
  6202. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6203. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6204. mob->range2 , mob->range3, msize[mob->status.size],
  6205. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6206. clif_displaymessage(fd, atcmd_output);
  6207. // drops
  6208. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6209. strcpy(atcmd_output, " ");
  6210. j = 0;
  6211. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6212. int droprate;
  6213. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6214. continue;
  6215. droprate = mob->dropitem[i].p;
  6216. #ifdef RENEWAL_DROP
  6217. if( battle_config.atcommand_mobinfo_type ) {
  6218. droprate = droprate * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 2) / 100;
  6219. if (droprate <= 0 && !battle_config.drop_rate0item)
  6220. droprate = 1;
  6221. }
  6222. #endif
  6223. if (pc_isvip(sd)) // Display drop rate increase for VIP
  6224. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6225. if (item_data->slot)
  6226. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6227. else
  6228. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6229. strcat(atcmd_output, atcmd_output2);
  6230. if (++j % 3 == 0) {
  6231. clif_displaymessage(fd, atcmd_output);
  6232. strcpy(atcmd_output, " ");
  6233. }
  6234. }
  6235. if (j == 0)
  6236. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6237. else if (j % 3 != 0)
  6238. clif_displaymessage(fd, atcmd_output);
  6239. // mvp
  6240. if (mob->mexp) {
  6241. float mvppercent, mvpremain;
  6242. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6243. clif_displaymessage(fd, atcmd_output);
  6244. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6245. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6246. j = 0;
  6247. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6248. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6249. continue;
  6250. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6251. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6252. if(battle_config.item_drop_mvp_mode == 0) {
  6253. mvpremain -= mvppercent;
  6254. }
  6255. if (mvppercent > 0) {
  6256. j++;
  6257. if (j == 1) {
  6258. if (item_data->slot)
  6259. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6260. else
  6261. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6262. } else {
  6263. if (item_data->slot)
  6264. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6265. else
  6266. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6267. }
  6268. strcat(atcmd_output, atcmd_output2);
  6269. }
  6270. }
  6271. if (j == 0)
  6272. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6273. else
  6274. clif_displaymessage(fd, atcmd_output);
  6275. }
  6276. }
  6277. return 0;
  6278. }
  6279. /*=========================================
  6280. * @showmobs by KarLaeda
  6281. * => For 15 sec displays the mobs on minimap
  6282. *------------------------------------------*/
  6283. ACMD_FUNC(showmobs)
  6284. {
  6285. char mob_name[100];
  6286. int mob_id;
  6287. int number = 0;
  6288. struct s_mapiterator* it;
  6289. nullpo_retr(-1, sd);
  6290. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6291. return -1;
  6292. if((mob_id = atoi(mob_name)) == 0)
  6293. mob_id = mobdb_searchname(mob_name);
  6294. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6295. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6296. clif_displaymessage(fd, atcmd_output);
  6297. return 0;
  6298. }
  6299. if(status_has_mode(&mob_db(mob_id)->status,MD_STATUS_IMMUNE) && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6300. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6301. return 0;
  6302. }
  6303. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6304. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6305. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6306. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6307. mob_name, mapindex_id2name(sd->mapindex));
  6308. clif_displaymessage(fd, atcmd_output);
  6309. it = mapit_geteachmob();
  6310. for(;;)
  6311. {
  6312. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6313. if( md == NULL )
  6314. break;// no more mobs
  6315. if( md->bl.m != sd->bl.m )
  6316. continue;
  6317. if( mob_id != -1 && md->mob_id != mob_id )
  6318. continue;
  6319. if( md->special_state.ai || md->master_id )
  6320. continue; // hide slaves and player summoned mobs
  6321. if( md->spawn_timer != INVALID_TIMER )
  6322. continue; // hide mobs waiting for respawn
  6323. ++number;
  6324. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6325. }
  6326. mapit_free(it);
  6327. return 0;
  6328. }
  6329. /*==========================================
  6330. * homunculus level up [orn]
  6331. *------------------------------------------*/
  6332. ACMD_FUNC(homlevel)
  6333. {
  6334. TBL_HOM * hd;
  6335. int level = 0, i = 0;
  6336. nullpo_retr(-1, sd);
  6337. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6338. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6339. return -1;
  6340. }
  6341. if ( !hom_is_active(sd->hd) ) {
  6342. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6343. return -1;
  6344. }
  6345. hd = sd->hd;
  6346. for (i = 1; i <= level && hd->exp_next; i++){
  6347. hd->homunculus.exp += hd->exp_next;
  6348. if( !hom_levelup(hd) )
  6349. break;
  6350. }
  6351. status_calc_homunculus(hd, SCO_NONE);
  6352. status_percent_heal(&hd->bl, 100, 100);
  6353. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6354. return 0;
  6355. }
  6356. /*==========================================
  6357. * homunculus evolution H [orn]
  6358. *------------------------------------------*/
  6359. ACMD_FUNC(homevolution)
  6360. {
  6361. nullpo_retr(-1, sd);
  6362. if ( !hom_is_active(sd->hd) ) {
  6363. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6364. return -1;
  6365. }
  6366. if ( !hom_evolution(sd->hd) ) {
  6367. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6368. return -1;
  6369. }
  6370. clif_homskillinfoblock(sd);
  6371. return 0;
  6372. }
  6373. ACMD_FUNC(hommutate)
  6374. {
  6375. int homun_id, m_class = 0, m_id;
  6376. nullpo_retr(-1, sd);
  6377. if (!hom_is_active(sd->hd)) {
  6378. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6379. return -1;
  6380. }
  6381. if (!message || !*message) {
  6382. homun_id = 6048 + (rnd() % 4);
  6383. } else {
  6384. homun_id = atoi(message);
  6385. }
  6386. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6387. m_id = hom_class2mapid(homun_id);
  6388. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6389. hom_mutate(sd->hd, homun_id);
  6390. } else {
  6391. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6392. }
  6393. return 0;
  6394. }
  6395. /*==========================================
  6396. * call choosen homunculus [orn]
  6397. *------------------------------------------*/
  6398. ACMD_FUNC(makehomun)
  6399. {
  6400. int homunid;
  6401. nullpo_retr(-1, sd);
  6402. if ( sd->status.hom_id ) {
  6403. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6404. return -1;
  6405. }
  6406. if (!message || !*message) {
  6407. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6408. return -1;
  6409. }
  6410. homunid = atoi(message);
  6411. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6412. {
  6413. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6414. return -1;
  6415. }
  6416. hom_create_request(sd,homunid);
  6417. return 0;
  6418. }
  6419. /*==========================================
  6420. * modify homunculus intimacy [orn]
  6421. *------------------------------------------*/
  6422. ACMD_FUNC(homfriendly)
  6423. {
  6424. int friendly = 0;
  6425. nullpo_retr(-1, sd);
  6426. if ( !hom_is_active(sd->hd) ) {
  6427. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6428. return -1;
  6429. }
  6430. if (!message || !*message) {
  6431. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6432. return -1;
  6433. }
  6434. friendly = atoi(message);
  6435. friendly = cap_value(friendly, 0, 1000);
  6436. sd->hd->homunculus.intimacy = friendly * 100 ;
  6437. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6438. return 0;
  6439. }
  6440. /*==========================================
  6441. * modify homunculus hunger [orn]
  6442. *------------------------------------------*/
  6443. ACMD_FUNC(homhungry)
  6444. {
  6445. int hungry = 0;
  6446. nullpo_retr(-1, sd);
  6447. if ( !hom_is_active(sd->hd) ) {
  6448. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6449. return -1;
  6450. }
  6451. if (!message || !*message) {
  6452. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6453. return -1;
  6454. }
  6455. hungry = atoi(message);
  6456. hungry = cap_value(hungry, 0, 100);
  6457. sd->hd->homunculus.hunger = hungry;
  6458. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6459. return 0;
  6460. }
  6461. /*==========================================
  6462. * make the homunculus speak [orn]
  6463. *------------------------------------------*/
  6464. ACMD_FUNC(homtalk)
  6465. {
  6466. char mes[100],temp[100];
  6467. nullpo_retr(-1, sd);
  6468. if ( battle_config.min_chat_delay ) {
  6469. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6470. return 0;
  6471. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6472. }
  6473. if (sd->sc.cant.chat)
  6474. return -1; //no "chatting" while muted.
  6475. if ( !hom_is_active(sd->hd) ) {
  6476. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6477. return -1;
  6478. }
  6479. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6480. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6481. return -1;
  6482. }
  6483. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6484. clif_disp_overhead(&sd->hd->bl, temp);
  6485. return 0;
  6486. }
  6487. /*==========================================
  6488. * Show homunculus stats
  6489. *------------------------------------------*/
  6490. ACMD_FUNC(hominfo)
  6491. {
  6492. struct homun_data *hd;
  6493. struct status_data *status;
  6494. nullpo_retr(-1, sd);
  6495. if ( !hom_is_active(sd->hd) ) {
  6496. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6497. return -1;
  6498. }
  6499. hd = sd->hd;
  6500. status = status_get_status_data(&hd->bl);
  6501. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6502. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6503. status->hp, status->max_hp, status->sp, status->max_sp);
  6504. clif_displaymessage(fd, atcmd_output);
  6505. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6506. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6507. clif_displaymessage(fd, atcmd_output);
  6508. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6509. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6510. clif_displaymessage(fd, atcmd_output);
  6511. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6512. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6513. status->str, status->agi, status->vit,
  6514. status->int_, status->dex, status->luk);
  6515. clif_displaymessage(fd, atcmd_output);
  6516. return 0;
  6517. }
  6518. ACMD_FUNC(homstats)
  6519. {
  6520. struct homun_data *hd;
  6521. struct s_homunculus_db *db;
  6522. struct s_homunculus *hom;
  6523. int lv, min, max, evo;
  6524. nullpo_retr(-1, sd);
  6525. if ( !hom_is_active(sd->hd) ) {
  6526. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6527. return -1;
  6528. }
  6529. hd = sd->hd;
  6530. hom = &hd->homunculus;
  6531. db = hd->homunculusDB;
  6532. lv = hom->level;
  6533. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6534. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6535. clif_displaymessage(fd, atcmd_output);
  6536. lv--; //Since the first increase is at level 2.
  6537. evo = (hom->class_ == db->evo_class);
  6538. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6539. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6540. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6541. clif_displaymessage(fd, atcmd_output);
  6542. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6543. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6544. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6545. clif_displaymessage(fd, atcmd_output);
  6546. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6547. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6548. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6549. clif_displaymessage(fd, atcmd_output);
  6550. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6551. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6552. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6553. clif_displaymessage(fd, atcmd_output);
  6554. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6555. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6556. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6557. clif_displaymessage(fd, atcmd_output);
  6558. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6559. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6560. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6561. clif_displaymessage(fd, atcmd_output);
  6562. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6563. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6564. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6565. clif_displaymessage(fd, atcmd_output);
  6566. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6567. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6568. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6569. clif_displaymessage(fd, atcmd_output);
  6570. return 0;
  6571. }
  6572. ACMD_FUNC(homshuffle)
  6573. {
  6574. nullpo_retr(-1, sd);
  6575. if(!sd->hd)
  6576. return -1; // nothing to do
  6577. if(!hom_shuffle(sd->hd))
  6578. return -1;
  6579. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6580. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6581. return 0;
  6582. }
  6583. /*==========================================
  6584. * Show Items DB Info v 1.0
  6585. * originally by [Lupus]
  6586. *------------------------------------------*/
  6587. ACMD_FUNC(iteminfo)
  6588. {
  6589. struct item_data *item_array[MAX_SEARCH];
  6590. int i, count = 1;
  6591. if (!message || !*message) {
  6592. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6593. return -1;
  6594. }
  6595. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6596. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6597. if (!count) {
  6598. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6599. return -1;
  6600. }
  6601. if (count == MAX_SEARCH) {
  6602. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6603. clif_displaymessage(fd, atcmd_output);
  6604. }
  6605. for (i = 0; i < count; i++) {
  6606. struct item_data * item_data = item_array[i];
  6607. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6608. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6609. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6610. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6611. );
  6612. clif_displaymessage(fd, atcmd_output);
  6613. 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
  6614. clif_displaymessage(fd, atcmd_output);
  6615. if (item_data->maxchance == -1) {
  6616. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6617. clif_displaymessage(fd, atcmd_output);
  6618. }
  6619. else if (!battle_config.atcommand_mobinfo_type) {
  6620. if (item_data->maxchance)
  6621. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6622. else
  6623. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6624. clif_displaymessage(fd, atcmd_output);
  6625. }
  6626. }
  6627. return 0;
  6628. }
  6629. /*==========================================
  6630. * Show who drops the item.
  6631. *------------------------------------------*/
  6632. ACMD_FUNC(whodrops)
  6633. {
  6634. struct item_data *item_data, *item_array[MAX_SEARCH];
  6635. int i,j, count = 1;
  6636. if (!message || !*message) {
  6637. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6638. return -1;
  6639. }
  6640. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6641. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6642. if (!count) {
  6643. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6644. return -1;
  6645. }
  6646. if (count == MAX_SEARCH) {
  6647. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6648. clif_displaymessage(fd, atcmd_output);
  6649. }
  6650. for (i = 0; i < count; i++) {
  6651. item_data = item_array[i];
  6652. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6653. clif_displaymessage(fd, atcmd_output);
  6654. if (item_data->mob[0].chance == 0) {
  6655. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6656. clif_displaymessage(fd, atcmd_output);
  6657. } else {
  6658. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6659. clif_displaymessage(fd, atcmd_output);
  6660. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6661. {
  6662. int dropchance = item_data->mob[j].chance;
  6663. #ifdef RENEWAL_DROP
  6664. if( battle_config.atcommand_mobinfo_type )
  6665. dropchance = dropchance * pc_level_penalty_mod(mob_db(item_data->mob[j].id)->lv - sd->status.base_level, mob_db(item_data->mob[j].id)->status.class_, mob_db(item_data->mob[j].id)->status.mode, 2) / 100;
  6666. #endif
  6667. if (pc_isvip(sd)) // Display item rate increase for VIP
  6668. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6669. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6670. clif_displaymessage(fd, atcmd_output);
  6671. }
  6672. }
  6673. }
  6674. return 0;
  6675. }
  6676. ACMD_FUNC(whereis)
  6677. {
  6678. uint16 mob_ids[MAX_SEARCH] = {0};
  6679. int count = 0;
  6680. if (!message || !*message) {
  6681. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6682. return -1;
  6683. }
  6684. int i_message = atoi(message);
  6685. if (mobdb_checkid(i_message)) {
  6686. // ID given
  6687. mob_ids[0] = i_message;
  6688. count = 1;
  6689. } else {
  6690. // Name given, get all monster associated whith this name
  6691. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6692. }
  6693. if (count <= 0) {
  6694. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6695. return -1;
  6696. }
  6697. if (count >= MAX_SEARCH) {
  6698. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6699. clif_displaymessage(fd, atcmd_output);
  6700. count = MAX_SEARCH;
  6701. }
  6702. for (int i = 0; i < count; i++) {
  6703. uint16 mob_id = mob_ids[i];
  6704. struct mob_db * mob = mob_db(mob_id);
  6705. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6706. clif_displaymessage(fd, atcmd_output);
  6707. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  6708. if (spawns.size() <= 0) {
  6709. // This monster does not spawn normally.
  6710. clif_displaymessage(fd, msg_txt(sd,1290));
  6711. } else {
  6712. for(auto& spawn : spawns)
  6713. {
  6714. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  6715. if (mapid < 0)
  6716. continue;
  6717. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[mapid].name, spawn.qty);
  6718. clif_displaymessage(fd, atcmd_output);
  6719. }
  6720. }
  6721. }
  6722. return 0;
  6723. }
  6724. ACMD_FUNC(version)
  6725. {
  6726. pc_show_version(sd);
  6727. return 0;
  6728. }
  6729. /*==========================================
  6730. * @mutearea by MouseJstr
  6731. *------------------------------------------*/
  6732. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6733. {
  6734. int time, id;
  6735. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6736. if (pl_sd == NULL)
  6737. return 0;
  6738. id = va_arg(ap, int);
  6739. time = va_arg(ap, int);
  6740. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6741. pl_sd->status.manner -= time;
  6742. if (pl_sd->status.manner < 0)
  6743. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6744. else
  6745. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6746. }
  6747. return 0;
  6748. }
  6749. ACMD_FUNC(mutearea)
  6750. {
  6751. int time;
  6752. nullpo_ret(sd);
  6753. if (!message || !*message) {
  6754. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6755. return -1;
  6756. }
  6757. time = atoi(message);
  6758. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  6759. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6760. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6761. return 0;
  6762. }
  6763. ACMD_FUNC(rates)
  6764. {
  6765. char buf[CHAT_SIZE_MAX];
  6766. nullpo_ret(sd);
  6767. memset(buf, '\0', sizeof(buf));
  6768. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6769. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  6770. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  6771. clif_displaymessage(fd, buf);
  6772. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6773. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6774. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6775. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6776. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6777. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6778. clif_displaymessage(fd, buf);
  6779. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6780. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6781. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6782. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6783. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6784. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6785. clif_displaymessage(fd, buf);
  6786. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6787. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6788. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6789. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6790. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6791. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6792. clif_displaymessage(fd, buf);
  6793. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6794. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6795. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6796. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6797. clif_displaymessage(fd, buf);
  6798. return 0;
  6799. }
  6800. /*==========================================
  6801. * @me by lordalfa
  6802. * => Displays the OUTPUT string on top of the Visible players Heads.
  6803. *------------------------------------------*/
  6804. ACMD_FUNC(me)
  6805. {
  6806. char tempmes[CHAT_SIZE_MAX];
  6807. nullpo_retr(-1, sd);
  6808. memset(tempmes, '\0', sizeof(tempmes));
  6809. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6810. if (sd->sc.cant.chat)
  6811. return -1; //no "chatting" while muted.
  6812. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6813. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6814. return -1;
  6815. }
  6816. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6817. clif_disp_overhead(&sd->bl, atcmd_output);
  6818. return 0;
  6819. }
  6820. /*==========================================
  6821. * @size
  6822. * => Resize your character sprite. [Valaris]
  6823. *------------------------------------------*/
  6824. ACMD_FUNC(size)
  6825. {
  6826. int size = SZ_SMALL;
  6827. nullpo_retr(-1, sd);
  6828. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6829. if(sd->state.size) {
  6830. sd->state.size = SZ_SMALL;
  6831. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6832. }
  6833. sd->state.size = size;
  6834. if( size == SZ_MEDIUM )
  6835. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  6836. else if( size == SZ_BIG )
  6837. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  6838. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6839. return 0;
  6840. }
  6841. ACMD_FUNC(sizeall)
  6842. {
  6843. int size;
  6844. struct map_session_data *pl_sd;
  6845. struct s_mapiterator* iter;
  6846. size = atoi(message);
  6847. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6848. iter = mapit_getallusers();
  6849. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6850. if( pl_sd->state.size != size ) {
  6851. if( pl_sd->state.size ) {
  6852. pl_sd->state.size = SZ_SMALL;
  6853. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6854. }
  6855. pl_sd->state.size = size;
  6856. if( size == SZ_MEDIUM )
  6857. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6858. else if( size == SZ_BIG )
  6859. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6860. }
  6861. }
  6862. mapit_free(iter);
  6863. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6864. return 0;
  6865. }
  6866. ACMD_FUNC(sizeguild)
  6867. {
  6868. int size = SZ_SMALL, i;
  6869. char guild[NAME_LENGTH];
  6870. struct map_session_data *pl_sd;
  6871. struct guild *g;
  6872. nullpo_retr(-1, sd);
  6873. memset(guild, '\0', sizeof(guild));
  6874. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6875. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6876. return -1;
  6877. }
  6878. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6879. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6880. return -1;
  6881. }
  6882. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6883. for( i = 0; i < g->max_member; i++ ) {
  6884. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6885. if( pl_sd->state.size ) {
  6886. pl_sd->state.size = SZ_SMALL;
  6887. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6888. }
  6889. pl_sd->state.size = size;
  6890. if( size == SZ_MEDIUM )
  6891. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6892. else if( size == SZ_BIG )
  6893. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6894. }
  6895. }
  6896. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6897. return 0;
  6898. }
  6899. /*==========================================
  6900. * @monsterignore
  6901. * => Makes monsters ignore you. [Valaris]
  6902. *------------------------------------------*/
  6903. ACMD_FUNC(monsterignore)
  6904. {
  6905. nullpo_retr(-1, sd);
  6906. if (!sd->state.monster_ignore) {
  6907. sd->state.monster_ignore = 1;
  6908. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6909. } else {
  6910. sd->state.monster_ignore = 0;
  6911. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6912. }
  6913. return 0;
  6914. }
  6915. /*==========================================
  6916. * @fakename
  6917. * => Gives your character a fake name. [Valaris]
  6918. *------------------------------------------*/
  6919. ACMD_FUNC(fakename)
  6920. {
  6921. nullpo_retr(-1, sd);
  6922. if( !message || !*message )
  6923. {
  6924. if( sd->fakename[0] )
  6925. {
  6926. sd->fakename[0] = '\0';
  6927. clif_name_area(&sd->bl);
  6928. if (sd->disguise)
  6929. clif_name_self(&sd->bl);
  6930. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6931. return 0;
  6932. }
  6933. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6934. return -1;
  6935. }
  6936. if( strlen(message) < 2 )
  6937. {
  6938. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6939. return -1;
  6940. }
  6941. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6942. clif_name_area(&sd->bl);
  6943. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6944. clif_name_self(&sd->bl);
  6945. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6946. return 0;
  6947. }
  6948. /*==========================================
  6949. * Ragnarok Resources
  6950. *------------------------------------------*/
  6951. ACMD_FUNC(mapflag) {
  6952. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6953. #define setflag( cmd ) \
  6954. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6955. map[ sd->bl.m ].flag.cmd = flag;\
  6956. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6957. clif_displaymessage(sd->fd,atcmd_output);\
  6958. return 0;\
  6959. }
  6960. char flag_name[100];
  6961. short flag=0,i;
  6962. nullpo_retr(-1, sd);
  6963. memset(flag_name, '\0', sizeof(flag_name));
  6964. if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
  6965. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6966. clif_displaymessage(sd->fd,"----------------------------------");
  6967. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6968. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6969. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6970. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6971. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6972. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6973. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6974. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6975. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6976. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6977. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6978. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6979. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6980. checkflag(nolockon); checkflag(notomb); checkflag(nocostume); checkflag(gvg_te);
  6981. checkflag(gvg_te_castle); checkflag(hidemobhpbar);
  6982. #ifdef ADJUST_SKILL_DAMAGE
  6983. checkflag(skill_damage);
  6984. #endif
  6985. clif_displaymessage(sd->fd," ");
  6986. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6987. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6988. return 1;
  6989. }
  6990. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6991. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6992. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6993. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6994. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6995. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6996. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6997. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6998. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6999. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  7000. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  7001. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  7002. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  7003. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  7004. setflag(nolockon); setflag(notomb); setflag(nocostume); setflag(gvg_te);
  7005. setflag(gvg_te_castle); setflag(hidemobhpbar);
  7006. #ifdef ADJUST_SKILL_DAMAGE
  7007. setflag(skill_damage);
  7008. #endif
  7009. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  7010. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7011. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7012. clif_displaymessage(sd->fd,"----------------------------------");
  7013. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  7014. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  7015. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  7016. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  7017. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  7018. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  7019. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb,");
  7020. clif_displaymessage(sd->fd,"nocostume, gvg_te, gvg_te_castle, hidemobhpbar");
  7021. #ifdef ADJUST_SKILL_DAMAGE
  7022. clif_displaymessage(sd->fd,"skill_damage");
  7023. #endif
  7024. #undef checkflag
  7025. #undef setflag
  7026. return 0;
  7027. }
  7028. /*===================================
  7029. * Remove some messages
  7030. *-----------------------------------*/
  7031. ACMD_FUNC(showexp)
  7032. {
  7033. if (sd->state.showexp) {
  7034. sd->state.showexp = 0;
  7035. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7036. return 0;
  7037. }
  7038. sd->state.showexp = 1;
  7039. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7040. return 0;
  7041. }
  7042. ACMD_FUNC(showzeny)
  7043. {
  7044. if (sd->state.showzeny) {
  7045. sd->state.showzeny = 0;
  7046. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7047. return 0;
  7048. }
  7049. sd->state.showzeny = 1;
  7050. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7051. return 0;
  7052. }
  7053. ACMD_FUNC(showdelay)
  7054. {
  7055. if (sd->state.showdelay) {
  7056. sd->state.showdelay = 0;
  7057. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7058. return 0;
  7059. }
  7060. sd->state.showdelay = 1;
  7061. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7062. return 0;
  7063. }
  7064. /*==========================================
  7065. * Duel organizing functions [LuzZza]
  7066. *
  7067. * @duel [limit|nick] - create a duel
  7068. * @invite <nick> - invite player
  7069. * @accept - accept invitation
  7070. * @reject - reject invitation
  7071. * @leave - leave duel
  7072. *------------------------------------------*/
  7073. ACMD_FUNC(invite)
  7074. {
  7075. unsigned int did = sd->duel_group;
  7076. struct map_session_data *target_sd = NULL;
  7077. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7078. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7079. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7080. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7081. clif_displaymessage(fd, atcmd_output);
  7082. return -1;
  7083. }
  7084. if(did == 0 || !duel_exist(did) ) {
  7085. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7086. return 0;
  7087. }
  7088. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7089. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7090. return 0;
  7091. }
  7092. if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
  7093. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7094. return 0;
  7095. }
  7096. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7097. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7098. return 0;
  7099. }
  7100. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7101. {
  7102. 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.
  7103. clif_displaymessage(fd, atcmd_output);
  7104. return 0;
  7105. }
  7106. duel_invite(did, sd, target_sd);
  7107. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7108. return 0;
  7109. }
  7110. ACMD_FUNC(duel)
  7111. {
  7112. unsigned int maxpl = 0;
  7113. if(sd->duel_group > 0) {
  7114. duel_showinfo(sd->duel_group, sd);
  7115. return 0;
  7116. }
  7117. if(sd->duel_invite > 0) {
  7118. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7119. return 0;
  7120. }
  7121. if(!duel_checktime(sd)) {
  7122. char output[CHAT_SIZE_MAX];
  7123. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7124. clif_displaymessage(fd, output);
  7125. return 0;
  7126. }
  7127. if( message[0] ) {
  7128. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7129. if(maxpl < 2 || maxpl > 65535) {
  7130. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7131. return 0;
  7132. }
  7133. duel_create(sd, maxpl);
  7134. } else {
  7135. struct map_session_data *target_sd = NULL;
  7136. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7137. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7138. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7139. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7140. clif_displaymessage(fd, atcmd_output);
  7141. return -1;
  7142. }
  7143. target_sd = map_nick2sd(atcmd_player_name,true);
  7144. if(target_sd != NULL) {
  7145. unsigned int newduel;
  7146. if((newduel = duel_create(sd, 2)) != -1) {
  7147. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7148. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7149. return 0;
  7150. }
  7151. duel_invite(newduel, sd, target_sd);
  7152. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7153. }
  7154. } else {
  7155. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7156. return 0;
  7157. }
  7158. }
  7159. } else
  7160. duel_create(sd, 0);
  7161. return 0;
  7162. }
  7163. ACMD_FUNC(leave)
  7164. {
  7165. if(sd->duel_group <= 0) {
  7166. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7167. return 0;
  7168. }
  7169. duel_leave(sd->duel_group, sd);
  7170. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7171. return 0;
  7172. }
  7173. ACMD_FUNC(accept)
  7174. {
  7175. if(!duel_checktime(sd)) {
  7176. char output[CHAT_SIZE_MAX];
  7177. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7178. clif_displaymessage(fd, output);
  7179. return 0;
  7180. }
  7181. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7182. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7183. return 0;
  7184. }
  7185. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7186. {
  7187. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7188. return 0;
  7189. }
  7190. duel_accept(sd->duel_invite, sd);
  7191. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7192. return 0;
  7193. }
  7194. ACMD_FUNC(reject)
  7195. {
  7196. if(sd->duel_invite <= 0) {
  7197. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7198. return 0;
  7199. }
  7200. duel_reject(sd->duel_invite, sd);
  7201. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7202. return 0;
  7203. }
  7204. /*===================================
  7205. * Cash Points
  7206. *-----------------------------------*/
  7207. ACMD_FUNC(cash)
  7208. {
  7209. char output[128];
  7210. int value;
  7211. int ret=0;
  7212. nullpo_retr(-1, sd);
  7213. // Since there is no cashpoint update packet we need to force updating like this
  7214. if( sd->state.cashshop_open ){
  7215. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7216. return -1;
  7217. }
  7218. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7219. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7220. return -1;
  7221. }
  7222. parent_cmd = atcommand_checkalias(command+1);
  7223. if( !strcmpi(parent_cmd,"cash") )
  7224. {
  7225. if( value > 0 ) {
  7226. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7227. // If this option is set, the message is already sent by pc function
  7228. if( !battle_config.cashshop_show_points ){
  7229. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7230. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7231. }
  7232. }
  7233. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7234. } else {
  7235. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7236. value = -sd->cashPoints;
  7237. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7238. // If this option is set, the message is already sent by pc function
  7239. if( !battle_config.cashshop_show_points ){
  7240. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7241. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7242. }
  7243. }
  7244. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7245. }
  7246. }
  7247. else
  7248. { // @points
  7249. if( value > 0 ) {
  7250. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7251. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7252. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7253. }
  7254. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7255. } else {
  7256. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7257. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7258. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7259. }
  7260. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7261. }
  7262. }
  7263. return 0;
  7264. }
  7265. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7266. ACMD_FUNC(clone)
  7267. {
  7268. int x=0,y=0,flag=0,master=0,i=0;
  7269. struct map_session_data *pl_sd=NULL;
  7270. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7271. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7272. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7273. return 0;
  7274. }
  7275. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
  7276. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7277. return 0;
  7278. }
  7279. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7280. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7281. return 0;
  7282. }
  7283. parent_cmd = atcommand_checkalias(command+1);
  7284. if (strcmpi(parent_cmd, "clone") == 0)
  7285. flag = 1;
  7286. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7287. flag = 2;
  7288. if(pc_isdead(sd)){
  7289. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7290. return 0;
  7291. }
  7292. master = sd->bl.id;
  7293. if (battle_config.atc_slave_clone_limit
  7294. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7295. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7296. return 0;
  7297. }
  7298. }
  7299. do {
  7300. x = sd->bl.x + (rnd() % 10 - 5);
  7301. y = sd->bl.y + (rnd() % 10 - 5);
  7302. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7303. if (i >= 10) {
  7304. x = sd->bl.x;
  7305. y = sd->bl.y;
  7306. }
  7307. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7308. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7309. return 0;
  7310. }
  7311. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7312. return 0;
  7313. }
  7314. /*=====================================
  7315. * Autorejecting Invites/Deals [LuzZza]
  7316. * Usage: @noask
  7317. *-------------------------------------*/
  7318. ACMD_FUNC(noask)
  7319. {
  7320. if(sd->state.noask) {
  7321. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7322. sd->state.noask = 0;
  7323. } else {
  7324. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7325. sd->state.noask = 1;
  7326. }
  7327. return 0;
  7328. }
  7329. /*=====================================
  7330. * Send a @request message to all GMs of lowest_gm_level.
  7331. * Usage: @request <petition>
  7332. *-------------------------------------*/
  7333. ACMD_FUNC(request)
  7334. {
  7335. if (!message || !*message) {
  7336. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7337. return -1;
  7338. }
  7339. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7340. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7341. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7342. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7343. return 0;
  7344. }
  7345. /*==========================================
  7346. * Feel (SG save map) Reset [HiddenDragon]
  7347. *------------------------------------------*/
  7348. ACMD_FUNC(feelreset)
  7349. {
  7350. pc_resetfeel(sd);
  7351. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7352. return 0;
  7353. }
  7354. /*==========================================
  7355. * AUCTION SYSTEM
  7356. *------------------------------------------*/
  7357. ACMD_FUNC(auction)
  7358. {
  7359. nullpo_ret(sd);
  7360. if (!battle_config.feature_auction) {
  7361. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7362. return 0;
  7363. }
  7364. clif_Auction_openwindow(sd);
  7365. return 0;
  7366. }
  7367. /*==========================================
  7368. * Kill Steal Protection
  7369. *------------------------------------------*/
  7370. ACMD_FUNC(ksprotection)
  7371. {
  7372. nullpo_retr(-1,sd);
  7373. if( sd->state.noks ) {
  7374. sd->state.noks = 0;
  7375. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7376. }
  7377. else
  7378. {
  7379. if( !message || !*message || !strcmpi(message, "party") )
  7380. { // Default is Party
  7381. sd->state.noks = 2;
  7382. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7383. }
  7384. else if( !strcmpi(message, "self") )
  7385. {
  7386. sd->state.noks = 1;
  7387. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7388. }
  7389. else if( !strcmpi(message, "guild") )
  7390. {
  7391. sd->state.noks = 3;
  7392. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7393. }
  7394. else
  7395. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7396. }
  7397. return 0;
  7398. }
  7399. /*==========================================
  7400. * Map Kill Steal Protection Setting
  7401. *------------------------------------------*/
  7402. ACMD_FUNC(allowks)
  7403. {
  7404. nullpo_retr(-1,sd);
  7405. if( map[sd->bl.m].flag.allowks ) {
  7406. map[sd->bl.m].flag.allowks = 0;
  7407. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7408. } else {
  7409. map[sd->bl.m].flag.allowks = 1;
  7410. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7411. }
  7412. return 0;
  7413. }
  7414. ACMD_FUNC(resetstat)
  7415. {
  7416. nullpo_retr(-1, sd);
  7417. pc_resetstate(sd);
  7418. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7419. clif_displaymessage(fd, atcmd_output);
  7420. return 0;
  7421. }
  7422. ACMD_FUNC(resetskill)
  7423. {
  7424. nullpo_retr(-1,sd);
  7425. pc_resetskill(sd,1);
  7426. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7427. clif_displaymessage(fd, atcmd_output);
  7428. return 0;
  7429. }
  7430. /*==========================================
  7431. * #storagelist: Displays the items list of a player's storage.
  7432. * #cartlist: Displays contents of target's cart.
  7433. * #itemlist: Displays contents of target's inventory.
  7434. *------------------------------------------*/
  7435. ACMD_FUNC(itemlist)
  7436. {
  7437. int i, j, count, counter;
  7438. const char* location;
  7439. const struct item* items;
  7440. int size;
  7441. StringBuf buf;
  7442. nullpo_retr(-1, sd);
  7443. parent_cmd = atcommand_checkalias(command+1);
  7444. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7445. location = "storage";
  7446. items = sd->storage.u.items_storage;
  7447. size = sd->storage.max_amount;
  7448. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7449. location = "cart";
  7450. items = sd->cart.u.items_cart;
  7451. size = MAX_CART;
  7452. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7453. location = "inventory";
  7454. items = sd->inventory.u.items_inventory;
  7455. size = MAX_INVENTORY;
  7456. } else
  7457. return 1;
  7458. StringBuf_Init(&buf);
  7459. count = 0; // total slots occupied
  7460. counter = 0; // total items found
  7461. for( i = 0; i < size; ++i ) {
  7462. const struct item* it = &items[i];
  7463. struct item_data* itd;
  7464. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7465. continue;
  7466. counter += it->amount;
  7467. count++;
  7468. if( count == 1 ) {
  7469. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7470. clif_displaymessage(fd, StringBuf_Value(&buf));
  7471. StringBuf_Clear(&buf);
  7472. }
  7473. if( it->refine )
  7474. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7475. else
  7476. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7477. if( it->equip ) {
  7478. char equipstr[CHAT_SIZE_MAX];
  7479. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7480. if( it->equip&EQP_GARMENT )
  7481. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7482. if( it->equip&EQP_ACC_L )
  7483. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7484. if( it->equip&EQP_ARMOR )
  7485. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7486. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7487. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7488. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7489. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7490. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7491. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7492. if( it->equip&EQP_SHOES )
  7493. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7494. if( it->equip&EQP_ACC_R )
  7495. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7496. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7497. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7498. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7499. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7500. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7501. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7502. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7503. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7504. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7505. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7506. if( (it->equip&EQP_HELM) == EQP_HELM )
  7507. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7508. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7509. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7510. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7511. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7512. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7513. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7514. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7515. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7516. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7517. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7518. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7519. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7520. if( it->equip&EQP_COSTUME_GARMENT )
  7521. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7522. //if( it->equip&EQP_COSTUME_FLOOR )
  7523. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7524. if( it->equip&EQP_AMMO )
  7525. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7526. if( it->equip&EQP_SHADOW_ARMOR )
  7527. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7528. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7529. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7530. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7531. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7532. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7533. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7534. if( it->equip&EQP_SHADOW_SHOES )
  7535. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7536. if( it->equip&EQP_SHADOW_ACC_R )
  7537. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7538. if( it->equip&EQP_SHADOW_ACC_L )
  7539. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7540. // remove final ', '
  7541. equipstr[strlen(equipstr) - 2] = '\0';
  7542. StringBuf_AppendStr(&buf, equipstr);
  7543. }
  7544. clif_displaymessage(fd, StringBuf_Value(&buf));
  7545. StringBuf_Clear(&buf);
  7546. if( it->card[0] == CARD0_PET ) { // pet egg
  7547. if (it->card[3])
  7548. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7549. else
  7550. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7551. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7552. 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)
  7553. } else if(it->card[0] == CARD0_CREATE) { // created item
  7554. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7555. } else { // normal item
  7556. int counter2 = 0;
  7557. for( j = 0; j < itd->slot; ++j ) {
  7558. struct item_data* card;
  7559. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7560. continue;
  7561. counter2++;
  7562. if( counter2 == 1 )
  7563. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7564. if( counter2 != 1 )
  7565. StringBuf_AppendStr(&buf, ", ");
  7566. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7567. }
  7568. if( counter2 > 0 )
  7569. StringBuf_AppendStr(&buf, ")");
  7570. }
  7571. if( StringBuf_Length(&buf) > 0 )
  7572. clif_displaymessage(fd, StringBuf_Value(&buf));
  7573. StringBuf_Clear(&buf);
  7574. }
  7575. if( count == 0 )
  7576. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7577. else
  7578. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7579. clif_displaymessage(fd, StringBuf_Value(&buf));
  7580. StringBuf_Destroy(&buf);
  7581. return 0;
  7582. }
  7583. ACMD_FUNC(stats)
  7584. {
  7585. char job_jobname[100];
  7586. char output[CHAT_SIZE_MAX];
  7587. int i;
  7588. struct {
  7589. const char* format;
  7590. int value;
  7591. } output_table[] = {
  7592. { "Base Level - %d", 0 },
  7593. { NULL, 0 },
  7594. { "Hp - %d", 0 },
  7595. { "MaxHp - %d", 0 },
  7596. { "Sp - %d", 0 },
  7597. { "MaxSp - %d", 0 },
  7598. { "Str - %3d", 0 },
  7599. { "Agi - %3d", 0 },
  7600. { "Vit - %3d", 0 },
  7601. { "Int - %3d", 0 },
  7602. { "Dex - %3d", 0 },
  7603. { "Luk - %3d", 0 },
  7604. { "Zeny - %d", 0 },
  7605. { "Free SK Points - %d", 0 },
  7606. { "JobChangeLvl (2nd) - %d", 0 },
  7607. { "JobChangeLvl (3rd) - %d", 0 },
  7608. { NULL, 0 }
  7609. };
  7610. memset(job_jobname, '\0', sizeof(job_jobname));
  7611. memset(output, '\0', sizeof(output));
  7612. //direct array initialization with variables is not standard C compliant.
  7613. output_table[0].value = sd->status.base_level;
  7614. output_table[1].format = job_jobname;
  7615. output_table[1].value = sd->status.job_level;
  7616. output_table[2].value = sd->status.hp;
  7617. output_table[3].value = sd->status.max_hp;
  7618. output_table[4].value = sd->status.sp;
  7619. output_table[5].value = sd->status.max_sp;
  7620. output_table[6].value = sd->status.str;
  7621. output_table[7].value = sd->status.agi;
  7622. output_table[8].value = sd->status.vit;
  7623. output_table[9].value = sd->status.int_;
  7624. output_table[10].value = sd->status.dex;
  7625. output_table[11].value = sd->status.luk;
  7626. output_table[12].value = sd->status.zeny;
  7627. output_table[13].value = sd->status.skill_point;
  7628. output_table[14].value = sd->change_level_2nd;
  7629. output_table[15].value = sd->change_level_3rd;
  7630. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7631. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7632. clif_displaymessage(fd, output);
  7633. for (i = 0; output_table[i].format != NULL; i++) {
  7634. sprintf(output, output_table[i].format, output_table[i].value);
  7635. clif_displaymessage(fd, output);
  7636. }
  7637. return 0;
  7638. }
  7639. ACMD_FUNC(delitem)
  7640. {
  7641. char item_name[100];
  7642. unsigned short nameid;
  7643. int amount = 0, total, idx;
  7644. struct item_data* id;
  7645. nullpo_retr(-1, sd);
  7646. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7647. {
  7648. 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>).
  7649. return -1;
  7650. }
  7651. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7652. {
  7653. nameid = id->nameid;
  7654. }
  7655. else
  7656. {
  7657. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7658. return -1;
  7659. }
  7660. total = amount;
  7661. // delete items
  7662. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7663. {
  7664. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  7665. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  7666. {// delete pet
  7667. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  7668. }
  7669. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7670. amount-= delamount;
  7671. }
  7672. // notify target
  7673. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7674. clif_displaymessage(sd->fd, atcmd_output);
  7675. // notify source
  7676. if( amount == total )
  7677. {
  7678. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7679. }
  7680. else if( amount )
  7681. {
  7682. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7683. clif_displaymessage(fd, atcmd_output);
  7684. }
  7685. else
  7686. {
  7687. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7688. clif_displaymessage(fd, atcmd_output);
  7689. }
  7690. return 0;
  7691. }
  7692. /*==========================================
  7693. * Custom Fonts
  7694. *------------------------------------------*/
  7695. ACMD_FUNC(font)
  7696. {
  7697. int font_id;
  7698. nullpo_retr(-1,sd);
  7699. font_id = atoi(message);
  7700. if( font_id == 0 ) {
  7701. if( sd->status.font ) {
  7702. sd->status.font = 0;
  7703. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7704. clif_font(sd);
  7705. } else {
  7706. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7707. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7708. }
  7709. } else if( font_id < 0 || font_id > 9 )
  7710. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7711. else if( font_id != sd->status.font ) {
  7712. sd->status.font = font_id;
  7713. clif_font(sd);
  7714. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7715. } else
  7716. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7717. return 0;
  7718. }
  7719. /*==========================================
  7720. * type: 1 = commands (@), 2 = charcommands (#)
  7721. *------------------------------------------*/
  7722. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7723. {
  7724. char line_buff[CHATBOX_SIZE];
  7725. char* cur = line_buff;
  7726. AtCommandInfo* cmd;
  7727. DBIterator *iter = db_iterator(atcommand_db);
  7728. int count = 0;
  7729. memset(line_buff,' ',CHATBOX_SIZE);
  7730. line_buff[CHATBOX_SIZE-1] = 0;
  7731. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7732. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7733. unsigned int slen = 0;
  7734. switch( type ) {
  7735. case COMMAND_CHARCOMMAND:
  7736. if( cmd->char_groups[sd->group_pos] == 0 )
  7737. continue;
  7738. break;
  7739. case COMMAND_ATCOMMAND:
  7740. if( cmd->at_groups[sd->group_pos] == 0 )
  7741. continue;
  7742. break;
  7743. default:
  7744. continue;
  7745. }
  7746. slen = strlen(cmd->command);
  7747. // flush the text buffer if this command won't fit into it
  7748. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7749. clif_displaymessage(fd,line_buff);
  7750. cur = line_buff;
  7751. memset(line_buff,' ',CHATBOX_SIZE);
  7752. line_buff[CHATBOX_SIZE-1] = 0;
  7753. }
  7754. memcpy(cur,cmd->command,slen);
  7755. cur += slen+(10-slen%10);
  7756. count++;
  7757. }
  7758. dbi_destroy(iter);
  7759. clif_displaymessage(fd,line_buff);
  7760. if ( atcmd_binding_count ) {
  7761. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7762. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7763. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7764. unsigned int slen = strlen(atcmd_binding[i]->command);
  7765. if ( count_bind == 0 ) {
  7766. cur = line_buff;
  7767. memset(line_buff,' ',CHATBOX_SIZE);
  7768. line_buff[CHATBOX_SIZE-1] = 0;
  7769. clif_displaymessage(fd, "-----------------");
  7770. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7771. }
  7772. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7773. clif_displaymessage(fd,line_buff);
  7774. cur = line_buff;
  7775. memset(line_buff,' ',CHATBOX_SIZE);
  7776. line_buff[CHATBOX_SIZE-1] = 0;
  7777. }
  7778. memcpy(cur,atcmd_binding[i]->command,slen);
  7779. cur += slen+(10-slen%10);
  7780. count_bind++;
  7781. }
  7782. }
  7783. if ( count_bind )
  7784. clif_displaymessage(fd,line_buff);// last one
  7785. count += count_bind;
  7786. }
  7787. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7788. clif_displaymessage(fd, atcmd_output);
  7789. return;
  7790. }
  7791. /*==========================================
  7792. * @commands Lists available @ commands to you
  7793. *------------------------------------------*/
  7794. ACMD_FUNC(commands)
  7795. {
  7796. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7797. return 0;
  7798. }
  7799. /*==========================================
  7800. * @charcommands Lists available # commands to you
  7801. *------------------------------------------*/
  7802. ACMD_FUNC(charcommands) {
  7803. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7804. return 0;
  7805. }
  7806. /* for new mounts */
  7807. ACMD_FUNC(mount2) {
  7808. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7809. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7810. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7811. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7812. } else {
  7813. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7814. if (&sd->sc)
  7815. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7816. }
  7817. return 0;
  7818. }
  7819. ACMD_FUNC(accinfo) {
  7820. char query[NAME_LENGTH];
  7821. char type = 0; // type = 1, get only account name
  7822. if (!message || !*message || strlen(message) > NAME_LENGTH
  7823. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7824. {
  7825. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7826. 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".
  7827. return -1;
  7828. } else if (type != 0) {
  7829. type = type-'0'; //make it int
  7830. if (type != 1) {
  7831. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7832. return -1;
  7833. }
  7834. }
  7835. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7836. return 0;
  7837. }
  7838. /**
  7839. * @set <variable name{[index]}>{ <value>}
  7840. *
  7841. * Gets or sets a value of a non server variable.
  7842. * If a value is specified it is used to set the variable's value,
  7843. * if not the variable's value is read.
  7844. * In any case it reads and displays the variable's value.
  7845. *
  7846. * Original implementation by Ind
  7847. */
  7848. ACMD_FUNC(set) {
  7849. char reg[46], val[128], name[32];
  7850. int toset = 0, len, index;
  7851. bool is_str = false;
  7852. int64 uid;
  7853. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7854. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7855. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7856. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7857. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7858. return -1;
  7859. }
  7860. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7861. if( reg[0] == '.' ) {
  7862. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7863. return -1;
  7864. } else if( reg[0] == '\'' ) {
  7865. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7866. return -1;
  7867. }
  7868. // Check if the user wanted to set an array
  7869. if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){
  7870. // The user did not specify array brackets, so we set the index to zero
  7871. index = 0;
  7872. }
  7873. is_str = is_string_variable(name);
  7874. if( ( len = strlen(val) ) > 1 ) {
  7875. if( val[0] == '"' && val[len-1] == '"') {
  7876. val[len-1] = '\0'; //Strip quotes.
  7877. memmove(val, val+1, len-1);
  7878. }
  7879. }
  7880. // Only set the variable if there is a value for it
  7881. if( toset >= 2 ){
  7882. setd_sub( NULL, sd, name, index, is_str ? (void*)val : (void*)__64BPRTSIZE((atoi(val))), NULL );
  7883. }
  7884. uid = reference_uid( add_str( name ), index );
  7885. if( is_str ) {// string variable
  7886. char* value;
  7887. switch( reg[0] ) {
  7888. case '@':
  7889. value = pc_readregstr(sd, uid);
  7890. break;
  7891. case '$':
  7892. value = mapreg_readregstr(uid);
  7893. break;
  7894. case '#':
  7895. if( reg[1] == '#' )
  7896. value = pc_readaccountreg2str(sd, uid);// global
  7897. else
  7898. value = pc_readaccountregstr(sd, uid);// local
  7899. break;
  7900. default:
  7901. value = pc_readglobalreg_str(sd, uid);
  7902. break;
  7903. }
  7904. if( value == NULL || *value == '\0' ){// empty string
  7905. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7906. }else{
  7907. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
  7908. }
  7909. } else {// integer variable
  7910. int value;
  7911. switch( reg[0] ) {
  7912. case '@':
  7913. value = pc_readreg(sd, uid);
  7914. break;
  7915. case '$':
  7916. value = mapreg_readreg(uid);
  7917. break;
  7918. case '#':
  7919. if( reg[1] == '#' )
  7920. value = pc_readaccountreg2(sd, uid);// global
  7921. else
  7922. value = pc_readaccountreg(sd, uid);// local
  7923. break;
  7924. default:
  7925. value = pc_readglobalreg(sd, uid);
  7926. break;
  7927. }
  7928. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d
  7929. }
  7930. clif_displaymessage(fd, atcmd_output);
  7931. return 0;
  7932. }
  7933. ACMD_FUNC(addperm) {
  7934. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7935. bool add;
  7936. int i;
  7937. parent_cmd = atcommand_checkalias(command+1);
  7938. add = (strcmpi(parent_cmd, "addperm") == 0);
  7939. if( !message || !*message ) {
  7940. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7941. clif_displaymessage(fd, atcmd_output);
  7942. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7943. for( i = 0; i < perm_size; i++ ) {
  7944. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7945. clif_displaymessage(fd, atcmd_output);
  7946. }
  7947. return -1;
  7948. }
  7949. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7950. if( i == perm_size ) {
  7951. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7952. clif_displaymessage(fd, atcmd_output);
  7953. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7954. for( i = 0; i < perm_size; i++ ) {
  7955. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7956. clif_displaymessage(fd, atcmd_output);
  7957. }
  7958. return -1;
  7959. }
  7960. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7961. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7962. clif_displaymessage(fd, atcmd_output);
  7963. return -1;
  7964. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7965. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7966. clif_displaymessage(fd, atcmd_output);
  7967. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7968. clif_displaymessage(fd, atcmd_output);
  7969. for( i = 0; i < perm_size; i++ ) {
  7970. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7971. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7972. clif_displaymessage(fd, atcmd_output);
  7973. }
  7974. }
  7975. return -1;
  7976. }
  7977. if( add )
  7978. sd->permissions |= pc_g_permission_name[i].permission;
  7979. else
  7980. sd->permissions &=~ pc_g_permission_name[i].permission;
  7981. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7982. clif_displaymessage(fd, atcmd_output);
  7983. return 0;
  7984. }
  7985. ACMD_FUNC(unloadnpcfile) {
  7986. if( !message || !*message ) {
  7987. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7988. return -1;
  7989. }
  7990. if( npc_unloadfile(message) )
  7991. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7992. else {
  7993. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7994. return -1;
  7995. }
  7996. return 0;
  7997. }
  7998. ACMD_FUNC(cart) {
  7999. #define MC_CART_MDFY(idx, x) \
  8000. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8001. sd->status.skill[(idx)].lv = (x)?1:0; \
  8002. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8003. int val = atoi(message);
  8004. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8005. uint16 sk_idx = 0;
  8006. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8007. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8008. clif_displaymessage(fd, atcmd_output);
  8009. return -1;
  8010. }
  8011. if( val == 0 && !pc_iscarton(sd) ) {
  8012. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8013. return -1;
  8014. }
  8015. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8016. return -1;
  8017. if( need_skill ) {
  8018. MC_CART_MDFY(sk_idx,1);
  8019. }
  8020. if( !pc_setcart(sd, val) ) {
  8021. if( need_skill ) {
  8022. MC_CART_MDFY(sk_idx,0);
  8023. }
  8024. return -1;/* @cart failed */
  8025. }
  8026. if( need_skill ) {
  8027. MC_CART_MDFY(sk_idx,0);
  8028. }
  8029. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8030. return 0;
  8031. #undef MC_CART_MDFY
  8032. }
  8033. /* Channel System [Ind] */
  8034. ACMD_FUNC(join){
  8035. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8036. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8037. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8038. clif_displaymessage(fd, atcmd_output);
  8039. return -1;
  8040. }
  8041. return channel_pcjoin(sd, chname, pass);
  8042. }
  8043. /*
  8044. * Display available option for @channel command
  8045. * @command : the name of used command (for alias case)
  8046. */
  8047. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8048. {
  8049. int fd = sd->fd;
  8050. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8051. bool can_create = (can_delete || channel_config.private_channel.allow);
  8052. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8053. //option create
  8054. if( can_create ) {
  8055. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8056. clif_displaymessage(fd, atcmd_output);
  8057. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8058. }
  8059. //option delete
  8060. if(can_delete){
  8061. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8062. clif_displaymessage(fd, atcmd_output);
  8063. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8064. }
  8065. //option list
  8066. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8067. clif_displaymessage(fd, atcmd_output);
  8068. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8069. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8070. clif_displaymessage(fd, atcmd_output);
  8071. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8072. if( can_create ) {
  8073. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8074. clif_displaymessage(fd, atcmd_output);
  8075. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8076. }
  8077. //option setcolor
  8078. if(can_create){
  8079. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8080. clif_displaymessage(fd, atcmd_output);
  8081. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8082. }
  8083. //option join
  8084. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8085. clif_displaymessage(fd, atcmd_output);
  8086. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8087. //option leave
  8088. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8089. clif_displaymessage(fd, atcmd_output);
  8090. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8091. //option bindto
  8092. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8093. clif_displaymessage(fd, atcmd_output);
  8094. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8095. //option unbind
  8096. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8097. clif_displaymessage(fd, atcmd_output);
  8098. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8099. //option ban/unban/banlist
  8100. if( can_create ) {
  8101. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8102. clif_displaymessage(fd, atcmd_output);
  8103. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8104. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8105. clif_displaymessage(fd, atcmd_output);
  8106. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8107. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8108. clif_displaymessage(fd, atcmd_output);
  8109. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8110. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8111. clif_displaymessage(fd, atcmd_output);
  8112. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8113. }
  8114. //option setopt
  8115. if(can_create){
  8116. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8117. clif_displaymessage(fd, atcmd_output);
  8118. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8119. }
  8120. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8121. clif_displaymessage(fd, atcmd_output);
  8122. }
  8123. ACMD_FUNC(channel) {
  8124. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8125. sub1[0] = sub2[0] = '\0';
  8126. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8127. atcmd_channel_help(sd,command);
  8128. return 0;
  8129. }
  8130. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8131. return channel_pcdelete(sd,sub1);
  8132. } else if ( strcmpi(key,"list") == 0 ) {
  8133. return channel_display_list(sd,sub1);
  8134. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8135. return channel_pccolor(sd, sub1, sub2);
  8136. } else if ( strcmpi(key,"join") == 0 ) {
  8137. return channel_pcjoin(sd, sub1, sub2);
  8138. }else if ( strcmpi(key,"leave") == 0 ) {
  8139. return channel_pcleave(sd, sub1);
  8140. } else if ( strcmpi(key,"bindto") == 0 ) {
  8141. return channel_pcbind(sd, sub1);
  8142. } else if ( strcmpi(key,"unbind") == 0 ) {
  8143. return channel_pcunbind(sd);
  8144. } else if ( strcmpi(key,"ban") == 0 ) {
  8145. return channel_pcban(sd,sub1,sub2,0);
  8146. } else if ( strcmpi(key,"kick") == 0 ) {
  8147. return channel_pckick(sd,sub1,sub2);
  8148. } else if ( strcmpi(key,"banlist") == 0 ) {
  8149. return channel_pcban(sd,sub1,NULL,3);
  8150. } else if ( strcmpi(key,"unban") == 0 ) {
  8151. return channel_pcban(sd,sub1,sub2,1);
  8152. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8153. return channel_pcban(sd,sub1,NULL,2);
  8154. } else {
  8155. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8156. sub3[0] = sub4[0] = '\0';
  8157. sscanf(sub2, "%19s %19s", sub3, sub4);
  8158. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8159. if (sub4[0] != '\0') {
  8160. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8161. return -1;
  8162. }
  8163. return channel_pccreate(sd,sub1,sub3);
  8164. } else if ( strcmpi(key,"setopt") == 0 ) {
  8165. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8166. }
  8167. atcmd_channel_help(sd,command);
  8168. }
  8169. return 0;
  8170. }
  8171. ACMD_FUNC(fontcolor)
  8172. {
  8173. if( !message || !*message ) {
  8174. channel_display_list(sd,"colors");
  8175. return -1;
  8176. }
  8177. if( strcmpi(message,"Normal") == 0 ) {
  8178. sd->fontcolor = 0;
  8179. } else {
  8180. unsigned char k;
  8181. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8182. if( k == channel_config.colors_count ) {
  8183. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8184. clif_displaymessage(fd, atcmd_output);
  8185. return -1;
  8186. }
  8187. sd->fontcolor = k;
  8188. }
  8189. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8190. clif_displaymessage(fd, atcmd_output);
  8191. return 0;
  8192. }
  8193. ACMD_FUNC(langtype)
  8194. {
  8195. char langstr[8];
  8196. int i=0, fail=0;
  8197. memset(langstr, '\0', sizeof(langstr));
  8198. if(sscanf(message, "%3s", langstr) >= 1){
  8199. int lang=0;
  8200. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8201. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8202. char output[100];
  8203. pc_setaccountreg(sd, add_str("#langtype"), lang); //For login/char
  8204. sd->langtype = lang;
  8205. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8206. clif_displaymessage(fd,output);
  8207. return 0;
  8208. } else if (lang != -1) { //defined langage but failed check
  8209. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8210. return -1;
  8211. }
  8212. }
  8213. //wrong or no entry
  8214. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8215. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8216. while(fail != -1){ //out of range
  8217. fail = msg_checklangtype(i,false);
  8218. if(fail == 1)
  8219. clif_displaymessage(fd,msg_langtype2langstr(i));
  8220. i++;
  8221. }
  8222. return -1;
  8223. }
  8224. #ifdef VIP_ENABLE
  8225. ACMD_FUNC(vip) {
  8226. struct map_session_data *pl_sd = NULL;
  8227. char * modif_p;
  8228. int32 vipdifftime = 0;
  8229. time_t now=time(NULL);
  8230. nullpo_retr(-1, sd);
  8231. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8232. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8233. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8234. return -1;
  8235. }
  8236. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8237. modif_p = atcmd_output;
  8238. vipdifftime = (int32)solve_time(modif_p);
  8239. if (vipdifftime == 0) {
  8240. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8241. 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.
  8242. return -1;
  8243. }
  8244. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8245. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8246. return -1;
  8247. }
  8248. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8249. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8250. return -1;
  8251. }
  8252. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8253. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8254. if (pl_sd->vip.time <= now) {
  8255. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8256. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8257. } else {
  8258. int year,month,day,hour,minute,second;
  8259. char timestr[21];
  8260. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8261. 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.
  8262. clif_displaymessage(pl_sd->fd,atcmd_output);
  8263. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8264. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8265. clif_displaymessage(pl_sd->fd,atcmd_output);
  8266. if (pl_sd != sd) {
  8267. 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.
  8268. clif_displaymessage(fd,atcmd_output);
  8269. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8270. clif_displaymessage(fd,atcmd_output);
  8271. }
  8272. }
  8273. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8274. return 0;
  8275. }
  8276. /** Enable/disable rate info */
  8277. ACMD_FUNC(showrate) {
  8278. nullpo_retr(-1,sd);
  8279. if (!sd->vip.disableshowrate) {
  8280. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8281. sd->vip.disableshowrate = 1;
  8282. } else {
  8283. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8284. sd->vip.disableshowrate = 0;
  8285. }
  8286. clif_displaymessage(fd,atcmd_output);
  8287. return 0;
  8288. }
  8289. #endif
  8290. ACMD_FUNC(fullstrip) {
  8291. int i;
  8292. TBL_PC *tsd;
  8293. nullpo_retr(-1,sd);
  8294. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8295. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8296. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8297. return -1;
  8298. }
  8299. if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
  8300. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8301. return -1;
  8302. }
  8303. for( i = 0; i < EQI_MAX; i++ ) {
  8304. if( tsd->equip_index[ i ] >= 0 )
  8305. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8306. }
  8307. return 0;
  8308. }
  8309. ACMD_FUNC(costume) {
  8310. const char* names[] = {
  8311. "Wedding",
  8312. "Xmas",
  8313. "Summer",
  8314. "Summer2"
  8315. "Hanbok",
  8316. "Oktoberfest",
  8317. };
  8318. const int name2id[] = {
  8319. SC_WEDDING,
  8320. SC_XMAS,
  8321. SC_SUMMER,
  8322. SC_DRESSUP,
  8323. SC_HANBOK,
  8324. SC_OKTOBERFEST
  8325. };
  8326. unsigned short k = 0, len = ARRAYLENGTH(names);
  8327. if( !message || !*message ) {
  8328. for( k = 0; k < len; k++ ) {
  8329. if( sd->sc.data[name2id[k]] ) {
  8330. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8331. clif_displaymessage(sd->fd, atcmd_output);
  8332. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8333. return 0;
  8334. }
  8335. }
  8336. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8337. for( k = 0; k < len; k++ ) {
  8338. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8339. clif_displaymessage(sd->fd, atcmd_output);
  8340. }
  8341. return -1;
  8342. }
  8343. for( k = 0; k < len; k++ ) {
  8344. if( sd->sc.data[name2id[k]] ) {
  8345. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8346. clif_displaymessage(sd->fd, atcmd_output);
  8347. return -1;
  8348. }
  8349. }
  8350. for( k = 0; k < len; k++ )
  8351. if( strcmpi(message, names[k]) == 0 )
  8352. break;
  8353. if( k == len ) {
  8354. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8355. clif_displaymessage(sd->fd, atcmd_output);
  8356. return -1;
  8357. }
  8358. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, -1);
  8359. return 0;
  8360. }
  8361. /**
  8362. * Clone other player's equipments
  8363. * Usage: @cloneequip <char name/ID>
  8364. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8365. * @author [Cydh], [Antares]
  8366. */
  8367. ACMD_FUNC(cloneequip) {
  8368. struct map_session_data *pl_sd;
  8369. nullpo_retr(-1, sd);
  8370. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8371. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8372. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8373. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8374. clif_displaymessage(fd, atcmd_output);
  8375. return -1;
  8376. }
  8377. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8378. clif_displaymessage(fd, msg_txt(sd, 3));
  8379. return -1;
  8380. }
  8381. if (sd == pl_sd) {
  8382. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8383. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8384. clif_displaymessage(fd, atcmd_output);
  8385. return -1;
  8386. }
  8387. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8388. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8389. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8390. clif_displaymessage(fd, atcmd_output);
  8391. return -1;
  8392. }
  8393. else {
  8394. int8 i;
  8395. for (i = 0; i < EQI_MAX; i++) {
  8396. short idx;
  8397. char flag = 0;
  8398. struct item tmp_item;
  8399. if ((idx = pl_sd->equip_index[i]) < 0)
  8400. continue;
  8401. if (i == EQI_AMMO)
  8402. continue;
  8403. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8404. continue;
  8405. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8406. if (itemdb_isspecial(tmp_item.card[0]))
  8407. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8408. tmp_item.bound = 0;
  8409. tmp_item.expire_time = 0;
  8410. tmp_item.unique_id = 0;
  8411. tmp_item.favorite = 0;
  8412. tmp_item.amount = 1;
  8413. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8414. clif_additem(sd, 0, 0, flag);
  8415. else
  8416. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8417. }
  8418. }
  8419. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8420. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8421. clif_displaymessage(fd, atcmd_output);
  8422. return 0;
  8423. }
  8424. /**
  8425. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8426. * Usage: @clonestat <char name/ID>
  8427. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8428. * @author [Cydh], [Antares]
  8429. */
  8430. ACMD_FUNC(clonestat) {
  8431. struct map_session_data *pl_sd;
  8432. nullpo_retr(-1, sd);
  8433. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8434. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8435. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8436. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8437. clif_displaymessage(fd, atcmd_output);
  8438. return -1;
  8439. }
  8440. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8441. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8442. return -1;
  8443. }
  8444. if (sd == pl_sd) {
  8445. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8446. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8447. clif_displaymessage(fd, atcmd_output);
  8448. return -1;
  8449. }
  8450. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8451. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8452. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8453. clif_displaymessage(fd, atcmd_output);
  8454. return -1;
  8455. }
  8456. else {
  8457. uint8 i;
  8458. short max_status[6];
  8459. pc_resetstate(sd);
  8460. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8461. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8462. else {
  8463. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8464. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8465. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8466. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8467. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8468. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8469. }
  8470. #define clonestat_check(cmd,stat)\
  8471. {\
  8472. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8473. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8474. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8475. clif_displaymessage(fd, atcmd_output);\
  8476. sd->status.cmd = max_status[(stat)];\
  8477. }\
  8478. else\
  8479. sd->status.cmd = pl_sd->status.cmd;\
  8480. }
  8481. clonestat_check(str, PARAM_STR);
  8482. clonestat_check(agi, PARAM_AGI);
  8483. clonestat_check(vit, PARAM_VIT);
  8484. clonestat_check(int_, PARAM_INT);
  8485. clonestat_check(dex, PARAM_DEX);
  8486. clonestat_check(luk, PARAM_LUK);
  8487. for (i = 0; i < PARAM_MAX; i++) {
  8488. clif_updatestatus(sd, SP_STR + i);
  8489. clif_updatestatus(sd, SP_USTR + i);
  8490. }
  8491. status_calc_pc(sd, SCO_FORCE);
  8492. }
  8493. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8494. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  8495. clif_displaymessage(fd, atcmd_output);
  8496. #undef clonestat_check
  8497. return 0;
  8498. }
  8499. /**
  8500. * Adopt a character.
  8501. * Usage: @adopt <char name>
  8502. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8503. */
  8504. ACMD_FUNC(adopt)
  8505. {
  8506. TBL_PC *b_sd;
  8507. enum adopt_responses response;
  8508. nullpo_retr(-1, sd);
  8509. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8510. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8511. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8512. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8513. clif_displaymessage(fd, atcmd_output);
  8514. return -1;
  8515. }
  8516. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8517. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8518. return -1;
  8519. }
  8520. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8521. if (response == ADOPT_ALLOWED) {
  8522. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8523. b_sd->adopt_invite = sd->status.account_id;
  8524. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8525. return 0;
  8526. }
  8527. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8528. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8529. return -1;
  8530. }
  8531. #include "../custom/atcommand.inc"
  8532. /**
  8533. * Fills the reference of available commands in atcommand DBMap
  8534. **/
  8535. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8536. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8537. // Define with restriction
  8538. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8539. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8540. void atcommand_basecommands(void) {
  8541. /**
  8542. * Command reference list, place the base of your commands here
  8543. * TODO: List all commands that causing crash
  8544. **/
  8545. AtCommandInfo atcommand_base[] = {
  8546. #include "../custom/atcommand_def.inc"
  8547. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8548. ACMD_DEF(where),
  8549. ACMD_DEF(jumpto),
  8550. ACMD_DEF(jump),
  8551. ACMD_DEF(who),
  8552. ACMD_DEF2("who2", who),
  8553. ACMD_DEF2("who3", who),
  8554. ACMD_DEF2("whomap", who),
  8555. ACMD_DEF2("whomap2", who),
  8556. ACMD_DEF2("whomap3", who),
  8557. ACMD_DEF(whogm),
  8558. ACMD_DEF(save),
  8559. ACMD_DEF(load),
  8560. ACMD_DEF(speed),
  8561. ACMD_DEF(storage),
  8562. ACMD_DEF(guildstorage),
  8563. ACMD_DEF(option),
  8564. ACMD_DEF(hide), // + /hide
  8565. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8566. ACMD_DEF(kill),
  8567. ACMD_DEF(alive),
  8568. ACMD_DEF(kami),
  8569. ACMD_DEF2("kamib", kami),
  8570. ACMD_DEF2("kamic", kami),
  8571. ACMD_DEF2("lkami", kami),
  8572. ACMD_DEF(heal),
  8573. ACMD_DEF(item),
  8574. ACMD_DEF(item2),
  8575. ACMD_DEF2("itembound",item),
  8576. ACMD_DEF2("itembound2",item2),
  8577. ACMD_DEF(itemreset),
  8578. ACMD_DEF(clearstorage),
  8579. ACMD_DEF(cleargstorage),
  8580. ACMD_DEF(clearcart),
  8581. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8582. ACMD_DEF2("jlvl", joblevelup),
  8583. ACMD_DEF(help),
  8584. ACMD_DEF(pvpoff),
  8585. ACMD_DEF(pvpon),
  8586. ACMD_DEF(gvgoff),
  8587. ACMD_DEF(gvgon),
  8588. ACMD_DEF(model),
  8589. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8590. ACMD_DEF(monster),
  8591. ACMD_DEF2("monstersmall", monster),
  8592. ACMD_DEF2("monsterbig", monster),
  8593. ACMD_DEF(killmonster),
  8594. ACMD_DEF2("killmonster2", killmonster),
  8595. ACMD_DEF(refine),
  8596. ACMD_DEF(produce),
  8597. ACMD_DEF(memo),
  8598. ACMD_DEF(gat),
  8599. ACMD_DEF(displaystatus),
  8600. ACMD_DEF2("stpoint", statuspoint),
  8601. ACMD_DEF2("skpoint", skillpoint),
  8602. ACMD_DEF(zeny),
  8603. ACMD_DEF2("str", param),
  8604. ACMD_DEF2("agi", param),
  8605. ACMD_DEF2("vit", param),
  8606. ACMD_DEF2("int", param),
  8607. ACMD_DEF2("dex", param),
  8608. ACMD_DEF2("luk", param),
  8609. ACMD_DEF2("glvl", guildlevelup),
  8610. ACMD_DEF(makeegg),
  8611. ACMD_DEF(hatch),
  8612. ACMD_DEF(petfriendly),
  8613. ACMD_DEF(pethungry),
  8614. ACMD_DEF(petrename),
  8615. ACMD_DEF(recall), // + /recall
  8616. ACMD_DEF(night),
  8617. ACMD_DEF(day),
  8618. ACMD_DEF(doom),
  8619. ACMD_DEF(doommap),
  8620. ACMD_DEF(raise),
  8621. ACMD_DEF(raisemap),
  8622. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8623. ACMD_DEF(kickall),
  8624. ACMD_DEF(allskill),
  8625. ACMD_DEF(questskill),
  8626. ACMD_DEF(lostskill),
  8627. ACMD_DEF(spiritball),
  8628. ACMD_DEF(party),
  8629. ACMD_DEF(guild),
  8630. ACMD_DEF(breakguild),
  8631. ACMD_DEF(agitstart),
  8632. ACMD_DEF(agitend),
  8633. ACMD_DEF(mapexit),
  8634. ACMD_DEF(idsearch),
  8635. ACMD_DEF(broadcast), // + /b and /nb
  8636. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8637. ACMD_DEF(recallall),
  8638. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8639. ACMD_DEF2("reloaditemdb", reload),
  8640. ACMD_DEF2("reloadmobdb", reload),
  8641. ACMD_DEF2("reloadskilldb", reload),
  8642. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8643. ACMD_DEF2("reloadatcommand", reload),
  8644. ACMD_DEF2("reloadbattleconf", reload),
  8645. ACMD_DEF2("reloadstatusdb", reload),
  8646. ACMD_DEF2("reloadpcdb", reload),
  8647. ACMD_DEF2("reloadmotd", reload),
  8648. ACMD_DEF2("reloadquestdb", reload),
  8649. ACMD_DEF2("reloadmsgconf", reload),
  8650. ACMD_DEF2("reloadinstancedb", reload),
  8651. ACMD_DEF2("reloadachievementdb",reload),
  8652. ACMD_DEF(partysharelvl),
  8653. ACMD_DEF(mapinfo),
  8654. ACMD_DEF(dye),
  8655. ACMD_DEF2("hairstyle", hair_style),
  8656. ACMD_DEF2("haircolor", hair_color),
  8657. ACMD_DEF2("allstats", stat_all),
  8658. ACMD_DEF2("block", char_block),
  8659. ACMD_DEF2("ban", char_ban),
  8660. ACMD_DEF2("unblock", char_unblock),
  8661. ACMD_DEF2("unban", char_unban),
  8662. ACMD_DEF2("charban", char_ban),
  8663. ACMD_DEF2("charunban", char_unban),
  8664. ACMD_DEF2("mount", mount_peco),
  8665. ACMD_DEF(guildspy),
  8666. ACMD_DEF(partyspy),
  8667. ACMD_DEF(clanspy),
  8668. ACMD_DEF(repairall),
  8669. ACMD_DEF(guildrecall),
  8670. ACMD_DEF(partyrecall),
  8671. ACMD_DEF(nuke),
  8672. ACMD_DEF(shownpc),
  8673. ACMD_DEF(hidenpc),
  8674. ACMD_DEF(loadnpc),
  8675. ACMD_DEF(unloadnpc),
  8676. ACMD_DEF(reloadnpcfile),
  8677. ACMD_DEF2("time", servertime),
  8678. ACMD_DEF(jail),
  8679. ACMD_DEF(unjail),
  8680. ACMD_DEF(jailfor),
  8681. ACMD_DEF(jailtime),
  8682. ACMD_DEF(disguise),
  8683. ACMD_DEF(undisguise),
  8684. ACMD_DEF(email),
  8685. ACMD_DEF(effect),
  8686. ACMD_DEF(follow),
  8687. ACMD_DEF(addwarp),
  8688. ACMD_DEF(skillon),
  8689. ACMD_DEF(skilloff),
  8690. ACMD_DEF(killer),
  8691. ACMD_DEF(npcmove),
  8692. ACMD_DEF(killable),
  8693. ACMD_DEF(dropall),
  8694. ACMD_DEF(storeall),
  8695. ACMD_DEF(skillid),
  8696. ACMD_DEF(useskill),
  8697. ACMD_DEF(displayskill),
  8698. ACMD_DEF(snow),
  8699. ACMD_DEF(sakura),
  8700. ACMD_DEF(clouds),
  8701. ACMD_DEF(clouds2),
  8702. ACMD_DEF(fog),
  8703. ACMD_DEF(fireworks),
  8704. ACMD_DEF(leaves),
  8705. ACMD_DEF(summon),
  8706. ACMD_DEF(adjgroup),
  8707. ACMD_DEF(trade),
  8708. ACMD_DEF(send),
  8709. ACMD_DEF(setbattleflag),
  8710. ACMD_DEF(unmute),
  8711. ACMD_DEF(clearweather),
  8712. ACMD_DEF(uptime),
  8713. ACMD_DEF(changesex),
  8714. ACMD_DEF(changecharsex),
  8715. ACMD_DEF(mute),
  8716. ACMD_DEF(refresh),
  8717. ACMD_DEF(refreshall),
  8718. ACMD_DEF(identify),
  8719. ACMD_DEF(identifyall),
  8720. ACMD_DEF(gmotd),
  8721. ACMD_DEF(misceffect),
  8722. ACMD_DEF(mobsearch),
  8723. ACMD_DEF(cleanmap),
  8724. ACMD_DEF(cleanarea),
  8725. ACMD_DEF(npctalk),
  8726. ACMD_DEF(pettalk),
  8727. ACMD_DEF(users),
  8728. ACMD_DEF(reset),
  8729. ACMD_DEF(skilltree),
  8730. ACMD_DEF(marry),
  8731. ACMD_DEF(divorce),
  8732. ACMD_DEF(sound),
  8733. ACMD_DEF(undisguiseall),
  8734. ACMD_DEF(disguiseall),
  8735. ACMD_DEF(changelook),
  8736. ACMD_DEF(autoloot),
  8737. ACMD_DEF2("alootid", autolootitem),
  8738. ACMD_DEF(autoloottype),
  8739. ACMD_DEF(mobinfo),
  8740. ACMD_DEF(exp),
  8741. ACMD_DEF(version),
  8742. ACMD_DEF(mutearea),
  8743. ACMD_DEF(rates),
  8744. ACMD_DEF(iteminfo),
  8745. ACMD_DEF(whodrops),
  8746. ACMD_DEF(whereis),
  8747. ACMD_DEF(mapflag),
  8748. ACMD_DEF(me),
  8749. ACMD_DEF(monsterignore),
  8750. ACMD_DEF(fakename),
  8751. ACMD_DEF(size),
  8752. ACMD_DEF(showexp),
  8753. ACMD_DEF(showzeny),
  8754. ACMD_DEF(showdelay),
  8755. ACMD_DEF(autotrade),
  8756. ACMD_DEF(changegm),
  8757. ACMD_DEF(changeleader),
  8758. ACMD_DEF(partyoption),
  8759. ACMD_DEF(invite),
  8760. ACMD_DEF(duel),
  8761. ACMD_DEF(leave),
  8762. ACMD_DEF(accept),
  8763. ACMD_DEF(reject),
  8764. ACMD_DEF(clone),
  8765. ACMD_DEF2("slaveclone", clone),
  8766. ACMD_DEF2("evilclone", clone),
  8767. ACMD_DEF(tonpc),
  8768. ACMD_DEF(commands),
  8769. ACMD_DEF(noask),
  8770. ACMD_DEF(request),
  8771. ACMD_DEF(homlevel),
  8772. ACMD_DEF(homevolution),
  8773. ACMD_DEF(hommutate),
  8774. ACMD_DEF(makehomun),
  8775. ACMD_DEF(homfriendly),
  8776. ACMD_DEF(homhungry),
  8777. ACMD_DEF(homtalk),
  8778. ACMD_DEF(hominfo),
  8779. ACMD_DEF(homstats),
  8780. ACMD_DEF(homshuffle),
  8781. ACMD_DEF(showmobs),
  8782. ACMD_DEF(feelreset),
  8783. ACMD_DEF(auction),
  8784. ACMD_DEF(mail),
  8785. ACMD_DEF2("noks", ksprotection),
  8786. ACMD_DEF(allowks),
  8787. ACMD_DEF(cash),
  8788. ACMD_DEF2("points", cash),
  8789. ACMD_DEF(agitstart2),
  8790. ACMD_DEF(agitend2),
  8791. ACMD_DEF(resetskill),
  8792. ACMD_DEF(resetstat),
  8793. ACMD_DEF2("storagelist", itemlist),
  8794. ACMD_DEF2("cartlist", itemlist),
  8795. ACMD_DEF2("itemlist", itemlist),
  8796. ACMD_DEF(stats),
  8797. ACMD_DEF(delitem),
  8798. ACMD_DEF(charcommands),
  8799. ACMD_DEF(font),
  8800. ACMD_DEF(accinfo),
  8801. ACMD_DEF(set),
  8802. ACMD_DEF(undisguiseguild),
  8803. ACMD_DEF(disguiseguild),
  8804. ACMD_DEF(sizeall),
  8805. ACMD_DEF(sizeguild),
  8806. ACMD_DEF(addperm),
  8807. ACMD_DEF2("rmvperm", addperm),
  8808. ACMD_DEF(unloadnpcfile),
  8809. ACMD_DEF(cart),
  8810. ACMD_DEF(mount2),
  8811. ACMD_DEF(join),
  8812. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  8813. ACMD_DEF(fontcolor),
  8814. ACMD_DEF(langtype),
  8815. #ifdef VIP_ENABLE
  8816. ACMD_DEF(vip),
  8817. ACMD_DEF(showrate),
  8818. #endif
  8819. ACMD_DEF(fullstrip),
  8820. ACMD_DEF(costume),
  8821. ACMD_DEF(cloneequip),
  8822. ACMD_DEF(clonestat),
  8823. ACMD_DEF(bodystyle),
  8824. ACMD_DEF(adopt),
  8825. ACMD_DEF(agitstart3),
  8826. ACMD_DEF(agitend3),
  8827. };
  8828. AtCommandInfo* atcommand;
  8829. int i;
  8830. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8831. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8832. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8833. continue;
  8834. }
  8835. CREATE(atcommand, AtCommandInfo, 1);
  8836. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8837. atcommand->func = atcommand_base[i].func;
  8838. atcommand->restriction = atcommand_base[i].restriction;
  8839. strdb_put(atcommand_db, atcommand->command, atcommand);
  8840. }
  8841. return;
  8842. }
  8843. /*==========================================
  8844. * Command lookup functions
  8845. *------------------------------------------*/
  8846. bool atcommand_exists(const char* name)
  8847. {
  8848. return strdb_exists(atcommand_db, name);
  8849. }
  8850. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8851. {
  8852. if (strdb_exists(atcommand_db, name))
  8853. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8854. return NULL;
  8855. }
  8856. static const char* atcommand_checkalias(const char *aliasname)
  8857. {
  8858. AliasInfo *alias_info = NULL;
  8859. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8860. return alias_info->command->command;
  8861. return aliasname;
  8862. }
  8863. /// AtCommand suggestion
  8864. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8865. DBIterator* atcommand_iter;
  8866. DBIterator* alias_iter;
  8867. AtCommandInfo* command_info = NULL;
  8868. AliasInfo* alias_info = NULL;
  8869. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8870. char* full_match[MAX_SUGGESTIONS];
  8871. char* suggestions[MAX_SUGGESTIONS];
  8872. char* match;
  8873. int prefix_count = 0, full_count = 0;
  8874. bool can_use;
  8875. if (!battle_config.atcommand_suggestions_enabled)
  8876. return;
  8877. atcommand_iter = db_iterator(atcommand_db);
  8878. alias_iter = db_iterator(atcommand_alias_db);
  8879. // Build the matches
  8880. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8881. match = strstr(command_info->command, name);
  8882. can_use = pc_can_use_command(sd, command_info->command, type);
  8883. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8884. suggestions[prefix_count] = command_info->command;
  8885. ++prefix_count;
  8886. }
  8887. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8888. full_match[full_count] = command_info->command;
  8889. ++full_count;
  8890. }
  8891. }
  8892. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8893. match = strstr(alias_info->alias, name);
  8894. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8895. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8896. suggestions[prefix_count] = alias_info->alias;
  8897. ++prefix_count;
  8898. }
  8899. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8900. full_match[full_count] = alias_info->alias;
  8901. ++full_count;
  8902. }
  8903. }
  8904. if ((full_count+prefix_count) > 0) {
  8905. char buffer[512];
  8906. int i;
  8907. // Merge full match and prefix match results
  8908. if (prefix_count < MAX_SUGGESTIONS) {
  8909. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8910. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8911. }
  8912. // Build the suggestion string
  8913. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  8914. strcat(buffer,"\n");
  8915. for(i=0; i < prefix_count; ++i) {
  8916. strcat(buffer,suggestions[i]);
  8917. strcat(buffer," ");
  8918. }
  8919. clif_displaymessage(sd->fd, buffer);
  8920. }
  8921. dbi_destroy(atcommand_iter);
  8922. dbi_destroy(alias_iter);
  8923. }
  8924. /**
  8925. * Executes an at-command
  8926. * @param fd
  8927. * @param sd
  8928. * @param message
  8929. * @param type
  8930. * 0 : script call (atcommand)
  8931. * 1 : normal player @atcommand
  8932. * 2 : console (admin:@atcommand)
  8933. * 3 : script call (useatcmd)
  8934. */
  8935. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8936. {
  8937. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8938. char output[CHAT_SIZE_MAX];
  8939. //Reconstructed message
  8940. char atcmd_msg[CHAT_SIZE_MAX];
  8941. TBL_PC * ssd = NULL; //sd for target
  8942. AtCommandInfo * info;
  8943. bool is_atcommand = true; // false if it's a charcommand
  8944. nullpo_retr(false, sd);
  8945. //Shouldn't happen
  8946. if ( !message || !*message )
  8947. return false;
  8948. //If cannot use atcomamnd while talking with NPC [Kichi]
  8949. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8950. return false;
  8951. //Block NOCHAT but do not display it as a normal message
  8952. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8953. return true;
  8954. // skip 10/11-langtype's codepage indicator, if detected
  8955. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8956. message += 3;
  8957. //Should display as a normal message
  8958. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8959. return false;
  8960. // type value 0|2 = script|console invoked: bypass restrictions
  8961. if ( type == 1 || type == 3) {
  8962. //Commands are disabled on maps flagged as 'nocommand'
  8963. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8964. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  8965. return false;
  8966. }
  8967. }
  8968. if (*message == charcommand_symbol)
  8969. is_atcommand = false;
  8970. if (is_atcommand) { // @command
  8971. sprintf(atcmd_msg, "%s", message);
  8972. ssd = sd;
  8973. } else { // #command
  8974. char charname[NAME_LENGTH];
  8975. int n;
  8976. //Checks to see if #command has a name or a name + parameters.
  8977. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  8978. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  8979. ) {
  8980. if (pc_get_group_level(sd) == 0) {
  8981. if (n < 1)
  8982. return false; // No command found. Display as normal message.
  8983. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8984. 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
  8985. return false;
  8986. }
  8987. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8988. clif_displaymessage(fd, output);
  8989. return true;
  8990. }
  8991. ssd = map_nick2sd(charname,true);
  8992. if (ssd == NULL) {
  8993. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8994. clif_displaymessage(fd, output);
  8995. return true;
  8996. }
  8997. if (n > 2)
  8998. sprintf(atcmd_msg, "%s %s", command, params);
  8999. else
  9000. sprintf(atcmd_msg, "%s", command);
  9001. }
  9002. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9003. sd->idletime = last_tick;
  9004. //Clearing these to be used once more.
  9005. memset(command, '\0', sizeof(command));
  9006. memset(params, '\0', sizeof(params));
  9007. //check to see if any params exist within this command
  9008. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9009. params[0] = '\0';
  9010. // @commands (script based)
  9011. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9012. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9013. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  9014. if( binding != NULL && binding->npc_event[0] &&
  9015. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9016. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9017. {
  9018. // Check if self or character invoking; if self == character invoked, then self invoke.
  9019. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9020. return true;
  9021. }
  9022. }
  9023. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9024. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9025. if (info == NULL) {
  9026. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9027. return false;
  9028. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9029. clif_displaymessage(fd, output);
  9030. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9031. return true;
  9032. }
  9033. //check restriction
  9034. if (info->restriction) {
  9035. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9036. return true;
  9037. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9038. return true;
  9039. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9040. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9041. return true;
  9042. }
  9043. // type == 1 : player invoked
  9044. if (type == 1) {
  9045. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9046. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9047. return false;
  9048. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9049. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9050. return true;
  9051. }
  9052. }
  9053. //Attempt to use the command
  9054. if ( (info->func(fd, ssd, command, params) != 0) )
  9055. {
  9056. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9057. clif_displaymessage(fd, output);
  9058. return true;
  9059. }
  9060. //Log only if successful.
  9061. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9062. return true;
  9063. }
  9064. /*==========================================
  9065. *
  9066. *------------------------------------------*/
  9067. static void atcommand_config_read(const char* config_filename)
  9068. {
  9069. config_setting_t *aliases = NULL, *help = NULL;
  9070. const char *symbol = NULL;
  9071. int num_aliases = 0;
  9072. if (conf_read_file(&atcommand_config, config_filename))
  9073. return;
  9074. // Command symbols
  9075. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  9076. if (ISPRINT(*symbol) && // no control characters
  9077. *symbol != '/' && // symbol of client commands
  9078. *symbol != '%' && // symbol of party chat
  9079. *symbol != '$' && // symbol of guild chat
  9080. *symbol != charcommand_symbol)
  9081. atcommand_symbol = *symbol;
  9082. }
  9083. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  9084. if (ISPRINT(*symbol) && // no control characters
  9085. *symbol != '/' && // symbol of client commands
  9086. *symbol != '%' && // symbol of party chat
  9087. *symbol != '$' && // symbol of guild chat
  9088. *symbol != atcommand_symbol)
  9089. charcommand_symbol = *symbol;
  9090. }
  9091. // Command aliases
  9092. aliases = config_lookup(&atcommand_config, "aliases");
  9093. if (aliases != NULL) {
  9094. int i = 0;
  9095. int count = config_setting_length(aliases);
  9096. for (i = 0; i < count; ++i) {
  9097. config_setting_t *command;
  9098. const char *commandname = NULL;
  9099. int j = 0, alias_count = 0;
  9100. AtCommandInfo *commandinfo = NULL;
  9101. command = config_setting_get_elem(aliases, i);
  9102. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  9103. continue;
  9104. commandname = config_setting_name(command);
  9105. if (!atcommand_exists(commandname)) {
  9106. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  9107. continue;
  9108. }
  9109. commandinfo = get_atcommandinfo_byname(commandname);
  9110. alias_count = config_setting_length(command);
  9111. for (j = 0; j < alias_count; ++j) {
  9112. const char *alias = config_setting_get_string_elem(command, j);
  9113. if (alias != NULL) {
  9114. AliasInfo *alias_info;
  9115. if (strdb_exists(atcommand_alias_db, alias)) {
  9116. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  9117. continue;
  9118. }
  9119. CREATE(alias_info, AliasInfo, 1);
  9120. alias_info->command = commandinfo;
  9121. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  9122. strdb_put(atcommand_alias_db, alias, alias_info);
  9123. ++num_aliases;
  9124. }
  9125. }
  9126. }
  9127. }
  9128. // Commands help
  9129. // We only check if all commands exist
  9130. help = config_lookup(&atcommand_config, "help");
  9131. if (help != NULL) {
  9132. int count = config_setting_length(help);
  9133. int i;
  9134. for (i = 0; i < count; ++i) {
  9135. config_setting_t *command;
  9136. const char *commandname;
  9137. command = config_setting_get_elem(help, i);
  9138. commandname = config_setting_name(command);
  9139. if (!atcommand_exists(commandname))
  9140. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  9141. }
  9142. }
  9143. ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' command aliases in '" CL_WHITE "%s" CL_RESET "'.\n", num_aliases, config_filename);
  9144. return;
  9145. }
  9146. void atcommand_db_load_groups(int* group_ids) {
  9147. DBIterator *iter = db_iterator(atcommand_db);
  9148. AtCommandInfo* cmd;
  9149. int i;
  9150. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9151. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9152. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9153. for(i = 0; i < pc_group_max; i++) {
  9154. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9155. cmd->at_groups[i] = 1;
  9156. else
  9157. cmd->at_groups[i] = 0;
  9158. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9159. cmd->char_groups[i] = 1;
  9160. else
  9161. cmd->char_groups[i] = 0;
  9162. }
  9163. }
  9164. dbi_destroy(iter);
  9165. return;
  9166. }
  9167. void atcommand_db_clear(void) {
  9168. if (atcommand_db != NULL) {
  9169. DBIterator *iter = db_iterator(atcommand_db);
  9170. AtCommandInfo* cmd;
  9171. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9172. aFree(cmd->at_groups);
  9173. aFree(cmd->char_groups);
  9174. }
  9175. dbi_destroy(iter);
  9176. db_destroy(atcommand_db);
  9177. }
  9178. if (atcommand_alias_db != NULL)
  9179. db_destroy(atcommand_alias_db);
  9180. config_destroy(&atcommand_config);
  9181. }
  9182. void atcommand_doload(void) {
  9183. atcommand_db_clear();
  9184. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9185. atcommand_alias_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9186. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9187. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9188. }
  9189. void do_init_atcommand(void) {
  9190. atcommand_doload();
  9191. }
  9192. void do_final_atcommand(void) {
  9193. atcommand_db_clear();
  9194. }