atcommand.c 317 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/showmsg.h"
  8. #include "../common/malloc.h"
  9. #include "../common/random.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "../common/conf.h"
  14. #include "map.h"
  15. #include "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "channel.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "instance.h"
  22. #include "intif.h"
  23. #include "pet.h"
  24. #include "homunculus.h"
  25. #include "mail.h"
  26. #include "mercenary.h"
  27. #include "elemental.h"
  28. #include "party.h"
  29. #include "script.h"
  30. #include "storage.h"
  31. #include "trade.h"
  32. #include "mapreg.h"
  33. #include "quest.h"
  34. #include "pc.h"
  35. #include <stdlib.h>
  36. #include <math.h>
  37. #define ATCOMMAND_LENGTH 50
  38. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  39. typedef struct AtCommandInfo AtCommandInfo;
  40. typedef struct AliasInfo AliasInfo;
  41. int atcmd_binding_count = 0;
  42. /// Atcommand restriction usage
  43. enum e_atcmd_restict {
  44. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  45. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  46. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  47. };
  48. struct AtCommandInfo {
  49. char command[ATCOMMAND_LENGTH];
  50. AtCommandFunc func;
  51. char* at_groups; /// Quick @commands "can-use" lookup
  52. char* char_groups; /// Quick @charcommands "can-use" lookup
  53. uint8 restriction; /// Restrictions see enum e_restict
  54. };
  55. struct AliasInfo {
  56. AtCommandInfo *command;
  57. char alias[ATCOMMAND_LENGTH];
  58. };
  59. char atcommand_symbol = '@'; // first char of the commands
  60. char charcommand_symbol = '#';
  61. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  62. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  63. static config_t atcommand_config;
  64. static char atcmd_output[CHAT_SIZE_MAX];
  65. static char atcmd_player_name[NAME_LENGTH];
  66. const char *parent_cmd;
  67. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  68. static const char* atcommand_checkalias(const char *aliasname); // @help
  69. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  70. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  71. // @commands (script-based)
  72. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  73. int i = 0;
  74. if( *name == atcommand_symbol || *name == charcommand_symbol )
  75. name++; // for backwards compatibility
  76. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  77. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  78. }
  79. /**
  80. * retrieves the help string associated with a given command.
  81. *
  82. * @param name the name of the command to retrieve help information for
  83. * @return the string associated with the command, or NULL
  84. */
  85. static const char* atcommand_help_string(const char* command)
  86. {
  87. const char* str = NULL;
  88. config_setting_t* info;
  89. if( *command == atcommand_symbol || *command == charcommand_symbol )
  90. {// remove the prefix symbol for the raw name of the command
  91. command ++;
  92. }
  93. // convert alias to the real command name
  94. command = atcommand_checkalias(command);
  95. // attempt to find the first default help command
  96. info = config_lookup(&atcommand_config, "help");
  97. if( info == NULL )
  98. {// failed to find the help property in the configuration file
  99. return NULL;
  100. }
  101. if( !config_setting_lookup_string( info, command, &str ) )
  102. {// failed to find the matching help string
  103. return NULL;
  104. }
  105. // push the result from the method
  106. return str;
  107. }
  108. /*==========================================
  109. * @send (used for testing packet sends from the client)
  110. *------------------------------------------*/
  111. ACMD_FUNC(send)
  112. {
  113. int len=0,type;
  114. // read message type as hex number (without the 0x)
  115. if(!message || !*message ||
  116. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  117. || sscanf(message, "%8x", &type)==1) )
  118. {
  119. int i;
  120. for (i = 900; i <= 903; ++i)
  121. clif_displaymessage(fd, msg_txt(sd,i));
  122. return -1;
  123. }
  124. #define PARSE_ERROR(error,p) \
  125. {\
  126. clif_displaymessage(fd, (error));\
  127. sprintf(atcmd_output, ">%s", (p));\
  128. clif_displaymessage(fd, atcmd_output);\
  129. }
  130. //define PARSE_ERROR
  131. #define CHECK_EOS(p) \
  132. if(*(p) == 0){\
  133. clif_displaymessage(fd, "Unexpected end of string");\
  134. return -1;\
  135. }
  136. //define CHECK_EOS
  137. #define SKIP_VALUE(p) \
  138. {\
  139. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  140. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  141. }
  142. //define SKIP_VALUE
  143. #define GET_VALUE(p,num) \
  144. {\
  145. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  146. PARSE_ERROR("Invalid number in:",(p));\
  147. return -1;\
  148. }\
  149. }
  150. //define GET_VALUE
  151. if (type > 0 && type < MAX_PACKET_DB) {
  152. int off,end;
  153. long num;
  154. if(len)
  155. {// show packet length
  156. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  157. clif_displaymessage(fd, atcmd_output);
  158. return 0;
  159. }
  160. len=packet_db[sd->packet_ver][type].len;
  161. off=2;
  162. if(len == 0)
  163. {// unknown packet - ERROR
  164. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  165. clif_displaymessage(fd, atcmd_output);
  166. return -1;
  167. } else if(len == -1)
  168. {// dynamic packet
  169. len=SHRT_MAX-4; // maximum length
  170. off=4;
  171. }
  172. WFIFOHEAD(fd, len);
  173. WFIFOW(fd,0)=TOW(type);
  174. // parse packet contents
  175. SKIP_VALUE(message);
  176. while(*message != 0 && off < len){
  177. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  178. {// default (byte)
  179. GET_VALUE(message,num);
  180. WFIFOB(fd,off)=TOB(num);
  181. ++off;
  182. } else if(TOUPPER(*message) == 'B')
  183. {// byte
  184. ++message;
  185. GET_VALUE(message,num);
  186. WFIFOB(fd,off)=TOB(num);
  187. ++off;
  188. } else if(TOUPPER(*message) == 'W')
  189. {// word (2 bytes)
  190. ++message;
  191. GET_VALUE(message,num);
  192. WFIFOW(fd,off)=TOW(num);
  193. off+=2;
  194. } else if(TOUPPER(*message) == 'L')
  195. {// long word (4 bytes)
  196. ++message;
  197. GET_VALUE(message,num);
  198. WFIFOL(fd,off)=TOL(num);
  199. off+=4;
  200. } else if(TOUPPER(*message) == 'S')
  201. {// string - escapes are valid
  202. // get string length - num <= 0 means not fixed length (default)
  203. ++message;
  204. if(*message == '"'){
  205. num=0;
  206. } else {
  207. GET_VALUE(message,num);
  208. while(*message != '"')
  209. {// find start of string
  210. if(*message == 0 || ISSPACE(*message)){
  211. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  212. return -1;
  213. }
  214. ++message;
  215. }
  216. }
  217. // parse string
  218. ++message;
  219. CHECK_EOS(message);
  220. end=(num<=0? 0: min(off+((int)num),len));
  221. for(; *message != '"' && (off < end || end == 0); ++off){
  222. if(*message == '\\'){
  223. ++message;
  224. CHECK_EOS(message);
  225. switch(*message){
  226. case 'a': num=0x07; break; // Bell
  227. case 'b': num=0x08; break; // Backspace
  228. case 't': num=0x09; break; // Horizontal tab
  229. case 'n': num=0x0A; break; // Line feed
  230. case 'v': num=0x0B; break; // Vertical tab
  231. case 'f': num=0x0C; break; // Form feed
  232. case 'r': num=0x0D; break; // Carriage return
  233. case 'e': num=0x1B; break; // Escape
  234. default: num=*message; break;
  235. case 'x': // Hexadecimal
  236. {
  237. ++message;
  238. CHECK_EOS(message);
  239. if(!ISXDIGIT(*message)){
  240. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  241. return -1;
  242. }
  243. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  244. if(ISXDIGIT(*message)){
  245. ++message;
  246. CHECK_EOS(message);
  247. num<<=8;
  248. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  249. }
  250. WFIFOB(fd,off)=TOB(num);
  251. ++message;
  252. CHECK_EOS(message);
  253. continue;
  254. }
  255. case '0':
  256. case '1':
  257. case '2':
  258. case '3':
  259. case '4':
  260. case '5':
  261. case '6':
  262. case '7': // Octal
  263. {
  264. num=*message-'0'; // 1st octal digit
  265. ++message;
  266. CHECK_EOS(message);
  267. if(ISDIGIT(*message) && *message < '8'){
  268. num<<=3;
  269. num+=*message-'0'; // 2nd octal digit
  270. ++message;
  271. CHECK_EOS(message);
  272. if(ISDIGIT(*message) && *message < '8'){
  273. num<<=3;
  274. num+=*message-'0'; // 3rd octal digit
  275. ++message;
  276. CHECK_EOS(message);
  277. }
  278. }
  279. WFIFOB(fd,off)=TOB(num);
  280. continue;
  281. }
  282. }
  283. } else
  284. num=*message;
  285. WFIFOB(fd,off)=TOB(num);
  286. ++message;
  287. CHECK_EOS(message);
  288. }//for
  289. while(*message != '"')
  290. {// ignore extra characters
  291. ++message;
  292. CHECK_EOS(message);
  293. }
  294. // terminate the string
  295. if(off < end)
  296. {// fill the rest with 0's
  297. memset(WFIFOP(fd,off),0,end-off);
  298. off=end;
  299. }
  300. } else
  301. {// unknown
  302. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  303. return -1;
  304. }
  305. SKIP_VALUE(message);
  306. }
  307. if(packet_db[sd->packet_ver][type].len == -1)
  308. {// send dynamic packet
  309. WFIFOW(fd,2)=TOW(off);
  310. WFIFOSET(fd,off);
  311. } else
  312. {// send static packet
  313. if(off < len)
  314. memset(WFIFOP(fd,off),0,len-off);
  315. WFIFOSET(fd,len);
  316. }
  317. } else {
  318. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  319. return -1;
  320. }
  321. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  322. clif_displaymessage(fd, atcmd_output);
  323. return 0;
  324. #undef PARSE_ERROR
  325. #undef CHECK_EOS
  326. #undef SKIP_VALUE
  327. #undef GET_VALUE
  328. }
  329. /**
  330. * Retrieves map name suggestions for a given string.
  331. * This will first check if any map names contain the given string, and will
  332. * print out MAX_SUGGESTIONS results if any maps are found.
  333. * Otherwise, suggestions will be calculated through Levenshtein distance,
  334. * and up to 5 of the closest matches will be printed.
  335. *
  336. * @author Euphy
  337. */
  338. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  339. char buffer[512];
  340. int i, count = 0;
  341. if (strlen(name) < 2)
  342. return;
  343. // build the suggestion string
  344. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  345. strcat(buffer, "\n");
  346. // check for maps that contain string
  347. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  348. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  349. strcat(buffer, map[i].name);
  350. strcat(buffer, " ");
  351. if (++count >= MAX_SUGGESTIONS)
  352. break;
  353. }
  354. }
  355. // if no maps found, search by edit distance
  356. if (!count) {
  357. unsigned int distance[MAX_MAP_PER_SERVER][2];
  358. int j;
  359. // calculate Levenshtein distance for all maps
  360. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  361. if (strlen(map[i].name) < 4) // invalid map name?
  362. distance[i][0] = INT_MAX;
  363. else {
  364. distance[i][0] = levenshtein(map[i].name, name);
  365. distance[i][1] = i;
  366. }
  367. }
  368. // selection sort elements as needed
  369. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  370. for (i = 0; i < count; i++) {
  371. int min = i;
  372. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  373. if (distance[j][0] < distance[min][0])
  374. min = j;
  375. }
  376. // print map name
  377. if (distance[min][0] > 4) { // awful results, don't bother
  378. if (!i) return;
  379. break;
  380. }
  381. strcat(buffer, map[distance[min][1]].name);
  382. strcat(buffer, " ");
  383. // swap elements
  384. swap(distance[i][0], distance[min][0]);
  385. swap(distance[i][1], distance[min][1]);
  386. }
  387. }
  388. clif_displaymessage(sd->fd, buffer);
  389. }
  390. /*==========================================
  391. * @rura, @warp, @mapmove
  392. *------------------------------------------*/
  393. ACMD_FUNC(mapmove)
  394. {
  395. char map_name[MAP_NAME_LENGTH_EXT];
  396. unsigned short mapindex;
  397. short x = 0, y = 0;
  398. int16 m = -1;
  399. nullpo_retr(-1, sd);
  400. memset(map_name, '\0', sizeof(map_name));
  401. if (!message || !*message ||
  402. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  403. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  404. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  405. return -1;
  406. }
  407. mapindex = mapindex_name2id(map_name);
  408. if (mapindex)
  409. m = map_mapindex2mapid(mapindex);
  410. if (!mapindex) { // m < 0 means on different server! [Kevin]
  411. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  412. if (battle_config.warp_suggestions_enabled)
  413. warp_get_suggestions(sd, map_name);
  414. return -1;
  415. }
  416. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  417. { //This is to prevent the pc_setpos call from printing an error.
  418. clif_displaymessage(fd, msg_txt(sd,2));
  419. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  420. x = y = 0; //Invalid cell, use random spot.
  421. }
  422. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  423. clif_displaymessage(fd, msg_txt(sd,247));
  424. return -1;
  425. }
  426. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  427. clif_displaymessage(fd, msg_txt(sd,248));
  428. return -1;
  429. }
  430. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  431. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  432. return -1;
  433. }
  434. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  435. return 0;
  436. }
  437. /*==========================================
  438. * Displays where a character is. Corrected version by Silent. [Skotlex]
  439. *------------------------------------------*/
  440. ACMD_FUNC(where)
  441. {
  442. struct map_session_data* pl_sd;
  443. nullpo_retr(-1, sd);
  444. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  445. if (!message || !*message || sscanf(message, "%23s[^\n]", atcmd_player_name) < 1) {
  446. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  447. return -1;
  448. }
  449. pl_sd = map_nick2sd(atcmd_player_name);
  450. if (pl_sd == NULL ||
  451. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  452. (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))
  453. ) {
  454. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  455. return -1;
  456. }
  457. 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);
  458. clif_displaymessage(fd, atcmd_output);
  459. return 0;
  460. }
  461. /*==========================================
  462. *
  463. *------------------------------------------*/
  464. ACMD_FUNC(jumpto)
  465. {
  466. struct map_session_data *pl_sd = NULL;
  467. nullpo_retr(-1, sd);
  468. if (!message || !*message) {
  469. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  470. return -1;
  471. }
  472. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  473. {
  474. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  475. return -1;
  476. }
  477. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  478. {
  479. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  480. return -1;
  481. }
  482. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  483. {
  484. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  485. return -1;
  486. }
  487. if( pc_isdead(sd) )
  488. {
  489. clif_displaymessage(fd, msg_txt(sd,664));
  490. return -1;
  491. }
  492. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  493. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  494. clif_displaymessage(fd, atcmd_output);
  495. return 0;
  496. }
  497. /*==========================================
  498. *
  499. *------------------------------------------*/
  500. ACMD_FUNC(jump)
  501. {
  502. short x = 0, y = 0;
  503. nullpo_retr(-1, sd);
  504. memset(atcmd_output, '\0', sizeof(atcmd_output));
  505. sscanf(message, "%6hd %6hd", &x, &y);
  506. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  507. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  508. return -1;
  509. }
  510. if( pc_isdead(sd) )
  511. {
  512. clif_displaymessage(fd, msg_txt(sd,664));
  513. return -1;
  514. }
  515. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  516. { //This is to prevent the pc_setpos call from printing an error.
  517. clif_displaymessage(fd, msg_txt(sd,2));
  518. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  519. x = y = 0; //Invalid cell, use random spot.
  520. }
  521. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  522. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  523. clif_displaymessage(fd, atcmd_output);
  524. return 0;
  525. }
  526. /*==========================================
  527. * Display list of online characters with
  528. * various info.
  529. *------------------------------------------*/
  530. ACMD_FUNC(who) {
  531. struct map_session_data *pl_sd = NULL;
  532. struct s_mapiterator *iter = NULL;
  533. char player_name[NAME_LENGTH] = "";
  534. int count = 0;
  535. int level = 0;
  536. StringBuf buf;
  537. /**
  538. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  539. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  540. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  541. */
  542. int display_type = 1;
  543. int map_id = -1;
  544. nullpo_retr(-1, sd);
  545. if (strstr(command, "map") != NULL) {
  546. char map_name[MAP_NAME_LENGTH_EXT] = "";
  547. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  548. map_id = sd->bl.m;
  549. } else {
  550. sscanf(message, "%23s", player_name);
  551. }
  552. if (strstr(command, "2") != NULL)
  553. display_type = 2;
  554. else if (strstr(command, "3") != NULL)
  555. display_type = 3;
  556. level = pc_get_group_level(sd);
  557. StringBuf_Init(&buf);
  558. iter = mapit_getallusers();
  559. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  560. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  561. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  562. || (map_id >= 0 && pl_sd->bl.m != map_id))
  563. continue;
  564. switch (display_type) {
  565. case 2: {
  566. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  567. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  568. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  569. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  570. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  571. break;
  572. }
  573. case 3: {
  574. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  575. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  576. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  577. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  578. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  579. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  580. break;
  581. }
  582. default: {
  583. struct party_data *p = party_search(pl_sd->status.party_id);
  584. struct guild *g = pl_sd->guild;
  585. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  586. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  587. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  588. if (p != NULL)
  589. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  590. if (g != NULL)
  591. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  592. break;
  593. }
  594. }
  595. clif_displaymessage(fd, StringBuf_Value(&buf));
  596. StringBuf_Clear(&buf);
  597. count++;
  598. }
  599. }
  600. mapit_free(iter);
  601. if (map_id < 0) {
  602. if (count == 0)
  603. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  604. else if (count == 1)
  605. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  606. else
  607. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  608. } else {
  609. if (count == 0)
  610. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  611. else if (count == 1)
  612. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  613. else
  614. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  615. }
  616. clif_displaymessage(fd, StringBuf_Value(&buf));
  617. StringBuf_Destroy(&buf);
  618. return 0;
  619. }
  620. /*==========================================
  621. *
  622. *------------------------------------------*/
  623. ACMD_FUNC(whogm)
  624. {
  625. struct map_session_data* pl_sd;
  626. struct s_mapiterator* iter;
  627. int j, count;
  628. int level;
  629. char match_text[CHAT_SIZE_MAX];
  630. char player_name[NAME_LENGTH];
  631. struct guild *g;
  632. struct party_data *p;
  633. nullpo_retr(-1, sd);
  634. memset(atcmd_output, '\0', sizeof(atcmd_output));
  635. memset(match_text, '\0', sizeof(match_text));
  636. memset(player_name, '\0', sizeof(player_name));
  637. if (sscanf(message, "%255[^\n]", match_text) < 1)
  638. strcpy(match_text, "");
  639. for (j = 0; match_text[j]; j++)
  640. match_text[j] = TOLOWER(match_text[j]);
  641. count = 0;
  642. level = pc_get_group_level(sd);
  643. iter = mapit_getallusers();
  644. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  645. {
  646. int pl_level = pc_get_group_level(pl_sd);
  647. if (!pl_level)
  648. continue;
  649. if (match_text[0])
  650. {
  651. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  652. for (j = 0; player_name[j]; j++)
  653. player_name[j] = TOLOWER(player_name[j]);
  654. // search with no case sensitive
  655. if (strstr(player_name, match_text) == NULL)
  656. continue;
  657. }
  658. if (pl_level > level) {
  659. if (pl_sd->sc.option & OPTION_INVISIBLE)
  660. continue;
  661. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  662. clif_displaymessage(fd, atcmd_output);
  663. count++;
  664. continue;
  665. }
  666. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  667. pl_sd->status.name, pl_level,
  668. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  669. clif_displaymessage(fd, atcmd_output);
  670. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  671. pl_sd->status.base_level,
  672. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  673. clif_displaymessage(fd, atcmd_output);
  674. p = party_search(pl_sd->status.party_id);
  675. g = pl_sd->guild;
  676. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  677. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  678. clif_displaymessage(fd, atcmd_output);
  679. count++;
  680. }
  681. mapit_free(iter);
  682. if (count == 0)
  683. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  684. else if (count == 1)
  685. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  686. else {
  687. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  688. clif_displaymessage(fd, atcmd_output);
  689. }
  690. return 0;
  691. }
  692. /*==========================================
  693. *
  694. *------------------------------------------*/
  695. ACMD_FUNC(save)
  696. {
  697. nullpo_retr(-1, sd);
  698. if( map[sd->bl.m].instance_id ) {
  699. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  700. return 1;
  701. }
  702. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  703. if (sd->status.pet_id > 0 && sd->pd)
  704. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  705. chrif_save(sd,0);
  706. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  707. return 0;
  708. }
  709. /*==========================================
  710. *
  711. *------------------------------------------*/
  712. ACMD_FUNC(load)
  713. {
  714. int16 m;
  715. nullpo_retr(-1, sd);
  716. m = map_mapindex2mapid(sd->status.save_point.map);
  717. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  718. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  719. return -1;
  720. }
  721. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  722. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  723. return -1;
  724. }
  725. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  726. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  727. return 0;
  728. }
  729. /*==========================================
  730. *
  731. *------------------------------------------*/
  732. ACMD_FUNC(speed)
  733. {
  734. short speed;
  735. nullpo_retr(-1, sd);
  736. memset(atcmd_output, '\0', sizeof(atcmd_output));
  737. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  738. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  739. clif_displaymessage(fd, atcmd_output);
  740. return -1;
  741. }
  742. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  743. if (speed < 0)
  744. sd->base_status.speed = DEFAULT_WALK_SPEED;
  745. else
  746. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  747. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  748. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  749. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  750. } else
  751. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  752. status_calc_bl(&sd->bl, SCB_SPEED);
  753. return 0;
  754. }
  755. /*==========================================
  756. *
  757. *------------------------------------------*/
  758. ACMD_FUNC(storage)
  759. {
  760. nullpo_retr(-1, sd);
  761. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  762. return -1;
  763. if (storage_storageopen(sd) == 1)
  764. { //Already open.
  765. clif_displaymessage(fd, msg_txt(sd,250));
  766. return -1;
  767. }
  768. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  769. return 0;
  770. }
  771. /*==========================================
  772. *
  773. *------------------------------------------*/
  774. ACMD_FUNC(guildstorage)
  775. {
  776. nullpo_retr(-1, sd);
  777. if (!sd->status.guild_id) {
  778. clif_displaymessage(fd, msg_txt(sd,252));
  779. return -1;
  780. }
  781. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  782. return -1;
  783. if (sd->state.storage_flag == 1) {
  784. clif_displaymessage(fd, msg_txt(sd,250));
  785. return -1;
  786. }
  787. if (sd->state.storage_flag == 2) {
  788. clif_displaymessage(fd, msg_txt(sd,251));
  789. return -1;
  790. }
  791. gstorage_storageopen(sd);
  792. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  793. return 0;
  794. }
  795. /*==========================================
  796. *
  797. *------------------------------------------*/
  798. ACMD_FUNC(option)
  799. {
  800. int param1 = 0, param2 = 0, param3 = 0;
  801. nullpo_retr(-1, sd);
  802. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  803. {// failed to match the parameters so inform the user of the options
  804. const char* text;
  805. // attempt to find the setting information for this command
  806. text = atcommand_help_string( command );
  807. // notify the user of the requirement to enter an option
  808. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  809. if( text )
  810. {// send the help text associated with this command
  811. clif_displaymessage( fd, text );
  812. }
  813. return -1;
  814. }
  815. sd->sc.opt1 = param1;
  816. sd->sc.opt2 = param2;
  817. pc_setoption(sd, param3);
  818. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  819. return 0;
  820. }
  821. /*==========================================
  822. *
  823. *------------------------------------------*/
  824. ACMD_FUNC(hide)
  825. {
  826. nullpo_retr(-1, sd);
  827. if (sd->sc.option & OPTION_INVISIBLE) {
  828. sd->sc.option &= ~OPTION_INVISIBLE;
  829. if (sd->disguise)
  830. status_set_viewdata(&sd->bl, sd->disguise);
  831. else
  832. status_set_viewdata(&sd->bl, sd->status.class_);
  833. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  834. // increment the number of pvp players on the map
  835. map[sd->bl.m].users_pvp++;
  836. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  837. {// register the player for ranking calculations
  838. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  839. }
  840. //bugreport:2266
  841. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  842. } else {
  843. sd->sc.option |= OPTION_INVISIBLE;
  844. sd->vd.class_ = INVISIBLE_CLASS;
  845. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  846. // decrement the number of pvp players on the map
  847. map[sd->bl.m].users_pvp--;
  848. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  849. {// unregister the player for ranking
  850. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  851. sd->pvp_timer = INVALID_TIMER;
  852. }
  853. }
  854. clif_changeoption(&sd->bl);
  855. return 0;
  856. }
  857. /*==========================================
  858. * Changes a character's class
  859. *------------------------------------------*/
  860. ACMD_FUNC(jobchange)
  861. {
  862. int job = 0, upper = 0;
  863. const char* text;
  864. nullpo_retr(-1, sd);
  865. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  866. int i;
  867. bool found = false;
  868. upper = 0;
  869. // Normal Jobs
  870. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  871. if (strncmpi(message, job_name(i), 16) == 0) {
  872. job = i;
  873. found = true;
  874. }
  875. }
  876. // High Jobs, Babys and Third
  877. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  878. if (strncmpi(message, job_name(i), 16) == 0) {
  879. job = i;
  880. found = true;
  881. }
  882. }
  883. if (!found) {
  884. text = atcommand_help_string(command);
  885. if (text)
  886. clif_displaymessage(fd, text);
  887. return -1;
  888. }
  889. }
  890. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  891. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  892. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2))
  893. { // Deny direct transformation into dummy jobs
  894. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  895. return 0;
  896. }
  897. if (pcdb_checkid(job))
  898. {
  899. if (pc_jobchange(sd, job, upper))
  900. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  901. else {
  902. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  903. return -1;
  904. }
  905. } else {
  906. text = atcommand_help_string(command);
  907. if (text)
  908. clif_displaymessage(fd, text);
  909. return -1;
  910. }
  911. return 0;
  912. }
  913. /*==========================================
  914. *
  915. *------------------------------------------*/
  916. ACMD_FUNC(kill)
  917. {
  918. nullpo_retr(-1, sd);
  919. status_kill(&sd->bl);
  920. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  921. if (fd != sd->fd)
  922. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  923. return 0;
  924. }
  925. /*==========================================
  926. *
  927. *------------------------------------------*/
  928. ACMD_FUNC(alive)
  929. {
  930. nullpo_retr(-1, sd);
  931. if (!status_revive(&sd->bl, 100, 100))
  932. {
  933. clif_displaymessage(fd, msg_txt(sd,667));
  934. return -1;
  935. }
  936. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  937. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  938. return 0;
  939. }
  940. /*==========================================
  941. * +kamic [LuzZza]
  942. *------------------------------------------*/
  943. ACMD_FUNC(kami)
  944. {
  945. unsigned long color=0;
  946. nullpo_retr(-1, sd);
  947. memset(atcmd_output, '\0', sizeof(atcmd_output));
  948. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  949. if (!message || !*message) {
  950. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  951. return -1;
  952. }
  953. sscanf(message, "%255[^\n]", atcmd_output);
  954. if (strstr(command, "l") != NULL)
  955. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  956. else
  957. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  958. } else {
  959. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  960. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  961. return -1;
  962. }
  963. if(color > 0xFFFFFF) {
  964. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  965. return -1;
  966. }
  967. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  968. }
  969. return 0;
  970. }
  971. /*==========================================
  972. *
  973. *------------------------------------------*/
  974. ACMD_FUNC(heal)
  975. {
  976. int hp = 0, sp = 0; // [Valaris] thanks to fov
  977. nullpo_retr(-1, sd);
  978. sscanf(message, "%11d %11d", &hp, &sp);
  979. // some overflow checks
  980. if( hp == INT_MIN ) hp++;
  981. if( sp == INT_MIN ) sp++;
  982. if ( hp == 0 && sp == 0 ) {
  983. if (!status_percent_heal(&sd->bl, 100, 100))
  984. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  985. else
  986. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  987. return 0;
  988. }
  989. if ( hp > 0 && sp >= 0 ) {
  990. if(!status_heal(&sd->bl, hp, sp, 0))
  991. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  992. else
  993. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  994. return 0;
  995. }
  996. if ( hp < 0 && sp <= 0 ) {
  997. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  998. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  999. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1000. return 0;
  1001. }
  1002. //Opposing signs.
  1003. if ( hp ) {
  1004. if (hp > 0)
  1005. status_heal(&sd->bl, hp, 0, 0);
  1006. else {
  1007. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1008. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1009. }
  1010. }
  1011. if ( sp ) {
  1012. if (sp > 0)
  1013. status_heal(&sd->bl, 0, sp, 0);
  1014. else
  1015. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1016. }
  1017. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1018. return 0;
  1019. }
  1020. /*==========================================
  1021. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1022. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1023. *------------------------------------------*/
  1024. ACMD_FUNC(item)
  1025. {
  1026. char item_name[100];
  1027. int number = 0, bound = BOUND_NONE;
  1028. char flag = 0;
  1029. struct item item_tmp;
  1030. struct item_data *item_data[10];
  1031. int get_count, i, j=0;
  1032. char *itemlist;
  1033. nullpo_retr(-1, sd);
  1034. memset(item_name, '\0', sizeof(item_name));
  1035. parent_cmd = atcommand_checkalias(command+1);
  1036. if (!strcmpi(parent_cmd,"itembound")) {
  1037. if (!message || !*message || (
  1038. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1039. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1040. {
  1041. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1042. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1043. return -1;
  1044. }
  1045. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1046. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1047. return -1;
  1048. }
  1049. } else if (!message || !*message || (
  1050. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1051. sscanf(message, "%99s %11d", item_name, &number) < 1
  1052. )) {
  1053. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1054. return -1;
  1055. }
  1056. itemlist = strtok(item_name, ":");
  1057. while (itemlist != NULL && j<10) {
  1058. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1059. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1060. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1061. return -1;
  1062. }
  1063. itemlist = strtok(NULL, ":"); //next itemline
  1064. j++;
  1065. }
  1066. if (number <= 0)
  1067. number = 1;
  1068. get_count = number;
  1069. for(j--; j>=0; j--){ //produce items in list
  1070. unsigned short item_id = item_data[j]->nameid;
  1071. //Check if it's stackable.
  1072. if (!itemdb_isstackable2(item_data[j]))
  1073. get_count = 1;
  1074. for (i = 0; i < number; i += get_count) {
  1075. // if not pet egg
  1076. if (!pet_create_egg(sd, item_id)) {
  1077. memset(&item_tmp, 0, sizeof(item_tmp));
  1078. item_tmp.nameid = item_id;
  1079. item_tmp.identify = 1;
  1080. item_tmp.bound = bound;
  1081. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1082. clif_additem(sd, 0, 0, flag);
  1083. }
  1084. }
  1085. }
  1086. if (flag == 0)
  1087. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1088. return 0;
  1089. }
  1090. /*==========================================
  1091. *
  1092. *------------------------------------------*/
  1093. ACMD_FUNC(item2)
  1094. {
  1095. struct item item_tmp;
  1096. struct item_data *item_data;
  1097. char item_name[100];
  1098. unsigned short item_id;
  1099. int number = 0, bound = BOUND_NONE;
  1100. int identify = 0, refine = 0, attr = 0;
  1101. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1102. nullpo_retr(-1, sd);
  1103. memset(item_name, '\0', sizeof(item_name));
  1104. parent_cmd = atcommand_checkalias(command+1);
  1105. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1106. if (!message || !*message || (
  1107. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1108. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1109. {
  1110. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1111. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1112. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1113. return -1;
  1114. }
  1115. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1116. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1117. return -1;
  1118. }
  1119. } else if ( !message || !*message || (
  1120. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1121. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1122. )) {
  1123. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1124. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1125. return -1;
  1126. }
  1127. if (number <= 0)
  1128. number = 1;
  1129. item_id = 0;
  1130. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1131. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1132. item_id = item_data->nameid;
  1133. if (item_id > 500) {
  1134. int loop, get_count, i;
  1135. char flag = 0;
  1136. //Check if it's stackable.
  1137. if(!itemdb_isstackable2(item_data)){
  1138. loop = number;
  1139. get_count = 1;
  1140. }else{
  1141. loop = 1;
  1142. get_count = number;
  1143. }
  1144. if( itemdb_isequip2(item_data ) ){
  1145. refine = cap_value( refine, 0, MAX_REFINE );
  1146. }else{
  1147. // All other items cannot be refined and are always identified
  1148. identify = 1;
  1149. refine = attr = 0;
  1150. }
  1151. for (i = 0; i < loop; i++) {
  1152. // if not pet egg
  1153. if (!pet_create_egg(sd, item_id)) {
  1154. memset(&item_tmp, 0, sizeof(item_tmp));
  1155. item_tmp.nameid = item_id;
  1156. item_tmp.identify = identify;
  1157. item_tmp.refine = refine;
  1158. item_tmp.attribute = attr;
  1159. item_tmp.card[0] = c1;
  1160. item_tmp.card[1] = c2;
  1161. item_tmp.card[2] = c3;
  1162. item_tmp.card[3] = c4;
  1163. item_tmp.bound = bound;
  1164. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1165. clif_additem(sd, 0, 0, flag);
  1166. }
  1167. }
  1168. if (flag == 0)
  1169. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1170. } else {
  1171. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1172. return -1;
  1173. }
  1174. return 0;
  1175. }
  1176. /*==========================================
  1177. *
  1178. *------------------------------------------*/
  1179. ACMD_FUNC(itemreset)
  1180. {
  1181. int i;
  1182. nullpo_retr(-1, sd);
  1183. for (i = 0; i < MAX_INVENTORY; i++) {
  1184. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1185. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1186. }
  1187. }
  1188. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1189. return 0;
  1190. }
  1191. /*==========================================
  1192. * Atcommand @lvlup
  1193. *------------------------------------------*/
  1194. ACMD_FUNC(baselevelup)
  1195. {
  1196. int level=0, i=0, status_point=0;
  1197. nullpo_retr(-1, sd);
  1198. level = atoi(message);
  1199. if (!message || !*message || !level) {
  1200. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1201. return -1;
  1202. }
  1203. if (level > 0) {
  1204. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1205. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1206. return -1;
  1207. } // End Addition
  1208. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1209. level = pc_maxbaselv(sd) - sd->status.base_level;
  1210. for (i = 0; i < level; i++)
  1211. status_point += pc_gets_status_point(sd->status.base_level + i);
  1212. sd->status.status_point += status_point;
  1213. sd->status.base_level += (unsigned int)level;
  1214. status_calc_pc(sd, SCO_FORCE);
  1215. status_percent_heal(&sd->bl, 100, 100);
  1216. clif_misceffect(&sd->bl, 0);
  1217. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1218. } else {
  1219. if (sd->status.base_level == 1) {
  1220. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1221. return -1;
  1222. }
  1223. level*=-1;
  1224. if ((unsigned int)level >= sd->status.base_level)
  1225. level = sd->status.base_level-1;
  1226. for (i = 0; i > -level; i--)
  1227. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1228. if (sd->status.status_point < status_point)
  1229. pc_resetstate(sd);
  1230. if (sd->status.status_point < status_point)
  1231. sd->status.status_point = 0;
  1232. else
  1233. sd->status.status_point -= status_point;
  1234. sd->status.base_level -= (unsigned int)level;
  1235. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1236. status_calc_pc(sd, SCO_FORCE);
  1237. }
  1238. sd->status.base_exp = 0;
  1239. clif_updatestatus(sd, SP_STATUSPOINT);
  1240. clif_updatestatus(sd, SP_BASELEVEL);
  1241. clif_updatestatus(sd, SP_BASEEXP);
  1242. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1243. pc_baselevelchanged(sd);
  1244. if(sd->status.party_id)
  1245. party_send_levelup(sd);
  1246. return 0;
  1247. }
  1248. /*==========================================
  1249. *
  1250. *------------------------------------------*/
  1251. ACMD_FUNC(joblevelup)
  1252. {
  1253. int level=0;
  1254. nullpo_retr(-1, sd);
  1255. level = atoi(message);
  1256. if (!message || !*message || !level) {
  1257. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1258. return -1;
  1259. }
  1260. if (level > 0) {
  1261. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1262. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1263. return -1;
  1264. }
  1265. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1266. level = pc_maxjoblv(sd) - sd->status.job_level;
  1267. sd->status.job_level += (unsigned int)level;
  1268. sd->status.skill_point += level;
  1269. clif_misceffect(&sd->bl, 1);
  1270. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1271. } else {
  1272. if (sd->status.job_level == 1) {
  1273. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1274. return -1;
  1275. }
  1276. level *=-1;
  1277. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1278. level = sd->status.job_level-1;
  1279. sd->status.job_level -= (unsigned int)level;
  1280. if (sd->status.skill_point < level)
  1281. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1282. if (sd->status.skill_point < level)
  1283. sd->status.skill_point = 0;
  1284. else
  1285. sd->status.skill_point -= level;
  1286. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1287. }
  1288. sd->status.job_exp = 0;
  1289. clif_updatestatus(sd, SP_JOBLEVEL);
  1290. clif_updatestatus(sd, SP_JOBEXP);
  1291. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1292. clif_updatestatus(sd, SP_SKILLPOINT);
  1293. status_calc_pc(sd, SCO_FORCE);
  1294. return 0;
  1295. }
  1296. /*==========================================
  1297. * @help
  1298. *------------------------------------------*/
  1299. ACMD_FUNC(help)
  1300. {
  1301. config_setting_t *help;
  1302. const char *text = NULL;
  1303. const char *command_name = NULL;
  1304. char *default_command = "help";
  1305. nullpo_retr(-1, sd);
  1306. help = config_lookup(&atcommand_config, "help");
  1307. if (help == NULL) {
  1308. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1309. return -1;
  1310. }
  1311. if (!message || !*message) {
  1312. command_name = default_command; // If no command_name specified, display help for @help.
  1313. } else {
  1314. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1315. ++message;
  1316. command_name = atcommand_checkalias(message);
  1317. }
  1318. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1319. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1320. clif_displaymessage(fd, atcmd_output);
  1321. atcommand_get_suggestions(sd, command_name, true);
  1322. return -1;
  1323. }
  1324. if (!config_setting_lookup_string(help, command_name, &text)) {
  1325. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1326. clif_displaymessage(fd, atcmd_output);
  1327. atcommand_get_suggestions(sd, command_name, true);
  1328. return -1;
  1329. }
  1330. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1331. clif_displaymessage(fd, atcmd_output);
  1332. { // Display aliases
  1333. DBIterator* iter;
  1334. AtCommandInfo *command_info;
  1335. AliasInfo *alias_info = NULL;
  1336. StringBuf buf;
  1337. bool has_aliases = false;
  1338. StringBuf_Init(&buf);
  1339. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1340. command_info = get_atcommandinfo_byname(command_name);
  1341. iter = db_iterator(atcommand_alias_db);
  1342. for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
  1343. if (alias_info->command == command_info) {
  1344. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1345. has_aliases = true;
  1346. }
  1347. }
  1348. dbi_destroy(iter);
  1349. if (has_aliases)
  1350. clif_displaymessage(fd, StringBuf_Value(&buf));
  1351. StringBuf_Destroy(&buf);
  1352. }
  1353. // Display help contents
  1354. clif_displaymessage(fd, text);
  1355. return 0;
  1356. }
  1357. // helper function, used in foreach calls to stop auto-attack timers
  1358. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1359. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1360. {
  1361. struct unit_data *ud = unit_bl2ud(bl);
  1362. int id = va_arg(ap, int);
  1363. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1364. {
  1365. unit_stop_attack(bl);
  1366. return 1;
  1367. }
  1368. return 0;
  1369. }
  1370. /*==========================================
  1371. *
  1372. *------------------------------------------*/
  1373. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1374. {
  1375. TBL_PC* sd = (TBL_PC*)bl;
  1376. clif_pvpset(sd, 0, 0, 2);
  1377. if (sd->pvp_timer != INVALID_TIMER) {
  1378. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1379. sd->pvp_timer = INVALID_TIMER;
  1380. }
  1381. return 0;
  1382. }
  1383. ACMD_FUNC(pvpoff)
  1384. {
  1385. nullpo_retr(-1, sd);
  1386. if (!map[sd->bl.m].flag.pvp) {
  1387. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1388. return -1;
  1389. }
  1390. map[sd->bl.m].flag.pvp = 0;
  1391. if (!battle_config.pk_mode){
  1392. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1393. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1394. }
  1395. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1396. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1397. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1398. return 0;
  1399. }
  1400. /*==========================================
  1401. *
  1402. *------------------------------------------*/
  1403. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1404. {
  1405. TBL_PC* sd = (TBL_PC*)bl;
  1406. if (sd->pvp_timer == INVALID_TIMER) {
  1407. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1408. sd->pvp_rank = 0;
  1409. sd->pvp_lastusers = 0;
  1410. sd->pvp_point = 5;
  1411. sd->pvp_won = 0;
  1412. sd->pvp_lost = 0;
  1413. }
  1414. return 0;
  1415. }
  1416. ACMD_FUNC(pvpon)
  1417. {
  1418. nullpo_retr(-1, sd);
  1419. if (map[sd->bl.m].flag.pvp) {
  1420. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1421. return -1;
  1422. }
  1423. map[sd->bl.m].flag.pvp = 1;
  1424. if (!battle_config.pk_mode) {// display pvp circle and rank
  1425. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1426. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1427. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1428. }
  1429. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1430. return 0;
  1431. }
  1432. /*==========================================
  1433. *
  1434. *------------------------------------------*/
  1435. ACMD_FUNC(gvgoff)
  1436. {
  1437. nullpo_retr(-1, sd);
  1438. if (!map[sd->bl.m].flag.gvg) {
  1439. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1440. return -1;
  1441. }
  1442. map[sd->bl.m].flag.gvg = 0;
  1443. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1444. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1445. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1446. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1447. return 0;
  1448. }
  1449. /*==========================================
  1450. *
  1451. *------------------------------------------*/
  1452. ACMD_FUNC(gvgon)
  1453. {
  1454. nullpo_retr(-1, sd);
  1455. if (map[sd->bl.m].flag.gvg) {
  1456. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1457. return -1;
  1458. }
  1459. map[sd->bl.m].flag.gvg = 1;
  1460. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1461. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1462. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1463. return 0;
  1464. }
  1465. /*==========================================
  1466. *
  1467. *------------------------------------------*/
  1468. ACMD_FUNC(model)
  1469. {
  1470. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1471. nullpo_retr(-1, sd);
  1472. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1473. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1474. 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>).
  1475. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1476. clif_displaymessage(fd, atcmd_output);
  1477. return -1;
  1478. }
  1479. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1480. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1481. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1482. pc_changelook(sd, LOOK_HAIR, hair_style);
  1483. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1484. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1485. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1486. } else {
  1487. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1488. return -1;
  1489. }
  1490. return 0;
  1491. }
  1492. /*==========================================
  1493. * @bodystyle [Rytech]
  1494. *------------------------------------------*/
  1495. ACMD_FUNC(bodystyle)
  1496. {
  1497. int body_style = 0;
  1498. nullpo_retr(-1, sd);
  1499. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1500. // Limit body styles to certain jobs since not all of them are released yet.
  1501. if (!((sd->class_&MAPID_THIRDMASK) == MAPID_GUILLOTINE_CROSS || (sd->class_&MAPID_THIRDMASK) == MAPID_GENETIC
  1502. || (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC || (sd->class_&MAPID_THIRDMASK) == MAPID_ROYAL_GUARD
  1503. || (sd->class_&MAPID_THIRDMASK) == MAPID_ARCH_BISHOP)) {
  1504. clif_displaymessage(fd, msg_txt(sd,770)); // This job has no alternate body styles.
  1505. return -1;
  1506. }
  1507. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1508. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1509. clif_displaymessage(fd, atcmd_output);
  1510. return -1;
  1511. }
  1512. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1513. pc_changelook(sd, LOOK_BODY2, body_style);
  1514. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1515. } else {
  1516. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1517. return -1;
  1518. }
  1519. return 0;
  1520. }
  1521. /*==========================================
  1522. * @dye && @ccolor
  1523. *------------------------------------------*/
  1524. ACMD_FUNC(dye)
  1525. {
  1526. int cloth_color = 0;
  1527. nullpo_retr(-1, sd);
  1528. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1529. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1530. 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>).
  1531. clif_displaymessage(fd, atcmd_output);
  1532. return -1;
  1533. }
  1534. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1535. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1536. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1537. } else {
  1538. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1539. return -1;
  1540. }
  1541. return 0;
  1542. }
  1543. /*==========================================
  1544. * @hairstyle && @hstyle
  1545. *------------------------------------------*/
  1546. ACMD_FUNC(hair_style)
  1547. {
  1548. int hair_style = 0;
  1549. nullpo_retr(-1, sd);
  1550. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1551. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1552. 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>).
  1553. clif_displaymessage(fd, atcmd_output);
  1554. return -1;
  1555. }
  1556. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1557. pc_changelook(sd, LOOK_HAIR, hair_style);
  1558. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1559. } else {
  1560. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1561. return -1;
  1562. }
  1563. return 0;
  1564. }
  1565. /*==========================================
  1566. * @haircolor && @hcolor
  1567. *------------------------------------------*/
  1568. ACMD_FUNC(hair_color)
  1569. {
  1570. int hair_color = 0;
  1571. nullpo_retr(-1, sd);
  1572. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1573. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1574. 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>).
  1575. clif_displaymessage(fd, atcmd_output);
  1576. return -1;
  1577. }
  1578. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1579. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1580. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1581. } else {
  1582. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1583. return -1;
  1584. }
  1585. return 0;
  1586. }
  1587. /*==========================================
  1588. * @go [city_number or city_name] - Updated by Harbin
  1589. *------------------------------------------*/
  1590. ACMD_FUNC(go)
  1591. {
  1592. int i;
  1593. int town;
  1594. char map_name[MAP_NAME_LENGTH];
  1595. const struct {
  1596. char map[MAP_NAME_LENGTH];
  1597. int x, y;
  1598. } data[] = {
  1599. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1600. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1601. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1602. { MAP_PAYON, 162, 233 }, // 3=Payon
  1603. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1604. #ifdef RENEWAL
  1605. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1606. #else
  1607. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1608. #endif
  1609. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1610. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1611. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1612. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1613. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1614. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1615. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1616. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1617. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1618. #ifdef RENEWAL
  1619. { MAP_NOVICE, 97, 90 }, // 15=Training Grounds (Renewal)
  1620. #else
  1621. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1622. #endif
  1623. { MAP_JAIL, 23, 61 }, // 16=Prison
  1624. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1625. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1626. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1627. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1628. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1629. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1630. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1631. { MAP_VEINS, 216, 123 }, // 24=Veins
  1632. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1633. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1634. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1635. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1636. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1637. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1638. { MAP_MORA, 44, 151 }, // 31=Mora
  1639. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1640. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1641. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1642. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1643. };
  1644. nullpo_retr(-1, sd);
  1645. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1646. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1647. return 0;
  1648. }
  1649. memset(map_name, '\0', sizeof(map_name));
  1650. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1651. // get the number
  1652. town = atoi(message);
  1653. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1654. {// no value matched so send the list of locations
  1655. const char* text;
  1656. // attempt to find the text help string
  1657. text = atcommand_help_string( command );
  1658. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1659. if( text )
  1660. {// send the text to the client
  1661. clif_displaymessage( fd, text );
  1662. }
  1663. return -1;
  1664. }
  1665. // get possible name of the city
  1666. map_name[MAP_NAME_LENGTH-1] = '\0';
  1667. for (i = 0; map_name[i]; i++)
  1668. map_name[i] = TOLOWER(map_name[i]);
  1669. // try to identify the map name
  1670. if (strncmp(map_name, "prontera", 3) == 0) {
  1671. town = 0;
  1672. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1673. strncmp(map_name, "morroc", 4) == 0) {
  1674. town = 1;
  1675. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1676. town = 2;
  1677. } else if (strncmp(map_name, "payon", 3) == 0) {
  1678. town = 3;
  1679. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1680. town = 4;
  1681. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1682. town = 5;
  1683. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1684. town = 6;
  1685. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1686. strcmp(map_name, "christmas") == 0 ||
  1687. strncmp(map_name, "xmas", 3) == 0 ||
  1688. strncmp(map_name, "x-mas", 3) == 0) {
  1689. town = 7;
  1690. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1691. town = 8;
  1692. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1693. strncmp(map_name, "yuno", 3) == 0) {
  1694. town = 9;
  1695. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1696. town = 10;
  1697. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1698. strncmp(map_name, "gonryun", 3) == 0) {
  1699. town = 11;
  1700. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1701. town = 12;
  1702. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1703. town = 13;
  1704. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1705. town = 14;
  1706. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1707. strncmp(map_name, "startpoint", 3) == 0 ||
  1708. strncmp(map_name, "beginning", 3) == 0) {
  1709. town = 15;
  1710. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1711. strncmp(map_name, "prison", 3) == 0 ||
  1712. strncmp(map_name, "jail", 3) == 0) {
  1713. town = 16;
  1714. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1715. town = 17;
  1716. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1717. town = 18;
  1718. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1719. town = 19;
  1720. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1721. town = 20;
  1722. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1723. town = 21;
  1724. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1725. town = 22;
  1726. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1727. town = 23;
  1728. } else if (strncmp(map_name, "veins", 3) == 0) {
  1729. town = 24;
  1730. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1731. town = 25;
  1732. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1733. town = 26;
  1734. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1735. town = 27;
  1736. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1737. town = 28;
  1738. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1739. town = 29;
  1740. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1741. town = 30;
  1742. } else if (strcmp(map_name, "mora") == 0) {
  1743. town = 31;
  1744. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1745. town = 32;
  1746. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1747. town = 33;
  1748. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1749. town = 34;
  1750. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1751. town = 35;
  1752. }
  1753. if (town >= 0 && town < ARRAYLENGTH(data))
  1754. {
  1755. int16 m = map_mapname2mapid(data[town].map);
  1756. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1757. clif_displaymessage(fd, msg_txt(sd,247));
  1758. return -1;
  1759. }
  1760. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1761. clif_displaymessage(fd, msg_txt(sd,248));
  1762. return -1;
  1763. }
  1764. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1765. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1766. } else {
  1767. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1768. return -1;
  1769. }
  1770. } else { // if you arrive here, you have an error in town variable when reading of names
  1771. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1772. return -1;
  1773. }
  1774. return 0;
  1775. }
  1776. /*==========================================
  1777. *
  1778. *------------------------------------------*/
  1779. ACMD_FUNC(monster)
  1780. {
  1781. char name[NAME_LENGTH];
  1782. char monster[NAME_LENGTH];
  1783. char eventname[EVENT_NAME_LENGTH] = "";
  1784. int mob_id;
  1785. int number = 0;
  1786. int count;
  1787. int i, range;
  1788. short mx, my;
  1789. unsigned int size;
  1790. nullpo_retr(-1, sd);
  1791. memset(name, '\0', sizeof(name));
  1792. memset(monster, '\0', sizeof(monster));
  1793. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1794. if (!message || !*message) {
  1795. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1796. return -1;
  1797. }
  1798. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1799. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1800. //All data can be left as it is.
  1801. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1802. //Here, it is possible name was not given and we are using monster for it.
  1803. if (count < 3) //Blank mob's name.
  1804. name[0] = '\0';
  1805. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1806. //All data can be left as it is.
  1807. } else if (sscanf(message, "%23s", monster) > 0) {
  1808. //As before, name may be already filled.
  1809. name[0] = '\0';
  1810. } else {
  1811. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1812. return -1;
  1813. }
  1814. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1815. mob_id = mobdb_checkid(atoi(monster));
  1816. if (mob_id == 0) {
  1817. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1818. return -1;
  1819. }
  1820. if (mob_id == MOBID_EMPERIUM) {
  1821. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1822. return -1;
  1823. }
  1824. if (number <= 0)
  1825. number = 1;
  1826. if( !name[0] )
  1827. strcpy(name, "--ja--");
  1828. // 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
  1829. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1830. number = battle_config.atc_spawn_quantity_limit;
  1831. parent_cmd = atcommand_checkalias(command+1);
  1832. if (strcmp(parent_cmd, "monstersmall") == 0)
  1833. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1834. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1835. size = SZ_BIG;
  1836. else
  1837. size = SZ_SMALL;
  1838. if (battle_config.etc_log)
  1839. 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);
  1840. count = 0;
  1841. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1842. for (i = 0; i < number; i++) {
  1843. int k;
  1844. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1845. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1846. if(k) {
  1847. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1848. count ++;
  1849. }
  1850. }
  1851. if (count != 0)
  1852. if (number == count)
  1853. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1854. else {
  1855. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1856. clif_displaymessage(fd, atcmd_output);
  1857. }
  1858. else {
  1859. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1860. return -1;
  1861. }
  1862. return 0;
  1863. }
  1864. /*==========================================
  1865. *
  1866. *------------------------------------------*/
  1867. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1868. {
  1869. struct mob_data *md;
  1870. int flag;
  1871. nullpo_ret(md=(struct mob_data *)bl);
  1872. flag = va_arg(ap, int);
  1873. if (md->guardian_data)
  1874. return 0; //Do not touch WoE mobs!
  1875. if (flag)
  1876. status_zap(bl,md->status.hp, 0);
  1877. else
  1878. status_kill(bl);
  1879. return 1;
  1880. }
  1881. ACMD_FUNC(killmonster)
  1882. {
  1883. int map_id, drop_flag;
  1884. char map_name[MAP_NAME_LENGTH_EXT];
  1885. nullpo_retr(-1, sd);
  1886. memset(map_name, '\0', sizeof(map_name));
  1887. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1888. map_id = sd->bl.m;
  1889. else {
  1890. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1891. map_id = sd->bl.m;
  1892. }
  1893. parent_cmd = atcommand_checkalias(command+1);
  1894. drop_flag = strcmp(parent_cmd, "killmonster2");
  1895. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1896. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1897. return 0;
  1898. }
  1899. /*==========================================
  1900. *
  1901. *------------------------------------------*/
  1902. ACMD_FUNC(refine)
  1903. {
  1904. int j, position = 0, refine = 0, current_position, final_refine;
  1905. int count;
  1906. nullpo_retr(-1, sd);
  1907. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1908. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1909. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1910. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1911. clif_displaymessage(fd, atcmd_output);
  1912. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1913. clif_displaymessage(fd, atcmd_output);
  1914. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1915. clif_displaymessage(fd, atcmd_output);
  1916. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1917. clif_displaymessage(fd, atcmd_output);
  1918. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1919. clif_displaymessage(fd, atcmd_output);
  1920. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1921. clif_displaymessage(fd, atcmd_output);
  1922. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1923. clif_displaymessage(fd, atcmd_output);
  1924. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1925. clif_displaymessage(fd, atcmd_output);
  1926. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1927. clif_displaymessage(fd, atcmd_output);
  1928. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1929. clif_displaymessage(fd, atcmd_output);
  1930. return -1;
  1931. }
  1932. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1933. count = 0;
  1934. for (j = 0; j < EQI_MAX; j++) {
  1935. int i;
  1936. if ((i = sd->equip_index[j]) < 0)
  1937. continue;
  1938. if(j == EQI_AMMO)
  1939. continue;
  1940. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1941. continue;
  1942. if(position && !(sd->status.inventory[i].equip & position))
  1943. continue;
  1944. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1945. if (sd->status.inventory[i].refine != final_refine) {
  1946. sd->status.inventory[i].refine = final_refine;
  1947. current_position = sd->status.inventory[i].equip;
  1948. pc_unequipitem(sd, i, 3);
  1949. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1950. clif_delitem(sd, i, 1, 3);
  1951. clif_additem(sd, i, 1, 0);
  1952. pc_equipitem(sd, i, current_position);
  1953. clif_misceffect(&sd->bl, 3);
  1954. count++;
  1955. }
  1956. }
  1957. if (count == 0)
  1958. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1959. else if (count == 1)
  1960. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1961. else {
  1962. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1963. clif_displaymessage(fd, atcmd_output);
  1964. }
  1965. return 0;
  1966. }
  1967. /*==========================================
  1968. *
  1969. *------------------------------------------*/
  1970. ACMD_FUNC(produce)
  1971. {
  1972. char item_name[100];
  1973. unsigned short item_id;
  1974. int attribute = 0, star = 0;
  1975. struct item_data *item_data;
  1976. struct item tmp_item;
  1977. nullpo_retr(-1, sd);
  1978. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1979. memset(item_name, '\0', sizeof(item_name));
  1980. if (!message || !*message || (
  1981. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  1982. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  1983. )) {
  1984. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1985. return -1;
  1986. }
  1987. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1988. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1989. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1990. return -1;
  1991. }
  1992. item_id = item_data->nameid;
  1993. if (itemdb_isequip2(item_data)) {
  1994. char flag = 0;
  1995. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1996. attribute = ATTRIBUTE_NORMAL;
  1997. if (star < MIN_STAR || star > MAX_STAR)
  1998. star = 0;
  1999. memset(&tmp_item, 0, sizeof tmp_item);
  2000. tmp_item.nameid = item_id;
  2001. tmp_item.amount = 1;
  2002. tmp_item.identify = 1;
  2003. tmp_item.card[0] = CARD0_FORGE;
  2004. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2005. ((star*5) << 8) + attribute:0;
  2006. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2007. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2008. clif_produceeffect(sd, 0, item_id);
  2009. clif_misceffect(&sd->bl, 3);
  2010. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2011. clif_additem(sd, 0, 0, flag);
  2012. } else {
  2013. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  2014. clif_displaymessage(fd, atcmd_output);
  2015. return -1;
  2016. }
  2017. return 0;
  2018. }
  2019. /*==========================================
  2020. *
  2021. *------------------------------------------*/
  2022. ACMD_FUNC(memo)
  2023. {
  2024. int position = 0;
  2025. nullpo_retr(-1, sd);
  2026. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2027. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2028. {
  2029. int i;
  2030. clif_displaymessage(sd->fd, msg_txt(sd,668));
  2031. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2032. {
  2033. if( sd->status.memo_point[i].map )
  2034. 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);
  2035. else
  2036. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2037. clif_displaymessage(sd->fd, atcmd_output);
  2038. }
  2039. return 0;
  2040. }
  2041. if( position < 0 || position >= MAX_MEMOPOINTS )
  2042. {
  2043. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2044. clif_displaymessage(fd, atcmd_output);
  2045. return -1;
  2046. }
  2047. return !pc_memo( sd, position );
  2048. }
  2049. /*==========================================
  2050. *
  2051. *------------------------------------------*/
  2052. ACMD_FUNC(gat)
  2053. {
  2054. int y;
  2055. nullpo_retr(-1, sd);
  2056. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2057. for (y = 2; y >= -2; y--) {
  2058. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2059. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2060. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2061. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2062. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2063. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2064. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2065. clif_displaymessage(fd, atcmd_output);
  2066. }
  2067. return 0;
  2068. }
  2069. /*==========================================
  2070. *
  2071. *------------------------------------------*/
  2072. ACMD_FUNC(displaystatus)
  2073. {
  2074. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2075. nullpo_retr(-1, sd);
  2076. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2077. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2078. return -1;
  2079. }
  2080. if (i < 2) flag = 1;
  2081. if (i < 3) tick = 0;
  2082. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2083. return 0;
  2084. }
  2085. /*==========================================
  2086. * @stpoint (Rewritten by [Yor])
  2087. *------------------------------------------*/
  2088. ACMD_FUNC(statuspoint)
  2089. {
  2090. int point;
  2091. unsigned int new_status_point;
  2092. if (!message || !*message || (point = atoi(message)) == 0) {
  2093. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2094. return -1;
  2095. }
  2096. if(point < 0)
  2097. {
  2098. if(sd->status.status_point < (unsigned int)(-point))
  2099. {
  2100. new_status_point = 0;
  2101. }
  2102. else
  2103. {
  2104. new_status_point = sd->status.status_point + point;
  2105. }
  2106. }
  2107. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2108. {
  2109. new_status_point = UINT_MAX;
  2110. }
  2111. else
  2112. {
  2113. new_status_point = sd->status.status_point + point;
  2114. }
  2115. if (new_status_point != sd->status.status_point) {
  2116. sd->status.status_point = new_status_point;
  2117. clif_updatestatus(sd, SP_STATUSPOINT);
  2118. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2119. } else {
  2120. if (point < 0)
  2121. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2122. else
  2123. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2124. return -1;
  2125. }
  2126. return 0;
  2127. }
  2128. /*==========================================
  2129. * @skpoint (Rewritten by [Yor])
  2130. *------------------------------------------*/
  2131. ACMD_FUNC(skillpoint)
  2132. {
  2133. int point;
  2134. unsigned int new_skill_point;
  2135. nullpo_retr(-1, sd);
  2136. if (!message || !*message || (point = atoi(message)) == 0) {
  2137. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2138. return -1;
  2139. }
  2140. if(point < 0)
  2141. {
  2142. if(sd->status.skill_point < (unsigned int)(-point))
  2143. {
  2144. new_skill_point = 0;
  2145. }
  2146. else
  2147. {
  2148. new_skill_point = sd->status.skill_point + point;
  2149. }
  2150. }
  2151. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2152. {
  2153. new_skill_point = UINT_MAX;
  2154. }
  2155. else
  2156. {
  2157. new_skill_point = sd->status.skill_point + point;
  2158. }
  2159. if (new_skill_point != sd->status.skill_point) {
  2160. sd->status.skill_point = new_skill_point;
  2161. clif_updatestatus(sd, SP_SKILLPOINT);
  2162. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2163. } else {
  2164. if (point < 0)
  2165. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2166. else
  2167. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2168. return -1;
  2169. }
  2170. return 0;
  2171. }
  2172. /*==========================================
  2173. * @zeny
  2174. *------------------------------------------*/
  2175. ACMD_FUNC(zeny)
  2176. {
  2177. int zeny=0, ret=-1;
  2178. nullpo_retr(-1, sd);
  2179. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2180. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2181. return -1;
  2182. }
  2183. if(zeny > 0){
  2184. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2185. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2186. }
  2187. else {
  2188. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2189. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2190. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2191. }
  2192. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2193. return 0;
  2194. }
  2195. /*==========================================
  2196. *
  2197. *------------------------------------------*/
  2198. ACMD_FUNC(param)
  2199. {
  2200. uint8 i;
  2201. int value = 0;
  2202. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2203. unsigned short new_value, *status[6], max_status[6];
  2204. //we don't use direct initialization because it isn't part of the c standard.
  2205. nullpo_retr(-1, sd);
  2206. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2207. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2208. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2209. return -1;
  2210. }
  2211. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2212. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2213. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2214. return -1;
  2215. }
  2216. status[0] = &sd->status.str;
  2217. status[1] = &sd->status.agi;
  2218. status[2] = &sd->status.vit;
  2219. status[3] = &sd->status.int_;
  2220. status[4] = &sd->status.dex;
  2221. status[5] = &sd->status.luk;
  2222. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2223. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2224. else {
  2225. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2226. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2227. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2228. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2229. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2230. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2231. }
  2232. if(value > 0 && *status[i] + value >= max_status[i])
  2233. new_value = max_status[i];
  2234. else if(value < 0 && *status[i] <= -value)
  2235. new_value = 1;
  2236. else
  2237. new_value = *status[i] + value;
  2238. if (new_value != *status[i]) {
  2239. *status[i] = new_value;
  2240. clif_updatestatus(sd, SP_STR + i);
  2241. clif_updatestatus(sd, SP_USTR + i);
  2242. status_calc_pc(sd, SCO_FORCE);
  2243. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2244. } else {
  2245. if (value < 0)
  2246. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2247. else
  2248. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2249. return -1;
  2250. }
  2251. return 0;
  2252. }
  2253. /*==========================================
  2254. * Stat all by fritz (rewritten by [Yor])
  2255. *------------------------------------------*/
  2256. ACMD_FUNC(stat_all)
  2257. {
  2258. int value = 0;
  2259. uint8 count, i;
  2260. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2261. //we don't use direct initialization because it isn't part of the c standard.
  2262. nullpo_retr(-1, sd);
  2263. status[0] = &sd->status.str;
  2264. status[1] = &sd->status.agi;
  2265. status[2] = &sd->status.vit;
  2266. status[3] = &sd->status.int_;
  2267. status[4] = &sd->status.dex;
  2268. status[5] = &sd->status.luk;
  2269. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2270. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2271. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2272. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2273. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2274. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2275. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2276. value = SHRT_MAX;
  2277. } else {
  2278. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2279. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2280. else {
  2281. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2282. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2283. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2284. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2285. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2286. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2287. }
  2288. }
  2289. count = 0;
  2290. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2291. short new_value;
  2292. if (value > 0 && *status[i] + value >= max_status[i])
  2293. new_value = max_status[i];
  2294. else if (value < 0 && *status[i] <= -value)
  2295. new_value = 1;
  2296. else
  2297. new_value = *status[i] + value;
  2298. if (new_value != *status[i]) {
  2299. *status[i] = new_value;
  2300. clif_updatestatus(sd, SP_STR + i);
  2301. clif_updatestatus(sd, SP_USTR + i);
  2302. count++;
  2303. }
  2304. }
  2305. if (count > 0) { // if at least 1 stat modified
  2306. status_calc_pc(sd, SCO_FORCE);
  2307. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2308. } else {
  2309. if (value < 0)
  2310. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2311. else
  2312. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2313. return -1;
  2314. }
  2315. return 0;
  2316. }
  2317. /*==========================================
  2318. *
  2319. *------------------------------------------*/
  2320. ACMD_FUNC(guildlevelup) {
  2321. int level = 0;
  2322. short added_level;
  2323. struct guild *guild_info;
  2324. nullpo_retr(-1, sd);
  2325. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2326. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2327. return -1;
  2328. }
  2329. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2330. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2331. return -1;
  2332. }
  2333. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2334. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2335. // return -1;
  2336. //}
  2337. added_level = (short)level;
  2338. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2339. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2340. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2341. added_level = 1 - guild_info->guild_lv;
  2342. if (added_level != 0) {
  2343. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2344. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2345. } else {
  2346. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2347. return -1;
  2348. }
  2349. return 0;
  2350. }
  2351. /*==========================================
  2352. *
  2353. *------------------------------------------*/
  2354. ACMD_FUNC(makeegg) {
  2355. struct item_data *item_data;
  2356. int id, pet_id;
  2357. nullpo_retr(-1, sd);
  2358. if (!message || !*message) {
  2359. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2360. return -1;
  2361. }
  2362. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2363. id = item_data->nameid;
  2364. else
  2365. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2366. ;
  2367. else
  2368. id = atoi(message);
  2369. pet_id = search_petDB_index(id, PET_CLASS);
  2370. if (pet_id < 0)
  2371. pet_id = search_petDB_index(id, PET_EGG);
  2372. if (pet_id >= 0) {
  2373. sd->catch_target_class = pet_db[pet_id].class_;
  2374. intif_create_pet(
  2375. sd->status.account_id, sd->status.char_id,
  2376. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2377. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2378. 100, 0, 1, pet_db[pet_id].jname);
  2379. } else {
  2380. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2381. return -1;
  2382. }
  2383. return 0;
  2384. }
  2385. /*==========================================
  2386. *
  2387. *------------------------------------------*/
  2388. ACMD_FUNC(hatch) {
  2389. nullpo_retr(-1, sd);
  2390. if (sd->status.pet_id <= 0)
  2391. clif_sendegg(sd);
  2392. else {
  2393. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2394. return -1;
  2395. }
  2396. return 0;
  2397. }
  2398. /*==========================================
  2399. *
  2400. *------------------------------------------*/
  2401. ACMD_FUNC(petfriendly) {
  2402. int friendly;
  2403. struct pet_data *pd;
  2404. nullpo_retr(-1, sd);
  2405. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2406. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2407. return -1;
  2408. }
  2409. pd = sd->pd;
  2410. if (!pd) {
  2411. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2412. return -1;
  2413. }
  2414. if (friendly < 0 || friendly > 1000)
  2415. {
  2416. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2417. return -1;
  2418. }
  2419. if (friendly == pd->pet.intimate) {
  2420. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2421. return -1;
  2422. }
  2423. pet_set_intimate(pd, friendly);
  2424. clif_send_petstatus(sd);
  2425. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2426. return 0;
  2427. }
  2428. /*==========================================
  2429. *
  2430. *------------------------------------------*/
  2431. ACMD_FUNC(pethungry)
  2432. {
  2433. int hungry;
  2434. struct pet_data *pd;
  2435. nullpo_retr(-1, sd);
  2436. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2437. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2438. return -1;
  2439. }
  2440. pd = sd->pd;
  2441. if (!sd->status.pet_id || !pd) {
  2442. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2443. return -1;
  2444. }
  2445. if (hungry < 0 || hungry > 100) {
  2446. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2447. return -1;
  2448. }
  2449. if (hungry == pd->pet.hungry) {
  2450. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2451. return -1;
  2452. }
  2453. pd->pet.hungry = hungry;
  2454. clif_send_petstatus(sd);
  2455. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2456. return 0;
  2457. }
  2458. /*==========================================
  2459. *
  2460. *------------------------------------------*/
  2461. ACMD_FUNC(petrename)
  2462. {
  2463. struct pet_data *pd;
  2464. nullpo_retr(-1, sd);
  2465. if (!sd->status.pet_id || !sd->pd) {
  2466. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2467. return -1;
  2468. }
  2469. pd = sd->pd;
  2470. if (!pd->pet.rename_flag) {
  2471. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2472. return -1;
  2473. }
  2474. pd->pet.rename_flag = 0;
  2475. intif_save_petdata(sd->status.account_id, &pd->pet);
  2476. clif_send_petstatus(sd);
  2477. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2478. return 0;
  2479. }
  2480. /*==========================================
  2481. *
  2482. *------------------------------------------*/
  2483. ACMD_FUNC(recall) {
  2484. struct map_session_data *pl_sd = NULL;
  2485. nullpo_retr(-1, sd);
  2486. if (!message || !*message) {
  2487. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2488. return -1;
  2489. }
  2490. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2491. {
  2492. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2493. return -1;
  2494. }
  2495. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2496. {
  2497. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2498. return -1;
  2499. }
  2500. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2501. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2502. return -1;
  2503. }
  2504. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2505. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2506. return -1;
  2507. }
  2508. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2509. return -1;
  2510. }
  2511. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2512. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2513. return -1;
  2514. }
  2515. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2516. clif_displaymessage(fd, atcmd_output);
  2517. return 0;
  2518. }
  2519. /*==========================================
  2520. * charblock command (usage: charblock <player_name>)
  2521. * This command do a definitiv ban on a player
  2522. *------------------------------------------*/
  2523. ACMD_FUNC(char_block)
  2524. {
  2525. nullpo_retr(-1, sd);
  2526. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2527. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2528. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2529. clif_displaymessage(fd, atcmd_output);
  2530. return -1;
  2531. }
  2532. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2533. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2534. clif_displaymessage(fd, atcmd_output);
  2535. return 0;
  2536. }
  2537. /*==========================================
  2538. * accountban command (usage: ban <%time> <player_name>)
  2539. * charban command (usage: charban <%time> <player_name>)
  2540. * %time see common/timer.c::solve_time()
  2541. *------------------------------------------*/
  2542. ACMD_FUNC(char_ban)
  2543. {
  2544. char *modif_p, output[CHAT_SIZE_MAX];
  2545. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2546. int bantype = 0;
  2547. nullpo_retr(-1, sd);
  2548. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2549. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2550. parent_cmd = atcommand_checkalias(command+1);
  2551. if (strcmpi(parent_cmd,"charban") == 0)
  2552. bantype = CHRIF_OP_BAN;
  2553. else if (strcmpi(parent_cmd,"ban") == 0)
  2554. bantype = CHRIF_OP_LOGIN_BAN;
  2555. else
  2556. return -1;
  2557. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2558. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2559. clif_displaymessage(fd, output);
  2560. return -1;
  2561. }
  2562. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2563. modif_p = atcmd_output;
  2564. timediff = (int32)solve_time(modif_p); //discard seconds
  2565. if (timediff == 0) { //allow negative ?
  2566. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2567. clif_displaymessage(fd, output);
  2568. 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.
  2569. return -1;
  2570. }
  2571. if( timediff < 0 && (
  2572. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2573. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2574. ))
  2575. {
  2576. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2577. return -1;
  2578. }
  2579. if (bantype == CHRIF_OP_BAN)
  2580. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2581. else
  2582. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2583. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2584. clif_displaymessage(fd, output);
  2585. return 0;
  2586. }
  2587. /*==========================================
  2588. * charunblock command (usage: charunblock <player_name>)
  2589. *------------------------------------------*/
  2590. ACMD_FUNC(char_unblock)
  2591. {
  2592. nullpo_retr(-1, sd);
  2593. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2594. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2595. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2596. clif_displaymessage(fd, atcmd_output);
  2597. return -1;
  2598. }
  2599. // send answer to login server via char-server
  2600. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2601. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2602. clif_displaymessage(fd, atcmd_output);
  2603. return 0;
  2604. }
  2605. /*==========================================
  2606. * acc unban command (usage: unban <player_name>)
  2607. * char unban command (usage: charunban <player_name>)
  2608. *------------------------------------------*/
  2609. ACMD_FUNC(char_unban){
  2610. int unbantype = 0;
  2611. nullpo_retr(-1, sd);
  2612. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2613. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2614. parent_cmd = atcommand_checkalias(command+1);
  2615. if (strcmpi(parent_cmd,"charunban") == 0)
  2616. unbantype = CHRIF_OP_UNBAN;
  2617. else if (strcmpi(parent_cmd,"unban") == 0)
  2618. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2619. else
  2620. return -1;
  2621. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2622. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2623. clif_displaymessage(fd, atcmd_output);
  2624. return -1;
  2625. }
  2626. if (unbantype == CHRIF_OP_UNBAN)
  2627. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2628. else
  2629. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2630. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2631. clif_displaymessage(fd, atcmd_output);
  2632. return 0;
  2633. }
  2634. /*==========================================
  2635. *
  2636. *------------------------------------------*/
  2637. ACMD_FUNC(night)
  2638. {
  2639. nullpo_retr(-1, sd);
  2640. if (night_flag != 1) {
  2641. map_night_timer(night_timer_tid, 0, 0, 1);
  2642. } else {
  2643. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2644. return -1;
  2645. }
  2646. return 0;
  2647. }
  2648. /*==========================================
  2649. *
  2650. *------------------------------------------*/
  2651. ACMD_FUNC(day)
  2652. {
  2653. nullpo_retr(-1, sd);
  2654. if (night_flag != 0) {
  2655. map_day_timer(day_timer_tid, 0, 0, 1);
  2656. } else {
  2657. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2658. return -1;
  2659. }
  2660. return 0;
  2661. }
  2662. /*==========================================
  2663. *
  2664. *------------------------------------------*/
  2665. ACMD_FUNC(doom)
  2666. {
  2667. struct map_session_data* pl_sd;
  2668. struct s_mapiterator* iter;
  2669. nullpo_retr(-1, sd);
  2670. iter = mapit_getallusers();
  2671. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2672. {
  2673. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2674. {
  2675. status_kill(&pl_sd->bl);
  2676. clif_specialeffect(&pl_sd->bl,450,AREA);
  2677. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2678. }
  2679. }
  2680. mapit_free(iter);
  2681. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2682. return 0;
  2683. }
  2684. /*==========================================
  2685. *
  2686. *------------------------------------------*/
  2687. ACMD_FUNC(doommap)
  2688. {
  2689. struct map_session_data* pl_sd;
  2690. struct s_mapiterator* iter;
  2691. nullpo_retr(-1, sd);
  2692. iter = mapit_getallusers();
  2693. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2694. {
  2695. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2696. {
  2697. status_kill(&pl_sd->bl);
  2698. clif_specialeffect(&pl_sd->bl,450,AREA);
  2699. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2700. }
  2701. }
  2702. mapit_free(iter);
  2703. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2704. return 0;
  2705. }
  2706. /*==========================================
  2707. *
  2708. *------------------------------------------*/
  2709. static void atcommand_raise_sub(struct map_session_data* sd) {
  2710. status_revive(&sd->bl, 100, 100);
  2711. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2712. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2713. }
  2714. /*==========================================
  2715. *
  2716. *------------------------------------------*/
  2717. ACMD_FUNC(raise)
  2718. {
  2719. struct map_session_data* pl_sd;
  2720. struct s_mapiterator* iter;
  2721. nullpo_retr(-1, sd);
  2722. iter = mapit_getallusers();
  2723. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2724. if( pc_isdead(pl_sd) )
  2725. atcommand_raise_sub(pl_sd);
  2726. mapit_free(iter);
  2727. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2728. return 0;
  2729. }
  2730. /*==========================================
  2731. *
  2732. *------------------------------------------*/
  2733. ACMD_FUNC(raisemap)
  2734. {
  2735. struct map_session_data* pl_sd;
  2736. struct s_mapiterator* iter;
  2737. nullpo_retr(-1, sd);
  2738. iter = mapit_getallusers();
  2739. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2740. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2741. atcommand_raise_sub(pl_sd);
  2742. mapit_free(iter);
  2743. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2744. return 0;
  2745. }
  2746. /*==========================================
  2747. *
  2748. *------------------------------------------*/
  2749. ACMD_FUNC(kick)
  2750. {
  2751. struct map_session_data *pl_sd;
  2752. nullpo_retr(-1, sd);
  2753. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2754. if (!message || !*message) {
  2755. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2756. return -1;
  2757. }
  2758. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2759. {
  2760. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2761. return -1;
  2762. }
  2763. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2764. {
  2765. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2766. return -1;
  2767. }
  2768. clif_GM_kick(sd, pl_sd);
  2769. return 0;
  2770. }
  2771. /*==========================================
  2772. *
  2773. *------------------------------------------*/
  2774. ACMD_FUNC(kickall)
  2775. {
  2776. struct map_session_data* pl_sd;
  2777. struct s_mapiterator* iter;
  2778. nullpo_retr(-1, sd);
  2779. iter = mapit_getallusers();
  2780. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2781. {
  2782. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2783. if (sd->status.account_id != pl_sd->status.account_id)
  2784. clif_GM_kick(NULL, pl_sd);
  2785. }
  2786. }
  2787. mapit_free(iter);
  2788. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2789. return 0;
  2790. }
  2791. /*==========================================
  2792. *
  2793. *------------------------------------------*/
  2794. ACMD_FUNC(allskill)
  2795. {
  2796. nullpo_retr(-1, sd);
  2797. pc_allskillup(sd); // all skills
  2798. sd->status.skill_point = 0; // 0 skill points
  2799. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2800. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2801. return 0;
  2802. }
  2803. /*==========================================
  2804. *
  2805. *------------------------------------------*/
  2806. ACMD_FUNC(questskill)
  2807. {
  2808. uint16 skill_id;
  2809. nullpo_retr(-1, sd);
  2810. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2811. {// also send a list of skills applicable to this command
  2812. const char* text;
  2813. // attempt to find the text corresponding to this command
  2814. text = atcommand_help_string( command );
  2815. // send the error message as always
  2816. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2817. if( text )
  2818. {// send the skill ID list associated with this command
  2819. clif_displaymessage( fd, text );
  2820. }
  2821. return -1;
  2822. }
  2823. if (skill_id >= MAX_SKILL_ID) {
  2824. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2825. return -1;
  2826. }
  2827. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2828. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2829. return -1;
  2830. }
  2831. if (pc_checkskill(sd, skill_id) > 0) {
  2832. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2833. return -1;
  2834. }
  2835. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2836. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2837. return 0;
  2838. }
  2839. /*==========================================
  2840. *
  2841. *------------------------------------------*/
  2842. ACMD_FUNC(lostskill)
  2843. {
  2844. uint16 skill_id = 0, sk_idx = 0;
  2845. nullpo_retr(-1, sd);
  2846. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2847. {// also send a list of skills applicable to this command
  2848. const char* text;
  2849. // attempt to find the text corresponding to this command
  2850. text = atcommand_help_string( command );
  2851. // send the error message as always
  2852. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2853. if( text )
  2854. {// send the skill ID list associated with this command
  2855. clif_displaymessage( fd, text );
  2856. }
  2857. return -1;
  2858. }
  2859. if (!(sk_idx = skill_get_index(skill_id))) {
  2860. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2861. return -1;
  2862. }
  2863. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2864. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2865. return -1;
  2866. }
  2867. if (pc_checkskill(sd, skill_id) == 0) {
  2868. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2869. return -1;
  2870. }
  2871. sd->status.skill[sk_idx].lv = 0;
  2872. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2873. clif_deleteskill(sd,skill_id);
  2874. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2875. return 0;
  2876. }
  2877. /*==========================================
  2878. *
  2879. *------------------------------------------*/
  2880. ACMD_FUNC(spiritball)
  2881. {
  2882. uint32 max_spiritballs;
  2883. int number;
  2884. nullpo_retr(-1, sd);
  2885. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2886. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2887. {
  2888. char msg[CHAT_SIZE_MAX];
  2889. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2890. clif_displaymessage(fd, msg);
  2891. return -1;
  2892. }
  2893. if( sd->spiritball > 0 )
  2894. pc_delspiritball(sd, sd->spiritball, 1);
  2895. sd->spiritball = number;
  2896. clif_spiritball(&sd->bl);
  2897. // no message, player can look the difference
  2898. return 0;
  2899. }
  2900. /*==========================================
  2901. *
  2902. *------------------------------------------*/
  2903. ACMD_FUNC(party)
  2904. {
  2905. char party[NAME_LENGTH];
  2906. nullpo_retr(-1, sd);
  2907. memset(party, '\0', sizeof(party));
  2908. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2909. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2910. return -1;
  2911. }
  2912. party_create(sd, party, 0, 0);
  2913. return 0;
  2914. }
  2915. /*==========================================
  2916. *
  2917. *------------------------------------------*/
  2918. ACMD_FUNC(guild)
  2919. {
  2920. char guild[NAME_LENGTH];
  2921. int prev;
  2922. nullpo_retr(-1, sd);
  2923. memset(guild, '\0', sizeof(guild));
  2924. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2925. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2926. return -1;
  2927. }
  2928. prev = battle_config.guild_emperium_check;
  2929. battle_config.guild_emperium_check = 0;
  2930. guild_create(sd, guild);
  2931. battle_config.guild_emperium_check = prev;
  2932. return 0;
  2933. }
  2934. ACMD_FUNC(breakguild)
  2935. {
  2936. nullpo_retr(-1, sd);
  2937. if (sd->status.guild_id) { // Check if the player has a guild
  2938. struct guild *g;
  2939. g = sd->guild; // Search the guild
  2940. if (g) { // Check if guild was found
  2941. if (sd->state.gmaster_flag) { // Check if player is guild master
  2942. int ret = 0;
  2943. ret = guild_break(sd, g->name); // Break guild
  2944. if (ret) { // Check if anything went wrong
  2945. return 0; // Guild was broken
  2946. } else {
  2947. return -1; // Something went wrong
  2948. }
  2949. } else { // Not guild master
  2950. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2951. return -1;
  2952. }
  2953. } else { // Guild was not found. HOW?
  2954. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2955. return -1;
  2956. }
  2957. } else { // Player does not have a guild
  2958. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2959. return -1;
  2960. }
  2961. return 0;
  2962. }
  2963. /*==========================================
  2964. *
  2965. *------------------------------------------*/
  2966. ACMD_FUNC(agitstart)
  2967. {
  2968. nullpo_retr(-1, sd);
  2969. if (agit_flag == 1) {
  2970. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2971. return -1;
  2972. }
  2973. agit_flag = 1;
  2974. guild_agit_start();
  2975. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2976. return 0;
  2977. }
  2978. /*==========================================
  2979. *
  2980. *------------------------------------------*/
  2981. ACMD_FUNC(agitstart2)
  2982. {
  2983. nullpo_retr(-1, sd);
  2984. if (agit2_flag == 1) {
  2985. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2986. return -1;
  2987. }
  2988. agit2_flag = 1;
  2989. guild_agit2_start();
  2990. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2991. return 0;
  2992. }
  2993. /*==========================================
  2994. *
  2995. *------------------------------------------*/
  2996. ACMD_FUNC(agitend)
  2997. {
  2998. nullpo_retr(-1, sd);
  2999. if (agit_flag == 0) {
  3000. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3001. return -1;
  3002. }
  3003. agit_flag = 0;
  3004. guild_agit_end();
  3005. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3006. return 0;
  3007. }
  3008. /*==========================================
  3009. *
  3010. *------------------------------------------*/
  3011. ACMD_FUNC(agitend2)
  3012. {
  3013. nullpo_retr(-1, sd);
  3014. if (agit2_flag == 0) {
  3015. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3016. return -1;
  3017. }
  3018. agit2_flag = 0;
  3019. guild_agit2_end();
  3020. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3021. return 0;
  3022. }
  3023. /*==========================================
  3024. * @mapexit - shuts down the map server
  3025. *------------------------------------------*/
  3026. ACMD_FUNC(mapexit)
  3027. {
  3028. nullpo_retr(-1, sd);
  3029. do_shutdown();
  3030. return 0;
  3031. }
  3032. /*==========================================
  3033. * idsearch <part_of_name>: revrited by [Yor]
  3034. *------------------------------------------*/
  3035. ACMD_FUNC(idsearch)
  3036. {
  3037. char item_name[100];
  3038. unsigned int i, match;
  3039. struct item_data *item_array[MAX_SEARCH];
  3040. nullpo_retr(-1, sd);
  3041. memset(item_name, '\0', sizeof(item_name));
  3042. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3043. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3044. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3045. return -1;
  3046. }
  3047. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3048. clif_displaymessage(fd, atcmd_output);
  3049. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3050. if (match > MAX_SEARCH) {
  3051. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  3052. clif_displaymessage(fd, atcmd_output);
  3053. match = MAX_SEARCH;
  3054. }
  3055. for(i = 0; i < match; i++) {
  3056. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3057. clif_displaymessage(fd, atcmd_output);
  3058. }
  3059. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3060. clif_displaymessage(fd, atcmd_output);
  3061. return 0;
  3062. }
  3063. /*==========================================
  3064. * Recall All Characters Online To Your Location
  3065. *------------------------------------------*/
  3066. ACMD_FUNC(recallall)
  3067. {
  3068. struct map_session_data* pl_sd;
  3069. struct s_mapiterator* iter;
  3070. int count;
  3071. nullpo_retr(-1, sd);
  3072. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3073. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3074. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3075. return -1;
  3076. }
  3077. count = 0;
  3078. iter = mapit_getallusers();
  3079. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3080. {
  3081. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3082. {
  3083. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3084. continue; // Don't waste time warping the character to the same place.
  3085. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3086. count++;
  3087. else {
  3088. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3089. count++;
  3090. }
  3091. }
  3092. }
  3093. }
  3094. mapit_free(iter);
  3095. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3096. if (count) {
  3097. 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.
  3098. clif_displaymessage(fd, atcmd_output);
  3099. }
  3100. return 0;
  3101. }
  3102. /*==========================================
  3103. * Recall online characters of a guild to your location
  3104. *------------------------------------------*/
  3105. ACMD_FUNC(guildrecall)
  3106. {
  3107. struct map_session_data* pl_sd;
  3108. struct s_mapiterator* iter;
  3109. int count;
  3110. char guild_name[NAME_LENGTH];
  3111. struct guild *g;
  3112. nullpo_retr(-1, sd);
  3113. memset(guild_name, '\0', sizeof(guild_name));
  3114. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3115. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3116. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3117. return -1;
  3118. }
  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. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3124. (g = guild_search(atoi(message))) == NULL)
  3125. {
  3126. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3127. return -1;
  3128. }
  3129. count = 0;
  3130. iter = mapit_getallusers();
  3131. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3132. {
  3133. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3134. {
  3135. 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))
  3136. continue; // Skip GMs greater than you... or chars already on the cell
  3137. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3138. count++;
  3139. else{
  3140. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3141. count++;
  3142. }
  3143. }
  3144. }
  3145. }
  3146. mapit_free(iter);
  3147. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3148. clif_displaymessage(fd, atcmd_output);
  3149. if (count) {
  3150. 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.
  3151. clif_displaymessage(fd, atcmd_output);
  3152. }
  3153. return 0;
  3154. }
  3155. /*==========================================
  3156. * Recall online characters of a party to your location
  3157. *------------------------------------------*/
  3158. ACMD_FUNC(partyrecall)
  3159. {
  3160. struct map_session_data* pl_sd;
  3161. struct s_mapiterator* iter;
  3162. char party_name[NAME_LENGTH];
  3163. struct party_data *p;
  3164. int count;
  3165. nullpo_retr(-1, sd);
  3166. memset(party_name, '\0', sizeof(party_name));
  3167. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3168. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3169. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3170. return -1;
  3171. }
  3172. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3173. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3174. return -1;
  3175. }
  3176. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3177. (p = party_search(atoi(message))) == NULL)
  3178. {
  3179. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3180. return -1;
  3181. }
  3182. count = 0;
  3183. iter = mapit_getallusers();
  3184. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3185. {
  3186. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3187. {
  3188. 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))
  3189. continue; // Skip GMs greater than you... or chars already on the cell
  3190. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3191. count++;
  3192. else{
  3193. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3194. count++;
  3195. }
  3196. }
  3197. }
  3198. }
  3199. mapit_free(iter);
  3200. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3201. clif_displaymessage(fd, atcmd_output);
  3202. if (count) {
  3203. 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.
  3204. clif_displaymessage(fd, atcmd_output);
  3205. }
  3206. return 0;
  3207. }
  3208. /*==========================================
  3209. *
  3210. *------------------------------------------*/
  3211. void atcommand_doload();
  3212. ACMD_FUNC(reload) {
  3213. nullpo_retr(-1, sd);
  3214. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3215. const char* text;
  3216. text = atcommand_help_string( command );
  3217. if(text)
  3218. clif_displaymessage( fd, text );
  3219. return -1;
  3220. }
  3221. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3222. itemdb_reload();
  3223. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3224. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3225. mob_reload();
  3226. read_petdb();
  3227. hom_reload();
  3228. mercenary_readdb();
  3229. mercenary_read_skilldb();
  3230. reload_elementaldb();
  3231. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3232. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3233. skill_reload();
  3234. hom_reload_skill();
  3235. reload_elemental_skilldb();
  3236. mercenary_read_skilldb();
  3237. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3238. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3239. config_t run_test;
  3240. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3241. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3242. return -1;
  3243. }
  3244. config_destroy(&run_test);
  3245. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3246. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3247. return -1;
  3248. }
  3249. config_destroy(&run_test);
  3250. atcommand_doload();
  3251. pc_groups_reload();
  3252. clif_displaymessage(fd, msg_txt(sd,254));
  3253. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3254. struct Battle_Config prev_config;
  3255. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3256. battle_config_read(BATTLE_CONF_FILENAME);
  3257. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3258. || prev_config.item_rate_common != battle_config.item_rate_common
  3259. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3260. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3261. || prev_config.item_rate_card != battle_config.item_rate_card
  3262. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3263. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3264. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3265. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3266. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3267. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3268. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3269. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3270. || prev_config.item_rate_use != battle_config.item_rate_use
  3271. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3272. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3273. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3274. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3275. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3276. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3277. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3278. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3279. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3280. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3281. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3282. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3283. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3284. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3285. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3286. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3287. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3288. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3289. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3290. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3291. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3292. )
  3293. { // Exp or Drop rates changed.
  3294. mob_reload(); //Needed as well so rate changes take effect.
  3295. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3296. }
  3297. clif_displaymessage(fd, msg_txt(sd,255));
  3298. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3299. status_readdb();
  3300. clif_displaymessage(fd, msg_txt(sd,256));
  3301. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3302. pc_readdb();
  3303. clif_displaymessage(fd, msg_txt(sd,257));
  3304. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3305. pc_read_motd();
  3306. clif_displaymessage(fd, msg_txt(sd,268));
  3307. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3308. struct s_mapiterator* iter;
  3309. struct map_session_data* pl_sd;
  3310. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3311. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3312. iter = mapit_getallusers();
  3313. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3314. pc_close_npc(pl_sd,2);
  3315. mapit_free(iter);
  3316. flush_fifos();
  3317. map_reloadnpc(true); // reload config files seeking for npcs
  3318. script_reload();
  3319. npc_reload();
  3320. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3321. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3322. map_msg_reload();
  3323. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3324. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3325. do_reload_quest();
  3326. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3327. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3328. packetdb_readdb(true);
  3329. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3330. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3331. instance_reload();
  3332. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3333. }
  3334. return 0;
  3335. }
  3336. /*==========================================
  3337. * @partysharelvl <share_range> [Akinari]
  3338. * Updates char server party share level range in runtime
  3339. * Temporary - Permanent update in inter_athena.conf
  3340. *------------------------------------------*/
  3341. ACMD_FUNC(partysharelvl) {
  3342. unsigned int share_lvl;
  3343. nullpo_retr(-1, sd);
  3344. if(!message || !*message) {
  3345. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3346. return -1;
  3347. } else {
  3348. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3349. }
  3350. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3351. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3352. else //Char server offline
  3353. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3354. return 0;
  3355. }
  3356. /*==========================================
  3357. * @mapinfo [0-3] <map name> by MC_Cameri
  3358. * => Shows information about the map [map name]
  3359. * 0 = no additional information
  3360. * 1 = Show users in that map and their location
  3361. * 2 = Shows NPCs in that map
  3362. * 3 = Shows the chats in that map
  3363. *------------------------------------------*/
  3364. ACMD_FUNC(mapinfo) {
  3365. struct map_session_data* pl_sd;
  3366. struct s_mapiterator* iter;
  3367. struct chat_data *cd = NULL;
  3368. char direction[12];
  3369. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3370. unsigned short m_index;
  3371. char mapname[24];
  3372. nullpo_retr(-1, sd);
  3373. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3374. memset(mapname, '\0', sizeof(mapname));
  3375. memset(direction, '\0', sizeof(direction));
  3376. sscanf(message, "%11d %23[^\n]", &list, mapname);
  3377. if (list < 0 || list > 3) {
  3378. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3379. return -1;
  3380. }
  3381. if (mapname[0] == '\0') {
  3382. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3383. m_id = map_mapindex2mapid(sd->mapindex);
  3384. } else {
  3385. m_id = map_mapname2mapid(mapname);
  3386. }
  3387. if (m_id < 0) {
  3388. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3389. return -1;
  3390. }
  3391. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3392. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3393. // count chats (for initial message)
  3394. chat_num = 0;
  3395. iter = mapit_getallusers();
  3396. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3397. if( pl_sd->mapindex == m_index ) {
  3398. if( pl_sd->state.vending )
  3399. vend_num++;
  3400. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3401. chat_num++;
  3402. }
  3403. }
  3404. mapit_free(iter);
  3405. 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
  3406. clif_displaymessage(fd, atcmd_output);
  3407. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3408. if (map[m_id].flag.town)
  3409. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3410. if (map[m_id].flag.restricted){
  3411. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3412. clif_displaymessage(fd, atcmd_output);
  3413. }
  3414. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3415. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3416. else
  3417. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3418. if (map[m_id].flag.battleground){
  3419. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3420. clif_displaymessage(fd, atcmd_output);
  3421. }
  3422. /* Skill damage adjustment info [Cydh] */
  3423. #ifdef ADJUST_SKILL_DAMAGE
  3424. if (map[m_id].flag.skill_damage) {
  3425. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3426. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3427. ,map[m_id].adjust.damage.pc
  3428. ,map[m_id].adjust.damage.mob
  3429. ,map[m_id].adjust.damage.boss
  3430. ,map[m_id].adjust.damage.other
  3431. ,map[m_id].adjust.damage.caster);
  3432. clif_displaymessage(fd, atcmd_output);
  3433. if (map[m_id].skill_damage.count) {
  3434. uint8 j;
  3435. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3436. for (j = 0; j < map[m_id].skill_damage.count; j++) {
  3437. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3438. ,j+1
  3439. ,skill_get_name(map[m_id].skill_damage.entries[j]->skill_id)
  3440. ,map[m_id].skill_damage.entries[j]->pc
  3441. ,map[m_id].skill_damage.entries[j]->mob
  3442. ,map[m_id].skill_damage.entries[j]->boss
  3443. ,map[m_id].skill_damage.entries[j]->other
  3444. ,map[m_id].skill_damage.entries[j]->caster);
  3445. clif_displaymessage(fd,atcmd_output);
  3446. }
  3447. }
  3448. }
  3449. #endif
  3450. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3451. if (map[m_id].flag.pvp)
  3452. strcat(atcmd_output, " Pvp ON |");
  3453. if (map[m_id].flag.pvp_noguild)
  3454. strcat(atcmd_output, " NoGuild |");
  3455. if (map[m_id].flag.pvp_noparty)
  3456. strcat(atcmd_output, " NoParty |");
  3457. if (map[m_id].flag.pvp_nightmaredrop)
  3458. strcat(atcmd_output, " NightmareDrop |");
  3459. if (map[m_id].flag.pvp_nocalcrank)
  3460. strcat(atcmd_output, " NoCalcRank |");
  3461. clif_displaymessage(fd, atcmd_output);
  3462. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3463. if (map[m_id].flag.gvg)
  3464. strcat(atcmd_output, " GvG ON |");
  3465. if (map[m_id].flag.gvg_dungeon)
  3466. strcat(atcmd_output, " GvG Dungeon |");
  3467. if (map[m_id].flag.gvg_castle)
  3468. strcat(atcmd_output, " GvG Castle |");
  3469. if (map[m_id].flag.gvg_noparty)
  3470. strcat(atcmd_output, " NoParty |");
  3471. clif_displaymessage(fd, atcmd_output);
  3472. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3473. if (map[m_id].flag.noteleport)
  3474. strcat(atcmd_output, " NoTeleport |");
  3475. if (map[m_id].flag.monster_noteleport)
  3476. strcat(atcmd_output, " Monster NoTeleport |");
  3477. if (map[m_id].flag.nowarp)
  3478. strcat(atcmd_output, " NoWarp |");
  3479. if (map[m_id].flag.nowarpto)
  3480. strcat(atcmd_output, " NoWarpTo |");
  3481. if (map[m_id].flag.noreturn)
  3482. strcat(atcmd_output, " NoReturn |");
  3483. if (map[m_id].flag.nogo)
  3484. strcat(atcmd_output, " NoGo |"); //
  3485. if (map[m_id].flag.nomemo)
  3486. strcat(atcmd_output, " NoMemo |");
  3487. clif_displaymessage(fd, atcmd_output);
  3488. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3489. (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
  3490. clif_displaymessage(fd, atcmd_output);
  3491. if (map[m_id].flag.nosave) {
  3492. if (!map[m_id].save.map)
  3493. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3494. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3495. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3496. clif_displaymessage(fd, atcmd_output);
  3497. }
  3498. else {
  3499. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3500. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3501. clif_displaymessage(fd, atcmd_output);
  3502. }
  3503. }
  3504. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3505. if (map[m_id].flag.snow)
  3506. strcat(atcmd_output, " Snow |");
  3507. if (map[m_id].flag.fog)
  3508. strcat(atcmd_output, " Fog |");
  3509. if (map[m_id].flag.sakura)
  3510. strcat(atcmd_output, " Sakura |");
  3511. if (map[m_id].flag.clouds)
  3512. strcat(atcmd_output, " Clouds |");
  3513. if (map[m_id].flag.clouds2)
  3514. strcat(atcmd_output, " Clouds2 |");
  3515. if (map[m_id].flag.fireworks)
  3516. strcat(atcmd_output, " Fireworks |");
  3517. if (map[m_id].flag.leaves)
  3518. strcat(atcmd_output, " Leaves |");
  3519. if (map[m_id].flag.nightenabled)
  3520. strcat(atcmd_output, " Displays Night |");
  3521. clif_displaymessage(fd, atcmd_output);
  3522. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3523. if (map[m_id].flag.nobranch)
  3524. strcat(atcmd_output, " NoBranch |");
  3525. if (map[m_id].flag.notrade)
  3526. strcat(atcmd_output, " NoTrade |");
  3527. if (map[m_id].flag.novending)
  3528. strcat(atcmd_output, " NoVending |");
  3529. if (map[m_id].flag.nodrop)
  3530. strcat(atcmd_output, " NoDrop |");
  3531. if (map[m_id].flag.noskill)
  3532. strcat(atcmd_output, " NoSkill |");
  3533. if (map[m_id].flag.noicewall)
  3534. strcat(atcmd_output, " NoIcewall |");
  3535. if (map[m_id].flag.allowks)
  3536. strcat(atcmd_output, " AllowKS |");
  3537. if (map[m_id].flag.reset)
  3538. strcat(atcmd_output, " Reset |");
  3539. clif_displaymessage(fd, atcmd_output);
  3540. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3541. if (map[m_id].nocommand)
  3542. strcat(atcmd_output, " NoCommand |");
  3543. if (map[m_id].flag.nobaseexp)
  3544. strcat(atcmd_output, " NoBaseEXP |");
  3545. if (map[m_id].flag.nojobexp)
  3546. strcat(atcmd_output, " NoJobEXP |");
  3547. if (map[m_id].flag.nomobloot)
  3548. strcat(atcmd_output, " NoMobLoot |");
  3549. if (map[m_id].flag.nomvploot)
  3550. strcat(atcmd_output, " NoMVPLoot |");
  3551. if (map[m_id].flag.partylock)
  3552. strcat(atcmd_output, " PartyLock |");
  3553. if (map[m_id].flag.guildlock)
  3554. strcat(atcmd_output, " GuildLock |");
  3555. if (map[m_id].flag.loadevent)
  3556. strcat(atcmd_output, " Loadevent |");
  3557. if (map[m_id].flag.chmautojoin)
  3558. strcat(atcmd_output, " Chmautojoin |");
  3559. if (map[m_id].flag.nousecart)
  3560. strcat(atcmd_output, " NoUsecart |");
  3561. if (map[m_id].flag.noitemconsumption)
  3562. strcat(atcmd_output, " NoItemConsumption |");
  3563. if (map[m_id].flag.nosumstarmiracle)
  3564. strcat(atcmd_output, " NoSumStarMiracle |");
  3565. if (map[m_id].flag.nomineeffect)
  3566. strcat(atcmd_output, " NoMineEffect |");
  3567. if (map[m_id].flag.nolockon)
  3568. strcat(atcmd_output, " NoLockOn |");
  3569. if (map[m_id].flag.notomb)
  3570. strcat(atcmd_output, " NoTomb |");
  3571. clif_displaymessage(fd, atcmd_output);
  3572. switch (list) {
  3573. case 0:
  3574. // Do nothing. It's list 0, no additional display.
  3575. break;
  3576. case 1:
  3577. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3578. iter = mapit_getallusers();
  3579. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3580. {
  3581. if (pl_sd->mapindex == m_index) {
  3582. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3583. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3584. clif_displaymessage(fd, atcmd_output);
  3585. }
  3586. }
  3587. mapit_free(iter);
  3588. break;
  3589. case 2:
  3590. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3591. for (i = 0; i < map[m_id].npc_num;)
  3592. {
  3593. struct npc_data *nd = map[m_id].npc[i];
  3594. switch(nd->ud.dir) {
  3595. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  3596. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  3597. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  3598. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  3599. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  3600. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  3601. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  3602. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  3603. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  3604. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3605. }
  3606. if(strcmp(nd->name,nd->exname) == 0)
  3607. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3608. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3609. else
  3610. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3611. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3612. clif_displaymessage(fd, atcmd_output);
  3613. }
  3614. break;
  3615. case 3:
  3616. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3617. iter = mapit_getallusers();
  3618. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3619. {
  3620. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3621. pl_sd->mapindex == m_index &&
  3622. cd->usersd[0] == pl_sd)
  3623. {
  3624. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3625. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3626. clif_displaymessage(fd, atcmd_output);
  3627. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3628. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3629. clif_displaymessage(fd, atcmd_output);
  3630. }
  3631. }
  3632. mapit_free(iter);
  3633. break;
  3634. default: // normally impossible to arrive here
  3635. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3636. return -1;
  3637. break;
  3638. }
  3639. return 0;
  3640. }
  3641. /*==========================================
  3642. *
  3643. *------------------------------------------*/
  3644. ACMD_FUNC(mount_peco)
  3645. {
  3646. nullpo_retr(-1, sd);
  3647. if (sd->disguise) {
  3648. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3649. return -1;
  3650. }
  3651. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3652. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3653. unsigned int option = OPTION_DRAGON1;
  3654. if( message[0] ) {
  3655. int color = atoi(message);
  3656. option = ( color == 2 ? OPTION_DRAGON2 :
  3657. color == 3 ? OPTION_DRAGON3 :
  3658. color == 4 ? OPTION_DRAGON4 :
  3659. color == 5 ? OPTION_DRAGON5 :
  3660. OPTION_DRAGON1 );
  3661. }
  3662. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3663. pc_setoption(sd, sd->sc.option|option);
  3664. } else {
  3665. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3666. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3667. }
  3668. return 0;
  3669. }
  3670. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3671. if( !pc_isridingwug(sd) ) {
  3672. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3673. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3674. } else {
  3675. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3676. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3677. }
  3678. return 0;
  3679. }
  3680. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3681. if( !pc_ismadogear(sd) ) {
  3682. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3683. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3684. } else {
  3685. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3686. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3687. }
  3688. return 0;
  3689. }
  3690. if (!pc_isriding(sd)) { // if actually no peco
  3691. if (!pc_checkskill(sd, KN_RIDING)) {
  3692. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3693. return -1;
  3694. }
  3695. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3696. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3697. } else {//Dismount
  3698. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3699. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3700. }
  3701. return 0;
  3702. }
  3703. /*==========================================
  3704. *Spy Commands by Syrus22
  3705. *------------------------------------------*/
  3706. ACMD_FUNC(guildspy)
  3707. {
  3708. char guild_name[NAME_LENGTH];
  3709. struct guild *g;
  3710. nullpo_retr(-1, sd);
  3711. memset(guild_name, '\0', sizeof(guild_name));
  3712. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3713. if (!enable_spy)
  3714. {
  3715. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3716. return -1;
  3717. }
  3718. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3719. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3720. return -1;
  3721. }
  3722. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3723. (g = guild_search(atoi(message))) != NULL) {
  3724. if (sd->guildspy == g->guild_id) {
  3725. sd->guildspy = 0;
  3726. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3727. clif_displaymessage(fd, atcmd_output);
  3728. } else {
  3729. sd->guildspy = g->guild_id;
  3730. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3731. clif_displaymessage(fd, atcmd_output);
  3732. }
  3733. } else {
  3734. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3735. return -1;
  3736. }
  3737. return 0;
  3738. }
  3739. /*==========================================
  3740. *
  3741. *------------------------------------------*/
  3742. ACMD_FUNC(partyspy)
  3743. {
  3744. char party_name[NAME_LENGTH];
  3745. struct party_data *p;
  3746. nullpo_retr(-1, sd);
  3747. memset(party_name, '\0', sizeof(party_name));
  3748. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3749. if (!enable_spy)
  3750. {
  3751. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3752. return -1;
  3753. }
  3754. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3755. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3756. return -1;
  3757. }
  3758. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3759. (p = party_search(atoi(message))) != NULL) {
  3760. if (sd->partyspy == p->party.party_id) {
  3761. sd->partyspy = 0;
  3762. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3763. clif_displaymessage(fd, atcmd_output);
  3764. } else {
  3765. sd->partyspy = p->party.party_id;
  3766. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3767. clif_displaymessage(fd, atcmd_output);
  3768. }
  3769. } else {
  3770. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3771. return -1;
  3772. }
  3773. return 0;
  3774. }
  3775. /*==========================================
  3776. * @repairall [Valaris]
  3777. *------------------------------------------*/
  3778. ACMD_FUNC(repairall)
  3779. {
  3780. int count, i;
  3781. nullpo_retr(-1, sd);
  3782. count = 0;
  3783. for (i = 0; i < MAX_INVENTORY; i++) {
  3784. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3785. sd->status.inventory[i].attribute = 0;
  3786. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3787. count++;
  3788. }
  3789. }
  3790. if (count > 0) {
  3791. clif_misceffect(&sd->bl, 3);
  3792. clif_equiplist(sd);
  3793. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3794. } else {
  3795. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3796. return -1;
  3797. }
  3798. return 0;
  3799. }
  3800. /*==========================================
  3801. * @nuke [Valaris]
  3802. *------------------------------------------*/
  3803. ACMD_FUNC(nuke)
  3804. {
  3805. struct map_session_data *pl_sd;
  3806. nullpo_retr(-1, sd);
  3807. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3808. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3809. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3810. return -1;
  3811. }
  3812. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3813. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3814. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3815. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3816. } else {
  3817. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3818. return -1;
  3819. }
  3820. } else {
  3821. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3822. return -1;
  3823. }
  3824. return 0;
  3825. }
  3826. /*==========================================
  3827. * @tonpc
  3828. *------------------------------------------*/
  3829. ACMD_FUNC(tonpc)
  3830. {
  3831. char npcname[NAME_LENGTH+1];
  3832. struct npc_data *nd;
  3833. nullpo_retr(-1, sd);
  3834. memset(npcname, 0, sizeof(npcname));
  3835. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3836. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3837. return -1;
  3838. }
  3839. if ((nd = npc_name2id(npcname)) != NULL) {
  3840. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  3841. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3842. else
  3843. return -1;
  3844. } else {
  3845. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3846. return -1;
  3847. }
  3848. return 0;
  3849. }
  3850. /*==========================================
  3851. *
  3852. *------------------------------------------*/
  3853. ACMD_FUNC(shownpc)
  3854. {
  3855. char NPCname[NAME_LENGTH+1];
  3856. nullpo_retr(-1, sd);
  3857. memset(NPCname, '\0', sizeof(NPCname));
  3858. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3859. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3860. return -1;
  3861. }
  3862. if (npc_name2id(NPCname) != NULL) {
  3863. npc_enable(NPCname, 1);
  3864. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3865. } else {
  3866. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3867. return -1;
  3868. }
  3869. return 0;
  3870. }
  3871. /*==========================================
  3872. *
  3873. *------------------------------------------*/
  3874. ACMD_FUNC(hidenpc)
  3875. {
  3876. char NPCname[NAME_LENGTH+1];
  3877. nullpo_retr(-1, sd);
  3878. memset(NPCname, '\0', sizeof(NPCname));
  3879. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3880. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3881. return -1;
  3882. }
  3883. if (npc_name2id(NPCname) == NULL) {
  3884. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3885. return -1;
  3886. }
  3887. npc_enable(NPCname, 0);
  3888. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3889. return 0;
  3890. }
  3891. ACMD_FUNC(loadnpc)
  3892. {
  3893. if (!message || !*message) {
  3894. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3895. return -1;
  3896. }
  3897. // add to list of script sources and run it
  3898. if( !npc_addsrcfile(message) //try to read file
  3899. || !npc_parsesrcfile(message,true)
  3900. ){
  3901. clif_displaymessage(fd, msg_txt(sd,261));
  3902. return -1;
  3903. }
  3904. npc_read_event_script();
  3905. clif_displaymessage(fd, msg_txt(sd,262));
  3906. return 0;
  3907. }
  3908. ACMD_FUNC(unloadnpc)
  3909. {
  3910. struct npc_data *nd;
  3911. char NPCname[NAME_LENGTH];
  3912. nullpo_retr(-1, sd);
  3913. memset(NPCname, '\0', sizeof(NPCname));
  3914. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3915. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3916. return -1;
  3917. }
  3918. if ((nd = npc_name2id(NPCname)) == NULL) {
  3919. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3920. return -1;
  3921. }
  3922. npc_unload_duplicates(nd);
  3923. npc_unload(nd,true);
  3924. npc_read_event_script();
  3925. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3926. return 0;
  3927. }
  3928. /*==========================================
  3929. * time in txt for time command (by [Yor])
  3930. *------------------------------------------*/
  3931. char* txt_time(unsigned int duration)
  3932. {
  3933. int days, hours, minutes, seconds;
  3934. char temp[CHAT_SIZE_MAX];
  3935. static char temp1[CHAT_SIZE_MAX];
  3936. memset(temp, '\0', sizeof(temp));
  3937. memset(temp1, '\0', sizeof(temp1));
  3938. days = duration / (60 * 60 * 24);
  3939. duration = duration - (60 * 60 * 24 * days);
  3940. hours = duration / (60 * 60);
  3941. duration = duration - (60 * 60 * hours);
  3942. minutes = duration / 60;
  3943. seconds = duration - (60 * minutes);
  3944. if (days == 1)
  3945. sprintf(temp, msg_txt(NULL,219), days); // %d day
  3946. else if (days > 1)
  3947. sprintf(temp, msg_txt(NULL,220), days); // %d days
  3948. if (hours == 1)
  3949. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  3950. else if (hours > 1)
  3951. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  3952. if (minutes < 2)
  3953. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  3954. else
  3955. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  3956. if (seconds == 1)
  3957. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  3958. else if (seconds > 1)
  3959. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  3960. return temp1;
  3961. }
  3962. /*==========================================
  3963. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3964. * Calculation management of GM modification (@day/@night GM commands) is done
  3965. *------------------------------------------*/
  3966. ACMD_FUNC(servertime)
  3967. {
  3968. const struct TimerData * timer_data;
  3969. time_t time_server; // variable for number of seconds (used with time() function)
  3970. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3971. char temp[CHAT_SIZE_MAX];
  3972. nullpo_retr(-1, sd);
  3973. memset(temp, '\0', sizeof(temp));
  3974. time(&time_server); // get time in seconds since 1/1/1970
  3975. datetime = localtime(&time_server); // convert seconds in structure
  3976. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3977. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3978. clif_displaymessage(fd, temp);
  3979. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3980. if (night_flag == 0)
  3981. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3982. else
  3983. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3984. } else if (battle_config.night_duration == 0)
  3985. if (night_flag == 1) { // we start with night
  3986. timer_data = get_timer(day_timer_tid);
  3987. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  3988. clif_displaymessage(fd, temp);
  3989. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  3990. } else
  3991. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3992. else if (battle_config.day_duration == 0)
  3993. if (night_flag == 0) { // we start with day
  3994. timer_data = get_timer(night_timer_tid);
  3995. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3996. clif_displaymessage(fd, temp);
  3997. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  3998. } else
  3999. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4000. else {
  4001. const struct TimerData * timer_data2;
  4002. if (night_flag == 0) {
  4003. timer_data = get_timer(night_timer_tid);
  4004. timer_data2 = get_timer(day_timer_tid);
  4005. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4006. clif_displaymessage(fd, temp);
  4007. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4008. 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.
  4009. else
  4010. 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.
  4011. clif_displaymessage(fd, temp);
  4012. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4013. clif_displaymessage(fd, temp);
  4014. } else {
  4015. timer_data = get_timer(day_timer_tid);
  4016. timer_data2 = get_timer(night_timer_tid);
  4017. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4018. clif_displaymessage(fd, temp);
  4019. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4020. 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.
  4021. else
  4022. 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.
  4023. clif_displaymessage(fd, temp);
  4024. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4025. clif_displaymessage(fd, temp);
  4026. }
  4027. }
  4028. return 0;
  4029. }
  4030. /*==========================================
  4031. * @jail <char_name> by [Yor]
  4032. * Special warp! No check with nowarp and nowarpto flag
  4033. *------------------------------------------*/
  4034. ACMD_FUNC(jail)
  4035. {
  4036. struct map_session_data *pl_sd;
  4037. int x, y;
  4038. unsigned short m_index;
  4039. nullpo_retr(-1, sd);
  4040. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4041. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4042. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4043. return -1;
  4044. }
  4045. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4046. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4047. return -1;
  4048. }
  4049. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4050. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4051. return -1;
  4052. }
  4053. if (pl_sd->sc.data[SC_JAILED]) {
  4054. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4055. return -1;
  4056. }
  4057. switch(rnd() % 2) { //Jail Locations
  4058. case 0:
  4059. m_index = mapindex_name2id(MAP_JAIL);
  4060. x = 24;
  4061. y = 75;
  4062. break;
  4063. default:
  4064. m_index = mapindex_name2id(MAP_JAIL);
  4065. x = 49;
  4066. y = 75;
  4067. break;
  4068. }
  4069. //Duration of INT_MAX to specify infinity.
  4070. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4071. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4072. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4073. return 0;
  4074. }
  4075. /*==========================================
  4076. * @unjail/@discharge <char_name> by [Yor]
  4077. * Special warp! No check with nowarp and nowarpto flag
  4078. *------------------------------------------*/
  4079. ACMD_FUNC(unjail)
  4080. {
  4081. struct map_session_data *pl_sd;
  4082. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4083. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4084. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4085. return -1;
  4086. }
  4087. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4088. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4089. return -1;
  4090. }
  4091. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4092. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4093. return -1;
  4094. }
  4095. if (!pl_sd->sc.data[SC_JAILED]) {
  4096. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4097. return -1;
  4098. }
  4099. //Reset jail time to 1 sec.
  4100. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4101. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4102. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4103. return 0;
  4104. }
  4105. ACMD_FUNC(jailfor) {
  4106. struct map_session_data *pl_sd = NULL;
  4107. char * modif_p;
  4108. int jailtime = 0,x,y;
  4109. short m_index = 0;
  4110. nullpo_retr(-1, sd);
  4111. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4112. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4113. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4114. return -1;
  4115. }
  4116. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4117. modif_p = atcmd_output;
  4118. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4119. if (jailtime == 0) {
  4120. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4121. 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.
  4122. return -1;
  4123. }
  4124. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4125. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4126. return -1;
  4127. }
  4128. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4129. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4130. return -1;
  4131. }
  4132. // Added by Coltaro
  4133. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4134. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4135. if (jailtime <= 0) {
  4136. jailtime = 0;
  4137. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4138. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4139. } else {
  4140. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4141. char timestr[21];
  4142. time_t now=time(NULL);
  4143. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4144. 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
  4145. clif_displaymessage(pl_sd->fd, atcmd_output);
  4146. 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
  4147. clif_displaymessage(fd, atcmd_output);
  4148. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4149. sprintf(atcmd_output,"Release date is: %s",timestr);
  4150. clif_displaymessage(pl_sd->fd, atcmd_output);
  4151. clif_displaymessage(fd, atcmd_output);
  4152. }
  4153. } else if (jailtime < 0) {
  4154. clif_displaymessage(fd, msg_txt(sd,1136));
  4155. return -1;
  4156. }
  4157. // Jail locations, add more as you wish.
  4158. switch(rnd()%2) {
  4159. case 1: // Jail #1
  4160. m_index = mapindex_name2id(MAP_JAIL);
  4161. x = 49; y = 75;
  4162. break;
  4163. default: // Default Jail
  4164. m_index = mapindex_name2id(MAP_JAIL);
  4165. x = 24; y = 75;
  4166. break;
  4167. }
  4168. 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).
  4169. return 0;
  4170. }
  4171. //By Coltaro
  4172. ACMD_FUNC(jailtime){
  4173. int year, month, day, hour, minute, second;
  4174. char timestr[21];
  4175. time_t now = time(NULL);
  4176. nullpo_retr(-1, sd);
  4177. if (!sd->sc.data[SC_JAILED]) {
  4178. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4179. return -1;
  4180. }
  4181. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4182. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4183. return 0;
  4184. }
  4185. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4186. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4187. return -1;
  4188. }
  4189. // Get remaining jail time
  4190. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4191. 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
  4192. clif_displaymessage(fd, atcmd_output);
  4193. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4194. sprintf(atcmd_output,"Release date is: %s",timestr);
  4195. clif_displaymessage(fd, atcmd_output);
  4196. return 0;
  4197. }
  4198. /*==========================================
  4199. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4200. *------------------------------------------*/
  4201. ACMD_FUNC(disguise)
  4202. {
  4203. int id = 0;
  4204. nullpo_retr(-1, sd);
  4205. if (!message || !*message) {
  4206. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4207. return -1;
  4208. }
  4209. if ((id = atoi(message)) > 0)
  4210. { //Acquired an ID
  4211. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4212. id = 0; //Invalid id for either mobs or npcs.
  4213. } else { //Acquired a Name
  4214. if ((id = mobdb_searchname(message)) == 0)
  4215. {
  4216. struct npc_data* nd = npc_name2id(message);
  4217. if (nd != NULL)
  4218. id = nd->class_;
  4219. }
  4220. }
  4221. if (id == 0)
  4222. {
  4223. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4224. return -1;
  4225. }
  4226. if(pc_isriding(sd))
  4227. {
  4228. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4229. return -1;
  4230. }
  4231. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4232. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4233. return -1;
  4234. }
  4235. pc_disguise(sd, id);
  4236. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4237. return 0;
  4238. }
  4239. /*==========================================
  4240. * DisguiseAll
  4241. *------------------------------------------*/
  4242. ACMD_FUNC(disguiseall)
  4243. {
  4244. int mob_id=0;
  4245. struct map_session_data *pl_sd;
  4246. struct s_mapiterator* iter;
  4247. nullpo_retr(-1, sd);
  4248. if (!message || !*message) {
  4249. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4250. return -1;
  4251. }
  4252. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4253. mob_id = atoi(message);
  4254. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4255. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4256. return -1;
  4257. }
  4258. iter = mapit_getallusers();
  4259. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4260. pc_disguise(pl_sd, mob_id);
  4261. mapit_free(iter);
  4262. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4263. return 0;
  4264. }
  4265. /*==========================================
  4266. * DisguiseGuild
  4267. *------------------------------------------*/
  4268. ACMD_FUNC(disguiseguild)
  4269. {
  4270. int id = 0, i;
  4271. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4272. struct guild *g;
  4273. memset(monster, '\0', sizeof(monster));
  4274. memset(guild, '\0', sizeof(guild));
  4275. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4276. 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>).
  4277. return -1;
  4278. }
  4279. if( (id = atoi(monster)) > 0 ) {
  4280. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4281. id = 0;
  4282. } else {
  4283. if( (id = mobdb_searchname(monster)) == 0 ) {
  4284. struct npc_data* nd = npc_name2id(monster);
  4285. if( nd != NULL )
  4286. id = nd->class_;
  4287. }
  4288. }
  4289. if( id == 0 ) {
  4290. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4291. return -1;
  4292. }
  4293. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4294. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4295. return -1;
  4296. }
  4297. for( i = 0; i < g->max_member; i++ ){
  4298. struct map_session_data *pl_sd;
  4299. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4300. pc_disguise(pl_sd, id);
  4301. }
  4302. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4303. return 0;
  4304. }
  4305. /*==========================================
  4306. * @undisguise by [Yor]
  4307. *------------------------------------------*/
  4308. ACMD_FUNC(undisguise)
  4309. {
  4310. nullpo_retr(-1, sd);
  4311. if (sd->disguise) {
  4312. pc_disguise(sd, 0);
  4313. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4314. } else {
  4315. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4316. return -1;
  4317. }
  4318. return 0;
  4319. }
  4320. /*==========================================
  4321. * UndisguiseAll
  4322. *------------------------------------------*/
  4323. ACMD_FUNC(undisguiseall)
  4324. {
  4325. struct map_session_data *pl_sd;
  4326. struct s_mapiterator* iter;
  4327. nullpo_retr(-1, sd);
  4328. iter = mapit_getallusers();
  4329. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4330. if( pl_sd->disguise )
  4331. pc_disguise(pl_sd, 0);
  4332. mapit_free(iter);
  4333. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4334. return 0;
  4335. }
  4336. /*==========================================
  4337. * UndisguiseGuild
  4338. *------------------------------------------*/
  4339. ACMD_FUNC(undisguiseguild)
  4340. {
  4341. char guild_name[NAME_LENGTH];
  4342. struct guild *g;
  4343. int i;
  4344. nullpo_retr(-1, sd);
  4345. memset(guild_name, '\0', sizeof(guild_name));
  4346. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4347. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4348. return -1;
  4349. }
  4350. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4351. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4352. return -1;
  4353. }
  4354. for(i = 0; i < g->max_member; i++){
  4355. struct map_session_data *pl_sd;
  4356. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4357. pc_disguise(pl_sd, 0);
  4358. }
  4359. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4360. return 0;
  4361. }
  4362. /*==========================================
  4363. * @exp by [Skotlex]
  4364. *------------------------------------------*/
  4365. ACMD_FUNC(exp)
  4366. {
  4367. char output[CHAT_SIZE_MAX];
  4368. double nextb, nextj;
  4369. nullpo_retr(-1, sd);
  4370. memset(output, '\0', sizeof(output));
  4371. nextb = pc_nextbaseexp(sd);
  4372. if (nextb)
  4373. nextb = sd->status.base_exp*100.0/nextb;
  4374. nextj = pc_nextjobexp(sd);
  4375. if (nextj)
  4376. nextj = sd->status.job_exp*100.0/nextj;
  4377. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4378. clif_displaymessage(fd, output);
  4379. return 0;
  4380. }
  4381. /*==========================================
  4382. * @broadcast by [Valaris]
  4383. *------------------------------------------*/
  4384. ACMD_FUNC(broadcast)
  4385. {
  4386. nullpo_retr(-1, sd);
  4387. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4388. if (!message || !*message) {
  4389. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4390. return -1;
  4391. }
  4392. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4393. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4394. return 0;
  4395. }
  4396. /*==========================================
  4397. * @localbroadcast by [Valaris]
  4398. *------------------------------------------*/
  4399. ACMD_FUNC(localbroadcast)
  4400. {
  4401. nullpo_retr(-1, sd);
  4402. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4403. if (!message || !*message) {
  4404. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4405. return -1;
  4406. }
  4407. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4408. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4409. return 0;
  4410. }
  4411. /*==========================================
  4412. * @email <actual@email> <new@email> by [Yor]
  4413. *------------------------------------------*/
  4414. ACMD_FUNC(email)
  4415. {
  4416. char actual_email[100];
  4417. char new_email[100];
  4418. nullpo_retr(-1, sd);
  4419. memset(actual_email, '\0', sizeof(actual_email));
  4420. memset(new_email, '\0', sizeof(new_email));
  4421. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4422. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4423. return -1;
  4424. }
  4425. if (e_mail_check(actual_email) == 0) {
  4426. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4427. return -1;
  4428. } else if (e_mail_check(new_email) == 0) {
  4429. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4430. return -1;
  4431. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4432. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4433. return -1;
  4434. } else if (strcmpi(actual_email, new_email) == 0) {
  4435. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4436. return -1;
  4437. }
  4438. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4439. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4440. return 0;
  4441. }
  4442. /*==========================================
  4443. *@effect
  4444. *------------------------------------------*/
  4445. ACMD_FUNC(effect)
  4446. {
  4447. int type = 0, flag = 0;
  4448. nullpo_retr(-1, sd);
  4449. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4450. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4451. return -1;
  4452. }
  4453. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4454. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4455. return 0;
  4456. }
  4457. /*==========================================
  4458. * @killer by MouseJstr
  4459. * enable killing players even when not in pvp
  4460. *------------------------------------------*/
  4461. ACMD_FUNC(killer)
  4462. {
  4463. nullpo_retr(-1, sd);
  4464. sd->state.killer = !sd->state.killer;
  4465. if(sd->state.killer)
  4466. clif_displaymessage(fd, msg_txt(sd,241));
  4467. else {
  4468. clif_displaymessage(fd, msg_txt(sd,292));
  4469. pc_stop_attack(sd);
  4470. }
  4471. return 0;
  4472. }
  4473. /*==========================================
  4474. * @killable by MouseJstr
  4475. * enable other people killing you
  4476. *------------------------------------------*/
  4477. ACMD_FUNC(killable)
  4478. {
  4479. nullpo_retr(-1, sd);
  4480. sd->state.killable = !sd->state.killable;
  4481. if(sd->state.killable)
  4482. clif_displaymessage(fd, msg_txt(sd,242));
  4483. else {
  4484. clif_displaymessage(fd, msg_txt(sd,288));
  4485. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4486. }
  4487. return 0;
  4488. }
  4489. /*==========================================
  4490. * @skillon by MouseJstr
  4491. * turn skills on for the map
  4492. *------------------------------------------*/
  4493. ACMD_FUNC(skillon)
  4494. {
  4495. nullpo_retr(-1, sd);
  4496. map[sd->bl.m].flag.noskill = 0;
  4497. clif_displaymessage(fd, msg_txt(sd,244));
  4498. return 0;
  4499. }
  4500. /*==========================================
  4501. * @skilloff by MouseJstr
  4502. * Turn skills off on the map
  4503. *------------------------------------------*/
  4504. ACMD_FUNC(skilloff)
  4505. {
  4506. nullpo_retr(-1, sd);
  4507. map[sd->bl.m].flag.noskill = 1;
  4508. clif_displaymessage(fd, msg_txt(sd,243));
  4509. return 0;
  4510. }
  4511. /*==========================================
  4512. * @npcmove by MouseJstr
  4513. * move a npc
  4514. *------------------------------------------*/
  4515. ACMD_FUNC(npcmove)
  4516. {
  4517. short x = 0, y = 0, m;
  4518. struct npc_data *nd = 0;
  4519. nullpo_retr(-1, sd);
  4520. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4521. if (!message || !*message || sscanf(message, "%6hd %6hd %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4522. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4523. return -1;
  4524. }
  4525. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4526. {
  4527. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4528. return -1;
  4529. }
  4530. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4531. {
  4532. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4533. return -1; //Not on a map.
  4534. }
  4535. x = cap_value(x, 0, map[m].xs-1);
  4536. y = cap_value(y, 0, map[m].ys-1);
  4537. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4538. map_moveblock(&nd->bl, x, y, gettick());
  4539. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4540. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4541. return 0;
  4542. }
  4543. /*==========================================
  4544. * @addwarp by MouseJstr
  4545. * Create a new static warp point.
  4546. *------------------------------------------*/
  4547. ACMD_FUNC(addwarp)
  4548. {
  4549. char mapname[32], warpname[MAP_NAME_LENGTH_EXT];
  4550. short x,y;
  4551. unsigned short m;
  4552. struct npc_data* nd;
  4553. nullpo_retr(-1, sd);
  4554. memset(warpname, '\0', sizeof(warpname));
  4555. if (!message || !*message || sscanf(message, "%31s %6hd %6hd %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4556. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4557. return -1;
  4558. }
  4559. m = mapindex_name2id(mapname);
  4560. if( m == 0 )
  4561. {
  4562. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4563. clif_displaymessage(fd, atcmd_output);
  4564. return -1;
  4565. }
  4566. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4567. if( nd == NULL )
  4568. return -1;
  4569. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4570. clif_displaymessage(fd, atcmd_output);
  4571. return 0;
  4572. }
  4573. /*==========================================
  4574. * @follow by [MouseJstr]
  4575. * Follow a player .. staying no more then 5 spaces away
  4576. *------------------------------------------*/
  4577. ACMD_FUNC(follow)
  4578. {
  4579. struct map_session_data *pl_sd = NULL;
  4580. nullpo_retr(-1, sd);
  4581. if (!message || !*message) {
  4582. if (sd->followtarget == -1)
  4583. return -1;
  4584. pc_stop_following (sd);
  4585. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4586. return 0;
  4587. }
  4588. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4589. {
  4590. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4591. return -1;
  4592. }
  4593. if (sd->followtarget == pl_sd->bl.id) {
  4594. pc_stop_following (sd);
  4595. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4596. } else {
  4597. pc_follow(sd, pl_sd->bl.id);
  4598. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4599. }
  4600. return 0;
  4601. }
  4602. /*==========================================
  4603. * @dropall by [MouseJstr] and [Xantara]
  4604. * Drops all your possession on the ground based on item type
  4605. *------------------------------------------*/
  4606. ACMD_FUNC(dropall)
  4607. {
  4608. int8 type = -1;
  4609. uint16 i, count = 0, count2 = 0;
  4610. struct item_data *item_data = NULL;
  4611. nullpo_retr(-1, sd);
  4612. if( message[0] ) {
  4613. type = atoi(message);
  4614. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4615. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4616. {
  4617. clif_displaymessage(fd, msg_txt(sd,1492));
  4618. clif_displaymessage(fd, msg_txt(sd,1493));
  4619. return -1;
  4620. }
  4621. }
  4622. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4623. if( sd->status.inventory[i].amount ) {
  4624. if( (item_data = itemdb_exists(sd->status.inventory[i].nameid)) == NULL ) {
  4625. ShowDebug("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->status.inventory[i].nameid, sd->status.account_id, sd->status.char_id);
  4626. continue;
  4627. }
  4628. if( !pc_candrop(sd,&sd->status.inventory[i]) )
  4629. continue;
  4630. if( type == -1 || type == (uint8)item_data->type ) {
  4631. if( sd->status.inventory[i].equip != 0 )
  4632. pc_unequipitem(sd, i, 3);
  4633. if(pc_dropitem(sd, i, sd->status.inventory[i].amount))
  4634. count += sd->status.inventory[i].amount;
  4635. else count2 += sd->status.inventory[i].amount;
  4636. }
  4637. }
  4638. }
  4639. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4640. clif_displaymessage(fd, atcmd_output);
  4641. return 0;
  4642. }
  4643. /*==========================================
  4644. * @storeall by [MouseJstr]
  4645. * Put everything into storage
  4646. *------------------------------------------*/
  4647. ACMD_FUNC(storeall)
  4648. {
  4649. int i;
  4650. nullpo_retr(-1, sd);
  4651. if (sd->state.storage_flag != 1)
  4652. { //Open storage.
  4653. if( storage_storageopen(sd) == 1 ) {
  4654. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4655. return -1;
  4656. }
  4657. }
  4658. for (i = 0; i < MAX_INVENTORY; i++) {
  4659. if (sd->status.inventory[i].amount) {
  4660. if(sd->status.inventory[i].equip != 0)
  4661. pc_unequipitem(sd, i, 3);
  4662. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4663. }
  4664. }
  4665. storage_storageclose(sd);
  4666. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4667. return 0;
  4668. }
  4669. ACMD_FUNC(clearstorage)
  4670. {
  4671. int i, j;
  4672. nullpo_retr(-1, sd);
  4673. if (sd->state.storage_flag == 1) {
  4674. clif_displaymessage(fd, msg_txt(sd,250));
  4675. return -1;
  4676. }
  4677. j = sd->status.storage.storage_amount;
  4678. for (i = 0; i < j; ++i) {
  4679. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4680. }
  4681. storage_storageclose(sd);
  4682. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4683. return 0;
  4684. }
  4685. ACMD_FUNC(cleargstorage)
  4686. {
  4687. int i, j;
  4688. struct guild *g;
  4689. struct guild_storage *gstorage;
  4690. nullpo_retr(-1, sd);
  4691. g = sd->guild;
  4692. if (g == NULL) {
  4693. clif_displaymessage(fd, msg_txt(sd,43));
  4694. return -1;
  4695. }
  4696. if (sd->state.storage_flag == 1) {
  4697. clif_displaymessage(fd, msg_txt(sd,250));
  4698. return -1;
  4699. }
  4700. if (sd->state.storage_flag == 2) {
  4701. clif_displaymessage(fd, msg_txt(sd,251));
  4702. return -1;
  4703. }
  4704. gstorage = gstorage_get_storage(sd->status.guild_id);
  4705. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4706. return -1;
  4707. }
  4708. if (gstorage->opened) {
  4709. struct map_session_data *tsd = map_charid2sd(gstorage->opened);
  4710. if (tsd)
  4711. gstorage_storageclose(tsd);
  4712. }
  4713. j = gstorage->storage_amount;
  4714. gstorage->locked = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4715. for (i = 0; i < j; ++i) {
  4716. gstorage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4717. }
  4718. gstorage_storageclose(sd);
  4719. gstorage->locked = false; // Cleaning done, release lock
  4720. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4721. return 0;
  4722. }
  4723. ACMD_FUNC(clearcart)
  4724. {
  4725. int i;
  4726. nullpo_retr(-1, sd);
  4727. if (pc_iscarton(sd) == 0) {
  4728. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4729. return -1;
  4730. }
  4731. if (sd->state.vending == 1) { //Somehow...
  4732. return -1;
  4733. }
  4734. for( i = 0; i < MAX_CART; i++ )
  4735. if(sd->status.cart[i].nameid > 0)
  4736. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4737. clif_clearcart(fd);
  4738. clif_updatestatus(sd,SP_CARTINFO);
  4739. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4740. return 0;
  4741. }
  4742. /*==========================================
  4743. * @skillid by [MouseJstr]
  4744. * lookup a skill by name
  4745. *------------------------------------------*/
  4746. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4747. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4748. ACMD_FUNC(skillid) {
  4749. int skillen, i, found = 0;
  4750. DBIterator* iter;
  4751. DBKey key;
  4752. DBData *data;
  4753. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4754. nullpo_retr(-1, sd);
  4755. if (!message || !*message) {
  4756. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4757. return -1;
  4758. }
  4759. skillen = strlen(message);
  4760. iter = db_iterator(skilldb_name2id);
  4761. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4762. int idx = skill_get_index(db_data2i(data));
  4763. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4764. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4765. clif_displaymessage(fd, atcmd_output);
  4766. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4767. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str);
  4768. }
  4769. }
  4770. dbi_destroy(iter);
  4771. if( found ) {
  4772. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4773. clif_displaymessage(fd, atcmd_output);
  4774. }
  4775. for(i = 0; i < found; i++) { /* partials */
  4776. clif_displaymessage(fd, partials[i]);
  4777. }
  4778. return 0;
  4779. }
  4780. /*==========================================
  4781. * @useskill by [MouseJstr]
  4782. * A way of using skills without having to find them in the skills menu
  4783. *------------------------------------------*/
  4784. ACMD_FUNC(useskill)
  4785. {
  4786. struct map_session_data *pl_sd = NULL;
  4787. struct block_list *bl;
  4788. uint16 skill_id;
  4789. uint16 skill_lv;
  4790. char target[100];
  4791. nullpo_retr(-1, sd);
  4792. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4793. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4794. return -1;
  4795. }
  4796. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4797. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4798. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4799. return -1;
  4800. }
  4801. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4802. {
  4803. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4804. return -1;
  4805. }
  4806. if (SKILL_CHK_HOMUN(skill_id)
  4807. && sd->hd && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4808. bl = &sd->hd->bl;
  4809. else
  4810. bl = &sd->bl;
  4811. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4812. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4813. else
  4814. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4815. return 0;
  4816. }
  4817. /*==========================================
  4818. * @displayskill by [Skotlex]
  4819. * Debug command to locate new skill IDs. It sends the
  4820. * three possible skill-effect packets to the area.
  4821. *------------------------------------------*/
  4822. ACMD_FUNC(displayskill)
  4823. {
  4824. struct status_data * status;
  4825. unsigned int tick;
  4826. uint16 skill_id;
  4827. uint16 skill_lv = 1;
  4828. nullpo_retr(-1, sd);
  4829. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4830. {
  4831. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4832. return -1;
  4833. }
  4834. status = status_get_status_data(&sd->bl);
  4835. tick = gettick();
  4836. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4837. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4838. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4839. return 0;
  4840. }
  4841. /*==========================================
  4842. * @skilltree by [MouseJstr]
  4843. * prints the skill tree for a player required to get to a skill
  4844. *------------------------------------------*/
  4845. ACMD_FUNC(skilltree)
  4846. {
  4847. struct map_session_data *pl_sd = NULL;
  4848. uint16 skill_id;
  4849. int meets, i, j, c=0;
  4850. char target[NAME_LENGTH];
  4851. struct skill_tree_entry *ent;
  4852. nullpo_retr(-1, sd);
  4853. if(!message || !*message || sscanf(message, "%6hu %23[^\r\n]", &skill_id, target) != 2) {
  4854. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4855. return -1;
  4856. }
  4857. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4858. {
  4859. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4860. return -1;
  4861. }
  4862. i = pc_calc_skilltree_normalize_job(pl_sd);
  4863. c = pc_mapid2jobid(i, pl_sd->status.sex);
  4864. 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).
  4865. clif_displaymessage(fd, atcmd_output);
  4866. c = pc_class2idx(c);
  4867. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4868. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4869. {
  4870. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4871. return 0;
  4872. }
  4873. ent = &skill_tree[c][j];
  4874. meets = 1;
  4875. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4876. {
  4877. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4878. {
  4879. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].lv, skill_db[skill_get_index(ent->need[j].id)]->desc); // Player requires level %d of skill %s.
  4880. clif_displaymessage(fd, atcmd_output);
  4881. meets = 0;
  4882. }
  4883. }
  4884. if (meets == 1) {
  4885. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4886. }
  4887. return 0;
  4888. }
  4889. // Hand a ring with partners name on it to this char
  4890. void getring (struct map_session_data* sd)
  4891. {
  4892. char flag = 0;
  4893. unsigned short item_id;
  4894. struct item item_tmp;
  4895. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4896. memset(&item_tmp, 0, sizeof(item_tmp));
  4897. item_tmp.nameid = item_id;
  4898. item_tmp.identify = 1;
  4899. item_tmp.card[0] = 255;
  4900. item_tmp.card[2] = sd->status.partner_id;
  4901. item_tmp.card[3] = sd->status.partner_id >> 16;
  4902. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4903. clif_additem(sd,0,0,flag);
  4904. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  4905. }
  4906. }
  4907. /*==========================================
  4908. * @marry by [MouseJstr], fixed by Lupus
  4909. * Marry two players
  4910. *------------------------------------------*/
  4911. ACMD_FUNC(marry)
  4912. {
  4913. struct map_session_data *pl_sd = NULL;
  4914. char player_name[NAME_LENGTH] = "";
  4915. nullpo_retr(-1, sd);
  4916. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4917. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4918. return -1;
  4919. }
  4920. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4921. clif_displaymessage(fd, msg_txt(sd,3));
  4922. return -1;
  4923. }
  4924. if (pc_marriage(sd, pl_sd)) {
  4925. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4926. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4927. getring(sd); // Auto-give named rings (Aru)
  4928. getring(pl_sd);
  4929. return 0;
  4930. }
  4931. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4932. return -1;
  4933. }
  4934. /*==========================================
  4935. * @divorce by [MouseJstr], fixed by [Lupus]
  4936. * divorce two players
  4937. *------------------------------------------*/
  4938. ACMD_FUNC(divorce)
  4939. {
  4940. nullpo_retr(-1, sd);
  4941. if (!pc_divorce(sd)) {
  4942. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4943. clif_displaymessage(fd, atcmd_output);
  4944. return -1;
  4945. }
  4946. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4947. clif_displaymessage(fd, atcmd_output);
  4948. return 0;
  4949. }
  4950. /*==========================================
  4951. * @changelook by [Celest]
  4952. *------------------------------------------*/
  4953. ACMD_FUNC(changelook)
  4954. {
  4955. int i, j = 0, k = 0;
  4956. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  4957. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  4958. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4959. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  4960. return -1;
  4961. } else if ( i == 2 ) {
  4962. if (j < 1 || j > 8)
  4963. j = 1;
  4964. j = pos[j - 1];
  4965. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4966. k = j; // swap
  4967. j = LOOK_HEAD_TOP;
  4968. }
  4969. clif_changelook(&sd->bl,j,k);
  4970. return 0;
  4971. }
  4972. /*==========================================
  4973. * @autotrade by durf [Lupus] [Paradox924X]
  4974. * Turns on/off Autotrade for a specific player
  4975. *------------------------------------------*/
  4976. ACMD_FUNC(autotrade) {
  4977. nullpo_retr(-1, sd);
  4978. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4979. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4980. return -1;
  4981. }
  4982. if( pc_isdead(sd) ) {
  4983. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4984. return -1;
  4985. }
  4986. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4987. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4988. return -1;
  4989. }
  4990. sd->state.autotrade = 1;
  4991. if (battle_config.autotrade_monsterignore)
  4992. sd->state.monster_ignore = 1;
  4993. if( sd->state.vending ){
  4994. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
  4995. Sql_ShowDebug( mmysql_handle );
  4996. }
  4997. }else if( sd->state.buyingstore ){
  4998. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_db, sd->buyer_id ) != SQL_SUCCESS ){
  4999. Sql_ShowDebug( mmysql_handle );
  5000. }
  5001. }
  5002. if( battle_config.at_timeout ) {
  5003. int timeout = atoi(message);
  5004. 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);
  5005. }
  5006. channel_pcquit(sd,0xF); //leave all chan
  5007. clif_authfail_fd(sd->fd, 15);
  5008. chrif_save(sd,3);
  5009. return 0;
  5010. }
  5011. /*==========================================
  5012. * @changegm by durf (changed by Lupus)
  5013. * Changes Master of your Guild to a specified guild member
  5014. *------------------------------------------*/
  5015. ACMD_FUNC(changegm)
  5016. {
  5017. struct guild *g;
  5018. struct map_session_data *pl_sd;
  5019. nullpo_retr(-1, sd);
  5020. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5021. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5022. return -1;
  5023. }
  5024. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  5025. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5026. return -1;
  5027. }
  5028. if( !message[0] ) {
  5029. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5030. return -1;
  5031. }
  5032. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5033. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5034. return -1;
  5035. }
  5036. guild_gm_change(sd->status.guild_id, pl_sd);
  5037. return 0;
  5038. }
  5039. /*==========================================
  5040. * @changeleader by Skotlex
  5041. * Changes the leader of a party.
  5042. *------------------------------------------*/
  5043. ACMD_FUNC(changeleader)
  5044. {
  5045. nullpo_retr(-1, sd);
  5046. if( !message[0] )
  5047. {
  5048. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5049. return -1;
  5050. }
  5051. if (party_changeleader(sd, map_nick2sd((char *) message),NULL))
  5052. return 0;
  5053. return -1;
  5054. }
  5055. /*==========================================
  5056. * @partyoption by Skotlex
  5057. * Used to change the item share setting of a party.
  5058. *------------------------------------------*/
  5059. ACMD_FUNC(partyoption)
  5060. {
  5061. struct party_data *p;
  5062. int mi, option;
  5063. char w1[16], w2[16];
  5064. nullpo_retr(-1, sd);
  5065. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5066. {
  5067. clif_displaymessage(fd, msg_txt(sd,282));
  5068. return -1;
  5069. }
  5070. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5071. if (mi == MAX_PARTY)
  5072. return -1; //Shouldn't happen
  5073. if (!p->party.member[mi].leader)
  5074. {
  5075. clif_displaymessage(fd, msg_txt(sd,282));
  5076. return -1;
  5077. }
  5078. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5079. {
  5080. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5081. return -1;
  5082. }
  5083. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5084. //Change item share type.
  5085. if (option != p->party.item)
  5086. party_changeoption(sd, p->party.exp, option);
  5087. else
  5088. clif_displaymessage(fd, msg_txt(sd,286));
  5089. return 0;
  5090. }
  5091. /*==========================================
  5092. * @autoloot by Upa-Kun
  5093. * Turns on/off AutoLoot for a specific player
  5094. *------------------------------------------*/
  5095. ACMD_FUNC(autoloot)
  5096. {
  5097. int rate;
  5098. nullpo_retr(-1, sd);
  5099. // autoloot command without value
  5100. if(!message || !*message)
  5101. {
  5102. if (sd->state.autoloot)
  5103. rate = 0;
  5104. else
  5105. rate = 10000;
  5106. } else {
  5107. double drate;
  5108. drate = atof(message);
  5109. rate = (int)(drate*100);
  5110. }
  5111. if (rate < 0) rate = 0;
  5112. if (rate > 10000) rate = 10000;
  5113. sd->state.autoloot = rate;
  5114. if (sd->state.autoloot) {
  5115. 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.
  5116. clif_displaymessage(fd, atcmd_output);
  5117. }else
  5118. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5119. return 0;
  5120. }
  5121. /*==========================================
  5122. * @alootid
  5123. *------------------------------------------*/
  5124. ACMD_FUNC(autolootitem)
  5125. {
  5126. struct item_data *item_data = NULL;
  5127. int i;
  5128. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5129. nullpo_retr(-1, sd);
  5130. if (message && *message) {
  5131. if (message[0] == '+') {
  5132. message++;
  5133. action = 1;
  5134. }
  5135. else if (message[0] == '-') {
  5136. message++;
  5137. action = 2;
  5138. }
  5139. else if (!strcmp(message,"reset"))
  5140. action = 4;
  5141. }
  5142. if (action < 3) // add or remove
  5143. {
  5144. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5145. item_data = itemdb_searchname(message);
  5146. if (!item_data) {
  5147. // No items founds in the DB with Id or Name
  5148. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5149. return -1;
  5150. }
  5151. }
  5152. switch(action) {
  5153. case 1:
  5154. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5155. if (i != AUTOLOOTITEM_SIZE) {
  5156. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5157. return -1;
  5158. }
  5159. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5160. if (i == AUTOLOOTITEM_SIZE) {
  5161. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5162. return -1;
  5163. }
  5164. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5165. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5166. clif_displaymessage(fd, atcmd_output);
  5167. sd->state.autolooting = 1;
  5168. break;
  5169. case 2:
  5170. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5171. if (i == AUTOLOOTITEM_SIZE) {
  5172. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5173. return -1;
  5174. }
  5175. sd->state.autolootid[i] = 0;
  5176. 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.
  5177. clif_displaymessage(fd, atcmd_output);
  5178. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5179. if (i == AUTOLOOTITEM_SIZE) {
  5180. sd->state.autolooting = 0;
  5181. }
  5182. break;
  5183. case 3:
  5184. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5185. clif_displaymessage(fd, atcmd_output);
  5186. 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>".
  5187. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5188. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5189. if (i == AUTOLOOTITEM_SIZE) {
  5190. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5191. } else {
  5192. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5193. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5194. {
  5195. if (sd->state.autolootid[i] == 0)
  5196. continue;
  5197. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5198. 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);
  5199. continue;
  5200. }
  5201. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5202. clif_displaymessage(fd, atcmd_output);
  5203. }
  5204. }
  5205. break;
  5206. case 4:
  5207. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5208. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5209. sd->state.autolooting = 0;
  5210. break;
  5211. }
  5212. return 0;
  5213. }
  5214. /*==========================================
  5215. * @autoloottype
  5216. * Flags:
  5217. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5218. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5219. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5220. * 262144: IT_CASH
  5221. *------------------------------------------
  5222. * Credits:
  5223. * chriser
  5224. * Aleos
  5225. *------------------------------------------*/
  5226. ACMD_FUNC(autoloottype)
  5227. {
  5228. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5229. enum item_types type = -1;
  5230. int ITEM_MAX = 1533;
  5231. nullpo_retr(-1, sd);
  5232. if (message && *message) {
  5233. if (message[0] == '+') {
  5234. message++;
  5235. action = 1;
  5236. }
  5237. else if (message[0] == '-') {
  5238. message++;
  5239. action = 2;
  5240. }
  5241. else if (!strcmp(message,"reset"))
  5242. action = 4;
  5243. }
  5244. if (action < 3) { // add or remove
  5245. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5246. type = IT_HEALING;
  5247. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5248. type = IT_USABLE;
  5249. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5250. type = IT_ETC;
  5251. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5252. type = IT_ARMOR;
  5253. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5254. type = IT_WEAPON;
  5255. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5256. type = IT_CARD;
  5257. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5258. type = IT_PETEGG;
  5259. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5260. type = IT_PETARMOR;
  5261. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5262. type = IT_AMMO;
  5263. else {
  5264. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5265. return -1;
  5266. }
  5267. }
  5268. switch (action) {
  5269. case 1:
  5270. if (sd->state.autoloottype&(1<<type)) {
  5271. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5272. return -1;
  5273. }
  5274. if (sd->state.autoloottype == ITEM_MAX) {
  5275. 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>.
  5276. return -1;
  5277. }
  5278. sd->state.autoloottype |= (1<<type); // Stores the type
  5279. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5280. clif_displaymessage(fd, atcmd_output);
  5281. break;
  5282. case 2:
  5283. if (!(sd->state.autoloottype&(1<<type))) {
  5284. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5285. return -1;
  5286. }
  5287. sd->state.autoloottype &= ~(1<<type);
  5288. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5289. clif_displaymessage(fd, atcmd_output);
  5290. break;
  5291. case 3:
  5292. 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>".
  5293. 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
  5294. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5295. if (sd->state.autoloottype == 0)
  5296. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5297. else {
  5298. uint8 i = 0;
  5299. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5300. while (i < IT_MAX) {
  5301. if (sd->state.autoloottype&(1<<i)) {
  5302. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(i), i);
  5303. clif_displaymessage(fd, atcmd_output);
  5304. }
  5305. i++;
  5306. }
  5307. }
  5308. break;
  5309. case 4:
  5310. sd->state.autoloottype = 0;
  5311. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5312. break;
  5313. }
  5314. return 0;
  5315. }
  5316. /**
  5317. * No longer available, keeping here just in case it's back someday. [Ind]
  5318. **/
  5319. /*==========================================
  5320. * It is made to rain.
  5321. *------------------------------------------*/
  5322. //ACMD_FUNC(rain)
  5323. //{
  5324. // nullpo_retr(-1, sd);
  5325. // if (map[sd->bl.m].flag.rain) {
  5326. // map[sd->bl.m].flag.rain=0;
  5327. // clif_weather(sd->bl.m);
  5328. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5329. // } else {
  5330. // map[sd->bl.m].flag.rain=1;
  5331. // clif_weather(sd->bl.m);
  5332. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5333. // }
  5334. // return 0;
  5335. //}
  5336. /*==========================================
  5337. * It is made to snow.
  5338. *------------------------------------------*/
  5339. ACMD_FUNC(snow)
  5340. {
  5341. nullpo_retr(-1, sd);
  5342. if (map[sd->bl.m].flag.snow) {
  5343. map[sd->bl.m].flag.snow=0;
  5344. clif_weather(sd->bl.m);
  5345. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5346. } else {
  5347. map[sd->bl.m].flag.snow=1;
  5348. clif_weather(sd->bl.m);
  5349. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5350. }
  5351. return 0;
  5352. }
  5353. /*==========================================
  5354. * Cherry tree snowstorm is made to fall. (Sakura)
  5355. *------------------------------------------*/
  5356. ACMD_FUNC(sakura)
  5357. {
  5358. nullpo_retr(-1, sd);
  5359. if (map[sd->bl.m].flag.sakura) {
  5360. map[sd->bl.m].flag.sakura=0;
  5361. clif_weather(sd->bl.m);
  5362. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5363. } else {
  5364. map[sd->bl.m].flag.sakura=1;
  5365. clif_weather(sd->bl.m);
  5366. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5367. }
  5368. return 0;
  5369. }
  5370. /*==========================================
  5371. * Clouds appear.
  5372. *------------------------------------------*/
  5373. ACMD_FUNC(clouds)
  5374. {
  5375. nullpo_retr(-1, sd);
  5376. if (map[sd->bl.m].flag.clouds) {
  5377. map[sd->bl.m].flag.clouds=0;
  5378. clif_weather(sd->bl.m);
  5379. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5380. } else {
  5381. map[sd->bl.m].flag.clouds=1;
  5382. clif_weather(sd->bl.m);
  5383. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5384. }
  5385. return 0;
  5386. }
  5387. /*==========================================
  5388. * Different type of clouds using effect 516
  5389. *------------------------------------------*/
  5390. ACMD_FUNC(clouds2)
  5391. {
  5392. nullpo_retr(-1, sd);
  5393. if (map[sd->bl.m].flag.clouds2) {
  5394. map[sd->bl.m].flag.clouds2=0;
  5395. clif_weather(sd->bl.m);
  5396. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5397. } else {
  5398. map[sd->bl.m].flag.clouds2=1;
  5399. clif_weather(sd->bl.m);
  5400. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5401. }
  5402. return 0;
  5403. }
  5404. /*==========================================
  5405. * Fog hangs over.
  5406. *------------------------------------------*/
  5407. ACMD_FUNC(fog)
  5408. {
  5409. nullpo_retr(-1, sd);
  5410. if (map[sd->bl.m].flag.fog) {
  5411. map[sd->bl.m].flag.fog=0;
  5412. clif_weather(sd->bl.m);
  5413. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5414. } else {
  5415. map[sd->bl.m].flag.fog=1;
  5416. clif_weather(sd->bl.m);
  5417. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5418. }
  5419. return 0;
  5420. }
  5421. /*==========================================
  5422. * Fallen leaves fall.
  5423. *------------------------------------------*/
  5424. ACMD_FUNC(leaves)
  5425. {
  5426. nullpo_retr(-1, sd);
  5427. if (map[sd->bl.m].flag.leaves) {
  5428. map[sd->bl.m].flag.leaves=0;
  5429. clif_weather(sd->bl.m);
  5430. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5431. } else {
  5432. map[sd->bl.m].flag.leaves=1;
  5433. clif_weather(sd->bl.m);
  5434. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5435. }
  5436. return 0;
  5437. }
  5438. /*==========================================
  5439. * Fireworks appear.
  5440. *------------------------------------------*/
  5441. ACMD_FUNC(fireworks)
  5442. {
  5443. nullpo_retr(-1, sd);
  5444. if (map[sd->bl.m].flag.fireworks) {
  5445. map[sd->bl.m].flag.fireworks=0;
  5446. clif_weather(sd->bl.m);
  5447. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5448. } else {
  5449. map[sd->bl.m].flag.fireworks=1;
  5450. clif_weather(sd->bl.m);
  5451. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5452. }
  5453. return 0;
  5454. }
  5455. /*==========================================
  5456. * Clearing Weather Effects by Dexity
  5457. *------------------------------------------*/
  5458. ACMD_FUNC(clearweather)
  5459. {
  5460. nullpo_retr(-1, sd);
  5461. /**
  5462. * No longer available, keeping here just in case it's back someday. [Ind]
  5463. **/
  5464. //map[sd->bl.m].flag.rain=0;
  5465. map[sd->bl.m].flag.snow=0;
  5466. map[sd->bl.m].flag.sakura=0;
  5467. map[sd->bl.m].flag.clouds=0;
  5468. map[sd->bl.m].flag.clouds2=0;
  5469. map[sd->bl.m].flag.fog=0;
  5470. map[sd->bl.m].flag.fireworks=0;
  5471. map[sd->bl.m].flag.leaves=0;
  5472. clif_weather(sd->bl.m);
  5473. clif_displaymessage(fd, msg_txt(sd,291));
  5474. return 0;
  5475. }
  5476. /*===============================================================
  5477. * Sound Command - plays a sound for everyone around! [Codemaster]
  5478. *---------------------------------------------------------------*/
  5479. ACMD_FUNC(sound)
  5480. {
  5481. char sound_file[100];
  5482. memset(sound_file, '\0', sizeof(sound_file));
  5483. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5484. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5485. return -1;
  5486. }
  5487. if(strstr(sound_file, ".wav") == NULL)
  5488. strcat(sound_file, ".wav");
  5489. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5490. return 0;
  5491. }
  5492. /*==========================================
  5493. * MOB Search
  5494. *------------------------------------------*/
  5495. ACMD_FUNC(mobsearch)
  5496. {
  5497. char mob_name[100];
  5498. int mob_id;
  5499. int number = 0;
  5500. struct s_mapiterator* it;
  5501. nullpo_retr(-1, sd);
  5502. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5503. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5504. return -1;
  5505. }
  5506. if ((mob_id = atoi(mob_name)) == 0)
  5507. mob_id = mobdb_searchname(mob_name);
  5508. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5509. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5510. clif_displaymessage(fd, atcmd_output);
  5511. return -1;
  5512. }
  5513. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5514. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5515. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5516. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5517. clif_displaymessage(fd, atcmd_output);
  5518. it = mapit_geteachmob();
  5519. for(;;)
  5520. {
  5521. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5522. if( md == NULL )
  5523. break;// no more mobs
  5524. if( md->bl.m != sd->bl.m )
  5525. continue;
  5526. if( mob_id != -1 && md->mob_id != mob_id )
  5527. continue;
  5528. ++number;
  5529. if( md->spawn_timer == INVALID_TIMER )
  5530. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5531. else
  5532. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5533. clif_displaymessage(fd, atcmd_output);
  5534. }
  5535. mapit_free(it);
  5536. return 0;
  5537. }
  5538. /*==========================================
  5539. * @cleanmap - cleans items on the ground
  5540. * @cleanarea - cleans items on the ground within an specified area
  5541. *------------------------------------------*/
  5542. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5543. {
  5544. nullpo_ret(bl);
  5545. map_clearflooritem(bl);
  5546. return 0;
  5547. }
  5548. ACMD_FUNC(cleanmap)
  5549. {
  5550. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5551. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5552. return 0;
  5553. }
  5554. ACMD_FUNC(cleanarea)
  5555. {
  5556. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5557. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5558. map_foreachinarea(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);
  5559. }
  5560. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5561. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
  5562. }
  5563. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5564. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5565. }
  5566. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5567. return 0;
  5568. }
  5569. /*==========================================
  5570. * make a NPC/PET talk
  5571. * @npctalkc [SnakeDrak]
  5572. *------------------------------------------*/
  5573. ACMD_FUNC(npctalk)
  5574. {
  5575. char name[NAME_LENGTH],mes[100],temp[100];
  5576. struct npc_data *nd;
  5577. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5578. unsigned long color=0;
  5579. if (sd->sc.cant.chat)
  5580. return -1; //no "chatting" while muted.
  5581. if(!ifcolor) {
  5582. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5583. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5584. return -1;
  5585. }
  5586. }
  5587. else {
  5588. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5589. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5590. return -1;
  5591. }
  5592. }
  5593. if (!(nd = npc_name2id(name))) {
  5594. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5595. return -1;
  5596. }
  5597. strtok(name, "#"); // discard extra name identifier if present
  5598. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5599. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5600. else clif_disp_overhead(&nd->bl, temp);
  5601. return 0;
  5602. }
  5603. ACMD_FUNC(pettalk)
  5604. {
  5605. char mes[100],temp[100];
  5606. struct pet_data *pd;
  5607. nullpo_retr(-1, sd);
  5608. if ( battle_config.min_chat_delay ) {
  5609. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5610. return 0;
  5611. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5612. }
  5613. if(!sd->status.pet_id || !(pd=sd->pd))
  5614. {
  5615. clif_displaymessage(fd, msg_txt(sd,184));
  5616. return -1;
  5617. }
  5618. if (sd->sc.cant.chat)
  5619. return -1; //no "chatting" while muted.
  5620. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5621. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5622. return -1;
  5623. }
  5624. if (message[0] == '/')
  5625. {// pet emotion processing
  5626. const char* emo[] = {
  5627. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5628. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5629. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5630. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5631. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5632. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5633. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5634. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5635. "/whisp"
  5636. };
  5637. int i;
  5638. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5639. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5640. if( i < ARRAYLENGTH(emo) )
  5641. {
  5642. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5643. sd->emotionlasttime = time(NULL);
  5644. return 0;
  5645. }
  5646. sd->emotionlasttime = time(NULL);
  5647. clif_emotion(&pd->bl, i);
  5648. return 0;
  5649. }
  5650. }
  5651. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5652. clif_disp_overhead(&pd->bl, temp);
  5653. return 0;
  5654. }
  5655. /// @users - displays the number of players present on each map (and percentage)
  5656. /// #users displays on the target user instead of self
  5657. ACMD_FUNC(users)
  5658. {
  5659. char buf[CHAT_SIZE_MAX];
  5660. int i;
  5661. int users[MAX_MAPINDEX];
  5662. int users_all;
  5663. struct s_mapiterator* iter;
  5664. memset(users, 0, sizeof(users));
  5665. users_all = 0;
  5666. // count users on each map
  5667. iter = mapit_getallusers();
  5668. for(;;)
  5669. {
  5670. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5671. if( sd2 == NULL )
  5672. break;// no more users
  5673. if( sd2->mapindex >= MAX_MAPINDEX )
  5674. continue;// invalid mapindex
  5675. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5676. if( users_all < INT_MAX ) ++users_all;
  5677. }
  5678. mapit_free(iter);
  5679. // display results for each map
  5680. for( i = 0; i < MAX_MAPINDEX; ++i )
  5681. {
  5682. if( users[i] == 0 )
  5683. continue;// empty
  5684. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5685. clif_displaymessage(sd->fd, buf);
  5686. }
  5687. // display overall count
  5688. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5689. clif_displaymessage(sd->fd, buf);
  5690. return 0;
  5691. }
  5692. /*==========================================
  5693. *
  5694. *------------------------------------------*/
  5695. ACMD_FUNC(reset)
  5696. {
  5697. pc_resetstate(sd);
  5698. pc_resetskill(sd,1);
  5699. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5700. clif_displaymessage(fd, atcmd_output);
  5701. return 0;
  5702. }
  5703. /*==========================================
  5704. *
  5705. *------------------------------------------*/
  5706. ACMD_FUNC(summon)
  5707. {
  5708. char name[NAME_LENGTH];
  5709. int mob_id = 0;
  5710. int duration = 0;
  5711. struct mob_data *md;
  5712. unsigned int tick=gettick();
  5713. nullpo_retr(-1, sd);
  5714. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5715. {
  5716. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5717. return -1;
  5718. }
  5719. if (duration < 1)
  5720. duration =1;
  5721. else if (duration > 60)
  5722. duration =60;
  5723. if ((mob_id = atoi(name)) == 0)
  5724. mob_id = mobdb_searchname(name);
  5725. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5726. {
  5727. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5728. return -1;
  5729. }
  5730. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5731. if(!md)
  5732. return -1;
  5733. md->master_id=sd->bl.id;
  5734. md->special_state.ai=AI_ATTACK;
  5735. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5736. clif_specialeffect(&md->bl,344,AREA);
  5737. mob_spawn(md);
  5738. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5739. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5740. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5741. return 0;
  5742. }
  5743. /*==========================================
  5744. * @adjgroup
  5745. * Temporarily move player to another group
  5746. * Useful during beta testing to allow players to use GM commands for short periods of time
  5747. *------------------------------------------*/
  5748. ACMD_FUNC(adjgroup)
  5749. {
  5750. int new_group = 0;
  5751. nullpo_retr(-1, sd);
  5752. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5753. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5754. return -1;
  5755. }
  5756. if (!pc_group_exists(new_group)) {
  5757. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5758. return -1;
  5759. }
  5760. sd->group_id = new_group;
  5761. pc_group_pc_load(sd);/* update cache */
  5762. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5763. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5764. return 0;
  5765. }
  5766. /*==========================================
  5767. * @trade by [MouseJstr]
  5768. * Open a trade window with a remote player
  5769. *------------------------------------------*/
  5770. ACMD_FUNC(trade)
  5771. {
  5772. struct map_session_data *pl_sd = NULL;
  5773. nullpo_retr(-1, sd);
  5774. if (!message || !*message) {
  5775. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5776. return -1;
  5777. }
  5778. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5779. {
  5780. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5781. return -1;
  5782. }
  5783. trade_traderequest(sd, pl_sd);
  5784. return 0;
  5785. }
  5786. /*==========================================
  5787. * @setbattleflag by [MouseJstr]
  5788. * set a battle_config flag without having to reboot
  5789. *------------------------------------------*/
  5790. ACMD_FUNC(setbattleflag)
  5791. {
  5792. char flag[128], value[128];
  5793. nullpo_retr(-1, sd);
  5794. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5795. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5796. return -1;
  5797. }
  5798. if (battle_set_value(flag, value) == 0)
  5799. {
  5800. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5801. return -1;
  5802. }
  5803. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5804. return 0;
  5805. }
  5806. /*==========================================
  5807. * @unmute [Valaris]
  5808. *------------------------------------------*/
  5809. ACMD_FUNC(unmute)
  5810. {
  5811. struct map_session_data *pl_sd = NULL;
  5812. nullpo_retr(-1, sd);
  5813. if (!message || !*message) {
  5814. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5815. return -1;
  5816. }
  5817. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5818. {
  5819. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5820. return -1;
  5821. }
  5822. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5823. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5824. return -1;
  5825. }
  5826. pl_sd->status.manner = 0;
  5827. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5828. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5829. return 0;
  5830. }
  5831. /*==========================================
  5832. * @uptime by MC Cameri
  5833. *------------------------------------------*/
  5834. ACMD_FUNC(uptime)
  5835. {
  5836. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5837. minute = 60, days = 0, hours = 0, minutes = 0;
  5838. nullpo_retr(-1, sd);
  5839. seconds = get_uptime();
  5840. days = seconds/day;
  5841. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5842. hours = seconds/hour;
  5843. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5844. minutes = seconds/minute;
  5845. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5846. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5847. clif_displaymessage(fd, atcmd_output);
  5848. return 0;
  5849. }
  5850. /*==========================================
  5851. * @changesex
  5852. * => Changes one's account sex. Switch from male to female or visversa
  5853. *------------------------------------------*/
  5854. ACMD_FUNC(changesex)
  5855. {
  5856. int i;
  5857. nullpo_retr(-1, sd);
  5858. pc_resetskill(sd,4);
  5859. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5860. for (i = 0; i < EQI_MAX; i++) {
  5861. if (sd->equip_index[i] >= 0)
  5862. pc_unequipitem(sd, sd->equip_index[i], 3);
  5863. }
  5864. chrif_changesex(sd, true);
  5865. return 0;
  5866. }
  5867. /*==========================================
  5868. * @changecharsex
  5869. * => Changes one's character sex. Switch from male to female or visversa.
  5870. *------------------------------------------*/
  5871. ACMD_FUNC(changecharsex)
  5872. {
  5873. int i;
  5874. nullpo_retr(-1, sd);
  5875. pc_resetskill(sd,4);
  5876. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5877. for (i = 0; i < EQI_MAX; i++) {
  5878. if (sd->equip_index[i] >= 0)
  5879. pc_unequipitem(sd, sd->equip_index[i], 3);
  5880. }
  5881. chrif_changesex(sd, false);
  5882. return 0;
  5883. }
  5884. /*================================================
  5885. * @mute - Mutes a player for a set amount of time
  5886. *------------------------------------------------*/
  5887. ACMD_FUNC(mute)
  5888. {
  5889. struct map_session_data *pl_sd = NULL;
  5890. int manner;
  5891. nullpo_retr(-1, sd);
  5892. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5893. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5894. return -1;
  5895. }
  5896. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5897. {
  5898. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5899. return -1;
  5900. }
  5901. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5902. {
  5903. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5904. return -1;
  5905. }
  5906. clif_manner_message(sd, 0);
  5907. clif_manner_message(pl_sd, 5);
  5908. if( pl_sd->status.manner < manner ) {
  5909. pl_sd->status.manner -= manner;
  5910. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5911. } else {
  5912. pl_sd->status.manner = 0;
  5913. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5914. }
  5915. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5916. return 0;
  5917. }
  5918. /*==========================================
  5919. * @refresh (like @jumpto <<yourself>>)
  5920. *------------------------------------------*/
  5921. ACMD_FUNC(refresh)
  5922. {
  5923. nullpo_retr(-1, sd);
  5924. clif_refresh(sd);
  5925. return 0;
  5926. }
  5927. ACMD_FUNC(refreshall)
  5928. {
  5929. struct map_session_data* iter_sd;
  5930. struct s_mapiterator* iter;
  5931. nullpo_retr(-1, sd);
  5932. iter = mapit_getallusers();
  5933. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5934. clif_refresh(iter_sd);
  5935. mapit_free(iter);
  5936. return 0;
  5937. }
  5938. /*==========================================
  5939. * @identify
  5940. * => GM's magnifier.
  5941. *------------------------------------------*/
  5942. ACMD_FUNC(identify)
  5943. {
  5944. int i,num;
  5945. nullpo_retr(-1, sd);
  5946. for(i=num=0;i<MAX_INVENTORY;i++){
  5947. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5948. num++;
  5949. }
  5950. }
  5951. if (num > 0) {
  5952. clif_item_identify_list(sd);
  5953. } else {
  5954. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5955. }
  5956. return 0;
  5957. }
  5958. /*===============================================
  5959. * @identifyall
  5960. * => Indentify all items in inventory - Akinari
  5961. *-----------------------------------------------*/
  5962. ACMD_FUNC(identifyall)
  5963. {
  5964. int i;
  5965. nullpo_retr(-1, sd);
  5966. for(i=0; i<MAX_INVENTORY; i++) {
  5967. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  5968. sd->status.inventory[i].identify=1;
  5969. clif_item_identified(sd,i,0);
  5970. }
  5971. }
  5972. return 0;
  5973. }
  5974. /*==========================================
  5975. * @gmotd (Global MOTD)
  5976. * by davidsiaw :P
  5977. *------------------------------------------*/
  5978. ACMD_FUNC(gmotd)
  5979. {
  5980. FILE* fp;
  5981. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5982. {
  5983. char buf[CHAT_SIZE_MAX];
  5984. size_t len;
  5985. while( fgets(buf, sizeof(buf), fp) )
  5986. {
  5987. if( buf[0] == '/' && buf[1] == '/' )
  5988. {
  5989. continue;
  5990. }
  5991. len = strlen(buf);
  5992. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5993. {// strip trailing EOL characters
  5994. len--;
  5995. }
  5996. if( len )
  5997. {
  5998. buf[len] = 0;
  5999. intif_broadcast(buf, len+1, 0);
  6000. }
  6001. }
  6002. fclose(fp);
  6003. }
  6004. return 0;
  6005. }
  6006. ACMD_FUNC(misceffect)
  6007. {
  6008. int effect = 0;
  6009. nullpo_retr(-1, sd);
  6010. if (!message || !*message)
  6011. return -1;
  6012. if (sscanf(message, "%11d", &effect) < 1)
  6013. return -1;
  6014. clif_misceffect(&sd->bl,effect);
  6015. return 0;
  6016. }
  6017. /*==========================================
  6018. * MAIL SYSTEM
  6019. *------------------------------------------*/
  6020. ACMD_FUNC(mail)
  6021. {
  6022. nullpo_ret(sd);
  6023. mail_openmail(sd);
  6024. return 0;
  6025. }
  6026. /*==========================================
  6027. * Show Monster DB Info v 1.0
  6028. * originally by [Lupus]
  6029. *------------------------------------------*/
  6030. ACMD_FUNC(mobinfo)
  6031. {
  6032. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6033. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6034. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6035. char atcmd_output2[CHAT_SIZE_MAX];
  6036. struct item_data *item_data;
  6037. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6038. int count;
  6039. int i, k;
  6040. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6041. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6042. if (!message || !*message) {
  6043. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6044. return -1;
  6045. }
  6046. // If monster identifier/name argument is a name
  6047. if ((i = mobdb_checkid(atoi(message))))
  6048. {
  6049. mob_array[0] = mob_db(i);
  6050. count = 1;
  6051. } else
  6052. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6053. if (!count) {
  6054. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6055. return -1;
  6056. }
  6057. if (count > MAX_SEARCH) {
  6058. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6059. clif_displaymessage(fd, atcmd_output);
  6060. count = MAX_SEARCH;
  6061. }
  6062. for (k = 0; k < count; k++) {
  6063. unsigned int j,base_exp,job_exp;
  6064. mob = mob_array[k];
  6065. base_exp = mob->base_exp;
  6066. job_exp = mob->job_exp;
  6067. #ifdef RENEWAL_EXP
  6068. if( battle_config.atcommand_mobinfo_type ) {
  6069. base_exp = base_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6070. job_exp = job_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6071. }
  6072. #endif
  6073. #ifdef VIP_ENABLE
  6074. // Display EXP rate increase for VIP.
  6075. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase)) {
  6076. base_exp += battle_config.vip_base_exp_increase;
  6077. job_exp += battle_config.vip_job_exp_increase;
  6078. }
  6079. #endif
  6080. // stats
  6081. if (mob->mexp)
  6082. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6083. else
  6084. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6085. clif_displaymessage(fd, atcmd_output);
  6086. 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
  6087. clif_displaymessage(fd, atcmd_output);
  6088. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6089. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6090. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6091. clif_displaymessage(fd, atcmd_output);
  6092. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6093. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6094. mob->range2 , mob->range3, msize[mob->status.size],
  6095. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6096. clif_displaymessage(fd, atcmd_output);
  6097. // drops
  6098. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6099. strcpy(atcmd_output, " ");
  6100. j = 0;
  6101. for (i = 0; i < MAX_MOB_DROP; i++) {
  6102. int droprate;
  6103. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6104. continue;
  6105. droprate = mob->dropitem[i].p;
  6106. #ifdef RENEWAL_DROP
  6107. if( battle_config.atcommand_mobinfo_type ) {
  6108. droprate = droprate * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 2) / 100;
  6109. if (droprate <= 0 && !battle_config.drop_rate0item)
  6110. droprate = 1;
  6111. }
  6112. #endif
  6113. #ifdef VIP_ENABLE
  6114. // Display item rate increase for VIP.
  6115. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6116. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6117. #endif
  6118. if (item_data->slot)
  6119. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6120. else
  6121. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6122. strcat(atcmd_output, atcmd_output2);
  6123. if (++j % 3 == 0) {
  6124. clif_displaymessage(fd, atcmd_output);
  6125. strcpy(atcmd_output, " ");
  6126. }
  6127. }
  6128. if (j == 0)
  6129. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6130. else if (j % 3 != 0)
  6131. clif_displaymessage(fd, atcmd_output);
  6132. // mvp
  6133. if (mob->mexp) {
  6134. float mvppercent, mvpremain;
  6135. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6136. clif_displaymessage(fd, atcmd_output);
  6137. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6138. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6139. j = 0;
  6140. for (i = 0; i < MAX_MVP_DROP; i++) {
  6141. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6142. continue;
  6143. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6144. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6145. if(battle_config.item_drop_mvp_mode == 0) {
  6146. mvpremain -= mvppercent;
  6147. }
  6148. if (mvppercent > 0) {
  6149. j++;
  6150. if (j == 1) {
  6151. if (item_data->slot)
  6152. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6153. else
  6154. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6155. } else {
  6156. if (item_data->slot)
  6157. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6158. else
  6159. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6160. }
  6161. strcat(atcmd_output, atcmd_output2);
  6162. }
  6163. }
  6164. if (j == 0)
  6165. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6166. else
  6167. clif_displaymessage(fd, atcmd_output);
  6168. }
  6169. }
  6170. return 0;
  6171. }
  6172. /*=========================================
  6173. * @showmobs by KarLaeda
  6174. * => For 15 sec displays the mobs on minimap
  6175. *------------------------------------------*/
  6176. ACMD_FUNC(showmobs)
  6177. {
  6178. char mob_name[100];
  6179. int mob_id;
  6180. int number = 0;
  6181. struct s_mapiterator* it;
  6182. nullpo_retr(-1, sd);
  6183. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6184. return -1;
  6185. if((mob_id = atoi(mob_name)) == 0)
  6186. mob_id = mobdb_searchname(mob_name);
  6187. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6188. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6189. clif_displaymessage(fd, atcmd_output);
  6190. return 0;
  6191. }
  6192. 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.
  6193. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6194. return 0;
  6195. }
  6196. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6197. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6198. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6199. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6200. mob_name, mapindex_id2name(sd->mapindex));
  6201. clif_displaymessage(fd, atcmd_output);
  6202. it = mapit_geteachmob();
  6203. for(;;)
  6204. {
  6205. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6206. if( md == NULL )
  6207. break;// no more mobs
  6208. if( md->bl.m != sd->bl.m )
  6209. continue;
  6210. if( mob_id != -1 && md->mob_id != mob_id )
  6211. continue;
  6212. if( md->special_state.ai || md->master_id )
  6213. continue; // hide slaves and player summoned mobs
  6214. if( md->spawn_timer != INVALID_TIMER )
  6215. continue; // hide mobs waiting for respawn
  6216. ++number;
  6217. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6218. }
  6219. mapit_free(it);
  6220. return 0;
  6221. }
  6222. /*==========================================
  6223. * homunculus level up [orn]
  6224. *------------------------------------------*/
  6225. ACMD_FUNC(homlevel)
  6226. {
  6227. TBL_HOM * hd;
  6228. int level = 0, i = 0;
  6229. nullpo_retr(-1, sd);
  6230. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6231. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6232. return -1;
  6233. }
  6234. if ( !hom_is_active(sd->hd) ) {
  6235. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6236. return -1;
  6237. }
  6238. hd = sd->hd;
  6239. for (i = 1; i <= level && hd->exp_next; i++){
  6240. hd->homunculus.exp += hd->exp_next;
  6241. if( !hom_levelup(hd) )
  6242. break;
  6243. }
  6244. status_calc_homunculus(hd, SCO_NONE);
  6245. status_percent_heal(&hd->bl, 100, 100);
  6246. clif_specialeffect(&hd->bl,568,AREA);
  6247. return 0;
  6248. }
  6249. /*==========================================
  6250. * homunculus evolution H [orn]
  6251. *------------------------------------------*/
  6252. ACMD_FUNC(homevolution)
  6253. {
  6254. nullpo_retr(-1, sd);
  6255. if ( !hom_is_active(sd->hd) ) {
  6256. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6257. return -1;
  6258. }
  6259. if ( !hom_evolution(sd->hd) ) {
  6260. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6261. return -1;
  6262. }
  6263. clif_homskillinfoblock(sd);
  6264. return 0;
  6265. }
  6266. ACMD_FUNC(hommutate)
  6267. {
  6268. int homun_id, m_class = 0, m_id;
  6269. nullpo_retr(-1, sd);
  6270. if (!hom_is_active(sd->hd)) {
  6271. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6272. return -1;
  6273. }
  6274. if (!message || !*message) {
  6275. homun_id = 6048 + (rnd() % 4);
  6276. } else {
  6277. homun_id = atoi(message);
  6278. }
  6279. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6280. m_id = hom_class2mapid(homun_id);
  6281. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6282. hom_mutate(sd->hd, homun_id);
  6283. } else {
  6284. clif_emotion(&sd->hd->bl, E_SWT);
  6285. }
  6286. return 0;
  6287. }
  6288. /*==========================================
  6289. * call choosen homunculus [orn]
  6290. *------------------------------------------*/
  6291. ACMD_FUNC(makehomun)
  6292. {
  6293. int homunid;
  6294. nullpo_retr(-1, sd);
  6295. if ( sd->status.hom_id ) {
  6296. clif_displaymessage(fd, msg_txt(sd,450));
  6297. return -1;
  6298. }
  6299. if (!message || !*message) {
  6300. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6301. return -1;
  6302. }
  6303. homunid = atoi(message);
  6304. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6305. {
  6306. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6307. return -1;
  6308. }
  6309. hom_create_request(sd,homunid);
  6310. return 0;
  6311. }
  6312. /*==========================================
  6313. * modify homunculus intimacy [orn]
  6314. *------------------------------------------*/
  6315. ACMD_FUNC(homfriendly)
  6316. {
  6317. int friendly = 0;
  6318. nullpo_retr(-1, sd);
  6319. if ( !hom_is_active(sd->hd) ) {
  6320. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6321. return -1;
  6322. }
  6323. if (!message || !*message) {
  6324. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6325. return -1;
  6326. }
  6327. friendly = atoi(message);
  6328. friendly = cap_value(friendly, 0, 1000);
  6329. sd->hd->homunculus.intimacy = friendly * 100 ;
  6330. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6331. return 0;
  6332. }
  6333. /*==========================================
  6334. * modify homunculus hunger [orn]
  6335. *------------------------------------------*/
  6336. ACMD_FUNC(homhungry)
  6337. {
  6338. int hungry = 0;
  6339. nullpo_retr(-1, sd);
  6340. if ( !hom_is_active(sd->hd) ) {
  6341. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6342. return -1;
  6343. }
  6344. if (!message || !*message) {
  6345. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6346. return -1;
  6347. }
  6348. hungry = atoi(message);
  6349. hungry = cap_value(hungry, 0, 100);
  6350. sd->hd->homunculus.hunger = hungry;
  6351. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6352. return 0;
  6353. }
  6354. /*==========================================
  6355. * make the homunculus speak [orn]
  6356. *------------------------------------------*/
  6357. ACMD_FUNC(homtalk)
  6358. {
  6359. char mes[100],temp[100];
  6360. nullpo_retr(-1, sd);
  6361. if ( battle_config.min_chat_delay ) {
  6362. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6363. return 0;
  6364. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6365. }
  6366. if (sd->sc.cant.chat)
  6367. return -1; //no "chatting" while muted.
  6368. if ( !hom_is_active(sd->hd) ) {
  6369. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6370. return -1;
  6371. }
  6372. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6373. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6374. return -1;
  6375. }
  6376. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6377. clif_disp_overhead(&sd->hd->bl, temp);
  6378. return 0;
  6379. }
  6380. /*==========================================
  6381. * Show homunculus stats
  6382. *------------------------------------------*/
  6383. ACMD_FUNC(hominfo)
  6384. {
  6385. struct homun_data *hd;
  6386. struct status_data *status;
  6387. nullpo_retr(-1, sd);
  6388. if ( !hom_is_active(sd->hd) ) {
  6389. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6390. return -1;
  6391. }
  6392. hd = sd->hd;
  6393. status = status_get_status_data(&hd->bl);
  6394. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6395. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6396. status->hp, status->max_hp, status->sp, status->max_sp);
  6397. clif_displaymessage(fd, atcmd_output);
  6398. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6399. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6400. clif_displaymessage(fd, atcmd_output);
  6401. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6402. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6403. clif_displaymessage(fd, atcmd_output);
  6404. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6405. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6406. status->str, status->agi, status->vit,
  6407. status->int_, status->dex, status->luk);
  6408. clif_displaymessage(fd, atcmd_output);
  6409. return 0;
  6410. }
  6411. ACMD_FUNC(homstats)
  6412. {
  6413. struct homun_data *hd;
  6414. struct s_homunculus_db *db;
  6415. struct s_homunculus *hom;
  6416. int lv, min, max, evo;
  6417. nullpo_retr(-1, sd);
  6418. if ( !hom_is_active(sd->hd) ) {
  6419. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6420. return -1;
  6421. }
  6422. hd = sd->hd;
  6423. hom = &hd->homunculus;
  6424. db = hd->homunculusDB;
  6425. lv = hom->level;
  6426. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6427. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6428. clif_displaymessage(fd, atcmd_output);
  6429. lv--; //Since the first increase is at level 2.
  6430. evo = (hom->class_ == db->evo_class);
  6431. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6432. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6433. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6434. clif_displaymessage(fd, atcmd_output);
  6435. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6436. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6437. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6438. clif_displaymessage(fd, atcmd_output);
  6439. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6440. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6441. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6442. clif_displaymessage(fd, atcmd_output);
  6443. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6444. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6445. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6446. clif_displaymessage(fd, atcmd_output);
  6447. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6448. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6449. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6450. clif_displaymessage(fd, atcmd_output);
  6451. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6452. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6453. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6454. clif_displaymessage(fd, atcmd_output);
  6455. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6456. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6457. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6458. clif_displaymessage(fd, atcmd_output);
  6459. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6460. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6461. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6462. clif_displaymessage(fd, atcmd_output);
  6463. return 0;
  6464. }
  6465. ACMD_FUNC(homshuffle)
  6466. {
  6467. nullpo_retr(-1, sd);
  6468. if(!sd->hd)
  6469. return -1; // nothing to do
  6470. if(!hom_shuffle(sd->hd))
  6471. return -1;
  6472. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6473. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6474. return 0;
  6475. }
  6476. /*==========================================
  6477. * Show Items DB Info v 1.0
  6478. * originally by [Lupus]
  6479. *------------------------------------------*/
  6480. ACMD_FUNC(iteminfo)
  6481. {
  6482. struct item_data *item_array[MAX_SEARCH];
  6483. int i, count = 1;
  6484. if (!message || !*message) {
  6485. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6486. return -1;
  6487. }
  6488. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6489. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6490. if (!count) {
  6491. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6492. return -1;
  6493. }
  6494. if (count > MAX_SEARCH) {
  6495. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6496. clif_displaymessage(fd, atcmd_output);
  6497. count = MAX_SEARCH;
  6498. }
  6499. for (i = 0; i < count; i++) {
  6500. struct item_data * item_data = item_array[i];
  6501. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6502. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6503. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6504. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6505. );
  6506. clif_displaymessage(fd, atcmd_output);
  6507. 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
  6508. clif_displaymessage(fd, atcmd_output);
  6509. if (item_data->maxchance == -1)
  6510. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6511. else if (!battle_config.atcommand_mobinfo_type) {
  6512. if (item_data->maxchance)
  6513. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6514. else
  6515. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6516. }
  6517. clif_displaymessage(fd, atcmd_output);
  6518. }
  6519. return 0;
  6520. }
  6521. /*==========================================
  6522. * Show who drops the item.
  6523. *------------------------------------------*/
  6524. ACMD_FUNC(whodrops)
  6525. {
  6526. struct item_data *item_data, *item_array[MAX_SEARCH];
  6527. int i,j, count = 1;
  6528. if (!message || !*message) {
  6529. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6530. return -1;
  6531. }
  6532. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6533. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6534. if (!count) {
  6535. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6536. return -1;
  6537. }
  6538. if (count > MAX_SEARCH) {
  6539. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6540. clif_displaymessage(fd, atcmd_output);
  6541. count = MAX_SEARCH;
  6542. }
  6543. for (i = 0; i < count; i++) {
  6544. item_data = item_array[i];
  6545. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6546. clif_displaymessage(fd, atcmd_output);
  6547. if (item_data->mob[0].chance == 0) {
  6548. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6549. clif_displaymessage(fd, atcmd_output);
  6550. } else {
  6551. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6552. clif_displaymessage(fd, atcmd_output);
  6553. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6554. {
  6555. int dropchance = item_data->mob[j].chance;
  6556. #ifdef RENEWAL_DROP
  6557. if( battle_config.atcommand_mobinfo_type )
  6558. 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;
  6559. #endif
  6560. #ifdef VIP_ENABLE
  6561. // Display item rate increase for VIP.
  6562. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6563. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6564. #endif
  6565. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6566. clif_displaymessage(fd, atcmd_output);
  6567. }
  6568. }
  6569. }
  6570. return 0;
  6571. }
  6572. ACMD_FUNC(whereis)
  6573. {
  6574. struct mob_db *mob_array[MAX_SEARCH];
  6575. int count;
  6576. int i, j, k;
  6577. if (!message || !*message) {
  6578. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6579. return -1;
  6580. }
  6581. // If monster identifier/name argument is a name
  6582. if ((i = mobdb_checkid(atoi(message))))
  6583. {
  6584. mob_array[0] = mob_db(i);
  6585. count = 1;
  6586. } else
  6587. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6588. if (!count) {
  6589. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6590. return -1;
  6591. }
  6592. if (count > MAX_SEARCH) {
  6593. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6594. clif_displaymessage(fd, atcmd_output);
  6595. count = MAX_SEARCH;
  6596. }
  6597. for (k = 0; k < count; k++) {
  6598. struct mob_db *mob = mob_array[k];
  6599. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6600. clif_displaymessage(fd, atcmd_output);
  6601. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6602. {
  6603. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6604. if (j < 0) continue;
  6605. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6606. clif_displaymessage(fd, atcmd_output);
  6607. }
  6608. if (i == 0)
  6609. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6610. }
  6611. return 0;
  6612. }
  6613. ACMD_FUNC(version)
  6614. {
  6615. pc_show_version(sd);
  6616. return 0;
  6617. }
  6618. /*==========================================
  6619. * @mutearea by MouseJstr
  6620. *------------------------------------------*/
  6621. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6622. {
  6623. int time, id;
  6624. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6625. if (pl_sd == NULL)
  6626. return 0;
  6627. id = va_arg(ap, int);
  6628. time = va_arg(ap, int);
  6629. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6630. pl_sd->status.manner -= time;
  6631. if (pl_sd->status.manner < 0)
  6632. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6633. else
  6634. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6635. }
  6636. return 0;
  6637. }
  6638. ACMD_FUNC(mutearea)
  6639. {
  6640. int time;
  6641. nullpo_ret(sd);
  6642. if (!message || !*message) {
  6643. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6644. return -1;
  6645. }
  6646. time = atoi(message);
  6647. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6648. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6649. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6650. return 0;
  6651. }
  6652. ACMD_FUNC(rates)
  6653. {
  6654. char buf[CHAT_SIZE_MAX];
  6655. int base_exp_rate = 0, job_exp_rate = 0;
  6656. nullpo_ret(sd);
  6657. memset(buf, '\0', sizeof(buf));
  6658. #ifdef VIP_ENABLE
  6659. // Display EXP and item rate increase for VIP.
  6660. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase || battle_config.vip_drop_increase)) {
  6661. base_exp_rate += battle_config.vip_base_exp_increase;
  6662. job_exp_rate += battle_config.vip_job_exp_increase;
  6663. }
  6664. #endif
  6665. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6666. (battle_config.base_exp_rate+base_exp_rate)/100., (battle_config.job_exp_rate+job_exp_rate)/100.);
  6667. clif_displaymessage(fd, buf);
  6668. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6669. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6670. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6671. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6672. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6673. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6674. clif_displaymessage(fd, buf);
  6675. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6676. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6677. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6678. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6679. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6680. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6681. clif_displaymessage(fd, buf);
  6682. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6683. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6684. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6685. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6686. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6687. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6688. clif_displaymessage(fd, buf);
  6689. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6690. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6691. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6692. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6693. clif_displaymessage(fd, buf);
  6694. return 0;
  6695. }
  6696. /*==========================================
  6697. * @me by lordalfa
  6698. * => Displays the OUTPUT string on top of the Visible players Heads.
  6699. *------------------------------------------*/
  6700. ACMD_FUNC(me)
  6701. {
  6702. char tempmes[CHAT_SIZE_MAX];
  6703. nullpo_retr(-1, sd);
  6704. memset(tempmes, '\0', sizeof(tempmes));
  6705. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6706. if (sd->sc.cant.chat)
  6707. return -1; //no "chatting" while muted.
  6708. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6709. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6710. return -1;
  6711. }
  6712. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6713. clif_disp_overhead(&sd->bl, atcmd_output);
  6714. return 0;
  6715. }
  6716. /*==========================================
  6717. * @size
  6718. * => Resize your character sprite. [Valaris]
  6719. *------------------------------------------*/
  6720. ACMD_FUNC(size)
  6721. {
  6722. int size = 0;
  6723. nullpo_retr(-1, sd);
  6724. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6725. if(sd->state.size) {
  6726. sd->state.size = SZ_SMALL;
  6727. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6728. }
  6729. sd->state.size = size;
  6730. if( size == SZ_MEDIUM )
  6731. clif_specialeffect(&sd->bl,420,AREA);
  6732. else if( size == SZ_BIG )
  6733. clif_specialeffect(&sd->bl,422,AREA);
  6734. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6735. return 0;
  6736. }
  6737. ACMD_FUNC(sizeall)
  6738. {
  6739. int size;
  6740. struct map_session_data *pl_sd;
  6741. struct s_mapiterator* iter;
  6742. size = atoi(message);
  6743. size = cap_value(size,0,2);
  6744. iter = mapit_getallusers();
  6745. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6746. if( pl_sd->state.size != size ) {
  6747. if( pl_sd->state.size ) {
  6748. pl_sd->state.size = SZ_SMALL;
  6749. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6750. }
  6751. pl_sd->state.size = size;
  6752. if( size == SZ_MEDIUM )
  6753. clif_specialeffect(&pl_sd->bl,420,AREA);
  6754. else if( size == SZ_BIG )
  6755. clif_specialeffect(&pl_sd->bl,422,AREA);
  6756. }
  6757. }
  6758. mapit_free(iter);
  6759. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6760. return 0;
  6761. }
  6762. ACMD_FUNC(sizeguild)
  6763. {
  6764. int size = 0, i;
  6765. char guild[NAME_LENGTH];
  6766. struct map_session_data *pl_sd;
  6767. struct guild *g;
  6768. nullpo_retr(-1, sd);
  6769. memset(guild, '\0', sizeof(guild));
  6770. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6771. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6772. return -1;
  6773. }
  6774. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6775. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6776. return -1;
  6777. }
  6778. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6779. for( i = 0; i < g->max_member; i++ ) {
  6780. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6781. if( pl_sd->state.size ) {
  6782. pl_sd->state.size = SZ_SMALL;
  6783. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6784. }
  6785. pl_sd->state.size = size;
  6786. if( size == SZ_MEDIUM )
  6787. clif_specialeffect(&pl_sd->bl,420,AREA);
  6788. else if( size == SZ_BIG )
  6789. clif_specialeffect(&pl_sd->bl,422,AREA);
  6790. }
  6791. }
  6792. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6793. return 0;
  6794. }
  6795. /*==========================================
  6796. * @monsterignore
  6797. * => Makes monsters ignore you. [Valaris]
  6798. *------------------------------------------*/
  6799. ACMD_FUNC(monsterignore)
  6800. {
  6801. nullpo_retr(-1, sd);
  6802. if (!sd->state.monster_ignore) {
  6803. sd->state.monster_ignore = 1;
  6804. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6805. } else {
  6806. sd->state.monster_ignore = 0;
  6807. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6808. }
  6809. return 0;
  6810. }
  6811. /*==========================================
  6812. * @fakename
  6813. * => Gives your character a fake name. [Valaris]
  6814. *------------------------------------------*/
  6815. ACMD_FUNC(fakename)
  6816. {
  6817. nullpo_retr(-1, sd);
  6818. if( !message || !*message )
  6819. {
  6820. if( sd->fakename[0] )
  6821. {
  6822. sd->fakename[0] = '\0';
  6823. clif_charnameack(0, &sd->bl);
  6824. if (sd->disguise)
  6825. clif_charnameack(sd->fd, &sd->bl);
  6826. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6827. return 0;
  6828. }
  6829. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6830. return -1;
  6831. }
  6832. if( strlen(message) < 2 )
  6833. {
  6834. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6835. return -1;
  6836. }
  6837. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6838. clif_charnameack(0, &sd->bl);
  6839. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6840. clif_charnameack(sd->fd, &sd->bl);
  6841. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6842. return 0;
  6843. }
  6844. /*==========================================
  6845. * Ragnarok Resources
  6846. *------------------------------------------*/
  6847. ACMD_FUNC(mapflag) {
  6848. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6849. #define setflag( cmd ) \
  6850. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6851. map[ sd->bl.m ].flag.cmd = flag;\
  6852. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6853. clif_displaymessage(sd->fd,atcmd_output);\
  6854. return 0;\
  6855. }
  6856. char flag_name[100];
  6857. short flag=0,i;
  6858. nullpo_retr(-1, sd);
  6859. memset(flag_name, '\0', sizeof(flag_name));
  6860. if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
  6861. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6862. clif_displaymessage(sd->fd,"----------------------------------");
  6863. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6864. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6865. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6866. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6867. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6868. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6869. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6870. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6871. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6872. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6873. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6874. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6875. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6876. checkflag(nolockon); checkflag(notomb);
  6877. #ifdef ADJUST_SKILL_DAMAGE
  6878. checkflag(skill_damage);
  6879. #endif
  6880. clif_displaymessage(sd->fd," ");
  6881. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6882. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6883. return 1;
  6884. }
  6885. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6886. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6887. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6888. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6889. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6890. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6891. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6892. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6893. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6894. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6895. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  6896. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  6897. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  6898. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  6899. setflag(nolockon); setflag(notomb);
  6900. #ifdef ADJUST_SKILL_DAMAGE
  6901. setflag(skill_damage);
  6902. #endif
  6903. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6904. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6905. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6906. clif_displaymessage(sd->fd,"----------------------------------");
  6907. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6908. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6909. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6910. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6911. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  6912. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  6913. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb");
  6914. #ifdef ADJUST_SKILL_DAMAGE
  6915. clif_displaymessage(sd->fd,"skill_damage");
  6916. #endif
  6917. #undef checkflag
  6918. #undef setflag
  6919. return 0;
  6920. }
  6921. /*===================================
  6922. * Remove some messages
  6923. *-----------------------------------*/
  6924. ACMD_FUNC(showexp)
  6925. {
  6926. if (sd->state.showexp) {
  6927. sd->state.showexp = 0;
  6928. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6929. return 0;
  6930. }
  6931. sd->state.showexp = 1;
  6932. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6933. return 0;
  6934. }
  6935. ACMD_FUNC(showzeny)
  6936. {
  6937. if (sd->state.showzeny) {
  6938. sd->state.showzeny = 0;
  6939. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6940. return 0;
  6941. }
  6942. sd->state.showzeny = 1;
  6943. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6944. return 0;
  6945. }
  6946. ACMD_FUNC(showdelay)
  6947. {
  6948. if (sd->state.showdelay) {
  6949. sd->state.showdelay = 0;
  6950. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6951. return 0;
  6952. }
  6953. sd->state.showdelay = 1;
  6954. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6955. return 0;
  6956. }
  6957. /*==========================================
  6958. * Duel organizing functions [LuzZza]
  6959. *
  6960. * @duel [limit|nick] - create a duel
  6961. * @invite <nick> - invite player
  6962. * @accept - accept invitation
  6963. * @reject - reject invitation
  6964. * @leave - leave duel
  6965. *------------------------------------------*/
  6966. ACMD_FUNC(invite)
  6967. {
  6968. unsigned int did = sd->duel_group;
  6969. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6970. if(did == 0) {
  6971. // "Duel: @invite without @duel."
  6972. clif_displaymessage(fd, msg_txt(sd,350));
  6973. return 0;
  6974. }
  6975. if(duel_list[did].max_players_limit > 0 &&
  6976. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6977. // "Duel: Limit of players is reached."
  6978. clif_displaymessage(fd, msg_txt(sd,351));
  6979. return 0;
  6980. }
  6981. if(target_sd == NULL) {
  6982. // "Duel: Player not found."
  6983. clif_displaymessage(fd, msg_txt(sd,352));
  6984. return 0;
  6985. }
  6986. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6987. // "Duel: Player already in duel."
  6988. clif_displaymessage(fd, msg_txt(sd,353));
  6989. return 0;
  6990. }
  6991. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6992. {
  6993. sprintf(atcmd_output, msg_txt(sd,364), message);
  6994. clif_displaymessage(fd, atcmd_output);
  6995. return 0;
  6996. }
  6997. duel_invite(did, sd, target_sd);
  6998. // "Duel: Invitation has been sent."
  6999. clif_displaymessage(fd, msg_txt(sd,354));
  7000. return 0;
  7001. }
  7002. ACMD_FUNC(duel)
  7003. {
  7004. unsigned int maxpl = 0;
  7005. if(sd->duel_group > 0) {
  7006. duel_showinfo(sd->duel_group, sd);
  7007. return 0;
  7008. }
  7009. if(sd->duel_invite > 0) {
  7010. // "Duel: @duel without @reject."
  7011. clif_displaymessage(fd, msg_txt(sd,355));
  7012. return 0;
  7013. }
  7014. if(!duel_checktime(sd)) {
  7015. char output[CHAT_SIZE_MAX];
  7016. // "Duel: You can take part in duel only one time per %d minutes."
  7017. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  7018. clif_displaymessage(fd, output);
  7019. return 0;
  7020. }
  7021. if( message[0] ) {
  7022. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7023. if(maxpl < 2 || maxpl > 65535) {
  7024. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7025. return 0;
  7026. }
  7027. duel_create(sd, maxpl);
  7028. } else {
  7029. struct map_session_data *target_sd;
  7030. target_sd = map_nick2sd((char *)message);
  7031. if(target_sd != NULL) {
  7032. unsigned int newduel;
  7033. if((newduel = duel_create(sd, 2)) != -1) {
  7034. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7035. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7036. return 0;
  7037. }
  7038. duel_invite(newduel, sd, target_sd);
  7039. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7040. }
  7041. } else {
  7042. // "Duel: Player not found."
  7043. clif_displaymessage(fd, msg_txt(sd,352));
  7044. return 0;
  7045. }
  7046. }
  7047. } else
  7048. duel_create(sd, 0);
  7049. return 0;
  7050. }
  7051. ACMD_FUNC(leave)
  7052. {
  7053. if(sd->duel_group <= 0) {
  7054. // "Duel: @leave without @duel."
  7055. clif_displaymessage(fd, msg_txt(sd,358));
  7056. return 0;
  7057. }
  7058. duel_leave(sd->duel_group, sd);
  7059. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7060. return 0;
  7061. }
  7062. ACMD_FUNC(accept)
  7063. {
  7064. if(!duel_checktime(sd)) {
  7065. char output[CHAT_SIZE_MAX];
  7066. // "Duel: You can take part in duel only one time per %d minutes."
  7067. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  7068. clif_displaymessage(fd, output);
  7069. return 0;
  7070. }
  7071. if(sd->duel_invite <= 0) {
  7072. // "Duel: @accept without invititation."
  7073. clif_displaymessage(fd, msg_txt(sd,360));
  7074. return 0;
  7075. }
  7076. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  7077. {
  7078. // "Duel: Limit of players is reached."
  7079. clif_displaymessage(fd, msg_txt(sd,351));
  7080. return 0;
  7081. }
  7082. duel_accept(sd->duel_invite, sd);
  7083. // "Duel: Invitation has been accepted."
  7084. clif_displaymessage(fd, msg_txt(sd,361));
  7085. return 0;
  7086. }
  7087. ACMD_FUNC(reject)
  7088. {
  7089. if(sd->duel_invite <= 0) {
  7090. // "Duel: @reject without invititation."
  7091. clif_displaymessage(fd, msg_txt(sd,362));
  7092. return 0;
  7093. }
  7094. duel_reject(sd->duel_invite, sd);
  7095. // "Duel: Invitation has been rejected."
  7096. clif_displaymessage(fd, msg_txt(sd,363));
  7097. return 0;
  7098. }
  7099. /*===================================
  7100. * Cash Points
  7101. *-----------------------------------*/
  7102. ACMD_FUNC(cash)
  7103. {
  7104. char output[128];
  7105. int value;
  7106. int ret=0;
  7107. nullpo_retr(-1, sd);
  7108. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7109. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7110. return -1;
  7111. }
  7112. parent_cmd = atcommand_checkalias(command+1);
  7113. if( !strcmpi(parent_cmd,"cash") )
  7114. {
  7115. if( value > 0 ) {
  7116. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7117. // If this option is set, the message is already sent by pc function
  7118. if( !battle_config.cashshop_show_points ){
  7119. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  7120. clif_disp_onlyself(sd, output, strlen(output));
  7121. }
  7122. }
  7123. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7124. } else {
  7125. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7126. value = -sd->cashPoints;
  7127. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7128. // If this option is set, the message is already sent by pc function
  7129. if( !battle_config.cashshop_show_points ){
  7130. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  7131. clif_disp_onlyself(sd, output, strlen(output));
  7132. }
  7133. }
  7134. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7135. }
  7136. }
  7137. else
  7138. { // @points
  7139. if( value > 0 ) {
  7140. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7141. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  7142. clif_disp_onlyself(sd, output, strlen(output));
  7143. }
  7144. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7145. } else {
  7146. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7147. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  7148. clif_disp_onlyself(sd, output, strlen(output));
  7149. }
  7150. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7151. }
  7152. }
  7153. return 0;
  7154. }
  7155. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7156. ACMD_FUNC(clone)
  7157. {
  7158. int x=0,y=0,flag=0,master=0,i=0;
  7159. struct map_session_data *pl_sd=NULL;
  7160. if (!message || !*message) {
  7161. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7162. return 0;
  7163. }
  7164. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7165. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7166. return 0;
  7167. }
  7168. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7169. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7170. return 0;
  7171. }
  7172. parent_cmd = atcommand_checkalias(command+1);
  7173. if (strcmpi(parent_cmd, "clone") == 0)
  7174. flag = 1;
  7175. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7176. flag = 2;
  7177. if(pc_isdead(sd)){
  7178. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7179. return 0;
  7180. }
  7181. master = sd->bl.id;
  7182. if (battle_config.atc_slave_clone_limit
  7183. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7184. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7185. return 0;
  7186. }
  7187. }
  7188. do {
  7189. x = sd->bl.x + (rnd() % 10 - 5);
  7190. y = sd->bl.y + (rnd() % 10 - 5);
  7191. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7192. if (i >= 10) {
  7193. x = sd->bl.x;
  7194. y = sd->bl.y;
  7195. }
  7196. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7197. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7198. return 0;
  7199. }
  7200. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7201. return 0;
  7202. }
  7203. /*=====================================
  7204. * Autorejecting Invites/Deals [LuzZza]
  7205. * Usage: @noask
  7206. *-------------------------------------*/
  7207. ACMD_FUNC(noask)
  7208. {
  7209. if(sd->state.noask) {
  7210. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7211. sd->state.noask = 0;
  7212. } else {
  7213. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7214. sd->state.noask = 1;
  7215. }
  7216. return 0;
  7217. }
  7218. /*=====================================
  7219. * Send a @request message to all GMs of lowest_gm_level.
  7220. * Usage: @request <petition>
  7221. *-------------------------------------*/
  7222. ACMD_FUNC(request)
  7223. {
  7224. if (!message || !*message) {
  7225. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7226. return -1;
  7227. }
  7228. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7229. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7230. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7231. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7232. return 0;
  7233. }
  7234. /*==========================================
  7235. * Feel (SG save map) Reset [HiddenDragon]
  7236. *------------------------------------------*/
  7237. ACMD_FUNC(feelreset)
  7238. {
  7239. pc_resetfeel(sd);
  7240. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7241. return 0;
  7242. }
  7243. /*==========================================
  7244. * AUCTION SYSTEM
  7245. *------------------------------------------*/
  7246. ACMD_FUNC(auction)
  7247. {
  7248. nullpo_ret(sd);
  7249. if (!battle_config.feature_auction) {
  7250. clif_colormes(sd->fd, color_table[COLOR_RED], msg_txt(sd, 517));
  7251. return 0;
  7252. }
  7253. clif_Auction_openwindow(sd);
  7254. return 0;
  7255. }
  7256. /*==========================================
  7257. * Kill Steal Protection
  7258. *------------------------------------------*/
  7259. ACMD_FUNC(ksprotection)
  7260. {
  7261. nullpo_retr(-1,sd);
  7262. if( sd->state.noks ) {
  7263. sd->state.noks = 0;
  7264. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7265. }
  7266. else
  7267. {
  7268. if( !message || !*message || !strcmpi(message, "party") )
  7269. { // Default is Party
  7270. sd->state.noks = 2;
  7271. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7272. }
  7273. else if( !strcmpi(message, "self") )
  7274. {
  7275. sd->state.noks = 1;
  7276. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7277. }
  7278. else if( !strcmpi(message, "guild") )
  7279. {
  7280. sd->state.noks = 3;
  7281. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7282. }
  7283. else
  7284. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7285. }
  7286. return 0;
  7287. }
  7288. /*==========================================
  7289. * Map Kill Steal Protection Setting
  7290. *------------------------------------------*/
  7291. ACMD_FUNC(allowks)
  7292. {
  7293. nullpo_retr(-1,sd);
  7294. if( map[sd->bl.m].flag.allowks ) {
  7295. map[sd->bl.m].flag.allowks = 0;
  7296. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7297. } else {
  7298. map[sd->bl.m].flag.allowks = 1;
  7299. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7300. }
  7301. return 0;
  7302. }
  7303. ACMD_FUNC(resetstat)
  7304. {
  7305. nullpo_retr(-1, sd);
  7306. pc_resetstate(sd);
  7307. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  7308. clif_displaymessage(fd, atcmd_output);
  7309. return 0;
  7310. }
  7311. ACMD_FUNC(resetskill)
  7312. {
  7313. nullpo_retr(-1,sd);
  7314. pc_resetskill(sd,1);
  7315. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  7316. clif_displaymessage(fd, atcmd_output);
  7317. return 0;
  7318. }
  7319. /*==========================================
  7320. * #storagelist: Displays the items list of a player's storage.
  7321. * #cartlist: Displays contents of target's cart.
  7322. * #itemlist: Displays contents of target's inventory.
  7323. *------------------------------------------*/
  7324. ACMD_FUNC(itemlist)
  7325. {
  7326. int i, j, count, counter;
  7327. const char* location;
  7328. const struct item* items;
  7329. int size;
  7330. StringBuf buf;
  7331. nullpo_retr(-1, sd);
  7332. parent_cmd = atcommand_checkalias(command+1);
  7333. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7334. location = "storage";
  7335. items = sd->status.storage.items;
  7336. size = sd->storage_size;
  7337. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7338. location = "cart";
  7339. items = sd->status.cart;
  7340. size = MAX_CART;
  7341. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7342. location = "inventory";
  7343. items = sd->status.inventory;
  7344. size = MAX_INVENTORY;
  7345. } else
  7346. return 1;
  7347. StringBuf_Init(&buf);
  7348. count = 0; // total slots occupied
  7349. counter = 0; // total items found
  7350. for( i = 0; i < size; ++i ) {
  7351. const struct item* it = &items[i];
  7352. struct item_data* itd;
  7353. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7354. continue;
  7355. counter += it->amount;
  7356. count++;
  7357. if( count == 1 ) {
  7358. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7359. clif_displaymessage(fd, StringBuf_Value(&buf));
  7360. StringBuf_Clear(&buf);
  7361. }
  7362. if( it->refine )
  7363. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7364. else
  7365. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7366. if( it->equip ) {
  7367. char equipstr[CHAT_SIZE_MAX];
  7368. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7369. if( it->equip&EQP_GARMENT )
  7370. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7371. if( it->equip&EQP_ACC_L )
  7372. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7373. if( it->equip&EQP_ARMOR )
  7374. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7375. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7376. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7377. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7378. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7379. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7380. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7381. if( it->equip&EQP_SHOES )
  7382. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7383. if( it->equip&EQP_ACC_R )
  7384. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7385. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7386. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7387. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7388. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7389. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7390. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7391. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7392. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7393. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7394. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7395. if( (it->equip&EQP_HELM) == EQP_HELM )
  7396. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7397. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7398. strcat(equipstr, msg_txt(sd,518));
  7399. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7400. strcat(equipstr, msg_txt(sd,519));
  7401. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7402. strcat(equipstr, msg_txt(sd,520));
  7403. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7404. strcat(equipstr, msg_txt(sd,521));
  7405. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7406. strcat(equipstr, msg_txt(sd,522));
  7407. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7408. strcat(equipstr, msg_txt(sd,523));
  7409. if( it->equip&EQP_COSTUME_GARMENT )
  7410. strcat(equipstr, msg_txt(sd,524));
  7411. //if( it->equip&EQP_COSTUME_FLOOR )
  7412. //strcat(equipstr, msg_txt(sd,525));
  7413. if( it->equip&EQP_AMMO )
  7414. strcat(equipstr, msg_txt(sd,526));
  7415. if( it->equip&EQP_SHADOW_ARMOR )
  7416. strcat(equipstr, msg_txt(sd,527));
  7417. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7418. strcat(equipstr, msg_txt(sd,528));
  7419. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7420. strcat(equipstr, msg_txt(sd,529));
  7421. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7422. strcat(equipstr, msg_txt(sd,530));
  7423. if( it->equip&EQP_SHADOW_SHOES )
  7424. strcat(equipstr, msg_txt(sd,531));
  7425. if( it->equip&EQP_SHADOW_ACC_R )
  7426. strcat(equipstr, msg_txt(sd,532));
  7427. if( it->equip&EQP_SHADOW_ACC_L )
  7428. strcat(equipstr, msg_txt(sd,533));
  7429. // remove final ', '
  7430. equipstr[strlen(equipstr) - 2] = '\0';
  7431. StringBuf_AppendStr(&buf, equipstr);
  7432. }
  7433. clif_displaymessage(fd, StringBuf_Value(&buf));
  7434. StringBuf_Clear(&buf);
  7435. if( it->card[0] == CARD0_PET ) { // pet egg
  7436. if (it->card[3])
  7437. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7438. else
  7439. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7440. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7441. 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)
  7442. } else if(it->card[0] == CARD0_CREATE) { // created item
  7443. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7444. } else { // normal item
  7445. int counter2 = 0;
  7446. for( j = 0; j < itd->slot; ++j ) {
  7447. struct item_data* card;
  7448. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7449. continue;
  7450. counter2++;
  7451. if( counter2 == 1 )
  7452. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7453. if( counter2 != 1 )
  7454. StringBuf_AppendStr(&buf, ", ");
  7455. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7456. }
  7457. if( counter2 > 0 )
  7458. StringBuf_AppendStr(&buf, ")");
  7459. }
  7460. if( StringBuf_Length(&buf) > 0 )
  7461. clif_displaymessage(fd, StringBuf_Value(&buf));
  7462. StringBuf_Clear(&buf);
  7463. }
  7464. if( count == 0 )
  7465. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7466. else
  7467. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7468. clif_displaymessage(fd, StringBuf_Value(&buf));
  7469. StringBuf_Destroy(&buf);
  7470. return 0;
  7471. }
  7472. ACMD_FUNC(stats)
  7473. {
  7474. char job_jobname[100];
  7475. char output[CHAT_SIZE_MAX];
  7476. int i;
  7477. struct {
  7478. const char* format;
  7479. int value;
  7480. } output_table[] = {
  7481. { "Base Level - %d", 0 },
  7482. { NULL, 0 },
  7483. { "Hp - %d", 0 },
  7484. { "MaxHp - %d", 0 },
  7485. { "Sp - %d", 0 },
  7486. { "MaxSp - %d", 0 },
  7487. { "Str - %3d", 0 },
  7488. { "Agi - %3d", 0 },
  7489. { "Vit - %3d", 0 },
  7490. { "Int - %3d", 0 },
  7491. { "Dex - %3d", 0 },
  7492. { "Luk - %3d", 0 },
  7493. { "Zeny - %d", 0 },
  7494. { "Free SK Points - %d", 0 },
  7495. { "JobChangeLvl (2nd) - %d", 0 },
  7496. { "JobChangeLvl (3rd) - %d", 0 },
  7497. { NULL, 0 }
  7498. };
  7499. memset(job_jobname, '\0', sizeof(job_jobname));
  7500. memset(output, '\0', sizeof(output));
  7501. //direct array initialization with variables is not standard C compliant.
  7502. output_table[0].value = sd->status.base_level;
  7503. output_table[1].format = job_jobname;
  7504. output_table[1].value = sd->status.job_level;
  7505. output_table[2].value = sd->status.hp;
  7506. output_table[3].value = sd->status.max_hp;
  7507. output_table[4].value = sd->status.sp;
  7508. output_table[5].value = sd->status.max_sp;
  7509. output_table[6].value = sd->status.str;
  7510. output_table[7].value = sd->status.agi;
  7511. output_table[8].value = sd->status.vit;
  7512. output_table[9].value = sd->status.int_;
  7513. output_table[10].value = sd->status.dex;
  7514. output_table[11].value = sd->status.luk;
  7515. output_table[12].value = sd->status.zeny;
  7516. output_table[13].value = sd->status.skill_point;
  7517. output_table[14].value = sd->change_level_2nd;
  7518. output_table[15].value = sd->change_level_3rd;
  7519. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7520. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7521. clif_displaymessage(fd, output);
  7522. for (i = 0; output_table[i].format != NULL; i++) {
  7523. sprintf(output, output_table[i].format, output_table[i].value);
  7524. clif_displaymessage(fd, output);
  7525. }
  7526. return 0;
  7527. }
  7528. ACMD_FUNC(delitem)
  7529. {
  7530. char item_name[100];
  7531. unsigned short nameid;
  7532. int amount = 0, total, idx;
  7533. struct item_data* id;
  7534. nullpo_retr(-1, sd);
  7535. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7536. {
  7537. 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>).
  7538. return -1;
  7539. }
  7540. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7541. {
  7542. nameid = id->nameid;
  7543. }
  7544. else
  7545. {
  7546. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7547. return -1;
  7548. }
  7549. total = amount;
  7550. // delete items
  7551. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7552. {
  7553. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7554. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7555. {// delete pet
  7556. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7557. }
  7558. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7559. amount-= delamount;
  7560. }
  7561. // notify target
  7562. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7563. clif_displaymessage(sd->fd, atcmd_output);
  7564. // notify source
  7565. if( amount == total )
  7566. {
  7567. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7568. }
  7569. else if( amount )
  7570. {
  7571. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7572. clif_displaymessage(fd, atcmd_output);
  7573. }
  7574. else
  7575. {
  7576. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7577. clif_displaymessage(fd, atcmd_output);
  7578. }
  7579. return 0;
  7580. }
  7581. /*==========================================
  7582. * Custom Fonts
  7583. *------------------------------------------*/
  7584. ACMD_FUNC(font)
  7585. {
  7586. int font_id;
  7587. nullpo_retr(-1,sd);
  7588. font_id = atoi(message);
  7589. if( font_id == 0 ) {
  7590. if( sd->status.font ) {
  7591. sd->status.font = 0;
  7592. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7593. clif_font(sd);
  7594. } else {
  7595. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7596. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7597. }
  7598. } else if( font_id < 0 || font_id > 9 )
  7599. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7600. else if( font_id != sd->status.font ) {
  7601. sd->status.font = font_id;
  7602. clif_font(sd);
  7603. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7604. } else
  7605. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7606. return 0;
  7607. }
  7608. /*==========================================
  7609. * type: 1 = commands (@), 2 = charcommands (#)
  7610. *------------------------------------------*/
  7611. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7612. {
  7613. char line_buff[CHATBOX_SIZE];
  7614. char* cur = line_buff;
  7615. AtCommandInfo* cmd;
  7616. DBIterator *iter = db_iterator(atcommand_db);
  7617. int count = 0;
  7618. memset(line_buff,' ',CHATBOX_SIZE);
  7619. line_buff[CHATBOX_SIZE-1] = 0;
  7620. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7621. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7622. unsigned int slen = 0;
  7623. switch( type ) {
  7624. case COMMAND_CHARCOMMAND:
  7625. if( cmd->char_groups[sd->group_pos] == 0 )
  7626. continue;
  7627. break;
  7628. case COMMAND_ATCOMMAND:
  7629. if( cmd->at_groups[sd->group_pos] == 0 )
  7630. continue;
  7631. break;
  7632. default:
  7633. continue;
  7634. }
  7635. slen = strlen(cmd->command);
  7636. // flush the text buffer if this command won't fit into it
  7637. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7638. clif_displaymessage(fd,line_buff);
  7639. cur = line_buff;
  7640. memset(line_buff,' ',CHATBOX_SIZE);
  7641. line_buff[CHATBOX_SIZE-1] = 0;
  7642. }
  7643. memcpy(cur,cmd->command,slen);
  7644. cur += slen+(10-slen%10);
  7645. count++;
  7646. }
  7647. dbi_destroy(iter);
  7648. clif_displaymessage(fd,line_buff);
  7649. if ( atcmd_binding_count ) {
  7650. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7651. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7652. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7653. unsigned int slen = strlen(atcmd_binding[i]->command);
  7654. if ( count_bind == 0 ) {
  7655. cur = line_buff;
  7656. memset(line_buff,' ',CHATBOX_SIZE);
  7657. line_buff[CHATBOX_SIZE-1] = 0;
  7658. clif_displaymessage(fd, "-----------------");
  7659. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7660. }
  7661. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7662. clif_displaymessage(fd,line_buff);
  7663. cur = line_buff;
  7664. memset(line_buff,' ',CHATBOX_SIZE);
  7665. line_buff[CHATBOX_SIZE-1] = 0;
  7666. }
  7667. memcpy(cur,atcmd_binding[i]->command,slen);
  7668. cur += slen+(10-slen%10);
  7669. count_bind++;
  7670. }
  7671. }
  7672. if ( count_bind )
  7673. clif_displaymessage(fd,line_buff);// last one
  7674. count += count_bind;
  7675. }
  7676. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7677. clif_displaymessage(fd, atcmd_output);
  7678. return;
  7679. }
  7680. /*==========================================
  7681. * @commands Lists available @ commands to you
  7682. *------------------------------------------*/
  7683. ACMD_FUNC(commands)
  7684. {
  7685. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7686. return 0;
  7687. }
  7688. /*==========================================
  7689. * @charcommands Lists available # commands to you
  7690. *------------------------------------------*/
  7691. ACMD_FUNC(charcommands) {
  7692. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7693. return 0;
  7694. }
  7695. /* for new mounts */
  7696. ACMD_FUNC(mount2) {
  7697. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7698. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7699. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7700. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7701. } else {
  7702. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7703. if (&sd->sc)
  7704. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7705. }
  7706. return 0;
  7707. }
  7708. ACMD_FUNC(accinfo) {
  7709. char query[NAME_LENGTH];
  7710. char type = 0; // type = 1, get only account name
  7711. if (!message || !*message || strlen(message) > NAME_LENGTH
  7712. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7713. {
  7714. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7715. 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".
  7716. return -1;
  7717. } else if (type != 0) {
  7718. type = type-'0'; //make it int
  7719. if (type != 1) {
  7720. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7721. return -1;
  7722. }
  7723. }
  7724. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7725. return 0;
  7726. }
  7727. /**
  7728. * @set <variable name{[index]}>{ <value>}
  7729. *
  7730. * Gets or sets a value of a non server variable.
  7731. * If a value is specified it is used to set the variable's value,
  7732. * if not the variable's value is read.
  7733. * In any case it reads and displays the variable's value.
  7734. *
  7735. * Original implementation by Ind
  7736. */
  7737. ACMD_FUNC(set) {
  7738. char reg[46], val[128], name[32];
  7739. int toset = 0, len, index;
  7740. bool is_str = false;
  7741. int64 uid;
  7742. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7743. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7744. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7745. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7746. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7747. return -1;
  7748. }
  7749. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7750. if( reg[0] == '.' ) {
  7751. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7752. return -1;
  7753. } else if( reg[0] == '\'' ) {
  7754. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7755. return -1;
  7756. }
  7757. // Check if the user wanted to set an array
  7758. if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){
  7759. // The user did not specify array brackets, so we set the index to zero
  7760. index = 0;
  7761. }
  7762. is_str = is_string_variable(name);
  7763. if( ( len = strlen(val) ) > 1 ) {
  7764. if( val[0] == '"' && val[len-1] == '"') {
  7765. val[len-1] = '\0'; //Strip quotes.
  7766. memmove(val, val+1, len-1);
  7767. }
  7768. }
  7769. // Only set the variable if there is a value for it
  7770. if( toset >= 2 ){
  7771. setd_sub( NULL, sd, name, index, is_str ? (void*)val : (void*)__64BPRTSIZE((atoi(val))), NULL );
  7772. }
  7773. uid = reference_uid( add_str( name ), index );
  7774. if( is_str ) {// string variable
  7775. char* value;
  7776. switch( reg[0] ) {
  7777. case '@':
  7778. value = pc_readregstr(sd, uid);
  7779. break;
  7780. case '$':
  7781. value = mapreg_readregstr(uid);
  7782. break;
  7783. case '#':
  7784. if( reg[1] == '#' )
  7785. value = pc_readaccountreg2str(sd, uid);// global
  7786. else
  7787. value = pc_readaccountregstr(sd, uid);// local
  7788. break;
  7789. default:
  7790. value = pc_readglobalreg_str(sd, uid);
  7791. break;
  7792. }
  7793. if( value == NULL || value == '\0' ){// empty string
  7794. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7795. }else{
  7796. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
  7797. }
  7798. } else {// integer variable
  7799. int value;
  7800. switch( reg[0] ) {
  7801. case '@':
  7802. value = pc_readreg(sd, uid);
  7803. break;
  7804. case '$':
  7805. value = mapreg_readreg(uid);
  7806. break;
  7807. case '#':
  7808. if( reg[1] == '#' )
  7809. value = pc_readaccountreg2(sd, uid);// global
  7810. else
  7811. value = pc_readaccountreg(sd, uid);// local
  7812. break;
  7813. default:
  7814. value = pc_readglobalreg(sd, uid);
  7815. break;
  7816. }
  7817. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d
  7818. }
  7819. clif_displaymessage(fd, atcmd_output);
  7820. return 0;
  7821. }
  7822. ACMD_FUNC(addperm) {
  7823. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7824. bool add;
  7825. int i;
  7826. parent_cmd = atcommand_checkalias(command+1);
  7827. add = (strcmpi(parent_cmd, "addperm") == 0);
  7828. if( !message || !*message ) {
  7829. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7830. clif_displaymessage(fd, atcmd_output);
  7831. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7832. for( i = 0; i < perm_size; i++ ) {
  7833. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7834. clif_displaymessage(fd, atcmd_output);
  7835. }
  7836. return -1;
  7837. }
  7838. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7839. if( i == perm_size ) {
  7840. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7841. clif_displaymessage(fd, atcmd_output);
  7842. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7843. for( i = 0; i < perm_size; i++ ) {
  7844. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7845. clif_displaymessage(fd, atcmd_output);
  7846. }
  7847. return -1;
  7848. }
  7849. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7850. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7851. clif_displaymessage(fd, atcmd_output);
  7852. return -1;
  7853. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7854. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7855. clif_displaymessage(fd, atcmd_output);
  7856. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7857. clif_displaymessage(fd, atcmd_output);
  7858. for( i = 0; i < perm_size; i++ ) {
  7859. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7860. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7861. clif_displaymessage(fd, atcmd_output);
  7862. }
  7863. }
  7864. return -1;
  7865. }
  7866. if( add )
  7867. sd->permissions |= pc_g_permission_name[i].permission;
  7868. else
  7869. sd->permissions &=~ pc_g_permission_name[i].permission;
  7870. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7871. clif_displaymessage(fd, atcmd_output);
  7872. return 0;
  7873. }
  7874. ACMD_FUNC(unloadnpcfile) {
  7875. if( !message || !*message ) {
  7876. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7877. return -1;
  7878. }
  7879. if( npc_unloadfile(message) )
  7880. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7881. else {
  7882. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7883. return -1;
  7884. }
  7885. return 0;
  7886. }
  7887. ACMD_FUNC(cart) {
  7888. #define MC_CART_MDFY(idx, x) \
  7889. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  7890. sd->status.skill[(idx)].lv = (x)?1:0; \
  7891. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7892. int val = atoi(message);
  7893. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  7894. uint16 sk_idx = 0;
  7895. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7896. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7897. clif_displaymessage(fd, atcmd_output);
  7898. return -1;
  7899. }
  7900. if( val == 0 && !pc_iscarton(sd) ) {
  7901. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7902. return -1;
  7903. }
  7904. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  7905. return -1;
  7906. if( need_skill ) {
  7907. MC_CART_MDFY(sk_idx,1);
  7908. }
  7909. if( !pc_setcart(sd, val) ) {
  7910. if( need_skill ) {
  7911. MC_CART_MDFY(sk_idx,0);
  7912. }
  7913. return -1;/* @cart failed */
  7914. }
  7915. if( need_skill ) {
  7916. MC_CART_MDFY(sk_idx,0);
  7917. }
  7918. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7919. return 0;
  7920. #undef MC_CART_MDFY
  7921. }
  7922. /* Channel System [Ind] */
  7923. ACMD_FUNC(join){
  7924. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7925. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  7926. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7927. clif_displaymessage(fd, atcmd_output);
  7928. return -1;
  7929. }
  7930. return channel_pcjoin(sd, chname, pass);
  7931. }
  7932. /*
  7933. * Display available option for @channel command
  7934. * @command : the name of used command (for alias case)
  7935. */
  7936. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7937. {
  7938. int fd = sd->fd;
  7939. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7940. bool can_create = (can_delete || channel_config.user_chenable);
  7941. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7942. //option create
  7943. if( can_create ) {
  7944. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7945. clif_displaymessage(fd, atcmd_output);
  7946. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7947. }
  7948. //option delete
  7949. if(can_delete){
  7950. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7951. clif_displaymessage(fd, atcmd_output);
  7952. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7953. }
  7954. //option list
  7955. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7956. clif_displaymessage(fd, atcmd_output);
  7957. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7958. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7959. clif_displaymessage(fd, atcmd_output);
  7960. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7961. if( can_create ) {
  7962. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7963. clif_displaymessage(fd, atcmd_output);
  7964. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7965. }
  7966. //option setcolor
  7967. if(can_create){
  7968. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7969. clif_displaymessage(fd, atcmd_output);
  7970. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7971. }
  7972. //option join
  7973. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7974. clif_displaymessage(fd, atcmd_output);
  7975. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7976. //option leave
  7977. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7978. clif_displaymessage(fd, atcmd_output);
  7979. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7980. //option bindto
  7981. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7982. clif_displaymessage(fd, atcmd_output);
  7983. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7984. //option unbind
  7985. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7986. clif_displaymessage(fd, atcmd_output);
  7987. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7988. //option ban/unban/banlist
  7989. if( can_create ) {
  7990. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7991. clif_displaymessage(fd, atcmd_output);
  7992. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7993. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7994. clif_displaymessage(fd, atcmd_output);
  7995. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7996. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7997. clif_displaymessage(fd, atcmd_output);
  7998. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7999. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8000. clif_displaymessage(fd, atcmd_output);
  8001. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8002. }
  8003. //option setopt
  8004. if(can_create){
  8005. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8006. clif_displaymessage(fd, atcmd_output);
  8007. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8008. }
  8009. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8010. clif_displaymessage(fd, atcmd_output);
  8011. }
  8012. ACMD_FUNC(channel) {
  8013. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8014. sub1[0] = sub2[0] = '\0';
  8015. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8016. atcmd_channel_help(sd,command);
  8017. return 0;
  8018. }
  8019. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8020. return channel_pcdelete(sd,sub1);
  8021. } else if ( strcmpi(key,"list") == 0 ) {
  8022. return channel_display_list(sd,sub1);
  8023. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8024. return channel_pccolor(sd, sub1, sub2);
  8025. } else if ( strcmpi(key,"join") == 0 ) {
  8026. return channel_pcjoin(sd, sub1, sub2);
  8027. }else if ( strcmpi(key,"leave") == 0 ) {
  8028. return channel_pcleave(sd, sub1);
  8029. } else if ( strcmpi(key,"bindto") == 0 ) {
  8030. return channel_pcbind(sd, sub1);
  8031. } else if ( strcmpi(key,"unbind") == 0 ) {
  8032. return channel_pcunbind(sd);
  8033. } else if ( strcmpi(key,"ban") == 0 ) {
  8034. return channel_pcban(sd,sub1,sub2,0);
  8035. } else if ( strcmpi(key,"banlist") == 0 ) {
  8036. return channel_pcban(sd,sub1,NULL,3);
  8037. } else if ( strcmpi(key,"unban") == 0 ) {
  8038. return channel_pcban(sd,sub1,sub2,1);
  8039. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8040. return channel_pcban(sd,sub1,NULL,2);
  8041. } else {
  8042. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8043. sub3[0] = sub4[0] = '\0';
  8044. sscanf(sub2, "%19s %19s", sub3, sub4);
  8045. if( strcmpi(key,"create") == 0 && ( channel_config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8046. if (sub4[0] != '\0') {
  8047. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8048. return -1;
  8049. }
  8050. return channel_pccreate(sd,sub1,sub3);
  8051. } else if ( strcmpi(key,"setopt") == 0 ) {
  8052. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8053. }
  8054. atcmd_channel_help(sd,command);
  8055. }
  8056. return 0;
  8057. }
  8058. ACMD_FUNC(fontcolor)
  8059. {
  8060. if( !message || !*message ) {
  8061. channel_display_list(sd,"colors");
  8062. return -1;
  8063. }
  8064. if( strcmpi(message,"Normal") == 0 ) {
  8065. sd->fontcolor = 0;
  8066. } else {
  8067. unsigned char k;
  8068. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8069. if( k == channel_config.colors_count ) {
  8070. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8071. clif_displaymessage(fd, atcmd_output);
  8072. return -1;
  8073. }
  8074. sd->fontcolor = k;
  8075. }
  8076. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8077. clif_displaymessage(fd, atcmd_output);
  8078. return 0;
  8079. }
  8080. ACMD_FUNC(langtype)
  8081. {
  8082. char langstr[8];
  8083. int i=0, fail=0;
  8084. memset(langstr, '\0', sizeof(langstr));
  8085. if(sscanf(message, "%3s", langstr) >= 1){
  8086. int lang=0;
  8087. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8088. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8089. char output[100];
  8090. pc_setaccountreg(sd, add_str("#langtype"), lang); //For login/char
  8091. sd->langtype = lang;
  8092. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8093. clif_displaymessage(fd,output);
  8094. return 0;
  8095. } else if (lang != -1) { //defined langage but failed check
  8096. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8097. return -1;
  8098. }
  8099. }
  8100. //wrong or no entry
  8101. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8102. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8103. while(fail != -1){ //out of range
  8104. fail = msg_checklangtype(i,false);
  8105. if(fail == 1)
  8106. clif_displaymessage(fd,msg_langtype2langstr(i));
  8107. i++;
  8108. }
  8109. return -1;
  8110. }
  8111. #ifdef VIP_ENABLE
  8112. ACMD_FUNC(vip) {
  8113. struct map_session_data *pl_sd = NULL;
  8114. char * modif_p;
  8115. int32 vipdifftime = 0;
  8116. time_t now=time(NULL);
  8117. nullpo_retr(-1, sd);
  8118. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8119. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8120. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8121. return -1;
  8122. }
  8123. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8124. modif_p = atcmd_output;
  8125. vipdifftime = (int32)solve_time(modif_p);
  8126. if (vipdifftime == 0) {
  8127. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8128. 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.
  8129. return -1;
  8130. }
  8131. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  8132. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8133. return -1;
  8134. }
  8135. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8136. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8137. return -1;
  8138. }
  8139. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8140. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8141. if (pl_sd->vip.time <= now) {
  8142. pl_sd->vip.time = 0;
  8143. pl_sd->vip.enabled = 0;
  8144. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8145. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8146. } else {
  8147. int year,month,day,hour,minute,second;
  8148. char timestr[21];
  8149. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8150. 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.
  8151. clif_displaymessage(pl_sd->fd,atcmd_output);
  8152. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8153. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8154. clif_displaymessage(pl_sd->fd,atcmd_output);
  8155. if (pl_sd != sd) {
  8156. 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.
  8157. clif_displaymessage(fd,atcmd_output);
  8158. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8159. clif_displaymessage(fd,atcmd_output);
  8160. }
  8161. }
  8162. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8163. return 0;
  8164. }
  8165. /** Enable/disable rate info */
  8166. ACMD_FUNC(showrate) {
  8167. nullpo_retr(-1,sd);
  8168. if (!sd->disableshowrate) {
  8169. sprintf(atcmd_output,msg_txt(sd,718)); //Personal rate information is not displayed now.
  8170. sd->disableshowrate = 1;
  8171. }
  8172. else {
  8173. sprintf(atcmd_output,msg_txt(sd,719)); //Personal rate information will be shown.
  8174. sd->disableshowrate = 0;
  8175. }
  8176. clif_displaymessage(fd,atcmd_output);
  8177. return 0;
  8178. }
  8179. #endif
  8180. ACMD_FUNC(fullstrip) {
  8181. int i;
  8182. TBL_PC *tsd;
  8183. nullpo_retr(-1,sd);
  8184. if (!message || !*message) {
  8185. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8186. return -1;
  8187. }
  8188. if((tsd=map_nick2sd((char *)message)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){
  8189. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8190. return -1;
  8191. }
  8192. for( i = 0; i < EQI_MAX; i++ ) {
  8193. if( tsd->equip_index[ i ] >= 0 )
  8194. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8195. }
  8196. return 0;
  8197. }
  8198. ACMD_FUNC(costume) {
  8199. const char* names[] = {
  8200. "Wedding",
  8201. "Xmas",
  8202. "Summer",
  8203. "Hanbok",
  8204. "Oktoberfest",
  8205. };
  8206. const int name2id[] = {
  8207. SC_WEDDING,
  8208. SC_XMAS,
  8209. SC_SUMMER,
  8210. SC_HANBOK,
  8211. SC_OKTOBERFEST
  8212. };
  8213. unsigned short k = 0, len = ARRAYLENGTH(names);
  8214. if( !message || !*message ) {
  8215. for( k = 0; k < len; k++ ) {
  8216. if( sd->sc.data[name2id[k]] ) {
  8217. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8218. clif_displaymessage(sd->fd, atcmd_output);
  8219. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8220. return 0;
  8221. }
  8222. }
  8223. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8224. for( k = 0; k < len; k++ ) {
  8225. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8226. clif_displaymessage(sd->fd, atcmd_output);
  8227. }
  8228. return -1;
  8229. }
  8230. for( k = 0; k < len; k++ ) {
  8231. if( sd->sc.data[name2id[k]] ) {
  8232. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8233. clif_displaymessage(sd->fd, atcmd_output);
  8234. return -1;
  8235. }
  8236. }
  8237. for( k = 0; k < len; k++ )
  8238. if( strcmpi(message, names[k]) == 0 )
  8239. break;
  8240. if( k == len ) {
  8241. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8242. clif_displaymessage(sd->fd, atcmd_output);
  8243. return -1;
  8244. }
  8245. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, 0, -1);
  8246. return 0;
  8247. }
  8248. /**
  8249. * Clone other player's equipments
  8250. * Usage: @cloneequip <char_id or "char name">
  8251. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8252. * @author [Cydh], [Antares]
  8253. */
  8254. ACMD_FUNC(cloneequip) {
  8255. struct map_session_data *pl_sd;
  8256. uint32 char_id = 0;
  8257. nullpo_retr(-1, sd);
  8258. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8259. if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8260. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8261. return -1;
  8262. }
  8263. if (char_id)
  8264. pl_sd = map_charid2sd(char_id);
  8265. else
  8266. pl_sd = map_nick2sd(atcmd_output);
  8267. if (!pl_sd) {
  8268. clif_displaymessage(fd, msg_txt(sd, 3));
  8269. return -1;
  8270. }
  8271. if (sd == pl_sd) {
  8272. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8273. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8274. clif_displaymessage(fd, atcmd_output);
  8275. return -1;
  8276. }
  8277. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8278. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8279. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8280. clif_displaymessage(fd, atcmd_output);
  8281. return -1;
  8282. }
  8283. else {
  8284. int8 i;
  8285. for (i = 0; i < EQI_MAX; i++) {
  8286. short idx;
  8287. char flag = 0;
  8288. struct item tmp_item;
  8289. if ((idx = pl_sd->equip_index[i]) < 0)
  8290. continue;
  8291. if (i == EQI_AMMO)
  8292. continue;
  8293. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8294. continue;
  8295. tmp_item = pl_sd->status.inventory[idx];
  8296. if (itemdb_isspecial(tmp_item.card[0]))
  8297. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8298. tmp_item.bound = 0;
  8299. tmp_item.expire_time = 0;
  8300. tmp_item.unique_id = 0;
  8301. tmp_item.favorite = 0;
  8302. tmp_item.amount = 1;
  8303. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8304. clif_additem(sd, 0, 0, flag);
  8305. else
  8306. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8307. }
  8308. }
  8309. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8310. sprintf(atcmd_output, msg_txt(sd, 738), "equip");
  8311. clif_displaymessage(fd, atcmd_output);
  8312. return 0;
  8313. }
  8314. /**
  8315. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8316. * Usage: @clonestat <char_id or "char name">
  8317. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8318. * @author [Cydh], [Antares]
  8319. */
  8320. ACMD_FUNC(clonestat) {
  8321. struct map_session_data *pl_sd;
  8322. uint32 char_id = 0;
  8323. nullpo_retr(-1, sd);
  8324. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8325. if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8326. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8327. return -1;
  8328. }
  8329. if (char_id)
  8330. pl_sd = map_charid2sd(char_id);
  8331. else
  8332. pl_sd = map_nick2sd(atcmd_output);
  8333. if (!pl_sd) {
  8334. clif_displaymessage(fd, msg_txt(sd, 3));
  8335. return -1;
  8336. }
  8337. if (sd == pl_sd) {
  8338. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8339. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8340. clif_displaymessage(fd, atcmd_output);
  8341. return -1;
  8342. }
  8343. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8344. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8345. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8346. clif_displaymessage(fd, atcmd_output);
  8347. return -1;
  8348. }
  8349. else {
  8350. uint8 i;
  8351. short max_status[6];
  8352. pc_resetstate(sd);
  8353. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8354. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8355. else {
  8356. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8357. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8358. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8359. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8360. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8361. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8362. }
  8363. #define clonestat_check(cmd,stat)\
  8364. {\
  8365. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8366. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8367. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8368. clif_displaymessage(fd, atcmd_output);\
  8369. sd->status.cmd = max_status[(stat)];\
  8370. }\
  8371. else\
  8372. sd->status.cmd = pl_sd->status.cmd;\
  8373. }
  8374. clonestat_check(str, PARAM_STR);
  8375. clonestat_check(agi, PARAM_AGI);
  8376. clonestat_check(vit, PARAM_VIT);
  8377. clonestat_check(int_, PARAM_INT);
  8378. clonestat_check(dex, PARAM_DEX);
  8379. clonestat_check(luk, PARAM_LUK);
  8380. for (i = 0; i < PARAM_MAX; i++) {
  8381. clif_updatestatus(sd, SP_STR + i);
  8382. clif_updatestatus(sd, SP_USTR + i);
  8383. }
  8384. status_calc_pc(sd, SCO_FORCE);
  8385. }
  8386. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8387. sprintf(atcmd_output, msg_txt(sd, 738), "status");
  8388. clif_displaymessage(fd, atcmd_output);
  8389. #undef clonestat_check
  8390. return 0;
  8391. }
  8392. /**
  8393. * Adopt a character.
  8394. * Usage: @adopt <char name>
  8395. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8396. */
  8397. ACMD_FUNC(adopt)
  8398. {
  8399. TBL_PC *b_sd;
  8400. enum adopt_responses response;
  8401. nullpo_retr(-1, sd);
  8402. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8403. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8404. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8405. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8406. clif_displaymessage(fd, atcmd_output);
  8407. return -1;
  8408. }
  8409. if ((b_sd = map_nick2sd((char *)atcmd_player_name)) == NULL) {
  8410. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8411. return -1;
  8412. }
  8413. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8414. if (response == ADOPT_ALLOWED) {
  8415. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8416. b_sd->adopt_invite = sd->status.account_id;
  8417. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8418. return 0;
  8419. }
  8420. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8421. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8422. return -1;
  8423. }
  8424. #include "../custom/atcommand.inc"
  8425. /**
  8426. * Fills the reference of available commands in atcommand DBMap
  8427. **/
  8428. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8429. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8430. // Define with restriction
  8431. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8432. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8433. void atcommand_basecommands(void) {
  8434. /**
  8435. * Command reference list, place the base of your commands here
  8436. * TODO: List all commands that causing crash
  8437. **/
  8438. AtCommandInfo atcommand_base[] = {
  8439. #include "../custom/atcommand_def.inc"
  8440. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8441. ACMD_DEF(where),
  8442. ACMD_DEF(jumpto),
  8443. ACMD_DEF(jump),
  8444. ACMD_DEF(who),
  8445. ACMD_DEF2("who2", who),
  8446. ACMD_DEF2("who3", who),
  8447. ACMD_DEF2("whomap", who),
  8448. ACMD_DEF2("whomap2", who),
  8449. ACMD_DEF2("whomap3", who),
  8450. ACMD_DEF(whogm),
  8451. ACMD_DEF(save),
  8452. ACMD_DEF(load),
  8453. ACMD_DEF(speed),
  8454. ACMD_DEF(storage),
  8455. ACMD_DEF(guildstorage),
  8456. ACMD_DEF(option),
  8457. ACMD_DEF(hide), // + /hide
  8458. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8459. ACMD_DEF(kill),
  8460. ACMD_DEF(alive),
  8461. ACMD_DEF(kami),
  8462. ACMD_DEF2("kamib", kami),
  8463. ACMD_DEF2("kamic", kami),
  8464. ACMD_DEF2("lkami", kami),
  8465. ACMD_DEF(heal),
  8466. ACMD_DEF(item),
  8467. ACMD_DEF(item2),
  8468. ACMD_DEF2("itembound",item),
  8469. ACMD_DEF2("itembound2",item2),
  8470. ACMD_DEF(itemreset),
  8471. ACMD_DEF(clearstorage),
  8472. ACMD_DEF(cleargstorage),
  8473. ACMD_DEF(clearcart),
  8474. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8475. ACMD_DEF2("jlvl", joblevelup),
  8476. ACMD_DEF(help),
  8477. ACMD_DEF(pvpoff),
  8478. ACMD_DEF(pvpon),
  8479. ACMD_DEF(gvgoff),
  8480. ACMD_DEF(gvgon),
  8481. ACMD_DEF(model),
  8482. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8483. ACMD_DEF(monster),
  8484. ACMD_DEF2("monstersmall", monster),
  8485. ACMD_DEF2("monsterbig", monster),
  8486. ACMD_DEF(killmonster),
  8487. ACMD_DEF2("killmonster2", killmonster),
  8488. ACMD_DEF(refine),
  8489. ACMD_DEF(produce),
  8490. ACMD_DEF(memo),
  8491. ACMD_DEF(gat),
  8492. ACMD_DEF(displaystatus),
  8493. ACMD_DEF2("stpoint", statuspoint),
  8494. ACMD_DEF2("skpoint", skillpoint),
  8495. ACMD_DEF(zeny),
  8496. ACMD_DEF2("str", param),
  8497. ACMD_DEF2("agi", param),
  8498. ACMD_DEF2("vit", param),
  8499. ACMD_DEF2("int", param),
  8500. ACMD_DEF2("dex", param),
  8501. ACMD_DEF2("luk", param),
  8502. ACMD_DEF2("glvl", guildlevelup),
  8503. ACMD_DEF(makeegg),
  8504. ACMD_DEF(hatch),
  8505. ACMD_DEF(petfriendly),
  8506. ACMD_DEF(pethungry),
  8507. ACMD_DEF(petrename),
  8508. ACMD_DEF(recall), // + /recall
  8509. ACMD_DEF(night),
  8510. ACMD_DEF(day),
  8511. ACMD_DEF(doom),
  8512. ACMD_DEF(doommap),
  8513. ACMD_DEF(raise),
  8514. ACMD_DEF(raisemap),
  8515. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8516. ACMD_DEF(kickall),
  8517. ACMD_DEF(allskill),
  8518. ACMD_DEF(questskill),
  8519. ACMD_DEF(lostskill),
  8520. ACMD_DEF(spiritball),
  8521. ACMD_DEF(party),
  8522. ACMD_DEF(guild),
  8523. ACMD_DEF(breakguild),
  8524. ACMD_DEF(agitstart),
  8525. ACMD_DEF(agitend),
  8526. ACMD_DEF(mapexit),
  8527. ACMD_DEF(idsearch),
  8528. ACMD_DEF(broadcast), // + /b and /nb
  8529. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8530. ACMD_DEF(recallall),
  8531. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8532. ACMD_DEF2("reloaditemdb", reload),
  8533. ACMD_DEF2("reloadmobdb", reload),
  8534. ACMD_DEF2("reloadskilldb", reload),
  8535. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8536. ACMD_DEF2("reloadatcommand", reload),
  8537. ACMD_DEF2("reloadbattleconf", reload),
  8538. ACMD_DEF2("reloadstatusdb", reload),
  8539. ACMD_DEF2("reloadpcdb", reload),
  8540. ACMD_DEF2("reloadmotd", reload),
  8541. ACMD_DEF2("reloadquestdb", reload),
  8542. ACMD_DEF2("reloadmsgconf", reload),
  8543. ACMD_DEF2("reloadpacketdb", reload),
  8544. ACMD_DEF2("reloadinstancedb", reload),
  8545. ACMD_DEF(partysharelvl),
  8546. ACMD_DEF(mapinfo),
  8547. ACMD_DEF(dye),
  8548. ACMD_DEF2("hairstyle", hair_style),
  8549. ACMD_DEF2("haircolor", hair_color),
  8550. ACMD_DEF2("allstats", stat_all),
  8551. ACMD_DEF2("block", char_block),
  8552. ACMD_DEF2("ban", char_ban),
  8553. ACMD_DEF2("unblock", char_unblock),
  8554. ACMD_DEF2("unban", char_unban),
  8555. ACMD_DEF2("charban", char_ban),
  8556. ACMD_DEF2("charunban", char_unban),
  8557. ACMD_DEF2("mount", mount_peco),
  8558. ACMD_DEF(guildspy),
  8559. ACMD_DEF(partyspy),
  8560. ACMD_DEF(repairall),
  8561. ACMD_DEF(guildrecall),
  8562. ACMD_DEF(partyrecall),
  8563. ACMD_DEF(nuke),
  8564. ACMD_DEF(shownpc),
  8565. ACMD_DEF(hidenpc),
  8566. ACMD_DEF(loadnpc),
  8567. ACMD_DEF(unloadnpc),
  8568. ACMD_DEF2("time", servertime),
  8569. ACMD_DEF(jail),
  8570. ACMD_DEF(unjail),
  8571. ACMD_DEF(jailfor),
  8572. ACMD_DEF(jailtime),
  8573. ACMD_DEF(disguise),
  8574. ACMD_DEF(undisguise),
  8575. ACMD_DEF(email),
  8576. ACMD_DEF(effect),
  8577. ACMD_DEF(follow),
  8578. ACMD_DEF(addwarp),
  8579. ACMD_DEF(skillon),
  8580. ACMD_DEF(skilloff),
  8581. ACMD_DEF(killer),
  8582. ACMD_DEF(npcmove),
  8583. ACMD_DEF(killable),
  8584. ACMD_DEF(dropall),
  8585. ACMD_DEF(storeall),
  8586. ACMD_DEF(skillid),
  8587. ACMD_DEF(useskill),
  8588. ACMD_DEF(displayskill),
  8589. ACMD_DEF(snow),
  8590. ACMD_DEF(sakura),
  8591. ACMD_DEF(clouds),
  8592. ACMD_DEF(clouds2),
  8593. ACMD_DEF(fog),
  8594. ACMD_DEF(fireworks),
  8595. ACMD_DEF(leaves),
  8596. ACMD_DEF(summon),
  8597. ACMD_DEF(adjgroup),
  8598. ACMD_DEF(trade),
  8599. ACMD_DEF(send),
  8600. ACMD_DEF(setbattleflag),
  8601. ACMD_DEF(unmute),
  8602. ACMD_DEF(clearweather),
  8603. ACMD_DEF(uptime),
  8604. ACMD_DEF(changesex),
  8605. ACMD_DEF(changecharsex),
  8606. ACMD_DEF(mute),
  8607. ACMD_DEF(refresh),
  8608. ACMD_DEF(refreshall),
  8609. ACMD_DEF(identify),
  8610. ACMD_DEF(identifyall),
  8611. ACMD_DEF(gmotd),
  8612. ACMD_DEF(misceffect),
  8613. ACMD_DEF(mobsearch),
  8614. ACMD_DEF(cleanmap),
  8615. ACMD_DEF(cleanarea),
  8616. ACMD_DEF(npctalk),
  8617. ACMD_DEF(pettalk),
  8618. ACMD_DEF(users),
  8619. ACMD_DEF(reset),
  8620. ACMD_DEF(skilltree),
  8621. ACMD_DEF(marry),
  8622. ACMD_DEF(divorce),
  8623. ACMD_DEF(sound),
  8624. ACMD_DEF(undisguiseall),
  8625. ACMD_DEF(disguiseall),
  8626. ACMD_DEF(changelook),
  8627. ACMD_DEF(autoloot),
  8628. ACMD_DEF2("alootid", autolootitem),
  8629. ACMD_DEF(autoloottype),
  8630. ACMD_DEF(mobinfo),
  8631. ACMD_DEF(exp),
  8632. ACMD_DEF(version),
  8633. ACMD_DEF(mutearea),
  8634. ACMD_DEF(rates),
  8635. ACMD_DEF(iteminfo),
  8636. ACMD_DEF(whodrops),
  8637. ACMD_DEF(whereis),
  8638. ACMD_DEF(mapflag),
  8639. ACMD_DEF(me),
  8640. ACMD_DEF(monsterignore),
  8641. ACMD_DEF(fakename),
  8642. ACMD_DEF(size),
  8643. ACMD_DEF(showexp),
  8644. ACMD_DEF(showzeny),
  8645. ACMD_DEF(showdelay),
  8646. ACMD_DEF(autotrade),
  8647. ACMD_DEF(changegm),
  8648. ACMD_DEF(changeleader),
  8649. ACMD_DEF(partyoption),
  8650. ACMD_DEF(invite),
  8651. ACMD_DEF(duel),
  8652. ACMD_DEF(leave),
  8653. ACMD_DEF(accept),
  8654. ACMD_DEF(reject),
  8655. ACMD_DEF(clone),
  8656. ACMD_DEF2("slaveclone", clone),
  8657. ACMD_DEF2("evilclone", clone),
  8658. ACMD_DEF(tonpc),
  8659. ACMD_DEF(commands),
  8660. ACMD_DEF(noask),
  8661. ACMD_DEF(request),
  8662. ACMD_DEF(homlevel),
  8663. ACMD_DEF(homevolution),
  8664. ACMD_DEF(hommutate),
  8665. ACMD_DEF(makehomun),
  8666. ACMD_DEF(homfriendly),
  8667. ACMD_DEF(homhungry),
  8668. ACMD_DEF(homtalk),
  8669. ACMD_DEF(hominfo),
  8670. ACMD_DEF(homstats),
  8671. ACMD_DEF(homshuffle),
  8672. ACMD_DEF(showmobs),
  8673. ACMD_DEF(feelreset),
  8674. ACMD_DEF(auction),
  8675. ACMD_DEF(mail),
  8676. ACMD_DEF2("noks", ksprotection),
  8677. ACMD_DEF(allowks),
  8678. ACMD_DEF(cash),
  8679. ACMD_DEF2("points", cash),
  8680. ACMD_DEF(agitstart2),
  8681. ACMD_DEF(agitend2),
  8682. ACMD_DEF(resetskill),
  8683. ACMD_DEF(resetstat),
  8684. ACMD_DEF2("storagelist", itemlist),
  8685. ACMD_DEF2("cartlist", itemlist),
  8686. ACMD_DEF2("itemlist", itemlist),
  8687. ACMD_DEF(stats),
  8688. ACMD_DEF(delitem),
  8689. ACMD_DEF(charcommands),
  8690. ACMD_DEF(font),
  8691. ACMD_DEF(accinfo),
  8692. ACMD_DEF(set),
  8693. ACMD_DEF(undisguiseguild),
  8694. ACMD_DEF(disguiseguild),
  8695. ACMD_DEF(sizeall),
  8696. ACMD_DEF(sizeguild),
  8697. ACMD_DEF(addperm),
  8698. ACMD_DEF2("rmvperm", addperm),
  8699. ACMD_DEF(unloadnpcfile),
  8700. ACMD_DEF(cart),
  8701. ACMD_DEF(mount2),
  8702. ACMD_DEF(join),
  8703. ACMD_DEF(channel),
  8704. ACMD_DEF(fontcolor),
  8705. ACMD_DEF(langtype),
  8706. #ifdef VIP_ENABLE
  8707. ACMD_DEF(vip),
  8708. ACMD_DEF(showrate),
  8709. #endif
  8710. ACMD_DEF(fullstrip),
  8711. ACMD_DEF(costume),
  8712. ACMD_DEF(cloneequip),
  8713. ACMD_DEF(clonestat),
  8714. ACMD_DEF(bodystyle),
  8715. ACMD_DEF(adopt),
  8716. };
  8717. AtCommandInfo* atcommand;
  8718. int i;
  8719. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8720. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8721. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8722. continue;
  8723. }
  8724. CREATE(atcommand, AtCommandInfo, 1);
  8725. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8726. atcommand->func = atcommand_base[i].func;
  8727. atcommand->restriction = atcommand_base[i].restriction;
  8728. strdb_put(atcommand_db, atcommand->command, atcommand);
  8729. }
  8730. return;
  8731. }
  8732. /*==========================================
  8733. * Command lookup functions
  8734. *------------------------------------------*/
  8735. bool atcommand_exists(const char* name)
  8736. {
  8737. return strdb_exists(atcommand_db, name);
  8738. }
  8739. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8740. {
  8741. if (strdb_exists(atcommand_db, name))
  8742. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8743. return NULL;
  8744. }
  8745. static const char* atcommand_checkalias(const char *aliasname)
  8746. {
  8747. AliasInfo *alias_info = NULL;
  8748. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8749. return alias_info->command->command;
  8750. return aliasname;
  8751. }
  8752. /// AtCommand suggestion
  8753. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8754. DBIterator* atcommand_iter;
  8755. DBIterator* alias_iter;
  8756. AtCommandInfo* command_info = NULL;
  8757. AliasInfo* alias_info = NULL;
  8758. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8759. char* full_match[MAX_SUGGESTIONS];
  8760. char* suggestions[MAX_SUGGESTIONS];
  8761. char* match;
  8762. int prefix_count = 0, full_count = 0;
  8763. bool can_use;
  8764. if (!battle_config.atcommand_suggestions_enabled)
  8765. return;
  8766. atcommand_iter = db_iterator(atcommand_db);
  8767. alias_iter = db_iterator(atcommand_alias_db);
  8768. // Build the matches
  8769. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8770. match = strstr(command_info->command, name);
  8771. can_use = pc_can_use_command(sd, command_info->command, type);
  8772. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8773. suggestions[prefix_count] = command_info->command;
  8774. ++prefix_count;
  8775. }
  8776. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8777. full_match[full_count] = command_info->command;
  8778. ++full_count;
  8779. }
  8780. }
  8781. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8782. match = strstr(alias_info->alias, name);
  8783. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8784. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8785. suggestions[prefix_count] = alias_info->alias;
  8786. ++prefix_count;
  8787. }
  8788. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8789. full_match[full_count] = alias_info->alias;
  8790. ++full_count;
  8791. }
  8792. }
  8793. if ((full_count+prefix_count) > 0) {
  8794. char buffer[512];
  8795. int i;
  8796. // Merge full match and prefix match results
  8797. if (prefix_count < MAX_SUGGESTIONS) {
  8798. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8799. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8800. }
  8801. // Build the suggestion string
  8802. strcpy(buffer, msg_txt(sd,205));
  8803. strcat(buffer,"\n");
  8804. for(i=0; i < prefix_count; ++i) {
  8805. strcat(buffer,suggestions[i]);
  8806. strcat(buffer," ");
  8807. }
  8808. clif_displaymessage(sd->fd, buffer);
  8809. }
  8810. dbi_destroy(atcommand_iter);
  8811. dbi_destroy(alias_iter);
  8812. }
  8813. /**
  8814. * Executes an at-command
  8815. * @param fd
  8816. * @param sd
  8817. * @param message
  8818. * @param type
  8819. * 0 : script call (atcommand)
  8820. * 1 : normal player @atcommand
  8821. * 2 : console (admin:@atcommand)
  8822. * 3 : script call (useatcmd)
  8823. */
  8824. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8825. {
  8826. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8827. char output[CHAT_SIZE_MAX];
  8828. //Reconstructed message
  8829. char atcmd_msg[CHAT_SIZE_MAX];
  8830. TBL_PC * ssd = NULL; //sd for target
  8831. AtCommandInfo * info;
  8832. bool is_atcommand = true; // false if it's a charcommand
  8833. nullpo_retr(false, sd);
  8834. //Shouldn't happen
  8835. if ( !message || !*message )
  8836. return false;
  8837. //If cannot use atcomamnd while talking with NPC [Kichi]
  8838. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8839. return false;
  8840. //Block NOCHAT but do not display it as a normal message
  8841. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8842. return true;
  8843. // skip 10/11-langtype's codepage indicator, if detected
  8844. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8845. message += 3;
  8846. //Should display as a normal message
  8847. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8848. return false;
  8849. // type value 0|2 = script|console invoked: bypass restrictions
  8850. if ( type == 1 || type == 3) {
  8851. //Commands are disabled on maps flagged as 'nocommand'
  8852. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8853. clif_displaymessage(fd, msg_txt(sd,143));
  8854. return false;
  8855. }
  8856. }
  8857. if (*message == charcommand_symbol)
  8858. is_atcommand = false;
  8859. if (is_atcommand) { // #command
  8860. sprintf(atcmd_msg, "%s", message);
  8861. ssd = sd;
  8862. } else { // @command
  8863. char charname[NAME_LENGTH];
  8864. int n;
  8865. //Checks to see if #command has a name or a name + parameters.
  8866. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  8867. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  8868. ) {
  8869. if (pc_get_group_level(sd) == 0) {
  8870. if (n < 1)
  8871. return false; // No command found. Display as normal message.
  8872. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8873. 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
  8874. return false;
  8875. }
  8876. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8877. clif_displaymessage(fd, output);
  8878. return true;
  8879. }
  8880. ssd = map_nick2sd(charname);
  8881. if (ssd == NULL) {
  8882. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8883. clif_displaymessage(fd, output);
  8884. return true;
  8885. }
  8886. if (n > 2)
  8887. sprintf(atcmd_msg, "%s %s", command, params);
  8888. else
  8889. sprintf(atcmd_msg, "%s", command);
  8890. }
  8891. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  8892. sd->idletime = last_tick;
  8893. //Clearing these to be used once more.
  8894. memset(command, '\0', sizeof(command));
  8895. memset(params, '\0', sizeof(params));
  8896. //check to see if any params exist within this command
  8897. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  8898. params[0] = '\0';
  8899. // @commands (script based)
  8900. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8901. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  8902. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8903. if( binding != NULL && binding->npc_event[0] &&
  8904. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  8905. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  8906. {
  8907. // Check if self or character invoking; if self == character invoked, then self invoke.
  8908. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  8909. return true;
  8910. }
  8911. }
  8912. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8913. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8914. if (info == NULL) {
  8915. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  8916. return false;
  8917. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8918. clif_displaymessage(fd, output);
  8919. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  8920. return true;
  8921. }
  8922. //check restriction
  8923. if (info->restriction) {
  8924. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  8925. return true;
  8926. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  8927. return true;
  8928. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  8929. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  8930. return true;
  8931. }
  8932. // type == 1 : player invoked
  8933. if (type == 1) {
  8934. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  8935. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  8936. return false;
  8937. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8938. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8939. return true;
  8940. }
  8941. }
  8942. //Attempt to use the command
  8943. if ( (info->func(fd, ssd, command, params) != 0) )
  8944. {
  8945. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8946. clif_displaymessage(fd, output);
  8947. return true;
  8948. }
  8949. //Log only if successful.
  8950. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  8951. return true;
  8952. }
  8953. /*==========================================
  8954. *
  8955. *------------------------------------------*/
  8956. static void atcommand_config_read(const char* config_filename)
  8957. {
  8958. config_setting_t *aliases = NULL, *help = NULL;
  8959. const char *symbol = NULL;
  8960. int num_aliases = 0;
  8961. if (conf_read_file(&atcommand_config, config_filename))
  8962. return;
  8963. // Command symbols
  8964. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8965. if (ISPRINT(*symbol) && // no control characters
  8966. *symbol != '/' && // symbol of client commands
  8967. *symbol != '%' && // symbol of party chat
  8968. *symbol != '$' && // symbol of guild chat
  8969. *symbol != charcommand_symbol)
  8970. atcommand_symbol = *symbol;
  8971. }
  8972. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8973. if (ISPRINT(*symbol) && // no control characters
  8974. *symbol != '/' && // symbol of client commands
  8975. *symbol != '%' && // symbol of party chat
  8976. *symbol != '$' && // symbol of guild chat
  8977. *symbol != atcommand_symbol)
  8978. charcommand_symbol = *symbol;
  8979. }
  8980. // Command aliases
  8981. aliases = config_lookup(&atcommand_config, "aliases");
  8982. if (aliases != NULL) {
  8983. int i = 0;
  8984. int count = config_setting_length(aliases);
  8985. for (i = 0; i < count; ++i) {
  8986. config_setting_t *command;
  8987. const char *commandname = NULL;
  8988. int j = 0, alias_count = 0;
  8989. AtCommandInfo *commandinfo = NULL;
  8990. command = config_setting_get_elem(aliases, i);
  8991. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8992. continue;
  8993. commandname = config_setting_name(command);
  8994. if (!atcommand_exists(commandname)) {
  8995. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8996. continue;
  8997. }
  8998. commandinfo = get_atcommandinfo_byname(commandname);
  8999. alias_count = config_setting_length(command);
  9000. for (j = 0; j < alias_count; ++j) {
  9001. const char *alias = config_setting_get_string_elem(command, j);
  9002. if (alias != NULL) {
  9003. AliasInfo *alias_info;
  9004. if (strdb_exists(atcommand_alias_db, alias)) {
  9005. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  9006. continue;
  9007. }
  9008. CREATE(alias_info, AliasInfo, 1);
  9009. alias_info->command = commandinfo;
  9010. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  9011. strdb_put(atcommand_alias_db, alias, alias_info);
  9012. ++num_aliases;
  9013. }
  9014. }
  9015. }
  9016. }
  9017. // Commands help
  9018. // We only check if all commands exist
  9019. help = config_lookup(&atcommand_config, "help");
  9020. if (help != NULL) {
  9021. int count = config_setting_length(help);
  9022. int i;
  9023. for (i = 0; i < count; ++i) {
  9024. config_setting_t *command;
  9025. const char *commandname;
  9026. command = config_setting_get_elem(help, i);
  9027. commandname = config_setting_name(command);
  9028. if (!atcommand_exists(commandname))
  9029. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  9030. }
  9031. }
  9032. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  9033. return;
  9034. }
  9035. void atcommand_db_load_groups(int* group_ids) {
  9036. DBIterator *iter = db_iterator(atcommand_db);
  9037. AtCommandInfo* cmd;
  9038. int i;
  9039. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9040. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9041. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9042. for(i = 0; i < pc_group_max; i++) {
  9043. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9044. cmd->at_groups[i] = 1;
  9045. else
  9046. cmd->at_groups[i] = 0;
  9047. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9048. cmd->char_groups[i] = 1;
  9049. else
  9050. cmd->char_groups[i] = 0;
  9051. }
  9052. }
  9053. dbi_destroy(iter);
  9054. return;
  9055. }
  9056. void atcommand_db_clear(void) {
  9057. if (atcommand_db != NULL) {
  9058. DBIterator *iter = db_iterator(atcommand_db);
  9059. AtCommandInfo* cmd;
  9060. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9061. aFree(cmd->at_groups);
  9062. aFree(cmd->char_groups);
  9063. }
  9064. dbi_destroy(iter);
  9065. db_destroy(atcommand_db);
  9066. }
  9067. if (atcommand_alias_db != NULL)
  9068. db_destroy(atcommand_alias_db);
  9069. config_destroy(&atcommand_config);
  9070. }
  9071. void atcommand_doload(void) {
  9072. atcommand_db_clear();
  9073. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9074. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9075. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9076. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9077. }
  9078. void do_init_atcommand(void) {
  9079. atcommand_doload();
  9080. }
  9081. void do_final_atcommand(void) {
  9082. atcommand_db_clear();
  9083. }