atcommand.c 310 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/random.h"
  11. #include "../common/socket.h"
  12. #include "../common/strlib.h"
  13. #include "../common/utils.h"
  14. #include "../common/conf.h"
  15. #include "map.h"
  16. #include "atcommand.h"
  17. #include "battle.h"
  18. #include "chat.h"
  19. #include "channel.h"
  20. #include "clif.h"
  21. #include "chrif.h"
  22. #include "duel.h"
  23. #include "instance.h"
  24. #include "intif.h"
  25. #include "itemdb.h"
  26. #include "log.h"
  27. #include "pc.h"
  28. #include "pc_groups.h" // groupid2name
  29. #include "status.h"
  30. #include "skill.h"
  31. #include "mob.h"
  32. #include "npc.h"
  33. #include "pet.h"
  34. #include "homunculus.h"
  35. #include "mail.h"
  36. #include "mercenary.h"
  37. #include "elemental.h"
  38. #include "party.h"
  39. #include "guild.h"
  40. #include "script.h"
  41. #include "storage.h"
  42. #include "trade.h"
  43. #include "unit.h"
  44. #include "mapreg.h"
  45. #include "quest.h"
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #include <string.h>
  49. #include <math.h>
  50. #define ATCOMMAND_LENGTH 50
  51. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  52. typedef struct AtCommandInfo AtCommandInfo;
  53. typedef struct AliasInfo AliasInfo;
  54. int atcmd_binding_count = 0;
  55. struct AtCommandInfo {
  56. char command[ATCOMMAND_LENGTH];
  57. AtCommandFunc func;
  58. char* at_groups;/* quick @commands "can-use" lookup */
  59. char* char_groups;/* quick @charcommands "can-use" lookup */
  60. int restriction; //prevent : 1 console, 2 script...
  61. };
  62. struct AliasInfo {
  63. AtCommandInfo *command;
  64. char alias[ATCOMMAND_LENGTH];
  65. };
  66. char atcommand_symbol = '@'; // first char of the commands
  67. char charcommand_symbol = '#';
  68. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  69. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  70. static config_t atcommand_config;
  71. static char atcmd_output[CHAT_SIZE_MAX];
  72. static char atcmd_player_name[NAME_LENGTH];
  73. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  74. static const char* atcommand_checkalias(const char *aliasname); // @help
  75. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  76. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  77. // @commands (script-based)
  78. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  79. int i = 0;
  80. if( *name == atcommand_symbol || *name == charcommand_symbol )
  81. name++; // for backwards compatibility
  82. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  83. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  84. }
  85. /**
  86. * retrieves the help string associated with a given command.
  87. *
  88. * @param name the name of the command to retrieve help information for
  89. * @return the string associated with the command, or NULL
  90. */
  91. static const char* atcommand_help_string(const char* command)
  92. {
  93. const char* str = NULL;
  94. config_setting_t* info;
  95. if( *command == atcommand_symbol || *command == charcommand_symbol )
  96. {// remove the prefix symbol for the raw name of the command
  97. command ++;
  98. }
  99. // convert alias to the real command name
  100. command = atcommand_checkalias(command);
  101. // attempt to find the first default help command
  102. info = config_lookup(&atcommand_config, "help");
  103. if( info == NULL )
  104. {// failed to find the help property in the configuration file
  105. return NULL;
  106. }
  107. if( !config_setting_lookup_string( info, command, &str ) )
  108. {// failed to find the matching help string
  109. return NULL;
  110. }
  111. // push the result from the method
  112. return str;
  113. }
  114. /*==========================================
  115. * @send (used for testing packet sends from the client)
  116. *------------------------------------------*/
  117. ACMD_FUNC(send)
  118. {
  119. int len=0,type;
  120. // read message type as hex number (without the 0x)
  121. if(!message || !*message ||
  122. !((sscanf(message, "len %x", &type)==1 && (len=1))
  123. || sscanf(message, "%x", &type)==1) )
  124. {
  125. int i;
  126. for (i = 900; i <= 903; ++i)
  127. clif_displaymessage(fd, msg_txt(sd,i));
  128. return -1;
  129. }
  130. #define PARSE_ERROR(error,p) \
  131. {\
  132. clif_displaymessage(fd, (error));\
  133. sprintf(atcmd_output, ">%s", (p));\
  134. clif_displaymessage(fd, atcmd_output);\
  135. }
  136. //define PARSE_ERROR
  137. #define CHECK_EOS(p) \
  138. if(*(p) == 0){\
  139. clif_displaymessage(fd, "Unexpected end of string");\
  140. return -1;\
  141. }
  142. //define CHECK_EOS
  143. #define SKIP_VALUE(p) \
  144. {\
  145. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  146. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  147. }
  148. //define SKIP_VALUE
  149. #define GET_VALUE(p,num) \
  150. {\
  151. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  152. PARSE_ERROR("Invalid number in:",(p));\
  153. return -1;\
  154. }\
  155. }
  156. //define GET_VALUE
  157. if (type > 0 && type < MAX_PACKET_DB) {
  158. int off,end;
  159. long num;
  160. if(len)
  161. {// show packet length
  162. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  163. clif_displaymessage(fd, atcmd_output);
  164. return 0;
  165. }
  166. len=packet_db[sd->packet_ver][type].len;
  167. off=2;
  168. if(len == 0)
  169. {// unknown packet - ERROR
  170. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  171. clif_displaymessage(fd, atcmd_output);
  172. return -1;
  173. } else if(len == -1)
  174. {// dynamic packet
  175. len=SHRT_MAX-4; // maximum length
  176. off=4;
  177. }
  178. WFIFOHEAD(fd, len);
  179. WFIFOW(fd,0)=TOW(type);
  180. // parse packet contents
  181. SKIP_VALUE(message);
  182. while(*message != 0 && off < len){
  183. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  184. {// default (byte)
  185. GET_VALUE(message,num);
  186. WFIFOB(fd,off)=TOB(num);
  187. ++off;
  188. } else if(TOUPPER(*message) == 'B')
  189. {// byte
  190. ++message;
  191. GET_VALUE(message,num);
  192. WFIFOB(fd,off)=TOB(num);
  193. ++off;
  194. } else if(TOUPPER(*message) == 'W')
  195. {// word (2 bytes)
  196. ++message;
  197. GET_VALUE(message,num);
  198. WFIFOW(fd,off)=TOW(num);
  199. off+=2;
  200. } else if(TOUPPER(*message) == 'L')
  201. {// long word (4 bytes)
  202. ++message;
  203. GET_VALUE(message,num);
  204. WFIFOL(fd,off)=TOL(num);
  205. off+=4;
  206. } else if(TOUPPER(*message) == 'S')
  207. {// string - escapes are valid
  208. // get string length - num <= 0 means not fixed length (default)
  209. ++message;
  210. if(*message == '"'){
  211. num=0;
  212. } else {
  213. GET_VALUE(message,num);
  214. while(*message != '"')
  215. {// find start of string
  216. if(*message == 0 || ISSPACE(*message)){
  217. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  218. return -1;
  219. }
  220. ++message;
  221. }
  222. }
  223. // parse string
  224. ++message;
  225. CHECK_EOS(message);
  226. end=(num<=0? 0: min(off+((int)num),len));
  227. for(; *message != '"' && (off < end || end == 0); ++off){
  228. if(*message == '\\'){
  229. ++message;
  230. CHECK_EOS(message);
  231. switch(*message){
  232. case 'a': num=0x07; break; // Bell
  233. case 'b': num=0x08; break; // Backspace
  234. case 't': num=0x09; break; // Horizontal tab
  235. case 'n': num=0x0A; break; // Line feed
  236. case 'v': num=0x0B; break; // Vertical tab
  237. case 'f': num=0x0C; break; // Form feed
  238. case 'r': num=0x0D; break; // Carriage return
  239. case 'e': num=0x1B; break; // Escape
  240. default: num=*message; break;
  241. case 'x': // Hexadecimal
  242. {
  243. ++message;
  244. CHECK_EOS(message);
  245. if(!ISXDIGIT(*message)){
  246. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  247. return -1;
  248. }
  249. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  250. if(ISXDIGIT(*message)){
  251. ++message;
  252. CHECK_EOS(message);
  253. num<<=8;
  254. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  255. }
  256. WFIFOB(fd,off)=TOB(num);
  257. ++message;
  258. CHECK_EOS(message);
  259. continue;
  260. }
  261. case '0':
  262. case '1':
  263. case '2':
  264. case '3':
  265. case '4':
  266. case '5':
  267. case '6':
  268. case '7': // Octal
  269. {
  270. num=*message-'0'; // 1st octal digit
  271. ++message;
  272. CHECK_EOS(message);
  273. if(ISDIGIT(*message) && *message < '8'){
  274. num<<=3;
  275. num+=*message-'0'; // 2nd octal digit
  276. ++message;
  277. CHECK_EOS(message);
  278. if(ISDIGIT(*message) && *message < '8'){
  279. num<<=3;
  280. num+=*message-'0'; // 3rd octal digit
  281. ++message;
  282. CHECK_EOS(message);
  283. }
  284. }
  285. WFIFOB(fd,off)=TOB(num);
  286. continue;
  287. }
  288. }
  289. } else
  290. num=*message;
  291. WFIFOB(fd,off)=TOB(num);
  292. ++message;
  293. CHECK_EOS(message);
  294. }//for
  295. while(*message != '"')
  296. {// ignore extra characters
  297. ++message;
  298. CHECK_EOS(message);
  299. }
  300. // terminate the string
  301. if(off < end)
  302. {// fill the rest with 0's
  303. memset(WFIFOP(fd,off),0,end-off);
  304. off=end;
  305. }
  306. } else
  307. {// unknown
  308. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  309. return -1;
  310. }
  311. SKIP_VALUE(message);
  312. }
  313. if(packet_db[sd->packet_ver][type].len == -1)
  314. {// send dynamic packet
  315. WFIFOW(fd,2)=TOW(off);
  316. WFIFOSET(fd,off);
  317. } else
  318. {// send static packet
  319. if(off < len)
  320. memset(WFIFOP(fd,off),0,len-off);
  321. WFIFOSET(fd,len);
  322. }
  323. } else {
  324. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  325. return -1;
  326. }
  327. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  328. clif_displaymessage(fd, atcmd_output);
  329. return 0;
  330. #undef PARSE_ERROR
  331. #undef CHECK_EOS
  332. #undef SKIP_VALUE
  333. #undef GET_VALUE
  334. }
  335. /**
  336. * Retrieves map name suggestions for a given string.
  337. * This will first check if any map names contain the given string, and will
  338. * print out MAX_SUGGESTIONS results if any maps are found.
  339. * Otherwise, suggestions will be calculated through Levenshtein distance,
  340. * and up to 5 of the closest matches will be printed.
  341. *
  342. * @author Euphy
  343. */
  344. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  345. char buffer[512];
  346. int i, count = 0;
  347. if (strlen(name) < 2)
  348. return;
  349. // build the suggestion string
  350. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  351. strcat(buffer, "\n");
  352. // check for maps that contain string
  353. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  354. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  355. strcat(buffer, map[i].name);
  356. strcat(buffer, " ");
  357. if (++count >= MAX_SUGGESTIONS)
  358. break;
  359. }
  360. }
  361. // if no maps found, search by edit distance
  362. if (!count) {
  363. unsigned int distance[MAX_MAP_PER_SERVER][2];
  364. int j;
  365. // calculate Levenshtein distance for all maps
  366. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  367. if (strlen(map[i].name) < 4) // invalid map name?
  368. distance[i][0] = INT_MAX;
  369. else {
  370. distance[i][0] = levenshtein(map[i].name, name);
  371. distance[i][1] = i;
  372. }
  373. }
  374. // selection sort elements as needed
  375. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  376. for (i = 0; i < count; i++) {
  377. int min = i;
  378. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  379. if (distance[j][0] < distance[min][0])
  380. min = j;
  381. }
  382. // print map name
  383. if (distance[min][0] > 4) { // awful results, don't bother
  384. if (!i) return;
  385. break;
  386. }
  387. strcat(buffer, map[distance[min][1]].name);
  388. strcat(buffer, " ");
  389. // swap elements
  390. swap(distance[i][0], distance[min][0]);
  391. swap(distance[i][1], distance[min][1]);
  392. }
  393. }
  394. clif_displaymessage(sd->fd, buffer);
  395. }
  396. /*==========================================
  397. * @rura, @warp, @mapmove
  398. *------------------------------------------*/
  399. ACMD_FUNC(mapmove)
  400. {
  401. char map_name[MAP_NAME_LENGTH_EXT];
  402. unsigned short mapindex;
  403. short x = 0, y = 0;
  404. int16 m = -1;
  405. nullpo_retr(-1, sd);
  406. memset(map_name, '\0', sizeof(map_name));
  407. if (!message || !*message ||
  408. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  409. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  410. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  411. return -1;
  412. }
  413. mapindex = mapindex_name2id(map_name);
  414. if (mapindex)
  415. m = map_mapindex2mapid(mapindex);
  416. if (!mapindex) { // m < 0 means on different server! [Kevin]
  417. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  418. if (battle_config.warp_suggestions_enabled)
  419. warp_get_suggestions(sd, map_name);
  420. return -1;
  421. }
  422. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  423. { //This is to prevent the pc_setpos call from printing an error.
  424. clif_displaymessage(fd, msg_txt(sd,2));
  425. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  426. x = y = 0; //Invalid cell, use random spot.
  427. }
  428. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  429. clif_displaymessage(fd, msg_txt(sd,247));
  430. return -1;
  431. }
  432. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  433. clif_displaymessage(fd, msg_txt(sd,248));
  434. return -1;
  435. }
  436. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  437. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  438. return -1;
  439. }
  440. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  441. return 0;
  442. }
  443. /*==========================================
  444. * Displays where a character is. Corrected version by Silent. [Skotlex]
  445. *------------------------------------------*/
  446. ACMD_FUNC(where)
  447. {
  448. struct map_session_data* pl_sd;
  449. nullpo_retr(-1, sd);
  450. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  451. if (!message || !*message || sscanf(message, "%23s[^\n]", atcmd_player_name) < 1) {
  452. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  453. return -1;
  454. }
  455. pl_sd = map_nick2sd(atcmd_player_name);
  456. if (pl_sd == NULL ||
  457. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  458. (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))
  459. ) {
  460. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  461. return -1;
  462. }
  463. 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);
  464. clif_displaymessage(fd, atcmd_output);
  465. return 0;
  466. }
  467. /*==========================================
  468. *
  469. *------------------------------------------*/
  470. ACMD_FUNC(jumpto)
  471. {
  472. struct map_session_data *pl_sd = NULL;
  473. nullpo_retr(-1, sd);
  474. if (!message || !*message) {
  475. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  476. return -1;
  477. }
  478. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  479. {
  480. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  481. return -1;
  482. }
  483. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  484. {
  485. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  486. return -1;
  487. }
  488. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  489. {
  490. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  491. return -1;
  492. }
  493. if( pc_isdead(sd) )
  494. {
  495. clif_displaymessage(fd, msg_txt(sd,664));
  496. return -1;
  497. }
  498. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  499. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  500. clif_displaymessage(fd, atcmd_output);
  501. return 0;
  502. }
  503. /*==========================================
  504. *
  505. *------------------------------------------*/
  506. ACMD_FUNC(jump)
  507. {
  508. short x = 0, y = 0;
  509. nullpo_retr(-1, sd);
  510. memset(atcmd_output, '\0', sizeof(atcmd_output));
  511. sscanf(message, "%hd %hd", &x, &y);
  512. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  513. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  514. return -1;
  515. }
  516. if( pc_isdead(sd) )
  517. {
  518. clif_displaymessage(fd, msg_txt(sd,664));
  519. return -1;
  520. }
  521. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  522. { //This is to prevent the pc_setpos call from printing an error.
  523. clif_displaymessage(fd, msg_txt(sd,2));
  524. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  525. x = y = 0; //Invalid cell, use random spot.
  526. }
  527. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  528. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  529. clif_displaymessage(fd, atcmd_output);
  530. return 0;
  531. }
  532. /*==========================================
  533. * Display list of online characters with
  534. * various info.
  535. *------------------------------------------*/
  536. ACMD_FUNC(who) {
  537. struct map_session_data *pl_sd = NULL;
  538. struct s_mapiterator *iter = NULL;
  539. char player_name[NAME_LENGTH] = "";
  540. int count = 0;
  541. int level = 0;
  542. StringBuf buf;
  543. /**
  544. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  545. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  546. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  547. */
  548. int display_type = 1;
  549. int map_id = -1;
  550. nullpo_retr(-1, sd);
  551. if (strstr(command, "map") != NULL) {
  552. char map_name[MAP_NAME_LENGTH_EXT] = "";
  553. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  554. map_id = sd->bl.m;
  555. } else {
  556. sscanf(message, "%23s", player_name);
  557. }
  558. if (strstr(command, "2") != NULL)
  559. display_type = 2;
  560. else if (strstr(command, "3") != NULL)
  561. display_type = 3;
  562. level = pc_get_group_level(sd);
  563. StringBuf_Init(&buf);
  564. iter = mapit_getallusers();
  565. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  566. 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
  567. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  568. || (map_id >= 0 && pl_sd->bl.m != map_id))
  569. continue;
  570. switch (display_type) {
  571. case 2: {
  572. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  573. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  574. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  575. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  576. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  577. break;
  578. }
  579. case 3: {
  580. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  581. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  582. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  583. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  584. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  585. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  586. break;
  587. }
  588. default: {
  589. struct party_data *p = party_search(pl_sd->status.party_id);
  590. struct guild *g = pl_sd->guild;
  591. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  592. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  593. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  594. if (p != NULL)
  595. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  596. if (g != NULL)
  597. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  598. break;
  599. }
  600. }
  601. clif_displaymessage(fd, StringBuf_Value(&buf));
  602. StringBuf_Clear(&buf);
  603. count++;
  604. }
  605. }
  606. mapit_free(iter);
  607. if (map_id < 0) {
  608. if (count == 0)
  609. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  610. else if (count == 1)
  611. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  612. else
  613. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  614. } else {
  615. if (count == 0)
  616. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  617. else if (count == 1)
  618. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  619. else
  620. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  621. }
  622. clif_displaymessage(fd, StringBuf_Value(&buf));
  623. StringBuf_Destroy(&buf);
  624. return 0;
  625. }
  626. /*==========================================
  627. *
  628. *------------------------------------------*/
  629. ACMD_FUNC(whogm)
  630. {
  631. struct map_session_data* pl_sd;
  632. struct s_mapiterator* iter;
  633. int j, count;
  634. int level;
  635. char match_text[CHAT_SIZE_MAX];
  636. char player_name[NAME_LENGTH];
  637. struct guild *g;
  638. struct party_data *p;
  639. nullpo_retr(-1, sd);
  640. memset(atcmd_output, '\0', sizeof(atcmd_output));
  641. memset(match_text, '\0', sizeof(match_text));
  642. memset(player_name, '\0', sizeof(player_name));
  643. if (sscanf(message, "%199[^\n]", match_text) < 1)
  644. strcpy(match_text, "");
  645. for (j = 0; match_text[j]; j++)
  646. match_text[j] = TOLOWER(match_text[j]);
  647. count = 0;
  648. level = pc_get_group_level(sd);
  649. iter = mapit_getallusers();
  650. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  651. {
  652. int pl_level = pc_get_group_level(pl_sd);
  653. if (!pl_level)
  654. continue;
  655. if (match_text[0])
  656. {
  657. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  658. for (j = 0; player_name[j]; j++)
  659. player_name[j] = TOLOWER(player_name[j]);
  660. // search with no case sensitive
  661. if (strstr(player_name, match_text) == NULL)
  662. continue;
  663. }
  664. if (pl_level > level) {
  665. if (pl_sd->sc.option & OPTION_INVISIBLE)
  666. continue;
  667. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  668. clif_displaymessage(fd, atcmd_output);
  669. count++;
  670. continue;
  671. }
  672. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  673. pl_sd->status.name, pl_level,
  674. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  675. clif_displaymessage(fd, atcmd_output);
  676. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  677. pl_sd->status.base_level,
  678. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  679. clif_displaymessage(fd, atcmd_output);
  680. p = party_search(pl_sd->status.party_id);
  681. g = pl_sd->guild;
  682. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  683. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  684. clif_displaymessage(fd, atcmd_output);
  685. count++;
  686. }
  687. mapit_free(iter);
  688. if (count == 0)
  689. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  690. else if (count == 1)
  691. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  692. else {
  693. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  694. clif_displaymessage(fd, atcmd_output);
  695. }
  696. return 0;
  697. }
  698. /*==========================================
  699. *
  700. *------------------------------------------*/
  701. ACMD_FUNC(save)
  702. {
  703. nullpo_retr(-1, sd);
  704. if( map[sd->bl.m].instance_id ) {
  705. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  706. return 1;
  707. }
  708. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  709. if (sd->status.pet_id > 0 && sd->pd)
  710. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  711. chrif_save(sd,0);
  712. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  713. return 0;
  714. }
  715. /*==========================================
  716. *
  717. *------------------------------------------*/
  718. ACMD_FUNC(load)
  719. {
  720. int16 m;
  721. nullpo_retr(-1, sd);
  722. m = map_mapindex2mapid(sd->status.save_point.map);
  723. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  724. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  725. return -1;
  726. }
  727. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  728. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  729. return -1;
  730. }
  731. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  732. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  733. return 0;
  734. }
  735. /*==========================================
  736. *
  737. *------------------------------------------*/
  738. ACMD_FUNC(speed)
  739. {
  740. int speed;
  741. nullpo_retr(-1, sd);
  742. memset(atcmd_output, '\0', sizeof(atcmd_output));
  743. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  744. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  745. clif_displaymessage(fd, atcmd_output);
  746. return -1;
  747. }
  748. if (speed < 0) {
  749. sd->base_status.speed = DEFAULT_WALK_SPEED;
  750. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  751. } else {
  752. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  753. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  754. }
  755. status_calc_bl(&sd->bl, SCB_SPEED);
  756. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  757. return 0;
  758. }
  759. /*==========================================
  760. *
  761. *------------------------------------------*/
  762. ACMD_FUNC(storage)
  763. {
  764. nullpo_retr(-1, sd);
  765. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  766. return -1;
  767. if (storage_storageopen(sd) == 1)
  768. { //Already open.
  769. clif_displaymessage(fd, msg_txt(sd,250));
  770. return -1;
  771. }
  772. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  773. return 0;
  774. }
  775. /*==========================================
  776. *
  777. *------------------------------------------*/
  778. ACMD_FUNC(guildstorage)
  779. {
  780. nullpo_retr(-1, sd);
  781. if (!sd->status.guild_id) {
  782. clif_displaymessage(fd, msg_txt(sd,252));
  783. return -1;
  784. }
  785. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  786. return -1;
  787. if (sd->state.storage_flag == 1) {
  788. clif_displaymessage(fd, msg_txt(sd,250));
  789. return -1;
  790. }
  791. if (sd->state.storage_flag == 2) {
  792. clif_displaymessage(fd, msg_txt(sd,251));
  793. return -1;
  794. }
  795. storage_guild_storageopen(sd);
  796. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  797. return 0;
  798. }
  799. /*==========================================
  800. *
  801. *------------------------------------------*/
  802. ACMD_FUNC(option)
  803. {
  804. int param1 = 0, param2 = 0, param3 = 0;
  805. nullpo_retr(-1, sd);
  806. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  807. {// failed to match the parameters so inform the user of the options
  808. const char* text;
  809. // attempt to find the setting information for this command
  810. text = atcommand_help_string( command );
  811. // notify the user of the requirement to enter an option
  812. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  813. if( text )
  814. {// send the help text associated with this command
  815. clif_displaymessage( fd, text );
  816. }
  817. return -1;
  818. }
  819. sd->sc.opt1 = param1;
  820. sd->sc.opt2 = param2;
  821. pc_setoption(sd, param3);
  822. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  823. return 0;
  824. }
  825. /*==========================================
  826. *
  827. *------------------------------------------*/
  828. ACMD_FUNC(hide)
  829. {
  830. nullpo_retr(-1, sd);
  831. if (sd->sc.option & OPTION_INVISIBLE) {
  832. sd->sc.option &= ~OPTION_INVISIBLE;
  833. if (sd->disguise)
  834. status_set_viewdata(&sd->bl, sd->disguise);
  835. else
  836. status_set_viewdata(&sd->bl, sd->status.class_);
  837. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  838. // increment the number of pvp players on the map
  839. map[sd->bl.m].users_pvp++;
  840. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  841. {// register the player for ranking calculations
  842. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  843. }
  844. //bugreport:2266
  845. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  846. } else {
  847. sd->sc.option |= OPTION_INVISIBLE;
  848. sd->vd.class_ = INVISIBLE_CLASS;
  849. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  850. // decrement the number of pvp players on the map
  851. map[sd->bl.m].users_pvp--;
  852. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  853. {// unregister the player for ranking
  854. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  855. sd->pvp_timer = INVALID_TIMER;
  856. }
  857. }
  858. clif_changeoption(&sd->bl);
  859. return 0;
  860. }
  861. /*==========================================
  862. * Changes a character's class
  863. *------------------------------------------*/
  864. ACMD_FUNC(jobchange)
  865. {
  866. int job = 0, upper = 0;
  867. const char* text;
  868. nullpo_retr(-1, sd);
  869. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  870. int i;
  871. bool found = false;
  872. upper = 0;
  873. // Normal Jobs
  874. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  875. if (strncmpi(message, job_name(i), 16) == 0) {
  876. job = i;
  877. found = true;
  878. }
  879. }
  880. // High Jobs, Babys and Third
  881. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  882. if (strncmpi(message, job_name(i), 16) == 0) {
  883. job = i;
  884. found = true;
  885. }
  886. }
  887. if (!found) {
  888. text = atcommand_help_string(command);
  889. if (text)
  890. clif_displaymessage(fd, text);
  891. return -1;
  892. }
  893. }
  894. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  895. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  896. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2))
  897. { // Deny direct transformation into dummy jobs
  898. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  899. return 0;
  900. }
  901. if (pcdb_checkid(job))
  902. {
  903. if (pc_jobchange(sd, job, upper))
  904. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  905. else {
  906. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  907. return -1;
  908. }
  909. } else {
  910. text = atcommand_help_string(command);
  911. if (text)
  912. clif_displaymessage(fd, text);
  913. return -1;
  914. }
  915. return 0;
  916. }
  917. /*==========================================
  918. *
  919. *------------------------------------------*/
  920. ACMD_FUNC(kill)
  921. {
  922. nullpo_retr(-1, sd);
  923. status_kill(&sd->bl);
  924. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  925. if (fd != sd->fd)
  926. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  927. return 0;
  928. }
  929. /*==========================================
  930. *
  931. *------------------------------------------*/
  932. ACMD_FUNC(alive)
  933. {
  934. nullpo_retr(-1, sd);
  935. if (!status_revive(&sd->bl, 100, 100))
  936. {
  937. clif_displaymessage(fd, msg_txt(sd,667));
  938. return -1;
  939. }
  940. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  941. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  942. return 0;
  943. }
  944. /*==========================================
  945. * +kamic [LuzZza]
  946. *------------------------------------------*/
  947. ACMD_FUNC(kami)
  948. {
  949. unsigned long color=0;
  950. nullpo_retr(-1, sd);
  951. memset(atcmd_output, '\0', sizeof(atcmd_output));
  952. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  953. if (!message || !*message) {
  954. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  955. return -1;
  956. }
  957. sscanf(message, "%199[^\n]", atcmd_output);
  958. if (strstr(command, "l") != NULL)
  959. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  960. else
  961. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  962. } else {
  963. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  964. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  965. return -1;
  966. }
  967. if(color > 0xFFFFFF) {
  968. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  969. return -1;
  970. }
  971. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  972. }
  973. return 0;
  974. }
  975. /*==========================================
  976. *
  977. *------------------------------------------*/
  978. ACMD_FUNC(heal)
  979. {
  980. int hp = 0, sp = 0; // [Valaris] thanks to fov
  981. nullpo_retr(-1, sd);
  982. sscanf(message, "%d %d", &hp, &sp);
  983. // some overflow checks
  984. if( hp == INT_MIN ) hp++;
  985. if( sp == INT_MIN ) sp++;
  986. if ( hp == 0 && sp == 0 ) {
  987. if (!status_percent_heal(&sd->bl, 100, 100))
  988. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  989. else
  990. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  991. return 0;
  992. }
  993. if ( hp > 0 && sp >= 0 ) {
  994. if(!status_heal(&sd->bl, hp, sp, 0))
  995. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  996. else
  997. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  998. return 0;
  999. }
  1000. if ( hp < 0 && sp <= 0 ) {
  1001. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1002. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0);
  1003. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1004. return 0;
  1005. }
  1006. //Opposing signs.
  1007. if ( hp ) {
  1008. if (hp > 0)
  1009. status_heal(&sd->bl, hp, 0, 0);
  1010. else {
  1011. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1012. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0);
  1013. }
  1014. }
  1015. if ( sp ) {
  1016. if (sp > 0)
  1017. status_heal(&sd->bl, 0, sp, 0);
  1018. else
  1019. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1020. }
  1021. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1022. return 0;
  1023. }
  1024. /*==========================================
  1025. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1026. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1027. *------------------------------------------*/
  1028. ACMD_FUNC(item)
  1029. {
  1030. char item_name[100];
  1031. int number = 0, bound = BOUND_NONE;
  1032. char flag = 0;
  1033. struct item item_tmp;
  1034. struct item_data *item_data[10];
  1035. int get_count, i, j=0;
  1036. char *itemlist;
  1037. nullpo_retr(-1, sd);
  1038. memset(item_name, '\0', sizeof(item_name));
  1039. if (!strcmpi(command+1,"itembound")) {
  1040. if (!message || !*message || (
  1041. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 3 &&
  1042. sscanf(message, "%99s %d %d", item_name, &number, &bound) < 3))
  1043. {
  1044. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1045. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1046. return -1;
  1047. }
  1048. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1049. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1050. return -1;
  1051. }
  1052. } else if (!message || !*message || (
  1053. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1054. sscanf(message, "%99s %d", item_name, &number) < 1
  1055. )) {
  1056. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1057. return -1;
  1058. }
  1059. itemlist = strtok(item_name, ":");
  1060. while (itemlist != NULL && j<10) {
  1061. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1062. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1063. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1064. return -1;
  1065. }
  1066. itemlist = strtok(NULL, ":"); //next itemline
  1067. j++;
  1068. }
  1069. if (number <= 0)
  1070. number = 1;
  1071. get_count = number;
  1072. for(j--; j>=0; j--){ //produce items in list
  1073. unsigned short item_id = item_data[j]->nameid;
  1074. //Check if it's stackable.
  1075. if (!itemdb_isstackable2(item_data[j]))
  1076. get_count = 1;
  1077. for (i = 0; i < number; i += get_count) {
  1078. // if not pet egg
  1079. if (!pet_create_egg(sd, item_id)) {
  1080. memset(&item_tmp, 0, sizeof(item_tmp));
  1081. item_tmp.nameid = item_id;
  1082. item_tmp.identify = 1;
  1083. item_tmp.bound = bound;
  1084. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1085. clif_additem(sd, 0, 0, flag);
  1086. }
  1087. }
  1088. }
  1089. if (flag == 0)
  1090. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1091. return 0;
  1092. }
  1093. /*==========================================
  1094. *
  1095. *------------------------------------------*/
  1096. ACMD_FUNC(item2)
  1097. {
  1098. struct item item_tmp;
  1099. struct item_data *item_data;
  1100. char item_name[100];
  1101. unsigned short item_id;
  1102. int number = 0, bound = BOUND_NONE;
  1103. int identify = 0, refine = 0, attr = 0;
  1104. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1105. nullpo_retr(-1, sd);
  1106. memset(item_name, '\0', sizeof(item_name));
  1107. if (!strcmpi(command+1,"itembound2")) {
  1108. if (!message || !*message || (
  1109. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1110. sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1111. {
  1112. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1113. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1114. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1115. return -1;
  1116. }
  1117. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1118. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1119. return -1;
  1120. }
  1121. } else if ( !message || !*message || (
  1122. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1123. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1124. )) {
  1125. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1126. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1127. return -1;
  1128. }
  1129. if (number <= 0)
  1130. number = 1;
  1131. item_id = 0;
  1132. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1133. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1134. item_id = item_data->nameid;
  1135. if (item_id > 500) {
  1136. int loop, get_count, i;
  1137. char flag = 0;
  1138. loop = 1;
  1139. get_count = number;
  1140. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1141. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1142. loop = number;
  1143. get_count = 1;
  1144. if (item_data->type == IT_PETEGG) {
  1145. identify = 1;
  1146. refine = 0;
  1147. }
  1148. if (item_data->type == IT_PETARMOR)
  1149. refine = 0;
  1150. if (refine > MAX_REFINE)
  1151. refine = MAX_REFINE;
  1152. } else {
  1153. identify = 1;
  1154. refine = attr = 0;
  1155. }
  1156. for (i = 0; i < loop; i++) {
  1157. memset(&item_tmp, 0, sizeof(item_tmp));
  1158. item_tmp.nameid = item_id;
  1159. item_tmp.identify = identify;
  1160. item_tmp.refine = refine;
  1161. item_tmp.attribute = attr;
  1162. item_tmp.card[0] = c1;
  1163. item_tmp.card[1] = c2;
  1164. item_tmp.card[2] = c3;
  1165. item_tmp.card[3] = c4;
  1166. item_tmp.bound = bound;
  1167. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1168. clif_additem(sd, 0, 0, flag);
  1169. }
  1170. if (flag == 0)
  1171. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1172. } else {
  1173. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1174. return -1;
  1175. }
  1176. return 0;
  1177. }
  1178. /*==========================================
  1179. *
  1180. *------------------------------------------*/
  1181. ACMD_FUNC(itemreset)
  1182. {
  1183. int i;
  1184. nullpo_retr(-1, sd);
  1185. for (i = 0; i < MAX_INVENTORY; i++) {
  1186. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1187. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1188. }
  1189. }
  1190. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1191. return 0;
  1192. }
  1193. /*==========================================
  1194. * Atcommand @lvlup
  1195. *------------------------------------------*/
  1196. ACMD_FUNC(baselevelup)
  1197. {
  1198. int level=0, i=0, status_point=0;
  1199. nullpo_retr(-1, sd);
  1200. level = atoi(message);
  1201. if (!message || !*message || !level) {
  1202. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1203. return -1;
  1204. }
  1205. if (level > 0) {
  1206. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1207. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1208. return -1;
  1209. } // End Addition
  1210. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1211. level = pc_maxbaselv(sd) - sd->status.base_level;
  1212. for (i = 0; i < level; i++)
  1213. status_point += pc_gets_status_point(sd->status.base_level + i);
  1214. sd->status.status_point += status_point;
  1215. sd->status.base_level += (unsigned int)level;
  1216. status_calc_pc(sd, SCO_FORCE);
  1217. status_percent_heal(&sd->bl, 100, 100);
  1218. clif_misceffect(&sd->bl, 0);
  1219. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1220. } else {
  1221. if (sd->status.base_level == 1) {
  1222. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1223. return -1;
  1224. }
  1225. level*=-1;
  1226. if ((unsigned int)level >= sd->status.base_level)
  1227. level = sd->status.base_level-1;
  1228. for (i = 0; i > -level; i--)
  1229. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1230. if (sd->status.status_point < status_point)
  1231. pc_resetstate(sd);
  1232. if (sd->status.status_point < status_point)
  1233. sd->status.status_point = 0;
  1234. else
  1235. sd->status.status_point -= status_point;
  1236. sd->status.base_level -= (unsigned int)level;
  1237. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1238. status_calc_pc(sd, SCO_FORCE);
  1239. }
  1240. sd->status.base_exp = 0;
  1241. clif_updatestatus(sd, SP_STATUSPOINT);
  1242. clif_updatestatus(sd, SP_BASELEVEL);
  1243. clif_updatestatus(sd, SP_BASEEXP);
  1244. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1245. pc_baselevelchanged(sd);
  1246. if(sd->status.party_id)
  1247. party_send_levelup(sd);
  1248. return 0;
  1249. }
  1250. /*==========================================
  1251. *
  1252. *------------------------------------------*/
  1253. ACMD_FUNC(joblevelup)
  1254. {
  1255. int level=0;
  1256. nullpo_retr(-1, sd);
  1257. level = atoi(message);
  1258. if (!message || !*message || !level) {
  1259. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1260. return -1;
  1261. }
  1262. if (level > 0) {
  1263. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1264. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1265. return -1;
  1266. }
  1267. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1268. level = pc_maxjoblv(sd) - sd->status.job_level;
  1269. sd->status.job_level += (unsigned int)level;
  1270. sd->status.skill_point += level;
  1271. clif_misceffect(&sd->bl, 1);
  1272. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1273. } else {
  1274. if (sd->status.job_level == 1) {
  1275. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1276. return -1;
  1277. }
  1278. level *=-1;
  1279. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1280. level = sd->status.job_level-1;
  1281. sd->status.job_level -= (unsigned int)level;
  1282. if (sd->status.skill_point < level)
  1283. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1284. if (sd->status.skill_point < level)
  1285. sd->status.skill_point = 0;
  1286. else
  1287. sd->status.skill_point -= level;
  1288. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1289. }
  1290. sd->status.job_exp = 0;
  1291. clif_updatestatus(sd, SP_JOBLEVEL);
  1292. clif_updatestatus(sd, SP_JOBEXP);
  1293. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1294. clif_updatestatus(sd, SP_SKILLPOINT);
  1295. status_calc_pc(sd, SCO_FORCE);
  1296. return 0;
  1297. }
  1298. /*==========================================
  1299. * @help
  1300. *------------------------------------------*/
  1301. ACMD_FUNC(help)
  1302. {
  1303. config_setting_t *help;
  1304. const char *text = NULL;
  1305. const char *command_name = NULL;
  1306. char *default_command = "help";
  1307. nullpo_retr(-1, sd);
  1308. help = config_lookup(&atcommand_config, "help");
  1309. if (help == NULL) {
  1310. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1311. return -1;
  1312. }
  1313. if (!message || !*message) {
  1314. command_name = default_command; // If no command_name specified, display help for @help.
  1315. } else {
  1316. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1317. ++message;
  1318. command_name = atcommand_checkalias(message);
  1319. }
  1320. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1321. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1322. clif_displaymessage(fd, atcmd_output);
  1323. atcommand_get_suggestions(sd, command_name, true);
  1324. return -1;
  1325. }
  1326. if (!config_setting_lookup_string(help, command_name, &text)) {
  1327. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1328. clif_displaymessage(fd, atcmd_output);
  1329. atcommand_get_suggestions(sd, command_name, true);
  1330. return -1;
  1331. }
  1332. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1333. clif_displaymessage(fd, atcmd_output);
  1334. { // Display aliases
  1335. DBIterator* iter;
  1336. AtCommandInfo *command_info;
  1337. AliasInfo *alias_info = NULL;
  1338. StringBuf buf;
  1339. bool has_aliases = false;
  1340. StringBuf_Init(&buf);
  1341. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1342. command_info = get_atcommandinfo_byname(command_name);
  1343. iter = db_iterator(atcommand_alias_db);
  1344. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1345. if (alias_info->command == command_info) {
  1346. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1347. has_aliases = true;
  1348. }
  1349. }
  1350. dbi_destroy(iter);
  1351. if (has_aliases)
  1352. clif_displaymessage(fd, StringBuf_Value(&buf));
  1353. StringBuf_Destroy(&buf);
  1354. }
  1355. // Display help contents
  1356. clif_displaymessage(fd, text);
  1357. return 0;
  1358. }
  1359. // helper function, used in foreach calls to stop auto-attack timers
  1360. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1361. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1362. {
  1363. struct unit_data *ud = unit_bl2ud(bl);
  1364. int id = va_arg(ap, int);
  1365. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1366. {
  1367. unit_stop_attack(bl);
  1368. return 1;
  1369. }
  1370. return 0;
  1371. }
  1372. /*==========================================
  1373. *
  1374. *------------------------------------------*/
  1375. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1376. {
  1377. TBL_PC* sd = (TBL_PC*)bl;
  1378. clif_pvpset(sd, 0, 0, 2);
  1379. if (sd->pvp_timer != INVALID_TIMER) {
  1380. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1381. sd->pvp_timer = INVALID_TIMER;
  1382. }
  1383. return 0;
  1384. }
  1385. ACMD_FUNC(pvpoff)
  1386. {
  1387. nullpo_retr(-1, sd);
  1388. if (!map[sd->bl.m].flag.pvp) {
  1389. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1390. return -1;
  1391. }
  1392. map[sd->bl.m].flag.pvp = 0;
  1393. if (!battle_config.pk_mode){
  1394. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1395. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1396. }
  1397. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1398. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1399. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1400. return 0;
  1401. }
  1402. /*==========================================
  1403. *
  1404. *------------------------------------------*/
  1405. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1406. {
  1407. TBL_PC* sd = (TBL_PC*)bl;
  1408. if (sd->pvp_timer == INVALID_TIMER) {
  1409. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1410. sd->pvp_rank = 0;
  1411. sd->pvp_lastusers = 0;
  1412. sd->pvp_point = 5;
  1413. sd->pvp_won = 0;
  1414. sd->pvp_lost = 0;
  1415. }
  1416. return 0;
  1417. }
  1418. ACMD_FUNC(pvpon)
  1419. {
  1420. nullpo_retr(-1, sd);
  1421. if (map[sd->bl.m].flag.pvp) {
  1422. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1423. return -1;
  1424. }
  1425. map[sd->bl.m].flag.pvp = 1;
  1426. if (!battle_config.pk_mode) {// display pvp circle and rank
  1427. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1428. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1429. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1430. }
  1431. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1432. return 0;
  1433. }
  1434. /*==========================================
  1435. *
  1436. *------------------------------------------*/
  1437. ACMD_FUNC(gvgoff)
  1438. {
  1439. nullpo_retr(-1, sd);
  1440. if (!map[sd->bl.m].flag.gvg) {
  1441. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1442. return -1;
  1443. }
  1444. map[sd->bl.m].flag.gvg = 0;
  1445. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1446. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1447. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1448. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1449. return 0;
  1450. }
  1451. /*==========================================
  1452. *
  1453. *------------------------------------------*/
  1454. ACMD_FUNC(gvgon)
  1455. {
  1456. nullpo_retr(-1, sd);
  1457. if (map[sd->bl.m].flag.gvg) {
  1458. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1459. return -1;
  1460. }
  1461. map[sd->bl.m].flag.gvg = 1;
  1462. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1463. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1464. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1465. return 0;
  1466. }
  1467. /*==========================================
  1468. *
  1469. *------------------------------------------*/
  1470. ACMD_FUNC(model)
  1471. {
  1472. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1473. nullpo_retr(-1, sd);
  1474. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1475. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1476. 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>).
  1477. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1478. clif_displaymessage(fd, atcmd_output);
  1479. return -1;
  1480. }
  1481. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1482. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1483. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1484. pc_changelook(sd, LOOK_HAIR, hair_style);
  1485. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1486. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1487. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1488. } else {
  1489. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1490. return -1;
  1491. }
  1492. return 0;
  1493. }
  1494. /*==========================================
  1495. * @dye && @ccolor
  1496. *------------------------------------------*/
  1497. ACMD_FUNC(dye)
  1498. {
  1499. int cloth_color = 0;
  1500. nullpo_retr(-1, sd);
  1501. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1502. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1503. 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>).
  1504. clif_displaymessage(fd, atcmd_output);
  1505. return -1;
  1506. }
  1507. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1508. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1509. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1510. } else {
  1511. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1512. return -1;
  1513. }
  1514. return 0;
  1515. }
  1516. /*==========================================
  1517. * @hairstyle && @hstyle
  1518. *------------------------------------------*/
  1519. ACMD_FUNC(hair_style)
  1520. {
  1521. int hair_style = 0;
  1522. nullpo_retr(-1, sd);
  1523. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1524. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1525. 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>).
  1526. clif_displaymessage(fd, atcmd_output);
  1527. return -1;
  1528. }
  1529. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1530. pc_changelook(sd, LOOK_HAIR, hair_style);
  1531. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1532. } else {
  1533. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1534. return -1;
  1535. }
  1536. return 0;
  1537. }
  1538. /*==========================================
  1539. * @haircolor && @hcolor
  1540. *------------------------------------------*/
  1541. ACMD_FUNC(hair_color)
  1542. {
  1543. int hair_color = 0;
  1544. nullpo_retr(-1, sd);
  1545. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1546. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1547. 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>).
  1548. clif_displaymessage(fd, atcmd_output);
  1549. return -1;
  1550. }
  1551. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1552. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1553. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1554. } else {
  1555. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1556. return -1;
  1557. }
  1558. return 0;
  1559. }
  1560. /*==========================================
  1561. * @go [city_number or city_name] - Updated by Harbin
  1562. *------------------------------------------*/
  1563. ACMD_FUNC(go)
  1564. {
  1565. int i;
  1566. int town;
  1567. char map_name[MAP_NAME_LENGTH];
  1568. int16 m;
  1569. const struct {
  1570. char map[MAP_NAME_LENGTH];
  1571. int x, y;
  1572. } data[] = {
  1573. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1574. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1575. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1576. { MAP_PAYON, 162, 233 }, // 3=Payon
  1577. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1578. #ifdef RENEWAL
  1579. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1580. #else
  1581. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1582. #endif
  1583. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1584. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1585. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1586. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1587. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1588. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1589. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1590. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1591. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1592. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1593. { MAP_JAIL, 23, 61 }, // 16=Prison
  1594. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1595. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1596. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1597. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1598. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1599. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1600. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1601. { MAP_VEINS, 216, 123 }, // 24=Veins
  1602. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1603. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1604. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1605. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1606. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1607. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1608. { MAP_MORA, 44, 151 }, // 31=Mora
  1609. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1610. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1611. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1612. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1613. };
  1614. nullpo_retr(-1, sd);
  1615. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1616. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1617. return 0;
  1618. }
  1619. memset(map_name, '\0', sizeof(map_name));
  1620. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1621. // get the number
  1622. town = atoi(message);
  1623. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1624. {// no value matched so send the list of locations
  1625. const char* text;
  1626. // attempt to find the text help string
  1627. text = atcommand_help_string( command );
  1628. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1629. if( text )
  1630. {// send the text to the client
  1631. clif_displaymessage( fd, text );
  1632. }
  1633. return -1;
  1634. }
  1635. // get possible name of the city
  1636. map_name[MAP_NAME_LENGTH-1] = '\0';
  1637. for (i = 0; map_name[i]; i++)
  1638. map_name[i] = TOLOWER(map_name[i]);
  1639. // try to identify the map name
  1640. if (strncmp(map_name, "prontera", 3) == 0) {
  1641. town = 0;
  1642. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1643. strncmp(map_name, "morroc", 4) == 0) {
  1644. town = 1;
  1645. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1646. town = 2;
  1647. } else if (strncmp(map_name, "payon", 3) == 0) {
  1648. town = 3;
  1649. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1650. town = 4;
  1651. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1652. town = 5;
  1653. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1654. town = 6;
  1655. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1656. strcmp(map_name, "christmas") == 0 ||
  1657. strncmp(map_name, "xmas", 3) == 0 ||
  1658. strncmp(map_name, "x-mas", 3) == 0) {
  1659. town = 7;
  1660. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1661. town = 8;
  1662. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1663. strncmp(map_name, "yuno", 3) == 0) {
  1664. town = 9;
  1665. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1666. town = 10;
  1667. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1668. strncmp(map_name, "gonryun", 3) == 0) {
  1669. town = 11;
  1670. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1671. town = 12;
  1672. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1673. town = 13;
  1674. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1675. town = 14;
  1676. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1677. strncmp(map_name, "startpoint", 3) == 0 ||
  1678. strncmp(map_name, "beginning", 3) == 0) {
  1679. town = 15;
  1680. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1681. strncmp(map_name, "prison", 3) == 0 ||
  1682. strncmp(map_name, "jail", 3) == 0) {
  1683. town = 16;
  1684. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1685. town = 17;
  1686. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1687. town = 18;
  1688. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1689. town = 19;
  1690. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1691. town = 20;
  1692. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1693. town = 21;
  1694. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1695. town = 22;
  1696. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1697. town = 23;
  1698. } else if (strncmp(map_name, "veins", 3) == 0) {
  1699. town = 24;
  1700. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1701. town = 25;
  1702. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1703. town = 26;
  1704. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1705. town = 27;
  1706. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1707. town = 28;
  1708. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1709. town = 29;
  1710. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1711. town = 30;
  1712. } else if (strcmp(map_name, "mora") == 0) {
  1713. town = 31;
  1714. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1715. town = 32;
  1716. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1717. town = 33;
  1718. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1719. town = 34;
  1720. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1721. town = 35;
  1722. }
  1723. if (town >= 0 && town < ARRAYLENGTH(data))
  1724. {
  1725. m = map_mapname2mapid(data[town].map);
  1726. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1727. clif_displaymessage(fd, msg_txt(sd,247));
  1728. return -1;
  1729. }
  1730. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1731. clif_displaymessage(fd, msg_txt(sd,248));
  1732. return -1;
  1733. }
  1734. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1735. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1736. } else {
  1737. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1738. return -1;
  1739. }
  1740. } else { // if you arrive here, you have an error in town variable when reading of names
  1741. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1742. return -1;
  1743. }
  1744. return 0;
  1745. }
  1746. /*==========================================
  1747. *
  1748. *------------------------------------------*/
  1749. ACMD_FUNC(monster)
  1750. {
  1751. char name[NAME_LENGTH];
  1752. char monster[NAME_LENGTH];
  1753. char eventname[EVENT_NAME_LENGTH] = "";
  1754. int mob_id;
  1755. int number = 0;
  1756. int count;
  1757. int i, range;
  1758. short mx, my;
  1759. unsigned int size;
  1760. nullpo_retr(-1, sd);
  1761. memset(name, '\0', sizeof(name));
  1762. memset(monster, '\0', sizeof(monster));
  1763. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1764. if (!message || !*message) {
  1765. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1766. return -1;
  1767. }
  1768. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1769. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1770. //All data can be left as it is.
  1771. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1772. //Here, it is possible name was not given and we are using monster for it.
  1773. if (count < 3) //Blank mob's name.
  1774. name[0] = '\0';
  1775. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1776. //All data can be left as it is.
  1777. } else if (sscanf(message, "%23s", monster) > 0) {
  1778. //As before, name may be already filled.
  1779. name[0] = '\0';
  1780. } else {
  1781. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1782. return -1;
  1783. }
  1784. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1785. mob_id = mobdb_checkid(atoi(monster));
  1786. if (mob_id == 0) {
  1787. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1788. return -1;
  1789. }
  1790. if (mob_id == MOBID_EMPERIUM) {
  1791. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1792. return -1;
  1793. }
  1794. if (number <= 0)
  1795. number = 1;
  1796. if( !name[0] )
  1797. strcpy(name, "--ja--");
  1798. // 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
  1799. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1800. number = battle_config.atc_spawn_quantity_limit;
  1801. if (strcmp(command+1, "monstersmall") == 0)
  1802. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1803. else if (strcmp(command+1, "monsterbig") == 0)
  1804. size = SZ_BIG;
  1805. else
  1806. size = SZ_SMALL;
  1807. if (battle_config.etc_log)
  1808. 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);
  1809. count = 0;
  1810. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1811. for (i = 0; i < number; i++) {
  1812. int k;
  1813. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1814. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1815. if(k) {
  1816. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1817. count ++;
  1818. }
  1819. }
  1820. if (count != 0)
  1821. if (number == count)
  1822. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1823. else {
  1824. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1825. clif_displaymessage(fd, atcmd_output);
  1826. }
  1827. else {
  1828. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1829. return -1;
  1830. }
  1831. return 0;
  1832. }
  1833. /*==========================================
  1834. *
  1835. *------------------------------------------*/
  1836. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1837. {
  1838. struct mob_data *md;
  1839. int flag;
  1840. nullpo_ret(md=(struct mob_data *)bl);
  1841. flag = va_arg(ap, int);
  1842. if (md->guardian_data)
  1843. return 0; //Do not touch WoE mobs!
  1844. if (flag)
  1845. status_zap(bl,md->status.hp, 0);
  1846. else
  1847. status_kill(bl);
  1848. return 1;
  1849. }
  1850. ACMD_FUNC(killmonster)
  1851. {
  1852. int map_id, drop_flag;
  1853. char map_name[MAP_NAME_LENGTH_EXT];
  1854. nullpo_retr(-1, sd);
  1855. memset(map_name, '\0', sizeof(map_name));
  1856. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1857. map_id = sd->bl.m;
  1858. else {
  1859. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1860. map_id = sd->bl.m;
  1861. }
  1862. drop_flag = strcmp(command+1, "killmonster2");
  1863. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1864. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1865. return 0;
  1866. }
  1867. /*==========================================
  1868. *
  1869. *------------------------------------------*/
  1870. ACMD_FUNC(refine)
  1871. {
  1872. int j, position = 0, refine = 0, current_position, final_refine;
  1873. int count;
  1874. nullpo_retr(-1, sd);
  1875. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1876. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1877. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1878. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1879. clif_displaymessage(fd, atcmd_output);
  1880. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1881. clif_displaymessage(fd, atcmd_output);
  1882. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1883. clif_displaymessage(fd, atcmd_output);
  1884. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1885. clif_displaymessage(fd, atcmd_output);
  1886. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1887. clif_displaymessage(fd, atcmd_output);
  1888. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1889. clif_displaymessage(fd, atcmd_output);
  1890. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1891. clif_displaymessage(fd, atcmd_output);
  1892. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1893. clif_displaymessage(fd, atcmd_output);
  1894. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1895. clif_displaymessage(fd, atcmd_output);
  1896. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1897. clif_displaymessage(fd, atcmd_output);
  1898. return -1;
  1899. }
  1900. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1901. count = 0;
  1902. for (j = 0; j < EQI_MAX; j++) {
  1903. int i;
  1904. if ((i = sd->equip_index[j]) < 0)
  1905. continue;
  1906. if(j == EQI_AMMO)
  1907. continue;
  1908. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1909. continue;
  1910. if(position && !(sd->status.inventory[i].equip & position))
  1911. continue;
  1912. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1913. if (sd->status.inventory[i].refine != final_refine) {
  1914. sd->status.inventory[i].refine = final_refine;
  1915. current_position = sd->status.inventory[i].equip;
  1916. pc_unequipitem(sd, i, 3);
  1917. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1918. clif_delitem(sd, i, 1, 3);
  1919. clif_additem(sd, i, 1, 0);
  1920. pc_equipitem(sd, i, current_position);
  1921. clif_misceffect(&sd->bl, 3);
  1922. count++;
  1923. }
  1924. }
  1925. if (count == 0)
  1926. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1927. else if (count == 1)
  1928. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1929. else {
  1930. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1931. clif_displaymessage(fd, atcmd_output);
  1932. }
  1933. return 0;
  1934. }
  1935. /*==========================================
  1936. *
  1937. *------------------------------------------*/
  1938. ACMD_FUNC(produce)
  1939. {
  1940. char item_name[100];
  1941. unsigned short item_id;
  1942. int attribute = 0, star = 0;
  1943. struct item_data *item_data;
  1944. struct item tmp_item;
  1945. nullpo_retr(-1, sd);
  1946. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1947. memset(item_name, '\0', sizeof(item_name));
  1948. if (!message || !*message || (
  1949. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  1950. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  1951. )) {
  1952. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1953. return -1;
  1954. }
  1955. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1956. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1957. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1958. return -1;
  1959. }
  1960. item_id = item_data->nameid;
  1961. if (itemdb_isequip2(item_data)) {
  1962. char flag = 0;
  1963. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1964. attribute = ATTRIBUTE_NORMAL;
  1965. if (star < MIN_STAR || star > MAX_STAR)
  1966. star = 0;
  1967. memset(&tmp_item, 0, sizeof tmp_item);
  1968. tmp_item.nameid = item_id;
  1969. tmp_item.amount = 1;
  1970. tmp_item.identify = 1;
  1971. tmp_item.card[0] = CARD0_FORGE;
  1972. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1973. ((star*5) << 8) + attribute:0;
  1974. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1975. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1976. clif_produceeffect(sd, 0, item_id);
  1977. clif_misceffect(&sd->bl, 3);
  1978. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1979. clif_additem(sd, 0, 0, flag);
  1980. } else {
  1981. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  1982. clif_displaymessage(fd, atcmd_output);
  1983. return -1;
  1984. }
  1985. return 0;
  1986. }
  1987. /*==========================================
  1988. *
  1989. *------------------------------------------*/
  1990. ACMD_FUNC(memo)
  1991. {
  1992. int position = 0;
  1993. nullpo_retr(-1, sd);
  1994. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1995. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  1996. {
  1997. int i;
  1998. clif_displaymessage(sd->fd, msg_txt(sd,668));
  1999. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2000. {
  2001. if( sd->status.memo_point[i].map )
  2002. 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);
  2003. else
  2004. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2005. clif_displaymessage(sd->fd, atcmd_output);
  2006. }
  2007. return 0;
  2008. }
  2009. if( position < 0 || position >= MAX_MEMOPOINTS )
  2010. {
  2011. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2012. clif_displaymessage(fd, atcmd_output);
  2013. return -1;
  2014. }
  2015. return !pc_memo( sd, position );
  2016. }
  2017. /*==========================================
  2018. *
  2019. *------------------------------------------*/
  2020. ACMD_FUNC(gat)
  2021. {
  2022. int y;
  2023. nullpo_retr(-1, sd);
  2024. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2025. for (y = 2; y >= -2; y--) {
  2026. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2027. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2028. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2029. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2030. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2031. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2032. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2033. clif_displaymessage(fd, atcmd_output);
  2034. }
  2035. return 0;
  2036. }
  2037. /*==========================================
  2038. *
  2039. *------------------------------------------*/
  2040. ACMD_FUNC(displaystatus)
  2041. {
  2042. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2043. nullpo_retr(-1, sd);
  2044. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2045. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2046. return -1;
  2047. }
  2048. if (i < 2) flag = 1;
  2049. if (i < 3) tick = 0;
  2050. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2051. return 0;
  2052. }
  2053. /*==========================================
  2054. * @stpoint (Rewritten by [Yor])
  2055. *------------------------------------------*/
  2056. ACMD_FUNC(statuspoint)
  2057. {
  2058. int point;
  2059. unsigned int new_status_point;
  2060. if (!message || !*message || (point = atoi(message)) == 0) {
  2061. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2062. return -1;
  2063. }
  2064. if(point < 0)
  2065. {
  2066. if(sd->status.status_point < (unsigned int)(-point))
  2067. {
  2068. new_status_point = 0;
  2069. }
  2070. else
  2071. {
  2072. new_status_point = sd->status.status_point + point;
  2073. }
  2074. }
  2075. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2076. {
  2077. new_status_point = UINT_MAX;
  2078. }
  2079. else
  2080. {
  2081. new_status_point = sd->status.status_point + point;
  2082. }
  2083. if (new_status_point != sd->status.status_point) {
  2084. sd->status.status_point = new_status_point;
  2085. clif_updatestatus(sd, SP_STATUSPOINT);
  2086. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2087. } else {
  2088. if (point < 0)
  2089. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2090. else
  2091. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2092. return -1;
  2093. }
  2094. return 0;
  2095. }
  2096. /*==========================================
  2097. * @skpoint (Rewritten by [Yor])
  2098. *------------------------------------------*/
  2099. ACMD_FUNC(skillpoint)
  2100. {
  2101. int point;
  2102. unsigned int new_skill_point;
  2103. nullpo_retr(-1, sd);
  2104. if (!message || !*message || (point = atoi(message)) == 0) {
  2105. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2106. return -1;
  2107. }
  2108. if(point < 0)
  2109. {
  2110. if(sd->status.skill_point < (unsigned int)(-point))
  2111. {
  2112. new_skill_point = 0;
  2113. }
  2114. else
  2115. {
  2116. new_skill_point = sd->status.skill_point + point;
  2117. }
  2118. }
  2119. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2120. {
  2121. new_skill_point = UINT_MAX;
  2122. }
  2123. else
  2124. {
  2125. new_skill_point = sd->status.skill_point + point;
  2126. }
  2127. if (new_skill_point != sd->status.skill_point) {
  2128. sd->status.skill_point = new_skill_point;
  2129. clif_updatestatus(sd, SP_SKILLPOINT);
  2130. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2131. } else {
  2132. if (point < 0)
  2133. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2134. else
  2135. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2136. return -1;
  2137. }
  2138. return 0;
  2139. }
  2140. /*==========================================
  2141. * @zeny
  2142. *------------------------------------------*/
  2143. ACMD_FUNC(zeny)
  2144. {
  2145. int zeny=0, ret=-1;
  2146. nullpo_retr(-1, sd);
  2147. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2148. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2149. return -1;
  2150. }
  2151. if(zeny > 0){
  2152. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2153. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2154. }
  2155. else {
  2156. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2157. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2158. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2159. }
  2160. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2161. return 0;
  2162. }
  2163. /*==========================================
  2164. *
  2165. *------------------------------------------*/
  2166. ACMD_FUNC(param)
  2167. {
  2168. uint8 i;
  2169. int value = 0;
  2170. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2171. short new_value, *status[6], max_status[6];
  2172. //we don't use direct initialization because it isn't part of the c standard.
  2173. nullpo_retr(-1, sd);
  2174. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2175. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2176. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2177. return -1;
  2178. }
  2179. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2180. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2181. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2182. return -1;
  2183. }
  2184. status[0] = &sd->status.str;
  2185. status[1] = &sd->status.agi;
  2186. status[2] = &sd->status.vit;
  2187. status[3] = &sd->status.int_;
  2188. status[4] = &sd->status.dex;
  2189. status[5] = &sd->status.luk;
  2190. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2191. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2192. else {
  2193. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2194. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2195. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2196. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2197. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2198. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2199. }
  2200. if(value > 0 && *status[i] + value >= max_status[i])
  2201. new_value = max_status[i];
  2202. else if(value < 0 && *status[i] <= -value)
  2203. new_value = 1;
  2204. else
  2205. new_value = *status[i] + value;
  2206. if (new_value != *status[i]) {
  2207. *status[i] = new_value;
  2208. clif_updatestatus(sd, SP_STR + i);
  2209. clif_updatestatus(sd, SP_USTR + i);
  2210. status_calc_pc(sd, SCO_FORCE);
  2211. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2212. } else {
  2213. if (value < 0)
  2214. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2215. else
  2216. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2217. return -1;
  2218. }
  2219. return 0;
  2220. }
  2221. /*==========================================
  2222. * Stat all by fritz (rewritten by [Yor])
  2223. *------------------------------------------*/
  2224. ACMD_FUNC(stat_all)
  2225. {
  2226. int value = 0;
  2227. uint8 count, i;
  2228. short *status[PARAM_MAX], max_status[PARAM_MAX];
  2229. //we don't use direct initialization because it isn't part of the c standard.
  2230. nullpo_retr(-1, sd);
  2231. status[0] = &sd->status.str;
  2232. status[1] = &sd->status.agi;
  2233. status[2] = &sd->status.vit;
  2234. status[3] = &sd->status.int_;
  2235. status[4] = &sd->status.dex;
  2236. status[5] = &sd->status.luk;
  2237. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2238. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2239. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2240. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2241. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2242. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2243. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2244. value = SHRT_MAX;
  2245. } else {
  2246. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2247. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2248. else {
  2249. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2250. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2251. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2252. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2253. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2254. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2255. }
  2256. }
  2257. count = 0;
  2258. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2259. short new_value;
  2260. if (value > 0 && *status[i] + value >= max_status[i])
  2261. new_value = max_status[i];
  2262. else if (value < 0 && *status[i] <= -value)
  2263. new_value = 1;
  2264. else
  2265. new_value = *status[i] + value;
  2266. if (new_value != *status[i]) {
  2267. *status[i] = new_value;
  2268. clif_updatestatus(sd, SP_STR + i);
  2269. clif_updatestatus(sd, SP_USTR + i);
  2270. count++;
  2271. }
  2272. }
  2273. if (count > 0) { // if at least 1 stat modified
  2274. status_calc_pc(sd, SCO_FORCE);
  2275. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2276. } else {
  2277. if (value < 0)
  2278. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2279. else
  2280. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2281. return -1;
  2282. }
  2283. return 0;
  2284. }
  2285. /*==========================================
  2286. *
  2287. *------------------------------------------*/
  2288. ACMD_FUNC(guildlevelup) {
  2289. int level = 0;
  2290. short added_level;
  2291. struct guild *guild_info;
  2292. nullpo_retr(-1, sd);
  2293. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2294. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2295. return -1;
  2296. }
  2297. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2298. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2299. return -1;
  2300. }
  2301. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2302. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2303. // return -1;
  2304. //}
  2305. added_level = (short)level;
  2306. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2307. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2308. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2309. added_level = 1 - guild_info->guild_lv;
  2310. if (added_level != 0) {
  2311. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2312. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2313. } else {
  2314. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2315. return -1;
  2316. }
  2317. return 0;
  2318. }
  2319. /*==========================================
  2320. *
  2321. *------------------------------------------*/
  2322. ACMD_FUNC(makeegg) {
  2323. struct item_data *item_data;
  2324. int id, pet_id;
  2325. nullpo_retr(-1, sd);
  2326. if (!message || !*message) {
  2327. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2328. return -1;
  2329. }
  2330. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2331. id = item_data->nameid;
  2332. else
  2333. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2334. ;
  2335. else
  2336. id = atoi(message);
  2337. pet_id = search_petDB_index(id, PET_CLASS);
  2338. if (pet_id < 0)
  2339. pet_id = search_petDB_index(id, PET_EGG);
  2340. if (pet_id >= 0) {
  2341. sd->catch_target_class = pet_db[pet_id].class_;
  2342. intif_create_pet(
  2343. sd->status.account_id, sd->status.char_id,
  2344. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2345. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2346. 100, 0, 1, pet_db[pet_id].jname);
  2347. } else {
  2348. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2349. return -1;
  2350. }
  2351. return 0;
  2352. }
  2353. /*==========================================
  2354. *
  2355. *------------------------------------------*/
  2356. ACMD_FUNC(hatch) {
  2357. nullpo_retr(-1, sd);
  2358. if (sd->status.pet_id <= 0)
  2359. clif_sendegg(sd);
  2360. else {
  2361. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2362. return -1;
  2363. }
  2364. return 0;
  2365. }
  2366. /*==========================================
  2367. *
  2368. *------------------------------------------*/
  2369. ACMD_FUNC(petfriendly) {
  2370. int friendly;
  2371. struct pet_data *pd;
  2372. nullpo_retr(-1, sd);
  2373. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2374. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2375. return -1;
  2376. }
  2377. pd = sd->pd;
  2378. if (!pd) {
  2379. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2380. return -1;
  2381. }
  2382. if (friendly < 0 || friendly > 1000)
  2383. {
  2384. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2385. return -1;
  2386. }
  2387. if (friendly == pd->pet.intimate) {
  2388. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2389. return -1;
  2390. }
  2391. pet_set_intimate(pd, friendly);
  2392. clif_send_petstatus(sd);
  2393. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2394. return 0;
  2395. }
  2396. /*==========================================
  2397. *
  2398. *------------------------------------------*/
  2399. ACMD_FUNC(pethungry)
  2400. {
  2401. int hungry;
  2402. struct pet_data *pd;
  2403. nullpo_retr(-1, sd);
  2404. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2405. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2406. return -1;
  2407. }
  2408. pd = sd->pd;
  2409. if (!sd->status.pet_id || !pd) {
  2410. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2411. return -1;
  2412. }
  2413. if (hungry < 0 || hungry > 100) {
  2414. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2415. return -1;
  2416. }
  2417. if (hungry == pd->pet.hungry) {
  2418. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2419. return -1;
  2420. }
  2421. pd->pet.hungry = hungry;
  2422. clif_send_petstatus(sd);
  2423. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2424. return 0;
  2425. }
  2426. /*==========================================
  2427. *
  2428. *------------------------------------------*/
  2429. ACMD_FUNC(petrename)
  2430. {
  2431. struct pet_data *pd;
  2432. nullpo_retr(-1, sd);
  2433. if (!sd->status.pet_id || !sd->pd) {
  2434. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2435. return -1;
  2436. }
  2437. pd = sd->pd;
  2438. if (!pd->pet.rename_flag) {
  2439. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2440. return -1;
  2441. }
  2442. pd->pet.rename_flag = 0;
  2443. intif_save_petdata(sd->status.account_id, &pd->pet);
  2444. clif_send_petstatus(sd);
  2445. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2446. return 0;
  2447. }
  2448. /*==========================================
  2449. *
  2450. *------------------------------------------*/
  2451. ACMD_FUNC(recall) {
  2452. struct map_session_data *pl_sd = NULL;
  2453. nullpo_retr(-1, sd);
  2454. if (!message || !*message) {
  2455. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2456. return -1;
  2457. }
  2458. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2459. {
  2460. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2461. return -1;
  2462. }
  2463. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2464. {
  2465. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2466. return -1;
  2467. }
  2468. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2469. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2470. return -1;
  2471. }
  2472. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2473. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2474. return -1;
  2475. }
  2476. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2477. return -1;
  2478. }
  2479. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2480. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2481. clif_displaymessage(fd, atcmd_output);
  2482. return 0;
  2483. }
  2484. /*==========================================
  2485. * charblock command (usage: charblock <player_name>)
  2486. * This command do a definitiv ban on a player
  2487. *------------------------------------------*/
  2488. ACMD_FUNC(char_block)
  2489. {
  2490. nullpo_retr(-1, sd);
  2491. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2492. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2493. clif_displaymessage(fd, msg_txt(sd,1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2494. return -1;
  2495. }
  2496. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0); // type: 1 - block
  2497. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2498. return 0;
  2499. }
  2500. /*==========================================
  2501. * accountban command (usage: ban <%time> <player_name>)
  2502. * charban command (usage: charban <%time> <player_name>)
  2503. * %time see common/timer.c::solve_time()
  2504. *------------------------------------------*/
  2505. ACMD_FUNC(char_ban)
  2506. {
  2507. char * modif_p;
  2508. int32 timediff=0; //don't set this as uint as we may want to decrease banned time
  2509. int bantype=0; //2=account block, 6=char specific
  2510. nullpo_retr(-1, sd);
  2511. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2512. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2513. bantype = strcmpi(command+1,"charban")?2:6; //! FIXME this breaking alias recognition
  2514. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2515. clif_displaymessage(fd, msg_txt(sd,1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2516. return -1;
  2517. }
  2518. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2519. modif_p = atcmd_output;
  2520. timediff = (int32)solve_time(modif_p); //discard seconds
  2521. if (timediff == 0) { //allow negative ?
  2522. char output[256];
  2523. safesnprintf(output,sizeof(output),msg_txt(sd,85),bantype==6?"charban":"ban",timediff); // Invalid time for %s command (time=%d)
  2524. clif_displaymessage(fd, output);
  2525. 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.
  2526. return -1;
  2527. }
  2528. if( timediff<0 && (
  2529. ( bantype==2 && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) )
  2530. || ( bantype==6 && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND)) )
  2531. ){
  2532. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2533. return -1;
  2534. }
  2535. if(bantype==2)
  2536. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 2, timediff, 0, 0); // type: 2 - ban
  2537. else
  2538. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2539. {
  2540. char output[256];
  2541. safesnprintf(output,sizeof(output),msg_txt(sd,88),bantype==6?"char":"login"); // Sending request to %s server...
  2542. clif_displaymessage(fd, output);
  2543. }
  2544. return 0;
  2545. }
  2546. /*==========================================
  2547. * charunblock command (usage: charunblock <player_name>)
  2548. *------------------------------------------*/
  2549. ACMD_FUNC(char_unblock)
  2550. {
  2551. nullpo_retr(-1, sd);
  2552. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2553. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2554. clif_displaymessage(fd, msg_txt(sd,1024)); // Please enter a player name (usage: @charunblock <char name>).
  2555. return -1;
  2556. }
  2557. // send answer to login server via char-server
  2558. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0); // type: 3 - unblock
  2559. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2560. return 0;
  2561. }
  2562. /*==========================================
  2563. * acc unban command (usage: unban <player_name>)
  2564. * char unban command (usage: charunban <player_name>)
  2565. *------------------------------------------*/
  2566. ACMD_FUNC(char_unban){
  2567. int unbantype=0;
  2568. nullpo_retr(-1, sd);
  2569. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2570. unbantype = strcmpi(command+1,"charunban")?4:7; //! FIXME this breaking alias recognition
  2571. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2572. if(unbantype==4) clif_displaymessage(fd, msg_txt(sd,1025)); // Please enter a player name (usage: @unblock <char name>).
  2573. else clif_displaymessage(fd, msg_txt(sd,435)); //Please enter a player name (usage: @charunban <char name>).
  2574. return -1;
  2575. }
  2576. if(unbantype==4) // send answer to login server via char-server
  2577. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0); // type: 4 - unban
  2578. else //directly unban via char-serv
  2579. chrif_req_charunban(sd->status.char_id);
  2580. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2581. return 0;
  2582. }
  2583. /*==========================================
  2584. *
  2585. *------------------------------------------*/
  2586. ACMD_FUNC(night)
  2587. {
  2588. nullpo_retr(-1, sd);
  2589. if (night_flag != 1) {
  2590. map_night_timer(night_timer_tid, 0, 0, 1);
  2591. } else {
  2592. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2593. return -1;
  2594. }
  2595. return 0;
  2596. }
  2597. /*==========================================
  2598. *
  2599. *------------------------------------------*/
  2600. ACMD_FUNC(day)
  2601. {
  2602. nullpo_retr(-1, sd);
  2603. if (night_flag != 0) {
  2604. map_day_timer(day_timer_tid, 0, 0, 1);
  2605. } else {
  2606. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2607. return -1;
  2608. }
  2609. return 0;
  2610. }
  2611. /*==========================================
  2612. *
  2613. *------------------------------------------*/
  2614. ACMD_FUNC(doom)
  2615. {
  2616. struct map_session_data* pl_sd;
  2617. struct s_mapiterator* iter;
  2618. nullpo_retr(-1, sd);
  2619. iter = mapit_getallusers();
  2620. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2621. {
  2622. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2623. {
  2624. status_kill(&pl_sd->bl);
  2625. clif_specialeffect(&pl_sd->bl,450,AREA);
  2626. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2627. }
  2628. }
  2629. mapit_free(iter);
  2630. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2631. return 0;
  2632. }
  2633. /*==========================================
  2634. *
  2635. *------------------------------------------*/
  2636. ACMD_FUNC(doommap)
  2637. {
  2638. struct map_session_data* pl_sd;
  2639. struct s_mapiterator* iter;
  2640. nullpo_retr(-1, sd);
  2641. iter = mapit_getallusers();
  2642. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2643. {
  2644. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2645. {
  2646. status_kill(&pl_sd->bl);
  2647. clif_specialeffect(&pl_sd->bl,450,AREA);
  2648. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2649. }
  2650. }
  2651. mapit_free(iter);
  2652. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2653. return 0;
  2654. }
  2655. /*==========================================
  2656. *
  2657. *------------------------------------------*/
  2658. static void atcommand_raise_sub(struct map_session_data* sd) {
  2659. status_revive(&sd->bl, 100, 100);
  2660. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2661. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2662. }
  2663. /*==========================================
  2664. *
  2665. *------------------------------------------*/
  2666. ACMD_FUNC(raise)
  2667. {
  2668. struct map_session_data* pl_sd;
  2669. struct s_mapiterator* iter;
  2670. nullpo_retr(-1, sd);
  2671. iter = mapit_getallusers();
  2672. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2673. if( pc_isdead(pl_sd) )
  2674. atcommand_raise_sub(pl_sd);
  2675. mapit_free(iter);
  2676. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2677. return 0;
  2678. }
  2679. /*==========================================
  2680. *
  2681. *------------------------------------------*/
  2682. ACMD_FUNC(raisemap)
  2683. {
  2684. struct map_session_data* pl_sd;
  2685. struct s_mapiterator* iter;
  2686. nullpo_retr(-1, sd);
  2687. iter = mapit_getallusers();
  2688. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2689. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2690. atcommand_raise_sub(pl_sd);
  2691. mapit_free(iter);
  2692. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2693. return 0;
  2694. }
  2695. /*==========================================
  2696. *
  2697. *------------------------------------------*/
  2698. ACMD_FUNC(kick)
  2699. {
  2700. struct map_session_data *pl_sd;
  2701. nullpo_retr(-1, sd);
  2702. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2703. if (!message || !*message) {
  2704. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2705. return -1;
  2706. }
  2707. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2708. {
  2709. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2710. return -1;
  2711. }
  2712. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2713. {
  2714. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2715. return -1;
  2716. }
  2717. clif_GM_kick(sd, pl_sd);
  2718. return 0;
  2719. }
  2720. /*==========================================
  2721. *
  2722. *------------------------------------------*/
  2723. ACMD_FUNC(kickall)
  2724. {
  2725. struct map_session_data* pl_sd;
  2726. struct s_mapiterator* iter;
  2727. nullpo_retr(-1, sd);
  2728. iter = mapit_getallusers();
  2729. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2730. {
  2731. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2732. if (sd->status.account_id != pl_sd->status.account_id)
  2733. clif_GM_kick(NULL, pl_sd);
  2734. }
  2735. }
  2736. mapit_free(iter);
  2737. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2738. return 0;
  2739. }
  2740. /*==========================================
  2741. *
  2742. *------------------------------------------*/
  2743. ACMD_FUNC(allskill)
  2744. {
  2745. nullpo_retr(-1, sd);
  2746. pc_allskillup(sd); // all skills
  2747. sd->status.skill_point = 0; // 0 skill points
  2748. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2749. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2750. return 0;
  2751. }
  2752. /*==========================================
  2753. *
  2754. *------------------------------------------*/
  2755. ACMD_FUNC(questskill)
  2756. {
  2757. uint16 skill_id;
  2758. nullpo_retr(-1, sd);
  2759. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2760. {// also send a list of skills applicable to this command
  2761. const char* text;
  2762. // attempt to find the text corresponding to this command
  2763. text = atcommand_help_string( command );
  2764. // send the error message as always
  2765. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2766. if( text )
  2767. {// send the skill ID list associated with this command
  2768. clif_displaymessage( fd, text );
  2769. }
  2770. return -1;
  2771. }
  2772. if (skill_id >= MAX_SKILL_DB) {
  2773. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2774. return -1;
  2775. }
  2776. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2777. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2778. return -1;
  2779. }
  2780. if (pc_checkskill(sd, skill_id) > 0) {
  2781. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2782. return -1;
  2783. }
  2784. pc_skill(sd, skill_id, 1, 0);
  2785. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2786. return 0;
  2787. }
  2788. /*==========================================
  2789. *
  2790. *------------------------------------------*/
  2791. ACMD_FUNC(lostskill)
  2792. {
  2793. uint16 skill_id;
  2794. nullpo_retr(-1, sd);
  2795. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2796. {// also send a list of skills applicable to this command
  2797. const char* text;
  2798. // attempt to find the text corresponding to this command
  2799. text = atcommand_help_string( command );
  2800. // send the error message as always
  2801. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2802. if( text )
  2803. {// send the skill ID list associated with this command
  2804. clif_displaymessage( fd, text );
  2805. }
  2806. return -1;
  2807. }
  2808. if (skill_id >= MAX_SKILL) {
  2809. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2810. return -1;
  2811. }
  2812. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2813. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2814. return -1;
  2815. }
  2816. if (pc_checkskill(sd, skill_id) == 0) {
  2817. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2818. return -1;
  2819. }
  2820. sd->status.skill[skill_id].lv = 0;
  2821. sd->status.skill[skill_id].flag = SKILL_FLAG_PERMANENT;
  2822. clif_deleteskill(sd,skill_id);
  2823. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2824. return 0;
  2825. }
  2826. /*==========================================
  2827. *
  2828. *------------------------------------------*/
  2829. ACMD_FUNC(spiritball)
  2830. {
  2831. int max_spiritballs;
  2832. int number;
  2833. nullpo_retr(-1, sd);
  2834. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2835. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2836. {
  2837. char msg[CHAT_SIZE_MAX];
  2838. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2839. clif_displaymessage(fd, msg);
  2840. return -1;
  2841. }
  2842. if( sd->spiritball > 0 )
  2843. pc_delspiritball(sd, sd->spiritball, 1);
  2844. sd->spiritball = number;
  2845. clif_spiritball(&sd->bl);
  2846. // no message, player can look the difference
  2847. return 0;
  2848. }
  2849. /*==========================================
  2850. *
  2851. *------------------------------------------*/
  2852. ACMD_FUNC(party)
  2853. {
  2854. char party[NAME_LENGTH];
  2855. nullpo_retr(-1, sd);
  2856. memset(party, '\0', sizeof(party));
  2857. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2858. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2859. return -1;
  2860. }
  2861. party_create(sd, party, 0, 0);
  2862. return 0;
  2863. }
  2864. /*==========================================
  2865. *
  2866. *------------------------------------------*/
  2867. ACMD_FUNC(guild)
  2868. {
  2869. char guild[NAME_LENGTH];
  2870. int prev;
  2871. nullpo_retr(-1, sd);
  2872. memset(guild, '\0', sizeof(guild));
  2873. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2874. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2875. return -1;
  2876. }
  2877. prev = battle_config.guild_emperium_check;
  2878. battle_config.guild_emperium_check = 0;
  2879. guild_create(sd, guild);
  2880. battle_config.guild_emperium_check = prev;
  2881. return 0;
  2882. }
  2883. ACMD_FUNC(breakguild)
  2884. {
  2885. nullpo_retr(-1, sd);
  2886. if (sd->status.guild_id) { // Check if the player has a guild
  2887. struct guild *g;
  2888. g = sd->guild; // Search the guild
  2889. if (g) { // Check if guild was found
  2890. if (sd->state.gmaster_flag) { // Check if player is guild master
  2891. int ret = 0;
  2892. ret = guild_break(sd, g->name); // Break guild
  2893. if (ret) { // Check if anything went wrong
  2894. return 0; // Guild was broken
  2895. } else {
  2896. return -1; // Something went wrong
  2897. }
  2898. } else { // Not guild master
  2899. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2900. return -1;
  2901. }
  2902. } else { // Guild was not found. HOW?
  2903. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2904. return -1;
  2905. }
  2906. } else { // Player does not have a guild
  2907. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2908. return -1;
  2909. }
  2910. return 0;
  2911. }
  2912. /*==========================================
  2913. *
  2914. *------------------------------------------*/
  2915. ACMD_FUNC(agitstart)
  2916. {
  2917. nullpo_retr(-1, sd);
  2918. if (agit_flag == 1) {
  2919. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2920. return -1;
  2921. }
  2922. agit_flag = 1;
  2923. guild_agit_start();
  2924. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2925. return 0;
  2926. }
  2927. /*==========================================
  2928. *
  2929. *------------------------------------------*/
  2930. ACMD_FUNC(agitstart2)
  2931. {
  2932. nullpo_retr(-1, sd);
  2933. if (agit2_flag == 1) {
  2934. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2935. return -1;
  2936. }
  2937. agit2_flag = 1;
  2938. guild_agit2_start();
  2939. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2940. return 0;
  2941. }
  2942. /*==========================================
  2943. *
  2944. *------------------------------------------*/
  2945. ACMD_FUNC(agitend)
  2946. {
  2947. nullpo_retr(-1, sd);
  2948. if (agit_flag == 0) {
  2949. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  2950. return -1;
  2951. }
  2952. agit_flag = 0;
  2953. guild_agit_end();
  2954. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  2955. return 0;
  2956. }
  2957. /*==========================================
  2958. *
  2959. *------------------------------------------*/
  2960. ACMD_FUNC(agitend2)
  2961. {
  2962. nullpo_retr(-1, sd);
  2963. if (agit2_flag == 0) {
  2964. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  2965. return -1;
  2966. }
  2967. agit2_flag = 0;
  2968. guild_agit2_end();
  2969. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  2970. return 0;
  2971. }
  2972. /*==========================================
  2973. * @mapexit - shuts down the map server
  2974. *------------------------------------------*/
  2975. ACMD_FUNC(mapexit)
  2976. {
  2977. nullpo_retr(-1, sd);
  2978. do_shutdown();
  2979. return 0;
  2980. }
  2981. /*==========================================
  2982. * idsearch <part_of_name>: revrited by [Yor]
  2983. *------------------------------------------*/
  2984. ACMD_FUNC(idsearch)
  2985. {
  2986. char item_name[100];
  2987. unsigned int i, match;
  2988. struct item_data *item_array[MAX_SEARCH];
  2989. nullpo_retr(-1, sd);
  2990. memset(item_name, '\0', sizeof(item_name));
  2991. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2992. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  2993. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  2994. return -1;
  2995. }
  2996. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  2997. clif_displaymessage(fd, atcmd_output);
  2998. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  2999. if (match > MAX_SEARCH) {
  3000. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  3001. clif_displaymessage(fd, atcmd_output);
  3002. match = MAX_SEARCH;
  3003. }
  3004. for(i = 0; i < match; i++) {
  3005. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3006. clif_displaymessage(fd, atcmd_output);
  3007. }
  3008. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3009. clif_displaymessage(fd, atcmd_output);
  3010. return 0;
  3011. }
  3012. /*==========================================
  3013. * Recall All Characters Online To Your Location
  3014. *------------------------------------------*/
  3015. ACMD_FUNC(recallall)
  3016. {
  3017. struct map_session_data* pl_sd;
  3018. struct s_mapiterator* iter;
  3019. int count;
  3020. nullpo_retr(-1, sd);
  3021. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3022. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3023. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3024. return -1;
  3025. }
  3026. count = 0;
  3027. iter = mapit_getallusers();
  3028. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3029. {
  3030. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3031. {
  3032. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3033. continue; // Don't waste time warping the character to the same place.
  3034. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3035. count++;
  3036. else {
  3037. if (pc_isdead(pl_sd)) { //Wake them up
  3038. pc_setstand(pl_sd);
  3039. pc_setrestartvalue(pl_sd,1);
  3040. }
  3041. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3042. }
  3043. }
  3044. }
  3045. mapit_free(iter);
  3046. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3047. if (count) {
  3048. 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.
  3049. clif_displaymessage(fd, atcmd_output);
  3050. }
  3051. return 0;
  3052. }
  3053. /*==========================================
  3054. * Recall online characters of a guild to your location
  3055. *------------------------------------------*/
  3056. ACMD_FUNC(guildrecall)
  3057. {
  3058. struct map_session_data* pl_sd;
  3059. struct s_mapiterator* iter;
  3060. int count;
  3061. char guild_name[NAME_LENGTH];
  3062. struct guild *g;
  3063. nullpo_retr(-1, sd);
  3064. memset(guild_name, '\0', sizeof(guild_name));
  3065. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3066. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3067. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3068. return -1;
  3069. }
  3070. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3071. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3072. return -1;
  3073. }
  3074. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3075. (g = guild_search(atoi(message))) == NULL)
  3076. {
  3077. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3078. return -1;
  3079. }
  3080. count = 0;
  3081. iter = mapit_getallusers();
  3082. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3083. {
  3084. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3085. {
  3086. 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))
  3087. continue; // Skip GMs greater than you... or chars already on the cell
  3088. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3089. count++;
  3090. else
  3091. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3092. }
  3093. }
  3094. mapit_free(iter);
  3095. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3096. clif_displaymessage(fd, atcmd_output);
  3097. if (count) {
  3098. 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.
  3099. clif_displaymessage(fd, atcmd_output);
  3100. }
  3101. return 0;
  3102. }
  3103. /*==========================================
  3104. * Recall online characters of a party to your location
  3105. *------------------------------------------*/
  3106. ACMD_FUNC(partyrecall)
  3107. {
  3108. struct map_session_data* pl_sd;
  3109. struct s_mapiterator* iter;
  3110. char party_name[NAME_LENGTH];
  3111. struct party_data *p;
  3112. int count;
  3113. nullpo_retr(-1, sd);
  3114. memset(party_name, '\0', sizeof(party_name));
  3115. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3116. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3117. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3118. return -1;
  3119. }
  3120. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3121. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3122. return -1;
  3123. }
  3124. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3125. (p = party_search(atoi(message))) == NULL)
  3126. {
  3127. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3128. return -1;
  3129. }
  3130. count = 0;
  3131. iter = mapit_getallusers();
  3132. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3133. {
  3134. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3135. {
  3136. 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))
  3137. continue; // Skip GMs greater than you... or chars already on the cell
  3138. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3139. count++;
  3140. else
  3141. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3142. }
  3143. }
  3144. mapit_free(iter);
  3145. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3146. clif_displaymessage(fd, atcmd_output);
  3147. if (count) {
  3148. 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.
  3149. clif_displaymessage(fd, atcmd_output);
  3150. }
  3151. return 0;
  3152. }
  3153. /*==========================================
  3154. *
  3155. *------------------------------------------*/
  3156. void atcommand_doload();
  3157. ACMD_FUNC(reload) {
  3158. nullpo_retr(-1, sd);
  3159. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3160. const char* text;
  3161. text = atcommand_help_string( command );
  3162. if(text)
  3163. clif_displaymessage( fd, text );
  3164. return -1;
  3165. }
  3166. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3167. itemdb_reload();
  3168. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3169. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3170. mob_reload();
  3171. read_petdb();
  3172. hom_reload();
  3173. mercenary_readdb();
  3174. mercenary_read_skilldb();
  3175. reload_elementaldb();
  3176. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3177. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3178. skill_reload();
  3179. hom_reload_skill();
  3180. reload_elemental_skilldb();
  3181. mercenary_read_skilldb();
  3182. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3183. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3184. config_t run_test;
  3185. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3186. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3187. return -1;
  3188. }
  3189. config_destroy(&run_test);
  3190. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3191. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3192. return -1;
  3193. }
  3194. config_destroy(&run_test);
  3195. atcommand_doload();
  3196. pc_groups_reload();
  3197. clif_displaymessage(fd, msg_txt(sd,254));
  3198. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3199. struct Battle_Config prev_config;
  3200. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3201. battle_config_read(BATTLE_CONF_FILENAME);
  3202. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3203. || prev_config.item_rate_common != battle_config.item_rate_common
  3204. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3205. || prev_config.item_rate_card != battle_config.item_rate_card
  3206. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3207. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3208. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3209. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3210. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3211. || prev_config.item_rate_use != battle_config.item_rate_use
  3212. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3213. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3214. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3215. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3216. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3217. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3218. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3219. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3220. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3221. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3222. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3223. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3224. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3225. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3226. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3227. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3228. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3229. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3230. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3231. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3232. )
  3233. { // Exp or Drop rates changed.
  3234. mob_reload(); //Needed as well so rate changes take effect.
  3235. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3236. }
  3237. clif_displaymessage(fd, msg_txt(sd,255));
  3238. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3239. status_readdb();
  3240. clif_displaymessage(fd, msg_txt(sd,256));
  3241. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3242. pc_readdb();
  3243. clif_displaymessage(fd, msg_txt(sd,257));
  3244. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3245. pc_read_motd();
  3246. clif_displaymessage(fd, msg_txt(sd,268));
  3247. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3248. struct s_mapiterator* iter;
  3249. struct map_session_data* pl_sd;
  3250. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3251. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3252. iter = mapit_getallusers();
  3253. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3254. pc_close_npc(pl_sd,2);
  3255. mapit_free(iter);
  3256. flush_fifos();
  3257. map_reloadnpc(true); // reload config files seeking for npcs
  3258. script_reload();
  3259. npc_reload();
  3260. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3261. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3262. map_msg_reload();
  3263. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3264. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3265. do_reload_quest();
  3266. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3267. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3268. packetdb_readdb();
  3269. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3270. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3271. instance_readdb();
  3272. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3273. }
  3274. return 0;
  3275. }
  3276. /*==========================================
  3277. * @partysharelvl <share_range> [Akinari]
  3278. * Updates char server party share level range in runtime
  3279. * Temporary - Permanent update in inter_athena.conf
  3280. *------------------------------------------*/
  3281. ACMD_FUNC(partysharelvl) {
  3282. unsigned int share_lvl;
  3283. nullpo_retr(-1, sd);
  3284. if(!message || !*message) {
  3285. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3286. return -1;
  3287. } else
  3288. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3289. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3290. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3291. else //Char server offline
  3292. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3293. return 0;
  3294. }
  3295. /*==========================================
  3296. * @mapinfo [0-3] <map name> by MC_Cameri
  3297. * => Shows information about the map [map name]
  3298. * 0 = no additional information
  3299. * 1 = Show users in that map and their location
  3300. * 2 = Shows NPCs in that map
  3301. * 3 = Shows the chats in that map
  3302. *------------------------------------------*/
  3303. ACMD_FUNC(mapinfo) {
  3304. struct map_session_data* pl_sd;
  3305. struct s_mapiterator* iter;
  3306. struct chat_data *cd = NULL;
  3307. char direction[12];
  3308. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3309. unsigned short m_index;
  3310. char mapname[24];
  3311. nullpo_retr(-1, sd);
  3312. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3313. memset(mapname, '\0', sizeof(mapname));
  3314. memset(direction, '\0', sizeof(direction));
  3315. sscanf(message, "%d %23[^\n]", &list, mapname);
  3316. if (list < 0 || list > 3) {
  3317. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3318. return -1;
  3319. }
  3320. if (mapname[0] == '\0') {
  3321. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3322. m_id = map_mapindex2mapid(sd->mapindex);
  3323. } else {
  3324. m_id = map_mapname2mapid(mapname);
  3325. }
  3326. if (m_id < 0) {
  3327. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3328. return -1;
  3329. }
  3330. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3331. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3332. // count chats (for initial message)
  3333. chat_num = 0;
  3334. iter = mapit_getallusers();
  3335. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3336. if( pl_sd->mapindex == m_index ) {
  3337. if( pl_sd->state.vending )
  3338. vend_num++;
  3339. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3340. chat_num++;
  3341. }
  3342. }
  3343. mapit_free(iter);
  3344. 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
  3345. clif_displaymessage(fd, atcmd_output);
  3346. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3347. if (map[m_id].flag.town)
  3348. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3349. if (map[m_id].flag.restricted){
  3350. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3351. clif_displaymessage(fd, atcmd_output);
  3352. }
  3353. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3354. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3355. else
  3356. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3357. if (map[m_id].flag.battleground){
  3358. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3359. clif_displaymessage(fd, atcmd_output);
  3360. }
  3361. /* Skill damage adjustment info [Cydh] */
  3362. #ifdef ADJUST_SKILL_DAMAGE
  3363. if (map[m_id].flag.skill_damage) {
  3364. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3365. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3366. ,map[m_id].adjust.damage.pc
  3367. ,map[m_id].adjust.damage.mob
  3368. ,map[m_id].adjust.damage.boss
  3369. ,map[m_id].adjust.damage.other
  3370. ,map[m_id].adjust.damage.caster);
  3371. clif_displaymessage(fd, atcmd_output);
  3372. if (map[m_id].skill_damage[0].skill_id) {
  3373. int j;
  3374. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3375. for (j = 0; j < MAX_MAP_SKILL_MODIFIER; j++) {
  3376. if (map[m_id].skill_damage[j].skill_id) {
  3377. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3378. ,j+1
  3379. ,skill_get_name(map[m_id].skill_damage[j].skill_id)
  3380. ,map[m_id].skill_damage[j].pc
  3381. ,map[m_id].skill_damage[j].mob
  3382. ,map[m_id].skill_damage[j].boss
  3383. ,map[m_id].skill_damage[j].other
  3384. ,map[m_id].skill_damage[j].caster);
  3385. clif_displaymessage(fd,atcmd_output);
  3386. }
  3387. }
  3388. }
  3389. }
  3390. #endif
  3391. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3392. if (map[m_id].flag.pvp)
  3393. strcat(atcmd_output, " Pvp ON |");
  3394. if (map[m_id].flag.pvp_noguild)
  3395. strcat(atcmd_output, " NoGuild |");
  3396. if (map[m_id].flag.pvp_noparty)
  3397. strcat(atcmd_output, " NoParty |");
  3398. if (map[m_id].flag.pvp_nightmaredrop)
  3399. strcat(atcmd_output, " NightmareDrop |");
  3400. if (map[m_id].flag.pvp_nocalcrank)
  3401. strcat(atcmd_output, " NoCalcRank |");
  3402. clif_displaymessage(fd, atcmd_output);
  3403. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3404. if (map[m_id].flag.gvg)
  3405. strcat(atcmd_output, " GvG ON |");
  3406. if (map[m_id].flag.gvg_dungeon)
  3407. strcat(atcmd_output, " GvG Dungeon |");
  3408. if (map[m_id].flag.gvg_castle)
  3409. strcat(atcmd_output, " GvG Castle |");
  3410. if (map[m_id].flag.gvg_noparty)
  3411. strcat(atcmd_output, " NoParty |");
  3412. clif_displaymessage(fd, atcmd_output);
  3413. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3414. if (map[m_id].flag.noteleport)
  3415. strcat(atcmd_output, " NoTeleport |");
  3416. if (map[m_id].flag.monster_noteleport)
  3417. strcat(atcmd_output, " Monster NoTeleport |");
  3418. if (map[m_id].flag.nowarp)
  3419. strcat(atcmd_output, " NoWarp |");
  3420. if (map[m_id].flag.nowarpto)
  3421. strcat(atcmd_output, " NoWarpTo |");
  3422. if (map[m_id].flag.noreturn)
  3423. strcat(atcmd_output, " NoReturn |");
  3424. if (map[m_id].flag.nogo)
  3425. strcat(atcmd_output, " NoGo |"); //
  3426. if (map[m_id].flag.nomemo)
  3427. strcat(atcmd_output, " NoMemo |");
  3428. clif_displaymessage(fd, atcmd_output);
  3429. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3430. (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
  3431. clif_displaymessage(fd, atcmd_output);
  3432. if (map[m_id].flag.nosave) {
  3433. if (!map[m_id].save.map)
  3434. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3435. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3436. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3437. clif_displaymessage(fd, atcmd_output);
  3438. }
  3439. else {
  3440. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3441. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3442. clif_displaymessage(fd, atcmd_output);
  3443. }
  3444. }
  3445. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3446. if (map[m_id].flag.snow)
  3447. strcat(atcmd_output, " Snow |");
  3448. if (map[m_id].flag.fog)
  3449. strcat(atcmd_output, " Fog |");
  3450. if (map[m_id].flag.sakura)
  3451. strcat(atcmd_output, " Sakura |");
  3452. if (map[m_id].flag.clouds)
  3453. strcat(atcmd_output, " Clouds |");
  3454. if (map[m_id].flag.clouds2)
  3455. strcat(atcmd_output, " Clouds2 |");
  3456. if (map[m_id].flag.fireworks)
  3457. strcat(atcmd_output, " Fireworks |");
  3458. if (map[m_id].flag.leaves)
  3459. strcat(atcmd_output, " Leaves |");
  3460. if (map[m_id].flag.nightenabled)
  3461. strcat(atcmd_output, " Displays Night |");
  3462. clif_displaymessage(fd, atcmd_output);
  3463. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3464. if (map[m_id].flag.nobranch)
  3465. strcat(atcmd_output, " NoBranch |");
  3466. if (map[m_id].flag.notrade)
  3467. strcat(atcmd_output, " NoTrade |");
  3468. if (map[m_id].flag.novending)
  3469. strcat(atcmd_output, " NoVending |");
  3470. if (map[m_id].flag.nodrop)
  3471. strcat(atcmd_output, " NoDrop |");
  3472. if (map[m_id].flag.noskill)
  3473. strcat(atcmd_output, " NoSkill |");
  3474. if (map[m_id].flag.noicewall)
  3475. strcat(atcmd_output, " NoIcewall |");
  3476. if (map[m_id].flag.allowks)
  3477. strcat(atcmd_output, " AllowKS |");
  3478. if (map[m_id].flag.reset)
  3479. strcat(atcmd_output, " Reset |");
  3480. clif_displaymessage(fd, atcmd_output);
  3481. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3482. if (map[m_id].nocommand)
  3483. strcat(atcmd_output, " NoCommand |");
  3484. if (map[m_id].flag.nobaseexp)
  3485. strcat(atcmd_output, " NoBaseEXP |");
  3486. if (map[m_id].flag.nojobexp)
  3487. strcat(atcmd_output, " NoJobEXP |");
  3488. if (map[m_id].flag.nomobloot)
  3489. strcat(atcmd_output, " NoMobLoot |");
  3490. if (map[m_id].flag.nomvploot)
  3491. strcat(atcmd_output, " NoMVPLoot |");
  3492. if (map[m_id].flag.partylock)
  3493. strcat(atcmd_output, " PartyLock |");
  3494. if (map[m_id].flag.guildlock)
  3495. strcat(atcmd_output, " GuildLock |");
  3496. if (map[m_id].flag.loadevent)
  3497. strcat(atcmd_output, " Loadevent |");
  3498. if (map[m_id].flag.chmautojoin)
  3499. strcat(atcmd_output, " Chmautojoin |");
  3500. if (map[m_id].flag.nousecart)
  3501. strcat(atcmd_output, " NoUsecart |");
  3502. if (map[m_id].flag.noitemconsumption)
  3503. strcat(atcmd_output, " NoItemConsumption |");
  3504. if (map[m_id].flag.nosumstarmiracle)
  3505. strcat(atcmd_output, " NoSumStarMiracle |");
  3506. if (map[m_id].flag.nomineeffect)
  3507. strcat(atcmd_output, " NoMineEffect |");
  3508. if (map[m_id].flag.nolockon)
  3509. strcat(atcmd_output, " NoLockOn |");
  3510. if (map[m_id].flag.notomb)
  3511. strcat(atcmd_output, " NoTomb |");
  3512. clif_displaymessage(fd, atcmd_output);
  3513. switch (list) {
  3514. case 0:
  3515. // Do nothing. It's list 0, no additional display.
  3516. break;
  3517. case 1:
  3518. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3519. iter = mapit_getallusers();
  3520. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3521. {
  3522. if (pl_sd->mapindex == m_index) {
  3523. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3524. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3525. clif_displaymessage(fd, atcmd_output);
  3526. }
  3527. }
  3528. mapit_free(iter);
  3529. break;
  3530. case 2:
  3531. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3532. for (i = 0; i < map[m_id].npc_num;)
  3533. {
  3534. struct npc_data *nd = map[m_id].npc[i];
  3535. switch(nd->ud.dir) {
  3536. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  3537. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  3538. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  3539. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  3540. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  3541. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  3542. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  3543. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  3544. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  3545. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3546. }
  3547. if(strcmp(nd->name,nd->exname) == 0)
  3548. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3549. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3550. else
  3551. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3552. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3553. clif_displaymessage(fd, atcmd_output);
  3554. }
  3555. break;
  3556. case 3:
  3557. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3558. iter = mapit_getallusers();
  3559. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3560. {
  3561. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3562. pl_sd->mapindex == m_index &&
  3563. cd->usersd[0] == pl_sd)
  3564. {
  3565. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3566. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3567. clif_displaymessage(fd, atcmd_output);
  3568. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3569. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3570. clif_displaymessage(fd, atcmd_output);
  3571. }
  3572. }
  3573. mapit_free(iter);
  3574. break;
  3575. default: // normally impossible to arrive here
  3576. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3577. return -1;
  3578. break;
  3579. }
  3580. return 0;
  3581. }
  3582. /*==========================================
  3583. *
  3584. *------------------------------------------*/
  3585. ACMD_FUNC(mount_peco)
  3586. {
  3587. nullpo_retr(-1, sd);
  3588. if (sd->disguise) {
  3589. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3590. return -1;
  3591. }
  3592. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3593. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3594. unsigned int option = OPTION_DRAGON1;
  3595. if( message[0] ) {
  3596. int color = atoi(message);
  3597. option = ( color == 2 ? OPTION_DRAGON2 :
  3598. color == 3 ? OPTION_DRAGON3 :
  3599. color == 4 ? OPTION_DRAGON4 :
  3600. color == 5 ? OPTION_DRAGON5 :
  3601. OPTION_DRAGON1 );
  3602. }
  3603. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3604. pc_setoption(sd, sd->sc.option|option);
  3605. } else {
  3606. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3607. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3608. }
  3609. return 0;
  3610. }
  3611. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3612. if( !pc_isridingwug(sd) ) {
  3613. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3614. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3615. } else {
  3616. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3617. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3618. }
  3619. return 0;
  3620. }
  3621. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3622. if( !pc_ismadogear(sd) ) {
  3623. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3624. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3625. } else {
  3626. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3627. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3628. }
  3629. return 0;
  3630. }
  3631. if (!pc_isriding(sd)) { // if actually no peco
  3632. if (!pc_checkskill(sd, KN_RIDING)) {
  3633. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3634. return -1;
  3635. }
  3636. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3637. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3638. } else {//Dismount
  3639. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3640. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3641. }
  3642. return 0;
  3643. }
  3644. /*==========================================
  3645. *Spy Commands by Syrus22
  3646. *------------------------------------------*/
  3647. ACMD_FUNC(guildspy)
  3648. {
  3649. char guild_name[NAME_LENGTH];
  3650. struct guild *g;
  3651. nullpo_retr(-1, sd);
  3652. memset(guild_name, '\0', sizeof(guild_name));
  3653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3654. if (!enable_spy)
  3655. {
  3656. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3657. return -1;
  3658. }
  3659. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3660. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3661. return -1;
  3662. }
  3663. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3664. (g = guild_search(atoi(message))) != NULL) {
  3665. if (sd->guildspy == g->guild_id) {
  3666. sd->guildspy = 0;
  3667. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3668. clif_displaymessage(fd, atcmd_output);
  3669. } else {
  3670. sd->guildspy = g->guild_id;
  3671. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3672. clif_displaymessage(fd, atcmd_output);
  3673. }
  3674. } else {
  3675. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3676. return -1;
  3677. }
  3678. return 0;
  3679. }
  3680. /*==========================================
  3681. *
  3682. *------------------------------------------*/
  3683. ACMD_FUNC(partyspy)
  3684. {
  3685. char party_name[NAME_LENGTH];
  3686. struct party_data *p;
  3687. nullpo_retr(-1, sd);
  3688. memset(party_name, '\0', sizeof(party_name));
  3689. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3690. if (!enable_spy)
  3691. {
  3692. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3693. return -1;
  3694. }
  3695. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3696. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3697. return -1;
  3698. }
  3699. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3700. (p = party_search(atoi(message))) != NULL) {
  3701. if (sd->partyspy == p->party.party_id) {
  3702. sd->partyspy = 0;
  3703. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3704. clif_displaymessage(fd, atcmd_output);
  3705. } else {
  3706. sd->partyspy = p->party.party_id;
  3707. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3708. clif_displaymessage(fd, atcmd_output);
  3709. }
  3710. } else {
  3711. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3712. return -1;
  3713. }
  3714. return 0;
  3715. }
  3716. /*==========================================
  3717. * @repairall [Valaris]
  3718. *------------------------------------------*/
  3719. ACMD_FUNC(repairall)
  3720. {
  3721. int count, i;
  3722. nullpo_retr(-1, sd);
  3723. count = 0;
  3724. for (i = 0; i < MAX_INVENTORY; i++) {
  3725. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3726. sd->status.inventory[i].attribute = 0;
  3727. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3728. count++;
  3729. }
  3730. }
  3731. if (count > 0) {
  3732. clif_misceffect(&sd->bl, 3);
  3733. clif_equiplist(sd);
  3734. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3735. } else {
  3736. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3737. return -1;
  3738. }
  3739. return 0;
  3740. }
  3741. /*==========================================
  3742. * @nuke [Valaris]
  3743. *------------------------------------------*/
  3744. ACMD_FUNC(nuke)
  3745. {
  3746. struct map_session_data *pl_sd;
  3747. nullpo_retr(-1, sd);
  3748. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3749. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3750. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3751. return -1;
  3752. }
  3753. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3754. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3755. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3756. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3757. } else {
  3758. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3759. return -1;
  3760. }
  3761. } else {
  3762. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3763. return -1;
  3764. }
  3765. return 0;
  3766. }
  3767. /*==========================================
  3768. * @tonpc
  3769. *------------------------------------------*/
  3770. ACMD_FUNC(tonpc)
  3771. {
  3772. char npcname[NAME_LENGTH+1];
  3773. struct npc_data *nd;
  3774. nullpo_retr(-1, sd);
  3775. memset(npcname, 0, sizeof(npcname));
  3776. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3777. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3778. return -1;
  3779. }
  3780. if ((nd = npc_name2id(npcname)) != NULL) {
  3781. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3782. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3783. else
  3784. return -1;
  3785. } else {
  3786. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3787. return -1;
  3788. }
  3789. return 0;
  3790. }
  3791. /*==========================================
  3792. *
  3793. *------------------------------------------*/
  3794. ACMD_FUNC(shownpc)
  3795. {
  3796. char NPCname[NAME_LENGTH+1];
  3797. nullpo_retr(-1, sd);
  3798. memset(NPCname, '\0', sizeof(NPCname));
  3799. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3800. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3801. return -1;
  3802. }
  3803. if (npc_name2id(NPCname) != NULL) {
  3804. npc_enable(NPCname, 1);
  3805. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3806. } else {
  3807. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3808. return -1;
  3809. }
  3810. return 0;
  3811. }
  3812. /*==========================================
  3813. *
  3814. *------------------------------------------*/
  3815. ACMD_FUNC(hidenpc)
  3816. {
  3817. char NPCname[NAME_LENGTH+1];
  3818. nullpo_retr(-1, sd);
  3819. memset(NPCname, '\0', sizeof(NPCname));
  3820. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3821. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3822. return -1;
  3823. }
  3824. if (npc_name2id(NPCname) == NULL) {
  3825. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3826. return -1;
  3827. }
  3828. npc_enable(NPCname, 0);
  3829. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3830. return 0;
  3831. }
  3832. ACMD_FUNC(loadnpc)
  3833. {
  3834. FILE *fp;
  3835. if (!message || !*message) {
  3836. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3837. return -1;
  3838. }
  3839. // check if script file exists
  3840. if ((fp = fopen(message, "r")) == NULL) {
  3841. clif_displaymessage(fd, msg_txt(sd,261));
  3842. return -1;
  3843. }
  3844. fclose(fp);
  3845. // add to list of script sources and run it
  3846. npc_addsrcfile(message);
  3847. npc_parsesrcfile(message,true);
  3848. npc_read_event_script();
  3849. clif_displaymessage(fd, msg_txt(sd,262));
  3850. return 0;
  3851. }
  3852. ACMD_FUNC(unloadnpc)
  3853. {
  3854. struct npc_data *nd;
  3855. char NPCname[NAME_LENGTH];
  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,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3860. return -1;
  3861. }
  3862. if ((nd = npc_name2id(NPCname)) == NULL) {
  3863. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3864. return -1;
  3865. }
  3866. npc_unload_duplicates(nd);
  3867. npc_unload(nd,true);
  3868. npc_read_event_script();
  3869. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3870. return 0;
  3871. }
  3872. /*==========================================
  3873. * time in txt for time command (by [Yor])
  3874. *------------------------------------------*/
  3875. char* txt_time(unsigned int duration)
  3876. {
  3877. int days, hours, minutes, seconds;
  3878. char temp[CHAT_SIZE_MAX];
  3879. static char temp1[CHAT_SIZE_MAX];
  3880. memset(temp, '\0', sizeof(temp));
  3881. memset(temp1, '\0', sizeof(temp1));
  3882. days = duration / (60 * 60 * 24);
  3883. duration = duration - (60 * 60 * 24 * days);
  3884. hours = duration / (60 * 60);
  3885. duration = duration - (60 * 60 * hours);
  3886. minutes = duration / 60;
  3887. seconds = duration - (60 * minutes);
  3888. if (days == 1)
  3889. sprintf(temp, msg_txt(NULL,219), days); // %d day
  3890. else if (days > 1)
  3891. sprintf(temp, msg_txt(NULL,220), days); // %d days
  3892. if (hours == 1)
  3893. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  3894. else if (hours > 1)
  3895. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  3896. if (minutes < 2)
  3897. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  3898. else
  3899. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  3900. if (seconds == 1)
  3901. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  3902. else if (seconds > 1)
  3903. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  3904. return temp1;
  3905. }
  3906. /*==========================================
  3907. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3908. * Calculation management of GM modification (@day/@night GM commands) is done
  3909. *------------------------------------------*/
  3910. ACMD_FUNC(servertime)
  3911. {
  3912. const struct TimerData * timer_data;
  3913. time_t time_server; // variable for number of seconds (used with time() function)
  3914. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3915. char temp[CHAT_SIZE_MAX];
  3916. nullpo_retr(-1, sd);
  3917. memset(temp, '\0', sizeof(temp));
  3918. time(&time_server); // get time in seconds since 1/1/1970
  3919. datetime = localtime(&time_server); // convert seconds in structure
  3920. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3921. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3922. clif_displaymessage(fd, temp);
  3923. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3924. if (night_flag == 0)
  3925. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3926. else
  3927. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3928. } else if (battle_config.night_duration == 0)
  3929. if (night_flag == 1) { // we start with night
  3930. timer_data = get_timer(day_timer_tid);
  3931. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  3932. clif_displaymessage(fd, temp);
  3933. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  3934. } else
  3935. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3936. else if (battle_config.day_duration == 0)
  3937. if (night_flag == 0) { // we start with day
  3938. timer_data = get_timer(night_timer_tid);
  3939. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3940. clif_displaymessage(fd, temp);
  3941. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  3942. } else
  3943. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3944. else {
  3945. const struct TimerData * timer_data2;
  3946. if (night_flag == 0) {
  3947. timer_data = get_timer(night_timer_tid);
  3948. timer_data2 = get_timer(day_timer_tid);
  3949. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3950. clif_displaymessage(fd, temp);
  3951. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3952. 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.
  3953. else
  3954. 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.
  3955. clif_displaymessage(fd, temp);
  3956. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3957. clif_displaymessage(fd, temp);
  3958. } else {
  3959. timer_data = get_timer(day_timer_tid);
  3960. timer_data2 = get_timer(night_timer_tid);
  3961. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  3962. clif_displaymessage(fd, temp);
  3963. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3964. 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.
  3965. else
  3966. 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.
  3967. clif_displaymessage(fd, temp);
  3968. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3969. clif_displaymessage(fd, temp);
  3970. }
  3971. }
  3972. return 0;
  3973. }
  3974. /*==========================================
  3975. * @jail <char_name> by [Yor]
  3976. * Special warp! No check with nowarp and nowarpto flag
  3977. *------------------------------------------*/
  3978. ACMD_FUNC(jail)
  3979. {
  3980. struct map_session_data *pl_sd;
  3981. int x, y;
  3982. unsigned short m_index;
  3983. nullpo_retr(-1, sd);
  3984. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3985. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3986. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  3987. return -1;
  3988. }
  3989. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3990. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3991. return -1;
  3992. }
  3993. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3994. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3995. return -1;
  3996. }
  3997. if (pl_sd->sc.data[SC_JAILED]) {
  3998. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  3999. return -1;
  4000. }
  4001. switch(rnd() % 2) { //Jail Locations
  4002. case 0:
  4003. m_index = mapindex_name2id(MAP_JAIL);
  4004. x = 24;
  4005. y = 75;
  4006. break;
  4007. default:
  4008. m_index = mapindex_name2id(MAP_JAIL);
  4009. x = 49;
  4010. y = 75;
  4011. break;
  4012. }
  4013. //Duration of INT_MAX to specify infinity.
  4014. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4015. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4016. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4017. return 0;
  4018. }
  4019. /*==========================================
  4020. * @unjail/@discharge <char_name> by [Yor]
  4021. * Special warp! No check with nowarp and nowarpto flag
  4022. *------------------------------------------*/
  4023. ACMD_FUNC(unjail)
  4024. {
  4025. struct map_session_data *pl_sd;
  4026. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4027. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4028. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4029. return -1;
  4030. }
  4031. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4032. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4033. return -1;
  4034. }
  4035. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4036. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4037. return -1;
  4038. }
  4039. if (!pl_sd->sc.data[SC_JAILED]) {
  4040. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4041. return -1;
  4042. }
  4043. //Reset jail time to 1 sec.
  4044. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4045. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4046. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4047. return 0;
  4048. }
  4049. ACMD_FUNC(jailfor) {
  4050. struct map_session_data *pl_sd = NULL;
  4051. char * modif_p;
  4052. int jailtime = 0,x,y;
  4053. short m_index = 0;
  4054. nullpo_retr(-1, sd);
  4055. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4056. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4057. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4058. return -1;
  4059. }
  4060. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4061. modif_p = atcmd_output;
  4062. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4063. if (jailtime == 0) {
  4064. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4065. 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.
  4066. return -1;
  4067. }
  4068. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4069. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4070. return -1;
  4071. }
  4072. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4073. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4074. return -1;
  4075. }
  4076. // Added by Coltaro
  4077. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4078. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4079. if (jailtime <= 0) {
  4080. jailtime = 0;
  4081. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4082. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4083. } else {
  4084. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4085. char timestr[21];
  4086. time_t now=time(NULL);
  4087. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4088. 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
  4089. clif_displaymessage(pl_sd->fd, atcmd_output);
  4090. 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
  4091. clif_displaymessage(fd, atcmd_output);
  4092. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4093. sprintf(atcmd_output,"Release date is: %s",timestr);
  4094. clif_displaymessage(pl_sd->fd, atcmd_output);
  4095. clif_displaymessage(fd, atcmd_output);
  4096. }
  4097. } else if (jailtime < 0) {
  4098. clif_displaymessage(fd, msg_txt(sd,1136));
  4099. return -1;
  4100. }
  4101. // Jail locations, add more as you wish.
  4102. switch(rnd()%2) {
  4103. case 1: // Jail #1
  4104. m_index = mapindex_name2id(MAP_JAIL);
  4105. x = 49; y = 75;
  4106. break;
  4107. default: // Default Jail
  4108. m_index = mapindex_name2id(MAP_JAIL);
  4109. x = 24; y = 75;
  4110. break;
  4111. }
  4112. 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).
  4113. return 0;
  4114. }
  4115. //By Coltaro
  4116. ACMD_FUNC(jailtime){
  4117. int year, month, day, hour, minute, second;
  4118. char timestr[21];
  4119. time_t now = time(NULL);
  4120. nullpo_retr(-1, sd);
  4121. if (!sd->sc.data[SC_JAILED]) {
  4122. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4123. return -1;
  4124. }
  4125. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4126. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4127. return 0;
  4128. }
  4129. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4130. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4131. return -1;
  4132. }
  4133. // Get remaining jail time
  4134. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4135. 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
  4136. clif_displaymessage(fd, atcmd_output);
  4137. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4138. sprintf(atcmd_output,"Release date is: %s",timestr);
  4139. clif_displaymessage(fd, atcmd_output);
  4140. return 0;
  4141. }
  4142. /*==========================================
  4143. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4144. *------------------------------------------*/
  4145. ACMD_FUNC(disguise)
  4146. {
  4147. int id = 0;
  4148. nullpo_retr(-1, sd);
  4149. if (!message || !*message) {
  4150. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4151. return -1;
  4152. }
  4153. if ((id = atoi(message)) > 0)
  4154. { //Acquired an ID
  4155. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4156. id = 0; //Invalid id for either mobs or npcs.
  4157. } else { //Acquired a Name
  4158. if ((id = mobdb_searchname(message)) == 0)
  4159. {
  4160. struct npc_data* nd = npc_name2id(message);
  4161. if (nd != NULL)
  4162. id = nd->class_;
  4163. }
  4164. }
  4165. if (id == 0)
  4166. {
  4167. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4168. return -1;
  4169. }
  4170. if(pc_isriding(sd))
  4171. {
  4172. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4173. return -1;
  4174. }
  4175. if (sd->sc.data[SC_MONSTER_TRANSFORM]) {
  4176. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4177. return -1;
  4178. }
  4179. pc_disguise(sd, id);
  4180. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4181. return 0;
  4182. }
  4183. /*==========================================
  4184. * DisguiseAll
  4185. *------------------------------------------*/
  4186. ACMD_FUNC(disguiseall)
  4187. {
  4188. int mob_id=0;
  4189. struct map_session_data *pl_sd;
  4190. struct s_mapiterator* iter;
  4191. nullpo_retr(-1, sd);
  4192. if (!message || !*message) {
  4193. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4194. return -1;
  4195. }
  4196. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4197. mob_id = atoi(message);
  4198. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4199. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4200. return -1;
  4201. }
  4202. iter = mapit_getallusers();
  4203. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4204. pc_disguise(pl_sd, mob_id);
  4205. mapit_free(iter);
  4206. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4207. return 0;
  4208. }
  4209. /*==========================================
  4210. * DisguiseGuild
  4211. *------------------------------------------*/
  4212. ACMD_FUNC(disguiseguild)
  4213. {
  4214. int id = 0, i;
  4215. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4216. struct guild *g;
  4217. memset(monster, '\0', sizeof(monster));
  4218. memset(guild, '\0', sizeof(guild));
  4219. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4220. 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>).
  4221. return -1;
  4222. }
  4223. if( (id = atoi(monster)) > 0 ) {
  4224. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4225. id = 0;
  4226. } else {
  4227. if( (id = mobdb_searchname(monster)) == 0 ) {
  4228. struct npc_data* nd = npc_name2id(monster);
  4229. if( nd != NULL )
  4230. id = nd->class_;
  4231. }
  4232. }
  4233. if( id == 0 ) {
  4234. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4235. return -1;
  4236. }
  4237. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4238. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4239. return -1;
  4240. }
  4241. for( i = 0; i < g->max_member; i++ ){
  4242. struct map_session_data *pl_sd;
  4243. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4244. pc_disguise(pl_sd, id);
  4245. }
  4246. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4247. return 0;
  4248. }
  4249. /*==========================================
  4250. * @undisguise by [Yor]
  4251. *------------------------------------------*/
  4252. ACMD_FUNC(undisguise)
  4253. {
  4254. nullpo_retr(-1, sd);
  4255. if (sd->disguise) {
  4256. pc_disguise(sd, 0);
  4257. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4258. } else {
  4259. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4260. return -1;
  4261. }
  4262. return 0;
  4263. }
  4264. /*==========================================
  4265. * UndisguiseAll
  4266. *------------------------------------------*/
  4267. ACMD_FUNC(undisguiseall)
  4268. {
  4269. struct map_session_data *pl_sd;
  4270. struct s_mapiterator* iter;
  4271. nullpo_retr(-1, sd);
  4272. iter = mapit_getallusers();
  4273. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4274. if( pl_sd->disguise )
  4275. pc_disguise(pl_sd, 0);
  4276. mapit_free(iter);
  4277. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4278. return 0;
  4279. }
  4280. /*==========================================
  4281. * UndisguiseGuild
  4282. *------------------------------------------*/
  4283. ACMD_FUNC(undisguiseguild)
  4284. {
  4285. char guild_name[NAME_LENGTH];
  4286. struct guild *g;
  4287. int i;
  4288. nullpo_retr(-1, sd);
  4289. memset(guild_name, '\0', sizeof(guild_name));
  4290. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4291. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4292. return -1;
  4293. }
  4294. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4295. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4296. return -1;
  4297. }
  4298. for(i = 0; i < g->max_member; i++){
  4299. struct map_session_data *pl_sd;
  4300. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4301. pc_disguise(pl_sd, 0);
  4302. }
  4303. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4304. return 0;
  4305. }
  4306. /*==========================================
  4307. * @exp by [Skotlex]
  4308. *------------------------------------------*/
  4309. ACMD_FUNC(exp)
  4310. {
  4311. char output[CHAT_SIZE_MAX];
  4312. double nextb, nextj;
  4313. nullpo_retr(-1, sd);
  4314. memset(output, '\0', sizeof(output));
  4315. nextb = pc_nextbaseexp(sd);
  4316. if (nextb)
  4317. nextb = sd->status.base_exp*100.0/nextb;
  4318. nextj = pc_nextjobexp(sd);
  4319. if (nextj)
  4320. nextj = sd->status.job_exp*100.0/nextj;
  4321. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4322. clif_displaymessage(fd, output);
  4323. return 0;
  4324. }
  4325. /*==========================================
  4326. * @broadcast by [Valaris]
  4327. *------------------------------------------*/
  4328. ACMD_FUNC(broadcast)
  4329. {
  4330. nullpo_retr(-1, sd);
  4331. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4332. if (!message || !*message) {
  4333. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4334. return -1;
  4335. }
  4336. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4337. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4338. return 0;
  4339. }
  4340. /*==========================================
  4341. * @localbroadcast by [Valaris]
  4342. *------------------------------------------*/
  4343. ACMD_FUNC(localbroadcast)
  4344. {
  4345. nullpo_retr(-1, sd);
  4346. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4347. if (!message || !*message) {
  4348. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4349. return -1;
  4350. }
  4351. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4352. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4353. return 0;
  4354. }
  4355. /*==========================================
  4356. * @email <actual@email> <new@email> by [Yor]
  4357. *------------------------------------------*/
  4358. ACMD_FUNC(email)
  4359. {
  4360. char actual_email[100];
  4361. char new_email[100];
  4362. nullpo_retr(-1, sd);
  4363. memset(actual_email, '\0', sizeof(actual_email));
  4364. memset(new_email, '\0', sizeof(new_email));
  4365. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4366. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4367. return -1;
  4368. }
  4369. if (e_mail_check(actual_email) == 0) {
  4370. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4371. return -1;
  4372. } else if (e_mail_check(new_email) == 0) {
  4373. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4374. return -1;
  4375. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4376. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4377. return -1;
  4378. } else if (strcmpi(actual_email, new_email) == 0) {
  4379. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4380. return -1;
  4381. }
  4382. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4383. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4384. return 0;
  4385. }
  4386. /*==========================================
  4387. *@effect
  4388. *------------------------------------------*/
  4389. ACMD_FUNC(effect)
  4390. {
  4391. int type = 0, flag = 0;
  4392. nullpo_retr(-1, sd);
  4393. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4394. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4395. return -1;
  4396. }
  4397. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4398. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4399. return 0;
  4400. }
  4401. /*==========================================
  4402. * @killer by MouseJstr
  4403. * enable killing players even when not in pvp
  4404. *------------------------------------------*/
  4405. ACMD_FUNC(killer)
  4406. {
  4407. nullpo_retr(-1, sd);
  4408. sd->state.killer = !sd->state.killer;
  4409. if(sd->state.killer)
  4410. clif_displaymessage(fd, msg_txt(sd,241));
  4411. else {
  4412. clif_displaymessage(fd, msg_txt(sd,292));
  4413. pc_stop_attack(sd);
  4414. }
  4415. return 0;
  4416. }
  4417. /*==========================================
  4418. * @killable by MouseJstr
  4419. * enable other people killing you
  4420. *------------------------------------------*/
  4421. ACMD_FUNC(killable)
  4422. {
  4423. nullpo_retr(-1, sd);
  4424. sd->state.killable = !sd->state.killable;
  4425. if(sd->state.killable)
  4426. clif_displaymessage(fd, msg_txt(sd,242));
  4427. else {
  4428. clif_displaymessage(fd, msg_txt(sd,288));
  4429. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4430. }
  4431. return 0;
  4432. }
  4433. /*==========================================
  4434. * @skillon by MouseJstr
  4435. * turn skills on for the map
  4436. *------------------------------------------*/
  4437. ACMD_FUNC(skillon)
  4438. {
  4439. nullpo_retr(-1, sd);
  4440. map[sd->bl.m].flag.noskill = 0;
  4441. clif_displaymessage(fd, msg_txt(sd,244));
  4442. return 0;
  4443. }
  4444. /*==========================================
  4445. * @skilloff by MouseJstr
  4446. * Turn skills off on the map
  4447. *------------------------------------------*/
  4448. ACMD_FUNC(skilloff)
  4449. {
  4450. nullpo_retr(-1, sd);
  4451. map[sd->bl.m].flag.noskill = 1;
  4452. clif_displaymessage(fd, msg_txt(sd,243));
  4453. return 0;
  4454. }
  4455. /*==========================================
  4456. * @npcmove by MouseJstr
  4457. * move a npc
  4458. *------------------------------------------*/
  4459. ACMD_FUNC(npcmove)
  4460. {
  4461. int x = 0, y = 0, m;
  4462. struct npc_data *nd = 0;
  4463. nullpo_retr(-1, sd);
  4464. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4465. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4466. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4467. return -1;
  4468. }
  4469. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4470. {
  4471. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4472. return -1;
  4473. }
  4474. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4475. {
  4476. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4477. return -1; //Not on a map.
  4478. }
  4479. x = cap_value(x, 0, map[m].xs-1);
  4480. y = cap_value(y, 0, map[m].ys-1);
  4481. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4482. map_moveblock(&nd->bl, x, y, gettick());
  4483. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4484. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4485. return 0;
  4486. }
  4487. /*==========================================
  4488. * @addwarp by MouseJstr
  4489. * Create a new static warp point.
  4490. *------------------------------------------*/
  4491. ACMD_FUNC(addwarp)
  4492. {
  4493. char mapname[32], warpname[NAME_LENGTH+1];
  4494. int x,y;
  4495. unsigned short m;
  4496. struct npc_data* nd;
  4497. nullpo_retr(-1, sd);
  4498. memset(warpname, '\0', sizeof(warpname));
  4499. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4500. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4501. return -1;
  4502. }
  4503. m = mapindex_name2id(mapname);
  4504. if( m == 0 )
  4505. {
  4506. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4507. clif_displaymessage(fd, atcmd_output);
  4508. return -1;
  4509. }
  4510. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4511. if( nd == NULL )
  4512. return -1;
  4513. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4514. clif_displaymessage(fd, atcmd_output);
  4515. return 0;
  4516. }
  4517. /*==========================================
  4518. * @follow by [MouseJstr]
  4519. * Follow a player .. staying no more then 5 spaces away
  4520. *------------------------------------------*/
  4521. ACMD_FUNC(follow)
  4522. {
  4523. struct map_session_data *pl_sd = NULL;
  4524. nullpo_retr(-1, sd);
  4525. if (!message || !*message) {
  4526. if (sd->followtarget == -1)
  4527. return -1;
  4528. pc_stop_following (sd);
  4529. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4530. return 0;
  4531. }
  4532. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4533. {
  4534. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4535. return -1;
  4536. }
  4537. if (sd->followtarget == pl_sd->bl.id) {
  4538. pc_stop_following (sd);
  4539. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4540. } else {
  4541. pc_follow(sd, pl_sd->bl.id);
  4542. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4543. }
  4544. return 0;
  4545. }
  4546. /*==========================================
  4547. * @dropall by [MouseJstr] and [Xantara]
  4548. * Drops all your possession on the ground based on item type
  4549. *------------------------------------------*/
  4550. ACMD_FUNC(dropall)
  4551. {
  4552. int8 type = -1;
  4553. uint16 i, count = 0, count2 = 0;
  4554. struct item_data *item_data = NULL;
  4555. nullpo_retr(-1, sd);
  4556. if( message[0] ) {
  4557. type = atoi(message);
  4558. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4559. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4560. {
  4561. clif_displaymessage(fd, msg_txt(sd,1492));
  4562. clif_displaymessage(fd, msg_txt(sd,1493));
  4563. return -1;
  4564. }
  4565. }
  4566. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4567. if( sd->status.inventory[i].amount ) {
  4568. if( (item_data = itemdb_exists(sd->status.inventory[i].nameid)) == NULL ) {
  4569. 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);
  4570. continue;
  4571. }
  4572. if( !pc_candrop(sd,&sd->status.inventory[i]) )
  4573. continue;
  4574. if( type == -1 || type == (uint8)item_data->type ) {
  4575. if( sd->status.inventory[i].equip != 0 )
  4576. pc_unequipitem(sd, i, 3);
  4577. if(pc_dropitem(sd, i, sd->status.inventory[i].amount))
  4578. count += sd->status.inventory[i].amount;
  4579. else count2 += sd->status.inventory[i].amount;
  4580. }
  4581. }
  4582. }
  4583. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4584. clif_displaymessage(fd, atcmd_output);
  4585. return 0;
  4586. }
  4587. /*==========================================
  4588. * @storeall by [MouseJstr]
  4589. * Put everything into storage
  4590. *------------------------------------------*/
  4591. ACMD_FUNC(storeall)
  4592. {
  4593. int i;
  4594. nullpo_retr(-1, sd);
  4595. if (sd->state.storage_flag != 1)
  4596. { //Open storage.
  4597. if( storage_storageopen(sd) == 1 ) {
  4598. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4599. return -1;
  4600. }
  4601. }
  4602. for (i = 0; i < MAX_INVENTORY; i++) {
  4603. if (sd->status.inventory[i].amount) {
  4604. if(sd->status.inventory[i].equip != 0)
  4605. pc_unequipitem(sd, i, 3);
  4606. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4607. }
  4608. }
  4609. storage_storageclose(sd);
  4610. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4611. return 0;
  4612. }
  4613. ACMD_FUNC(clearstorage)
  4614. {
  4615. int i, j;
  4616. nullpo_retr(-1, sd);
  4617. if (sd->state.storage_flag == 1) {
  4618. clif_displaymessage(fd, msg_txt(sd,250));
  4619. return -1;
  4620. }
  4621. j = sd->status.storage.storage_amount;
  4622. for (i = 0; i < j; ++i) {
  4623. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4624. }
  4625. storage_storageclose(sd);
  4626. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4627. return 0;
  4628. }
  4629. ACMD_FUNC(cleargstorage)
  4630. {
  4631. int i, j;
  4632. struct guild *g;
  4633. struct guild_storage *gstorage;
  4634. nullpo_retr(-1, sd);
  4635. g = sd->guild;
  4636. if (g == NULL) {
  4637. clif_displaymessage(fd, msg_txt(sd,43));
  4638. return -1;
  4639. }
  4640. if (sd->state.storage_flag == 1) {
  4641. clif_displaymessage(fd, msg_txt(sd,250));
  4642. return -1;
  4643. }
  4644. if (sd->state.storage_flag == 2) {
  4645. clif_displaymessage(fd, msg_txt(sd,251));
  4646. return -1;
  4647. }
  4648. gstorage = guild2storage2(sd->status.guild_id);
  4649. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4650. return -1;
  4651. }
  4652. j = gstorage->storage_amount;
  4653. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4654. for (i = 0; i < j; ++i) {
  4655. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4656. }
  4657. storage_guild_storageclose(sd);
  4658. gstorage->lock = 0; // Cleaning done, release lock
  4659. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4660. return 0;
  4661. }
  4662. ACMD_FUNC(clearcart)
  4663. {
  4664. int i;
  4665. nullpo_retr(-1, sd);
  4666. if (pc_iscarton(sd) == 0) {
  4667. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4668. return -1;
  4669. }
  4670. if (sd->state.vending == 1) { //Somehow...
  4671. return -1;
  4672. }
  4673. for( i = 0; i < MAX_CART; i++ )
  4674. if(sd->status.cart[i].nameid > 0)
  4675. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4676. clif_clearcart(fd);
  4677. clif_updatestatus(sd,SP_CARTINFO);
  4678. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4679. return 0;
  4680. }
  4681. /*==========================================
  4682. * @skillid by [MouseJstr]
  4683. * lookup a skill by name
  4684. *------------------------------------------*/
  4685. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4686. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4687. ACMD_FUNC(skillid) {
  4688. int skillen, i, found = 0;
  4689. DBIterator* iter;
  4690. DBKey key;
  4691. DBData *data;
  4692. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4693. nullpo_retr(-1, sd);
  4694. if (!message || !*message) {
  4695. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4696. return -1;
  4697. }
  4698. skillen = strlen(message);
  4699. iter = db_iterator(skilldb_name2id);
  4700. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4701. int idx = skill_get_index(db_data2i(data));
  4702. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) {
  4703. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s)
  4704. clif_displaymessage(fd, atcmd_output);
  4705. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) {
  4706. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str);
  4707. }
  4708. }
  4709. dbi_destroy(iter);
  4710. if( found ) {
  4711. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4712. clif_displaymessage(fd, atcmd_output);
  4713. }
  4714. for(i = 0; i < found; i++) { /* partials */
  4715. clif_displaymessage(fd, partials[i]);
  4716. }
  4717. return 0;
  4718. }
  4719. /*==========================================
  4720. * @useskill by [MouseJstr]
  4721. * A way of using skills without having to find them in the skills menu
  4722. *------------------------------------------*/
  4723. ACMD_FUNC(useskill)
  4724. {
  4725. struct map_session_data *pl_sd = NULL;
  4726. struct block_list *bl;
  4727. uint16 skill_id;
  4728. uint16 skill_lv;
  4729. char target[100];
  4730. nullpo_retr(-1, sd);
  4731. if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4732. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4733. return -1;
  4734. }
  4735. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4736. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4737. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4738. return -1;
  4739. }
  4740. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4741. {
  4742. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4743. return -1;
  4744. }
  4745. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4746. && sd->hd && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4747. bl = &sd->hd->bl;
  4748. else
  4749. bl = &sd->bl;
  4750. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4751. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4752. else
  4753. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4754. return 0;
  4755. }
  4756. /*==========================================
  4757. * @displayskill by [Skotlex]
  4758. * Debug command to locate new skill IDs. It sends the
  4759. * three possible skill-effect packets to the area.
  4760. *------------------------------------------*/
  4761. ACMD_FUNC(displayskill)
  4762. {
  4763. struct status_data * status;
  4764. unsigned int tick;
  4765. uint16 skill_id;
  4766. uint16 skill_lv = 1;
  4767. nullpo_retr(-1, sd);
  4768. if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
  4769. {
  4770. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4771. return -1;
  4772. }
  4773. status = status_get_status_data(&sd->bl);
  4774. tick = gettick();
  4775. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4776. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4777. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4778. return 0;
  4779. }
  4780. /*==========================================
  4781. * @skilltree by [MouseJstr]
  4782. * prints the skill tree for a player required to get to a skill
  4783. *------------------------------------------*/
  4784. ACMD_FUNC(skilltree)
  4785. {
  4786. struct map_session_data *pl_sd = NULL;
  4787. uint16 skill_id;
  4788. int meets, j, c=0;
  4789. char target[NAME_LENGTH];
  4790. struct skill_tree_entry *ent;
  4791. nullpo_retr(-1, sd);
  4792. if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
  4793. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4794. return -1;
  4795. }
  4796. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4797. {
  4798. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4799. return -1;
  4800. }
  4801. c = pc_calc_skilltree_normalize_job(pl_sd);
  4802. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4803. 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).
  4804. clif_displaymessage(fd, atcmd_output);
  4805. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4806. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4807. {
  4808. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4809. return 0;
  4810. }
  4811. ent = &skill_tree[c][j];
  4812. meets = 1;
  4813. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4814. {
  4815. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4816. {
  4817. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  4818. clif_displaymessage(fd, atcmd_output);
  4819. meets = 0;
  4820. }
  4821. }
  4822. if (meets == 1) {
  4823. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4824. }
  4825. return 0;
  4826. }
  4827. // Hand a ring with partners name on it to this char
  4828. void getring (struct map_session_data* sd)
  4829. {
  4830. char flag = 0;
  4831. unsigned short item_id;
  4832. struct item item_tmp;
  4833. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4834. memset(&item_tmp, 0, sizeof(item_tmp));
  4835. item_tmp.nameid = item_id;
  4836. item_tmp.identify = 1;
  4837. item_tmp.card[0] = 255;
  4838. item_tmp.card[2] = sd->status.partner_id;
  4839. item_tmp.card[3] = sd->status.partner_id >> 16;
  4840. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4841. clif_additem(sd,0,0,flag);
  4842. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4);
  4843. }
  4844. }
  4845. /*==========================================
  4846. * @marry by [MouseJstr], fixed by Lupus
  4847. * Marry two players
  4848. *------------------------------------------*/
  4849. ACMD_FUNC(marry)
  4850. {
  4851. struct map_session_data *pl_sd = NULL;
  4852. char player_name[NAME_LENGTH] = "";
  4853. nullpo_retr(-1, sd);
  4854. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4855. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4856. return -1;
  4857. }
  4858. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4859. clif_displaymessage(fd, msg_txt(sd,3));
  4860. return -1;
  4861. }
  4862. if (pc_marriage(sd, pl_sd)) {
  4863. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4864. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4865. getring(sd); // Auto-give named rings (Aru)
  4866. getring(pl_sd);
  4867. return 0;
  4868. }
  4869. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4870. return -1;
  4871. }
  4872. /*==========================================
  4873. * @divorce by [MouseJstr], fixed by [Lupus]
  4874. * divorce two players
  4875. *------------------------------------------*/
  4876. ACMD_FUNC(divorce)
  4877. {
  4878. nullpo_retr(-1, sd);
  4879. if (!pc_divorce(sd)) {
  4880. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4881. clif_displaymessage(fd, atcmd_output);
  4882. return -1;
  4883. }
  4884. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4885. clif_displaymessage(fd, atcmd_output);
  4886. return 0;
  4887. }
  4888. /*==========================================
  4889. * @changelook by [Celest]
  4890. *------------------------------------------*/
  4891. ACMD_FUNC(changelook)
  4892. {
  4893. int i, j = 0, k = 0;
  4894. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4895. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4896. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4897. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4898. return -1;
  4899. } else if ( i == 2 ) {
  4900. if (j < 1 || j > 7)
  4901. j = 1;
  4902. j = pos[j - 1];
  4903. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4904. k = j; // swap
  4905. j = LOOK_HEAD_TOP;
  4906. }
  4907. clif_changelook(&sd->bl,j,k);
  4908. return 0;
  4909. }
  4910. /*==========================================
  4911. * @autotrade by durf [Lupus] [Paradox924X]
  4912. * Turns on/off Autotrade for a specific player
  4913. *------------------------------------------*/
  4914. ACMD_FUNC(autotrade) {
  4915. nullpo_retr(-1, sd);
  4916. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4917. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4918. return -1;
  4919. }
  4920. if( pc_isdead(sd) ) {
  4921. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4922. return -1;
  4923. }
  4924. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4925. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4926. return -1;
  4927. }
  4928. sd->state.autotrade = 1;
  4929. sd->state.monster_ignore = 1;
  4930. if( sd->state.vending ){
  4931. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
  4932. Sql_ShowDebug( mmysql_handle );
  4933. }
  4934. }else if( sd->state.buyingstore ){
  4935. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstore_db, sd->buyer_id ) != SQL_SUCCESS ){
  4936. Sql_ShowDebug( mmysql_handle );
  4937. }
  4938. }
  4939. if( battle_config.at_timeout ) {
  4940. int timeout = atoi(message);
  4941. 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, 0);
  4942. }
  4943. channel_pcquit(sd,0xF); //leave all chan
  4944. clif_authfail_fd(sd->fd, 15);
  4945. chrif_save(sd,3);
  4946. return 0;
  4947. }
  4948. /*==========================================
  4949. * @changegm by durf (changed by Lupus)
  4950. * Changes Master of your Guild to a specified guild member
  4951. *------------------------------------------*/
  4952. ACMD_FUNC(changegm)
  4953. {
  4954. struct guild *g;
  4955. struct map_session_data *pl_sd;
  4956. nullpo_retr(-1, sd);
  4957. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4958. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  4959. return -1;
  4960. }
  4961. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4962. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  4963. return -1;
  4964. }
  4965. if( !message[0] ) {
  4966. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  4967. return -1;
  4968. }
  4969. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4970. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  4971. return -1;
  4972. }
  4973. guild_gm_change(sd->status.guild_id, pl_sd);
  4974. return 0;
  4975. }
  4976. /*==========================================
  4977. * @changeleader by Skotlex
  4978. * Changes the leader of a party.
  4979. *------------------------------------------*/
  4980. ACMD_FUNC(changeleader)
  4981. {
  4982. nullpo_retr(-1, sd);
  4983. if( !message[0] )
  4984. {
  4985. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  4986. return -1;
  4987. }
  4988. if (party_changeleader(sd, map_nick2sd((char *) message),NULL))
  4989. return 0;
  4990. return -1;
  4991. }
  4992. /*==========================================
  4993. * @partyoption by Skotlex
  4994. * Used to change the item share setting of a party.
  4995. *------------------------------------------*/
  4996. ACMD_FUNC(partyoption)
  4997. {
  4998. struct party_data *p;
  4999. int mi, option;
  5000. char w1[16], w2[16];
  5001. nullpo_retr(-1, sd);
  5002. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5003. {
  5004. clif_displaymessage(fd, msg_txt(sd,282));
  5005. return -1;
  5006. }
  5007. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5008. if (mi == MAX_PARTY)
  5009. return -1; //Shouldn't happen
  5010. if (!p->party.member[mi].leader)
  5011. {
  5012. clif_displaymessage(fd, msg_txt(sd,282));
  5013. return -1;
  5014. }
  5015. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5016. {
  5017. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5018. return -1;
  5019. }
  5020. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5021. //Change item share type.
  5022. if (option != p->party.item)
  5023. party_changeoption(sd, p->party.exp, option);
  5024. else
  5025. clif_displaymessage(fd, msg_txt(sd,286));
  5026. return 0;
  5027. }
  5028. /*==========================================
  5029. * @autoloot by Upa-Kun
  5030. * Turns on/off AutoLoot for a specific player
  5031. *------------------------------------------*/
  5032. ACMD_FUNC(autoloot)
  5033. {
  5034. int rate;
  5035. nullpo_retr(-1, sd);
  5036. // autoloot command without value
  5037. if(!message || !*message)
  5038. {
  5039. if (sd->state.autoloot)
  5040. rate = 0;
  5041. else
  5042. rate = 10000;
  5043. } else {
  5044. double drate;
  5045. drate = atof(message);
  5046. rate = (int)(drate*100);
  5047. }
  5048. if (rate < 0) rate = 0;
  5049. if (rate > 10000) rate = 10000;
  5050. sd->state.autoloot = rate;
  5051. if (sd->state.autoloot) {
  5052. 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.
  5053. clif_displaymessage(fd, atcmd_output);
  5054. }else
  5055. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5056. return 0;
  5057. }
  5058. /*==========================================
  5059. * @alootid
  5060. *------------------------------------------*/
  5061. ACMD_FUNC(autolootitem)
  5062. {
  5063. struct item_data *item_data = NULL;
  5064. int i;
  5065. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5066. nullpo_retr(-1, sd);
  5067. if (message && *message) {
  5068. if (message[0] == '+') {
  5069. message++;
  5070. action = 1;
  5071. }
  5072. else if (message[0] == '-') {
  5073. message++;
  5074. action = 2;
  5075. }
  5076. else if (!strcmp(message,"reset"))
  5077. action = 4;
  5078. }
  5079. if (action < 3) // add or remove
  5080. {
  5081. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5082. item_data = itemdb_searchname(message);
  5083. if (!item_data) {
  5084. // No items founds in the DB with Id or Name
  5085. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5086. return -1;
  5087. }
  5088. }
  5089. switch(action) {
  5090. case 1:
  5091. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5092. if (i != AUTOLOOTITEM_SIZE) {
  5093. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5094. return -1;
  5095. }
  5096. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5097. if (i == AUTOLOOTITEM_SIZE) {
  5098. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5099. return -1;
  5100. }
  5101. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5102. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5103. clif_displaymessage(fd, atcmd_output);
  5104. sd->state.autolooting = 1;
  5105. break;
  5106. case 2:
  5107. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5108. if (i == AUTOLOOTITEM_SIZE) {
  5109. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5110. return -1;
  5111. }
  5112. sd->state.autolootid[i] = 0;
  5113. 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.
  5114. clif_displaymessage(fd, atcmd_output);
  5115. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5116. if (i == AUTOLOOTITEM_SIZE) {
  5117. sd->state.autolooting = 0;
  5118. }
  5119. break;
  5120. case 3:
  5121. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5122. clif_displaymessage(fd, atcmd_output);
  5123. 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>".
  5124. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5125. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5126. if (i == AUTOLOOTITEM_SIZE) {
  5127. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5128. } else {
  5129. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5130. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5131. {
  5132. if (sd->state.autolootid[i] == 0)
  5133. continue;
  5134. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5135. 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);
  5136. continue;
  5137. }
  5138. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5139. clif_displaymessage(fd, atcmd_output);
  5140. }
  5141. }
  5142. break;
  5143. case 4:
  5144. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5145. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5146. sd->state.autolooting = 0;
  5147. break;
  5148. }
  5149. return 0;
  5150. }
  5151. /*==========================================
  5152. * @autoloottype
  5153. * Flags:
  5154. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5155. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5156. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5157. * 262144: IT_CASH
  5158. *------------------------------------------
  5159. * Credits:
  5160. * chriser
  5161. * Aleos
  5162. *------------------------------------------*/
  5163. ACMD_FUNC(autoloottype)
  5164. {
  5165. uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5166. enum item_types type = -1;
  5167. int ITEM_MAX = 1533;
  5168. nullpo_retr(-1, sd);
  5169. if (message && *message) {
  5170. if (message[0] == '+') {
  5171. message++;
  5172. action = 1;
  5173. }
  5174. else if (message[0] == '-') {
  5175. message++;
  5176. action = 2;
  5177. }
  5178. else if (!strcmp(message,"reset"))
  5179. action = 4;
  5180. }
  5181. if (action < 3) { // add or remove
  5182. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5183. type = IT_HEALING;
  5184. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5185. type = IT_USABLE;
  5186. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5187. type = IT_ETC;
  5188. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5189. type = IT_ARMOR;
  5190. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5191. type = IT_WEAPON;
  5192. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5193. type = IT_CARD;
  5194. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5195. type = IT_PETEGG;
  5196. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5197. type = IT_PETARMOR;
  5198. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5199. type = IT_AMMO;
  5200. else {
  5201. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5202. return -1;
  5203. }
  5204. }
  5205. switch (action) {
  5206. case 1:
  5207. if (sd->state.autoloottype&(1<<type)) {
  5208. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5209. return -1;
  5210. }
  5211. if (sd->state.autoloottype == ITEM_MAX) {
  5212. 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>.
  5213. return -1;
  5214. }
  5215. sd->state.autoloottype |= (1<<type); // Stores the type
  5216. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5217. clif_displaymessage(fd, atcmd_output);
  5218. break;
  5219. case 2:
  5220. if (!(sd->state.autoloottype&(1<<type))) {
  5221. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5222. return -1;
  5223. }
  5224. sd->state.autoloottype &= ~(1<<type);
  5225. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5226. clif_displaymessage(fd, atcmd_output);
  5227. break;
  5228. case 3:
  5229. 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>".
  5230. 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
  5231. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5232. if (sd->state.autoloottype == 0)
  5233. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5234. else {
  5235. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5236. while (i < IT_MAX) {
  5237. if (sd->state.autoloottype&(1<<i)) {
  5238. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(i), i);
  5239. clif_displaymessage(fd, atcmd_output);
  5240. }
  5241. i++;
  5242. }
  5243. }
  5244. break;
  5245. case 4:
  5246. sd->state.autoloottype = 0;
  5247. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5248. break;
  5249. }
  5250. return 0;
  5251. }
  5252. /**
  5253. * No longer available, keeping here just in case it's back someday. [Ind]
  5254. **/
  5255. /*==========================================
  5256. * It is made to rain.
  5257. *------------------------------------------*/
  5258. //ACMD_FUNC(rain)
  5259. //{
  5260. // nullpo_retr(-1, sd);
  5261. // if (map[sd->bl.m].flag.rain) {
  5262. // map[sd->bl.m].flag.rain=0;
  5263. // clif_weather(sd->bl.m);
  5264. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5265. // } else {
  5266. // map[sd->bl.m].flag.rain=1;
  5267. // clif_weather(sd->bl.m);
  5268. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5269. // }
  5270. // return 0;
  5271. //}
  5272. /*==========================================
  5273. * It is made to snow.
  5274. *------------------------------------------*/
  5275. ACMD_FUNC(snow)
  5276. {
  5277. nullpo_retr(-1, sd);
  5278. if (map[sd->bl.m].flag.snow) {
  5279. map[sd->bl.m].flag.snow=0;
  5280. clif_weather(sd->bl.m);
  5281. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5282. } else {
  5283. map[sd->bl.m].flag.snow=1;
  5284. clif_weather(sd->bl.m);
  5285. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5286. }
  5287. return 0;
  5288. }
  5289. /*==========================================
  5290. * Cherry tree snowstorm is made to fall. (Sakura)
  5291. *------------------------------------------*/
  5292. ACMD_FUNC(sakura)
  5293. {
  5294. nullpo_retr(-1, sd);
  5295. if (map[sd->bl.m].flag.sakura) {
  5296. map[sd->bl.m].flag.sakura=0;
  5297. clif_weather(sd->bl.m);
  5298. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5299. } else {
  5300. map[sd->bl.m].flag.sakura=1;
  5301. clif_weather(sd->bl.m);
  5302. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5303. }
  5304. return 0;
  5305. }
  5306. /*==========================================
  5307. * Clouds appear.
  5308. *------------------------------------------*/
  5309. ACMD_FUNC(clouds)
  5310. {
  5311. nullpo_retr(-1, sd);
  5312. if (map[sd->bl.m].flag.clouds) {
  5313. map[sd->bl.m].flag.clouds=0;
  5314. clif_weather(sd->bl.m);
  5315. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5316. } else {
  5317. map[sd->bl.m].flag.clouds=1;
  5318. clif_weather(sd->bl.m);
  5319. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5320. }
  5321. return 0;
  5322. }
  5323. /*==========================================
  5324. * Different type of clouds using effect 516
  5325. *------------------------------------------*/
  5326. ACMD_FUNC(clouds2)
  5327. {
  5328. nullpo_retr(-1, sd);
  5329. if (map[sd->bl.m].flag.clouds2) {
  5330. map[sd->bl.m].flag.clouds2=0;
  5331. clif_weather(sd->bl.m);
  5332. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5333. } else {
  5334. map[sd->bl.m].flag.clouds2=1;
  5335. clif_weather(sd->bl.m);
  5336. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5337. }
  5338. return 0;
  5339. }
  5340. /*==========================================
  5341. * Fog hangs over.
  5342. *------------------------------------------*/
  5343. ACMD_FUNC(fog)
  5344. {
  5345. nullpo_retr(-1, sd);
  5346. if (map[sd->bl.m].flag.fog) {
  5347. map[sd->bl.m].flag.fog=0;
  5348. clif_weather(sd->bl.m);
  5349. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5350. } else {
  5351. map[sd->bl.m].flag.fog=1;
  5352. clif_weather(sd->bl.m);
  5353. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5354. }
  5355. return 0;
  5356. }
  5357. /*==========================================
  5358. * Fallen leaves fall.
  5359. *------------------------------------------*/
  5360. ACMD_FUNC(leaves)
  5361. {
  5362. nullpo_retr(-1, sd);
  5363. if (map[sd->bl.m].flag.leaves) {
  5364. map[sd->bl.m].flag.leaves=0;
  5365. clif_weather(sd->bl.m);
  5366. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5367. } else {
  5368. map[sd->bl.m].flag.leaves=1;
  5369. clif_weather(sd->bl.m);
  5370. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5371. }
  5372. return 0;
  5373. }
  5374. /*==========================================
  5375. * Fireworks appear.
  5376. *------------------------------------------*/
  5377. ACMD_FUNC(fireworks)
  5378. {
  5379. nullpo_retr(-1, sd);
  5380. if (map[sd->bl.m].flag.fireworks) {
  5381. map[sd->bl.m].flag.fireworks=0;
  5382. clif_weather(sd->bl.m);
  5383. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5384. } else {
  5385. map[sd->bl.m].flag.fireworks=1;
  5386. clif_weather(sd->bl.m);
  5387. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5388. }
  5389. return 0;
  5390. }
  5391. /*==========================================
  5392. * Clearing Weather Effects by Dexity
  5393. *------------------------------------------*/
  5394. ACMD_FUNC(clearweather)
  5395. {
  5396. nullpo_retr(-1, sd);
  5397. /**
  5398. * No longer available, keeping here just in case it's back someday. [Ind]
  5399. **/
  5400. //map[sd->bl.m].flag.rain=0;
  5401. map[sd->bl.m].flag.snow=0;
  5402. map[sd->bl.m].flag.sakura=0;
  5403. map[sd->bl.m].flag.clouds=0;
  5404. map[sd->bl.m].flag.clouds2=0;
  5405. map[sd->bl.m].flag.fog=0;
  5406. map[sd->bl.m].flag.fireworks=0;
  5407. map[sd->bl.m].flag.leaves=0;
  5408. clif_weather(sd->bl.m);
  5409. clif_displaymessage(fd, msg_txt(sd,291));
  5410. return 0;
  5411. }
  5412. /*===============================================================
  5413. * Sound Command - plays a sound for everyone around! [Codemaster]
  5414. *---------------------------------------------------------------*/
  5415. ACMD_FUNC(sound)
  5416. {
  5417. char sound_file[100];
  5418. memset(sound_file, '\0', sizeof(sound_file));
  5419. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5420. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5421. return -1;
  5422. }
  5423. if(strstr(sound_file, ".wav") == NULL)
  5424. strcat(sound_file, ".wav");
  5425. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5426. return 0;
  5427. }
  5428. /*==========================================
  5429. * MOB Search
  5430. *------------------------------------------*/
  5431. ACMD_FUNC(mobsearch)
  5432. {
  5433. char mob_name[100];
  5434. int mob_id;
  5435. int number = 0;
  5436. struct s_mapiterator* it;
  5437. nullpo_retr(-1, sd);
  5438. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5439. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5440. return -1;
  5441. }
  5442. if ((mob_id = atoi(mob_name)) == 0)
  5443. mob_id = mobdb_searchname(mob_name);
  5444. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5445. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5446. clif_displaymessage(fd, atcmd_output);
  5447. return -1;
  5448. }
  5449. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5450. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5451. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5452. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5453. clif_displaymessage(fd, atcmd_output);
  5454. it = mapit_geteachmob();
  5455. for(;;)
  5456. {
  5457. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5458. if( md == NULL )
  5459. break;// no more mobs
  5460. if( md->bl.m != sd->bl.m )
  5461. continue;
  5462. if( mob_id != -1 && md->mob_id != mob_id )
  5463. continue;
  5464. ++number;
  5465. if( md->spawn_timer == INVALID_TIMER )
  5466. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5467. else
  5468. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5469. clif_displaymessage(fd, atcmd_output);
  5470. }
  5471. mapit_free(it);
  5472. return 0;
  5473. }
  5474. /*==========================================
  5475. * @cleanmap - cleans items on the ground
  5476. * @cleanarea - cleans items on the ground within an specified area
  5477. *------------------------------------------*/
  5478. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5479. {
  5480. nullpo_ret(bl);
  5481. map_clearflooritem(bl);
  5482. return 0;
  5483. }
  5484. ACMD_FUNC(cleanmap)
  5485. {
  5486. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5487. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5488. return 0;
  5489. }
  5490. ACMD_FUNC(cleanarea)
  5491. {
  5492. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5493. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  5494. 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);
  5495. }
  5496. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  5497. 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);
  5498. }
  5499. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  5500. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5501. }
  5502. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5503. return 0;
  5504. }
  5505. /*==========================================
  5506. * make a NPC/PET talk
  5507. * @npctalkc [SnakeDrak]
  5508. *------------------------------------------*/
  5509. ACMD_FUNC(npctalk)
  5510. {
  5511. char name[NAME_LENGTH],mes[100],temp[100];
  5512. struct npc_data *nd;
  5513. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5514. unsigned long color=0;
  5515. if (sd->sc.cant.chat)
  5516. return -1; //no "chatting" while muted.
  5517. if(!ifcolor) {
  5518. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5519. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5520. return -1;
  5521. }
  5522. }
  5523. else {
  5524. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5525. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5526. return -1;
  5527. }
  5528. }
  5529. if (!(nd = npc_name2id(name))) {
  5530. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5531. return -1;
  5532. }
  5533. strtok(name, "#"); // discard extra name identifier if present
  5534. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5535. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5536. else clif_disp_overhead(&nd->bl, temp);
  5537. return 0;
  5538. }
  5539. ACMD_FUNC(pettalk)
  5540. {
  5541. char mes[100],temp[100];
  5542. struct pet_data *pd;
  5543. nullpo_retr(-1, sd);
  5544. if ( battle_config.min_chat_delay ) {
  5545. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5546. return 0;
  5547. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5548. }
  5549. if(!sd->status.pet_id || !(pd=sd->pd))
  5550. {
  5551. clif_displaymessage(fd, msg_txt(sd,184));
  5552. return -1;
  5553. }
  5554. if (sd->sc.cant.chat)
  5555. return -1; //no "chatting" while muted.
  5556. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5557. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5558. return -1;
  5559. }
  5560. if (message[0] == '/')
  5561. {// pet emotion processing
  5562. const char* emo[] = {
  5563. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5564. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5565. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5566. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5567. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5568. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5569. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5570. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5571. "/whisp"
  5572. };
  5573. int i;
  5574. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5575. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5576. if( i < ARRAYLENGTH(emo) )
  5577. {
  5578. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5579. sd->emotionlasttime = time(NULL);
  5580. return 0;
  5581. }
  5582. sd->emotionlasttime = time(NULL);
  5583. clif_emotion(&pd->bl, i);
  5584. return 0;
  5585. }
  5586. }
  5587. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5588. clif_disp_overhead(&pd->bl, temp);
  5589. return 0;
  5590. }
  5591. /// @users - displays the number of players present on each map (and percentage)
  5592. /// #users displays on the target user instead of self
  5593. ACMD_FUNC(users)
  5594. {
  5595. char buf[CHAT_SIZE_MAX];
  5596. int i;
  5597. int users[MAX_MAPINDEX];
  5598. int users_all;
  5599. struct s_mapiterator* iter;
  5600. memset(users, 0, sizeof(users));
  5601. users_all = 0;
  5602. // count users on each map
  5603. iter = mapit_getallusers();
  5604. for(;;)
  5605. {
  5606. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5607. if( sd2 == NULL )
  5608. break;// no more users
  5609. if( sd2->mapindex >= MAX_MAPINDEX )
  5610. continue;// invalid mapindex
  5611. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5612. if( users_all < INT_MAX ) ++users_all;
  5613. }
  5614. mapit_free(iter);
  5615. // display results for each map
  5616. for( i = 0; i < MAX_MAPINDEX; ++i )
  5617. {
  5618. if( users[i] == 0 )
  5619. continue;// empty
  5620. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5621. clif_displaymessage(sd->fd, buf);
  5622. }
  5623. // display overall count
  5624. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5625. clif_displaymessage(sd->fd, buf);
  5626. return 0;
  5627. }
  5628. /*==========================================
  5629. *
  5630. *------------------------------------------*/
  5631. ACMD_FUNC(reset)
  5632. {
  5633. pc_resetstate(sd);
  5634. pc_resetskill(sd,1);
  5635. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5636. clif_displaymessage(fd, atcmd_output);
  5637. return 0;
  5638. }
  5639. /*==========================================
  5640. *
  5641. *------------------------------------------*/
  5642. ACMD_FUNC(summon)
  5643. {
  5644. char name[NAME_LENGTH];
  5645. int mob_id = 0;
  5646. int duration = 0;
  5647. struct mob_data *md;
  5648. unsigned int tick=gettick();
  5649. nullpo_retr(-1, sd);
  5650. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5651. {
  5652. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5653. return -1;
  5654. }
  5655. if (duration < 1)
  5656. duration =1;
  5657. else if (duration > 60)
  5658. duration =60;
  5659. if ((mob_id = atoi(name)) == 0)
  5660. mob_id = mobdb_searchname(name);
  5661. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5662. {
  5663. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5664. return -1;
  5665. }
  5666. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5667. if(!md)
  5668. return -1;
  5669. md->master_id=sd->bl.id;
  5670. md->special_state.ai=AI_ATTACK;
  5671. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5672. clif_specialeffect(&md->bl,344,AREA);
  5673. mob_spawn(md);
  5674. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5675. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5676. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5677. return 0;
  5678. }
  5679. /*==========================================
  5680. * @adjgroup
  5681. * Temporarily move player to another group
  5682. * Useful during beta testing to allow players to use GM commands for short periods of time
  5683. *------------------------------------------*/
  5684. ACMD_FUNC(adjgroup)
  5685. {
  5686. int new_group = 0;
  5687. nullpo_retr(-1, sd);
  5688. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5689. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5690. return -1;
  5691. }
  5692. if (!pc_group_exists(new_group)) {
  5693. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5694. return -1;
  5695. }
  5696. sd->group_id = new_group;
  5697. pc_group_pc_load(sd);/* update cache */
  5698. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5699. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5700. return 0;
  5701. }
  5702. /*==========================================
  5703. * @trade by [MouseJstr]
  5704. * Open a trade window with a remote player
  5705. *------------------------------------------*/
  5706. ACMD_FUNC(trade)
  5707. {
  5708. struct map_session_data *pl_sd = NULL;
  5709. nullpo_retr(-1, sd);
  5710. if (!message || !*message) {
  5711. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5712. return -1;
  5713. }
  5714. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5715. {
  5716. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5717. return -1;
  5718. }
  5719. trade_traderequest(sd, pl_sd);
  5720. return 0;
  5721. }
  5722. /*==========================================
  5723. * @setbattleflag by [MouseJstr]
  5724. * set a battle_config flag without having to reboot
  5725. *------------------------------------------*/
  5726. ACMD_FUNC(setbattleflag)
  5727. {
  5728. char flag[128], value[128];
  5729. nullpo_retr(-1, sd);
  5730. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5731. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5732. return -1;
  5733. }
  5734. if (battle_set_value(flag, value) == 0)
  5735. {
  5736. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5737. return -1;
  5738. }
  5739. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5740. return 0;
  5741. }
  5742. /*==========================================
  5743. * @unmute [Valaris]
  5744. *------------------------------------------*/
  5745. ACMD_FUNC(unmute)
  5746. {
  5747. struct map_session_data *pl_sd = NULL;
  5748. nullpo_retr(-1, sd);
  5749. if (!message || !*message) {
  5750. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5751. return -1;
  5752. }
  5753. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5754. {
  5755. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5756. return -1;
  5757. }
  5758. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5759. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5760. return -1;
  5761. }
  5762. pl_sd->status.manner = 0;
  5763. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5764. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5765. return 0;
  5766. }
  5767. /*==========================================
  5768. * @uptime by MC Cameri
  5769. *------------------------------------------*/
  5770. ACMD_FUNC(uptime)
  5771. {
  5772. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5773. minute = 60, days = 0, hours = 0, minutes = 0;
  5774. nullpo_retr(-1, sd);
  5775. seconds = get_uptime();
  5776. days = seconds/day;
  5777. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5778. hours = seconds/hour;
  5779. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5780. minutes = seconds/minute;
  5781. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5782. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5783. clif_displaymessage(fd, atcmd_output);
  5784. return 0;
  5785. }
  5786. /*==========================================
  5787. * @changesex <sex>
  5788. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5789. *------------------------------------------*/
  5790. ACMD_FUNC(changesex)
  5791. {
  5792. int i;
  5793. nullpo_retr(-1, sd);
  5794. pc_resetskill(sd,4);
  5795. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5796. for( i=0; i<EQI_MAX; i++ )
  5797. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5798. chrif_changesex(sd);
  5799. return 0;
  5800. }
  5801. /*================================================
  5802. * @mute - Mutes a player for a set amount of time
  5803. *------------------------------------------------*/
  5804. ACMD_FUNC(mute)
  5805. {
  5806. struct map_session_data *pl_sd = NULL;
  5807. int manner;
  5808. nullpo_retr(-1, sd);
  5809. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5810. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5811. return -1;
  5812. }
  5813. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5814. {
  5815. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5816. return -1;
  5817. }
  5818. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5819. {
  5820. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5821. return -1;
  5822. }
  5823. clif_manner_message(sd, 0);
  5824. clif_manner_message(pl_sd, 5);
  5825. if( pl_sd->status.manner < manner ) {
  5826. pl_sd->status.manner -= manner;
  5827. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5828. } else {
  5829. pl_sd->status.manner = 0;
  5830. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5831. }
  5832. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5833. return 0;
  5834. }
  5835. /*==========================================
  5836. * @refresh (like @jumpto <<yourself>>)
  5837. *------------------------------------------*/
  5838. ACMD_FUNC(refresh)
  5839. {
  5840. nullpo_retr(-1, sd);
  5841. clif_refresh(sd);
  5842. return 0;
  5843. }
  5844. ACMD_FUNC(refreshall)
  5845. {
  5846. struct map_session_data* iter_sd;
  5847. struct s_mapiterator* iter;
  5848. nullpo_retr(-1, sd);
  5849. iter = mapit_getallusers();
  5850. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5851. clif_refresh(iter_sd);
  5852. mapit_free(iter);
  5853. return 0;
  5854. }
  5855. /*==========================================
  5856. * @identify
  5857. * => GM's magnifier.
  5858. *------------------------------------------*/
  5859. ACMD_FUNC(identify)
  5860. {
  5861. int i,num;
  5862. nullpo_retr(-1, sd);
  5863. for(i=num=0;i<MAX_INVENTORY;i++){
  5864. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5865. num++;
  5866. }
  5867. }
  5868. if (num > 0) {
  5869. clif_item_identify_list(sd);
  5870. } else {
  5871. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5872. }
  5873. return 0;
  5874. }
  5875. /*===============================================
  5876. * @identifyall
  5877. * => Indentify all items in inventory - Akinari
  5878. *-----------------------------------------------*/
  5879. ACMD_FUNC(identifyall)
  5880. {
  5881. int i;
  5882. nullpo_retr(-1, sd);
  5883. for(i=0; i<MAX_INVENTORY; i++) {
  5884. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  5885. sd->status.inventory[i].identify=1;
  5886. clif_item_identified(sd,i,0);
  5887. }
  5888. }
  5889. return 0;
  5890. }
  5891. /*==========================================
  5892. * @gmotd (Global MOTD)
  5893. * by davidsiaw :P
  5894. *------------------------------------------*/
  5895. ACMD_FUNC(gmotd)
  5896. {
  5897. FILE* fp;
  5898. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5899. {
  5900. char buf[CHAT_SIZE_MAX];
  5901. size_t len;
  5902. while( fgets(buf, sizeof(buf), fp) )
  5903. {
  5904. if( buf[0] == '/' && buf[1] == '/' )
  5905. {
  5906. continue;
  5907. }
  5908. len = strlen(buf);
  5909. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5910. {// strip trailing EOL characters
  5911. len--;
  5912. }
  5913. if( len )
  5914. {
  5915. buf[len] = 0;
  5916. intif_broadcast(buf, len+1, 0);
  5917. }
  5918. }
  5919. fclose(fp);
  5920. }
  5921. return 0;
  5922. }
  5923. ACMD_FUNC(misceffect)
  5924. {
  5925. int effect = 0;
  5926. nullpo_retr(-1, sd);
  5927. if (!message || !*message)
  5928. return -1;
  5929. if (sscanf(message, "%d", &effect) < 1)
  5930. return -1;
  5931. clif_misceffect(&sd->bl,effect);
  5932. return 0;
  5933. }
  5934. /*==========================================
  5935. * MAIL SYSTEM
  5936. *------------------------------------------*/
  5937. ACMD_FUNC(mail)
  5938. {
  5939. nullpo_ret(sd);
  5940. mail_openmail(sd);
  5941. return 0;
  5942. }
  5943. /*==========================================
  5944. * Show Monster DB Info v 1.0
  5945. * originally by [Lupus]
  5946. *------------------------------------------*/
  5947. ACMD_FUNC(mobinfo)
  5948. {
  5949. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5950. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5951. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5952. char atcmd_output2[CHAT_SIZE_MAX];
  5953. struct item_data *item_data;
  5954. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5955. int count;
  5956. int i, k;
  5957. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5958. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5959. if (!message || !*message) {
  5960. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5961. return -1;
  5962. }
  5963. // If monster identifier/name argument is a name
  5964. if ((i = mobdb_checkid(atoi(message))))
  5965. {
  5966. mob_array[0] = mob_db(i);
  5967. count = 1;
  5968. } else
  5969. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5970. if (!count) {
  5971. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5972. return -1;
  5973. }
  5974. if (count > MAX_SEARCH) {
  5975. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  5976. clif_displaymessage(fd, atcmd_output);
  5977. count = MAX_SEARCH;
  5978. }
  5979. for (k = 0; k < count; k++) {
  5980. unsigned int j,base_exp,job_exp;
  5981. mob = mob_array[k];
  5982. base_exp = mob->base_exp;
  5983. job_exp = mob->job_exp;
  5984. #ifdef RENEWAL_EXP
  5985. if( battle_config.atcommand_mobinfo_type ) {
  5986. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  5987. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  5988. }
  5989. #endif
  5990. #ifdef VIP_ENABLE
  5991. // Display EXP rate increase for VIP.
  5992. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase)) {
  5993. base_exp += battle_config.vip_base_exp_increase;
  5994. job_exp += battle_config.vip_job_exp_increase;
  5995. }
  5996. #endif
  5997. // stats
  5998. if (mob->mexp)
  5999. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6000. else
  6001. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6002. clif_displaymessage(fd, atcmd_output);
  6003. 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
  6004. clif_displaymessage(fd, atcmd_output);
  6005. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6006. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6007. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6008. clif_displaymessage(fd, atcmd_output);
  6009. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6010. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6011. mob->range2 , mob->range3, msize[mob->status.size],
  6012. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6013. clif_displaymessage(fd, atcmd_output);
  6014. // drops
  6015. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6016. strcpy(atcmd_output, " ");
  6017. j = 0;
  6018. for (i = 0; i < MAX_MOB_DROP; i++) {
  6019. int droprate;
  6020. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6021. continue;
  6022. droprate = mob->dropitem[i].p;
  6023. #ifdef RENEWAL_DROP
  6024. if( battle_config.atcommand_mobinfo_type ) {
  6025. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 2) / 100;
  6026. if (droprate <= 0 && !battle_config.drop_rate0item)
  6027. droprate = 1;
  6028. }
  6029. #endif
  6030. #ifdef VIP_ENABLE
  6031. // Display item rate increase for VIP.
  6032. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6033. droprate += battle_config.vip_drop_increase;
  6034. #endif
  6035. if (item_data->slot)
  6036. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6037. else
  6038. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6039. strcat(atcmd_output, atcmd_output2);
  6040. if (++j % 3 == 0) {
  6041. clif_displaymessage(fd, atcmd_output);
  6042. strcpy(atcmd_output, " ");
  6043. }
  6044. }
  6045. if (j == 0)
  6046. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6047. else if (j % 3 != 0)
  6048. clif_displaymessage(fd, atcmd_output);
  6049. // mvp
  6050. if (mob->mexp) {
  6051. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6052. clif_displaymessage(fd, atcmd_output);
  6053. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6054. j = 0;
  6055. for (i = 0; i < MAX_MVP_DROP; i++) {
  6056. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6057. continue;
  6058. if (mob->mvpitem[i].p > 0) {
  6059. j++;
  6060. if (j == 1) {
  6061. if (item_data->slot)
  6062. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->mvpitem[i].p / 100);
  6063. else
  6064. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6065. } else {
  6066. if (item_data->slot)
  6067. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->mvpitem[i].p / 100);
  6068. else
  6069. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6070. }
  6071. strcat(atcmd_output, atcmd_output2);
  6072. }
  6073. }
  6074. if (j == 0)
  6075. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6076. else
  6077. clif_displaymessage(fd, atcmd_output);
  6078. }
  6079. }
  6080. return 0;
  6081. }
  6082. /*=========================================
  6083. * @showmobs by KarLaeda
  6084. * => For 15 sec displays the mobs on minimap
  6085. *------------------------------------------*/
  6086. ACMD_FUNC(showmobs)
  6087. {
  6088. char mob_name[100];
  6089. int mob_id;
  6090. int number = 0;
  6091. struct s_mapiterator* it;
  6092. nullpo_retr(-1, sd);
  6093. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6094. return -1;
  6095. if((mob_id = atoi(mob_name)) == 0)
  6096. mob_id = mobdb_searchname(mob_name);
  6097. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6098. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6099. clif_displaymessage(fd, atcmd_output);
  6100. return 0;
  6101. }
  6102. if(mob_db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6103. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6104. return 0;
  6105. }
  6106. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6107. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6108. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6109. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6110. mob_name, mapindex_id2name(sd->mapindex));
  6111. clif_displaymessage(fd, atcmd_output);
  6112. it = mapit_geteachmob();
  6113. for(;;)
  6114. {
  6115. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6116. if( md == NULL )
  6117. break;// no more mobs
  6118. if( md->bl.m != sd->bl.m )
  6119. continue;
  6120. if( mob_id != -1 && md->mob_id != mob_id )
  6121. continue;
  6122. if( md->special_state.ai || md->master_id )
  6123. continue; // hide slaves and player summoned mobs
  6124. if( md->spawn_timer != INVALID_TIMER )
  6125. continue; // hide mobs waiting for respawn
  6126. ++number;
  6127. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6128. }
  6129. mapit_free(it);
  6130. return 0;
  6131. }
  6132. /*==========================================
  6133. * homunculus level up [orn]
  6134. *------------------------------------------*/
  6135. ACMD_FUNC(homlevel)
  6136. {
  6137. TBL_HOM * hd;
  6138. int level = 0, i = 0;
  6139. nullpo_retr(-1, sd);
  6140. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6141. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6142. return -1;
  6143. }
  6144. if ( !hom_is_active(sd->hd) ) {
  6145. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6146. return -1;
  6147. }
  6148. hd = sd->hd;
  6149. for (i = 1; i <= level && hd->exp_next; i++){
  6150. hd->homunculus.exp += hd->exp_next;
  6151. if( !hom_levelup(hd) )
  6152. break;
  6153. }
  6154. status_calc_homunculus(hd, SCO_NONE);
  6155. status_percent_heal(&hd->bl, 100, 100);
  6156. clif_specialeffect(&hd->bl,568,AREA);
  6157. return 0;
  6158. }
  6159. /*==========================================
  6160. * homunculus evolution H [orn]
  6161. *------------------------------------------*/
  6162. ACMD_FUNC(homevolution)
  6163. {
  6164. nullpo_retr(-1, sd);
  6165. if ( !hom_is_active(sd->hd) ) {
  6166. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6167. return -1;
  6168. }
  6169. if ( !hom_evolution(sd->hd) ) {
  6170. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6171. return -1;
  6172. }
  6173. clif_homskillinfoblock(sd);
  6174. return 0;
  6175. }
  6176. ACMD_FUNC(hommutate)
  6177. {
  6178. int homun_id, m_class = 0, m_id;
  6179. nullpo_retr(-1, sd);
  6180. if (!hom_is_active(sd->hd)) {
  6181. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6182. return -1;
  6183. }
  6184. if (!message || !*message) {
  6185. homun_id = 6048 + (rnd() % 4);
  6186. } else {
  6187. homun_id = atoi(message);
  6188. }
  6189. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6190. m_id = hom_class2mapid(homun_id);
  6191. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6192. hom_mutate(sd->hd, homun_id);
  6193. } else {
  6194. clif_emotion(&sd->hd->bl, E_SWT);
  6195. }
  6196. return 0;
  6197. }
  6198. /*==========================================
  6199. * call choosen homunculus [orn]
  6200. *------------------------------------------*/
  6201. ACMD_FUNC(makehomun)
  6202. {
  6203. int homunid;
  6204. nullpo_retr(-1, sd);
  6205. if ( sd->status.hom_id ) {
  6206. clif_displaymessage(fd, msg_txt(sd,450));
  6207. return -1;
  6208. }
  6209. if (!message || !*message) {
  6210. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6211. return -1;
  6212. }
  6213. homunid = atoi(message);
  6214. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6215. {
  6216. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6217. return -1;
  6218. }
  6219. hom_create_request(sd,homunid);
  6220. return 0;
  6221. }
  6222. /*==========================================
  6223. * modify homunculus intimacy [orn]
  6224. *------------------------------------------*/
  6225. ACMD_FUNC(homfriendly)
  6226. {
  6227. int friendly = 0;
  6228. nullpo_retr(-1, sd);
  6229. if ( !hom_is_active(sd->hd) ) {
  6230. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6231. return -1;
  6232. }
  6233. if (!message || !*message) {
  6234. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6235. return -1;
  6236. }
  6237. friendly = atoi(message);
  6238. friendly = cap_value(friendly, 0, 1000);
  6239. sd->hd->homunculus.intimacy = friendly * 100 ;
  6240. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6241. return 0;
  6242. }
  6243. /*==========================================
  6244. * modify homunculus hunger [orn]
  6245. *------------------------------------------*/
  6246. ACMD_FUNC(homhungry)
  6247. {
  6248. int hungry = 0;
  6249. nullpo_retr(-1, sd);
  6250. if ( !hom_is_active(sd->hd) ) {
  6251. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6252. return -1;
  6253. }
  6254. if (!message || !*message) {
  6255. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6256. return -1;
  6257. }
  6258. hungry = atoi(message);
  6259. hungry = cap_value(hungry, 0, 100);
  6260. sd->hd->homunculus.hunger = hungry;
  6261. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6262. return 0;
  6263. }
  6264. /*==========================================
  6265. * make the homunculus speak [orn]
  6266. *------------------------------------------*/
  6267. ACMD_FUNC(homtalk)
  6268. {
  6269. char mes[100],temp[100];
  6270. nullpo_retr(-1, sd);
  6271. if ( battle_config.min_chat_delay ) {
  6272. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6273. return 0;
  6274. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6275. }
  6276. if (sd->sc.cant.chat)
  6277. return -1; //no "chatting" while muted.
  6278. if ( !hom_is_active(sd->hd) ) {
  6279. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6280. return -1;
  6281. }
  6282. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6283. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6284. return -1;
  6285. }
  6286. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6287. clif_disp_overhead(&sd->hd->bl, temp);
  6288. return 0;
  6289. }
  6290. /*==========================================
  6291. * Show homunculus stats
  6292. *------------------------------------------*/
  6293. ACMD_FUNC(hominfo)
  6294. {
  6295. struct homun_data *hd;
  6296. struct status_data *status;
  6297. nullpo_retr(-1, sd);
  6298. if ( !hom_is_active(sd->hd) ) {
  6299. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6300. return -1;
  6301. }
  6302. hd = sd->hd;
  6303. status = status_get_status_data(&hd->bl);
  6304. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6305. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6306. status->hp, status->max_hp, status->sp, status->max_sp);
  6307. clif_displaymessage(fd, atcmd_output);
  6308. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6309. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6310. clif_displaymessage(fd, atcmd_output);
  6311. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6312. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6313. clif_displaymessage(fd, atcmd_output);
  6314. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6315. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6316. status->str, status->agi, status->vit,
  6317. status->int_, status->dex, status->luk);
  6318. clif_displaymessage(fd, atcmd_output);
  6319. return 0;
  6320. }
  6321. ACMD_FUNC(homstats)
  6322. {
  6323. struct homun_data *hd;
  6324. struct s_homunculus_db *db;
  6325. struct s_homunculus *hom;
  6326. int lv, min, max, evo;
  6327. nullpo_retr(-1, sd);
  6328. if ( !hom_is_active(sd->hd) ) {
  6329. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6330. return -1;
  6331. }
  6332. hd = sd->hd;
  6333. hom = &hd->homunculus;
  6334. db = hd->homunculusDB;
  6335. lv = hom->level;
  6336. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6337. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6338. clif_displaymessage(fd, atcmd_output);
  6339. lv--; //Since the first increase is at level 2.
  6340. evo = (hom->class_ == db->evo_class);
  6341. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6342. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6343. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6344. clif_displaymessage(fd, atcmd_output);
  6345. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6346. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6347. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6348. clif_displaymessage(fd, atcmd_output);
  6349. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6350. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6351. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6352. clif_displaymessage(fd, atcmd_output);
  6353. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6354. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6355. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6356. clif_displaymessage(fd, atcmd_output);
  6357. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6358. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6359. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6360. clif_displaymessage(fd, atcmd_output);
  6361. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6362. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6363. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6364. clif_displaymessage(fd, atcmd_output);
  6365. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6366. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6367. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6368. clif_displaymessage(fd, atcmd_output);
  6369. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6370. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6371. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6372. clif_displaymessage(fd, atcmd_output);
  6373. return 0;
  6374. }
  6375. ACMD_FUNC(homshuffle)
  6376. {
  6377. nullpo_retr(-1, sd);
  6378. if(!sd->hd)
  6379. return -1; // nothing to do
  6380. if(!hom_shuffle(sd->hd))
  6381. return -1;
  6382. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6383. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6384. return 0;
  6385. }
  6386. /*==========================================
  6387. * Show Items DB Info v 1.0
  6388. * originally by [Lupus]
  6389. *------------------------------------------*/
  6390. ACMD_FUNC(iteminfo)
  6391. {
  6392. struct item_data *item_array[MAX_SEARCH];
  6393. int i, count = 1;
  6394. if (!message || !*message) {
  6395. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6396. return -1;
  6397. }
  6398. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6399. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6400. if (!count) {
  6401. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6402. return -1;
  6403. }
  6404. if (count > MAX_SEARCH) {
  6405. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6406. clif_displaymessage(fd, atcmd_output);
  6407. count = MAX_SEARCH;
  6408. }
  6409. for (i = 0; i < count; i++) {
  6410. struct item_data * item_data = item_array[i];
  6411. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6412. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6413. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6414. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6415. );
  6416. clif_displaymessage(fd, atcmd_output);
  6417. 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
  6418. clif_displaymessage(fd, atcmd_output);
  6419. if (item_data->maxchance == -1)
  6420. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6421. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6422. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6423. else
  6424. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6425. clif_displaymessage(fd, atcmd_output);
  6426. }
  6427. return 0;
  6428. }
  6429. /*==========================================
  6430. * Show who drops the item.
  6431. *------------------------------------------*/
  6432. ACMD_FUNC(whodrops)
  6433. {
  6434. struct item_data *item_data, *item_array[MAX_SEARCH];
  6435. int i,j, count = 1;
  6436. if (!message || !*message) {
  6437. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6438. return -1;
  6439. }
  6440. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6441. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6442. if (!count) {
  6443. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6444. return -1;
  6445. }
  6446. if (count > MAX_SEARCH) {
  6447. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6448. clif_displaymessage(fd, atcmd_output);
  6449. count = MAX_SEARCH;
  6450. }
  6451. for (i = 0; i < count; i++) {
  6452. item_data = item_array[i];
  6453. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6454. clif_displaymessage(fd, atcmd_output);
  6455. if (item_data->mob[0].chance == 0) {
  6456. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6457. clif_displaymessage(fd, atcmd_output);
  6458. } else {
  6459. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6460. clif_displaymessage(fd, atcmd_output);
  6461. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6462. {
  6463. int dropchance = item_data->mob[j].chance;
  6464. #ifdef RENEWAL_DROP
  6465. if( battle_config.atcommand_mobinfo_type )
  6466. dropchance = dropchance * pc_level_penalty_mod(sd, mob_db(item_data->mob[j].id)->lv, mob_db(item_data->mob[j].id)->status.class_, 2) / 100;
  6467. #endif
  6468. #ifdef VIP_ENABLE
  6469. // Display item rate increase for VIP.
  6470. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6471. dropchance += battle_config.vip_drop_increase;
  6472. #endif
  6473. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, dropchance/100.);
  6474. clif_displaymessage(fd, atcmd_output);
  6475. }
  6476. }
  6477. }
  6478. return 0;
  6479. }
  6480. ACMD_FUNC(whereis)
  6481. {
  6482. struct mob_db *mob_array[MAX_SEARCH];
  6483. int count;
  6484. int i, j, k;
  6485. if (!message || !*message) {
  6486. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6487. return -1;
  6488. }
  6489. // If monster identifier/name argument is a name
  6490. if ((i = mobdb_checkid(atoi(message))))
  6491. {
  6492. mob_array[0] = mob_db(i);
  6493. count = 1;
  6494. } else
  6495. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6496. if (!count) {
  6497. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6498. return -1;
  6499. }
  6500. if (count > MAX_SEARCH) {
  6501. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6502. clif_displaymessage(fd, atcmd_output);
  6503. count = MAX_SEARCH;
  6504. }
  6505. for (k = 0; k < count; k++) {
  6506. struct mob_db *mob = mob_array[k];
  6507. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6508. clif_displaymessage(fd, atcmd_output);
  6509. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6510. {
  6511. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6512. if (j < 0) continue;
  6513. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6514. clif_displaymessage(fd, atcmd_output);
  6515. }
  6516. if (i == 0)
  6517. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6518. }
  6519. return 0;
  6520. }
  6521. ACMD_FUNC(version)
  6522. {
  6523. pc_show_version(sd);
  6524. return 0;
  6525. }
  6526. /*==========================================
  6527. * @mutearea by MouseJstr
  6528. *------------------------------------------*/
  6529. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6530. {
  6531. int time, id;
  6532. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6533. if (pl_sd == NULL)
  6534. return 0;
  6535. id = va_arg(ap, int);
  6536. time = va_arg(ap, int);
  6537. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6538. pl_sd->status.manner -= time;
  6539. if (pl_sd->status.manner < 0)
  6540. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6541. else
  6542. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6543. }
  6544. return 0;
  6545. }
  6546. ACMD_FUNC(mutearea)
  6547. {
  6548. int time;
  6549. nullpo_ret(sd);
  6550. if (!message || !*message) {
  6551. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6552. return -1;
  6553. }
  6554. time = atoi(message);
  6555. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6556. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6557. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6558. return 0;
  6559. }
  6560. ACMD_FUNC(rates)
  6561. {
  6562. char buf[CHAT_SIZE_MAX];
  6563. int base_exp_rate = 0, job_exp_rate = 0, item_rate = 0;
  6564. nullpo_ret(sd);
  6565. memset(buf, '\0', sizeof(buf));
  6566. #ifdef VIP_ENABLE
  6567. // Display EXP and item rate increase for VIP.
  6568. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase || battle_config.vip_drop_increase)) {
  6569. base_exp_rate += battle_config.vip_base_exp_increase;
  6570. job_exp_rate += battle_config.vip_job_exp_increase;
  6571. item_rate += battle_config.vip_drop_increase;
  6572. }
  6573. #endif
  6574. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6575. (battle_config.base_exp_rate+base_exp_rate)/100., (battle_config.job_exp_rate+job_exp_rate)/100.);
  6576. clif_displaymessage(fd, buf);
  6577. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6578. (battle_config.item_rate_common+item_rate)/100., (battle_config.item_rate_heal+item_rate)/100., (battle_config.item_rate_use+item_rate)/100., (battle_config.item_rate_equip+item_rate)/100., (battle_config.item_rate_card+item_rate)/100.);
  6579. clif_displaymessage(fd, buf);
  6580. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6581. (battle_config.item_rate_common_boss+item_rate)/100., (battle_config.item_rate_heal_boss+item_rate)/100., (battle_config.item_rate_use_boss+item_rate)/100., (battle_config.item_rate_equip_boss+item_rate)/100., (battle_config.item_rate_card_boss+item_rate)/100.);
  6582. clif_displaymessage(fd, buf);
  6583. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6584. (battle_config.item_rate_mvp+item_rate)/100., (battle_config.item_rate_adddrop+item_rate)/100., (battle_config.item_rate_treasure+item_rate)/100.);
  6585. clif_displaymessage(fd, buf);
  6586. return 0;
  6587. }
  6588. /*==========================================
  6589. * @me by lordalfa
  6590. * => Displays the OUTPUT string on top of the Visible players Heads.
  6591. *------------------------------------------*/
  6592. ACMD_FUNC(me)
  6593. {
  6594. char tempmes[CHAT_SIZE_MAX];
  6595. nullpo_retr(-1, sd);
  6596. memset(tempmes, '\0', sizeof(tempmes));
  6597. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6598. if (sd->sc.cant.chat)
  6599. return -1; //no "chatting" while muted.
  6600. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6601. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6602. return -1;
  6603. }
  6604. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6605. clif_disp_overhead(&sd->bl, atcmd_output);
  6606. return 0;
  6607. }
  6608. /*==========================================
  6609. * @size
  6610. * => Resize your character sprite. [Valaris]
  6611. *------------------------------------------*/
  6612. ACMD_FUNC(size)
  6613. {
  6614. int size = 0;
  6615. nullpo_retr(-1, sd);
  6616. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6617. if(sd->state.size) {
  6618. sd->state.size = SZ_SMALL;
  6619. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6620. }
  6621. sd->state.size = size;
  6622. if( size == SZ_MEDIUM )
  6623. clif_specialeffect(&sd->bl,420,AREA);
  6624. else if( size == SZ_BIG )
  6625. clif_specialeffect(&sd->bl,422,AREA);
  6626. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6627. return 0;
  6628. }
  6629. ACMD_FUNC(sizeall)
  6630. {
  6631. int size;
  6632. struct map_session_data *pl_sd;
  6633. struct s_mapiterator* iter;
  6634. size = atoi(message);
  6635. size = cap_value(size,0,2);
  6636. iter = mapit_getallusers();
  6637. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6638. if( pl_sd->state.size != size ) {
  6639. if( pl_sd->state.size ) {
  6640. pl_sd->state.size = SZ_SMALL;
  6641. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6642. }
  6643. pl_sd->state.size = size;
  6644. if( size == SZ_MEDIUM )
  6645. clif_specialeffect(&pl_sd->bl,420,AREA);
  6646. else if( size == SZ_BIG )
  6647. clif_specialeffect(&pl_sd->bl,422,AREA);
  6648. }
  6649. }
  6650. mapit_free(iter);
  6651. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6652. return 0;
  6653. }
  6654. ACMD_FUNC(sizeguild)
  6655. {
  6656. int size = 0, i;
  6657. char guild[NAME_LENGTH];
  6658. struct map_session_data *pl_sd;
  6659. struct guild *g;
  6660. nullpo_retr(-1, sd);
  6661. memset(guild, '\0', sizeof(guild));
  6662. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6663. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6664. return -1;
  6665. }
  6666. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6667. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6668. return -1;
  6669. }
  6670. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6671. for( i = 0; i < g->max_member; i++ ) {
  6672. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6673. if( pl_sd->state.size ) {
  6674. pl_sd->state.size = SZ_SMALL;
  6675. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6676. }
  6677. pl_sd->state.size = size;
  6678. if( size == SZ_MEDIUM )
  6679. clif_specialeffect(&pl_sd->bl,420,AREA);
  6680. else if( size == SZ_BIG )
  6681. clif_specialeffect(&pl_sd->bl,422,AREA);
  6682. }
  6683. }
  6684. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6685. return 0;
  6686. }
  6687. /*==========================================
  6688. * @monsterignore
  6689. * => Makes monsters ignore you. [Valaris]
  6690. *------------------------------------------*/
  6691. ACMD_FUNC(monsterignore)
  6692. {
  6693. nullpo_retr(-1, sd);
  6694. if (!sd->state.monster_ignore) {
  6695. sd->state.monster_ignore = 1;
  6696. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6697. } else {
  6698. sd->state.monster_ignore = 0;
  6699. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6700. }
  6701. return 0;
  6702. }
  6703. /*==========================================
  6704. * @fakename
  6705. * => Gives your character a fake name. [Valaris]
  6706. *------------------------------------------*/
  6707. ACMD_FUNC(fakename)
  6708. {
  6709. nullpo_retr(-1, sd);
  6710. if( !message || !*message )
  6711. {
  6712. if( sd->fakename[0] )
  6713. {
  6714. sd->fakename[0] = '\0';
  6715. clif_charnameack(0, &sd->bl);
  6716. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6717. return 0;
  6718. }
  6719. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6720. return -1;
  6721. }
  6722. if( strlen(message) < 2 )
  6723. {
  6724. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6725. return -1;
  6726. }
  6727. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6728. clif_charnameack(0, &sd->bl);
  6729. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6730. return 0;
  6731. }
  6732. /*==========================================
  6733. * Ragnarok Resources
  6734. *------------------------------------------*/
  6735. ACMD_FUNC(mapflag) {
  6736. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6737. #define setflag( cmd ) \
  6738. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6739. map[ sd->bl.m ].flag.cmd = flag;\
  6740. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6741. clif_displaymessage(sd->fd,atcmd_output);\
  6742. return 0;\
  6743. }
  6744. char flag_name[100];
  6745. short flag=0,i;
  6746. nullpo_retr(-1, sd);
  6747. memset(flag_name, '\0', sizeof(flag_name));
  6748. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  6749. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6750. clif_displaymessage(sd->fd,"----------------------------------");
  6751. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6752. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6753. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6754. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6755. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6756. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6757. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6758. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6759. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6760. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6761. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6762. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6763. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6764. checkflag(nolockon); checkflag(notomb);
  6765. #ifdef ADJUST_SKILL_DAMAGE
  6766. checkflag(skill_damage);
  6767. #endif
  6768. clif_displaymessage(sd->fd," ");
  6769. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6770. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6771. return 1;
  6772. }
  6773. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6774. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6775. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6776. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6777. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6778. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6779. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6780. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6781. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6782. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6783. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  6784. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  6785. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  6786. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  6787. setflag(nolockon); setflag(notomb);
  6788. #ifdef ADJUST_SKILL_DAMAGE
  6789. setflag(skill_damage);
  6790. #endif
  6791. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6792. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6793. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6794. clif_displaymessage(sd->fd,"----------------------------------");
  6795. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6796. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6797. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6798. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6799. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  6800. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  6801. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb");
  6802. #ifdef ADJUST_SKILL_DAMAGE
  6803. clif_displaymessage(sd->fd,"skill_damage");
  6804. #endif
  6805. #undef checkflag
  6806. #undef setflag
  6807. return 0;
  6808. }
  6809. /*===================================
  6810. * Remove some messages
  6811. *-----------------------------------*/
  6812. ACMD_FUNC(showexp)
  6813. {
  6814. if (sd->state.showexp) {
  6815. sd->state.showexp = 0;
  6816. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6817. return 0;
  6818. }
  6819. sd->state.showexp = 1;
  6820. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6821. return 0;
  6822. }
  6823. ACMD_FUNC(showzeny)
  6824. {
  6825. if (sd->state.showzeny) {
  6826. sd->state.showzeny = 0;
  6827. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6828. return 0;
  6829. }
  6830. sd->state.showzeny = 1;
  6831. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6832. return 0;
  6833. }
  6834. ACMD_FUNC(showdelay)
  6835. {
  6836. if (sd->state.showdelay) {
  6837. sd->state.showdelay = 0;
  6838. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6839. return 0;
  6840. }
  6841. sd->state.showdelay = 1;
  6842. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6843. return 0;
  6844. }
  6845. /*==========================================
  6846. * Duel organizing functions [LuzZza]
  6847. *
  6848. * @duel [limit|nick] - create a duel
  6849. * @invite <nick> - invite player
  6850. * @accept - accept invitation
  6851. * @reject - reject invitation
  6852. * @leave - leave duel
  6853. *------------------------------------------*/
  6854. ACMD_FUNC(invite)
  6855. {
  6856. unsigned int did = sd->duel_group;
  6857. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6858. if(did == 0) {
  6859. // "Duel: @invite without @duel."
  6860. clif_displaymessage(fd, msg_txt(sd,350));
  6861. return 0;
  6862. }
  6863. if(duel_list[did].max_players_limit > 0 &&
  6864. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6865. // "Duel: Limit of players is reached."
  6866. clif_displaymessage(fd, msg_txt(sd,351));
  6867. return 0;
  6868. }
  6869. if(target_sd == NULL) {
  6870. // "Duel: Player not found."
  6871. clif_displaymessage(fd, msg_txt(sd,352));
  6872. return 0;
  6873. }
  6874. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6875. // "Duel: Player already in duel."
  6876. clif_displaymessage(fd, msg_txt(sd,353));
  6877. return 0;
  6878. }
  6879. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6880. {
  6881. sprintf(atcmd_output, msg_txt(sd,364), message);
  6882. clif_displaymessage(fd, atcmd_output);
  6883. return 0;
  6884. }
  6885. duel_invite(did, sd, target_sd);
  6886. // "Duel: Invitation has been sent."
  6887. clif_displaymessage(fd, msg_txt(sd,354));
  6888. return 0;
  6889. }
  6890. ACMD_FUNC(duel)
  6891. {
  6892. unsigned int maxpl = 0;
  6893. if(sd->duel_group > 0) {
  6894. duel_showinfo(sd->duel_group, sd);
  6895. return 0;
  6896. }
  6897. if(sd->duel_invite > 0) {
  6898. // "Duel: @duel without @reject."
  6899. clif_displaymessage(fd, msg_txt(sd,355));
  6900. return 0;
  6901. }
  6902. if(!duel_checktime(sd)) {
  6903. char output[CHAT_SIZE_MAX];
  6904. // "Duel: You can take part in duel only one time per %d minutes."
  6905. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6906. clif_displaymessage(fd, output);
  6907. return 0;
  6908. }
  6909. if( message[0] ) {
  6910. if(sscanf(message, "%u", &maxpl) >= 1) {
  6911. if(maxpl < 2 || maxpl > 65535) {
  6912. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  6913. return 0;
  6914. }
  6915. duel_create(sd, maxpl);
  6916. } else {
  6917. struct map_session_data *target_sd;
  6918. target_sd = map_nick2sd((char *)message);
  6919. if(target_sd != NULL) {
  6920. unsigned int newduel;
  6921. if((newduel = duel_create(sd, 2)) != -1) {
  6922. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6923. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  6924. return 0;
  6925. }
  6926. duel_invite(newduel, sd, target_sd);
  6927. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  6928. }
  6929. } else {
  6930. // "Duel: Player not found."
  6931. clif_displaymessage(fd, msg_txt(sd,352));
  6932. return 0;
  6933. }
  6934. }
  6935. } else
  6936. duel_create(sd, 0);
  6937. return 0;
  6938. }
  6939. ACMD_FUNC(leave)
  6940. {
  6941. if(sd->duel_group <= 0) {
  6942. // "Duel: @leave without @duel."
  6943. clif_displaymessage(fd, msg_txt(sd,358));
  6944. return 0;
  6945. }
  6946. duel_leave(sd->duel_group, sd);
  6947. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  6948. return 0;
  6949. }
  6950. ACMD_FUNC(accept)
  6951. {
  6952. if(!duel_checktime(sd)) {
  6953. char output[CHAT_SIZE_MAX];
  6954. // "Duel: You can take part in duel only one time per %d minutes."
  6955. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6956. clif_displaymessage(fd, output);
  6957. return 0;
  6958. }
  6959. if(sd->duel_invite <= 0) {
  6960. // "Duel: @accept without invititation."
  6961. clif_displaymessage(fd, msg_txt(sd,360));
  6962. return 0;
  6963. }
  6964. 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 )
  6965. {
  6966. // "Duel: Limit of players is reached."
  6967. clif_displaymessage(fd, msg_txt(sd,351));
  6968. return 0;
  6969. }
  6970. duel_accept(sd->duel_invite, sd);
  6971. // "Duel: Invitation has been accepted."
  6972. clif_displaymessage(fd, msg_txt(sd,361));
  6973. return 0;
  6974. }
  6975. ACMD_FUNC(reject)
  6976. {
  6977. if(sd->duel_invite <= 0) {
  6978. // "Duel: @reject without invititation."
  6979. clif_displaymessage(fd, msg_txt(sd,362));
  6980. return 0;
  6981. }
  6982. duel_reject(sd->duel_invite, sd);
  6983. // "Duel: Invitation has been rejected."
  6984. clif_displaymessage(fd, msg_txt(sd,363));
  6985. return 0;
  6986. }
  6987. /*===================================
  6988. * Cash Points
  6989. *-----------------------------------*/
  6990. ACMD_FUNC(cash)
  6991. {
  6992. char output[128];
  6993. int value;
  6994. int ret=0;
  6995. nullpo_retr(-1, sd);
  6996. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6997. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  6998. return -1;
  6999. }
  7000. if( !strcmpi(command+1,"cash") )
  7001. {
  7002. if( value > 0 ) {
  7003. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7004. // If this option is set, the message is already sent by pc function
  7005. if( !battle_config.cashshop_show_points ){
  7006. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  7007. clif_disp_onlyself(sd, output, strlen(output));
  7008. }
  7009. }
  7010. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7011. } else {
  7012. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7013. value = -sd->cashPoints;
  7014. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7015. // If this option is set, the message is already sent by pc function
  7016. if( !battle_config.cashshop_show_points ){
  7017. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  7018. clif_disp_onlyself(sd, output, strlen(output));
  7019. }
  7020. }
  7021. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7022. }
  7023. }
  7024. else
  7025. { // @points
  7026. if( value > 0 ) {
  7027. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7028. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  7029. clif_disp_onlyself(sd, output, strlen(output));
  7030. }
  7031. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7032. } else {
  7033. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7034. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  7035. clif_disp_onlyself(sd, output, strlen(output));
  7036. }
  7037. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7038. }
  7039. }
  7040. return 0;
  7041. }
  7042. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7043. ACMD_FUNC(clone)
  7044. {
  7045. int x=0,y=0,flag=0,master=0,i=0;
  7046. struct map_session_data *pl_sd=NULL;
  7047. if (!message || !*message) {
  7048. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7049. return 0;
  7050. }
  7051. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7052. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7053. return 0;
  7054. }
  7055. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7056. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7057. return 0;
  7058. }
  7059. if (strcmpi(command+1, "clone") == 0)
  7060. flag = 1;
  7061. else if (strcmpi(command+1, "slaveclone") == 0) {
  7062. flag = 2;
  7063. if(pc_isdead(sd)){
  7064. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7065. return 0;
  7066. }
  7067. master = sd->bl.id;
  7068. if (battle_config.atc_slave_clone_limit
  7069. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7070. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7071. return 0;
  7072. }
  7073. }
  7074. do {
  7075. x = sd->bl.x + (rnd() % 10 - 5);
  7076. y = sd->bl.y + (rnd() % 10 - 5);
  7077. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7078. if (i >= 10) {
  7079. x = sd->bl.x;
  7080. y = sd->bl.y;
  7081. }
  7082. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7083. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7084. return 0;
  7085. }
  7086. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7087. return 0;
  7088. }
  7089. /*=====================================
  7090. * Autorejecting Invites/Deals [LuzZza]
  7091. * Usage: @noask
  7092. *-------------------------------------*/
  7093. ACMD_FUNC(noask)
  7094. {
  7095. if(sd->state.noask) {
  7096. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7097. sd->state.noask = 0;
  7098. } else {
  7099. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7100. sd->state.noask = 1;
  7101. }
  7102. return 0;
  7103. }
  7104. /*=====================================
  7105. * Send a @request message to all GMs of lowest_gm_level.
  7106. * Usage: @request <petition>
  7107. *-------------------------------------*/
  7108. ACMD_FUNC(request)
  7109. {
  7110. if (!message || !*message) {
  7111. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7112. return -1;
  7113. }
  7114. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7115. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7116. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7117. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7118. return 0;
  7119. }
  7120. /*==========================================
  7121. * Feel (SG save map) Reset [HiddenDragon]
  7122. *------------------------------------------*/
  7123. ACMD_FUNC(feelreset)
  7124. {
  7125. pc_resetfeel(sd);
  7126. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7127. return 0;
  7128. }
  7129. /*==========================================
  7130. * AUCTION SYSTEM
  7131. *------------------------------------------*/
  7132. ACMD_FUNC(auction)
  7133. {
  7134. nullpo_ret(sd);
  7135. if (!battle_config.feature_auction) {
  7136. clif_colormes(sd, color_table[COLOR_RED], msg_txt(sd, 517));
  7137. return 0;
  7138. }
  7139. clif_Auction_openwindow(sd);
  7140. return 0;
  7141. }
  7142. /*==========================================
  7143. * Kill Steal Protection
  7144. *------------------------------------------*/
  7145. ACMD_FUNC(ksprotection)
  7146. {
  7147. nullpo_retr(-1,sd);
  7148. if( sd->state.noks ) {
  7149. sd->state.noks = 0;
  7150. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7151. }
  7152. else
  7153. {
  7154. if( !message || !*message || !strcmpi(message, "party") )
  7155. { // Default is Party
  7156. sd->state.noks = 2;
  7157. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7158. }
  7159. else if( !strcmpi(message, "self") )
  7160. {
  7161. sd->state.noks = 1;
  7162. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7163. }
  7164. else if( !strcmpi(message, "guild") )
  7165. {
  7166. sd->state.noks = 3;
  7167. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7168. }
  7169. else
  7170. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7171. }
  7172. return 0;
  7173. }
  7174. /*==========================================
  7175. * Map Kill Steal Protection Setting
  7176. *------------------------------------------*/
  7177. ACMD_FUNC(allowks)
  7178. {
  7179. nullpo_retr(-1,sd);
  7180. if( map[sd->bl.m].flag.allowks ) {
  7181. map[sd->bl.m].flag.allowks = 0;
  7182. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7183. } else {
  7184. map[sd->bl.m].flag.allowks = 1;
  7185. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7186. }
  7187. return 0;
  7188. }
  7189. ACMD_FUNC(resetstat)
  7190. {
  7191. nullpo_retr(-1, sd);
  7192. pc_resetstate(sd);
  7193. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  7194. clif_displaymessage(fd, atcmd_output);
  7195. return 0;
  7196. }
  7197. ACMD_FUNC(resetskill)
  7198. {
  7199. nullpo_retr(-1,sd);
  7200. pc_resetskill(sd,1);
  7201. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  7202. clif_displaymessage(fd, atcmd_output);
  7203. return 0;
  7204. }
  7205. /*==========================================
  7206. * #storagelist: Displays the items list of a player's storage.
  7207. * #cartlist: Displays contents of target's cart.
  7208. * #itemlist: Displays contents of target's inventory.
  7209. *------------------------------------------*/
  7210. ACMD_FUNC(itemlist)
  7211. {
  7212. int i, j, count, counter;
  7213. const char* location;
  7214. const struct item* items;
  7215. int size;
  7216. StringBuf buf;
  7217. nullpo_retr(-1, sd);
  7218. if( strcmp(command+1, "storagelist") == 0 ) {
  7219. location = "storage";
  7220. items = sd->status.storage.items;
  7221. size = sd->storage_size;
  7222. } else if( strcmp(command+1, "cartlist") == 0 ) {
  7223. location = "cart";
  7224. items = sd->status.cart;
  7225. size = MAX_CART;
  7226. } else if( strcmp(command+1, "itemlist") == 0 ) {
  7227. location = "inventory";
  7228. items = sd->status.inventory;
  7229. size = MAX_INVENTORY;
  7230. } else
  7231. return 1;
  7232. StringBuf_Init(&buf);
  7233. count = 0; // total slots occupied
  7234. counter = 0; // total items found
  7235. for( i = 0; i < size; ++i ) {
  7236. const struct item* it = &items[i];
  7237. struct item_data* itd;
  7238. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7239. continue;
  7240. counter += it->amount;
  7241. count++;
  7242. if( count == 1 ) {
  7243. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7244. clif_displaymessage(fd, StringBuf_Value(&buf));
  7245. StringBuf_Clear(&buf);
  7246. }
  7247. if( it->refine )
  7248. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7249. else
  7250. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7251. if( it->equip ) {
  7252. char equipstr[CHAT_SIZE_MAX];
  7253. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7254. if( it->equip&EQP_GARMENT )
  7255. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7256. if( it->equip&EQP_ACC_L )
  7257. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7258. if( it->equip&EQP_ARMOR )
  7259. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7260. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7261. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7262. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7263. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7264. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7265. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7266. if( it->equip&EQP_SHOES )
  7267. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7268. if( it->equip&EQP_ACC_R )
  7269. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7270. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7271. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7272. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7273. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7274. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7275. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7276. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7277. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7278. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7279. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7280. if( (it->equip&EQP_HELM) == EQP_HELM )
  7281. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7282. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7283. strcat(equipstr, msg_txt(sd,518));
  7284. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7285. strcat(equipstr, msg_txt(sd,519));
  7286. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7287. strcat(equipstr, msg_txt(sd,520));
  7288. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7289. strcat(equipstr, msg_txt(sd,521));
  7290. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7291. strcat(equipstr, msg_txt(sd,522));
  7292. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7293. strcat(equipstr, msg_txt(sd,523));
  7294. if( it->equip&EQP_COSTUME_GARMENT )
  7295. strcat(equipstr, msg_txt(sd,524));
  7296. //if( it->equip&EQP_COSTUME_FLOOR )
  7297. //strcat(equipstr, msg_txt(sd,525));
  7298. if( it->equip&EQP_AMMO )
  7299. strcat(equipstr, msg_txt(sd,526));
  7300. if( it->equip&EQP_SHADOW_ARMOR )
  7301. strcat(equipstr, msg_txt(sd,527));
  7302. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7303. strcat(equipstr, msg_txt(sd,528));
  7304. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7305. strcat(equipstr, msg_txt(sd,529));
  7306. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7307. strcat(equipstr, msg_txt(sd,530));
  7308. if( it->equip&EQP_SHADOW_SHOES )
  7309. strcat(equipstr, msg_txt(sd,531));
  7310. if( it->equip&EQP_SHADOW_ACC_R )
  7311. strcat(equipstr, msg_txt(sd,532));
  7312. if( it->equip&EQP_SHADOW_ACC_L )
  7313. strcat(equipstr, msg_txt(sd,533));
  7314. // remove final ', '
  7315. equipstr[strlen(equipstr) - 2] = '\0';
  7316. StringBuf_AppendStr(&buf, equipstr);
  7317. }
  7318. clif_displaymessage(fd, StringBuf_Value(&buf));
  7319. StringBuf_Clear(&buf);
  7320. if( it->card[0] == CARD0_PET ) { // pet egg
  7321. if (it->card[3])
  7322. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7323. else
  7324. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7325. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7326. 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)
  7327. } else if(it->card[0] == CARD0_CREATE) { // created item
  7328. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7329. } else { // normal item
  7330. int counter2 = 0;
  7331. for( j = 0; j < itd->slot; ++j ) {
  7332. struct item_data* card;
  7333. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7334. continue;
  7335. counter2++;
  7336. if( counter2 == 1 )
  7337. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7338. if( counter2 != 1 )
  7339. StringBuf_AppendStr(&buf, ", ");
  7340. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7341. }
  7342. if( counter2 > 0 )
  7343. StringBuf_AppendStr(&buf, ")");
  7344. }
  7345. if( StringBuf_Length(&buf) > 0 )
  7346. clif_displaymessage(fd, StringBuf_Value(&buf));
  7347. StringBuf_Clear(&buf);
  7348. }
  7349. if( count == 0 )
  7350. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7351. else
  7352. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7353. clif_displaymessage(fd, StringBuf_Value(&buf));
  7354. StringBuf_Destroy(&buf);
  7355. return 0;
  7356. }
  7357. ACMD_FUNC(stats)
  7358. {
  7359. char job_jobname[100];
  7360. char output[CHAT_SIZE_MAX];
  7361. int i;
  7362. struct {
  7363. const char* format;
  7364. int value;
  7365. } output_table[] = {
  7366. { "Base Level - %d", 0 },
  7367. { NULL, 0 },
  7368. { "Hp - %d", 0 },
  7369. { "MaxHp - %d", 0 },
  7370. { "Sp - %d", 0 },
  7371. { "MaxSp - %d", 0 },
  7372. { "Str - %3d", 0 },
  7373. { "Agi - %3d", 0 },
  7374. { "Vit - %3d", 0 },
  7375. { "Int - %3d", 0 },
  7376. { "Dex - %3d", 0 },
  7377. { "Luk - %3d", 0 },
  7378. { "Zeny - %d", 0 },
  7379. { "Free SK Points - %d", 0 },
  7380. { "JobChangeLvl (2nd) - %d", 0 },
  7381. { "JobChangeLvl (3rd) - %d", 0 },
  7382. { NULL, 0 }
  7383. };
  7384. memset(job_jobname, '\0', sizeof(job_jobname));
  7385. memset(output, '\0', sizeof(output));
  7386. //direct array initialization with variables is not standard C compliant.
  7387. output_table[0].value = sd->status.base_level;
  7388. output_table[1].format = job_jobname;
  7389. output_table[1].value = sd->status.job_level;
  7390. output_table[2].value = sd->status.hp;
  7391. output_table[3].value = sd->status.max_hp;
  7392. output_table[4].value = sd->status.sp;
  7393. output_table[5].value = sd->status.max_sp;
  7394. output_table[6].value = sd->status.str;
  7395. output_table[7].value = sd->status.agi;
  7396. output_table[8].value = sd->status.vit;
  7397. output_table[9].value = sd->status.int_;
  7398. output_table[10].value = sd->status.dex;
  7399. output_table[11].value = sd->status.luk;
  7400. output_table[12].value = sd->status.zeny;
  7401. output_table[13].value = sd->status.skill_point;
  7402. output_table[14].value = sd->change_level_2nd;
  7403. output_table[15].value = sd->change_level_3rd;
  7404. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7405. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7406. clif_displaymessage(fd, output);
  7407. for (i = 0; output_table[i].format != NULL; i++) {
  7408. sprintf(output, output_table[i].format, output_table[i].value);
  7409. clif_displaymessage(fd, output);
  7410. }
  7411. return 0;
  7412. }
  7413. ACMD_FUNC(delitem)
  7414. {
  7415. char item_name[100];
  7416. unsigned short nameid;
  7417. int amount = 0, total, idx;
  7418. struct item_data* id;
  7419. nullpo_retr(-1, sd);
  7420. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7421. {
  7422. 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>).
  7423. return -1;
  7424. }
  7425. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7426. {
  7427. nameid = id->nameid;
  7428. }
  7429. else
  7430. {
  7431. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7432. return -1;
  7433. }
  7434. total = amount;
  7435. // delete items
  7436. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7437. {
  7438. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7439. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7440. {// delete pet
  7441. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7442. }
  7443. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7444. amount-= delamount;
  7445. }
  7446. // notify target
  7447. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7448. clif_displaymessage(sd->fd, atcmd_output);
  7449. // notify source
  7450. if( amount == total )
  7451. {
  7452. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7453. }
  7454. else if( amount )
  7455. {
  7456. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7457. clif_displaymessage(fd, atcmd_output);
  7458. }
  7459. else
  7460. {
  7461. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7462. clif_displaymessage(fd, atcmd_output);
  7463. }
  7464. return 0;
  7465. }
  7466. /*==========================================
  7467. * Custom Fonts
  7468. *------------------------------------------*/
  7469. ACMD_FUNC(font)
  7470. {
  7471. int font_id;
  7472. nullpo_retr(-1,sd);
  7473. font_id = atoi(message);
  7474. if( font_id == 0 ) {
  7475. if( sd->status.font ) {
  7476. sd->status.font = 0;
  7477. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7478. clif_font(sd);
  7479. } else {
  7480. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7481. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7482. }
  7483. } else if( font_id < 0 || font_id > 9 )
  7484. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7485. else if( font_id != sd->status.font ) {
  7486. sd->status.font = font_id;
  7487. clif_font(sd);
  7488. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7489. } else
  7490. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7491. return 0;
  7492. }
  7493. /*==========================================
  7494. * type: 1 = commands (@), 2 = charcommands (#)
  7495. *------------------------------------------*/
  7496. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7497. {
  7498. char line_buff[CHATBOX_SIZE];
  7499. char* cur = line_buff;
  7500. AtCommandInfo* cmd;
  7501. DBIterator *iter = db_iterator(atcommand_db);
  7502. int count = 0;
  7503. memset(line_buff,' ',CHATBOX_SIZE);
  7504. line_buff[CHATBOX_SIZE-1] = 0;
  7505. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7506. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7507. unsigned int slen = 0;
  7508. switch( type ) {
  7509. case COMMAND_CHARCOMMAND:
  7510. if( cmd->char_groups[sd->group_pos] == 0 )
  7511. continue;
  7512. break;
  7513. case COMMAND_ATCOMMAND:
  7514. if( cmd->at_groups[sd->group_pos] == 0 )
  7515. continue;
  7516. break;
  7517. default:
  7518. continue;
  7519. }
  7520. slen = strlen(cmd->command);
  7521. // flush the text buffer if this command won't fit into it
  7522. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7523. clif_displaymessage(fd,line_buff);
  7524. cur = line_buff;
  7525. memset(line_buff,' ',CHATBOX_SIZE);
  7526. line_buff[CHATBOX_SIZE-1] = 0;
  7527. }
  7528. memcpy(cur,cmd->command,slen);
  7529. cur += slen+(10-slen%10);
  7530. count++;
  7531. }
  7532. dbi_destroy(iter);
  7533. clif_displaymessage(fd,line_buff);
  7534. if ( atcmd_binding_count ) {
  7535. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7536. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7537. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7538. unsigned int slen = strlen(atcmd_binding[i]->command);
  7539. if ( count_bind == 0 ) {
  7540. cur = line_buff;
  7541. memset(line_buff,' ',CHATBOX_SIZE);
  7542. line_buff[CHATBOX_SIZE-1] = 0;
  7543. clif_displaymessage(fd, "-----------------");
  7544. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7545. }
  7546. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7547. clif_displaymessage(fd,line_buff);
  7548. cur = line_buff;
  7549. memset(line_buff,' ',CHATBOX_SIZE);
  7550. line_buff[CHATBOX_SIZE-1] = 0;
  7551. }
  7552. memcpy(cur,atcmd_binding[i]->command,slen);
  7553. cur += slen+(10-slen%10);
  7554. count_bind++;
  7555. }
  7556. }
  7557. if ( count_bind )
  7558. clif_displaymessage(fd,line_buff);// last one
  7559. count += count_bind;
  7560. }
  7561. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7562. clif_displaymessage(fd, atcmd_output);
  7563. return;
  7564. }
  7565. /*==========================================
  7566. * @commands Lists available @ commands to you
  7567. *------------------------------------------*/
  7568. ACMD_FUNC(commands)
  7569. {
  7570. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7571. return 0;
  7572. }
  7573. /*==========================================
  7574. * @charcommands Lists available # commands to you
  7575. *------------------------------------------*/
  7576. ACMD_FUNC(charcommands) {
  7577. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7578. return 0;
  7579. }
  7580. /* for new mounts */
  7581. ACMD_FUNC(mount2) {
  7582. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7583. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7584. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7585. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7586. } else {
  7587. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7588. if (&sd->sc)
  7589. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7590. }
  7591. return 0;
  7592. }
  7593. ACMD_FUNC(accinfo) {
  7594. char query[NAME_LENGTH];
  7595. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7596. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7597. 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".
  7598. return -1;
  7599. }
  7600. //remove const type
  7601. safestrncpy(query, message, NAME_LENGTH);
  7602. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
  7603. return 0;
  7604. }
  7605. /* [Ind] */
  7606. ACMD_FUNC(set) {
  7607. char reg[32], val[128];
  7608. struct script_data* data;
  7609. int toset = 0, len;
  7610. bool is_str = false;
  7611. if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
  7612. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7613. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7614. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7615. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7616. return -1;
  7617. }
  7618. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7619. if( reg[0] == '.' ) {
  7620. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7621. return -1;
  7622. } else if( reg[0] == '\'' ) {
  7623. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7624. return -1;
  7625. }
  7626. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7627. if( ( len = strlen(val) ) > 1 ) {
  7628. if( val[0] == '"' && val[len-1] == '"') {
  7629. val[len-1] = '\0'; //Strip quotes.
  7630. memmove(val, val+1, len-1);
  7631. }
  7632. }
  7633. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7634. if( is_str )
  7635. set_var(sd, reg, (void*) val);
  7636. else
  7637. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7638. }
  7639. CREATE(data, struct script_data,1);
  7640. if( is_str ) {// string variable
  7641. switch( reg[0] ) {
  7642. case '@':
  7643. data->u.str = pc_readregstr(sd, add_str(reg));
  7644. break;
  7645. case '$':
  7646. data->u.str = mapreg_readregstr(add_str(reg));
  7647. break;
  7648. case '#':
  7649. if( reg[1] == '#' )
  7650. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7651. else
  7652. data->u.str = pc_readaccountregstr(sd, reg);// local
  7653. break;
  7654. default:
  7655. data->u.str = pc_readglobalreg_str(sd, reg);
  7656. break;
  7657. }
  7658. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7659. data->type = C_CONSTSTR;
  7660. data->u.str = "";
  7661. } else {// duplicate string
  7662. data->type = C_STR;
  7663. data->u.str = aStrdup(data->u.str);
  7664. }
  7665. } else {// integer variable
  7666. data->type = C_INT;
  7667. switch( reg[0] ) {
  7668. case '@':
  7669. data->u.num = pc_readreg(sd, add_str(reg));
  7670. break;
  7671. case '$':
  7672. data->u.num = mapreg_readreg(add_str(reg));
  7673. break;
  7674. case '#':
  7675. if( reg[1] == '#' )
  7676. data->u.num = pc_readaccountreg2(sd, reg);// global
  7677. else
  7678. data->u.num = pc_readaccountreg(sd, reg);// local
  7679. break;
  7680. default:
  7681. data->u.num = pc_readglobalreg(sd, reg);
  7682. break;
  7683. }
  7684. }
  7685. switch( data->type ) {
  7686. case C_INT:
  7687. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  7688. break;
  7689. case C_STR:
  7690. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  7691. break;
  7692. case C_CONSTSTR:
  7693. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7694. break;
  7695. default:
  7696. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  7697. break;
  7698. }
  7699. clif_displaymessage(fd, atcmd_output);
  7700. aFree(data);
  7701. return 0;
  7702. }
  7703. ACMD_FUNC(addperm) {
  7704. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7705. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7706. int i;
  7707. if( !message || !*message ) {
  7708. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7709. clif_displaymessage(fd, atcmd_output);
  7710. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7711. for( i = 0; i < perm_size; i++ ) {
  7712. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7713. clif_displaymessage(fd, atcmd_output);
  7714. }
  7715. return -1;
  7716. }
  7717. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7718. if( i == perm_size ) {
  7719. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7720. clif_displaymessage(fd, atcmd_output);
  7721. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7722. for( i = 0; i < perm_size; i++ ) {
  7723. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7724. clif_displaymessage(fd, atcmd_output);
  7725. }
  7726. return -1;
  7727. }
  7728. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7729. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7730. clif_displaymessage(fd, atcmd_output);
  7731. return -1;
  7732. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7733. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7734. clif_displaymessage(fd, atcmd_output);
  7735. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7736. clif_displaymessage(fd, atcmd_output);
  7737. for( i = 0; i < perm_size; i++ ) {
  7738. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7739. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7740. clif_displaymessage(fd, atcmd_output);
  7741. }
  7742. }
  7743. return -1;
  7744. }
  7745. if( add )
  7746. sd->permissions |= pc_g_permission_name[i].permission;
  7747. else
  7748. sd->permissions &=~ pc_g_permission_name[i].permission;
  7749. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7750. clif_displaymessage(fd, atcmd_output);
  7751. return 0;
  7752. }
  7753. ACMD_FUNC(unloadnpcfile) {
  7754. if( !message || !*message ) {
  7755. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7756. return -1;
  7757. }
  7758. if( npc_unloadfile(message) )
  7759. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7760. else {
  7761. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7762. return -1;
  7763. }
  7764. return 0;
  7765. }
  7766. ACMD_FUNC(cart) {
  7767. #define MC_CART_MDFY(x) \
  7768. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7769. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7770. sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7771. int val = atoi(message);
  7772. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7773. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7774. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7775. clif_displaymessage(fd, atcmd_output);
  7776. return -1;
  7777. }
  7778. if( val == 0 && !pc_iscarton(sd) ) {
  7779. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7780. return -1;
  7781. }
  7782. if( need_skill ) {
  7783. MC_CART_MDFY(1);
  7784. }
  7785. if( !pc_setcart(sd, val) ) {
  7786. if( need_skill ) {
  7787. MC_CART_MDFY(0);
  7788. }
  7789. return -1;/* @cart failed */
  7790. }
  7791. if( need_skill ) {
  7792. MC_CART_MDFY(0);
  7793. }
  7794. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7795. return 0;
  7796. #undef MC_CART_MDFY
  7797. }
  7798. /* Channel System [Ind] */
  7799. ACMD_FUNC(join){
  7800. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7801. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  7802. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7803. clif_displaymessage(fd, atcmd_output);
  7804. return -1;
  7805. }
  7806. return channel_pcjoin(sd, chname, pass);
  7807. }
  7808. /*
  7809. * Display available option for @channel command
  7810. * @command : the name of used command (for alias case)
  7811. */
  7812. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7813. {
  7814. int fd = sd->fd;
  7815. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7816. bool can_create = (can_delete || Channel_Config.user_chenable);
  7817. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7818. //option create
  7819. if( can_create ) {
  7820. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7821. clif_displaymessage(fd, atcmd_output);
  7822. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7823. }
  7824. //option delete
  7825. if(can_delete){
  7826. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7827. clif_displaymessage(fd, atcmd_output);
  7828. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7829. }
  7830. //option list
  7831. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7832. clif_displaymessage(fd, atcmd_output);
  7833. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7834. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7835. clif_displaymessage(fd, atcmd_output);
  7836. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7837. if( can_create ) {
  7838. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7839. clif_displaymessage(fd, atcmd_output);
  7840. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7841. }
  7842. //option setcolor
  7843. if(can_create){
  7844. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7845. clif_displaymessage(fd, atcmd_output);
  7846. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7847. }
  7848. //option join
  7849. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7850. clif_displaymessage(fd, atcmd_output);
  7851. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7852. //option leave
  7853. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7854. clif_displaymessage(fd, atcmd_output);
  7855. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7856. //option bindto
  7857. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7858. clif_displaymessage(fd, atcmd_output);
  7859. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7860. //option unbind
  7861. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7862. clif_displaymessage(fd, atcmd_output);
  7863. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7864. //option ban/unban/banlist
  7865. if( can_create ) {
  7866. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7867. clif_displaymessage(fd, atcmd_output);
  7868. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7869. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7870. clif_displaymessage(fd, atcmd_output);
  7871. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7872. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7873. clif_displaymessage(fd, atcmd_output);
  7874. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7875. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  7876. clif_displaymessage(fd, atcmd_output);
  7877. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  7878. }
  7879. //option setopt
  7880. if(can_create){
  7881. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  7882. clif_displaymessage(fd, atcmd_output);
  7883. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  7884. }
  7885. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  7886. clif_displaymessage(fd, atcmd_output);
  7887. }
  7888. ACMD_FUNC(channel) {
  7889. char key[CHAN_NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[CHAN_NAME_LENGTH], sub3[CHAN_NAME_LENGTH];
  7890. sub1[0] = sub2[0] = sub3[0] = '\0';
  7891. if( !message || !*message || sscanf(message, "%19s %19s %19s %19s", key, sub1, sub2, sub3) < 1 ) {
  7892. atcmd_channel_help(sd,command);
  7893. return 0;
  7894. }
  7895. if( strcmpi(key,"create") == 0 && ( Channel_Config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7896. if(sub3[0] != '\0'){
  7897. clif_displaymessage(fd, msg_txt(sd,1408)); // Channel password may not contain spaces.
  7898. return -1;
  7899. }
  7900. return channel_pccreate(sd,sub1,sub2);
  7901. } else if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7902. return channel_pcdelete(sd,sub1);
  7903. } else if ( strcmpi(key,"list") == 0 ) {
  7904. return channel_display_list(sd,sub1);
  7905. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7906. return channel_pccolor(sd, sub1, sub2);
  7907. } else if ( strcmpi(key,"join") == 0 ) {
  7908. return channel_pcjoin(sd, sub1, sub2);
  7909. }else if ( strcmpi(key,"leave") == 0 ) {
  7910. return channel_pcleave(sd, sub1);
  7911. } else if ( strcmpi(key,"bindto") == 0 ) {
  7912. return channel_pcbind(sd, sub1);
  7913. } else if ( strcmpi(key,"unbind") == 0 ) {
  7914. return channel_pcunbind(sd);
  7915. } else if ( strcmpi(key,"ban") == 0 ) {
  7916. return channel_pcban(sd,sub1,map_nick2sd(sub2),0);
  7917. } else if ( strcmpi(key,"banlist") == 0 ) {
  7918. return channel_pcban(sd,sub1,NULL,3);
  7919. } else if ( strcmpi(key,"unban") == 0 ) {
  7920. return channel_pcban(sd,sub1,map_nick2sd(sub2),1);
  7921. } else if ( strcmpi(key,"unbanall") == 0 ) {
  7922. return channel_pcban(sd,sub1,NULL,2);
  7923. } else if ( strcmpi(key,"setopt") == 0 ) {
  7924. return channel_pcsetopt(sd,sub1,sub2,sub3);
  7925. } else {
  7926. atcmd_channel_help(sd,command);
  7927. }
  7928. return 0;
  7929. }
  7930. ACMD_FUNC(fontcolor)
  7931. {
  7932. if( !message || !*message ) {
  7933. channel_display_list(sd,"colors");
  7934. return -1;
  7935. }
  7936. if( strcmpi(message,"Normal") == 0 ) {
  7937. sd->fontcolor = 0;
  7938. } else {
  7939. unsigned char k;
  7940. ARR_FIND(0,Channel_Config.colors_count,k,( strcmpi(message,Channel_Config.colors_name[k]) == 0 ));
  7941. if( k == Channel_Config.colors_count ) {
  7942. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  7943. clif_displaymessage(fd, atcmd_output);
  7944. return -1;
  7945. }
  7946. sd->fontcolor = k;
  7947. }
  7948. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  7949. clif_displaymessage(fd, atcmd_output);
  7950. return 0;
  7951. }
  7952. ACMD_FUNC(langtype)
  7953. {
  7954. char langstr[8];
  7955. int i=0, fail=0;
  7956. memset(langstr, '\0', sizeof(langstr));
  7957. if(sscanf(message, "%3s", langstr) >= 1){
  7958. int lang=0;
  7959. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  7960. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  7961. char output[100];
  7962. pc_setaccountreg(sd, "#langtype", lang); //For login/char
  7963. sd->langtype = lang;
  7964. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  7965. clif_displaymessage(fd,output);
  7966. return 0;
  7967. } else if (lang != -1) { //defined langage but failed check
  7968. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  7969. return -1;
  7970. }
  7971. }
  7972. //wrong or no entry
  7973. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  7974. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  7975. while(fail != -1){ //out of range
  7976. fail = msg_checklangtype(i,false);
  7977. if(fail == 1)
  7978. clif_displaymessage(fd,msg_langtype2langstr(i));
  7979. i++;
  7980. }
  7981. return -1;
  7982. }
  7983. #ifdef VIP_ENABLE
  7984. ACMD_FUNC(vip) {
  7985. struct map_session_data *pl_sd = NULL;
  7986. char * modif_p;
  7987. int32 vipdifftime = 0;
  7988. time_t now=time(NULL);
  7989. nullpo_retr(-1, sd);
  7990. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7991. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  7992. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  7993. return -1;
  7994. }
  7995. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  7996. modif_p = atcmd_output;
  7997. vipdifftime = (int32)solve_time(modif_p);
  7998. if (vipdifftime == 0) {
  7999. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8000. 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.
  8001. return -1;
  8002. }
  8003. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  8004. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8005. return -1;
  8006. }
  8007. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8008. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8009. return -1;
  8010. }
  8011. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8012. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8013. if (pl_sd->vip.time <= now) {
  8014. pl_sd->vip.time = 0;
  8015. pl_sd->vip.enabled = 0;
  8016. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8017. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8018. } else {
  8019. int year,month,day,hour,minute,second;
  8020. char timestr[21];
  8021. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8022. 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.
  8023. clif_displaymessage(pl_sd->fd,atcmd_output);
  8024. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8025. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8026. clif_displaymessage(pl_sd->fd,atcmd_output);
  8027. if (pl_sd != sd) {
  8028. 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.
  8029. clif_displaymessage(fd,atcmd_output);
  8030. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8031. clif_displaymessage(fd,atcmd_output);
  8032. }
  8033. }
  8034. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, 6, vipdifftime, 7, 0);
  8035. return 0;
  8036. }
  8037. /** Enable/disable rate info */
  8038. ACMD_FUNC(showrate) {
  8039. nullpo_retr(-1,sd);
  8040. if (!sd->disableshowrate) {
  8041. sprintf(atcmd_output,msg_txt(sd,718)); //Personal rate information is not displayed now.
  8042. sd->disableshowrate = 1;
  8043. }
  8044. else {
  8045. sprintf(atcmd_output,msg_txt(sd,719)); //Personal rate information will be shown.
  8046. sd->disableshowrate = 0;
  8047. }
  8048. clif_displaymessage(fd,atcmd_output);
  8049. return 0;
  8050. }
  8051. #endif
  8052. ACMD_FUNC(fullstrip) {
  8053. int i;
  8054. TBL_PC *tsd;
  8055. nullpo_retr(-1,sd);
  8056. if (!message || !*message) {
  8057. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8058. return -1;
  8059. }
  8060. if((tsd=map_nick2sd((char *)message)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){
  8061. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8062. return -1;
  8063. }
  8064. for( i = 0; i < EQI_MAX; i++ ) {
  8065. if( tsd->equip_index[ i ] >= 0 )
  8066. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8067. }
  8068. return 0;
  8069. }
  8070. ACMD_FUNC(costume) {
  8071. const char* names[] = {
  8072. "Wedding",
  8073. "Xmas",
  8074. "Summer",
  8075. "Hanbok",
  8076. "Oktoberfest",
  8077. };
  8078. const int name2id[] = {
  8079. SC_WEDDING,
  8080. SC_XMAS,
  8081. SC_SUMMER,
  8082. SC_HANBOK,
  8083. SC_OKTOBERFEST
  8084. };
  8085. unsigned short k = 0, len = ARRAYLENGTH(names);
  8086. if( !message || !*message ) {
  8087. for( k = 0; k < len; k++ ) {
  8088. if( sd->sc.data[name2id[k]] ) {
  8089. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8090. clif_displaymessage(sd->fd, atcmd_output);
  8091. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8092. return 0;
  8093. }
  8094. }
  8095. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8096. for( k = 0; k < len; k++ ) {
  8097. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8098. clif_displaymessage(sd->fd, atcmd_output);
  8099. }
  8100. return -1;
  8101. }
  8102. for( k = 0; k < len; k++ ) {
  8103. if( sd->sc.data[name2id[k]] ) {
  8104. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8105. clif_displaymessage(sd->fd, atcmd_output);
  8106. return -1;
  8107. }
  8108. }
  8109. for( k = 0; k < len; k++ )
  8110. if( strcmpi(message, names[k]) == 0 )
  8111. break;
  8112. if( k == len ) {
  8113. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8114. clif_displaymessage(sd->fd, atcmd_output);
  8115. return -1;
  8116. }
  8117. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, 0, -1);
  8118. return 0;
  8119. }
  8120. /**
  8121. * Clone other player's equipments
  8122. * Usage: @cloneequip <char_id or "char name">
  8123. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8124. * @author [Cydh], [Antares]
  8125. */
  8126. ACMD_FUNC(cloneequip) {
  8127. struct map_session_data *pl_sd;
  8128. int char_id = 0;
  8129. nullpo_retr(-1, sd);
  8130. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8131. if( !message || !*message || (sscanf(message, "%d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8132. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8133. return -1;
  8134. }
  8135. if (char_id)
  8136. pl_sd = map_charid2sd(char_id);
  8137. else
  8138. pl_sd = map_nick2sd(atcmd_output);
  8139. if (!pl_sd) {
  8140. clif_displaymessage(fd, msg_txt(sd, 3));
  8141. return -1;
  8142. }
  8143. if (sd == pl_sd) {
  8144. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8145. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8146. clif_displaymessage(fd, atcmd_output);
  8147. return -1;
  8148. }
  8149. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8150. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8151. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8152. clif_displaymessage(fd, atcmd_output);
  8153. return -1;
  8154. }
  8155. else {
  8156. int8 i;
  8157. for (i = 0; i < EQI_MAX; i++) {
  8158. int8 idx;
  8159. char flag = 0;
  8160. struct item tmp_item;
  8161. if ((idx = pl_sd->equip_index[i]) < 0)
  8162. continue;
  8163. if (i == EQI_AMMO)
  8164. continue;
  8165. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8166. continue;
  8167. tmp_item = pl_sd->status.inventory[idx];
  8168. if (itemdb_isspecial(tmp_item.card[0]))
  8169. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8170. tmp_item.bound = 0;
  8171. tmp_item.expire_time = 0;
  8172. tmp_item.unique_id = 0;
  8173. tmp_item.favorite = 0;
  8174. tmp_item.amount = 1;
  8175. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8176. clif_additem(sd, 0, 0, flag);
  8177. else
  8178. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8179. }
  8180. }
  8181. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8182. sprintf(atcmd_output, msg_txt(sd, 738), "status");
  8183. clif_displaymessage(fd, atcmd_output);
  8184. return 0;
  8185. }
  8186. /**
  8187. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8188. * Usage: @clonestat <char_id or "char name">
  8189. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8190. * @author [Cydh], [Antares]
  8191. */
  8192. ACMD_FUNC(clonestat) {
  8193. struct map_session_data *pl_sd;
  8194. int char_id = 0;
  8195. nullpo_retr(-1, sd);
  8196. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8197. if( !message || !*message || (sscanf(message, "%d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8198. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8199. return -1;
  8200. }
  8201. if (char_id)
  8202. pl_sd = map_charid2sd(char_id);
  8203. else
  8204. pl_sd = map_nick2sd(atcmd_output);
  8205. if (!pl_sd) {
  8206. clif_displaymessage(fd, msg_txt(sd, 3));
  8207. return -1;
  8208. }
  8209. if (sd == pl_sd) {
  8210. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8211. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8212. clif_displaymessage(fd, atcmd_output);
  8213. return -1;
  8214. }
  8215. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8216. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8217. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8218. clif_displaymessage(fd, atcmd_output);
  8219. return -1;
  8220. }
  8221. else {
  8222. uint8 i;
  8223. short max_status[6];
  8224. pc_resetstate(sd);
  8225. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8226. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8227. else {
  8228. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8229. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8230. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8231. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8232. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8233. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8234. }
  8235. #define clonestat_check(cmd,stat)\
  8236. {\
  8237. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8238. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8239. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8240. clif_displaymessage(fd, atcmd_output);\
  8241. sd->status.cmd = max_status[(stat)];\
  8242. }\
  8243. else\
  8244. sd->status.cmd = pl_sd->status.cmd;\
  8245. }
  8246. clonestat_check(str, PARAM_STR);
  8247. clonestat_check(agi, PARAM_AGI);
  8248. clonestat_check(vit, PARAM_VIT);
  8249. clonestat_check(int_, PARAM_INT);
  8250. clonestat_check(dex, PARAM_DEX);
  8251. clonestat_check(luk, PARAM_LUK);
  8252. for (i = 0; i < PARAM_MAX; i++) {
  8253. clif_updatestatus(sd, SP_STR + i);
  8254. clif_updatestatus(sd, SP_USTR + i);
  8255. }
  8256. status_calc_pc(sd, SCO_FORCE);
  8257. }
  8258. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8259. sprintf(atcmd_output, msg_txt(sd, 738), "status");
  8260. clif_displaymessage(fd, atcmd_output);
  8261. #undef clonestat_check
  8262. return 0;
  8263. }
  8264. #include "../custom/atcommand.inc"
  8265. /**
  8266. * Fills the reference of available commands in atcommand DBMap
  8267. **/
  8268. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8269. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8270. //define with restriction
  8271. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8272. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8273. void atcommand_basecommands(void) {
  8274. /**
  8275. * Command reference list, place the base of your commands here
  8276. * TODO : all restricted command are crashing case, please look into it
  8277. **/
  8278. AtCommandInfo atcommand_base[] = {
  8279. #include "../custom/atcommand_def.inc"
  8280. ACMD_DEF2R("warp", mapmove, 1),
  8281. ACMD_DEF(where),
  8282. ACMD_DEF(jumpto),
  8283. ACMD_DEF(jump),
  8284. ACMD_DEF(who),
  8285. ACMD_DEF2("who2", who),
  8286. ACMD_DEF2("who3", who),
  8287. ACMD_DEF2("whomap", who),
  8288. ACMD_DEF2("whomap2", who),
  8289. ACMD_DEF2("whomap3", who),
  8290. ACMD_DEF(whogm),
  8291. ACMD_DEF(save),
  8292. ACMD_DEF(load),
  8293. ACMD_DEF(speed),
  8294. ACMD_DEF(storage),
  8295. ACMD_DEF(guildstorage),
  8296. ACMD_DEF(option),
  8297. ACMD_DEF(hide), // + /hide
  8298. ACMD_DEFR(jobchange, 1),
  8299. ACMD_DEF(kill),
  8300. ACMD_DEF(alive),
  8301. ACMD_DEF(kami),
  8302. ACMD_DEF2("kamib", kami),
  8303. ACMD_DEF2("kamic", kami),
  8304. ACMD_DEF2("lkami", kami),
  8305. ACMD_DEF(heal),
  8306. ACMD_DEF(item),
  8307. ACMD_DEF(item2),
  8308. ACMD_DEF2("itembound",item),
  8309. ACMD_DEF2("itembound2",item2),
  8310. ACMD_DEF(itemreset),
  8311. ACMD_DEF(clearstorage),
  8312. ACMD_DEF(cleargstorage),
  8313. ACMD_DEF(clearcart),
  8314. ACMD_DEF2R("blvl", baselevelup, 1),
  8315. ACMD_DEF2("jlvl", joblevelup),
  8316. ACMD_DEF(help),
  8317. ACMD_DEF(pvpoff),
  8318. ACMD_DEF(pvpon),
  8319. ACMD_DEF(gvgoff),
  8320. ACMD_DEF(gvgon),
  8321. ACMD_DEF(model),
  8322. ACMD_DEFR(go, 1),
  8323. ACMD_DEF(monster),
  8324. ACMD_DEF2("monstersmall", monster),
  8325. ACMD_DEF2("monsterbig", monster),
  8326. ACMD_DEF(killmonster),
  8327. ACMD_DEF2("killmonster2", killmonster),
  8328. ACMD_DEF(refine),
  8329. ACMD_DEF(produce),
  8330. ACMD_DEF(memo),
  8331. ACMD_DEF(gat),
  8332. ACMD_DEF(displaystatus),
  8333. ACMD_DEF2("stpoint", statuspoint),
  8334. ACMD_DEF2("skpoint", skillpoint),
  8335. ACMD_DEF(zeny),
  8336. ACMD_DEF2("str", param),
  8337. ACMD_DEF2("agi", param),
  8338. ACMD_DEF2("vit", param),
  8339. ACMD_DEF2("int", param),
  8340. ACMD_DEF2("dex", param),
  8341. ACMD_DEF2("luk", param),
  8342. ACMD_DEF2("glvl", guildlevelup),
  8343. ACMD_DEF(makeegg),
  8344. ACMD_DEF(hatch),
  8345. ACMD_DEF(petfriendly),
  8346. ACMD_DEF(pethungry),
  8347. ACMD_DEF(petrename),
  8348. ACMD_DEF(recall), // + /recall
  8349. ACMD_DEF(night),
  8350. ACMD_DEF(day),
  8351. ACMD_DEF(doom),
  8352. ACMD_DEF(doommap),
  8353. ACMD_DEF(raise),
  8354. ACMD_DEF(raisemap),
  8355. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  8356. ACMD_DEF(kickall),
  8357. ACMD_DEF(allskill),
  8358. ACMD_DEF(questskill),
  8359. ACMD_DEF(lostskill),
  8360. ACMD_DEF(spiritball),
  8361. ACMD_DEF(party),
  8362. ACMD_DEF(guild),
  8363. ACMD_DEF(breakguild),
  8364. ACMD_DEF(agitstart),
  8365. ACMD_DEF(agitend),
  8366. ACMD_DEF(mapexit),
  8367. ACMD_DEF(idsearch),
  8368. ACMD_DEF(broadcast), // + /b and /nb
  8369. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8370. ACMD_DEF(recallall),
  8371. ACMD_DEFR(reload,2),
  8372. ACMD_DEF2("reloaditemdb", reload),
  8373. ACMD_DEF2("reloadmobdb", reload),
  8374. ACMD_DEF2("reloadskilldb", reload),
  8375. ACMD_DEF2R("reloadscript", reload,2),
  8376. ACMD_DEF2("reloadatcommand", reload),
  8377. ACMD_DEF2("reloadbattleconf", reload),
  8378. ACMD_DEF2("reloadstatusdb", reload),
  8379. ACMD_DEF2("reloadpcdb", reload),
  8380. ACMD_DEF2("reloadmotd", reload),
  8381. ACMD_DEF2("reloadquestdb", reload),
  8382. ACMD_DEF2("reloadmsgconf", reload),
  8383. ACMD_DEF2("reloadpacketdb", reload),
  8384. ACMD_DEF2("reloadinstancedb", reload),
  8385. ACMD_DEF(partysharelvl),
  8386. ACMD_DEF(mapinfo),
  8387. ACMD_DEF(dye),
  8388. ACMD_DEF2("hairstyle", hair_style),
  8389. ACMD_DEF2("haircolor", hair_color),
  8390. ACMD_DEF2("allstats", stat_all),
  8391. ACMD_DEF2("block", char_block),
  8392. ACMD_DEF2("ban", char_ban),
  8393. ACMD_DEF2("unblock", char_unblock),
  8394. ACMD_DEF2("unban", char_unban),
  8395. ACMD_DEF2("charban", char_ban),
  8396. ACMD_DEF2("charunban", char_unban),
  8397. ACMD_DEF2("mount", mount_peco),
  8398. ACMD_DEF(guildspy),
  8399. ACMD_DEF(partyspy),
  8400. ACMD_DEF(repairall),
  8401. ACMD_DEF(guildrecall),
  8402. ACMD_DEF(partyrecall),
  8403. ACMD_DEF(nuke),
  8404. ACMD_DEF(shownpc),
  8405. ACMD_DEF(hidenpc),
  8406. ACMD_DEF(loadnpc),
  8407. ACMD_DEF(unloadnpc),
  8408. ACMD_DEF2("time", servertime),
  8409. ACMD_DEF(jail),
  8410. ACMD_DEF(unjail),
  8411. ACMD_DEF(jailfor),
  8412. ACMD_DEF(jailtime),
  8413. ACMD_DEF(disguise),
  8414. ACMD_DEF(undisguise),
  8415. ACMD_DEF(email),
  8416. ACMD_DEF(effect),
  8417. ACMD_DEF(follow),
  8418. ACMD_DEF(addwarp),
  8419. ACMD_DEF(skillon),
  8420. ACMD_DEF(skilloff),
  8421. ACMD_DEF(killer),
  8422. ACMD_DEF(npcmove),
  8423. ACMD_DEF(killable),
  8424. ACMD_DEF(dropall),
  8425. ACMD_DEF(storeall),
  8426. ACMD_DEF(skillid),
  8427. ACMD_DEF(useskill),
  8428. ACMD_DEF(displayskill),
  8429. ACMD_DEF(snow),
  8430. ACMD_DEF(sakura),
  8431. ACMD_DEF(clouds),
  8432. ACMD_DEF(clouds2),
  8433. ACMD_DEF(fog),
  8434. ACMD_DEF(fireworks),
  8435. ACMD_DEF(leaves),
  8436. ACMD_DEF(summon),
  8437. ACMD_DEF(adjgroup),
  8438. ACMD_DEF(trade),
  8439. ACMD_DEF(send),
  8440. ACMD_DEF(setbattleflag),
  8441. ACMD_DEF(unmute),
  8442. ACMD_DEF(clearweather),
  8443. ACMD_DEF(uptime),
  8444. ACMD_DEF(changesex),
  8445. ACMD_DEF(mute),
  8446. ACMD_DEF(refresh),
  8447. ACMD_DEF(refreshall),
  8448. ACMD_DEF(identify),
  8449. ACMD_DEF(identifyall),
  8450. ACMD_DEF(gmotd),
  8451. ACMD_DEF(misceffect),
  8452. ACMD_DEF(mobsearch),
  8453. ACMD_DEF(cleanmap),
  8454. ACMD_DEF(cleanarea),
  8455. ACMD_DEF(npctalk),
  8456. ACMD_DEF(pettalk),
  8457. ACMD_DEF(users),
  8458. ACMD_DEF(reset),
  8459. ACMD_DEF(skilltree),
  8460. ACMD_DEF(marry),
  8461. ACMD_DEF(divorce),
  8462. ACMD_DEF(sound),
  8463. ACMD_DEF(undisguiseall),
  8464. ACMD_DEF(disguiseall),
  8465. ACMD_DEF(changelook),
  8466. ACMD_DEF(autoloot),
  8467. ACMD_DEF2("alootid", autolootitem),
  8468. ACMD_DEF(autoloottype),
  8469. ACMD_DEF(mobinfo),
  8470. ACMD_DEF(exp),
  8471. ACMD_DEF(version),
  8472. ACMD_DEF(mutearea),
  8473. ACMD_DEF(rates),
  8474. ACMD_DEF(iteminfo),
  8475. ACMD_DEF(whodrops),
  8476. ACMD_DEF(whereis),
  8477. ACMD_DEF(mapflag),
  8478. ACMD_DEF(me),
  8479. ACMD_DEF(monsterignore),
  8480. ACMD_DEF(fakename),
  8481. ACMD_DEF(size),
  8482. ACMD_DEF(showexp),
  8483. ACMD_DEF(showzeny),
  8484. ACMD_DEF(showdelay),
  8485. ACMD_DEF(autotrade),
  8486. ACMD_DEF(changegm),
  8487. ACMD_DEF(changeleader),
  8488. ACMD_DEF(partyoption),
  8489. ACMD_DEF(invite),
  8490. ACMD_DEF(duel),
  8491. ACMD_DEF(leave),
  8492. ACMD_DEF(accept),
  8493. ACMD_DEF(reject),
  8494. ACMD_DEF(clone),
  8495. ACMD_DEF2("slaveclone", clone),
  8496. ACMD_DEF2("evilclone", clone),
  8497. ACMD_DEF(tonpc),
  8498. ACMD_DEF(commands),
  8499. ACMD_DEF(noask),
  8500. ACMD_DEF(request),
  8501. ACMD_DEF(homlevel),
  8502. ACMD_DEF(homevolution),
  8503. ACMD_DEF(hommutate),
  8504. ACMD_DEF(makehomun),
  8505. ACMD_DEF(homfriendly),
  8506. ACMD_DEF(homhungry),
  8507. ACMD_DEF(homtalk),
  8508. ACMD_DEF(hominfo),
  8509. ACMD_DEF(homstats),
  8510. ACMD_DEF(homshuffle),
  8511. ACMD_DEF(showmobs),
  8512. ACMD_DEF(feelreset),
  8513. ACMD_DEF(auction),
  8514. ACMD_DEF(mail),
  8515. ACMD_DEF2("noks", ksprotection),
  8516. ACMD_DEF(allowks),
  8517. ACMD_DEF(cash),
  8518. ACMD_DEF2("points", cash),
  8519. ACMD_DEF(agitstart2),
  8520. ACMD_DEF(agitend2),
  8521. ACMD_DEF(resetskill),
  8522. ACMD_DEF(resetstat),
  8523. ACMD_DEF2("storagelist", itemlist),
  8524. ACMD_DEF2("cartlist", itemlist),
  8525. ACMD_DEF2("itemlist", itemlist),
  8526. ACMD_DEF(stats),
  8527. ACMD_DEF(delitem),
  8528. ACMD_DEF(charcommands),
  8529. ACMD_DEF(font),
  8530. ACMD_DEF(accinfo),
  8531. ACMD_DEF(set),
  8532. ACMD_DEF(undisguiseguild),
  8533. ACMD_DEF(disguiseguild),
  8534. ACMD_DEF(sizeall),
  8535. ACMD_DEF(sizeguild),
  8536. ACMD_DEF(addperm),
  8537. ACMD_DEF2("rmvperm", addperm),
  8538. ACMD_DEF(unloadnpcfile),
  8539. ACMD_DEF(cart),
  8540. ACMD_DEF(mount2),
  8541. ACMD_DEF(join),
  8542. ACMD_DEF(channel),
  8543. ACMD_DEF(fontcolor),
  8544. ACMD_DEF(langtype),
  8545. #ifdef VIP_ENABLE
  8546. ACMD_DEF(vip),
  8547. ACMD_DEF(showrate),
  8548. #endif
  8549. ACMD_DEF(fullstrip),
  8550. ACMD_DEF(costume),
  8551. ACMD_DEF(cloneequip),
  8552. ACMD_DEF(clonestat),
  8553. };
  8554. AtCommandInfo* atcommand;
  8555. int i;
  8556. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8557. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8558. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8559. continue;
  8560. }
  8561. CREATE(atcommand, AtCommandInfo, 1);
  8562. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8563. atcommand->func = atcommand_base[i].func;
  8564. atcommand->restriction = atcommand_base[i].restriction;
  8565. strdb_put(atcommand_db, atcommand->command, atcommand);
  8566. }
  8567. return;
  8568. }
  8569. /*==========================================
  8570. * Command lookup functions
  8571. *------------------------------------------*/
  8572. bool atcommand_exists(const char* name)
  8573. {
  8574. return strdb_exists(atcommand_db, name);
  8575. }
  8576. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8577. {
  8578. if (strdb_exists(atcommand_db, name))
  8579. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8580. return NULL;
  8581. }
  8582. static const char* atcommand_checkalias(const char *aliasname)
  8583. {
  8584. AliasInfo *alias_info = NULL;
  8585. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8586. return alias_info->command->command;
  8587. return aliasname;
  8588. }
  8589. /// AtCommand suggestion
  8590. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8591. DBIterator* atcommand_iter;
  8592. DBIterator* alias_iter;
  8593. AtCommandInfo* command_info = NULL;
  8594. AliasInfo* alias_info = NULL;
  8595. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8596. char* full_match[MAX_SUGGESTIONS];
  8597. char* suggestions[MAX_SUGGESTIONS];
  8598. char* match;
  8599. int prefix_count = 0, full_count = 0;
  8600. bool can_use;
  8601. if (!battle_config.atcommand_suggestions_enabled)
  8602. return;
  8603. atcommand_iter = db_iterator(atcommand_db);
  8604. alias_iter = db_iterator(atcommand_alias_db);
  8605. // Build the matches
  8606. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  8607. match = strstr(command_info->command, name);
  8608. can_use = pc_can_use_command(sd, command_info->command, type);
  8609. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8610. suggestions[prefix_count] = command_info->command;
  8611. ++prefix_count;
  8612. }
  8613. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8614. full_match[full_count] = command_info->command;
  8615. ++full_count;
  8616. }
  8617. }
  8618. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  8619. match = strstr(alias_info->alias, name);
  8620. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8621. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8622. suggestions[prefix_count] = alias_info->alias;
  8623. ++prefix_count;
  8624. }
  8625. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8626. full_match[full_count] = alias_info->alias;
  8627. ++full_count;
  8628. }
  8629. }
  8630. if ((full_count+prefix_count) > 0) {
  8631. char buffer[512];
  8632. int i;
  8633. // Merge full match and prefix match results
  8634. if (prefix_count < MAX_SUGGESTIONS) {
  8635. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8636. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8637. }
  8638. // Build the suggestion string
  8639. strcpy(buffer, msg_txt(sd,205));
  8640. strcat(buffer,"\n");
  8641. for(i=0; i < prefix_count; ++i) {
  8642. strcat(buffer,suggestions[i]);
  8643. strcat(buffer," ");
  8644. }
  8645. clif_displaymessage(sd->fd, buffer);
  8646. }
  8647. dbi_destroy(atcommand_iter);
  8648. dbi_destroy(alias_iter);
  8649. }
  8650. /*
  8651. * Executes an at-command
  8652. * \param type :
  8653. * 0 : script call (atcommand)
  8654. * 1 : normal player @atcommand
  8655. * 2 : console
  8656. * 3 : script call (useatcmd)
  8657. */
  8658. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8659. {
  8660. char charname[NAME_LENGTH], params[100];
  8661. char charname2[NAME_LENGTH];
  8662. char command[100];
  8663. char output[CHAT_SIZE_MAX];
  8664. //Reconstructed message
  8665. char atcmd_msg[CHAT_SIZE_MAX];
  8666. TBL_PC * ssd = NULL; //sd for target
  8667. AtCommandInfo * info;
  8668. nullpo_retr(false, sd);
  8669. //Shouldn't happen
  8670. if ( !message || !*message )
  8671. return false;
  8672. //If cannot use atcomamnd while talking with NPC [Kichi]
  8673. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8674. return false;
  8675. //Block NOCHAT but do not display it as a normal message
  8676. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8677. return true;
  8678. // skip 10/11-langtype's codepage indicator, if detected
  8679. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8680. message += 3;
  8681. //Should display as a normal message
  8682. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8683. return false;
  8684. // type value 0|2 = script|console invoked: bypass restrictions
  8685. if ( type == 1 || type == 3) {
  8686. //Commands are disabled on maps flagged as 'nocommand'
  8687. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8688. clif_displaymessage(fd, msg_txt(sd,143));
  8689. return false;
  8690. }
  8691. }
  8692. if (*message == charcommand_symbol) {
  8693. do {
  8694. int x, y, z;
  8695. char params2[100];
  8696. //Checks to see if #command has a name or a name + parameters.
  8697. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  8698. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  8699. //z always has the value of the scan that was successful
  8700. z = ( x > 1 ) ? x : y;
  8701. //#command + name means the sufficient target was used and anything else after
  8702. //can be looked at by the actual command function since most scan to see if the
  8703. //right parameters are used.
  8704. if ( x > 2 ) {
  8705. sprintf(atcmd_msg, "%s %s", command, params);
  8706. break;
  8707. }
  8708. else if ( y > 2 ) {
  8709. sprintf(atcmd_msg, "%s %s", command, params2);
  8710. break;
  8711. }
  8712. //Regardless of what style the #command is used, if it's correct, it will always have
  8713. //this value if there is no parameter. Send it as just the #command
  8714. else if ( z == 2 ) {
  8715. sprintf(atcmd_msg, "%s", command);
  8716. break;
  8717. }
  8718. if( !pc_get_group_level(sd) ) {
  8719. if( x >= 1 || y >= 1 ) { /* we have command */
  8720. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8721. 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 */
  8722. return false;
  8723. } else
  8724. return false;/* display as normal message */
  8725. }
  8726. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8727. clif_displaymessage(fd, output);
  8728. return true;
  8729. } while(0);
  8730. }
  8731. else if (*message == atcommand_symbol) {
  8732. //atcmd_msg is constructed above differently for charcommands
  8733. //it's copied from message if not a charcommand so it can
  8734. //pass through the rest of the code compatible with both symbols
  8735. sprintf(atcmd_msg, "%s", message);
  8736. }
  8737. //Clearing these to be used once more.
  8738. memset(command, '\0', sizeof(command));
  8739. memset(params, '\0', sizeof(params));
  8740. //check to see if any params exist within this command
  8741. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  8742. params[0] = '\0';
  8743. // @commands (script based)
  8744. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8745. struct atcmd_binding_data * binding;
  8746. // Check if the command initiated is a character command
  8747. if (*message == charcommand_symbol &&
  8748. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8749. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8750. clif_displaymessage(fd, output);
  8751. return true;
  8752. }
  8753. // Get atcommand binding
  8754. binding = get_atcommandbind_byname(command);
  8755. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8756. if( binding != NULL && binding->npc_event[0] &&
  8757. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8758. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8759. {
  8760. // Check if self or character invoking; if self == character invoked, then self invoke.
  8761. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8762. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8763. return true;
  8764. }
  8765. }
  8766. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8767. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8768. if (info == NULL) {
  8769. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8770. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8771. clif_displaymessage(fd, output);
  8772. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8773. return true;
  8774. } else
  8775. return false;
  8776. }
  8777. //check restriction
  8778. if(info->restriction){
  8779. if(info->restriction&1 && type == 2) //console prevent
  8780. return true;
  8781. if(info->restriction&2 && (type == 0 || type == 3) ) //scripts prevent
  8782. return true;
  8783. }
  8784. // type == 1 : player invoked
  8785. if (type == 1) {
  8786. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8787. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8788. return false;
  8789. }
  8790. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8791. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8792. return true;
  8793. }
  8794. }
  8795. // Check if target is valid only if confirmed that player can use command.
  8796. if (*message == charcommand_symbol &&
  8797. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8798. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8799. clif_displaymessage(fd, output);
  8800. return true;
  8801. }
  8802. //Attempt to use the command
  8803. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8804. {
  8805. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8806. clif_displaymessage(fd, output);
  8807. return true;
  8808. }
  8809. //Log only if successful.
  8810. if ( *atcmd_msg == atcommand_symbol )
  8811. log_atcommand(sd, atcmd_msg);
  8812. else if ( *atcmd_msg == charcommand_symbol )
  8813. log_atcommand(sd, message);
  8814. return true;
  8815. }
  8816. /*==========================================
  8817. *
  8818. *------------------------------------------*/
  8819. static void atcommand_config_read(const char* config_filename)
  8820. {
  8821. config_setting_t *aliases = NULL, *help = NULL;
  8822. const char *symbol = NULL;
  8823. int num_aliases = 0;
  8824. if (conf_read_file(&atcommand_config, config_filename))
  8825. return;
  8826. // Command symbols
  8827. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8828. if (ISPRINT(*symbol) && // no control characters
  8829. *symbol != '/' && // symbol of client commands
  8830. *symbol != '%' && // symbol of party chat
  8831. *symbol != '$' && // symbol of guild chat
  8832. *symbol != charcommand_symbol)
  8833. atcommand_symbol = *symbol;
  8834. }
  8835. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8836. if (ISPRINT(*symbol) && // no control characters
  8837. *symbol != '/' && // symbol of client commands
  8838. *symbol != '%' && // symbol of party chat
  8839. *symbol != '$' && // symbol of guild chat
  8840. *symbol != atcommand_symbol)
  8841. charcommand_symbol = *symbol;
  8842. }
  8843. // Command aliases
  8844. aliases = config_lookup(&atcommand_config, "aliases");
  8845. if (aliases != NULL) {
  8846. int i = 0;
  8847. int count = config_setting_length(aliases);
  8848. for (i = 0; i < count; ++i) {
  8849. config_setting_t *command;
  8850. const char *commandname = NULL;
  8851. int j = 0, alias_count = 0;
  8852. AtCommandInfo *commandinfo = NULL;
  8853. command = config_setting_get_elem(aliases, i);
  8854. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8855. continue;
  8856. commandname = config_setting_name(command);
  8857. if (!atcommand_exists(commandname)) {
  8858. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8859. continue;
  8860. }
  8861. commandinfo = get_atcommandinfo_byname(commandname);
  8862. alias_count = config_setting_length(command);
  8863. for (j = 0; j < alias_count; ++j) {
  8864. const char *alias = config_setting_get_string_elem(command, j);
  8865. if (alias != NULL) {
  8866. AliasInfo *alias_info;
  8867. if (strdb_exists(atcommand_alias_db, alias)) {
  8868. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8869. continue;
  8870. }
  8871. CREATE(alias_info, AliasInfo, 1);
  8872. alias_info->command = commandinfo;
  8873. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8874. strdb_put(atcommand_alias_db, alias, alias_info);
  8875. ++num_aliases;
  8876. }
  8877. }
  8878. }
  8879. }
  8880. // Commands help
  8881. // We only check if all commands exist
  8882. help = config_lookup(&atcommand_config, "help");
  8883. if (help != NULL) {
  8884. int count = config_setting_length(help);
  8885. int i;
  8886. for (i = 0; i < count; ++i) {
  8887. config_setting_t *command;
  8888. const char *commandname;
  8889. command = config_setting_get_elem(help, i);
  8890. commandname = config_setting_name(command);
  8891. if (!atcommand_exists(commandname))
  8892. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8893. }
  8894. }
  8895. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8896. return;
  8897. }
  8898. void atcommand_db_load_groups(int* group_ids) {
  8899. DBIterator *iter = db_iterator(atcommand_db);
  8900. AtCommandInfo* cmd;
  8901. int i;
  8902. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8903. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8904. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8905. for(i = 0; i < pc_group_max; i++) {
  8906. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8907. cmd->at_groups[i] = 1;
  8908. else
  8909. cmd->at_groups[i] = 0;
  8910. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8911. cmd->char_groups[i] = 1;
  8912. else
  8913. cmd->char_groups[i] = 0;
  8914. }
  8915. }
  8916. dbi_destroy(iter);
  8917. return;
  8918. }
  8919. void atcommand_db_clear(void) {
  8920. if (atcommand_db != NULL) {
  8921. DBIterator *iter = db_iterator(atcommand_db);
  8922. AtCommandInfo* cmd;
  8923. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8924. aFree(cmd->at_groups);
  8925. aFree(cmd->char_groups);
  8926. }
  8927. dbi_destroy(iter);
  8928. db_destroy(atcommand_db);
  8929. }
  8930. if (atcommand_alias_db != NULL)
  8931. db_destroy(atcommand_alias_db);
  8932. config_destroy(&atcommand_config);
  8933. }
  8934. void atcommand_doload(void) {
  8935. atcommand_db_clear();
  8936. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8937. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8938. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8939. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8940. }
  8941. void do_init_atcommand(void) {
  8942. atcommand_doload();
  8943. }
  8944. void do_final_atcommand(void) {
  8945. atcommand_db_clear();
  8946. }